mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-01-22 23:08:50 +08:00
21 lines
23 KiB
JavaScript
21 lines
23 KiB
JavaScript
import{a as O,b as j}from"./chunk-JY7ZYBHV.js";import{$l as P,am as W}from"./chunk-23JDWT7I.js";import{a as T,b as L,e as V,j as _}from"./chunk-EP6THQJ3.js";function D(e,t,s=0){if(typeof e=="string")return e;if(e===void 0)return"";let i="";if(s){i+=t;for(let l=0;l<s;l++)i+=" "}if(i+=e.messageText,s++,e.next)for(let l of e.next)i+=D(l,t,s);return i}function k(e){return e?e.map(t=>t.text).join(""):""}function M(e){let t=`*@${e.name}*`;if(e.name==="param"&&e.text){let[s,...i]=e.text;t+=`\`${s.text}\``,i.length>0&&(t+=` \u2014 ${i.map(l=>l.text).join(" ")}`)}else Array.isArray(e.text)?t+=` \u2014 ${e.text.map(s=>s.text).join(" ")}`:e.text&&(t+=` \u2014 ${e.text}`);return t}function ue(e){A=K(e,"typescript")}function ge(e){F=K(e,"javascript")}function de(){return new Promise((e,t)=>{if(!F)return t("JavaScript not registered!");e(F)})}function pe(){return new Promise((e,t)=>{if(!A)return t("TypeScript not registered!");e(A)})}function K(e,t){let s=[],i=[],l=new J(t,e);s.push(l);let o=(...r)=>l.getLanguageServiceWorker(...r),u=new Q(o);function g(){let{modeConfiguration:r}=e;E(i),r.completionItems&&i.push(a.languages.registerCompletionItemProvider(t,new C(o))),r.signatureHelp&&i.push(a.languages.registerSignatureHelpProvider(t,new R(o))),r.hovers&&i.push(a.languages.registerHoverProvider(t,new X(o))),r.documentHighlights&&i.push(a.languages.registerDocumentHighlightProvider(t,new Y(o))),r.definitions&&i.push(a.languages.registerDefinitionProvider(t,new Z(u,o))),r.references&&i.push(a.languages.registerReferenceProvider(t,new ee(u,o))),r.documentSymbols&&i.push(a.languages.registerDocumentSymbolProvider(t,new te(o))),r.rename&&i.push(a.languages.registerRenameProvider(t,new ne(u,o))),r.documentRangeFormattingEdits&&i.push(a.languages.registerDocumentRangeFormattingEditProvider(t,new re(o))),r.onTypeFormattingEdits&&i.push(a.languages.registerOnTypeFormattingEditProvider(t,new se(o))),r.codeActions&&i.push(a.languages.registerCodeActionProvider(t,new ie(o))),r.inlayHints&&i.push(a.languages.registerInlayHintsProvider(t,new ae(o))),r.diagnostics&&i.push(new q(u,e,t,o))}return g(),s.push(oe(i)),o}function oe(e){return{dispose:()=>E(e)}}function E(e){for(;e.length;)e.pop().dispose()}var N,B,U,$,z,I,G,b,a,J,n,w,Q,q,C,R,X,Y,Z,ee,te,c,m,S,re,se,ie,ne,ae,F,A,le=V(()=>{W();j();N=Object.defineProperty,B=Object.getOwnPropertyDescriptor,U=Object.getOwnPropertyNames,$=Object.prototype.hasOwnProperty,z=(e,t,s)=>t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,I=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of U(t))!$.call(e,l)&&l!==s&&N(e,l,{get:()=>t[l],enumerable:!(i=B(t,l))||i.enumerable});return e},G=(e,t,s)=>(I(e,t,"default"),s&&I(s,t,"default")),b=(e,t,s)=>(z(e,typeof t!="symbol"?t+"":t,s),s),a={};G(a,P);J=class{constructor(e,t){_(this,"_configChangeListener");_(this,"_updateExtraLibsToken");_(this,"_extraLibsChangeListener");_(this,"_worker");_(this,"_client");this._modeId=e,this._defaults=t,this._worker=null,this._client=null,this._configChangeListener=this._defaults.onDidChange(()=>this._stopWorker()),this._updateExtraLibsToken=0,this._extraLibsChangeListener=this._defaults.onDidExtraLibsChange(()=>this._updateExtraLibs())}dispose(){this._configChangeListener.dispose(),this._extraLibsChangeListener.dispose(),this._stopWorker()}_stopWorker(){this._worker&&(this._worker.dispose(),this._worker=null),this._client=null}async _updateExtraLibs(){if(!this._worker)return;let e=++this._updateExtraLibsToken,t=await this._worker.getProxy();this._updateExtraLibsToken===e&&t.updateExtraLibs(this._defaults.getExtraLibs())}_getClient(){return this._client||(this._client=(async()=>(this._worker=a.editor.createWebWorker({moduleId:"vs/language/typescript/tsWorker",label:this._modeId,keepIdleModels:!0,createData:{compilerOptions:this._defaults.getCompilerOptions(),extraLibs:this._defaults.getExtraLibs(),customWorkerPath:this._defaults.workerOptions.customWorkerPath,inlayHintsOptions:this._defaults.inlayHintsOptions}}),this._defaults.getEagerModelSync()?await this._worker.withSyncedResources(a.editor.getModels().filter(e=>e.getLanguageId()===this._modeId).map(e=>e.uri)):await this._worker.getProxy()))()),this._client}async getLanguageServiceWorker(...e){let t=await this._getClient();return this._worker&&await this._worker.withSyncedResources(e),t}},n={};n["lib.d.ts"]=!0;n["lib.decorators.d.ts"]=!0;n["lib.decorators.legacy.d.ts"]=!0;n["lib.dom.d.ts"]=!0;n["lib.dom.iterable.d.ts"]=!0;n["lib.es2015.collection.d.ts"]=!0;n["lib.es2015.core.d.ts"]=!0;n["lib.es2015.d.ts"]=!0;n["lib.es2015.generator.d.ts"]=!0;n["lib.es2015.iterable.d.ts"]=!0;n["lib.es2015.promise.d.ts"]=!0;n["lib.es2015.proxy.d.ts"]=!0;n["lib.es2015.reflect.d.ts"]=!0;n["lib.es2015.symbol.d.ts"]=!0;n["lib.es2015.symbol.wellknown.d.ts"]=!0;n["lib.es2016.array.include.d.ts"]=!0;n["lib.es2016.d.ts"]=!0;n["lib.es2016.full.d.ts"]=!0;n["lib.es2017.d.ts"]=!0;n["lib.es2017.full.d.ts"]=!0;n["lib.es2017.intl.d.ts"]=!0;n["lib.es2017.object.d.ts"]=!0;n["lib.es2017.sharedmemory.d.ts"]=!0;n["lib.es2017.string.d.ts"]=!0;n["lib.es2017.typedarrays.d.ts"]=!0;n["lib.es2018.asyncgenerator.d.ts"]=!0;n["lib.es2018.asynciterable.d.ts"]=!0;n["lib.es2018.d.ts"]=!0;n["lib.es2018.full.d.ts"]=!0;n["lib.es2018.intl.d.ts"]=!0;n["lib.es2018.promise.d.ts"]=!0;n["lib.es2018.regexp.d.ts"]=!0;n["lib.es2019.array.d.ts"]=!0;n["lib.es2019.d.ts"]=!0;n["lib.es2019.full.d.ts"]=!0;n["lib.es2019.intl.d.ts"]=!0;n["lib.es2019.object.d.ts"]=!0;n["lib.es2019.string.d.ts"]=!0;n["lib.es2019.symbol.d.ts"]=!0;n["lib.es2020.bigint.d.ts"]=!0;n["lib.es2020.d.ts"]=!0;n["lib.es2020.date.d.ts"]=!0;n["lib.es2020.full.d.ts"]=!0;n["lib.es2020.intl.d.ts"]=!0;n["lib.es2020.number.d.ts"]=!0;n["lib.es2020.promise.d.ts"]=!0;n["lib.es2020.sharedmemory.d.ts"]=!0;n["lib.es2020.string.d.ts"]=!0;n["lib.es2020.symbol.wellknown.d.ts"]=!0;n["lib.es2021.d.ts"]=!0;n["lib.es2021.full.d.ts"]=!0;n["lib.es2021.intl.d.ts"]=!0;n["lib.es2021.promise.d.ts"]=!0;n["lib.es2021.string.d.ts"]=!0;n["lib.es2021.weakref.d.ts"]=!0;n["lib.es2022.array.d.ts"]=!0;n["lib.es2022.d.ts"]=!0;n["lib.es2022.error.d.ts"]=!0;n["lib.es2022.full.d.ts"]=!0;n["lib.es2022.intl.d.ts"]=!0;n["lib.es2022.object.d.ts"]=!0;n["lib.es2022.regexp.d.ts"]=!0;n["lib.es2022.sharedmemory.d.ts"]=!0;n["lib.es2022.string.d.ts"]=!0;n["lib.es2023.array.d.ts"]=!0;n["lib.es2023.d.ts"]=!0;n["lib.es2023.full.d.ts"]=!0;n["lib.es5.d.ts"]=!0;n["lib.es6.d.ts"]=!0;n["lib.esnext.d.ts"]=!0;n["lib.esnext.full.d.ts"]=!0;n["lib.esnext.intl.d.ts"]=!0;n["lib.scripthost.d.ts"]=!0;n["lib.webworker.d.ts"]=!0;n["lib.webworker.importscripts.d.ts"]=!0;n["lib.webworker.iterable.d.ts"]=!0;w=class{constructor(e){this._worker=e}_textSpanToRange(e,t){let s=e.getPositionAt(t.start),i=e.getPositionAt(t.start+t.length),{lineNumber:l,column:o}=s,{lineNumber:u,column:g}=i;return{startLineNumber:l,startColumn:o,endLineNumber:u,endColumn:g}}},Q=class{constructor(e){_(this,"_libFiles");_(this,"_hasFetchedLibFiles");_(this,"_fetchLibFilesPromise");this._worker=e,this._libFiles={},this._hasFetchedLibFiles=!1,this._fetchLibFilesPromise=null}isLibFile(e){return e&&e.path.indexOf("/lib.")===0?!!n[e.path.slice(1)]:!1}getOrCreateModel(e){let t=a.Uri.parse(e),s=a.editor.getModel(t);if(s)return s;if(this.isLibFile(t)&&this._hasFetchedLibFiles)return a.editor.createModel(this._libFiles[t.path.slice(1)],"typescript",t);let i=O.getExtraLibs()[e];return i?a.editor.createModel(i.content,"typescript",t):null}_containsLibFile(e){for(let t of e)if(this.isLibFile(t))return!0;return!1}async fetchLibFilesIfNecessary(e){this._containsLibFile(e)&&await this._fetchLibFiles()}_fetchLibFiles(){return this._fetchLibFilesPromise||(this._fetchLibFilesPromise=this._worker().then(e=>e.getLibFiles()).then(e=>{this._hasFetchedLibFiles=!0,this._libFiles=e})),this._fetchLibFilesPromise}},q=class extends w{constructor(t,s,i,l){super(l);_(this,"_disposables",[]);_(this,"_listener",Object.create(null));this._libFiles=t,this._defaults=s,this._selector=i;let o=r=>{if(r.getLanguageId()!==i)return;let p=()=>{let{onlyVisible:y}=this._defaults.getDiagnosticsOptions();y?r.isAttachedToEditor()&&this._doValidate(r):this._doValidate(r)},d,f=r.onDidChangeContent(()=>{clearTimeout(d),d=window.setTimeout(p,500)}),h=r.onDidChangeAttached(()=>{let{onlyVisible:y}=this._defaults.getDiagnosticsOptions();y&&(r.isAttachedToEditor()?p():a.editor.setModelMarkers(r,this._selector,[]))});this._listener[r.uri.toString()]={dispose(){f.dispose(),h.dispose(),clearTimeout(d)}},p()},u=r=>{a.editor.setModelMarkers(r,this._selector,[]);let p=r.uri.toString();this._listener[p]&&(this._listener[p].dispose(),delete this._listener[p])};this._disposables.push(a.editor.onDidCreateModel(r=>o(r))),this._disposables.push(a.editor.onWillDisposeModel(u)),this._disposables.push(a.editor.onDidChangeModelLanguage(r=>{u(r.model),o(r.model)})),this._disposables.push({dispose(){for(let r of a.editor.getModels())u(r)}});let g=()=>{for(let r of a.editor.getModels())u(r),o(r)};this._disposables.push(this._defaults.onDidChange(g)),this._disposables.push(this._defaults.onDidExtraLibsChange(g)),a.editor.getModels().forEach(r=>o(r))}dispose(){this._disposables.forEach(t=>t&&t.dispose()),this._disposables=[]}async _doValidate(t){let s=await this._worker(t.uri);if(t.isDisposed())return;let i=[],{noSyntaxValidation:l,noSemanticValidation:o,noSuggestionDiagnostics:u}=this._defaults.getDiagnosticsOptions();l||i.push(s.getSyntacticDiagnostics(t.uri.toString())),o||i.push(s.getSemanticDiagnostics(t.uri.toString())),u||i.push(s.getSuggestionDiagnostics(t.uri.toString()));let g=await Promise.all(i);if(!g||t.isDisposed())return;let r=g.reduce((d,f)=>f.concat(d),[]).filter(d=>(this._defaults.getDiagnosticsOptions().diagnosticCodesToIgnore||[]).indexOf(d.code)===-1),p=r.map(d=>d.relatedInformation||[]).reduce((d,f)=>f.concat(d),[]).map(d=>d.file?a.Uri.parse(d.file.fileName):null);await this._libFiles.fetchLibFilesIfNecessary(p),!t.isDisposed()&&a.editor.setModelMarkers(t,this._selector,r.map(d=>this._convertDiagnostics(t,d)))}_convertDiagnostics(t,s){let i=s.start||0,l=s.length||1,{lineNumber:o,column:u}=t.getPositionAt(i),{lineNumber:g,column:r}=t.getPositionAt(i+l),p=[];return s.reportsUnnecessary&&p.push(a.MarkerTag.Unnecessary),s.reportsDeprecated&&p.push(a.MarkerTag.Deprecated),{severity:this._tsDiagnosticCategoryToMarkerSeverity(s.category),startLineNumber:o,startColumn:u,endLineNumber:g,endColumn:r,message:D(s.messageText,`
|
|
`),code:s.code.toString(),tags:p,relatedInformation:this._convertRelatedInformation(t,s.relatedInformation)}}_convertRelatedInformation(t,s){if(!s)return[];let i=[];return s.forEach(l=>{let o=t;if(l.file&&(o=this._libFiles.getOrCreateModel(l.file.fileName)),!o)return;let u=l.start||0,g=l.length||1,{lineNumber:r,column:p}=o.getPositionAt(u),{lineNumber:d,column:f}=o.getPositionAt(u+g);i.push({resource:o.uri,startLineNumber:r,startColumn:p,endLineNumber:d,endColumn:f,message:D(l.messageText,`
|
|
`)})}),i}_tsDiagnosticCategoryToMarkerSeverity(t){switch(t){case 1:return a.MarkerSeverity.Error;case 3:return a.MarkerSeverity.Info;case 0:return a.MarkerSeverity.Warning;case 2:return a.MarkerSeverity.Hint}return a.MarkerSeverity.Info}},C=class extends w{get triggerCharacters(){return["."]}async provideCompletionItems(e,t,s,i){let l=e.getWordUntilPosition(t),o=new a.Range(t.lineNumber,l.startColumn,t.lineNumber,l.endColumn),u=e.uri,g=e.getOffsetAt(t),r=await this._worker(u);if(e.isDisposed())return;let p=await r.getCompletionsAtPosition(u.toString(),g);return!p||e.isDisposed()?void 0:{suggestions:p.entries.map(f=>{let h=o;if(f.replacementSpan){let x=e.getPositionAt(f.replacementSpan.start),v=e.getPositionAt(f.replacementSpan.start+f.replacementSpan.length);h=new a.Range(x.lineNumber,x.column,v.lineNumber,v.column)}let y=[];return f.kindModifiers!==void 0&&f.kindModifiers.indexOf("deprecated")!==-1&&y.push(a.languages.CompletionItemTag.Deprecated),{uri:u,position:t,offset:g,range:h,label:f.name,insertText:f.name,sortText:f.sortText,kind:C.convertKind(f.kind),tags:y}})}}async resolveCompletionItem(e,t){let s=e,i=s.uri,l=s.position,o=s.offset,g=await(await this._worker(i)).getCompletionEntryDetails(i.toString(),o,s.label);return g?{uri:i,position:l,label:g.name,kind:C.convertKind(g.kind),detail:k(g.displayParts),documentation:{value:C.createDocumentationString(g)}}:s}static convertKind(e){switch(e){case c.primitiveType:case c.keyword:return a.languages.CompletionItemKind.Keyword;case c.variable:case c.localVariable:return a.languages.CompletionItemKind.Variable;case c.memberVariable:case c.memberGetAccessor:case c.memberSetAccessor:return a.languages.CompletionItemKind.Field;case c.function:case c.memberFunction:case c.constructSignature:case c.callSignature:case c.indexSignature:return a.languages.CompletionItemKind.Function;case c.enum:return a.languages.CompletionItemKind.Enum;case c.module:return a.languages.CompletionItemKind.Module;case c.class:return a.languages.CompletionItemKind.Class;case c.interface:return a.languages.CompletionItemKind.Interface;case c.warning:return a.languages.CompletionItemKind.File}return a.languages.CompletionItemKind.Property}static createDocumentationString(e){let t=k(e.documentation);if(e.tags)for(let s of e.tags)t+=`
|
|
|
|
${M(s)}`;return t}};R=class extends w{constructor(){super(...arguments);_(this,"signatureHelpTriggerCharacters",["(",","])}static _toSignatureHelpTriggerReason(t){switch(t.triggerKind){case a.languages.SignatureHelpTriggerKind.TriggerCharacter:return t.triggerCharacter?t.isRetrigger?{kind:"retrigger",triggerCharacter:t.triggerCharacter}:{kind:"characterTyped",triggerCharacter:t.triggerCharacter}:{kind:"invoked"};case a.languages.SignatureHelpTriggerKind.ContentChange:return t.isRetrigger?{kind:"retrigger"}:{kind:"invoked"};case a.languages.SignatureHelpTriggerKind.Invoke:default:return{kind:"invoked"}}}async provideSignatureHelp(t,s,i,l){let o=t.uri,u=t.getOffsetAt(s),g=await this._worker(o);if(t.isDisposed())return;let r=await g.getSignatureHelpItems(o.toString(),u,{triggerReason:R._toSignatureHelpTriggerReason(l)});if(!r||t.isDisposed())return;let p={activeSignature:r.selectedItemIndex,activeParameter:r.argumentIndex,signatures:[]};return r.items.forEach(d=>{let f={label:"",parameters:[]};f.documentation={value:k(d.documentation)},f.label+=k(d.prefixDisplayParts),d.parameters.forEach((h,y,x)=>{let v=k(h.displayParts),H={label:v,documentation:{value:k(h.documentation)}};f.label+=v,f.parameters.push(H),y<x.length-1&&(f.label+=k(d.separatorDisplayParts))}),f.label+=k(d.suffixDisplayParts),p.signatures.push(f)}),{value:p,dispose(){}}}},X=class extends w{async provideHover(e,t,s){let i=e.uri,l=e.getOffsetAt(t),o=await this._worker(i);if(e.isDisposed())return;let u=await o.getQuickInfoAtPosition(i.toString(),l);if(!u||e.isDisposed())return;let g=k(u.documentation),r=u.tags?u.tags.map(d=>M(d)).join(`
|
|
|
|
`):"",p=k(u.displayParts);return{range:this._textSpanToRange(e,u.textSpan),contents:[{value:"```typescript\n"+p+"\n```\n"},{value:g+(r?`
|
|
|
|
`+r:"")}]}}},Y=class extends w{async provideDocumentHighlights(e,t,s){let i=e.uri,l=e.getOffsetAt(t),o=await this._worker(i);if(e.isDisposed())return;let u=await o.getDocumentHighlights(i.toString(),l,[i.toString()]);if(!(!u||e.isDisposed()))return u.flatMap(g=>g.highlightSpans.map(r=>({range:this._textSpanToRange(e,r.textSpan),kind:r.kind==="writtenReference"?a.languages.DocumentHighlightKind.Write:a.languages.DocumentHighlightKind.Text})))}},Z=class extends w{constructor(e,t){super(t),this._libFiles=e}async provideDefinition(e,t,s){let i=e.uri,l=e.getOffsetAt(t),o=await this._worker(i);if(e.isDisposed())return;let u=await o.getDefinitionAtPosition(i.toString(),l);if(!u||e.isDisposed()||(await this._libFiles.fetchLibFilesIfNecessary(u.map(r=>a.Uri.parse(r.fileName))),e.isDisposed()))return;let g=[];for(let r of u){let p=this._libFiles.getOrCreateModel(r.fileName);p&&g.push({uri:p.uri,range:this._textSpanToRange(p,r.textSpan)})}return g}},ee=class extends w{constructor(e,t){super(t),this._libFiles=e}async provideReferences(e,t,s,i){let l=e.uri,o=e.getOffsetAt(t),u=await this._worker(l);if(e.isDisposed())return;let g=await u.getReferencesAtPosition(l.toString(),o);if(!g||e.isDisposed()||(await this._libFiles.fetchLibFilesIfNecessary(g.map(p=>a.Uri.parse(p.fileName))),e.isDisposed()))return;let r=[];for(let p of g){let d=this._libFiles.getOrCreateModel(p.fileName);d&&r.push({uri:d.uri,range:this._textSpanToRange(d,p.textSpan)})}return r}},te=class extends w{async provideDocumentSymbols(e,t){let s=e.uri,i=await this._worker(s);if(e.isDisposed())return;let l=await i.getNavigationTree(s.toString());if(!l||e.isDisposed())return;let o=(g,r)=>{var d;return{name:g.text,detail:"",kind:m[g.kind]||a.languages.SymbolKind.Variable,range:this._textSpanToRange(e,g.spans[0]),selectionRange:this._textSpanToRange(e,g.spans[0]),tags:[],children:(d=g.childItems)==null?void 0:d.map(f=>o(f,g.text)),containerName:r}};return l.childItems?l.childItems.map(g=>o(g)):[]}},c=class{};b(c,"unknown","");b(c,"keyword","keyword");b(c,"script","script");b(c,"module","module");b(c,"class","class");b(c,"interface","interface");b(c,"type","type");b(c,"enum","enum");b(c,"variable","var");b(c,"localVariable","local var");b(c,"function","function");b(c,"localFunction","local function");b(c,"memberFunction","method");b(c,"memberGetAccessor","getter");b(c,"memberSetAccessor","setter");b(c,"memberVariable","property");b(c,"constructorImplementation","constructor");b(c,"callSignature","call");b(c,"indexSignature","index");b(c,"constructSignature","construct");b(c,"parameter","parameter");b(c,"typeParameter","type parameter");b(c,"primitiveType","primitive type");b(c,"label","label");b(c,"alias","alias");b(c,"const","const");b(c,"let","let");b(c,"warning","warning");m=Object.create(null);m[c.module]=a.languages.SymbolKind.Module;m[c.class]=a.languages.SymbolKind.Class;m[c.enum]=a.languages.SymbolKind.Enum;m[c.interface]=a.languages.SymbolKind.Interface;m[c.memberFunction]=a.languages.SymbolKind.Method;m[c.memberVariable]=a.languages.SymbolKind.Property;m[c.memberGetAccessor]=a.languages.SymbolKind.Property;m[c.memberSetAccessor]=a.languages.SymbolKind.Property;m[c.variable]=a.languages.SymbolKind.Variable;m[c.const]=a.languages.SymbolKind.Variable;m[c.localVariable]=a.languages.SymbolKind.Variable;m[c.variable]=a.languages.SymbolKind.Variable;m[c.function]=a.languages.SymbolKind.Function;m[c.localFunction]=a.languages.SymbolKind.Function;S=class extends w{static _convertOptions(e){return{ConvertTabsToSpaces:e.insertSpaces,TabSize:e.tabSize,IndentSize:e.tabSize,IndentStyle:2,NewLineCharacter:`
|
|
`,InsertSpaceAfterCommaDelimiter:!0,InsertSpaceAfterSemicolonInForStatements:!0,InsertSpaceBeforeAndAfterBinaryOperators:!0,InsertSpaceAfterKeywordsInControlFlowStatements:!0,InsertSpaceAfterFunctionKeywordForAnonymousFunctions:!0,InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis:!1,InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets:!1,InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces:!1,PlaceOpenBraceOnNewLineForControlBlocks:!1,PlaceOpenBraceOnNewLineForFunctions:!1}}_convertTextChanges(e,t){return{text:t.newText,range:this._textSpanToRange(e,t.span)}}},re=class extends S{constructor(){super(...arguments);_(this,"canFormatMultipleRanges",!1)}async provideDocumentRangeFormattingEdits(t,s,i,l){let o=t.uri,u=t.getOffsetAt({lineNumber:s.startLineNumber,column:s.startColumn}),g=t.getOffsetAt({lineNumber:s.endLineNumber,column:s.endColumn}),r=await this._worker(o);if(t.isDisposed())return;let p=await r.getFormattingEditsForRange(o.toString(),u,g,S._convertOptions(i));if(!(!p||t.isDisposed()))return p.map(d=>this._convertTextChanges(t,d))}},se=class extends S{get autoFormatTriggerCharacters(){return[";","}",`
|
|
`]}async provideOnTypeFormattingEdits(e,t,s,i,l){let o=e.uri,u=e.getOffsetAt(t),g=await this._worker(o);if(e.isDisposed())return;let r=await g.getFormattingEditsAfterKeystroke(o.toString(),u,s,S._convertOptions(i));if(!(!r||e.isDisposed()))return r.map(p=>this._convertTextChanges(e,p))}},ie=class extends S{async provideCodeActions(e,t,s,i){let l=e.uri,o=e.getOffsetAt({lineNumber:t.startLineNumber,column:t.startColumn}),u=e.getOffsetAt({lineNumber:t.endLineNumber,column:t.endColumn}),g=S._convertOptions(e.getOptions()),r=s.markers.filter(h=>h.code).map(h=>h.code).map(Number),p=await this._worker(l);if(e.isDisposed())return;let d=await p.getCodeFixesAtPosition(l.toString(),o,u,r,g);return!d||e.isDisposed()?{actions:[],dispose:()=>{}}:{actions:d.filter(h=>h.changes.filter(y=>y.isNewFile).length===0).map(h=>this._tsCodeFixActionToMonacoCodeAction(e,s,h)),dispose:()=>{}}}_tsCodeFixActionToMonacoCodeAction(e,t,s){let i=[];for(let o of s.changes)for(let u of o.textChanges)i.push({resource:e.uri,versionId:void 0,textEdit:{range:this._textSpanToRange(e,u.span),text:u.newText}});return{title:s.description,edit:{edits:i},diagnostics:t.markers,kind:"quickfix"}}},ne=class extends w{constructor(e,t){super(t),this._libFiles=e}async provideRenameEdits(e,t,s,i){let l=e.uri,o=l.toString(),u=e.getOffsetAt(t),g=await this._worker(l);if(e.isDisposed())return;let r=await g.getRenameInfo(o,u,{allowRenameOfImportPath:!1});if(r.canRename===!1)return{edits:[],rejectReason:r.localizedErrorMessage};if(r.fileToRename!==void 0)throw new Error("Renaming files is not supported.");let p=await g.findRenameLocations(o,u,!1,!1,!1);if(!p||e.isDisposed())return;let d=[];for(let f of p){let h=this._libFiles.getOrCreateModel(f.fileName);if(h)d.push({resource:h.uri,versionId:void 0,textEdit:{range:this._textSpanToRange(h,f.textSpan),text:s}});else throw new Error(`Unknown file ${f.fileName}.`)}return{edits:d}}},ae=class extends w{async provideInlayHints(e,t,s){let i=e.uri,l=i.toString(),o=e.getOffsetAt({lineNumber:t.startLineNumber,column:t.startColumn}),u=e.getOffsetAt({lineNumber:t.endLineNumber,column:t.endColumn}),g=await this._worker(i);return e.isDisposed()?null:{hints:(await g.provideInlayHints(l,o,u)).map(d=>L(T({},d),{label:d.text,position:e.getPositionAt(d.position),kind:this._convertHintKind(d.kind)})),dispose:()=>{}}}_convertHintKind(e){switch(e){case"Parameter":return a.languages.InlayHintKind.Parameter;case"Type":return a.languages.InlayHintKind.Type;default:return a.languages.InlayHintKind.Type}}}});le();export{w as Adapter,ie as CodeActionAdaptor,Z as DefinitionAdapter,q as DiagnosticsAdapter,Y as DocumentHighlightAdapter,re as FormatAdapter,S as FormatHelper,se as FormatOnTypeAdapter,ae as InlayHintsAdapter,c as Kind,Q as LibFiles,te as OutlineAdapter,X as QuickInfoAdapter,ee as ReferenceAdapter,ne as RenameAdapter,R as SignatureHelpAdapter,C as SuggestAdapter,J as WorkerManager,D as flattenDiagnosticMessageText,de as getJavaScriptWorker,pe as getTypeScriptWorker,ge as setupJavaScript,ue as setupTypeScript};
|
|
/*! Bundled license information:
|
|
|
|
monaco-editor/esm/vs/language/typescript/tsMode.js:
|
|
(*!-----------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Version: 0.43.0(94c055bcbdd49f04a0fa15515e848542a79fb948)
|
|
* Released under the MIT license
|
|
* https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
|
|
*-----------------------------------------------------------------------------*)
|
|
*/
|