ui/tokens.css from the server's dev (tokens.lock.json; repin to the beta tag at release). scripts/fetch-vendor.sh copies the server's vendored CodeMirror and Lezer modules into ui/vendor/, each checked against the server's own pin first, with the bare module names rewritten to sibling files (the page has no import map); vendor.lock.json records both hashes, and the script with no argument verifies the copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 lines
17 KiB
JavaScript
3 lines
17 KiB
JavaScript
/* esm.sh - @codemirror/lint@6.9.7 */
|
|
import{Decoration as T,showPanel as re,EditorView as E,ViewPlugin as ae,gutter as ce,showTooltip as fe,hoverTooltip as de,getPanel as ue,activateHover as U,logException as me,WidgetType as he,GutterMarker as ge}from"./cm-view.mjs";import{StateEffect as R,StateField as G,Facet as Z,combineConfig as X,RangeSet as j,RangeSetBuilder as pe}from"./cm-state.mjs";function k(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&typeof n=="object"&&n.nodeType==null&&!Array.isArray(n)){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var o=n[i];typeof o=="string"?t.setAttribute(i,o):o!=null&&(t[i]=o)}e++}for(;e<arguments.length;e++)_(t,arguments[e]);return t}function _(t,e){if(typeof e=="string")t.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)t.appendChild(e);else if(Array.isArray(e))for(var n=0;n<e.length;n++)_(t,e[n]);else throw new RangeError("Unsupported child node: "+e)}var L=class{constructor(e,n,i){this.from=e,this.to=n,this.diagnostic=i}},C=class t{constructor(e,n,i){this.diagnostics=e,this.panel=n,this.selected=i}static init(e,n,i){let o=i.facet(y).markerFilter;o&&(e=o(e,i));let s=e.slice().sort((h,b)=>h.from-b.from||h.to-b.to),r=new pe,l=[],c=0,a=i.doc.iter(),f=0,u=i.doc.length;for(let h=0;;){let b=h==s.length?null:s[h];if(!b&&!l.length)break;let w,g;if(l.length)w=c,g=l.reduce((d,x)=>Math.min(d,x.to),b&&b.from>w?b.from:1e8);else{if(w=b.from,w>u)break;g=b.to,l.push(b),h++}for(;h<s.length;){let d=s[h];if(d.from==w&&(d.to>d.from||d.to==w))l.push(d),h++,g=Math.min(d.to,g);else{g=Math.min(d.from,g);break}}g=Math.min(g,u);let P=!1;if(l.some(d=>d.from==w&&(d.to==g||g==u))&&(P=w==g,!P&&g-w<10)){let d=w-(f+a.value.length);d>0&&(a.next(d),f=w);for(let x=w;;){if(x>=g){P=!0;break}if(!a.lineBreak&&f+a.value.length>x)break;x=f+a.value.length,f+=a.value.length,a.next()}}let N=oe(l);if(P)r.add(w,w,T.widget({widget:new B(N),diagnostics:l.slice()}));else{let d=l.reduce((x,V)=>V.markClass?x+" "+V.markClass:x,"");r.add(w,g,T.mark({class:"cm-lintRange cm-lintRange-"+N+d,diagnostics:l.slice(),inclusiveEnd:l.some(x=>x.to>g)}))}if(c=g,c==u)break;for(let d=0;d<l.length;d++)l[d].to<=c&&l.splice(d--,1)}let m=r.finish();return new t(m,n,v(m))}};function v(t,e=null,n=0){let i=null;return t.between(n,1e9,(o,s,{spec:r})=>{if(!(e&&r.diagnostics.indexOf(e)<0))if(!i)i=new L(o,s,e||r.diagnostics[0]);else{if(r.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new L(i.from,s,i.diagnostic)}}),i}function W(t,e){let n=e.pos,i=e.end||n,o=t.state.facet(y).hideOn(t,n,i);if(o!=null)return o;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(r=>r.is(I))||t.changes.touchesRange(s.from,Math.max(s.to,i)))}function J(t,e){return t.field(p,!1)?e:e.concat(R.appendConfig.of(le))}function we(t,e){return{effects:J(t,[I.of(e)])}}var I=R.define(),z=R.define(),Q=R.define(),p=G.define({create(){return new C(T.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),i=null,o=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);i=v(n,t.selected.diagnostic,s)||v(n,null,s)}!n.size&&o&&e.state.facet(y).autoPanel&&(o=null),t=new C(n,o,i)}for(let n of e.effects)if(n.is(I)){let i=e.state.facet(y).autoPanel?n.value.length?S.open:null:t.panel;t=C.init(n.value,i,e.state)}else n.is(z)?t=new C(t.diagnostics,n.value?S.open:null,t.selected):n.is(Q)&&(t=new C(t.diagnostics,t.panel,n.value));return t},provide:t=>[re.from(t,e=>e.panel),E.decorations.from(t,e=>e.diagnostics)]});function Ie(t){let e=t.field(p,!1);return e?e.diagnostics.size:0}var be=T.mark({class:"cm-lintRange cm-lintRange-active"});function ke(t,e,n){let{diagnostics:i}=t.state.field(p),o,s=-1,r=-1;i.between(e-(n<0?1:0),e+(n>0?1:0),(c,a,{spec:f})=>{if(e>=c&&e<=a&&(c==a||(e>c||n>0)&&(e<a||n<0)))return o=f.diagnostics,s=c,r=a,!1});let l=t.state.facet(y).tooltipFilter;return o&&l&&(o=l(o,t.state)),o?{pos:s,end:r,above:!0,create(){return{dom:ee(t,o)}}}:null}function ee(t,e){return k("ul",{class:"cm-tooltip-lint"},e.map(n=>ne(t,n,!1)))}var xe=t=>{let e=t.state.field(p,!1);(!e||!e.panel)&&t.dispatch({effects:J(t.state,[z.of(!0)])});let n=ue(t,S.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},Y=t=>{let e=t.state.field(p,!1);return!e||!e.panel?!1:(t.dispatch({effects:z.of(!1)}),!0)},ye=t=>{let e=t.state.field(p,!1);if(!e)return!1;let n=t.state.selection.main,i=v(e.diagnostics,null,n.to+1);return!i&&(i=v(e.diagnostics,null,0),!i||i.from==n.from&&i.to==n.to)?!1:(t.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),U(t,i.from,1,{tooltip:K,until:o=>o.docChanged||o.newSelection.main.head<i.from||o.newSelection.main.head>i.to}),!0)},Oe=t=>{var e;let{state:n}=t,i=n.field(p,!1);if(!i)return!1;let o=n.selection.main,s,r,l,c;if(i.diagnostics.between(0,n.doc.length,(u,m)=>{m<o.to&&(s==null||s<u)&&(s=u,r=m),(l==null||u>l)&&(l=u,c=m)}),l==null||s==null&&l==o.from)return!1;let a=s??l,f=(e=r??c)!==null&&e!==void 0?e:a;return t.dispatch({selection:{anchor:a,head:f},scrollIntoView:!0}),U(t,a,1,{tooltip:K,until:u=>u.docChanged||u.newSelection.main.head<a||u.newSelection.main.head>f}),!0},Be=[{key:"Mod-Shift-m",run:xe,preventDefault:!0},{key:"F8",run:ye}],te=ae.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(y);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let t=Date.now();if(t<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-t);else{this.set=!1;let{state:e}=this.view,{sources:n}=e.facet(y);n.length&&ve(n.map(i=>Promise.resolve(i(this.view))),i=>{this.view.state.doc==e.doc&&this.view.dispatch(we(this.view.state,i.reduce((o,s)=>o.concat(s))))},i=>{me(this.view.state,i)})}}update(t){let e=t.state.facet(y);(t.docChanged||e!=t.startState.facet(y)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function ve(t,e,n){let i=[],o=-1;for(let s of t)s.then(r=>{i.push(r),clearTimeout(o),i.length==t.length?e(i):o=setTimeout(()=>e(i),200)},n)}var y=Z.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...X(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:q,tooltipFilter:q,needsRefresh:(e,n)=>e?n?i=>e(i)||n(i):e:n,hideOn:(e,n)=>e?n?(i,o,s)=>e(i,o,s)||n(i,o,s):e:n,autoPanel:(e,n)=>e||n})}}});function q(t,e){return t?e?(n,i)=>e(t(n,i),i):t:e}function He(t,e={}){return[y.of({source:t,config:e}),te,le]}function Ge(t){let e=t.plugin(te);e&&e.force()}function ie(t){let e=[];if(t)e:for(let{name:n}of t){for(let i=0;i<n.length;i++){let o=n[i];if(/[a-zA-Z]/.test(o)&&!e.some(s=>s.toLowerCase()==o.toLowerCase())){e.push(o);continue e}}e.push("")}return e}function ne(t,e,n){var i;let o=n?ie(e.actions):[];return k("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},k("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((s,r)=>{let l=!1,c=h=>{if(h.preventDefault(),l)return;l=!0;let b=v(t.state.field(p).diagnostics,e);b&&s.apply(t,b.from,b.to)},{name:a}=s,f=o[r]?a.indexOf(o[r]):-1,u=f<0?a:[a.slice(0,f),k("u",a.slice(f,f+1)),a.slice(f+1)],m=s.markClass?" "+s.markClass:"";return k("button",{type:"button",class:"cm-diagnosticAction"+m,onclick:c,onmousedown:c,"aria-label":` Action: ${a}${f<0?"":` (access key "${o[r]})"`}.`},u)}),e.source&&k("div",{class:"cm-diagnosticSource"},e.source))}var B=class extends he{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return k("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},M=class{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=ne(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},S=class t{constructor(e){this.view=e,this.items=[];let n=o=>{if(!(o.ctrlKey||o.altKey||o.metaKey)){if(o.keyCode==27)Y(this.view),this.view.focus();else if(o.keyCode==38||o.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(o.keyCode==40||o.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(o.keyCode==36)this.moveSelection(0);else if(o.keyCode==35)this.moveSelection(this.items.length-1);else if(o.keyCode==13)this.view.focus();else if(o.keyCode>=65&&o.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],r=ie(s.actions);for(let l=0;l<r.length;l++)if(r[l].toUpperCase().charCodeAt(0)==o.keyCode){let c=v(this.view.state.field(p).diagnostics,s);c&&s.actions[l].apply(e,c.from,c.to)}}else return;o.preventDefault()}},i=o=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(o.target)&&this.moveSelection(s)};this.list=k("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:i}),this.dom=k("div",{class:"cm-panel-lint"},this.list,k("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Y(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(p).selected;if(!e)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==e.diagnostic)return n;return-1}update(){let{diagnostics:e,selected:n}=this.view.state.field(p),i=0,o=!1,s=null,r=new Set;for(e.between(0,this.view.state.doc.length,(l,c,{spec:a})=>{for(let f of a.diagnostics){if(r.has(f))continue;r.add(f);let u=-1,m;for(let h=i;h<this.items.length;h++)if(this.items[h].diagnostic==f){u=h;break}u<0?(m=new M(this.view,f),this.items.splice(i,0,m),o=!0):(m=this.items[u],u>i&&(this.items.splice(i,u-i),o=!0)),n&&m.diagnostic==n.diagnostic?m.dom.hasAttribute("aria-selected")||(m.dom.setAttribute("aria-selected","true"),s=m):m.dom.hasAttribute("aria-selected")&&m.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)o=!0,this.items.pop();this.items.length==0&&(this.items.push(new M(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),o=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:c})=>{let a=c.height/this.list.offsetHeight;l.top<c.top?this.list.scrollTop-=(c.top-l.top)/a:l.bottom>c.bottom&&(this.list.scrollTop+=(l.bottom-c.bottom)/a)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),o&&this.sync()}sync(){let e=this.list.firstChild;function n(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)n();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(p),i=v(n.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Q.of(i)})}static open(e){return new t(e)}};function F(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function A(t){return F(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}var Ce=E.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:A("#f11")},".cm-lintRange-warning":{backgroundImage:A("orange")},".cm-lintRange-info":{backgroundImage:A("#999")},".cm-lintRange-hint":{backgroundImage:A("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function Te(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function oe(t){let e="hint",n=1;for(let i of t){let o=Te(i.severity);o>n&&(n=o,e=i.severity)}return e}var D=class extends ge{constructor(e){super(),this.diagnostics=e,this.severity=oe(e)}toDOM(e){let n=document.createElement("div");n.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,o=e.state.facet(O).tooltipFilter;return o&&(i=o(i,e.state)),i.length&&(n.onmouseover=()=>Re(e,n,i)),n}};function Se(t,e){let n=i=>{let o=e.getBoundingClientRect();if(!(i.clientX>o.left-10&&i.clientX<o.right+10&&i.clientY>o.top-10&&i.clientY<o.bottom+10)){for(let s=i.target;s;s=s.parentNode)if(s.nodeType==1&&s.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",n),t.state.field(se)&&t.dispatch({effects:$.of(null)})}};window.addEventListener("mousemove",n)}function Re(t,e,n){function i(){let r=t.elementAtHeight(e.getBoundingClientRect().top+5-t.documentTop);t.coordsAtPos(r.from)&&t.dispatch({effects:$.of({pos:r.from,above:!1,clip:!1,create(){return{dom:ee(t,n),getCoords:()=>e.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,Se(t,e)}let{hoverTime:o}=t.state.facet(O),s=setTimeout(i,o);e.onmouseout=()=>{clearTimeout(s),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(s),s=setTimeout(i,o)}}function Pe(t,e){let n=Object.create(null);for(let o of e){let s=t.lineAt(o.from);(n[s.from]||(n[s.from]=[])).push(o)}let i=[];for(let o in n)i.push(new D(n[o]).range(+o));return j.of(i,!0)}var Ae=ce({class:"cm-gutter-lint",markers:t=>t.state.field(H),widgetMarker:(t,e,n)=>{let i=[];return t.state.field(H).between(n.from,n.to,(o,s,r)=>{o>n.from&&o<n.to&&i.push(...r.diagnostics)}),i.length?new D(i):null}}),H=G.define({create(){return j.empty},update(t,e){t=t.map(e.changes);let n=e.state.facet(O).markerFilter;for(let i of e.effects)if(i.is(I)){let o=i.value;n&&(o=n(o||[],e.state)),t=Pe(e.state.doc,o.slice(0))}return t}}),$=R.define(),se=G.define({create(){return null},update(t,e){return t&&e.docChanged&&(t=W(e,t)?null:{...t,pos:e.changes.mapPos(t.pos)}),e.effects.reduce((n,i)=>i.is($)?i.value:n,t)},provide:t=>fe.from(t)}),Fe=E.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:F('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:F('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:F('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),K=de(ke,{hideOn:W}),le=[p,E.decorations.compute([p],t=>{let{selected:e,panel:n}=t.field(p);return!e||!n||e.from==e.to?T.none:T.set([be.range(e.from,e.to)])}),K,Ce],O=Z.define({combine(t){return X(t,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function je(t={}){return[O.of(t),H,Ae,Fe,se]}function ze(t,e){let n=t.field(p,!1);if(n&&n.diagnostics.size){let i=[],o=[],s=-1;for(let r=j.iter([n.diagnostics]);;r.next()){for(let l=0;l<i.length;l++)(!r.value||r.value.spec.diagnostics.indexOf(i[l])<0)&&(e(i[l],o[l],s),i.splice(l,1),o.splice(l--,1));if(!r.value)break;for(let l of r.value.spec.diagnostics)i.indexOf(l)<0&&(i.push(l),o.push(r.from));s=r.to}}}export{Y as closeLintPanel,Ie as diagnosticCount,ze as forEachDiagnostic,Ge as forceLinting,je as lintGutter,Be as lintKeymap,He as linter,ye as nextDiagnostic,xe as openLintPanel,Oe as previousDiagnostic,we as setDiagnostics,I as setDiagnosticsEffect};
|
|
//# sourceMappingURL=lint.bundle.mjs.map
|