monaco-editor11 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/css.worker-C7FogG4G.js +93 -0
- package/dist/assets/editor.worker-iXcRX1Tq.js +26 -0
- package/dist/assets/html.worker-C8VxctEJ.js +470 -0
- package/dist/assets/json.worker-CMC9kgPL.js +58 -0
- package/dist/assets/ts.worker-CtTJ3hNN.js +67731 -0
- package/dist/index.d.ts +0 -6
- package/dist/monaco-editor11.es.js +49 -78
- package/dist/monaco-editor11.umd.js +1 -50
- package/dist/monaco.d.ts +8 -0
- package/dist/workers/common/initialize.js +16 -0
- package/dist/workers/common/workers.js +141 -0
- package/dist/workers/editor/common/abstractSyntaxTokenBackend.js +128 -0
- package/dist/workers/editor/common/abstractText.js +89 -0
- package/dist/workers/editor/common/ast.js +485 -0
- package/dist/workers/editor/common/autoIndent.js +390 -0
- package/dist/workers/editor/common/beforeEditPositionMapper.js +110 -0
- package/dist/workers/editor/common/bracketPairsImpl.js +717 -0
- package/dist/workers/editor/common/bracketPairsTree.js +343 -0
- package/dist/workers/editor/common/brackets.js +108 -0
- package/dist/workers/editor/common/characterClassifier.js +59 -0
- package/dist/workers/editor/common/characterPair.js +40 -0
- package/dist/workers/editor/common/colorizedBracketPairsDecorationProvider.js +97 -0
- package/dist/workers/editor/common/columnRange.js +35 -0
- package/dist/workers/editor/common/combineTextEditInfos.js +124 -0
- package/dist/workers/editor/common/common.js +20 -0
- package/dist/workers/editor/common/computeMovedLines.js +249 -0
- package/dist/workers/editor/common/concat23Trees.js +192 -0
- package/dist/workers/editor/common/contiguousMultilineTokens.js +32 -0
- package/dist/workers/editor/common/contiguousMultilineTokensBuilder.js +23 -0
- package/dist/workers/editor/common/contiguousTokensEditing.js +128 -0
- package/dist/workers/editor/common/contiguousTokensStore.js +207 -0
- package/dist/workers/editor/common/coordinatesConverter.js +51 -0
- package/dist/workers/editor/common/cursor.js +899 -0
- package/dist/workers/editor/common/cursorAtomicMoveOperations.js +145 -0
- package/dist/workers/editor/common/cursorCollection.js +194 -0
- package/dist/workers/editor/common/cursorColumnSelection.js +93 -0
- package/dist/workers/editor/common/cursorColumns.js +112 -0
- package/dist/workers/editor/common/cursorCommon.js +250 -0
- package/dist/workers/editor/common/cursorContext.js +15 -0
- package/dist/workers/editor/common/cursorDeleteOperations.js +231 -0
- package/dist/workers/editor/common/cursorMoveCommands.js +676 -0
- package/dist/workers/editor/common/cursorMoveOperations.js +290 -0
- package/dist/workers/editor/common/cursorTypeEditOperations.js +968 -0
- package/dist/workers/editor/common/cursorTypeOperations.js +173 -0
- package/dist/workers/editor/common/cursorUtils.js +75 -0
- package/dist/workers/editor/common/cursorWordOperations.js +720 -0
- package/dist/workers/editor/common/defaultDocumentColorsComputer.js +138 -0
- package/dist/workers/editor/common/defaultLinesDiffComputer.js +188 -0
- package/dist/workers/editor/common/diffAlgorithm.js +139 -0
- package/dist/workers/editor/common/diffEditor.js +38 -0
- package/dist/workers/editor/common/dynamicProgrammingDiffing.js +101 -0
- package/dist/workers/editor/common/edit.js +183 -0
- package/dist/workers/editor/common/editOperation.js +36 -0
- package/dist/workers/editor/common/editStack.js +363 -0
- package/dist/workers/editor/common/editorAction.js +26 -0
- package/dist/workers/editor/common/editorBaseApi.js +43 -0
- package/dist/workers/editor/common/editorColorRegistry.js +102 -0
- package/dist/workers/editor/common/editorCommon.js +13 -0
- package/dist/workers/editor/common/editorConfigurationSchema.js +338 -0
- package/dist/workers/editor/common/editorContextKeys.js +84 -0
- package/dist/workers/editor/common/editorFeatures.js +17 -0
- package/dist/workers/editor/common/editorOptions.js +3440 -0
- package/dist/workers/editor/common/editorTheme.js +23 -0
- package/dist/workers/editor/common/editorWebWorker.js +299 -0
- package/dist/workers/editor/common/editorWorker.js +9 -0
- package/dist/workers/editor/common/editorWorkerHost.js +15 -0
- package/dist/workers/editor/common/editorZoom.js +26 -0
- package/dist/workers/editor/common/electricCharacter.js +55 -0
- package/dist/workers/editor/common/encodedTokenAttributes.js +79 -0
- package/dist/workers/editor/common/enterAction.js +53 -0
- package/dist/workers/editor/common/eolCounter.js +44 -0
- package/dist/workers/editor/common/findSectionHeaders.js +128 -0
- package/dist/workers/editor/common/fixBrackets.js +67 -0
- package/dist/workers/editor/common/fixedArray.js +70 -0
- package/dist/workers/editor/common/fontInfo.js +172 -0
- package/dist/workers/editor/common/fontInfoFromSettings.js +29 -0
- package/dist/workers/editor/common/getIconClasses.js +106 -0
- package/dist/workers/editor/common/getPositionOffsetTransformerFromTextModel.js +24 -0
- package/dist/workers/editor/common/glyphLanesModel.js +61 -0
- package/dist/workers/editor/common/guidesTextModelPart.js +405 -0
- package/dist/workers/editor/common/heuristicSequenceOptimizations.js +374 -0
- package/dist/workers/editor/common/indentRules.js +63 -0
- package/dist/workers/editor/common/indentation.js +39 -0
- package/dist/workers/editor/common/indentationGuesser.js +178 -0
- package/dist/workers/editor/common/indentationLineProcessor.js +193 -0
- package/dist/workers/editor/common/inlineDecorations.js +26 -0
- package/dist/workers/editor/common/inplaceReplaceSupport.js +87 -0
- package/dist/workers/editor/common/inputMode.js +22 -0
- package/dist/workers/editor/common/intervalTree.js +1002 -0
- package/dist/workers/editor/common/language.js +9 -0
- package/dist/workers/editor/common/languageBracketsConfiguration.js +133 -0
- package/dist/workers/editor/common/languageConfiguration.js +138 -0
- package/dist/workers/editor/common/languageConfigurationRegistry.js +361 -0
- package/dist/workers/editor/common/languageFeatureDebounce.js +137 -0
- package/dist/workers/editor/common/languageFeatureRegistry.js +180 -0
- package/dist/workers/editor/common/languageFeatures.js +9 -0
- package/dist/workers/editor/common/languageFeaturesService.js +47 -0
- package/dist/workers/editor/common/languageSelector.js +112 -0
- package/dist/workers/editor/common/languageService.js +92 -0
- package/dist/workers/editor/common/languages.js +522 -0
- package/dist/workers/editor/common/languagesAssociations.js +193 -0
- package/dist/workers/editor/common/languagesRegistry.js +237 -0
- package/dist/workers/editor/common/legacyLinesDiffComputer.js +468 -0
- package/dist/workers/editor/common/length.js +129 -0
- package/dist/workers/editor/common/lineDecorations.js +208 -0
- package/dist/workers/editor/common/lineEdit.js +75 -0
- package/dist/workers/editor/common/lineHeights.js +370 -0
- package/dist/workers/editor/common/linePart.js +25 -0
- package/dist/workers/editor/common/lineRange.js +312 -0
- package/dist/workers/editor/common/lineSequence.js +36 -0
- package/dist/workers/editor/common/lineTokens.js +405 -0
- package/dist/workers/editor/common/linesDiffComputer.js +29 -0
- package/dist/workers/editor/common/linesDiffComputers.js +13 -0
- package/dist/workers/editor/common/linesLayout.js +765 -0
- package/dist/workers/editor/common/linesSliceCharSequence.js +205 -0
- package/dist/workers/editor/common/linkComputer.js +269 -0
- package/dist/workers/editor/common/markerDecorations.js +9 -0
- package/dist/workers/editor/common/markerDecorationsService.js +248 -0
- package/dist/workers/editor/common/minimapTokensColorTracker.js +58 -0
- package/dist/workers/editor/common/mirrorTextModel.js +117 -0
- package/dist/workers/editor/common/model.js +9 -0
- package/dist/workers/editor/common/modelLineProjection.js +350 -0
- package/dist/workers/editor/common/modelLineProjectionData.js +297 -0
- package/dist/workers/editor/common/modelService.js +413 -0
- package/dist/workers/editor/common/modesRegistry.js +75 -0
- package/dist/workers/editor/common/monospaceLineBreaksComputer.js +473 -0
- package/dist/workers/editor/common/myersDiffAlgorithm.js +159 -0
- package/dist/workers/editor/common/nodeReader.js +127 -0
- package/dist/workers/editor/common/nullTokenize.js +29 -0
- package/dist/workers/editor/common/offsetRange.js +225 -0
- package/dist/workers/editor/common/onEnter.js +109 -0
- package/dist/workers/editor/common/oneCursor.js +117 -0
- package/dist/workers/editor/common/overviewZoneManager.js +176 -0
- package/dist/workers/editor/common/parser.js +121 -0
- package/dist/workers/editor/common/pieceTreeBase.js +1473 -0
- package/dist/workers/editor/common/pieceTreeTextBuffer.js +461 -0
- package/dist/workers/editor/common/pieceTreeTextBufferBuilder.js +140 -0
- package/dist/workers/editor/common/point.js +50 -0
- package/dist/workers/editor/common/position.js +142 -0
- package/dist/workers/editor/common/positionToOffset.js +17 -0
- package/dist/workers/editor/common/positionToOffsetImpl.js +98 -0
- package/dist/workers/editor/common/prefixSumComputer.js +226 -0
- package/dist/workers/editor/common/range.js +421 -0
- package/dist/workers/editor/common/rangeMapping.js +229 -0
- package/dist/workers/editor/common/rangeSingleLine.js +17 -0
- package/dist/workers/editor/common/rbTreeBase.js +362 -0
- package/dist/workers/editor/common/rect.js +163 -0
- package/dist/workers/editor/common/replaceCommand.js +158 -0
- package/dist/workers/editor/common/resolverService.js +5 -0
- package/dist/workers/editor/common/rgba.js +35 -0
- package/dist/workers/editor/common/richEditBrackets.js +356 -0
- package/dist/workers/editor/common/selection.js +145 -0
- package/dist/workers/editor/common/semanticTokensDto.js +82 -0
- package/dist/workers/editor/common/semanticTokensProviderStyling.js +263 -0
- package/dist/workers/editor/common/semanticTokensStyling.js +9 -0
- package/dist/workers/editor/common/semanticTokensStylingService.js +47 -0
- package/dist/workers/editor/common/shiftCommand.js +241 -0
- package/dist/workers/editor/common/smallImmutableSet.js +108 -0
- package/dist/workers/editor/common/sparseMultilineTokens.js +548 -0
- package/dist/workers/editor/common/sparseTokensStore.js +210 -0
- package/dist/workers/editor/common/standaloneEnums.js +1017 -0
- package/dist/workers/editor/common/standaloneStrings.js +42 -0
- package/dist/workers/editor/common/stringBuilder.js +122 -0
- package/dist/workers/editor/common/stringEdit.js +165 -0
- package/dist/workers/editor/common/supports.js +58 -0
- package/dist/workers/editor/common/surroundSelectionCommand.js +44 -0
- package/dist/workers/editor/common/textChange.js +248 -0
- package/dist/workers/editor/common/textEdit.js +269 -0
- package/dist/workers/editor/common/textLength.js +87 -0
- package/dist/workers/editor/common/textModel.js +2031 -0
- package/dist/workers/editor/common/textModelBracketPairs.js +45 -0
- package/dist/workers/editor/common/textModelDefaults.js +18 -0
- package/dist/workers/editor/common/textModelEditSource.js +166 -0
- package/dist/workers/editor/common/textModelEvents.js +216 -0
- package/dist/workers/editor/common/textModelGuides.js +40 -0
- package/dist/workers/editor/common/textModelPart.js +23 -0
- package/dist/workers/editor/common/textModelSearch.js +455 -0
- package/dist/workers/editor/common/textModelStringEdit.js +11 -0
- package/dist/workers/editor/common/textModelSync.impl.js +307 -0
- package/dist/workers/editor/common/textModelText.js +26 -0
- package/dist/workers/editor/common/textModelTokens.js +436 -0
- package/dist/workers/editor/common/textResourceConfiguration.js +6 -0
- package/dist/workers/editor/common/textToHtmlTokenizer.js +139 -0
- package/dist/workers/editor/common/tokenStore.js +407 -0
- package/dist/workers/editor/common/tokenWithTextArray.js +73 -0
- package/dist/workers/editor/common/tokenization.js +287 -0
- package/dist/workers/editor/common/tokenizationRegistry.js +123 -0
- package/dist/workers/editor/common/tokenizationTextModelPart.js +275 -0
- package/dist/workers/editor/common/tokenizer.js +301 -0
- package/dist/workers/editor/common/tokenizerSyntaxTokenBackend.js +261 -0
- package/dist/workers/editor/common/treeSitterLibraryService.js +9 -0
- package/dist/workers/editor/common/treeSitterSyntaxTokenBackend.js +167 -0
- package/dist/workers/editor/common/treeSitterThemeService.js +9 -0
- package/dist/workers/editor/common/treeSitterTokenizationImpl.js +713 -0
- package/dist/workers/editor/common/treeSitterTree.js +395 -0
- package/dist/workers/editor/common/treeViewsDnd.js +24 -0
- package/dist/workers/editor/common/treeViewsDndService.js +12 -0
- package/dist/workers/editor/common/trimTrailingWhitespaceCommand.js +98 -0
- package/dist/workers/editor/common/unicodeTextModelHighlighter.js +188 -0
- package/dist/workers/editor/common/utils.js +62 -0
- package/dist/workers/editor/common/viewContext.js +22 -0
- package/dist/workers/editor/common/viewEventHandler.js +186 -0
- package/dist/workers/editor/common/viewEvents.js +180 -0
- package/dist/workers/editor/common/viewLayout.js +368 -0
- package/dist/workers/editor/common/viewLineRenderer.js +948 -0
- package/dist/workers/editor/common/viewLinesViewportData.js +30 -0
- package/dist/workers/editor/common/viewModel.js +98 -0
- package/dist/workers/editor/common/viewModelDecoration.js +55 -0
- package/dist/workers/editor/common/viewModelDecorations.js +132 -0
- package/dist/workers/editor/common/viewModelEventDispatcher.js +398 -0
- package/dist/workers/editor/common/viewModelImpl.js +1163 -0
- package/dist/workers/editor/common/viewModelLines.js +938 -0
- package/dist/workers/editor/common/wordCharacterClassifier.js +87 -0
- package/dist/workers/editor/common/wordHelper.js +127 -0
- package/dist/workers/editor/editor.worker.js +11 -0
- package/dist/workers/language/css.worker.js +8 -0
- package/dist/workers/language/cssMode.js +198 -0
- package/dist/workers/language/cssWorker.js +183 -0
- package/dist/workers/language/html.worker.js +8 -0
- package/dist/workers/language/htmlMode.js +213 -0
- package/dist/workers/language/htmlWorker.js +126 -0
- package/dist/workers/language/json.worker.js +8 -0
- package/dist/workers/language/jsonMode.js +224 -0
- package/dist/workers/language/jsonWorker.js +187 -0
- package/dist/workers/language/languageFeatures.js +1009 -0
- package/dist/workers/language/lib.index.js +103 -0
- package/dist/workers/language/lib.js +1107 -0
- package/dist/workers/language/lspLanguageFeatures.js +716 -0
- package/dist/workers/language/monaco.contribution.js +144 -0
- package/dist/workers/language/tokenization.js +189 -0
- package/dist/workers/language/ts.worker.js +14 -0
- package/dist/workers/language/tsMode.js +212 -0
- package/dist/workers/language/tsWorker.js +352 -0
- package/dist/workers/language/typescriptServices.js +210154 -0
- package/dist/workers/language/typescriptServicesMetadata.js +3 -0
- package/dist/workers/language/workerManager.js +65 -0
- package/package.json +3 -2
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import * as typescriptServices from './lib/typescriptServices.js';
|
|
2
|
+
import { typescript, createLanguageService, ScriptKind } from './lib/typescriptServices.js';
|
|
3
|
+
import { libFileMap } from './lib/lib.js';
|
|
4
|
+
|
|
5
|
+
function fileNameIsLib(resource) {
|
|
6
|
+
if (typeof resource === "string") {
|
|
7
|
+
if (/^file:\/\/\//.test(resource)) {
|
|
8
|
+
return !!libFileMap[resource.substr(8)];
|
|
9
|
+
}
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
if (resource.path.indexOf("/lib.") === 0) {
|
|
13
|
+
return !!libFileMap[resource.path.slice(1)];
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
class TypeScriptWorker {
|
|
18
|
+
constructor(ctx, createData) {
|
|
19
|
+
this._extraLibs = /* @__PURE__ */ Object.create(null);
|
|
20
|
+
this._languageService = createLanguageService(this);
|
|
21
|
+
this._ctx = ctx;
|
|
22
|
+
this._compilerOptions = createData.compilerOptions;
|
|
23
|
+
this._extraLibs = createData.extraLibs;
|
|
24
|
+
this._inlayHintsOptions = createData.inlayHintsOptions;
|
|
25
|
+
}
|
|
26
|
+
// --- language service host ---------------
|
|
27
|
+
getCompilationSettings() {
|
|
28
|
+
return this._compilerOptions;
|
|
29
|
+
}
|
|
30
|
+
getLanguageService() {
|
|
31
|
+
return this._languageService;
|
|
32
|
+
}
|
|
33
|
+
getExtraLibs() {
|
|
34
|
+
return this._extraLibs;
|
|
35
|
+
}
|
|
36
|
+
getScriptFileNames() {
|
|
37
|
+
const allModels = this._ctx.getMirrorModels().map((model) => model.uri);
|
|
38
|
+
const models = allModels.filter((uri) => !fileNameIsLib(uri)).map((uri) => uri.toString());
|
|
39
|
+
return models.concat(Object.keys(this._extraLibs));
|
|
40
|
+
}
|
|
41
|
+
_getModel(fileName) {
|
|
42
|
+
let models = this._ctx.getMirrorModels();
|
|
43
|
+
for (let i = 0; i < models.length; i++) {
|
|
44
|
+
const uri = models[i].uri;
|
|
45
|
+
if (uri.toString() === fileName || uri.toString(true) === fileName) {
|
|
46
|
+
return models[i];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
getScriptVersion(fileName) {
|
|
52
|
+
let model = this._getModel(fileName);
|
|
53
|
+
if (model) {
|
|
54
|
+
return model.version.toString();
|
|
55
|
+
} else if (this.isDefaultLibFileName(fileName)) {
|
|
56
|
+
return "1";
|
|
57
|
+
} else if (fileName in this._extraLibs) {
|
|
58
|
+
return String(this._extraLibs[fileName].version);
|
|
59
|
+
}
|
|
60
|
+
return "";
|
|
61
|
+
}
|
|
62
|
+
async getScriptText(fileName) {
|
|
63
|
+
return this._getScriptText(fileName);
|
|
64
|
+
}
|
|
65
|
+
_getScriptText(fileName) {
|
|
66
|
+
let text;
|
|
67
|
+
let model = this._getModel(fileName);
|
|
68
|
+
const libizedFileName = "lib." + fileName + ".d.ts";
|
|
69
|
+
if (model) {
|
|
70
|
+
text = model.getValue();
|
|
71
|
+
} else if (fileName in libFileMap) {
|
|
72
|
+
text = libFileMap[fileName];
|
|
73
|
+
} else if (libizedFileName in libFileMap) {
|
|
74
|
+
text = libFileMap[libizedFileName];
|
|
75
|
+
} else if (fileName in this._extraLibs) {
|
|
76
|
+
text = this._extraLibs[fileName].content;
|
|
77
|
+
} else {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
return text;
|
|
81
|
+
}
|
|
82
|
+
getScriptSnapshot(fileName) {
|
|
83
|
+
const text = this._getScriptText(fileName);
|
|
84
|
+
if (text === void 0) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
getText: (start, end) => text.substring(start, end),
|
|
89
|
+
getLength: () => text.length,
|
|
90
|
+
getChangeRange: () => void 0
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
getScriptKind(fileName) {
|
|
94
|
+
const suffix = fileName.substr(fileName.lastIndexOf(".") + 1);
|
|
95
|
+
switch (suffix) {
|
|
96
|
+
case "ts":
|
|
97
|
+
return ScriptKind.TS;
|
|
98
|
+
case "tsx":
|
|
99
|
+
return ScriptKind.TSX;
|
|
100
|
+
case "js":
|
|
101
|
+
return ScriptKind.JS;
|
|
102
|
+
case "jsx":
|
|
103
|
+
return ScriptKind.JSX;
|
|
104
|
+
default:
|
|
105
|
+
return this.getCompilationSettings().allowJs ? ScriptKind.JS : ScriptKind.TS;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
getCurrentDirectory() {
|
|
109
|
+
return "";
|
|
110
|
+
}
|
|
111
|
+
getDefaultLibFileName(options) {
|
|
112
|
+
switch (options.target) {
|
|
113
|
+
case 99:
|
|
114
|
+
const esnext = "lib.esnext.full.d.ts";
|
|
115
|
+
if (esnext in libFileMap || esnext in this._extraLibs) return esnext;
|
|
116
|
+
case 7:
|
|
117
|
+
case 6:
|
|
118
|
+
case 5:
|
|
119
|
+
case 4:
|
|
120
|
+
case 3:
|
|
121
|
+
case 2:
|
|
122
|
+
default:
|
|
123
|
+
const eslib = `lib.es${2013 + (options.target || 99)}.full.d.ts`;
|
|
124
|
+
if (eslib in libFileMap || eslib in this._extraLibs) {
|
|
125
|
+
return eslib;
|
|
126
|
+
}
|
|
127
|
+
return "lib.es6.d.ts";
|
|
128
|
+
// We don't use lib.es2015.full.d.ts due to breaking change.
|
|
129
|
+
case 1:
|
|
130
|
+
case 0:
|
|
131
|
+
return "lib.d.ts";
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
isDefaultLibFileName(fileName) {
|
|
135
|
+
return fileName === this.getDefaultLibFileName(this._compilerOptions);
|
|
136
|
+
}
|
|
137
|
+
readFile(path) {
|
|
138
|
+
return this._getScriptText(path);
|
|
139
|
+
}
|
|
140
|
+
fileExists(path) {
|
|
141
|
+
return this._getScriptText(path) !== void 0;
|
|
142
|
+
}
|
|
143
|
+
async getLibFiles() {
|
|
144
|
+
return libFileMap;
|
|
145
|
+
}
|
|
146
|
+
// --- language features
|
|
147
|
+
static clearFiles(tsDiagnostics) {
|
|
148
|
+
const diagnostics = [];
|
|
149
|
+
for (const tsDiagnostic of tsDiagnostics) {
|
|
150
|
+
const diagnostic = { ...tsDiagnostic };
|
|
151
|
+
diagnostic.file = diagnostic.file ? { fileName: diagnostic.file.fileName } : void 0;
|
|
152
|
+
if (tsDiagnostic.relatedInformation) {
|
|
153
|
+
diagnostic.relatedInformation = [];
|
|
154
|
+
for (const tsRelatedDiagnostic of tsDiagnostic.relatedInformation) {
|
|
155
|
+
const relatedDiagnostic = { ...tsRelatedDiagnostic };
|
|
156
|
+
relatedDiagnostic.file = relatedDiagnostic.file ? { fileName: relatedDiagnostic.file.fileName } : void 0;
|
|
157
|
+
diagnostic.relatedInformation.push(relatedDiagnostic);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
diagnostics.push(diagnostic);
|
|
161
|
+
}
|
|
162
|
+
return diagnostics;
|
|
163
|
+
}
|
|
164
|
+
async getSyntacticDiagnostics(fileName) {
|
|
165
|
+
if (fileNameIsLib(fileName)) {
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
const diagnostics = this._languageService.getSyntacticDiagnostics(fileName);
|
|
169
|
+
return TypeScriptWorker.clearFiles(diagnostics);
|
|
170
|
+
}
|
|
171
|
+
async getSemanticDiagnostics(fileName) {
|
|
172
|
+
if (fileNameIsLib(fileName)) {
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
const diagnostics = this._languageService.getSemanticDiagnostics(fileName);
|
|
176
|
+
return TypeScriptWorker.clearFiles(diagnostics);
|
|
177
|
+
}
|
|
178
|
+
async getSuggestionDiagnostics(fileName) {
|
|
179
|
+
if (fileNameIsLib(fileName)) {
|
|
180
|
+
return [];
|
|
181
|
+
}
|
|
182
|
+
const diagnostics = this._languageService.getSuggestionDiagnostics(fileName);
|
|
183
|
+
return TypeScriptWorker.clearFiles(diagnostics);
|
|
184
|
+
}
|
|
185
|
+
async getCompilerOptionsDiagnostics(fileName) {
|
|
186
|
+
if (fileNameIsLib(fileName)) {
|
|
187
|
+
return [];
|
|
188
|
+
}
|
|
189
|
+
const diagnostics = this._languageService.getCompilerOptionsDiagnostics();
|
|
190
|
+
return TypeScriptWorker.clearFiles(diagnostics);
|
|
191
|
+
}
|
|
192
|
+
async getCompletionsAtPosition(fileName, position) {
|
|
193
|
+
if (fileNameIsLib(fileName)) {
|
|
194
|
+
return void 0;
|
|
195
|
+
}
|
|
196
|
+
return this._languageService.getCompletionsAtPosition(fileName, position, void 0);
|
|
197
|
+
}
|
|
198
|
+
async getCompletionEntryDetails(fileName, position, entry) {
|
|
199
|
+
return this._languageService.getCompletionEntryDetails(
|
|
200
|
+
fileName,
|
|
201
|
+
position,
|
|
202
|
+
entry,
|
|
203
|
+
void 0,
|
|
204
|
+
void 0,
|
|
205
|
+
void 0,
|
|
206
|
+
void 0
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
async getSignatureHelpItems(fileName, position, options) {
|
|
210
|
+
if (fileNameIsLib(fileName)) {
|
|
211
|
+
return void 0;
|
|
212
|
+
}
|
|
213
|
+
return this._languageService.getSignatureHelpItems(fileName, position, options);
|
|
214
|
+
}
|
|
215
|
+
async getQuickInfoAtPosition(fileName, position) {
|
|
216
|
+
if (fileNameIsLib(fileName)) {
|
|
217
|
+
return void 0;
|
|
218
|
+
}
|
|
219
|
+
return this._languageService.getQuickInfoAtPosition(fileName, position);
|
|
220
|
+
}
|
|
221
|
+
async getDocumentHighlights(fileName, position, filesToSearch) {
|
|
222
|
+
if (fileNameIsLib(fileName)) {
|
|
223
|
+
return void 0;
|
|
224
|
+
}
|
|
225
|
+
return this._languageService.getDocumentHighlights(fileName, position, filesToSearch);
|
|
226
|
+
}
|
|
227
|
+
async getDefinitionAtPosition(fileName, position) {
|
|
228
|
+
if (fileNameIsLib(fileName)) {
|
|
229
|
+
return void 0;
|
|
230
|
+
}
|
|
231
|
+
return this._languageService.getDefinitionAtPosition(fileName, position);
|
|
232
|
+
}
|
|
233
|
+
async getReferencesAtPosition(fileName, position) {
|
|
234
|
+
if (fileNameIsLib(fileName)) {
|
|
235
|
+
return void 0;
|
|
236
|
+
}
|
|
237
|
+
return this._languageService.getReferencesAtPosition(fileName, position);
|
|
238
|
+
}
|
|
239
|
+
async getNavigationTree(fileName) {
|
|
240
|
+
if (fileNameIsLib(fileName)) {
|
|
241
|
+
return void 0;
|
|
242
|
+
}
|
|
243
|
+
return this._languageService.getNavigationTree(fileName);
|
|
244
|
+
}
|
|
245
|
+
async getFormattingEditsForDocument(fileName, options) {
|
|
246
|
+
if (fileNameIsLib(fileName)) {
|
|
247
|
+
return [];
|
|
248
|
+
}
|
|
249
|
+
return this._languageService.getFormattingEditsForDocument(fileName, options);
|
|
250
|
+
}
|
|
251
|
+
async getFormattingEditsForRange(fileName, start, end, options) {
|
|
252
|
+
if (fileNameIsLib(fileName)) {
|
|
253
|
+
return [];
|
|
254
|
+
}
|
|
255
|
+
return this._languageService.getFormattingEditsForRange(fileName, start, end, options);
|
|
256
|
+
}
|
|
257
|
+
async getFormattingEditsAfterKeystroke(fileName, postion, ch, options) {
|
|
258
|
+
if (fileNameIsLib(fileName)) {
|
|
259
|
+
return [];
|
|
260
|
+
}
|
|
261
|
+
return this._languageService.getFormattingEditsAfterKeystroke(fileName, postion, ch, options);
|
|
262
|
+
}
|
|
263
|
+
async findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename) {
|
|
264
|
+
if (fileNameIsLib(fileName)) {
|
|
265
|
+
return void 0;
|
|
266
|
+
}
|
|
267
|
+
return this._languageService.findRenameLocations(
|
|
268
|
+
fileName,
|
|
269
|
+
position,
|
|
270
|
+
findInStrings,
|
|
271
|
+
findInComments,
|
|
272
|
+
providePrefixAndSuffixTextForRename
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
async getRenameInfo(fileName, position, options) {
|
|
276
|
+
if (fileNameIsLib(fileName)) {
|
|
277
|
+
return { canRename: false, localizedErrorMessage: "Cannot rename in lib file" };
|
|
278
|
+
}
|
|
279
|
+
return this._languageService.getRenameInfo(fileName, position, options);
|
|
280
|
+
}
|
|
281
|
+
async getEmitOutput(fileName, emitOnlyDtsFiles, forceDtsEmit) {
|
|
282
|
+
if (fileNameIsLib(fileName)) {
|
|
283
|
+
return { outputFiles: [], emitSkipped: true };
|
|
284
|
+
}
|
|
285
|
+
const emitOutput = this._languageService.getEmitOutput(
|
|
286
|
+
fileName,
|
|
287
|
+
emitOnlyDtsFiles,
|
|
288
|
+
forceDtsEmit
|
|
289
|
+
);
|
|
290
|
+
const diagnostics = emitOutput.diagnostics ? TypeScriptWorker.clearFiles(emitOutput.diagnostics) : void 0;
|
|
291
|
+
return { ...emitOutput, diagnostics };
|
|
292
|
+
}
|
|
293
|
+
async getCodeFixesAtPosition(fileName, start, end, errorCodes, formatOptions) {
|
|
294
|
+
if (fileNameIsLib(fileName)) {
|
|
295
|
+
return [];
|
|
296
|
+
}
|
|
297
|
+
const preferences = {};
|
|
298
|
+
try {
|
|
299
|
+
return this._languageService.getCodeFixesAtPosition(
|
|
300
|
+
fileName,
|
|
301
|
+
start,
|
|
302
|
+
end,
|
|
303
|
+
errorCodes,
|
|
304
|
+
formatOptions,
|
|
305
|
+
preferences
|
|
306
|
+
);
|
|
307
|
+
} catch {
|
|
308
|
+
return [];
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
async updateExtraLibs(extraLibs) {
|
|
312
|
+
this._extraLibs = extraLibs;
|
|
313
|
+
}
|
|
314
|
+
async provideInlayHints(fileName, start, end) {
|
|
315
|
+
if (fileNameIsLib(fileName)) {
|
|
316
|
+
return [];
|
|
317
|
+
}
|
|
318
|
+
const preferences = this._inlayHintsOptions ?? {};
|
|
319
|
+
const span = {
|
|
320
|
+
start,
|
|
321
|
+
length: end - start
|
|
322
|
+
};
|
|
323
|
+
try {
|
|
324
|
+
return this._languageService.provideInlayHints(fileName, span, preferences);
|
|
325
|
+
} catch {
|
|
326
|
+
return [];
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
function create(ctx, createData) {
|
|
331
|
+
let TSWorkerClass = TypeScriptWorker;
|
|
332
|
+
if (createData.customWorkerPath) {
|
|
333
|
+
if (typeof importScripts === "undefined") {
|
|
334
|
+
console.warn(
|
|
335
|
+
"Monaco is not using webworkers for background tasks, and that is needed to support the customWorkerPath flag"
|
|
336
|
+
);
|
|
337
|
+
} else {
|
|
338
|
+
self.importScripts(createData.customWorkerPath);
|
|
339
|
+
const workerFactoryFunc = self.customTSWorkerFactory;
|
|
340
|
+
if (!workerFactoryFunc) {
|
|
341
|
+
throw new Error(
|
|
342
|
+
`The script at ${createData.customWorkerPath} does not add customTSWorkerFactory to self`
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
TSWorkerClass = workerFactoryFunc(TypeScriptWorker, typescriptServices, libFileMap);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return new TSWorkerClass(ctx, createData);
|
|
349
|
+
}
|
|
350
|
+
globalThis.ts = typescript;
|
|
351
|
+
|
|
352
|
+
export { TypeScriptWorker, create };
|