UNPKG

@arcgis/coding-components

Version:
9 lines (8 loc) • 12.4 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */ import{a as y,b as R,c as ie,d as re,e as se,f as oe,g as V,h as le,i as ue,j as fe,k as ce,l as W,m as ae,n as F,o as P,p as M,q as z,r as q}from"./T2JZE2LL.js";import{a as D}from"./CF3TERM3.js";import"./Z5ZZ36DQ.js";import{$k as d,al as b}from"./LLPQEURF.js";import"./3TTFCHAA.js";var pe=120*1e3,E=class{constructor(t){this._defaults=t,this._worker=null,this._client=null,this._idleCheckInterval=window.setInterval(()=>this._checkIfIdle(),30*1e3),this._lastUsedTime=0,this._configChangeListener=this._defaults.onDidChange(()=>this._stopWorker())}_stopWorker(){this._worker&&(this._worker.dispose(),this._worker=null),this._client=null}dispose(){clearInterval(this._idleCheckInterval),this._configChangeListener.dispose(),this._stopWorker()}_checkIfIdle(){if(!this._worker)return;Date.now()-this._lastUsedTime>pe&&this._stopWorker()}_getClient(){return this._lastUsedTime=Date.now(),this._client||(this._worker=D({moduleId:"vs/language/json/jsonWorker",createWorker:()=>new Worker(new URL("json.worker.js",import.meta.url),{type:"module"}),label:this._defaults.languageId,createData:{languageSettings:this._defaults.diagnosticsOptions,languageId:this._defaults.languageId,enableSchemaRequest:this._defaults.diagnosticsOptions.enableSchemaRequest}}),this._client=this._worker.getProxy()),this._client}getLanguageServiceWorker(...t){let i;return this._getClient().then(n=>{i=n}).then(n=>{if(this._worker)return this._worker.withSyncedResources(t)}).then(n=>i)}};function v(e,t=!1){let i=e.length,n=0,o="",c=0,s=16,l=0,a=0,T=0,w=0,u=0;function O(r,p){let k=0,m=0;for(;k<r;){let f=e.charCodeAt(n);if(f>=48&&f<=57)m=m*16+f-48;else if(f>=65&&f<=70)m=m*16+f-65+10;else if(f>=97&&f<=102)m=m*16+f-97+10;else break;n++,k++}return k<r&&(m=-1),m}function U(r){n=r,o="",c=0,s=16,u=0}function I(){let r=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&_(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&_(e.charCodeAt(n)))for(n++;n<e.length&&_(e.charCodeAt(n));)n++;else return u=3,e.substring(r,n);let p=n;if(n<e.length&&(e.charCodeAt(n)===69||e.charCodeAt(n)===101))if(n++,(n<e.length&&e.charCodeAt(n)===43||e.charCodeAt(n)===45)&&n++,n<e.length&&_(e.charCodeAt(n))){for(n++;n<e.length&&_(e.charCodeAt(n));)n++;p=n}else u=3;return e.substring(r,p)}function ee(){let r="",p=n;for(;;){if(n>=i){r+=e.substring(p,n),u=2;break}let k=e.charCodeAt(n);if(k===34){r+=e.substring(p,n),n++;break}if(k===92){if(r+=e.substring(p,n),n++,n>=i){u=2;break}switch(e.charCodeAt(n++)){case 34:r+='"';break;case 92:r+="\\";break;case 47:r+="/";break;case 98:r+="\b";break;case 102:r+="\f";break;case 110:r+=` `;break;case 114:r+="\r";break;case 116:r+=" ";break;case 117:let f=O(4);f>=0?r+=String.fromCharCode(f):u=4;break;default:u=5}p=n;continue}if(k>=0&&k<=31)if(A(k)){r+=e.substring(p,n),u=2;break}else u=6;n++}return r}function j(){if(o="",u=0,c=n,a=l,w=T,n>=i)return c=i,s=17;let r=e.charCodeAt(n);if(B(r)){do n++,o+=String.fromCharCode(r),r=e.charCodeAt(n);while(B(r));return s=15}if(A(r))return n++,o+=String.fromCharCode(r),r===13&&e.charCodeAt(n)===10&&(n++,o+=` `),l++,T=n,s=14;switch(r){case 123:return n++,s=1;case 125:return n++,s=2;case 91:return n++,s=3;case 93:return n++,s=4;case 58:return n++,s=6;case 44:return n++,s=5;case 34:return n++,o=ee(),s=10;case 47:let p=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<i&&!A(e.charCodeAt(n));)n++;return o=e.substring(p,n),s=12}if(e.charCodeAt(n+1)===42){n+=2;let k=i-1,m=!1;for(;n<k;){let f=e.charCodeAt(n);if(f===42&&e.charCodeAt(n+1)===47){n+=2,m=!0;break}n++,A(f)&&(f===13&&e.charCodeAt(n)===10&&n++,l++,T=n)}return m||(n++,u=1),o=e.substring(p,n),s=13}return o+=String.fromCharCode(r),n++,s=16;case 45:if(o+=String.fromCharCode(r),n++,n===i||!_(e.charCodeAt(n)))return s=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return o+=I(),s=11;default:for(;n<i&&ne(r);)n++,r=e.charCodeAt(n);if(c!==n){switch(o=e.substring(c,n),o){case"true":return s=8;case"false":return s=9;case"null":return s=7}return s=16}return o+=String.fromCharCode(r),n++,s=16}}function ne(r){if(B(r)||A(r))return!1;switch(r){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function te(){let r;do r=j();while(r>=12&&r<=15);return r}return{setPosition:U,getPosition:()=>n,scan:t?te:j,getToken:()=>s,getTokenValue:()=>o,getTokenOffset:()=>c,getTokenLength:()=>n-c,getTokenStartLine:()=>a,getTokenStartCharacter:()=>c-w,getTokenError:()=>u}}function B(e){return e===32||e===9}function A(e){return e===10||e===13}function _(e){return e>=48&&e<=57}var H;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(H||(H={}));var me=new Array(20).fill(0).map((e,t)=>" ".repeat(t)),L=200,ge={" ":{"\n":new Array(L).fill(0).map((e,t)=>` `+" ".repeat(t)),"\r":new Array(L).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(L).fill(0).map((e,t)=>`\r `+" ".repeat(t))}," ":{"\n":new Array(L).fill(0).map((e,t)=>` `+" ".repeat(t)),"\r":new Array(L).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(L).fill(0).map((e,t)=>`\r `+" ".repeat(t))}};var $;(function(e){e.DEFAULT={allowTrailingComma:!1}})($||($={}));var J=v,Q;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(Q||(Q={}));var Y;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(Y||(Y={}));var G;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(G||(G={}));function K(e){return{getInitialState:()=>new N(null,null,!1,null),tokenize:(t,i)=>Ee(e,t,i)}}var X="delimiter.bracket.json",Z="delimiter.array.json",ke="delimiter.colon.json",be="delimiter.comma.json",Te="keyword.json",he="keyword.json",we="string.value.json",_e="number.json",Le="string.key.json",Oe="comment.block.json",Ae="comment.line.json",h=class e{constructor(t,i){this.parent=t,this.type=i}static pop(t){return t?t.parent:null}static push(t,i){return new e(t,i)}static equals(t,i){if(!t&&!i)return!0;if(!t||!i)return!1;for(;t&&i;){if(t===i)return!0;if(t.type!==i.type)return!1;t=t.parent,i=i.parent}return!0}},N=class e{constructor(t,i,n,o){this._state=t,this.scanError=i,this.lastWasColon=n,this.parents=o}clone(){return new e(this._state,this.scanError,this.lastWasColon,this.parents)}equals(t){return t===this?!0:!t||!(t instanceof e)?!1:this.scanError===t.scanError&&this.lastWasColon===t.lastWasColon&&h.equals(this.parents,t.parents)}getStateData(){return this._state}setStateData(t){this._state=t}};function Ee(e,t,i,n=0){let o=0,c=!1;switch(i.scanError){case 2:t='"'+t,o=1;break;case 1:t="/*"+t,o=2;break}let s=J(t),l=i.lastWasColon,a=i.parents,T={tokens:[],endState:i.clone()};for(;;){let w=n+s.getPosition(),u="",O=s.scan();if(O===17)break;if(w===n+s.getPosition())throw new Error("Scanner did not advance, next 3 characters are: "+t.substr(s.getPosition(),3));switch(c&&(w-=o),c=o>0,O){case 1:a=h.push(a,0),u=X,l=!1;break;case 2:a=h.pop(a),u=X,l=!1;break;case 3:a=h.push(a,1),u=Z,l=!1;break;case 4:a=h.pop(a),u=Z,l=!1;break;case 6:u=ke,l=!0;break;case 5:u=be,l=!1;break;case 8:case 9:u=Te,l=!1;break;case 7:u=he,l=!1;break;case 10:let I=(a?a.type:0)===1;u=l||I?we:Le,l=!1;break;case 11:u=_e,l=!1;break}switch(O){case 12:u=Ae;break;case 13:u=Oe;break}T.endState=new N(i.getStateData(),s.getTokenError(),l,a),T.tokens.push({startIndex:w,scopes:u})}return T}var g;function bt(){return new Promise((e,t)=>{if(!g)return t("JSON not registered!");e(g)})}var S=class extends y{constructor(t,i,n){super(t,i,n.onDidChange),this._disposables.push(d.onWillDisposeModel(o=>{this._resetSchema(o.uri)})),this._disposables.push(d.onDidChangeModelLanguage(o=>{this._resetSchema(o.model.uri)}))}_resetSchema(t){this._worker().then(i=>{i.resetSchema(t.toString())})}};function Tt(e){let t=[],i=[],n=new E(e);t.push(n),g=(...s)=>n.getLanguageServiceWorker(...s);function o(){let{languageId:s,modeConfiguration:l}=e;C(i),l.documentFormattingEdits&&i.push(b.registerDocumentFormattingEditProvider(s,new F(g))),l.documentRangeFormattingEdits&&i.push(b.registerDocumentRangeFormattingEditProvider(s,new P(g))),l.completionItems&&i.push(b.registerCompletionItemProvider(s,new R(g,[" ",":",'"']))),l.hovers&&i.push(b.registerHoverProvider(s,new V(g))),l.documentSymbols&&i.push(b.registerDocumentSymbolProvider(s,new W(g))),l.tokens&&i.push(b.setTokensProvider(s,K(!0))),l.colors&&i.push(b.registerColorProvider(s,new M(g))),l.foldingRanges&&i.push(b.registerFoldingRangeProvider(s,new z(g))),l.diagnostics&&i.push(new S(s,g,e)),l.selectionRanges&&i.push(b.registerSelectionRangeProvider(s,new q(g)))}o(),t.push(b.setLanguageConfiguration(e.languageId,ve));let c=e.modeConfiguration;return e.onDidChange(s=>{s.modeConfiguration!==c&&(c=s.modeConfiguration,o())}),t.push(x(i)),x(t)}function x(e){return{dispose:()=>C(e)}}function C(e){for(;e.length;)e.pop().dispose()}var ve={wordPattern:/(-?\d*\.\d\w*)|([^\[\{\]\}\:\"\,\s]+)/g,comments:{lineComment:"//",blockComment:["/*","*/"]},brackets:[["{","}"],["[","]"]],autoClosingPairs:[{open:"{",close:"}",notIn:["string"]},{open:"[",close:"]",notIn:["string"]},{open:'"',close:'"',notIn:["string"]}]};export{R as CompletionAdapter,ue as DefinitionAdapter,y as DiagnosticsAdapter,M as DocumentColorAdapter,F as DocumentFormattingEditProvider,le as DocumentHighlightAdapter,ae as DocumentLinkAdapter,P as DocumentRangeFormattingEditProvider,W as DocumentSymbolAdapter,z as FoldingRangeAdapter,V as HoverAdapter,fe as ReferenceAdapter,ce as RenameAdapter,q as SelectionRangeAdapter,E as WorkerManager,ie as fromPosition,re as fromRange,bt as getWorker,Tt as setupMode,se as toRange,oe as toTextEdit};