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