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
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
export declare const createEditorWorker: () => Worker;
|
|
2
|
-
export declare const createHtmlWorker: () => Worker;
|
|
3
|
-
export declare const createCssWorker: () => Worker;
|
|
4
|
-
export declare const createJsonWorker: () => Worker;
|
|
5
|
-
export declare const createTsWorker: () => Worker;
|
|
6
1
|
declare global {
|
|
7
2
|
interface Window {
|
|
8
3
|
MonacoEnvironment?: {
|
|
@@ -11,4 +6,3 @@ declare global {
|
|
|
11
6
|
}
|
|
12
7
|
}
|
|
13
8
|
export declare const initMonacoWorker: () => void;
|
|
14
|
-
export * from 'monaco-editor';
|
|
@@ -1,83 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
self.onmessage = () => {
|
|
7
|
-
if (!isWorkerInitialized()) {
|
|
8
|
-
start(() => {
|
|
9
|
-
return {};
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
`, o = `import { initialize } from '../../common/initialize.js';
|
|
14
|
-
import { HTMLWorker } from './htmlWorker.js';
|
|
15
|
-
|
|
16
|
-
self.onmessage = () => {
|
|
17
|
-
initialize((ctx, createData) => {
|
|
18
|
-
return new HTMLWorker(ctx, createData);
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
`, i = `import { initialize } from '../../common/initialize.js';
|
|
22
|
-
import { CSSWorker } from './cssWorker.js';
|
|
23
|
-
|
|
24
|
-
self.onmessage = () => {
|
|
25
|
-
initialize((ctx, createData) => {
|
|
26
|
-
return new CSSWorker(ctx, createData);
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
`, s = `import { initialize } from '../../common/initialize.js';
|
|
30
|
-
import { JSONWorker } from './jsonWorker.js';
|
|
31
|
-
|
|
32
|
-
self.onmessage = () => {
|
|
33
|
-
initialize((ctx, createData) => {
|
|
34
|
-
return new JSONWorker(ctx, createData);
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
`, a = `import { initialize } from '../../common/initialize.js';
|
|
38
|
-
import * as typescriptServices from './lib/typescriptServices.js';
|
|
39
|
-
export { typescriptServices as ts };
|
|
40
|
-
import { create } from './tsWorker.js';
|
|
41
|
-
export { TypeScriptWorker } from './tsWorker.js';
|
|
42
|
-
export { libFileMap } from './lib/lib.js';
|
|
43
|
-
|
|
44
|
-
self.onmessage = () => {
|
|
45
|
-
initialize((ctx, createData) => {
|
|
46
|
-
return create(ctx, createData);
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export { create, initialize };
|
|
51
|
-
`, e = (t) => {
|
|
52
|
-
const r = new Blob([t], { type: "application/javascript" });
|
|
53
|
-
return new Worker(URL.createObjectURL(r), { type: "module" });
|
|
54
|
-
}, c = () => e(n), m = () => e(o), l = () => e(i), p = () => e(s), k = () => e(a), W = () => {
|
|
55
|
-
window.MonacoEnvironment = {
|
|
56
|
-
getWorker(t, r) {
|
|
57
|
-
switch (r) {
|
|
58
|
-
case "json":
|
|
59
|
-
return p();
|
|
60
|
-
case "css":
|
|
61
|
-
case "scss":
|
|
62
|
-
case "less":
|
|
63
|
-
return l();
|
|
64
|
-
case "html":
|
|
65
|
-
case "handlebars":
|
|
66
|
-
return m();
|
|
67
|
-
case "typescript":
|
|
68
|
-
case "javascript":
|
|
69
|
-
return k();
|
|
70
|
-
default:
|
|
71
|
-
return c();
|
|
72
|
-
}
|
|
1
|
+
function n(r) {
|
|
2
|
+
return new Worker(
|
|
3
|
+
"/assets/editor.worker-iXcRX1Tq.js",
|
|
4
|
+
{
|
|
5
|
+
name: r == null ? void 0 : r.name
|
|
73
6
|
}
|
|
74
|
-
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
function a(r) {
|
|
10
|
+
return new Worker(
|
|
11
|
+
"/assets/html.worker-C8VxctEJ.js",
|
|
12
|
+
{
|
|
13
|
+
name: r == null ? void 0 : r.name
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
function c(r) {
|
|
18
|
+
return new Worker(
|
|
19
|
+
"/assets/css.worker-C7FogG4G.js",
|
|
20
|
+
{
|
|
21
|
+
name: r == null ? void 0 : r.name
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
function k(r) {
|
|
26
|
+
return new Worker(
|
|
27
|
+
"/assets/json.worker-CMC9kgPL.js",
|
|
28
|
+
{
|
|
29
|
+
name: r == null ? void 0 : r.name
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
function s(r) {
|
|
34
|
+
return new Worker(
|
|
35
|
+
"/assets/ts.worker-CtTJ3hNN.js",
|
|
36
|
+
{
|
|
37
|
+
name: r == null ? void 0 : r.name
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
const W = () => {
|
|
42
|
+
try {
|
|
43
|
+
self.MonacoEnvironment = {
|
|
44
|
+
getWorker(r, e) {
|
|
45
|
+
return e == "json" ? new k() : e == "css" || e == "scss" || e == "less" ? new c() : e == "html" || e == "handlebars" || e == "razor" ? new a() : e == "typescript" || e == "javascript" ? new s() : new n();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
} catch (r) {
|
|
49
|
+
console.log("initMonacoWorker资源加载失败", r);
|
|
50
|
+
}
|
|
75
51
|
};
|
|
76
52
|
export {
|
|
77
|
-
l as createCssWorker,
|
|
78
|
-
c as createEditorWorker,
|
|
79
|
-
m as createHtmlWorker,
|
|
80
|
-
p as createJsonWorker,
|
|
81
|
-
k as createTsWorker,
|
|
82
53
|
W as initMonacoWorker
|
|
83
54
|
};
|
|
@@ -1,50 +1 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
export { initialize } from '../common/initialize.js';
|
|
3
|
-
import { start } from './editor.worker.start.js';
|
|
4
|
-
|
|
5
|
-
self.onmessage = () => {
|
|
6
|
-
if (!isWorkerInitialized()) {
|
|
7
|
-
start(() => {
|
|
8
|
-
return {};
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
`,f=`import { initialize } from '../../common/initialize.js';
|
|
13
|
-
import { HTMLWorker } from './htmlWorker.js';
|
|
14
|
-
|
|
15
|
-
self.onmessage = () => {
|
|
16
|
-
initialize((ctx, createData) => {
|
|
17
|
-
return new HTMLWorker(ctx, createData);
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
`,p=`import { initialize } from '../../common/initialize.js';
|
|
21
|
-
import { CSSWorker } from './cssWorker.js';
|
|
22
|
-
|
|
23
|
-
self.onmessage = () => {
|
|
24
|
-
initialize((ctx, createData) => {
|
|
25
|
-
return new CSSWorker(ctx, createData);
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
`,W=`import { initialize } from '../../common/initialize.js';
|
|
29
|
-
import { JSONWorker } from './jsonWorker.js';
|
|
30
|
-
|
|
31
|
-
self.onmessage = () => {
|
|
32
|
-
initialize((ctx, createData) => {
|
|
33
|
-
return new JSONWorker(ctx, createData);
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
`,k=`import { initialize } from '../../common/initialize.js';
|
|
37
|
-
import * as typescriptServices from './lib/typescriptServices.js';
|
|
38
|
-
export { typescriptServices as ts };
|
|
39
|
-
import { create } from './tsWorker.js';
|
|
40
|
-
export { TypeScriptWorker } from './tsWorker.js';
|
|
41
|
-
export { libFileMap } from './lib/lib.js';
|
|
42
|
-
|
|
43
|
-
self.onmessage = () => {
|
|
44
|
-
initialize((ctx, createData) => {
|
|
45
|
-
return create(ctx, createData);
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export { create, initialize };
|
|
50
|
-
`,n=r=>{const o=new Blob([r],{type:"application/javascript"});return new Worker(URL.createObjectURL(o),{type:"module"})},i=()=>n(l),s=()=>n(f),a=()=>n(p),c=()=>n(W),m=()=>n(k),u=()=>{window.MonacoEnvironment={getWorker(r,o){switch(o){case"json":return c();case"css":case"scss":case"less":return a();case"html":case"handlebars":return s();case"typescript":case"javascript":return m();default:return i()}}}};e.createCssWorker=a,e.createEditorWorker=i,e.createHtmlWorker=s,e.createJsonWorker=c,e.createTsWorker=m,e.initMonacoWorker=u,Object.keys(t).forEach(r=>{r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:()=>t[r]})}),Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(n,t){typeof exports=="object"&&typeof module<"u"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(n=typeof globalThis<"u"?globalThis:n||self,t(n.monacoEditor11={}))})(this,(function(n){"use strict";function t(e){return new Worker("/assets/editor.worker-iXcRX1Tq.js",{name:e==null?void 0:e.name})}function s(e){return new Worker("/assets/html.worker-C8VxctEJ.js",{name:e==null?void 0:e.name})}function c(e){return new Worker("/assets/css.worker-C7FogG4G.js",{name:e==null?void 0:e.name})}function a(e){return new Worker("/assets/json.worker-CMC9kgPL.js",{name:e==null?void 0:e.name})}function u(e){return new Worker("/assets/ts.worker-CtTJ3hNN.js",{name:e==null?void 0:e.name})}const f=()=>{try{self.MonacoEnvironment={getWorker(e,r){return r=="json"?new a:r=="css"||r=="scss"||r=="less"?new c:r=="html"||r=="handlebars"||r=="razor"?new s:r=="typescript"||r=="javascript"?new u:new t}}}catch(e){console.log("initMonacoWorker资源加载失败",e)}};n.initMonacoWorker=f,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/monaco.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { start } from '../editor/editor.worker.start.js';
|
|
2
|
+
|
|
3
|
+
let initialized = false;
|
|
4
|
+
function isWorkerInitialized() {
|
|
5
|
+
return initialized;
|
|
6
|
+
}
|
|
7
|
+
function initialize(callback) {
|
|
8
|
+
initialized = true;
|
|
9
|
+
self.onmessage = (m) => {
|
|
10
|
+
start((ctx) => {
|
|
11
|
+
return callback(ctx, m.data);
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { initialize, isWorkerInitialized };
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import '../editor/browser/coreCommands.js';
|
|
2
|
+
import '../editor/browser/widget/codeEditor/codeEditorWidget.js';
|
|
3
|
+
import '../editor/browser/widget/diffEditor/diffEditor.contribution.js';
|
|
4
|
+
import '../editor/contrib/anchorSelect/browser/anchorSelect.js';
|
|
5
|
+
import '../editor/contrib/bracketMatching/browser/bracketMatching.js';
|
|
6
|
+
import '../editor/contrib/caretOperations/browser/caretOperations.js';
|
|
7
|
+
import '../editor/contrib/caretOperations/browser/transpose.js';
|
|
8
|
+
import '../editor/contrib/clipboard/browser/clipboard.js';
|
|
9
|
+
import '../editor/contrib/codeAction/browser/codeActionContributions.js';
|
|
10
|
+
import '../editor/contrib/codelens/browser/codelensController.js';
|
|
11
|
+
import '../editor/contrib/colorPicker/browser/colorPickerContribution.js';
|
|
12
|
+
import '../editor/contrib/comment/browser/comment.js';
|
|
13
|
+
import '../editor/contrib/contextmenu/browser/contextmenu.js';
|
|
14
|
+
import '../editor/contrib/cursorUndo/browser/cursorUndo.js';
|
|
15
|
+
import '../editor/contrib/dnd/browser/dnd.js';
|
|
16
|
+
import '../editor/contrib/dropOrPasteInto/browser/copyPasteContribution.js';
|
|
17
|
+
import '../editor/contrib/dropOrPasteInto/browser/dropIntoEditorContribution.js';
|
|
18
|
+
import '../editor/contrib/find/browser/findController.js';
|
|
19
|
+
import '../editor/contrib/folding/browser/folding.js';
|
|
20
|
+
import '../editor/contrib/fontZoom/browser/fontZoom.js';
|
|
21
|
+
import '../editor/contrib/format/browser/formatActions.js';
|
|
22
|
+
import '../editor/contrib/documentSymbols/browser/documentSymbols.js';
|
|
23
|
+
import '../editor/contrib/inlineCompletions/browser/inlineCompletions.contribution.js';
|
|
24
|
+
import '../editor/contrib/inlineProgress/browser/inlineProgress.js';
|
|
25
|
+
import '../editor/contrib/gotoSymbol/browser/goToCommands.js';
|
|
26
|
+
import '../editor/contrib/gotoSymbol/browser/link/goToDefinitionAtPosition.js';
|
|
27
|
+
import '../editor/contrib/gotoError/browser/gotoError.js';
|
|
28
|
+
import '../editor/contrib/gpu/browser/gpuActions.js';
|
|
29
|
+
import '../editor/contrib/hover/browser/hoverContribution.js';
|
|
30
|
+
import '../editor/contrib/indentation/browser/indentation.js';
|
|
31
|
+
import '../editor/contrib/inlayHints/browser/inlayHintsContribution.js';
|
|
32
|
+
import '../editor/contrib/inPlaceReplace/browser/inPlaceReplace.js';
|
|
33
|
+
import '../editor/contrib/insertFinalNewLine/browser/insertFinalNewLine.js';
|
|
34
|
+
import '../editor/contrib/lineSelection/browser/lineSelection.js';
|
|
35
|
+
import '../editor/contrib/linesOperations/browser/linesOperations.js';
|
|
36
|
+
import '../editor/contrib/linkedEditing/browser/linkedEditing.js';
|
|
37
|
+
import '../editor/contrib/links/browser/links.js';
|
|
38
|
+
import '../editor/contrib/longLinesHelper/browser/longLinesHelper.js';
|
|
39
|
+
import '../editor/contrib/middleScroll/browser/middleScroll.contribution.js';
|
|
40
|
+
import '../editor/contrib/multicursor/browser/multicursor.js';
|
|
41
|
+
import '../editor/contrib/parameterHints/browser/parameterHints.js';
|
|
42
|
+
import '../editor/contrib/placeholderText/browser/placeholderText.contribution.js';
|
|
43
|
+
import '../editor/contrib/rename/browser/rename.js';
|
|
44
|
+
import '../editor/contrib/sectionHeaders/browser/sectionHeaders.js';
|
|
45
|
+
import '../editor/contrib/semanticTokens/browser/documentSemanticTokens.js';
|
|
46
|
+
import '../editor/contrib/semanticTokens/browser/viewportSemanticTokens.js';
|
|
47
|
+
import '../editor/contrib/smartSelect/browser/smartSelect.js';
|
|
48
|
+
import '../editor/contrib/snippet/browser/snippetController2.js';
|
|
49
|
+
import '../editor/contrib/stickyScroll/browser/stickyScrollContribution.js';
|
|
50
|
+
import '../editor/contrib/suggest/browser/suggestController.js';
|
|
51
|
+
import '../editor/contrib/suggest/browser/suggestInlineCompletions.js';
|
|
52
|
+
import '../editor/contrib/tokenization/browser/tokenization.js';
|
|
53
|
+
import '../editor/contrib/toggleTabFocusMode/browser/toggleTabFocusMode.js';
|
|
54
|
+
import '../editor/contrib/unicodeHighlighter/browser/unicodeHighlighter.js';
|
|
55
|
+
import '../editor/contrib/unusualLineTerminators/browser/unusualLineTerminators.js';
|
|
56
|
+
import '../editor/contrib/wordHighlighter/browser/wordHighlighter.js';
|
|
57
|
+
import '../editor/contrib/wordOperations/browser/wordOperations.js';
|
|
58
|
+
import '../editor/contrib/wordPartOperations/browser/wordPartOperations.js';
|
|
59
|
+
import '../editor/contrib/readOnlyMessage/browser/contribution.js';
|
|
60
|
+
import '../editor/contrib/diffEditorBreadcrumbs/browser/contribution.js';
|
|
61
|
+
import '../editor/contrib/floatingMenu/browser/floatingMenu.contribution.js';
|
|
62
|
+
import '../editor/common/standaloneStrings.js';
|
|
63
|
+
import '../base/browser/ui/codicons/codicon/codicon.css';
|
|
64
|
+
import '../base/browser/ui/codicons/codicon/codicon-modifiers.css';
|
|
65
|
+
import '../editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard.js';
|
|
66
|
+
import '../editor/standalone/browser/inspectTokens/inspectTokens.js';
|
|
67
|
+
import '../editor/standalone/browser/quickAccess/standaloneHelpQuickAccess.js';
|
|
68
|
+
import '../editor/standalone/browser/quickAccess/standaloneGotoLineQuickAccess.js';
|
|
69
|
+
import '../editor/standalone/browser/quickAccess/standaloneGotoSymbolQuickAccess.js';
|
|
70
|
+
import '../editor/standalone/browser/quickAccess/standaloneCommandsQuickAccess.js';
|
|
71
|
+
import '../editor/standalone/browser/referenceSearch/standaloneReferenceSearch.js';
|
|
72
|
+
import '../editor/standalone/browser/toggleHighContrast/toggleHighContrast.js';
|
|
73
|
+
import { editor } from '../editor/editor.api2.js';
|
|
74
|
+
|
|
75
|
+
function createTrustedTypesPolicy(policyName, policyOptions) {
|
|
76
|
+
const monacoEnvironment = globalThis.MonacoEnvironment;
|
|
77
|
+
if (monacoEnvironment?.createTrustedTypesPolicy) {
|
|
78
|
+
try {
|
|
79
|
+
return monacoEnvironment.createTrustedTypesPolicy(policyName, policyOptions);
|
|
80
|
+
} catch (err) {
|
|
81
|
+
console.error(err);
|
|
82
|
+
return void 0;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
return globalThis.trustedTypes?.createPolicy(policyName, policyOptions);
|
|
87
|
+
} catch (err) {
|
|
88
|
+
console.error(err);
|
|
89
|
+
return void 0;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
let ttPolicy;
|
|
93
|
+
if (typeof self === "object" && self.constructor && self.constructor.name === "DedicatedWorkerGlobalScope" && globalThis.workerttPolicy !== void 0) {
|
|
94
|
+
ttPolicy = globalThis.workerttPolicy;
|
|
95
|
+
} else {
|
|
96
|
+
ttPolicy = createTrustedTypesPolicy("defaultWorkerFactory", {
|
|
97
|
+
createScriptURL: (value) => value
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function getWorker(descriptor) {
|
|
101
|
+
const label = descriptor.label;
|
|
102
|
+
const monacoEnvironment = globalThis.MonacoEnvironment;
|
|
103
|
+
if (monacoEnvironment) {
|
|
104
|
+
if (typeof monacoEnvironment.getWorker === "function") {
|
|
105
|
+
return monacoEnvironment.getWorker("workerMain.js", label);
|
|
106
|
+
}
|
|
107
|
+
if (typeof monacoEnvironment.getWorkerUrl === "function") {
|
|
108
|
+
const workerUrl = monacoEnvironment.getWorkerUrl("workerMain.js", label);
|
|
109
|
+
return new Worker(
|
|
110
|
+
ttPolicy ? ttPolicy.createScriptURL(workerUrl) : workerUrl,
|
|
111
|
+
{ name: label, type: "module" }
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (descriptor.createWorker) {
|
|
116
|
+
return descriptor.createWorker();
|
|
117
|
+
}
|
|
118
|
+
throw new Error(
|
|
119
|
+
`You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker`
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
function createWebWorker(opts) {
|
|
123
|
+
const worker = Promise.resolve(
|
|
124
|
+
getWorker({
|
|
125
|
+
label: opts.label ?? "monaco-editor-worker",
|
|
126
|
+
moduleId: opts.moduleId,
|
|
127
|
+
createWorker: opts.createWorker
|
|
128
|
+
})
|
|
129
|
+
).then((w) => {
|
|
130
|
+
w.postMessage("ignore");
|
|
131
|
+
w.postMessage(opts.createData);
|
|
132
|
+
return w;
|
|
133
|
+
});
|
|
134
|
+
return editor.createWebWorker({
|
|
135
|
+
worker,
|
|
136
|
+
host: opts.host,
|
|
137
|
+
keepIdleModels: opts.keepIdleModels
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export { createWebWorker };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { equals } from '../../../../base/common/arrays.js';
|
|
2
|
+
import { RunOnceScheduler } from '../../../../base/common/async.js';
|
|
3
|
+
import { Emitter } from '../../../../base/common/event.js';
|
|
4
|
+
import { Disposable } from '../../../../base/common/lifecycle.js';
|
|
5
|
+
import { LineRange } from '../../core/ranges/lineRange.js';
|
|
6
|
+
import '../../../../base/common/observableInternal/index.js';
|
|
7
|
+
import { itemsEquals, itemEquals, equalsIfDefined } from '../../../../base/common/equals.js';
|
|
8
|
+
import { observableSignal } from '../../../../base/common/observableInternal/observables/observableSignal.js';
|
|
9
|
+
import { observableValueOpts } from '../../../../base/common/observableInternal/observables/observableValueOpts.js';
|
|
10
|
+
import { derivedOpts } from '../../../../base/common/observableInternal/observables/derived.js';
|
|
11
|
+
|
|
12
|
+
/*---------------------------------------------------------------------------------------------
|
|
13
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
14
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
15
|
+
*--------------------------------------------------------------------------------------------*/
|
|
16
|
+
/**
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
class AttachedViews {
|
|
20
|
+
constructor() {
|
|
21
|
+
this._onDidChangeVisibleRanges = new Emitter();
|
|
22
|
+
this.onDidChangeVisibleRanges = this._onDidChangeVisibleRanges.event;
|
|
23
|
+
this._views = new Set();
|
|
24
|
+
this._viewsChanged = observableSignal(this);
|
|
25
|
+
this.visibleLineRanges = derivedOpts({
|
|
26
|
+
owner: this,
|
|
27
|
+
equalsFn: itemsEquals(itemEquals())
|
|
28
|
+
}, reader => {
|
|
29
|
+
this._viewsChanged.read(reader);
|
|
30
|
+
const ranges = LineRange.joinMany([...this._views].map(view => view.state.read(reader)?.visibleLineRanges ?? []));
|
|
31
|
+
return ranges;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
attachView() {
|
|
35
|
+
const view = new AttachedViewImpl((state) => {
|
|
36
|
+
this._onDidChangeVisibleRanges.fire({ view, state });
|
|
37
|
+
});
|
|
38
|
+
this._views.add(view);
|
|
39
|
+
this._viewsChanged.trigger(undefined);
|
|
40
|
+
return view;
|
|
41
|
+
}
|
|
42
|
+
detachView(view) {
|
|
43
|
+
this._views.delete(view);
|
|
44
|
+
this._onDidChangeVisibleRanges.fire({ view, state: undefined });
|
|
45
|
+
this._viewsChanged.trigger(undefined);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
class AttachedViewState {
|
|
52
|
+
constructor(visibleLineRanges, stabilized) {
|
|
53
|
+
this.visibleLineRanges = visibleLineRanges;
|
|
54
|
+
this.stabilized = stabilized;
|
|
55
|
+
}
|
|
56
|
+
equals(other) {
|
|
57
|
+
if (this === other) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
if (!equals(this.visibleLineRanges, other.visibleLineRanges, (a, b) => a.equals(b))) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (this.stabilized !== other.stabilized) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
class AttachedViewImpl {
|
|
70
|
+
get state() { return this._state; }
|
|
71
|
+
constructor(handleStateChange) {
|
|
72
|
+
this.handleStateChange = handleStateChange;
|
|
73
|
+
this._state = observableValueOpts({ owner: this, equalsFn: equalsIfDefined((a, b) => a.equals(b)) }, undefined);
|
|
74
|
+
}
|
|
75
|
+
setVisibleLines(visibleLines, stabilized) {
|
|
76
|
+
const visibleLineRanges = visibleLines.map((line) => new LineRange(line.startLineNumber, line.endLineNumber + 1));
|
|
77
|
+
const state = new AttachedViewState(visibleLineRanges, stabilized);
|
|
78
|
+
this._state.set(state, undefined, undefined);
|
|
79
|
+
this.handleStateChange(state);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
class AttachedViewHandler extends Disposable {
|
|
83
|
+
get lineRanges() { return this._lineRanges; }
|
|
84
|
+
constructor(_refreshTokens) {
|
|
85
|
+
super();
|
|
86
|
+
this._refreshTokens = _refreshTokens;
|
|
87
|
+
this.runner = this._register(new RunOnceScheduler(() => this.update(), 50));
|
|
88
|
+
this._computedLineRanges = [];
|
|
89
|
+
this._lineRanges = [];
|
|
90
|
+
}
|
|
91
|
+
update() {
|
|
92
|
+
if (equals(this._computedLineRanges, this._lineRanges, (a, b) => a.equals(b))) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
this._computedLineRanges = this._lineRanges;
|
|
96
|
+
this._refreshTokens();
|
|
97
|
+
}
|
|
98
|
+
handleStateChange(state) {
|
|
99
|
+
this._lineRanges = state.visibleLineRanges;
|
|
100
|
+
if (state.stabilized) {
|
|
101
|
+
this.runner.cancel();
|
|
102
|
+
this.update();
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
this.runner.schedule();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
class AbstractSyntaxTokenBackend extends Disposable {
|
|
110
|
+
get backgroundTokenizationState() {
|
|
111
|
+
return this._backgroundTokenizationState;
|
|
112
|
+
}
|
|
113
|
+
constructor(_languageIdCodec, _textModel) {
|
|
114
|
+
super();
|
|
115
|
+
this._languageIdCodec = _languageIdCodec;
|
|
116
|
+
this._textModel = _textModel;
|
|
117
|
+
this._onDidChangeTokens = this._register(new Emitter());
|
|
118
|
+
/** @internal, should not be exposed by the text model! */
|
|
119
|
+
this.onDidChangeTokens = this._onDidChangeTokens.event;
|
|
120
|
+
}
|
|
121
|
+
tokenizeIfCheap(lineNumber) {
|
|
122
|
+
if (this.isCheapToTokenize(lineNumber)) {
|
|
123
|
+
this.forceTokenization(lineNumber);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export { AbstractSyntaxTokenBackend, AttachedViewHandler, AttachedViewState, AttachedViews };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { assert } from '../../../../base/common/assert.js';
|
|
2
|
+
import { Position } from '../position.js';
|
|
3
|
+
import { Range } from '../range.js';
|
|
4
|
+
import { TextLength } from './textLength.js';
|
|
5
|
+
import { PositionOffsetTransformer } from './positionToOffsetImpl.js';
|
|
6
|
+
|
|
7
|
+
/*---------------------------------------------------------------------------------------------
|
|
8
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
10
|
+
*--------------------------------------------------------------------------------------------*/
|
|
11
|
+
class AbstractText {
|
|
12
|
+
constructor() {
|
|
13
|
+
this._transformer = undefined;
|
|
14
|
+
}
|
|
15
|
+
get endPositionExclusive() {
|
|
16
|
+
return this.length.addToPosition(new Position(1, 1));
|
|
17
|
+
}
|
|
18
|
+
get lineRange() {
|
|
19
|
+
return this.length.toLineRange();
|
|
20
|
+
}
|
|
21
|
+
getValue() {
|
|
22
|
+
return this.getValueOfRange(this.length.toRange());
|
|
23
|
+
}
|
|
24
|
+
getValueOfOffsetRange(range) {
|
|
25
|
+
return this.getValueOfRange(this.getTransformer().getRange(range));
|
|
26
|
+
}
|
|
27
|
+
getLineLength(lineNumber) {
|
|
28
|
+
return this.getValueOfRange(new Range(lineNumber, 1, lineNumber, Number.MAX_SAFE_INTEGER)).length;
|
|
29
|
+
}
|
|
30
|
+
getTransformer() {
|
|
31
|
+
if (!this._transformer) {
|
|
32
|
+
this._transformer = new PositionOffsetTransformer(this.getValue());
|
|
33
|
+
}
|
|
34
|
+
return this._transformer;
|
|
35
|
+
}
|
|
36
|
+
getLineAt(lineNumber) {
|
|
37
|
+
return this.getValueOfRange(new Range(lineNumber, 1, lineNumber, Number.MAX_SAFE_INTEGER));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
class LineBasedText extends AbstractText {
|
|
41
|
+
constructor(_getLineContent, _lineCount) {
|
|
42
|
+
assert(_lineCount >= 1);
|
|
43
|
+
super();
|
|
44
|
+
this._getLineContent = _getLineContent;
|
|
45
|
+
this._lineCount = _lineCount;
|
|
46
|
+
}
|
|
47
|
+
getValueOfRange(range) {
|
|
48
|
+
if (range.startLineNumber === range.endLineNumber) {
|
|
49
|
+
return this._getLineContent(range.startLineNumber).substring(range.startColumn - 1, range.endColumn - 1);
|
|
50
|
+
}
|
|
51
|
+
let result = this._getLineContent(range.startLineNumber).substring(range.startColumn - 1);
|
|
52
|
+
for (let i = range.startLineNumber + 1; i < range.endLineNumber; i++) {
|
|
53
|
+
result += '\n' + this._getLineContent(i);
|
|
54
|
+
}
|
|
55
|
+
result += '\n' + this._getLineContent(range.endLineNumber).substring(0, range.endColumn - 1);
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
getLineLength(lineNumber) {
|
|
59
|
+
return this._getLineContent(lineNumber).length;
|
|
60
|
+
}
|
|
61
|
+
get length() {
|
|
62
|
+
const lastLine = this._getLineContent(this._lineCount);
|
|
63
|
+
return new TextLength(this._lineCount - 1, lastLine.length);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
class ArrayText extends LineBasedText {
|
|
67
|
+
constructor(lines) {
|
|
68
|
+
super(lineNumber => lines[lineNumber - 1], lines.length);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
class StringText extends AbstractText {
|
|
72
|
+
constructor(value) {
|
|
73
|
+
super();
|
|
74
|
+
this.value = value;
|
|
75
|
+
this._t = new PositionOffsetTransformer(this.value);
|
|
76
|
+
}
|
|
77
|
+
getValueOfRange(range) {
|
|
78
|
+
return this._t.getOffsetRange(range).substring(this.value);
|
|
79
|
+
}
|
|
80
|
+
get length() {
|
|
81
|
+
return this._t.textLength;
|
|
82
|
+
}
|
|
83
|
+
// Override the getTransformer method to return the cached transformer
|
|
84
|
+
getTransformer() {
|
|
85
|
+
return this._t;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { AbstractText, ArrayText, LineBasedText, StringText };
|