monaco-languageclient 9.7.1 → 10.0.0-next.0
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/CHANGELOG.md +9 -0
- package/lib/{commonTypes.d.ts → common/commonTypes.d.ts} +2 -2
- package/lib/common/commonTypes.d.ts.map +1 -0
- package/lib/common/commonTypes.js +6 -0
- package/lib/common/commonTypes.js.map +1 -0
- package/lib/common/index.d.ts +4 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/{tools → common}/index.js +1 -0
- package/lib/common/index.js.map +1 -0
- package/lib/common/logging.d.ts.map +1 -0
- package/lib/common/logging.js.map +1 -0
- package/lib/common/utils.d.ts +5 -0
- package/lib/common/utils.d.ts.map +1 -0
- package/lib/{tools → common}/utils.js +14 -0
- package/lib/common/utils.js.map +1 -0
- package/lib/editorApp/config.d.ts +55 -0
- package/lib/editorApp/config.d.ts.map +1 -0
- package/lib/editorApp/config.js +13 -0
- package/lib/editorApp/config.js.map +1 -0
- package/lib/editorApp/editorApp.d.ts +66 -0
- package/lib/editorApp/editorApp.d.ts.map +1 -0
- package/lib/editorApp/editorApp.js +404 -0
- package/lib/editorApp/editorApp.js.map +1 -0
- package/lib/editorApp/index.d.ts +3 -0
- package/lib/editorApp/index.d.ts.map +1 -0
- package/lib/editorApp/index.js +7 -0
- package/lib/editorApp/index.js.map +1 -0
- package/lib/fs/definitions.d.ts +1 -1
- package/lib/fs/definitions.d.ts.map +1 -1
- package/lib/fs/endpoints/defaultEndpoint.d.ts +1 -1
- package/lib/fs/endpoints/defaultEndpoint.d.ts.map +1 -1
- package/lib/index.d.ts +15 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +18 -2
- package/lib/index.js.map +1 -1
- package/lib/vscode/apiWrapper.d.ts +59 -0
- package/lib/vscode/apiWrapper.d.ts.map +1 -0
- package/lib/vscode/apiWrapper.js +290 -0
- package/lib/vscode/apiWrapper.js.map +1 -0
- package/lib/vscode/config.d.ts +46 -0
- package/lib/vscode/config.d.ts.map +1 -0
- package/lib/vscode/config.js +7 -0
- package/lib/vscode/config.js.map +1 -0
- package/lib/vscode/index.d.ts +4 -2
- package/lib/vscode/index.d.ts.map +1 -1
- package/lib/vscode/index.js +4 -2
- package/lib/vscode/index.js.map +1 -1
- package/lib/vscode/locales.d.ts +5 -0
- package/lib/vscode/locales.d.ts.map +1 -0
- package/lib/vscode/locales.js +124 -0
- package/lib/vscode/locales.js.map +1 -0
- package/lib/vscode/utils.d.ts +13 -0
- package/lib/vscode/utils.d.ts.map +1 -0
- package/lib/vscode/utils.js +56 -0
- package/lib/vscode/utils.js.map +1 -0
- package/lib/vscode/viewsService.d.ts +4 -0
- package/lib/vscode/viewsService.d.ts.map +1 -0
- package/lib/vscode/viewsService.js +67 -0
- package/lib/vscode/viewsService.js.map +1 -0
- package/lib/{vscode → worker}/fakeWorker.d.ts.map +1 -1
- package/lib/{vscode → worker}/fakeWorker.js.map +1 -1
- package/lib/worker/index.d.ts +4 -0
- package/lib/worker/index.d.ts.map +1 -0
- package/lib/worker/index.js +8 -0
- package/lib/worker/index.js.map +1 -0
- package/lib/{workerFactory.d.ts → worker/workerFactory.d.ts} +1 -1
- package/lib/worker/workerFactory.d.ts.map +1 -0
- package/lib/{workerFactory.js → worker/workerFactory.js} +1 -1
- package/lib/worker/workerFactory.js.map +1 -0
- package/lib/worker/workerLoaders.d.ts +5 -0
- package/lib/worker/workerLoaders.d.ts.map +1 -0
- package/lib/worker/workerLoaders.js +26 -0
- package/lib/worker/workerLoaders.js.map +1 -0
- package/lib/wrapper/index.d.ts +4 -0
- package/lib/wrapper/index.d.ts.map +1 -0
- package/lib/wrapper/index.js +8 -0
- package/lib/wrapper/index.js.map +1 -0
- package/lib/wrapper/lcconfig.d.ts +24 -0
- package/lib/wrapper/lcconfig.d.ts.map +1 -0
- package/lib/wrapper/lcconfig.js +6 -0
- package/lib/wrapper/lcconfig.js.map +1 -0
- package/lib/wrapper/lcmanager.d.ts +18 -0
- package/lib/wrapper/lcmanager.d.ts.map +1 -0
- package/lib/wrapper/lcmanager.js +75 -0
- package/lib/wrapper/lcmanager.js.map +1 -0
- package/lib/wrapper/lcwrapper.d.ts +37 -0
- package/lib/wrapper/lcwrapper.d.ts.map +1 -0
- package/lib/wrapper/lcwrapper.js +247 -0
- package/lib/wrapper/lcwrapper.js.map +1 -0
- package/package.json +70 -28
- package/src/{commonTypes.ts → common/commonTypes.ts} +2 -2
- package/src/{tools → common}/index.ts +1 -0
- package/src/{tools → common}/utils.ts +16 -1
- package/src/editorApp/config.ts +67 -0
- package/src/editorApp/editorApp.ts +458 -0
- package/{lib/commonTypes.js → src/editorApp/index.ts} +3 -2
- package/src/fs/definitions.ts +1 -1
- package/src/fs/endpoints/defaultEndpoint.ts +1 -1
- package/src/index.ts +29 -2
- package/src/vscode/apiWrapper.ts +333 -0
- package/src/vscode/config.ts +55 -0
- package/src/vscode/index.ts +4 -2
- package/src/vscode/locales.ts +128 -0
- package/src/vscode/utils.ts +67 -0
- package/src/vscode/viewsService.ts +73 -0
- package/src/worker/index.ts +8 -0
- package/src/{workerFactory.ts → worker/workerFactory.ts} +2 -2
- package/src/worker/workerLoaders.ts +36 -0
- package/src/wrapper/index.ts +8 -0
- package/src/wrapper/lcconfig.ts +32 -0
- package/src/wrapper/lcmanager.ts +89 -0
- package/src/wrapper/lcwrapper.ts +280 -0
- package/lib/client.d.ts +0 -13
- package/lib/client.d.ts.map +0 -1
- package/lib/client.js +0 -16
- package/lib/client.js.map +0 -1
- package/lib/commonTypes.d.ts.map +0 -1
- package/lib/commonTypes.js.map +0 -1
- package/lib/tools/index.d.ts +0 -3
- package/lib/tools/index.d.ts.map +0 -1
- package/lib/tools/index.js.map +0 -1
- package/lib/tools/logging.d.ts.map +0 -1
- package/lib/tools/logging.js.map +0 -1
- package/lib/tools/utils.d.ts +0 -3
- package/lib/tools/utils.d.ts.map +0 -1
- package/lib/tools/utils.js.map +0 -1
- package/lib/vscode/services.d.ts +0 -64
- package/lib/vscode/services.d.ts.map +0 -1
- package/lib/vscode/services.js +0 -192
- package/lib/vscode/services.js.map +0 -1
- package/lib/workerFactory.d.ts.map +0 -1
- package/lib/workerFactory.js.map +0 -1
- package/src/client.ts +0 -26
- package/src/vscode/services.ts +0 -249
- /package/lib/{tools → common}/logging.d.ts +0 -0
- /package/lib/{tools → common}/logging.js +0 -0
- /package/lib/{vscode → worker}/fakeWorker.d.ts +0 -0
- /package/lib/{vscode → worker}/fakeWorker.js +0 -0
- /package/src/{tools → common}/logging.ts +0 -0
- /package/src/{vscode → worker}/fakeWorker.ts +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/* --------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) 2024 TypeFox and others.
|
|
3
|
+
* Licensed under the MIT License. See LICENSE in the package root for license information.
|
|
4
|
+
* ------------------------------------------------------------------------------------------ */
|
|
5
|
+
export const defaultViewsInit = async () => {
|
|
6
|
+
const { Parts, Position, onPartVisibilityChange, isPartVisibile, attachPart, getSideBarPosition, onDidChangeSideBarPosition } = await import('@codingame/monaco-vscode-views-service-override');
|
|
7
|
+
for (const config of [
|
|
8
|
+
{ part: Parts.TITLEBAR_PART, element: '#titleBar' },
|
|
9
|
+
{ part: Parts.BANNER_PART, element: '#banner' },
|
|
10
|
+
{
|
|
11
|
+
part: Parts.SIDEBAR_PART, get element() {
|
|
12
|
+
return getSideBarPosition() === Position.LEFT ? '#sidebar' : '#sidebar-right';
|
|
13
|
+
}, onDidElementChange: onDidChangeSideBarPosition
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
part: Parts.ACTIVITYBAR_PART, get element() {
|
|
17
|
+
return getSideBarPosition() === Position.LEFT ? '#activityBar' : '#activityBar-right';
|
|
18
|
+
}, onDidElementChange: onDidChangeSideBarPosition
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
part: Parts.AUXILIARYBAR_PART, get element() {
|
|
22
|
+
return getSideBarPosition() === Position.LEFT ? '#auxiliaryBar' : '#auxiliaryBar-left';
|
|
23
|
+
}, onDidElementChange: onDidChangeSideBarPosition
|
|
24
|
+
},
|
|
25
|
+
{ part: Parts.EDITOR_PART, element: '#editors' },
|
|
26
|
+
{ part: Parts.PANEL_PART, element: '#panel' },
|
|
27
|
+
{ part: Parts.STATUSBAR_PART, element: '#statusBar' }
|
|
28
|
+
]) {
|
|
29
|
+
attachPart(config.part, document.querySelector(config.element));
|
|
30
|
+
config.onDidElementChange?.(() => {
|
|
31
|
+
attachPart(config.part, document.querySelector(config.element));
|
|
32
|
+
});
|
|
33
|
+
if (!isPartVisibile(config.part)) {
|
|
34
|
+
document.querySelector(config.element).style.display = 'none';
|
|
35
|
+
}
|
|
36
|
+
onPartVisibilityChange(config.part, visible => {
|
|
37
|
+
document.querySelector(config.element).style.display = visible ? 'block' : 'none';
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
export const defaultViewsHtml = `<div id="workbench-container">
|
|
42
|
+
<div id="titleBar"></div>
|
|
43
|
+
<div id="banner"></div>
|
|
44
|
+
<div id="workbench-top">
|
|
45
|
+
<div id="sidebarDiv">
|
|
46
|
+
<div id="activityBar"></div>
|
|
47
|
+
<div id="sidebar"></div>
|
|
48
|
+
<div id="auxiliaryBar-left"></div>
|
|
49
|
+
</div>
|
|
50
|
+
<div id="editorsDiv">
|
|
51
|
+
<div id="editors"></div>
|
|
52
|
+
</div>
|
|
53
|
+
<div id="sidebarRightDiv">
|
|
54
|
+
<div id="sidebar-right"></div>
|
|
55
|
+
<div id="activityBar-right"></div>
|
|
56
|
+
<div id="auxiliaryBar"></div>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
<div id="panel"></div>
|
|
60
|
+
<div id="statusBar"></div>
|
|
61
|
+
</div>`;
|
|
62
|
+
export const defaultHtmlAugmentationInstructions = (htmlElement) => {
|
|
63
|
+
const htmlContainer = document.createElement('div', { is: 'app' });
|
|
64
|
+
htmlContainer.innerHTML = defaultViewsHtml;
|
|
65
|
+
htmlElement?.append(htmlContainer);
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=viewsService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewsService.js","sourceRoot":"","sources":["../../src/vscode/viewsService.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,IAAI,EAAE;IACvC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,sBAAsB,EAAE,cAAc,EAAE,UAAU,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,GAAG,MAAM,MAAM,CAAC,iDAAiD,CAAC,CAAC;IAEhM,KAAK,MAAM,MAAM,IAAI;QACjB,EAAE,IAAI,EAAE,KAAK,CAAC,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE;QACnD,EAAE,IAAI,EAAE,KAAK,CAAC,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE;QAC/C;YACI,IAAI,EAAE,KAAK,CAAC,YAAY,EAAE,IAAI,OAAO;gBACjC,OAAO,kBAAkB,EAAE,KAAK,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC;YAClF,CAAC,EAAE,kBAAkB,EAAE,0BAA0B;SACpD;QACD;YACI,IAAI,EAAE,KAAK,CAAC,gBAAgB,EAAE,IAAI,OAAO;gBACrC,OAAO,kBAAkB,EAAE,KAAK,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,oBAAoB,CAAC;YAC1F,CAAC,EAAE,kBAAkB,EAAE,0BAA0B;SACpD;QACD;YACI,IAAI,EAAE,KAAK,CAAC,iBAAiB,EAAE,IAAI,OAAO;gBACtC,OAAO,kBAAkB,EAAE,KAAK,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,oBAAoB,CAAC;YAC3F,CAAC,EAA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C;IACnE,aAAa,CAAC,SAAS,GAAG,gBAAgB,CAAC;IAC3C,WAAW,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;AACvC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fakeWorker.d.ts","sourceRoot":"","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"fakeWorker.d.ts","sourceRoot":"","sources":["../../src/worker/fakeWorker.ts"],"names":[],"mappings":"AAKA,qBAAa,UAAU;IACnB,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAClB,OAAO,CAAC,EAAE,aAAa,CAAC;gBAEZ,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,CAAC,EAAE,aAAa;CAIzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fakeWorker.js","sourceRoot":"","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"fakeWorker.js","sourceRoot":"","sources":["../../src/worker/fakeWorker.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,MAAM,OAAO,UAAU;IACnB,GAAG,CAAe;IAClB,OAAO,CAAiB;IAExB,YAAY,GAAiB,EAAE,OAAuB;QAClD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/worker/index.ts"],"names":[],"mappings":"AAKA,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/* --------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) 2024 TypeFox and others.
|
|
3
|
+
* Licensed under the MIT License. See LICENSE in the package root for license information.
|
|
4
|
+
* ------------------------------------------------------------------------------------------ */
|
|
5
|
+
export * from './fakeWorker.js';
|
|
6
|
+
export * from './workerFactory.js';
|
|
7
|
+
export * from './workerLoaders.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/worker/index.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerFactory.d.ts","sourceRoot":"","sources":["../../src/worker/workerFactory.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAE3D,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,SAAS,CAAC;AAEtD,MAAM,WAAW,mBAAmB;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACnE;AAED,eAAO,MAAM,gBAAgB,GAAI,QAAQ,mBAAmB,SAa3D,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2024 TypeFox and others.
|
|
3
3
|
* Licensed under the MIT License. See LICENSE in the package root for license information.
|
|
4
4
|
* ------------------------------------------------------------------------------------------ */
|
|
5
|
-
import { getEnhancedMonacoEnvironment } from 'monaco-languageclient/
|
|
5
|
+
import { getEnhancedMonacoEnvironment } from 'monaco-languageclient/vscodeApiWrapper';
|
|
6
6
|
export const useWorkerFactory = (config) => {
|
|
7
7
|
const envEnhanced = getEnhancedMonacoEnvironment();
|
|
8
8
|
const getWorker = (moduleId, label) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerFactory.js","sourceRoot":"","sources":["../../src/worker/workerFactory.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AAWtF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAA2B,EAAE,EAAE;IAC5D,MAAM,WAAW,GAAG,4BAA4B,EAAE,CAAC;IAEnD,MAAM,SAAS,GAAG,CAAC,QAAgB,EAAE,KAAa,EAAE,EAAE;QAClD,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,wBAAwB,QAAQ,WAAW,KAAK,EAAE,CAAC,CAAC;QAExE,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC;QAC9D,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,KAAK,QAAQ,GAAG,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,UAAU,EAAE,CAAC;IACxB,CAAC,CAAC;IACF,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC,iBAAiB,IAAI,SAAS,CAAC;AAClE,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Logger } from 'monaco-languageclient/common';
|
|
2
|
+
import { type WorkerLoader } from 'monaco-languageclient/workerFactory';
|
|
3
|
+
export declare const defineDefaultWorkerLoaders: () => Record<string, WorkerLoader>;
|
|
4
|
+
export declare const configureDefaultWorkerFactory: (logger?: Logger) => void;
|
|
5
|
+
//# sourceMappingURL=workerLoaders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerLoaders.d.ts","sourceRoot":"","sources":["../../src/worker/workerLoaders.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAoB,KAAK,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAE1F,eAAO,MAAM,0BAA0B,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,YAAY,CAoBzE,CAAC;AAEF,eAAO,MAAM,6BAA6B,GAAI,SAAS,MAAM,SAK5D,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* --------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) 2024 TypeFox and others.
|
|
3
|
+
* Licensed under the MIT License. See LICENSE in the package root for license information.
|
|
4
|
+
* ------------------------------------------------------------------------------------------ */
|
|
5
|
+
import { useWorkerFactory } from 'monaco-languageclient/workerFactory';
|
|
6
|
+
export const defineDefaultWorkerLoaders = () => {
|
|
7
|
+
const defaultTextEditorWorker = () => new Worker(new URL('@codingame/monaco-vscode-editor-api/esm/vs/editor/editor.worker.js', import.meta.url), { type: 'module' });
|
|
8
|
+
const defaultTextMateWorker = () => new Worker(new URL('@codingame/monaco-vscode-textmate-service-override/worker', import.meta.url), { type: 'module' });
|
|
9
|
+
return {
|
|
10
|
+
// if you import monaco api as 'monaco-editor': monaco-editor/esm/vs/editor/editor.worker.js
|
|
11
|
+
TextEditorWorker: defaultTextEditorWorker,
|
|
12
|
+
TextMateWorker: defaultTextMateWorker,
|
|
13
|
+
// these are other possible workers not configured by default
|
|
14
|
+
OutputLinkDetectionWorker: undefined,
|
|
15
|
+
LanguageDetectionWorker: undefined,
|
|
16
|
+
NotebookEditorWorker: undefined,
|
|
17
|
+
LocalFileSearchWorker: undefined
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export const configureDefaultWorkerFactory = (logger) => {
|
|
21
|
+
useWorkerFactory({
|
|
22
|
+
workerLoaders: defineDefaultWorkerLoaders(),
|
|
23
|
+
logger
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=workerLoaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerLoaders.js","sourceRoot":"","sources":["../../src/worker/workerLoaders.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,gBAAgB,EAAqB,MAAM,qCAAqC,CAAC;AAE1F,MAAM,CAAC,MAAM,0BAA0B,GAAuC,GAAG,EAAE;IAC/E,MAAM,uBAAuB,GAAG,GAAG,EAAE,CAAC,IAAI,MAAM,CAC5C,IAAI,GAAG,CAAC,oEAAoE,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAC9F,EAAE,IAAI,EAAE,QAAQ,EAAE,CACrB,CAAC;IACF,MAAM,qBAAqB,GAAG,GAAG,EAAE,CAAC,IAAI,MAAM,CAC1C,IAAI,GAAG,CAAC,2DAA2D,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EACrF,EAAE,IAAI,EAAE,QAAQ,EAAE,CACrB,CAAC;IAEF,OAAO;QACH,4FAA4F;QAC5F,gBAAgB,EAAE,uBAAuB;QACzC,cAAc,EAAE,qBAAqB;QACrC,6DAA6D;QAC7D,yBAAyB,EAAE,SAAS;QACpC,uBAAuB,EAAE,SAAS;QAClC,oBAAoB,EAAE,SAAS;QAC/B,qBAAqB,EAAE,SAAS;KACnC,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,MAAe,EAAE,EAAE;IAC7D,gBAAgB,CAAC;QACb,aAAa,EAAE,0BAA0B,EAAE;QAC3C,MAAM;KACT,CAAC,CAAC;AACP,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wrapper/index.ts"],"names":[],"mappings":"AAKA,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/* --------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) 2024 TypeFox and others.
|
|
3
|
+
* Licensed under the MIT License. See LICENSE in the package root for license information.
|
|
4
|
+
* ------------------------------------------------------------------------------------------ */
|
|
5
|
+
export * from './lcconfig.js';
|
|
6
|
+
export * from './lcmanager.js';
|
|
7
|
+
export * from './lcwrapper.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wrapper/index.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { LanguageClientOptions, MessageTransports } from 'vscode-languageclient/browser.js';
|
|
2
|
+
import { type ConnectionConfigOptions } from 'monaco-languageclient/common';
|
|
3
|
+
export interface ConnectionConfig {
|
|
4
|
+
options: ConnectionConfigOptions;
|
|
5
|
+
messageTransports?: MessageTransports;
|
|
6
|
+
}
|
|
7
|
+
export interface LanguageClientConfig {
|
|
8
|
+
name?: string;
|
|
9
|
+
connection: ConnectionConfig;
|
|
10
|
+
clientOptions: LanguageClientOptions;
|
|
11
|
+
restartOptions?: LanguageClientRestartOptions;
|
|
12
|
+
disposeWorker?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface LanguageClientRestartOptions {
|
|
15
|
+
retries: number;
|
|
16
|
+
timeout: number;
|
|
17
|
+
keepWorker?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface LanguageClientConfigs {
|
|
20
|
+
configs: Record<string, LanguageClientConfig>;
|
|
21
|
+
overwriteExisting?: boolean;
|
|
22
|
+
enforceDispose?: boolean;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=lcconfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lcconfig.d.ts","sourceRoot":"","sources":["../../src/wrapper/lcconfig.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACjG,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAE5E,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,uBAAuB,CAAC;IACjC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACzC;AAED,MAAM,WAAW,oBAAoB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,gBAAgB,CAAC;IAC7B,aAAa,EAAE,qBAAqB,CAAC;IACrC,cAAc,CAAC,EAAE,4BAA4B,CAAC;IAC9C,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,4BAA4B;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB;IAClC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;IAC7C,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/* --------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) 2024 TypeFox and others.
|
|
3
|
+
* Licensed under the MIT License. See LICENSE in the package root for license information.
|
|
4
|
+
* ------------------------------------------------------------------------------------------ */
|
|
5
|
+
import {} from 'monaco-languageclient/common';
|
|
6
|
+
//# sourceMappingURL=lcconfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lcconfig.js","sourceRoot":"","sources":["../../src/wrapper/lcconfig.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAgC,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Logger } from 'monaco-languageclient/common';
|
|
2
|
+
import type { LanguageClientConfigs } from './lcconfig.js';
|
|
3
|
+
import { LanguageClientWrapper } from './lcwrapper.js';
|
|
4
|
+
export declare class LanguageClientsManager {
|
|
5
|
+
private logger?;
|
|
6
|
+
private languageClientConfigs?;
|
|
7
|
+
private languageClientWrappers;
|
|
8
|
+
constructor(logger?: Logger);
|
|
9
|
+
haveLanguageClients(): boolean;
|
|
10
|
+
getLanguageClientWrapper(languageId: string): LanguageClientWrapper | undefined;
|
|
11
|
+
getLanguageClient(languageId: string): import("../index.js").MonacoLanguageClient | undefined;
|
|
12
|
+
getWorker(languageId: string): Worker | undefined;
|
|
13
|
+
setConfigs(languageClientConfigs: LanguageClientConfigs): Promise<void>;
|
|
14
|
+
start(): Promise<void | void[]>;
|
|
15
|
+
isStarted(): boolean;
|
|
16
|
+
dispose(): Promise<void | void[]>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=lcmanager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lcmanager.d.ts","sourceRoot":"","sources":["../../src/wrapper/lcmanager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,qBAAa,sBAAsB;IAE/B,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,qBAAqB,CAAC,CAAwB;IACtD,OAAO,CAAC,sBAAsB,CAAiD;gBAEnE,MAAM,CAAC,EAAE,MAAM;IAI3B,mBAAmB,IAAI,OAAO;IAI9B,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS;IAI/E,iBAAiB,CAAC,UAAU,EAAE,MAAM;IAIpC,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI3C,UAAU,CAAC,qBAAqB,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBvE,KAAK,IAAI,OAAO,CAAC,IAAI,GAAG,IAAI,EAAE,CAAC;IAUrC,SAAS,IAAI,OAAO;IAUd,OAAO,IAAI,OAAO,CAAC,IAAI,GAAG,IAAI,EAAE,CAAC;CAU1C"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* --------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) 2024 TypeFox and others.
|
|
3
|
+
* Licensed under the MIT License. See LICENSE in the package root for license information.
|
|
4
|
+
* ------------------------------------------------------------------------------------------ */
|
|
5
|
+
import { LanguageClientWrapper } from './lcwrapper.js';
|
|
6
|
+
export class LanguageClientsManager {
|
|
7
|
+
logger;
|
|
8
|
+
languageClientConfigs;
|
|
9
|
+
languageClientWrappers = new Map();
|
|
10
|
+
constructor(logger) {
|
|
11
|
+
this.logger = logger;
|
|
12
|
+
}
|
|
13
|
+
haveLanguageClients() {
|
|
14
|
+
return this.languageClientWrappers.size > 0;
|
|
15
|
+
}
|
|
16
|
+
getLanguageClientWrapper(languageId) {
|
|
17
|
+
return this.languageClientWrappers.get(languageId);
|
|
18
|
+
}
|
|
19
|
+
getLanguageClient(languageId) {
|
|
20
|
+
return this.languageClientWrappers.get(languageId)?.getLanguageClient();
|
|
21
|
+
}
|
|
22
|
+
getWorker(languageId) {
|
|
23
|
+
return this.languageClientWrappers.get(languageId)?.getWorker();
|
|
24
|
+
}
|
|
25
|
+
async setConfigs(languageClientConfigs) {
|
|
26
|
+
this.languageClientConfigs = languageClientConfigs;
|
|
27
|
+
const lccEntries = Object.entries(this.languageClientConfigs.configs);
|
|
28
|
+
if (lccEntries.length > 0) {
|
|
29
|
+
for (const [languageId, lcc] of lccEntries) {
|
|
30
|
+
const current = this.languageClientWrappers.get(languageId);
|
|
31
|
+
const lcw = new LanguageClientWrapper(lcc, this.logger);
|
|
32
|
+
if (current !== undefined) {
|
|
33
|
+
if (languageClientConfigs.overwriteExisting === true) {
|
|
34
|
+
if (languageClientConfigs.enforceDispose === true) {
|
|
35
|
+
await current.dispose();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
throw new Error(`A languageclient config with id "${languageId}" already exists and you confiured to not override.`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
this.languageClientWrappers.set(languageId, lcw);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async start() {
|
|
47
|
+
const allPromises = [];
|
|
48
|
+
for (const lcw of this.languageClientWrappers.values()) {
|
|
49
|
+
if (!lcw.isStarted()) {
|
|
50
|
+
allPromises.push(lcw.start());
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return Promise.all(allPromises);
|
|
54
|
+
}
|
|
55
|
+
isStarted() {
|
|
56
|
+
for (const lcw of this.languageClientWrappers.values()) {
|
|
57
|
+
// as soon as one is not started return
|
|
58
|
+
if (!lcw.isStarted()) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
async dispose() {
|
|
65
|
+
const allPromises = [];
|
|
66
|
+
for (const lcw of this.languageClientWrappers.values()) {
|
|
67
|
+
if (lcw.haveLanguageClient()) {
|
|
68
|
+
allPromises.push(lcw.dispose());
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
await Promise.all(allPromises);
|
|
72
|
+
this.languageClientWrappers.clear();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=lcmanager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lcmanager.js","sourceRoot":"","sources":["../../src/wrapper/lcmanager.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAIhG,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,MAAM,OAAO,sBAAsB;IAEvB,MAAM,CAAU;IAChB,qBAAqB,CAAyB;IAC9C,sBAAsB,GAAuC,IAAI,GAA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0 +1,37 @@
|
|
|
1
|
+
import { MessageTransports } from 'vscode-languageclient/browser.js';
|
|
2
|
+
import { type Logger, type WorkerConfigOptionsDirect, type WorkerConfigOptionsParams } from 'monaco-languageclient/common';
|
|
3
|
+
import { MonacoLanguageClient } from 'monaco-languageclient';
|
|
4
|
+
import type { LanguageClientConfig, LanguageClientRestartOptions } from './lcconfig.js';
|
|
5
|
+
export interface LanguageClientError {
|
|
6
|
+
message: string;
|
|
7
|
+
error: Error | string;
|
|
8
|
+
}
|
|
9
|
+
export declare class LanguageClientWrapper {
|
|
10
|
+
private languageClient?;
|
|
11
|
+
private languageClientConfig;
|
|
12
|
+
private worker?;
|
|
13
|
+
private port?;
|
|
14
|
+
private name?;
|
|
15
|
+
private logger;
|
|
16
|
+
constructor(config: LanguageClientConfig, logger?: Logger);
|
|
17
|
+
haveLanguageClient(): boolean;
|
|
18
|
+
getLanguageClient(): MonacoLanguageClient | undefined;
|
|
19
|
+
getWorker(): Worker | undefined;
|
|
20
|
+
isStarted(): boolean;
|
|
21
|
+
start(): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Restart the languageclient with options to control worker handling
|
|
24
|
+
*
|
|
25
|
+
* @param updatedWorker Set a new worker here that should be used. keepWorker has no effect then, as we want to dispose of the prior workers
|
|
26
|
+
* @param disposeWorker Set to false if worker should not be disposed
|
|
27
|
+
*/
|
|
28
|
+
restart(updatedWorker?: Worker, forceWorkerDispose?: boolean): Promise<void>;
|
|
29
|
+
protected initMessageTransportWebSocket(webSocket: WebSocket, resolve: () => void, reject: (reason?: unknown) => void): Promise<void>;
|
|
30
|
+
protected initMessageTransportWorker(lccOptions: WorkerConfigOptionsDirect | WorkerConfigOptionsParams, resolve: () => void, reject: (reason?: unknown) => void): Promise<void>;
|
|
31
|
+
protected performLanguageClientStart(messageTransports: MessageTransports, resolve: () => void, reject: (reason?: unknown) => void): Promise<void>;
|
|
32
|
+
protected initRestartConfiguration(messageTransports: MessageTransports, restartOptions?: LanguageClientRestartOptions): void;
|
|
33
|
+
protected disposeWorker(): void;
|
|
34
|
+
dispose(forceWorkerDispose?: boolean): Promise<void>;
|
|
35
|
+
reportStatus(): string[];
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=lcwrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lcwrapper.d.ts","sourceRoot":"","sources":["../../src/wrapper/lcwrapper.ts"],"names":[],"mappings":"AAMA,OAAO,EAA4B,iBAAiB,EAAS,MAAM,kCAAkC,CAAC;AACtG,OAAO,EAAa,KAAK,MAAM,EAAE,KAAK,yBAAyB,EAAE,KAAK,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAEtI,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAExF,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC;CACzB;AAED,qBAAa,qBAAqB;IAE9B,OAAO,CAAC,cAAc,CAAC,CAAuB;IAC9C,OAAO,CAAC,oBAAoB,CAAuB;IACnD,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,IAAI,CAAC,CAAc;IAC3B,OAAO,CAAC,IAAI,CAAC,CAAS;IACtB,OAAO,CAAC,MAAM,CAAqB;gBAEvB,MAAM,EAAE,oBAAoB,EAAE,MAAM,CAAC,EAAE,MAAM;IAMzD,kBAAkB,IAAI,OAAO;IAI7B,iBAAiB,IAAI,oBAAoB,GAAG,SAAS;IAIrD,SAAS,IAAI,MAAM,GAAG,SAAS;IAI/B,SAAS,IAAI,OAAO;IAId,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB5B;;;;;OAKG;IACG,OAAO,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;cAQlE,6BAA6B,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,IAAI,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI;cA6B3G,0BAA0B,CAAC,UAAU,EAAE,yBAAyB,GAAG,yBAAyB,EAAE,OAAO,EAAE,MAAM,IAAI,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI;cAqCrJ,0BAA0B,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,IAAI,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI;IAqExI,SAAS,CAAC,wBAAwB,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,CAAC,EAAE,4BAA4B;IA6BtH,SAAS,CAAC,aAAa;IAKjB,OAAO,CAAC,kBAAkB,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB1D,YAAY;CAOf"}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/* --------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) 2024 TypeFox and others.
|
|
3
|
+
* Licensed under the MIT License. See LICENSE in the package root for license information.
|
|
4
|
+
* ------------------------------------------------------------------------------------------ */
|
|
5
|
+
import { BrowserMessageReader, BrowserMessageWriter } from 'vscode-languageserver-protocol/browser.js';
|
|
6
|
+
import { CloseAction, ErrorAction, MessageTransports, State } from 'vscode-languageclient/browser.js';
|
|
7
|
+
import { createUrl } from 'monaco-languageclient/common';
|
|
8
|
+
import { toSocket, WebSocketMessageReader, WebSocketMessageWriter } from 'vscode-ws-jsonrpc';
|
|
9
|
+
import { MonacoLanguageClient } from 'monaco-languageclient';
|
|
10
|
+
export class LanguageClientWrapper {
|
|
11
|
+
languageClient;
|
|
12
|
+
languageClientConfig;
|
|
13
|
+
worker;
|
|
14
|
+
port;
|
|
15
|
+
name;
|
|
16
|
+
logger;
|
|
17
|
+
constructor(config, logger) {
|
|
18
|
+
this.languageClientConfig = config;
|
|
19
|
+
this.name = this.languageClientConfig.name ?? 'unnamed';
|
|
20
|
+
this.logger = logger;
|
|
21
|
+
}
|
|
22
|
+
haveLanguageClient() {
|
|
23
|
+
return this.languageClient !== undefined;
|
|
24
|
+
}
|
|
25
|
+
getLanguageClient() {
|
|
26
|
+
return this.languageClient;
|
|
27
|
+
}
|
|
28
|
+
getWorker() {
|
|
29
|
+
return this.worker;
|
|
30
|
+
}
|
|
31
|
+
isStarted() {
|
|
32
|
+
return this.languageClient !== undefined && this.languageClient.isRunning();
|
|
33
|
+
}
|
|
34
|
+
async start() {
|
|
35
|
+
if (this.languageClient?.isRunning() ?? false) {
|
|
36
|
+
this.logger?.info('startLanguageClientConnection: monaco-languageclient already running!');
|
|
37
|
+
return Promise.resolve();
|
|
38
|
+
}
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
const conConfig = this.languageClientConfig.connection;
|
|
41
|
+
const conOptions = conConfig.options;
|
|
42
|
+
if (conOptions.$type === 'WebSocketDirect' || conOptions.$type === 'WebSocketParams' || conOptions.$type === 'WebSocketUrl') {
|
|
43
|
+
const webSocket = conOptions.$type === 'WebSocketDirect' ? conOptions.webSocket : new WebSocket(createUrl(conOptions));
|
|
44
|
+
this.initMessageTransportWebSocket(webSocket, resolve, reject);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// init of worker and start of languageclient can be handled directly, because worker available already
|
|
48
|
+
this.initMessageTransportWorker(conOptions, resolve, reject);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Restart the languageclient with options to control worker handling
|
|
54
|
+
*
|
|
55
|
+
* @param updatedWorker Set a new worker here that should be used. keepWorker has no effect then, as we want to dispose of the prior workers
|
|
56
|
+
* @param disposeWorker Set to false if worker should not be disposed
|
|
57
|
+
*/
|
|
58
|
+
async restart(updatedWorker, forceWorkerDispose) {
|
|
59
|
+
await this.dispose(forceWorkerDispose);
|
|
60
|
+
this.worker = updatedWorker;
|
|
61
|
+
this.logger?.info('Re-Starting monaco-languageclient');
|
|
62
|
+
return this.start();
|
|
63
|
+
}
|
|
64
|
+
async initMessageTransportWebSocket(webSocket, resolve, reject) {
|
|
65
|
+
let messageTransports = this.languageClientConfig.connection.messageTransports;
|
|
66
|
+
if (messageTransports === undefined) {
|
|
67
|
+
const iWebSocket = toSocket(webSocket);
|
|
68
|
+
messageTransports = {
|
|
69
|
+
reader: new WebSocketMessageReader(iWebSocket),
|
|
70
|
+
writer: new WebSocketMessageWriter(iWebSocket)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
// if websocket is already open, then start the languageclient directly
|
|
74
|
+
if (webSocket.readyState === WebSocket.OPEN) {
|
|
75
|
+
await this.performLanguageClientStart(messageTransports, resolve, reject);
|
|
76
|
+
}
|
|
77
|
+
// otherwise start on open
|
|
78
|
+
webSocket.onopen = async () => {
|
|
79
|
+
await this.performLanguageClientStart(messageTransports, resolve, reject);
|
|
80
|
+
};
|
|
81
|
+
webSocket.onerror = (ev) => {
|
|
82
|
+
const languageClientError = {
|
|
83
|
+
message: `languageClientWrapper (${this.name}): Websocket connection failed.`,
|
|
84
|
+
error: ev.error ?? 'No error was provided.'
|
|
85
|
+
};
|
|
86
|
+
reject(languageClientError);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
async initMessageTransportWorker(lccOptions, resolve, reject) {
|
|
90
|
+
if (!this.worker) {
|
|
91
|
+
if (lccOptions.$type === 'WorkerConfig') {
|
|
92
|
+
const workerConfig = lccOptions;
|
|
93
|
+
this.worker = new Worker(workerConfig.url.href, {
|
|
94
|
+
type: workerConfig.type,
|
|
95
|
+
name: workerConfig.workerName
|
|
96
|
+
});
|
|
97
|
+
this.worker.onerror = (ev) => {
|
|
98
|
+
const languageClientError = {
|
|
99
|
+
message: `languageClientWrapper (${this.name}): Illegal worker configuration detected.`,
|
|
100
|
+
error: ev.error ?? 'No error was provided.'
|
|
101
|
+
};
|
|
102
|
+
reject(languageClientError);
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
const workerDirectConfig = lccOptions;
|
|
107
|
+
this.worker = workerDirectConfig.worker;
|
|
108
|
+
}
|
|
109
|
+
if (lccOptions.messagePort !== undefined) {
|
|
110
|
+
this.port = lccOptions.messagePort;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const portOrWorker = this.port ? this.port : this.worker;
|
|
114
|
+
let messageTransports = this.languageClientConfig.connection.messageTransports;
|
|
115
|
+
if (messageTransports === undefined) {
|
|
116
|
+
messageTransports = {
|
|
117
|
+
reader: new BrowserMessageReader(portOrWorker),
|
|
118
|
+
writer: new BrowserMessageWriter(portOrWorker)
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
await this.performLanguageClientStart(messageTransports, resolve, reject);
|
|
122
|
+
}
|
|
123
|
+
async performLanguageClientStart(messageTransports, resolve, reject) {
|
|
124
|
+
let starting = true;
|
|
125
|
+
// do not perform another start attempt if already running
|
|
126
|
+
if (this.languageClient?.isRunning() ?? false) {
|
|
127
|
+
this.logger?.info('performLanguageClientStart: monaco-languageclient already running!');
|
|
128
|
+
resolve();
|
|
129
|
+
}
|
|
130
|
+
const mlcConfig = {
|
|
131
|
+
name: this.languageClientConfig.name ?? 'Monaco Wrapper Language Client',
|
|
132
|
+
clientOptions: {
|
|
133
|
+
// disable the default error handler...
|
|
134
|
+
errorHandler: {
|
|
135
|
+
error: (e) => {
|
|
136
|
+
if (starting) {
|
|
137
|
+
reject(`Error occurred in language client: ${e}`);
|
|
138
|
+
return { action: ErrorAction.Shutdown };
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
return { action: ErrorAction.Continue };
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
closed: () => ({ action: CloseAction.DoNotRestart })
|
|
145
|
+
},
|
|
146
|
+
// ...but allowm to override all options
|
|
147
|
+
...this.languageClientConfig.clientOptions,
|
|
148
|
+
},
|
|
149
|
+
messageTransports
|
|
150
|
+
};
|
|
151
|
+
this.languageClient = new MonacoLanguageClient(mlcConfig);
|
|
152
|
+
const conOptions = this.languageClientConfig.connection.options;
|
|
153
|
+
this.initRestartConfiguration(messageTransports, this.languageClientConfig.restartOptions);
|
|
154
|
+
const isWebSocket = conOptions.$type === 'WebSocketParams' || conOptions.$type === 'WebSocketUrl' || conOptions.$type === 'WebSocketDirect';
|
|
155
|
+
messageTransports.reader.onClose(async () => {
|
|
156
|
+
await this.languageClient?.stop();
|
|
157
|
+
if (isWebSocket && conOptions.stopOptions !== undefined) {
|
|
158
|
+
const stopOptions = conOptions.stopOptions;
|
|
159
|
+
stopOptions.onCall(this.getLanguageClient());
|
|
160
|
+
if (stopOptions.reportStatus !== undefined) {
|
|
161
|
+
this.logger?.info(this.reportStatus().join('\n'));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
try {
|
|
166
|
+
await this.languageClient.start();
|
|
167
|
+
if (isWebSocket && conOptions.startOptions !== undefined) {
|
|
168
|
+
const startOptions = conOptions.startOptions;
|
|
169
|
+
startOptions.onCall(this.getLanguageClient());
|
|
170
|
+
if (startOptions.reportStatus !== undefined) {
|
|
171
|
+
this.logger?.info(this.reportStatus().join('\n'));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
catch (e) {
|
|
176
|
+
const languageClientError = {
|
|
177
|
+
message: `languageClientWrapper (${this.name}): Start was unsuccessful.`,
|
|
178
|
+
error: Object.hasOwn(e ?? {}, 'cause') ? e : 'No error was provided.'
|
|
179
|
+
};
|
|
180
|
+
reject(languageClientError);
|
|
181
|
+
}
|
|
182
|
+
this.logger?.info(`languageClientWrapper (${this.name}): Started successfully.`);
|
|
183
|
+
resolve();
|
|
184
|
+
starting = false;
|
|
185
|
+
}
|
|
186
|
+
initRestartConfiguration(messageTransports, restartOptions) {
|
|
187
|
+
if (restartOptions !== undefined) {
|
|
188
|
+
let retry = 0;
|
|
189
|
+
const readerOnError = messageTransports.reader.onError(() => restartLC);
|
|
190
|
+
const readerOnClose = messageTransports.reader.onClose(() => restartLC);
|
|
191
|
+
const restartLC = async () => {
|
|
192
|
+
if (this.isStarted()) {
|
|
193
|
+
try {
|
|
194
|
+
readerOnError.dispose();
|
|
195
|
+
readerOnClose.dispose();
|
|
196
|
+
await this.restart(this.worker, restartOptions.keepWorker);
|
|
197
|
+
}
|
|
198
|
+
finally {
|
|
199
|
+
retry++;
|
|
200
|
+
if (retry > (restartOptions.retries) && !this.isStarted()) {
|
|
201
|
+
this.logger?.info('Disabling Language Client. Failed to start clangd after 5 retries');
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
setTimeout(async () => {
|
|
205
|
+
await this.restart(this.worker, restartOptions.keepWorker);
|
|
206
|
+
}, restartOptions.timeout);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
disposeWorker() {
|
|
214
|
+
this.worker?.terminate();
|
|
215
|
+
this.worker = undefined;
|
|
216
|
+
}
|
|
217
|
+
async dispose(forceWorkerDispose) {
|
|
218
|
+
try {
|
|
219
|
+
if (this.isStarted()) {
|
|
220
|
+
await this.languageClient?.dispose();
|
|
221
|
+
this.languageClient = undefined;
|
|
222
|
+
this.logger?.info('monaco-languageclient and monaco-editor were successfully disposed.');
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
catch (e) {
|
|
226
|
+
const languageClientError = {
|
|
227
|
+
message: `languageClientWrapper (${this.name}): Disposing the monaco-languageclient resulted in error.`,
|
|
228
|
+
error: Object.hasOwn(e ?? {}, 'cause') ? e : 'No error was provided.'
|
|
229
|
+
};
|
|
230
|
+
return Promise.reject(languageClientError);
|
|
231
|
+
}
|
|
232
|
+
finally {
|
|
233
|
+
// always terminate the worker if desired
|
|
234
|
+
if (this.languageClientConfig.disposeWorker === true || forceWorkerDispose === true) {
|
|
235
|
+
this.disposeWorker();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
reportStatus() {
|
|
240
|
+
const status = [];
|
|
241
|
+
const languageClient = this.getLanguageClient();
|
|
242
|
+
status.push('LanguageClientWrapper status:');
|
|
243
|
+
status.push(`LanguageClient: ${languageClient?.name ?? 'Language Client'} is in a '${State[languageClient?.state ?? 1]}' state`);
|
|
244
|
+
return status;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=lcwrapper.js.map
|