pocketbase/ui/dist/assets/CodeEditor-458cff30.js

14 lines
152 KiB
JavaScript
Raw Normal View History

2023-01-10 21:26:36 +08:00
import{S as Te,i as Ve,s as Ue,e as _e,f as qe,T as XO,g as je,y as ZO,o as Ce,J as Ge,K as Re,L as ze}from"./index-2eee4006.js";import{P as Ae,N as Ie,u as Ee,D as Ne,v as QO,T as R,I as Oe,w as cO,x as l,y as Be,L as hO,z as pO,A as z,B as uO,F as ee,G as SO,H as C,J as De,K as Me,E as k,M as j,O as Je,Q as Le,R as g,U as Ke,a as V,h as He,b as Fe,c as Ot,d as et,e as tt,s as at,f as it,g as rt,i as st,r as nt,j as lt,k as ot,l as Qt,m as ct,n as ht,o as pt,p as ut,q as St,t as bO,C as G}from"./index-cd63fa18.js";class N{constructor(O,e,a,i,s,r,n,o,c,h=0,Q){this.p=O,this.stack=e,this.state=a,this.reducePos=i,this.pos=s,this.score=r,this.buffer=n,this.bufferBase=o,this.curContext=c,this.lookAhead=h,this.parent=Q}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 xO(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,s=i.dynamicPrecedence(a);if(s&&(this.score+=s),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 r=this.stack.length-(e-1)*3-(O&262144?6:0),n=this.stack[r-2],o=this.reducePos-n;o>=2e3&&(n==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=o):this.p.lastBigReductionSize<o&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=n,this.p.lastBigReductionSize=o));let c=this.stack[r-1],h=this.bufferBase+this.buffer.length-c;if(a<i.minRepeatTerm||O&131072){let Q=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(a,n,Q,h+4,!0)}if(O&262144)this.state=this.stack[r];else{let Q=this.stack[r-3];this.state=i.getGoto(Q,a,!0)}for(;this.stack.length>r;)this.stack.pop();this.reduceContext(a,n)}storeNode(O,e,a,i=4,s=!1){if(O==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let r=this,n=this.buffer.length;if(n==0&&r.parent&&(n=r.bufferBase-r.parent.bufferBase,r=r.parent),n>0&&r.buffer[n-4]==0&&r.buffer[n-1]>-1){if(e==a)return;if(r.buffer[n-2]>=e){r.buffer[n-2]=a;return}}}if(!s||this.pos==a)this.buffer.push(O,e,a,i);else{let r=this.buffer.length;if(r>0&&this.buffer[r-4]!=0)for(;r>0&&this.buffer[r-2]>a;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,i>4&&(i-=4);this.buffer[r]=O,this.buffer[r+1]=e,this.buffer[r+2]=a,this.buffer[r+3]=i}}shift(O,e,a){let i=this.pos;if(O&131072)this.pushState(O&65535,this.pos);else if(O&262144)this.pos=a,this.shiftContext(e,i),e<=this.p.parser.maxNode&&this.buffer.push(e,i,a,4);else{let s=O,{parser:r}=this.p;(a>this.pos||e<=r.maxNode)&&(this.pos=a,r.stateFlag(s,1)||(this.reducePos=a)),this.pushState(s,i),this.shiftContext(e,i),e<=r.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 $t(this);;){let a=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,O);if(a==0)return!1;if(!(a&65536))return!0;e.reduce(a)}}
\${}
} catch (\${error}) {
\${}
}`,{label:"try",detail:"/ catch block",type:"keyword"}),g("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),g(`if (\${}) {
\${}
} else {
\${}
}`,{label:"if",detail:"/ else block",type:"keyword"}),g(`class \${name} {
constructor(\${params}) {
\${}
}
}`,{label:"class",detail:"definition",type:"keyword"}),g('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),g('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],JO=new Ke,ge=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function U(t){return(O,e)=>{let a=O.node.getChild("VariableDefinition");return a&&e(a,t),!0}}const Ea=["FunctionDeclaration"],Na={FunctionDeclaration:U("function"),ClassDeclaration:U("class"),ClassExpression:()=>!0,EnumDeclaration:U("constant"),TypeAliasDeclaration:U("type"),NamespaceDeclaration:U("namespace"),VariableDefinition(t,O){t.matchContext(Ea)||O(t,"variable")},TypeDefinition(t,O){O(t,"type")},__proto__:null};function me(t,O){let e=JO.get(O);if(e)return e;let a=[],i=!0;function s(r,n){let o=t.sliceString(r.from,r.to);a.push({label:o,type:n})}return O.cursor(Oe.IncludeAnonymous).iterate(r=>{if(i)i=!1;else if(r.name){let n=Na[r.name];if(n&&n(r,s)||ge.has(r.name))return!1}else if(r.to-r.from>8192){for(let n of me(t,r.node))a.push(n);return!1}}),JO.set(O,a),a}const LO=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,Xe=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName"];function Ba(t){let O=C(t.state).resolveInner(t.pos,-1);if(Xe.indexOf(O.name)>-1)return null;let e=O.name=="VariableName"||O.to-O.from<20&&LO.test(t.state.sliceDoc(O.from,O.to));if(!e&&!t.explicit)return null;let a=[];for(let i=O;i;i=i.parent)ge.has(i.name)&&(a=a.concat(me(t.state.doc,i)));return{options:a,from:e?O.from:t.pos,validFor:LO}}const Z=hO.define({name:"javascript",parser:Aa.configure({props:[pO.add({IfStatement:z({except:/^\s*({|else\b)/}),TryStatement:z({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Je,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:Le({closing:"}"}),ArrowFunction:t=>t.baseIndent+t.unit,"TemplateString BlockComment":()=>null,"Statement Property":z({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}}),uO.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression":ee,BlockComment(t){return{from:t.from+2,to:t.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),Ze=Z.configure({dialect:"ts"},"typescript"),be=Z.configure({dialect:"jsx"}),xe=Z.configure({dialect:"jsx ts"},"typescript"),Da="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 ye(t={}){let O=t.jsx?t.typescript?xe:be:t.typescript?Ze:Z;return new SO(O,[Z.data.of({autocomplete:De(Xe,Me(Ia.concat(Da)))}),Z.data.of({autocomplete:Ba}),t.jsx?La:[]])}function Ma(t){for(;;){if(t.name=="JSXOpenTag"||t.name=="JSXSelfClosingTag"||t.name=="JSXFragmentTag")return t;if(!t.parent)return null;t=t.parent}}function KO(t,O,e=t.length){for(let a=O==null?void 0:O.firstChild;a;a=a.nextSibling)if(a.name=="JSXIdentifier"||a.name=="JSXBuiltin"||a.name=="JSXNamespacedName"||a.name=="JSXMemberExpression")return t.sliceString(a.from,Math.min(a.to,e));return""}const Ja=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),La=k.inputHandler.of((t,O,e,a)=>{if((Ja?t.composing:t.compositionStarted)||t.state.readOnly||O!=e||a!=">"&&a!="/"||!Z.isActiveAt(t.state,O,-1))return!1;let{state:i}=t,s=i.changeByRange(r=>{var n,o;let{head:c}=r,h=C(i).resolveInner(c,-1),Q;if(h.name=="JSXStartTag"&&(h=h.parent),a==">"&&h.name=="JSXFragmentTag")return{range:j.cursor(c+1),changes:{