4 lines
33 KiB
JavaScript
4 lines
33 KiB
JavaScript
|
|
import{N as b,T as d,I as re,P as pe,b as W,c as qe,d as E}from"./vendor-lezer-common-tVQBIsvN.js";import{P as Ge,F as v,l as O,m as me,b as Z,S as U,e as ge,h as Je,R as Ke}from"./cm-state-X9WpHEQO.js";import{E as y,V as _,D as g,b as Qe,G as Xe,l as Ye,W as ke,a as se}from"./cm-view-CiSFjroV.js";import{a as Ze,h as _e,t as f,s as et}from"./vendor-lezer-highlight-DuEf3ZFH.js";import{S as ie}from"./vendor-style-mod-Bs6eFhZE.js";var j;const P=new b;function be(n){return v.define({combine:n?e=>e.concat(n):void 0})}const tt=new b;class m{constructor(e,t,r=[],s=""){this.data=e,this.name=s,O.prototype.hasOwnProperty("tree")||Object.defineProperty(O.prototype,"tree",{get(){return w(this)}}),this.parser=t,this.extension=[S.of(this),O.languageData.of((i,o,l)=>{let a=oe(i,o,l),h=a.type.prop(P);if(!h)return[];let u=i.facet(h),c=a.type.prop(tt);if(c){let k=a.resolve(o-a.from,l);for(let p of c)if(p.test(k,i)){let x=i.facet(p.facet);return p.type=="replace"?x:x.concat(u)}}return u})].concat(r)}isActiveAt(e,t,r=-1){return oe(e,t,r).type.prop(P)==this.data}findRegions(e){let t=e.facet(S);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let r=[],s=(i,o)=>{if(i.prop(P)==this.data){r.push({from:o,to:o+i.length});return}let l=i.prop(b.mounted);if(l){if(l.tree.prop(P)==this.data){if(l.overlay)for(let a of l.overlay)r.push({from:a.from+o,to:a.to+o});else r.push({from:o,to:o+i.length});return}else if(l.overlay){let a=r.length;if(s(l.tree,l.overlay[0].from+o),r.length>a)return}}for(let a=0;a<i.children.length;a++){let h=i.children[a];h instanceof d&&s(h,i.positions[a]+o)}};return s(w(e),0),r}get allowsNesting(){return!0}}m.setState=U.define();function oe(n,e,t){let r=n.facet(S),s=w(n).topNode;if(!r||r.allowsNesting)for(let i=s;i;i=i.enter(e,t,re.ExcludeBuffers|re.EnterBracketed))i.type.isTop&&(s=i);return s}class K extends m{constructor(e,t,r){super(e,t,[],r),this.parser=t}static define(e){let t=be(e.languageData);return new K(t,e.parser.configure({props:[P.add(r=>r.isTop?t:void 0)]}),e.name)}configure(e,t){return new K(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function w(n){let e=n.field(m.state,!1);return e?e.tree:d.empty}class nt{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let r=this.cursorPos-this.string.length;return e<r||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-r,t-r)}}let D=null;class A{constructor(e,t,r=[],s,i,o,l,a){this.parser=e,this.state=t,this.fragments=r,this.tree=s,this.treeLen=i,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,r){return new A(e,t,[],d.empty,0,r,[],null)}startParse(){return this.parser.startParse(new nt(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=d.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(E.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(E.addTree(this.tree,this.fragments,!
|
||
|
|
`&&(t="");else{let r=t.indexOf(`
|
||
|
|
`);r>-1&&(t=t.slice(0,r))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),r=e+t.length;for(let s=this.rangeIndex;;){let i=this.ranges[s].to;if(i>=r||(t=t.slice(0,i-(r-t.length)),s++,s==this.ranges.length))break;let o=this.ranges[s].from,l=this.lineAfter(o);t+=l,r=o+l.length}return{line:t,end:r}}skipGapsTo(e,t,r){for(;;){let s=this.ranges[this.rangeIndex].to,i=e+t;if(r>0?s>i:s>=i)break;let o=this.ranges[++this.rangeIndex].from;t+=o-s}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,r,s){let i=4;if(this.ranges.length>1){s=this.skipGapsTo(t,s,1),t+=s;let l=this.chunk.length;s=this.skipGapsTo(r,s,-1),r+=s,i+=this.chunk.length-l}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&i==4&&o>=0&&this.chunk[o]==e&&this.chunk[o+2]==t?this.chunk[o+2]=r:this.chunk.push(e,t,r,i),s}parseLine(e){let{line:t,end:r}=this.nextLine(),s=0,{streamParser:i}=this.lang,o=new Re(t,e?e.state.tabSize:4,e?F(e.state):2);if(o.eol())i.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let l=He(i.token,o,this.state);if(l&&(s=this.emitToken(this.lang.tokenTable.resolve(l),this.parsedPos+o.start,this.parsedPos+o.pos,s)),o.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=d.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:$t,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new d(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new d(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function He(n,e,t){e.start=e.pos;for(let r=0;r<10;r++){let s=n(e,t);if(e.pos>e.start)return s}throw new Error("Stream parser failed to advance stream.")}const ne=Object.create(null),N=[W.none],$t=new qe(N),ce=[],de=Object.create(null),Ve=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Ve[n]=je(ne,e);class $e{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Ve)}resolve(e){return e?this.table[e]||(this.table[e]=je(this.extra,e)):0}}const jt=new $e(ne);function J(n,e){ce.indexOf(n)>-1||(ce.push(n),console.warn(e))}function je(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let u=n[h]||f[h];u?typeof u=="function"?a.length?a=a.map(u):J(h,`Modifier ${h} used at start of tag`):a.length?J(h,`Tag ${h} used as modifier`):a=Array.isArray(u)?u:[u]:J(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+t.map(l=>l.id),i=de[s];if(i)return i.id;let o=de[s]=W.define({id:N.length,name:r,props:[et({[r]:t})]});return N.push(o),o.id}function zt(n,e){let t=W.define({id:N.length,name:"Document",props:[P.add(()=>n),Pe.add(()=>r=>e.getIndent(r))],top:!0});return N.push(t),t}se.RTL,se.LTR;export{V as H,Se as I,K as L,A as P,We as S,it as a,F as b,Yt as c,Pe as d,en as e,mt as f,ot as g,Zt as h,ve as i,_t as j,nn as k,Ft as l,B as m,tt as n,be as o,m as p,pt as q,P as r,w as s,ye as t,on as u,sn as v,tn as w,ln as x,an as y,rn as z};
|