14 lines
131 KiB
JavaScript
14 lines
131 KiB
JavaScript
|
import{S as me,i as Te,s as Se,e as be,f as Pe,N as SO,g as Re,y as bO,o as xe,J as ke,L as Xe,M as ye}from"./index.5e335c1b.js";import{P as Ze,N as We,u as je,D as we,v as lO,T as Y,I as KO,w as QO,x as o,y as _e,L as cO,z as uO,A as V,B as dO,F as HO,G as $O,H as z,J as ve,K as qe,E as X,M as q,O as ze,Q as Ge,R as T,U as Ce,a as w,h as Ue,b as Ye,c as Ve,d as Ee,e as Ie,s as Ae,f as Ne,g as De,i as Le,r as Fe,j as Je,k as Me,l as Be,m as Ke,n as He,o as Ot,p as et,q as tt,t as PO,C as G}from"./index.a9121ab1.js";class N{constructor(O,e,a,i,r,s,n,Q,u,d=0,l){this.p=O,this.stack=e,this.state=a,this.reducePos=i,this.pos=r,this.score=s,this.buffer=n,this.bufferBase=Q,this.curContext=u,this.lookAhead=d,this.parent=l}toString(){return`[${this.stack.filter((O,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(O,e,a=0){let i=O.parser.context;return new N(O,[],e,a,a,0,[],0,i?new RO(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(O,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=O}reduce(O){let e=O>>19,a=O&65535,{parser:i}=this.p,r=i.dynamicPrecedence(a);if(r&&(this.score+=r),e==0){this.pushState(i.getGoto(this.state,a,!0),this.reducePos),a<i.minRepeatTerm&&this.storeNode(a,this.reducePos,this.reducePos,4,!0),this.reduceContext(a,this.reducePos);return}let s=this.stack.length-(e-1)*3-(O&262144?6:0),n=this.stack[s-2],Q=this.stack[s-1],u=this.bufferBase+this.buffer.length-Q;if(a<i.minRepeatTerm||O&131072){let d=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(a,n,d,u+4,!0)}if(O&262144)this.state=this.stack[s];else{let d=this.stack[s-3];this.state=i.getGoto(d,a,!0)}for(;this.stack.length>s;)this.stack.pop();this.reduceContext(a,n)}storeNode(O,e,a,i=4,r=!1){if(O==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let s=this,n=this.buffer.length;if(n==0&&s.parent&&(n=s.bufferBase-s.parent.bufferBase,s=s.parent),n>0&&s.buffer[n-4]==0&&s.buffer[n-1]>-1){if(e==a)return;if(s.buffer[n-2]>=e){s.buffer[n-2]=a;return}}}if(!r||this.pos==a)this.buffer.push(O,e,a,i);else{let s=this.buffer.length;if(s>0&&this.buffer[s-4]!=0)for(;s>0&&this.buffer[s-2]>a;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,i>4&&(i-=4);this.buffer[s]=O,this.buffer[s+1]=e,this.buffer[s+2]=a,this.buffer[s+3]=i}}shift(O,e,a){let i=this.pos;if(O&131072)this.pushState(O&65535,this.pos);else if((O&262144)==0){let r=O,{parser:s}=this.p;(a>this.pos||e<=s.maxNode)&&(this.pos=a,s.stateFlag(r,1)||(this.reducePos=a)),this.pushState(r,i),this.shiftContext(e,i),e<=s.maxNode&&this.buffer.push(e,i,a,4)}else this.pos=a,this.shiftContext(e,i),e<=this.p.parser.maxNode&&this.buffer.push(e,i,a,4)}apply(O,e,a){O&65536?this.reduce(O):this.shift(O,e,a)}useNode(O,e){let a=this.p.reused.length-1;(a<0||this.p.reused[a]!=O)&&(this.p.reused.push(O),a++);let i=this.pos;this.reducePos=this.pos=i+O.length,this.pushState(e,i),this.buffer.push(a,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,O,this,this.p.stream.reset(this.pos-O.length)))}split(){let O=this,e=O.buffer.length;for(;e>0&&O.buffer[e-2]>O.reducePos;)e-=4;let a=O.buffer.slice(e),i=O.bufferBase+e;for(;O&&i==O.bufferBase;)O=O.parent;return new N(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,a,i,this.curContext,this.lookAhead,O)}recoverByDelete(O,e){let a=O<=this.p.parser.maxNode;a&&this.storeNode(O,this.pos,e,4),this.storeNode(0,this.pos,e,a?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(O){for(let e=new at(this);;){let a=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,O);if((a&65536)==0)return!0;if(a==0)return!1;e.reduce(a)}}recoverByInsert(O){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>4<<1||this.stack.length>=120){let i=[];for(let r=0,s;r<e.length;r+=2)(s=e[r+1])!=this.state&&this.p.parser.hasAction(s,O)&&i.push
|
||
|
\${}
|
||
|
} catch (\${error}) {
|
||
|
\${}
|
||
|
}`,{label:"try",detail:"/ catch block",type:"keyword"}),T("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),T(`if (\${}) {
|
||
|
\${}
|
||
|
} else {
|
||
|
\${}
|
||
|
}`,{label:"if",detail:"/ else block",type:"keyword"}),T(`class \${name} {
|
||
|
constructor(\${params}) {
|
||
|
\${}
|
||
|
}
|
||
|
}`,{label:"class",detail:"definition",type:"keyword"}),T('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),T('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],LO=new Ce,ue=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function _(t){return(O,e)=>{let a=O.node.getChild("VariableDefinition");return a&&e(a,t),!0}}const Va=["FunctionDeclaration"],Ea={FunctionDeclaration:_("function"),ClassDeclaration:_("class"),ClassExpression:()=>!0,EnumDeclaration:_("constant"),TypeAliasDeclaration:_("type"),NamespaceDeclaration:_("namespace"),VariableDefinition(t,O){t.matchContext(Va)||O(t,"variable")},TypeDefinition(t,O){O(t,"type")},__proto__:null};function de(t,O){let e=LO.get(O);if(e)return e;let a=[],i=!0;function r(s,n){let Q=t.sliceString(s.from,s.to);a.push({label:Q,type:n})}return O.cursor(KO.IncludeAnonymous).iterate(s=>{if(i)i=!1;else if(s.name){let n=Ea[s.name];if(n&&n(s,r)||ue.has(s.name))return!1}else if(s.to-s.from>8192){for(let n of de(t,s.node))a.push(n);return!1}}),LO.set(O,a),a}const FO=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,$e=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName"];function Ia(t){let O=z(t.state).resolveInner(t.pos,-1);if($e.indexOf(O.name)>-1)return null;let e=O.name=="VariableName"||O.to-O.from<20&&FO.test(t.state.sliceDoc(O.from,O.to));if(!e&&!t.explicit)return null;let a=[];for(let i=O;i;i=i.parent)ue.has(i.name)&&(a=a.concat(de(t.state.doc,i)));return{options:a,from:e?O.from:t.pos,validFor:FO}}const k=cO.define({parser:Ua.configure({props:[uO.add({IfStatement:V({except:/^\s*({|else\b)/}),TryStatement:V({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:ze,SwitchBody:t=>{let O=t.textAfter,e=/^\s*\}/.test(O),a=/^\s*(case|default)\b/.test(O);return t.baseIndent+(e?0:a?1:2)*t.unit},Block:Ge({closing:"}"}),ArrowFunction:t=>t.baseIndent+t.unit,"TemplateString BlockComment":()=>null,"Statement Property":V({except:/^{/}),JSXElement(t){let O=/^\s*<\//.test(t.textAfter);return t.lineIndent(t.node.from)+(O?0:t.unit)},JSXEscape(t){let O=/\s*\}/.test(t.textAfter);return t.lineIndent(t.node.from)+(O?0:t.unit)},"JSXOpenTag JSXSelfClosingTag"(t){return t.column(t.node.from)+t.unit}}),dO.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression":HO,BlockComment(t){return{from:t.from+2,to:t.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),Aa=k.configure({dialect:"ts"}),Na=k.configure({dialect:"jsx"}),Da=k.configure({dialect:"jsx ts"}),La="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(t=>({label:t,type:"keyword"}));function he(t={}){let O=t.jsx?t.typescript?Da:Na:t.typescript?Aa:k;return new $O(O,[k.data.of({autocomplete:ve($e,qe(Ya.concat(La)))}),k.data.of({autocomplete:Ia}),t.jsx?Ja:[]])}function JO(t,O,e=t.length){if(!O)return"";let a=O.getChild("JSXIdentifier");return a?t.sliceString(a.from,Math.min(a.to,e)):""}const Fa=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Ja=X.inputHandler.of((t,O,e,a)=>{if((Fa?t.composing:t.compositionStarted)||t.state.readOnly||O!=e||a!=">"&&a!="/"||!k.isActiveAt(t.state,O,-1))return!1;let{state:i}=t,r=i.changeByRange(s=>{var n,Q,u;let{head:d}=s,l=z(i).resolveInner(d,-1),$;if(l.name=="JSXStartTag"&&(l=l.parent),a==">"&&l.name=="JSXFragmentTag")return{range:q.cursor(d+1),changes:{from:d,insert:"><>"}};if(a==">"&&l.name=="JSXIdentifier"){if(((Q=(n=l.parent)===null||n===void 0?void 0:n.lastChild)===null||Q===void 0?void 0:Q.name)!="JSXEndTag"&&($=JO(i.doc,l.parent,d)))return{range:q.cursor(d+1),changes:{from:d,insert:`></${$}>`}}}else if(a=="/"&&l.name=="JSXFragmentTag"){let h=l.parent,
|