livebook/static/assets/jsonMode-HM3NTNGY.js

17 lines
39 KiB
JavaScript
Raw Normal View History

2023-06-20 23:34:33 +08:00
import{vj as oe}from"./chunk-ITWFYK6C.js";import{i as C}from"./chunk-2YVZDWG7.js";var Qe=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,Ke=Object.getOwnPropertyNames,er=Object.prototype.hasOwnProperty,ue=(e,n,i,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Ke(n))!er.call(e,r)&&r!==i&&Qe(e,r,{get:()=>n[r],enumerable:!(t=Ze(n,r))||t.enumerable});return e},rr=(e,n,i)=>(ue(e,n,"default"),i&&ue(i,n,"default")),l={};rr(l,oe);var tr=2*60*1e3,nr=class{constructor(e){C(this,"_defaults");C(this,"_idleCheckInterval");C(this,"_lastUsedTime");C(this,"_configChangeListener");C(this,"_worker");C(this,"_client");this._defaults=e,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>tr&&this._stopWorker()}_getClient(){return this._lastUsedTime=Date.now(),this._client||(this._worker=l.editor.createWebWorker({moduleId:"vs/language/json/jsonWorker",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(...e){let n;return this._getClient().then(i=>{n=i}).then(i=>{if(this._worker)return this._worker.withSyncedResources(e)}).then(i=>n)}},ce;(function(e){e.MIN_VALUE=-2147483648,e.MAX_VALUE=2147483647})(ce||(ce={}));var Y;(function(e){e.MIN_VALUE=0,e.MAX_VALUE=2147483647})(Y||(Y={}));var T;(function(e){function n(t,r){return t===Number.MAX_VALUE&&(t=Y.MAX_VALUE),r===Number.MAX_VALUE&&(r=Y.MAX_VALUE),{line:t,character:r}}e.create=n;function i(t){var r=t;return o.objectLiteral(r)&&o.uinteger(r.line)&&o.uinteger(r.character)}e.is=i})(T||(T={}));var _;(function(e){function n(t,r,a,s){if(o.uinteger(t)&&o.uinteger(r)&&o.uinteger(a)&&o.uinteger(s))return{start:T.create(t,r),end:T.create(a,s)};if(T.is(t)&&T.is(r))return{start:t,end:r};throw new Error("Range#create called with invalid arguments["+t+", "+r+", "+a+", "+s+"]")}e.create=n;function i(t){var r=t;return o.objectLiteral(r)&&T.is(r.start)&&T.is(r.end)}e.is=i})(_||(_={}));var re;(function(e){function n(t,r){return{uri:t,range:r}}e.create=n;function i(t){var r=t;return o.defined(r)&&_.is(r.range)&&(o.string(r.uri)||o.undefined(r.uri))}e.is=i})(re||(re={}));var de;(function(e){function n(t,r,a,s){return{targetUri:t,targetRange:r,targetSelectionRange:a,originSelectionRange:s}}e.create=n;function i(t){var r=t;return o.defined(r)&&_.is(r.targetRange)&&o.string(r.targetUri)&&(_.is(r.targetSelectionRange)||o.undefined(r.targetSelectionRange))&&(_.is(r.originSelectionRange)||o.undefined(r.originSelectionRange))}e.is=i})(de||(de={}));var te;(function(e){function n(t,r,a,s){return{red:t,green:r,blue:a,alpha:s}}e.create=n;function i(t){var r=t;return o.numberRange(r.red,0,1)&&o.numberRange(r.green,0,1)&&o.numberRange(r.blue,0,1)&&o.numberRange(r.alpha,0,1)}e.is=i})(te||(te={}));var fe;(function(e){function n(t,r){return{range:t,color:r}}e.create=n;function i(t){var r=t;return _.is(r.range)&&te.is(r.color)}e.is=i})(fe||(fe={}));var le;(function(e){function n(t,r,a){return{label:t,textEdit:r,additionalTextEdits:a}}e.create=n;function i(t){var r=t;return o.string(r.label)&&(o.undefined(r.textEdit)||M.is(r))&&(o.undefined(r.additionalTextEdits)||o.typedArray(r.additionalTextEdits,M.is))}e.is=i})(le||(le={}));var W;(function(e){e.Comment="comment",e.Imports="imports",e.Region="region"})(W||(W={}));var ge;(function(e){function n(t,r,a,s,u){var c={startLine:t,endLine:r};return o.defined(a)&&(c.startCharacter=a),o.defined(s)&&(c.endCharacter=s),o.defined(u)&&(c.kind=u),c}e.create=n;function i(t){var r=t;return o.uinteger(r.startLine)&&o.uinteger(r.st
2023-05-27 15:05:48 +08:00
`,a==="\r"&&r+1<i.length&&i.charAt(r+1)===`
`&&r++}t&&i.length>0&&n.push(i.length),this._lineOffsets=n}return this._lineOffsets},e.prototype.positionAt=function(n){n=Math.max(Math.min(n,this._content.length),0);var i=this.getLineOffsets(),t=0,r=i.length;if(r===0)return T.create(0,n);for(;t<r;){var a=Math.floor((t+r)/2);i[a]>n?r=a:t=a+1}var s=t-1;return T.create(s,n-i[s])},e.prototype.offsetAt=function(n){var i=this.getLineOffsets();if(n.line>=i.length)return this._content.length;if(n.line<0)return 0;var t=i[n.line],r=n.line+1<i.length?i[n.line+1]:this._content.length;return Math.max(Math.min(t+n.character,r),t)},Object.defineProperty(e.prototype,"lineCount",{get:function(){return this.getLineOffsets().length},enumerable:!1,configurable:!0}),e}(),o;(function(e){var n=Object.prototype.toString;function i(h){return typeof h!="undefined"}e.defined=i;function t(h){return typeof h=="undefined"}e.undefined=t;function r(h){return h===!0||h===!1}e.boolean=r;function a(h){return n.call(h)==="[object String]"}e.string=a;function s(h){return n.call(h)==="[object Number]"}e.number=s;function u(h,I,R){return n.call(h)==="[object Number]"&&I<=h&&h<=R}e.numberRange=u;function c(h){return n.call(h)==="[object Number]"&&-2147483648<=h&&h<=2147483647}e.integer=c;function d(h){return n.call(h)==="[object Number]"&&0<=h&&h<=2147483647}e.uinteger=d;function v(h){return n.call(h)==="[object Function]"}e.func=v;function g(h){return h!==null&&typeof h=="object"}e.objectLiteral=g;function b(h,I){return Array.isArray(h)&&h.every(I)}e.typedArray=b})(o||(o={}));var ar=class{constructor(e,n,i){C(this,"_disposables",[]);C(this,"_listener",Object.create(null));this._languageId=e,this._worker=n;let t=a=>{let s=a.getLanguageId();if(s!==this._languageId)return;let u;this._listener[a.uri.toString()]=a.onDidChangeContent(()=>{window.clearTimeout(u),u=window.setTimeout(()=>this._doValidate(a.uri,s),500)}),this._doValidate(a.uri,s)},r=a=>{l.editor.setModelMarkers(a,this._languageId,[]);let s=a.uri.toString(),u=this._listener[s];u&&(u.dispose(),delete this._listener[s])};this._disposables.push(l.editor.onDidCreateModel(t)),this._disposables.push(l.editor.onWillDisposeModel(r)),this._disposables.push(l.editor.onDidChangeModelLanguage(a=>{r(a.model),t(a.model)})),this._disposables.push(i(a=>{l.editor.getModels().forEach(s=>{s.getLanguageId()===this._languageId&&(r(s),t(s))})})),this._disposables.push({dispose:()=>{l.editor.getModels().forEach(r);for(let a in this._listener)this._listener[a].dispose()}}),l.editor.getModels().forEach(t)}dispose(){this._disposables.forEach(e=>e&&e.dispose()),this._disposables.length=0}_doValidate(e,n){this._worker(e).then(i=>i.doValidation(e.toString())).then(i=>{let t=i.map(a=>or(e,a)),r=l.editor.getModel(e);r&&r.getLanguageId()===n&&l.editor.setModelMarkers(r,n,t)}).then(void 0,i=>{console.error(i)})}};function sr(e){switch(e){case N.Error:return l.MarkerSeverity.Error;case N.Warning:return l.MarkerSeverity.Warning;case N.Information:return l.MarkerSeverity.Info;case N.Hint:return l.MarkerSeverity.Hint;default:return l.MarkerSeverity.Info}}function or(e,n){let i=typeof n.code=="number"?String(n.code):n.code;return{severity:sr(n.severity),startLineNumber:n.range.start.line+1,startColumn:n.range.start.character+1,endLineNumber:n.range.end.line+1,endColumn:n.range.end.character+1,message:n.message,code:i,source:n.source}}var ur=class{constructor(e,n){this._worker=e,this._triggerCharacters=n}get triggerCharacters(){return this._triggerCharacters}provideCompletionItems(e,n,i,t){let r=e.uri;return this._worker(r).then(a=>a.doComplete(r.toString(),L(n))).then(a=>{if(!a)return;let s=e.getWordUntilPosition(n),u=new l.Range(n.lineNumber,s.startColumn,n.lineNumber,s.endColumn),c=a.items.map(d=>{let v={label:d.label,insertText:d.insertText||d.label,sortText:d.sortText,filterText:d.filterText,documentation:d.documentation,detail:d.detail,command:fr(d.command),range:u,kind:dr(d.kind)};return d.textEdit&&(cr(d.textEdit)?v.range={insert:y(d.textEdit.insert),replace:y(d.textEdit.replace)}:v.range=y(d.textEdit.range),v.insertText=d.textEdit.newText),d.additionalTextEdits&&(v.additionalText
`+e.value+"\n```\n"}}function hr(e){if(e)return Array.isArray(e)?e.map(Ue):[Ue(e)]}var Vr=class{constructor(e){this._worker=e}provideDocumentHighlights(e,n,i){let t=e.uri;return this._worker(t).then(r=>r.findDocumentHighlights(t.toString(),L(n))).then(r=>{if(r)return r.map(a=>({range:y(a.range),kind:vr(a.kind)}))})}};function vr(e){switch(e){case U.Read:return l.languages.DocumentHighlightKind.Read;case U.Write:return l.languages.DocumentHighlightKind.Write;case U.Text:return l.languages.DocumentHighlightKind.Text}return l.languages.DocumentHighlightKind.Text}var Hr=class{constructor(e){this._worker=e}provideDefinition(e,n,i){let t=e.uri;return this._worker(t).then(r=>r.findDefinition(t.toString(),L(n))).then(r=>{if(r)return[Xe(r)]})}};function Xe(e){return{uri:l.Uri.parse(e.uri),range:y(e.range)}}var zr=class{constructor(e){this._worker=e}provideReferences(e,n,i,t){let r=e.uri;return this._worker(r).then(a=>a.findReferences(r.toString(),L(n))).then(a=>{if(a)return a.map(Xe)})}},Br=class{constructor(e){this._worker=e}provideRenameEdits(e,n,i,t){let r=e.uri;return this._worker(r).then(a=>a.doRename(r.toString(),L(n),i)).then(a=>pr(a))}};function pr(e){if(!e||!e.changes)return;let n=[];for(let i in e.changes){let t=l.Uri.parse(i);for(let r of e.changes[i])n.push({resource:t,versionId:void 0,textEdit:{range:y(r.range),text:r.newText}})}return{edits:n}}var mr=class{constructor(e){this._worker=e}provideDocumentSymbols(e,n){let i=e.uri;return this._worker(i).then(t=>t.findDocumentSymbols(i.toString())).then(t=>{if(t)return t.map(r=>({name:r.name,detail:"",containerName:r.containerName,kind:_r(r.kind),range:y(r.location.range),selectionRange:y(r.location.range),tags:[]}))})}};function _r(e){let n=l.languages.SymbolKind;switch(e){case m.File:return n.Array;case m.Module:return n.Module;case m.Namespace:return n.Namespace;case m.Package:return n.Package;case m.Class:return n.Class;case m.Method:return n.Method;case m.Property:return n.Property;case m.Field:return n.Field;case m.Constructor:return n.Constructor;case m.Enum:return n.Enum;case m.Interface:return n.Interface;case m.Function:return n.Function;case m.Variable:return n.Variable;case m.Constant:return n.Constant;case m.String:return n.String;case m.Number:return n.Number;case m.Boolean:return n.Boolean;case m.Array:return n.Array}return n.Function}var qr=class{constructor(e){this._worker=e}provideLinks(e,n){let i=e.uri;return this._worker(i).then(t=>t.findDocumentLinks(i.toString())).then(t=>{if(t)return{links:t.map(r=>({range:y(r.range),url:r.target}))}})}},kr=class{constructor(e){this._worker=e}provideDocumentFormattingEdits(e,n,i){let t=e.uri;return this._worker(t).then(r=>r.format(t.toString(),null,Je(n)).then(a=>{if(!(!a||a.length===0))return a.map(X)}))}},wr=class{constructor(e){C(this,"canFormatMultipleRanges",!1);this._worker=e}provideDocumentRangeFormattingEdits(e,n,i,t){let r=e.uri;return this._worker(r).then(a=>a.format(r.toString(),qe(n),Je(i)).then(s=>{if(!(!s||s.length===0))return s.map(X)}))}};function Je(e){return{tabSize:e.tabSize,insertSpaces:e.insertSpaces}}var br=class{constructor(e){this._worker=e}provideDocumentColors(e,n){let i=e.uri;return this._worker(i).then(t=>t.findDocumentColors(i.toString())).then(t=>{if(t)return t.map(r=>({color:r.color,range:y(r.range)}))})}provideColorPresentations(e,n,i){let t=e.uri;return this._worker(t).then(r=>r.getColorPresentations(t.toString(),n.color,qe(n.range))).then(r=>{if(r)return r.map(a=>{let s={label:a.label};return a.textEdit&&(s.textEdit=X(a.textEdit)),a.additionalTextEdits&&(s.additionalTextEdits=a.additionalTextEdits.map(X)),s})})}},Cr=class{constructor(e){this._worker=e}provideFoldingRanges(e,n,i){let t=e.uri;return this._worker(t).then(r=>r.getFoldingRanges(t.toString(),n)).then(r=>{if(r)return r.map(a=>{let s={start:a.startLine+1,end:a.endLine+1};return typeof a.kind!="undefined"&&(s.kind=Er(a.kind)),s})})}};function Er(e){switch(e){case W.Comment:return l.languages.FoldingRangeKind.Comment;case W.Imports:return l.languages.FoldingRangeKind.Imports;case W.Region:return l.languages.FoldingRangeKind.R
`;break;case 114:f+="\r";break;case 116:f+=" ";break;case 117:var k=b(4,!0);k>=0?f+=String.fromCharCode(k):g=4;break;default:g=5}E=t;continue}if(S>=0&&S<=31)if(F(S)){f+=e.substring(E,t),g=2;break}else g=6;t++}return f}function j(){if(r="",g=0,a=t,c=u,v=d,t>=i)return a=i,s=17;var f=e.charCodeAt(t);if(ee(f)){do t++,r+=String.fromCharCode(f),f=e.charCodeAt(t);while(ee(f));return s=15}if(F(f))return t++,r+=String.fromCharCode(f),f===13&&e.charCodeAt(t)===10&&(t++,r+=`
`),u++,d=t,s=14;switch(f){case 123:return t++,s=1;case 125:return t++,s=2;case 91:return t++,s=3;case 93:return t++,s=4;case 58:return t++,s=6;case 44:return t++,s=5;case 34:return t++,r=R(),s=10;case 47:var E=t-1;if(e.charCodeAt(t+1)===47){for(t+=2;t<i&&!F(e.charCodeAt(t));)t++;return r=e.substring(E,t),s=12}if(e.charCodeAt(t+1)===42){t+=2;for(var S=i-1,A=!1;t<S;){var k=e.charCodeAt(t);if(k===42&&e.charCodeAt(t+1)===47){t+=2,A=!0;break}t++,F(k)&&(k===13&&e.charCodeAt(t)===10&&t++,u++,d=t)}return A||(t++,g=1),r=e.substring(E,t),s=13}return r+=String.fromCharCode(f),t++,s=16;case 45:if(r+=String.fromCharCode(f),t++,t===i||!D(e.charCodeAt(t)))return s=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return r+=I(),s=11;default:for(;t<i&&$e(f);)t++,f=e.charCodeAt(t);if(a!==t){switch(r=e.substring(a,t),r){case"true":return s=8;case"false":return s=9;case"null":return s=7}return s=16}return r+=String.fromCharCode(f),t++,s=16}}function $e(f){if(ee(f)||F(f))return!1;switch(f){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function Ge(){var f;do f=j();while(f>=12&&f<=15);return f}return{setPosition:h,getPosition:function(){return t},scan:n?Ge:j,getToken:function(){return s},getTokenValue:function(){return r},getTokenOffset:function(){return a},getTokenLength:function(){return t-a},getTokenStartLine:function(){return c},getTokenStartCharacter:function(){return a-v},getTokenError:function(){return g}}}function ee(e){return e===32||e===9||e===11||e===12||e===160||e===5760||e>=8192&&e<=8203||e===8239||e===8287||e===12288||e===65279}function F(e){return e===10||e===13||e===8232||e===8233}function D(e){return e>=48&&e<=57}var Ve;(function(e){e.DEFAULT={allowTrailingComma:!1}})(Ve||(Ve={}));var Sr=yr;function Ir(e){return{getInitialState:()=>new K(null,null,!1,null),tokenize:(n,i)=>jr(e,n,i)}}var He="delimiter.bracket.json",ze="delimiter.array.json",Tr="delimiter.colon.json",Pr="delimiter.comma.json",Mr="keyword.json",Lr="keyword.json",Rr="string.value.json",Dr="number.json",Nr="string.key.json",Or="comment.block.json",xr="comment.line.json",O=class{constructor(e,n){this.parent=e,this.type=n}static pop(e){return e?e.parent:null}static push(e,n){return new O(e,n)}static equals(e,n){if(!e&&!n)return!0;if(!e||!n)return!1;for(;e&&n;){if(e===n)return!0;if(e.type!==n.type)return!1;e=e.parent,n=n.parent}return!0}},K=class{constructor(e,n,i,t){C(this,"_state");C(this,"scanError");C(this,"lastWasColon");C(this,"parents");this._state=e,this.scanError=n,this.lastWasColon=i,this.parents=t}clone(){return new K(this._state,this.scanError,this.lastWasColon,this.parents)}equals(e){return e===this?!0:!e||!(e instanceof K)?!1:this.scanError===e.scanError&&this.lastWasColon===e.lastWasColon&&O.equals(this.parents,e.parents)}getStateData(){return this._state}setStateData(e){this._state=e}};function jr(e,n,i,t=0){let r=0,a=!1;switch(i.scanError){case 2:n='"'+n,r=1;break;case 1:n="/*"+n,r=2;break}let s=Sr(n),u=i.lastWasColon,c=i.parents,d={tokens:[],endState:i.clone()};for(;;){let v=t+s.getPosition(),g="",b=s.scan();if(b===17)break;if(v===t+s.getPosition())throw new Error("Scanner did not advance, next 3 characters are: "+n.substr(s.getPosition(),3));switch(a&&(v-=r),a=r>0,b){case 1:c=O.push(c,0),g=He,u=!1;break;case 2:c=O.pop(c),g=He,u=!1;break;case 3:c=O.push(c,1),g=ze,u=!1;break;case 4:c=O.pop(c),g=ze,u=!1;break;case 6:g=Tr,u=!0;break;case 5:g=Pr,u=!1;break;case 8:case 9:g=Mr,u=!1;break;case 7:g=Lr,u=!1;break;case 10:let I=(c?c.type:0)===1;g=u||I?Rr:Nr,u=!1;break;case 11:g=Dr,u=!1;break}if(e)switch(b){case 12:g=xr;break;case 13:g=Or;break}d.endState=new K(i.getStateData(),s.getTokenError(),u,c),d.tokens.push({startIndex:v,scopes:g})}return d}var Fr=class extends ar{constructor(e,n,i){super(e,n,i.onDidChange),this._disposables.push(l.editor.onWillDisposeModel(t=>{this._resetSchema(t.uri)})),this._disposables.push(l.editor.onDidChangeModelLanguage(t=>{this._resetSchema(t.model.uri)}))}_resetSchema(e){this._worker().then(n=>{n.resetSchema(e.toString())})}};function Xr(e){let n=[],i=[],t=
/*! Bundled license information:
monaco-editor/esm/vs/language/json/jsonMode.js:
(*!-----------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
2023-06-20 23:34:33 +08:00
* Version: 0.39.0(ff3621a3fa6389873be5412d17554294ea1b0941)
2023-05-27 15:05:48 +08:00
* Released under the MIT license
* https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
*-----------------------------------------------------------------------------*)
*/