2022-12-31 01:21:41 +01:00
|
|
|
import{S as _e,i as xe,s as Ue,e as Ve,f as ke,T as bO,g as Re,y as TO,o as we,K as je,L as ve,M as We}from"./index.b8a14a87.js";import{P as Ge,N as Ce,u as Ye,D as ze,v as QO,T as Y,I as HO,w as cO,x as n,y as Ae,L as hO,z as uO,A as z,B as dO,F as Oe,G as pO,H as v,J as Ee,K as De,E as y,M as j,O as Ie,Q as Ne,R as m,U as Be,a as k,h as Je,b as Le,c as Me,d as Fe,e as Ke,s as He,f as Ot,g as et,i as tt,r as at,j as it,k as rt,l as st,m as lt,n as nt,o as ot,p as Qt,q as ct,t as XO,C as W}from"./index.e8a8986f.js";class N{constructor(O,t,a,i,r,s,l,Q,c,h=0,o){this.p=O,this.stack=t,this.state=a,this.reducePos=i,this.pos=r,this.score=s,this.buffer=l,this.bufferBase=Q,this.curContext=c,this.lookAhead=h,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 N(O,[],t,a,a,0,[],0,i?new ZO(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 s=this.stack.length-(t-1)*3-(O&262144?6:0),l=this.stack[s-2],Q=this.stack[s-1],c=this.bufferBase+this.buffer.length-Q;if(a<i.minRepeatTerm||O&131072){let h=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(a,l,h,c+4,!0)}if(O&262144)this.state=this.stack[s];else{let h=this.stack[s-3];this.state=i.getGoto(h,a,!0)}for(;this.stack.length>s;)this.stack.pop();this.reduceContext(a,l)}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 s=this,l=this.buffer.length;if(l==0&&s.parent&&(l=s.bufferBase-s.parent.bufferBase,s=s.parent),l>0&&s.buffer[l-4]==0&&s.buffer[l-1]>-1){if(t==a)return;if(s.buffer[l-2]>=t){s.buffer[l-2]=a;return}}}if(!r||this.pos==a)this.buffer.push(O,t,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]=t,this.buffer[s+2]=a,this.buffer[s+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:s}=this.p;(a>this.pos||t<=s.maxNode)&&(this.pos=a,s.stateFlag(r,1)||(this.reducePos=a)),this.pushState(r,i),this.shiftContext(t,i),t<=s.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 N(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 ht(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,s;r<t.length;r+=2)(s=t[r+1])!=this.state&&this.p.parser.hasAction(s,O)&&i.push
|
|
|
|
}`,{label:"class",detail:"definition",type:"keyword"}),m('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),m('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],JO=new Be,$e=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function R(e){return(O,t)=>{let a=O.node.getChild("VariableDefinition");return a&&t(a,e),!0}}const Fa=["FunctionDeclaration"],Ka={FunctionDeclaration:R("function"),ClassDeclaration:R("class"),ClassExpression:()=>!0,EnumDeclaration:R("constant"),TypeAliasDeclaration:R("type"),NamespaceDeclaration:R("namespace"),VariableDefinition(e,O){e.matchContext(Fa)||O(e,"variable")},TypeDefinition(e,O){O(e,"type")},__proto__:null};function fe(e,O){let t=JO.get(O);if(t)return t;let a=[],i=!0;function r(s,l){let Q=e.sliceString(s.from,s.to);a.push({label:Q,type:l})}return O.cursor(HO.IncludeAnonymous).iterate(s=>{if(i)i=!1;else if(s.name){let l=Ka[s.name];if(l&&l(s,r)||$e.has(s.name))return!1}else if(s.to-s.from>8192){for(let l of fe(e,s.node))a.push(l);return!1}}),JO.set(O,a),a}const LO=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,Se=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName"];function Ha(e){let O=v(e.state).resolveInner(e.pos,-1);if(Se.indexOf(O.name)>-1)return null;let t=O.name=="VariableName"||O.to-O.from<20&&LO.test(e.state.sliceDoc(O.from,O.to));if(!t&&!e.explicit)return null;let a=[];for(let i=O;i;i=i.parent)$e.has(i.name)&&(a=a.concat(fe(e.state.doc,i)));return{options:a,from:t?O.from:e.pos,validFor:LO}}const Z=hO.define({name:"javascript",parser:La.configure({props:[uO.add({IfStatement:z({except:/^\s*({|else\b)/}),TryStatement:z({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Ie,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:Ne({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}}),dO.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression":Oe,BlockComment(e){return{from:e.from+2,to:e.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),Pe=Z.configure({dialect:"ts"},"typescript"),me=Z.configure({dialect:"jsx"}),ge=Z.configure({dialect:"jsx ts"},"typescript"),Oi="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 be(e={}){let O=e.jsx?e.typescript?ge:me:e.typescript?Pe:Z;return new pO(O,[Z.data.of({autocomplete:Ee(Se,De(Ma.concat(Oi)))}),Z.data.of({autocomplete:Ha}),e.jsx?ti:[]])}function MO(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 ei=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),ti=y.inputHandler.of((e,O,t,a)=>{if((ei?e.composing:e.compositionStarted)||e.state.readOnly||O!=t||a!=">"&&a!="/"||!Z.isActiveAt(e.state,O,-1))return!1;let{state:i}=e,r=i.changeByRange(s=>{var l,Q,c;let{head:h}=s,o=v(i).resolveInner(h,-1),d;if(o.name=="JSXStartTag"&&(o=o.parent),a==">"&&o.name=="JSXFragmentTag")return{range:j.cursor(h+1),changes:{from:h,insert:"><>"}};if(a==">"&&o.name=="JSXIdentifier"){if(((Q=(l=o.parent)===null||l===void 0?void 0:l.lastChild)===null||Q===void 0?void 0:Q.name)!="JSXEndTag"&&(d=MO(i.doc,o.parent,h)))return{range:j.cursor(h+1),changes:{from:h,insert:`></${d}>`}}}else if(a=="/
|