monaco-languageclient 10.0.0-next.0 → 10.0.0-next.2
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 +20 -3
- package/README.md +98 -34
- package/lib/common/utils.d.ts +1 -1
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +1 -1
- package/lib/common/utils.js.map +1 -1
- package/lib/editorApp/config.d.ts +0 -2
- package/lib/editorApp/config.d.ts.map +1 -1
- package/lib/editorApp/config.js +1 -2
- package/lib/editorApp/config.js.map +1 -1
- package/lib/editorApp/editorApp.d.ts +4 -11
- package/lib/editorApp/editorApp.d.ts.map +1 -1
- package/lib/editorApp/editorApp.js +73 -88
- package/lib/editorApp/editorApp.js.map +1 -1
- package/lib/fs/definitions.d.ts +2 -2
- package/lib/fs/definitions.d.ts.map +1 -1
- package/lib/vscode/apiWrapper.d.ts +21 -6
- package/lib/vscode/apiWrapper.d.ts.map +1 -1
- package/lib/vscode/apiWrapper.js +67 -39
- package/lib/vscode/apiWrapper.js.map +1 -1
- package/lib/vscode/config.d.ts +8 -6
- package/lib/vscode/config.d.ts.map +1 -1
- package/lib/vscode/config.js +1 -1
- package/lib/vscode/utils.d.ts.map +1 -1
- package/lib/vscode/utils.js +4 -5
- package/lib/vscode/utils.js.map +1 -1
- package/lib/worker/index.js +1 -1
- package/lib/wrapper/lcconfig.d.ts +3 -3
- package/lib/wrapper/lcconfig.d.ts.map +1 -1
- package/lib/wrapper/lcconfig.js +1 -1
- package/lib/wrapper/lcmanager.d.ts +2 -1
- package/lib/wrapper/lcmanager.d.ts.map +1 -1
- package/lib/wrapper/lcmanager.js +21 -17
- package/lib/wrapper/lcmanager.js.map +1 -1
- package/lib/wrapper/lcwrapper.d.ts +1 -1
- package/lib/wrapper/lcwrapper.d.ts.map +1 -1
- package/lib/wrapper/lcwrapper.js +10 -9
- package/lib/wrapper/lcwrapper.js.map +1 -1
- package/package.json +41 -40
- package/src/common/utils.ts +1 -1
- package/src/editorApp/config.ts +1 -3
- package/src/editorApp/editorApp.ts +81 -96
- package/src/fs/definitions.ts +2 -2
- package/src/vscode/apiWrapper.ts +84 -44
- package/src/vscode/config.ts +13 -8
- package/src/vscode/utils.ts +4 -5
- package/src/worker/index.ts +1 -1
- package/src/wrapper/lcconfig.ts +5 -5
- package/src/wrapper/lcmanager.ts +23 -18
- package/src/wrapper/lcwrapper.ts +10 -9
package/CHANGELOG.md
CHANGED
|
@@ -2,10 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this npm module are documented in this file.
|
|
4
4
|
|
|
5
|
-
## [10.0.0
|
|
5
|
+
## [10.0.0] - unreleased
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
7
|
+
- Merge `monaco-editor-wrapper` with `monaco-languageclient`:
|
|
8
|
+
- Documentation update [#956](https://github.com/TypeFox/monaco-languageclient/pull/956).
|
|
9
|
+
- Lifecycle adjustments [#939](https://github.com/TypeFox/monaco-languageclient/pull/939).
|
|
10
|
+
- Move MonacoLanguageClientWrapper to monaco-languageclient [#920](https://github.com/TypeFox/monaco-languageclient/pull/920).
|
|
11
|
+
- Added multiple new sub-exports: `vscodeApiWrapper`, `lcwrapper`, `editorApp` and `workerFactory` that expose the merged functionality, please see the [migration guide](https://github.com/TypeFox/monaco-languageclient/blob/main/docs/migration.md).
|
|
12
|
+
- Updated all `@codingame/monaco-vscode` packages to `^21.0.1`.
|
|
13
|
+
|
|
14
|
+
## [9.11.0] - 2025-08-21
|
|
15
|
+
|
|
16
|
+
- Updated all `@codingame/monaco-vscode` packages to `20.2.1`.
|
|
17
|
+
|
|
18
|
+
## [9.10.0] - 2025-08-14
|
|
19
|
+
|
|
20
|
+
- Updated all `@codingame/monaco-vscode` packages to `20.1.1`.
|
|
21
|
+
|
|
22
|
+
## [9.9.0] - 2025-08-11
|
|
23
|
+
|
|
24
|
+
- Updated all `@codingame/monaco-vscode` packages to `19.1.4`.
|
|
25
|
+
- Updated `vscode-ws-jsonrpc` package to `3.5.0`.
|
|
9
26
|
|
|
10
27
|
## [9.8.0] - 2025-06-24
|
|
11
28
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# Monaco Language Client
|
|
2
2
|
|
|
3
|
-
[](https://gitpod.io#https://github.com/TypeFox/monaco-languageclient)
|
|
4
3
|
[](https://github.com/TypeFox/monaco-languageclient/labels/help%20wanted)
|
|
5
4
|
[](https://github.com/TypeFox/monaco-languageclient/actions/workflows/actions.yml)
|
|
6
5
|
[](https://www.npmjs.com/package/monaco-languageclient)
|
|
@@ -12,41 +11,106 @@ Module to connect [Monaco editor](https://microsoft.github.io/monaco-editor/) wi
|
|
|
12
11
|
|
|
13
12
|
All changes are noted in the [CHANGELOG](https://github.com/TypeFox/monaco-languageclient/blob/main/packages/client/CHANGELOG.md).
|
|
14
13
|
|
|
15
|
-
##
|
|
16
|
-
|
|
17
|
-
This is npm package is part of the
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
import
|
|
41
|
-
|
|
14
|
+
## Official documentation, quick start and examples
|
|
15
|
+
|
|
16
|
+
This is npm package is part of the [monaco-languageclient mono repo](https://github.com/TypeFox/monaco-languageclient).
|
|
17
|
+
|
|
18
|
+
You find detailed information in the [official documentation](https://github.com/TypeFox/monaco-languageclient/blob/main/docs/index.md).
|
|
19
|
+
|
|
20
|
+
If interested, check [quick start for local development]](<https://github.com/TypeFox/monaco-languageclient#getting-started>).
|
|
21
|
+
|
|
22
|
+
A detailed list of examples is contained in the GitHub repository, please see [this listing](<https://github.com/TypeFox/monaco-languageclient#examples-overview>).
|
|
23
|
+
|
|
24
|
+
## Version 10: A toolbox for language client applications
|
|
25
|
+
|
|
26
|
+
Since Version 2 this library relied on [@codingame/monaco-vscode-api](https://github.com/CodinGame/monaco-vscode-api) to supply the VSCode API (see [Important Project Changes](https://github.com/TypeFox/monaco-languageclient/blob/main/docs/versions-and-history.md#important-project-changes)). `monaco-vscode-api` has evolved substantially since then and thesedays provides 100+ packages with additional services, default extensions and language packs allowing you to create VSCode Web compatible applications.
|
|
27
|
+
|
|
28
|
+
Since `monaco-langaugeclient` version `10` all building blocks for complete web applications are contained in this package. The biggest deviation from the previous major versions is that the handling of monaco-vscode-api, the handling of language clients and the single editor app functionality are now very clearly separated. Instead of supplying an independent npm module (monaco-editor-wrapper), almost all useful pieces of code were moved here and the different functionalities are exposed via domain specific sub-exports:
|
|
29
|
+
|
|
30
|
+
- **vscodeApiWrapper**: Contains MonacoVscodeApiWrapper used to handle everything regarding monaco-vscode-api
|
|
31
|
+
- **lcwrapper**: LanguageClientWrapper & LanguageClientsManager help to control one or multiple language clients
|
|
32
|
+
- **editorApp**: EditorApp is used to control a single monaco-editor
|
|
33
|
+
|
|
34
|
+
### Usage
|
|
35
|
+
|
|
36
|
+
The `monaco-vscode-api` initialization and start-up can only and must been only done once within an applications' lifecycle. Everything else cab be repeated. If you use TypeScript all configuration is fully typed.
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import * as vscode from 'vscode';
|
|
40
|
+
// Import Monaco Language Client components
|
|
41
|
+
import { EditorApp, type EditorAppConfig } from 'monaco-languageclient/editorApp';
|
|
42
|
+
import { configureDefaultWorkerFactory } from 'monaco-languageclient/workerFactory';
|
|
43
|
+
import { MonacoVscodeApiWrapper, type MonacoVscodeApiConfig } from 'monaco-languageclient/vscodeApiWrapper';
|
|
44
|
+
import { LanguageClientWrapper, type LanguageClientConfig } from 'monaco-languageclient/lcwrapper';
|
|
45
|
+
|
|
46
|
+
async function createEditorAndLanguageClient() {
|
|
47
|
+
const languageId = 'mylang';
|
|
48
|
+
const code = '// initial editor content';
|
|
49
|
+
const codeUri = '/workspace/hello.mylang';
|
|
50
|
+
|
|
51
|
+
// Monaco VSCode API configuration
|
|
52
|
+
const vscodeApiConfig: MonacoVscodeApiConfig = {
|
|
53
|
+
$type: 'extended',
|
|
54
|
+
viewsConfig: {
|
|
55
|
+
$type: 'EditorService',
|
|
56
|
+
// the div to which monaco-editor is added
|
|
57
|
+
htmlContainer: document.getElementById('monaco-editor-root')!
|
|
58
|
+
},
|
|
59
|
+
userConfiguration: {
|
|
60
|
+
json: JSON.stringify({
|
|
61
|
+
'workbench.colorTheme': 'Default Dark Modern',
|
|
62
|
+
'editor.wordBasedSuggestions': 'off'
|
|
63
|
+
})
|
|
64
|
+
},
|
|
65
|
+
monacoWorkerFactory: configureDefaultWorkerFactory
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// Language client configuration
|
|
69
|
+
const languageClientConfig: LanguageClientConfig = {
|
|
70
|
+
languageId,
|
|
71
|
+
connection: {
|
|
72
|
+
options: {
|
|
73
|
+
$type: 'WebSocketUrl',
|
|
74
|
+
// at this url the language server for myLang must be reachable
|
|
75
|
+
url: 'ws://localhost:30000/myLangLS'
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
clientOptions: {
|
|
79
|
+
documentSelector: [languageId],
|
|
80
|
+
orkspaceFolder: {
|
|
81
|
+
index: 0,
|
|
82
|
+
name: 'workspace',
|
|
83
|
+
uri: vscode.Uri.file('/workspace')
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// editor app / monaco-editor configuration
|
|
89
|
+
const editorAppConfig: EditorAppConfig = {
|
|
90
|
+
codeResources: {
|
|
91
|
+
main: {
|
|
92
|
+
text: code,
|
|
93
|
+
uri: codeUri
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// Create the monaco-vscode api Wrapper and start it before anything else
|
|
99
|
+
const apiWrapper = new MonacoVscodeApiWrapper(vscodeApiConfig);
|
|
100
|
+
await apiWrapper.start();
|
|
101
|
+
|
|
102
|
+
// Create language client wrapper
|
|
103
|
+
const lcWrapper = new LanguageClientWrapper(languageClientConfig);
|
|
104
|
+
await lcWrapper.start();
|
|
105
|
+
|
|
106
|
+
// Create and start the editor app
|
|
107
|
+
const editorApp = new EditorApp(editorAppConfig);
|
|
108
|
+
await editorApp.start(apiWrapper.getHtmlContainer());
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
createEditorAndLanguageClient().catch(console.error);
|
|
42
112
|
```
|
|
43
113
|
|
|
44
|
-
Once you those services you can no longer make use of monarch based grammars and themes.
|
|
45
|
-
|
|
46
|
-
## Examples
|
|
47
|
-
|
|
48
|
-
For a detailed list of examples please look at [this section](<https://github.com/TypeFox/monaco-languageclient#examples-overview>) in the main repository.
|
|
49
|
-
|
|
50
114
|
## License
|
|
51
115
|
|
|
52
116
|
[MIT](https://github.com/TypeFox/monaco-languageclient/blob/main/packages/client/LICENSE)
|
package/lib/common/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { WebSocketUrlParams, WebSocketUrlString } from './commonTypes.js';
|
|
2
2
|
export declare const createUrl: (config: WebSocketUrlParams | WebSocketUrlString) => string;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const encodeStringOrUrlToDataUrl: (input: string | URL) => string;
|
|
4
4
|
export declare const delayExecution: (ms: number) => Promise<unknown>;
|
|
5
5
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/common/utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,eAAO,MAAM,SAAS,GAAI,QAAQ,kBAAkB,GAAG,kBAAkB,WA+BxE,CAAC;AAEF,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/common/utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,eAAO,MAAM,SAAS,GAAI,QAAQ,kBAAkB,GAAG,kBAAkB,WA+BxE,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,OAAO,MAAM,GAAG,GAAG,WAS7D,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,IAAI,MAAM,qBAExC,CAAC"}
|
package/lib/common/utils.js
CHANGED
package/lib/common/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/common/utils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAIhG,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAA+C,EAAE,EAAE;IACzE,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,IAAK,MAA6B,CAAC,GAAG,EAAE,CAAC;QACrC,MAAM,OAAO,GAAG,MAA4B,CAAC;QAC7C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YACxE,MAAM,IAAI,KAAK,CAAC,uCAAuC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC1E,CAAC;QACD,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAC3B,CAAC;SAAM,CAAC;QACJ,MAAM,OAAO,GAAG,MAA4B,CAAC;QAC7C,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QAChD,QAAQ,GAAG,GAAG,QAAQ,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;QAC3C,IAAI,OAAO,CAAC,IA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M,CAAC,MAAM,0BAA0B,GAAG,CAAC,KAAmB,EAAE,EAAE;IAC9D,IAAI,KAAK,YAAY,GAAG,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC,IAAI,CAAC;IACtB,CAAC;SAAM,CAAC;QACJ,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC9C,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC7E,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/B,OAAO,IAAI,GAAG,CAAC,0BAA0B,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC;IAC5D,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAU,EAAE,EAAE;IACzC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC7D,CAAC,CAAC"}
|
|
@@ -2,7 +2,6 @@ import { LogLevel } from '@codingame/monaco-vscode-api';
|
|
|
2
2
|
import { type ITextFileEditorModel } from '@codingame/monaco-vscode-api/monaco';
|
|
3
3
|
import * as monaco from '@codingame/monaco-vscode-editor-api';
|
|
4
4
|
import type { IReference } from '@codingame/monaco-vscode-editor-service-override';
|
|
5
|
-
import { type OverallConfigType } from 'monaco-languageclient/vscodeApiWrapper';
|
|
6
5
|
export declare class ModelRefs {
|
|
7
6
|
modified?: IReference<ITextFileEditorModel>;
|
|
8
7
|
original?: IReference<ITextFileEditorModel>;
|
|
@@ -34,7 +33,6 @@ export interface DisposableModelRefs {
|
|
|
34
33
|
}
|
|
35
34
|
export interface EditorAppConfig {
|
|
36
35
|
id?: string;
|
|
37
|
-
$type?: OverallConfigType;
|
|
38
36
|
logLevel?: LogLevel | number;
|
|
39
37
|
codeResources?: CodeResources;
|
|
40
38
|
useDiffEditor?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/editorApp/config.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,MAAM,MAAM,qCAAqC,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kDAAkD,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/editorApp/config.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,MAAM,MAAM,qCAAqC,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kDAAkD,CAAC;AAEnF,qBAAa,SAAS;IAClB,QAAQ,CAAC,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC;IAC5C,QAAQ,CAAC,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,UAAU;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC;CAC9C;AAED,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,iBAAiB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
/* --------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) 2025 TypeFox and others.
|
|
3
3
|
* Licensed under the MIT License. See LICENSE in the package root for license information.
|
|
4
4
|
* ------------------------------------------------------------------------------------------ */
|
|
5
5
|
import { LogLevel } from '@codingame/monaco-vscode-api';
|
|
6
6
|
import {} from '@codingame/monaco-vscode-api/monaco';
|
|
7
7
|
import * as monaco from '@codingame/monaco-vscode-editor-api';
|
|
8
|
-
import {} from 'monaco-languageclient/vscodeApiWrapper';
|
|
9
8
|
export class ModelRefs {
|
|
10
9
|
modified;
|
|
11
10
|
original;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/editorApp/config.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAA6B,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,MAAM,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/editorApp/config.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAA6B,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,MAAM,MAAM,qCAAqC,CAAC;AAG9D,MAAM,OAAO,SAAS;IAClB,QAAQ,CAAoC;IAC5C,QAAQ,CAAoC;CAC/C"}
|
|
@@ -2,16 +2,15 @@ import { type ITextFileEditorModel } from '@codingame/monaco-vscode-api/monaco';
|
|
|
2
2
|
import * as monaco from '@codingame/monaco-vscode-editor-api';
|
|
3
3
|
import type { IReference } from '@codingame/monaco-vscode-editor-service-override';
|
|
4
4
|
import { type Logger } from 'monaco-languageclient/common';
|
|
5
|
-
import {
|
|
5
|
+
import type { CodeContent, CodeResources, EditorAppConfig, TextContents, TextModels } from './config.js';
|
|
6
6
|
/**
|
|
7
|
-
* This is the base class for both Monaco
|
|
7
|
+
* This is the base class for both Monaco Editor Apps:
|
|
8
8
|
* - EditorAppClassic
|
|
9
9
|
* - EditorAppExtended
|
|
10
10
|
*
|
|
11
11
|
* It provides the generic functionality for both implementations.
|
|
12
12
|
*/
|
|
13
13
|
export declare class EditorApp {
|
|
14
|
-
private $type;
|
|
15
14
|
private id;
|
|
16
15
|
private config;
|
|
17
16
|
protected logger: Logger;
|
|
@@ -19,13 +18,11 @@ export declare class EditorApp {
|
|
|
19
18
|
private diffEditor;
|
|
20
19
|
private modelRefs;
|
|
21
20
|
private onTextChanged?;
|
|
22
|
-
private
|
|
21
|
+
private textChangedDisposables;
|
|
23
22
|
private modelDisposables;
|
|
24
23
|
private modelRefDisposeTimeout;
|
|
25
24
|
private startingAwait?;
|
|
26
|
-
private startingResolve;
|
|
27
25
|
private disposingAwait?;
|
|
28
|
-
private disposingResolve;
|
|
29
26
|
constructor(userAppConfig?: EditorAppConfig);
|
|
30
27
|
isDiffEditor(): boolean;
|
|
31
28
|
getConfig(): EditorAppConfig;
|
|
@@ -35,15 +32,13 @@ export declare class EditorApp {
|
|
|
35
32
|
getLogger(): Logger;
|
|
36
33
|
registerOnTextChangedCallback(onTextChanged?: (textChanges: TextContents) => void): void;
|
|
37
34
|
setModelRefDisposeTimeout(modelRefDisposeTimeout: number): void;
|
|
38
|
-
private markStarting;
|
|
39
|
-
private markStarted;
|
|
40
35
|
isStarting(): boolean;
|
|
41
36
|
getStartingAwait(): Promise<void> | undefined;
|
|
42
37
|
isStarted(): boolean;
|
|
43
38
|
/**
|
|
44
39
|
* Starts the single editor application.
|
|
45
40
|
*/
|
|
46
|
-
start(htmlContainer: HTMLElement): Promise<
|
|
41
|
+
start(htmlContainer: HTMLElement): Promise<undefined>;
|
|
47
42
|
createEditors(htmlContainer: HTMLElement): Promise<void>;
|
|
48
43
|
updateCode(code: {
|
|
49
44
|
modified?: string;
|
|
@@ -54,8 +49,6 @@ export declare class EditorApp {
|
|
|
54
49
|
private announceModelUpdate;
|
|
55
50
|
dispose(): Promise<void>;
|
|
56
51
|
isDisposed(): boolean;
|
|
57
|
-
private markDisposing;
|
|
58
|
-
private markDisposed;
|
|
59
52
|
isDisposing(): boolean;
|
|
60
53
|
getDisposingAwait(): Promise<void> | undefined;
|
|
61
54
|
disposeModelRefs(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editorApp.d.ts","sourceRoot":"","sources":["../../src/editorApp/editorApp.ts"],"names":[],"mappings":"AAMA,OAAO,EAAwB,KAAK,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AACtG,OAAO,KAAK,MAAM,MAAM,qCAAqC,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kDAAkD,CAAC;AACnF,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAG1E,OAAO,
|
|
1
|
+
{"version":3,"file":"editorApp.d.ts","sourceRoot":"","sources":["../../src/editorApp/editorApp.ts"],"names":[],"mappings":"AAMA,OAAO,EAAwB,KAAK,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AACtG,OAAO,KAAK,MAAM,MAAM,qCAAqC,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kDAAkD,CAAC;AACnF,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAG1E,OAAO,KAAK,EAAuB,WAAW,EAAE,aAAa,EAAuB,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGnJ;;;;;;GAMG;AACH,qBAAa,SAAS;IAElB,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,MAAM,CAAkB;IAEhC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAuB;IAE/C,OAAO,CAAC,MAAM,CAAkD;IAChE,OAAO,CAAC,UAAU,CAAkD;IAEpE,OAAO,CAAC,SAAS,CA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AU,EAAE,gBAAgB,CAAC,WAAW,EAAE,YAAY,KAAK,IAAI,SAOhH,CAAC"}
|
|
@@ -10,14 +10,13 @@ import { getEnhancedMonacoEnvironment } from 'monaco-languageclient/vscodeApiWra
|
|
|
10
10
|
import * as vscode from 'vscode';
|
|
11
11
|
import { ModelRefs } from './config.js';
|
|
12
12
|
/**
|
|
13
|
-
* This is the base class for both Monaco
|
|
13
|
+
* This is the base class for both Monaco Editor Apps:
|
|
14
14
|
* - EditorAppClassic
|
|
15
15
|
* - EditorAppExtended
|
|
16
16
|
*
|
|
17
17
|
* It provides the generic functionality for both implementations.
|
|
18
18
|
*/
|
|
19
19
|
export class EditorApp {
|
|
20
|
-
$type;
|
|
21
20
|
id;
|
|
22
21
|
config;
|
|
23
22
|
logger = new ConsoleLogger();
|
|
@@ -25,15 +24,12 @@ export class EditorApp {
|
|
|
25
24
|
diffEditor;
|
|
26
25
|
modelRefs = new ModelRefs();
|
|
27
26
|
onTextChanged;
|
|
28
|
-
|
|
27
|
+
textChangedDisposables = {};
|
|
29
28
|
modelDisposables = {};
|
|
30
29
|
modelRefDisposeTimeout = -1;
|
|
31
30
|
startingAwait;
|
|
32
|
-
startingResolve;
|
|
33
31
|
disposingAwait;
|
|
34
|
-
disposingResolve;
|
|
35
32
|
constructor(userAppConfig) {
|
|
36
|
-
this.$type = userAppConfig?.$type ?? 'extended';
|
|
37
33
|
this.id = userAppConfig?.id ?? Math.floor(Math.random() * 1000001).toString();
|
|
38
34
|
if ((userAppConfig?.useDiffEditor ?? false) && !userAppConfig?.codeResources?.original) {
|
|
39
35
|
throw new Error(`Use diff editor was used without a valid config. code: ${userAppConfig?.codeResources?.modified} codeOriginal: ${userAppConfig?.codeResources?.original}`);
|
|
@@ -83,15 +79,6 @@ export class EditorApp {
|
|
|
83
79
|
setModelRefDisposeTimeout(modelRefDisposeTimeout) {
|
|
84
80
|
this.modelRefDisposeTimeout = modelRefDisposeTimeout;
|
|
85
81
|
}
|
|
86
|
-
markStarting() {
|
|
87
|
-
this.startingAwait = new Promise((resolve) => {
|
|
88
|
-
this.startingResolve = resolve;
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
markStarted() {
|
|
92
|
-
this.startingResolve();
|
|
93
|
-
this.startingAwait = undefined;
|
|
94
|
-
}
|
|
95
82
|
isStarting() {
|
|
96
83
|
return this.startingAwait !== undefined;
|
|
97
84
|
}
|
|
@@ -108,36 +95,61 @@ export class EditorApp {
|
|
|
108
95
|
if (this.isStarting()) {
|
|
109
96
|
await this.getStartingAwait();
|
|
110
97
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
98
|
+
let startingResolve = () => { };
|
|
99
|
+
this.startingAwait = new Promise((resolve) => {
|
|
100
|
+
startingResolve = resolve;
|
|
101
|
+
});
|
|
102
|
+
try {
|
|
103
|
+
const envEnhanced = getEnhancedMonacoEnvironment();
|
|
104
|
+
const viewServiceType = envEnhanced.viewServiceType;
|
|
105
|
+
// check general error case first
|
|
106
|
+
if (!(envEnhanced.vscodeApiInitialised ?? false)) {
|
|
107
|
+
return Promise.reject('monaco-vscode-api was not initialized. Aborting.');
|
|
119
108
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const languageRegistered = monaco.languages.getLanguages().filter(x => x.id === languageDef.languageExtensionConfig.id);
|
|
123
|
-
if (languageRegistered.length === 0) {
|
|
124
|
-
// this is only meaningful for languages supported by monaco out of the box
|
|
125
|
-
monaco.languages.register({
|
|
126
|
-
id: languageDef.languageExtensionConfig.id
|
|
127
|
-
});
|
|
109
|
+
if (viewServiceType !== 'EditorService' && viewServiceType !== undefined) {
|
|
110
|
+
return Promise.reject('No EditorService configured. monaco-editor will not be started.');
|
|
128
111
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
monaco.languages.setMonarchTokensProvider(languageDef.languageExtensionConfig.id, languageDef.monarchLanguage);
|
|
112
|
+
if (!this.isDisposed()) {
|
|
113
|
+
return Promise.reject('Start was called without properly disposing the EditorApp first.');
|
|
132
114
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
115
|
+
const languageDef = this.config.languageDef;
|
|
116
|
+
if (languageDef) {
|
|
117
|
+
// register own language first
|
|
118
|
+
monaco.languages.register(languageDef.languageExtensionConfig);
|
|
119
|
+
const languageRegistered = monaco.languages.getLanguages().filter(x => x.id === languageDef.languageExtensionConfig.id);
|
|
120
|
+
if (languageRegistered.length === 0) {
|
|
121
|
+
// this is only meaningful for languages supported by monaco out of the box
|
|
122
|
+
monaco.languages.register({
|
|
123
|
+
id: languageDef.languageExtensionConfig.id
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
// apply monarch definitions
|
|
127
|
+
if (languageDef.monarchLanguage) {
|
|
128
|
+
monaco.languages.setMonarchTokensProvider(languageDef.languageExtensionConfig.id, languageDef.monarchLanguage);
|
|
129
|
+
}
|
|
130
|
+
if (languageDef.theme) {
|
|
131
|
+
monaco.editor.defineTheme(languageDef.theme.name, languageDef.theme.data);
|
|
132
|
+
monaco.editor.setTheme(languageDef.theme.name);
|
|
133
|
+
}
|
|
136
134
|
}
|
|
135
|
+
if (this.config.editorOptions?.['semanticHighlighting.enabled'] !== undefined) {
|
|
136
|
+
StandaloneServices.get(IConfigurationService).updateValue('editor.semanticHighlighting.enabled', this.config.editorOptions['semanticHighlighting.enabled'], ConfigurationTarget.USER);
|
|
137
|
+
}
|
|
138
|
+
await this.createEditors(htmlContainer);
|
|
139
|
+
// everything is fine at this point
|
|
140
|
+
startingResolve();
|
|
141
|
+
this.logger.info('EditorApp start completed successfully.');
|
|
137
142
|
}
|
|
138
|
-
|
|
139
|
-
|
|
143
|
+
catch (e) {
|
|
144
|
+
// in case of further errors (after general ones above)
|
|
145
|
+
// take the error and build a new rejection to complete the promise
|
|
146
|
+
return Promise.reject(e);
|
|
140
147
|
}
|
|
148
|
+
finally {
|
|
149
|
+
this.startingAwait = undefined;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async createEditors(htmlContainer) {
|
|
141
153
|
// ensure proper default resources are initialized, uris have to be unique
|
|
142
154
|
const modified = {
|
|
143
155
|
text: this.config.codeResources?.modified?.text ?? '',
|
|
@@ -153,31 +165,10 @@ export class EditorApp {
|
|
|
153
165
|
};
|
|
154
166
|
this.modelRefs.original = await this.buildModelReference(original, this.logger);
|
|
155
167
|
}
|
|
156
|
-
|
|
157
|
-
const envEnhanced = getEnhancedMonacoEnvironment();
|
|
158
|
-
const viewServiceType = envEnhanced.viewServiceType;
|
|
159
|
-
if (viewServiceType === 'EditorService' || viewServiceType === undefined) {
|
|
160
|
-
this.logger.info(`Starting monaco-editor (${this.id})`);
|
|
161
|
-
await this.createEditors(htmlContainer);
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
this.logger.info('No EditorService configured. monaco-editor will not be started.');
|
|
165
|
-
}
|
|
166
|
-
this.logger.info('EditorApp start completed successfully.');
|
|
167
|
-
// eslint-disable-next-line no-useless-catch
|
|
168
|
-
}
|
|
169
|
-
catch (e) {
|
|
170
|
-
throw e;
|
|
171
|
-
}
|
|
172
|
-
finally {
|
|
173
|
-
// in case of rejection, mark as started, otherwise the promise will never resolve
|
|
174
|
-
this.markStarted();
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
async createEditors(htmlContainer) {
|
|
168
|
+
this.logger.info(`Starting monaco-editor (${this.id})`);
|
|
178
169
|
if (this.isDiffEditor()) {
|
|
179
170
|
this.diffEditor = monaco.editor.createDiffEditor(htmlContainer, this.config.diffEditorOptions);
|
|
180
|
-
const modified = this.modelRefs.modified
|
|
171
|
+
const modified = this.modelRefs.modified.object.textEditorModel ?? undefined;
|
|
181
172
|
const original = this.modelRefs.original?.object.textEditorModel ?? undefined;
|
|
182
173
|
if (modified !== undefined && original !== undefined) {
|
|
183
174
|
const model = {
|
|
@@ -190,7 +181,7 @@ export class EditorApp {
|
|
|
190
181
|
}
|
|
191
182
|
else {
|
|
192
183
|
const model = {
|
|
193
|
-
modified: this.modelRefs.modified
|
|
184
|
+
modified: this.modelRefs.modified.object.textEditorModel
|
|
194
185
|
};
|
|
195
186
|
this.editor = monaco.editor.create(htmlContainer, {
|
|
196
187
|
...this.config.editorOptions,
|
|
@@ -279,16 +270,16 @@ export class EditorApp {
|
|
|
279
270
|
if (this.onTextChanged !== undefined) {
|
|
280
271
|
let changed = false;
|
|
281
272
|
if (textModels.modified !== undefined && textModels.modified !== null) {
|
|
282
|
-
const old = this.
|
|
283
|
-
this.
|
|
273
|
+
const old = this.textChangedDisposables.modified;
|
|
274
|
+
this.textChangedDisposables.modified = textModels.modified.onDidChangeContent(() => {
|
|
284
275
|
didModelContentChange(textModels, this.onTextChanged);
|
|
285
276
|
});
|
|
286
277
|
old?.dispose();
|
|
287
278
|
changed = true;
|
|
288
279
|
}
|
|
289
280
|
if (textModels.original !== undefined && textModels.original !== null) {
|
|
290
|
-
const old = this.
|
|
291
|
-
this.
|
|
281
|
+
const old = this.textChangedDisposables.original;
|
|
282
|
+
this.textChangedDisposables.original = textModels.original.onDidChangeContent(() => {
|
|
292
283
|
didModelContentChange(textModels, this.onTextChanged);
|
|
293
284
|
});
|
|
294
285
|
old?.dispose();
|
|
@@ -304,7 +295,10 @@ export class EditorApp {
|
|
|
304
295
|
if (this.isDisposing()) {
|
|
305
296
|
await this.getDisposingAwait();
|
|
306
297
|
}
|
|
307
|
-
|
|
298
|
+
let disposingResolve = () => { };
|
|
299
|
+
this.disposingAwait = new Promise((resolve) => {
|
|
300
|
+
disposingResolve = resolve;
|
|
301
|
+
});
|
|
308
302
|
if (this.editor) {
|
|
309
303
|
this.editor.dispose();
|
|
310
304
|
this.editor = undefined;
|
|
@@ -313,27 +307,18 @@ export class EditorApp {
|
|
|
313
307
|
this.diffEditor.dispose();
|
|
314
308
|
this.diffEditor = undefined;
|
|
315
309
|
}
|
|
316
|
-
this.
|
|
317
|
-
this.
|
|
318
|
-
this.
|
|
319
|
-
this.
|
|
310
|
+
this.textChangedDisposables.modified?.dispose();
|
|
311
|
+
this.textChangedDisposables.original?.dispose();
|
|
312
|
+
this.textChangedDisposables.modified = undefined;
|
|
313
|
+
this.textChangedDisposables.original = undefined;
|
|
320
314
|
await this.disposeModelRefs();
|
|
321
|
-
|
|
315
|
+
disposingResolve();
|
|
316
|
+
this.disposingAwait = undefined;
|
|
322
317
|
}
|
|
323
318
|
isDisposed() {
|
|
324
319
|
return this.editor === undefined && this.diffEditor === undefined &&
|
|
325
|
-
// this.textChangedDiposeables.modified === undefined && this.textChangedDiposeables.original === undefined &&
|
|
326
320
|
this.modelDisposables.original === undefined && this.modelDisposables.modified === undefined;
|
|
327
321
|
}
|
|
328
|
-
markDisposing() {
|
|
329
|
-
this.disposingAwait = new Promise((resolve) => {
|
|
330
|
-
this.disposingResolve = resolve;
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
markDisposed() {
|
|
334
|
-
this.disposingResolve();
|
|
335
|
-
this.disposingAwait = undefined;
|
|
336
|
-
}
|
|
337
322
|
isDisposing() {
|
|
338
323
|
return this.disposingAwait !== undefined;
|
|
339
324
|
}
|
|
@@ -341,7 +326,7 @@ export class EditorApp {
|
|
|
341
326
|
return this.disposingAwait;
|
|
342
327
|
}
|
|
343
328
|
async disposeModelRefs() {
|
|
344
|
-
const
|
|
329
|
+
const disposeRefs = () => {
|
|
345
330
|
if (this.logger.getLevel() === LogLevel.Debug) {
|
|
346
331
|
const models = monaco.editor.getModels();
|
|
347
332
|
this.logger.debug('Current model URIs:');
|
|
@@ -349,11 +334,11 @@ export class EditorApp {
|
|
|
349
334
|
this.logger.debug(`${model.uri.toString()}`);
|
|
350
335
|
});
|
|
351
336
|
}
|
|
352
|
-
if (this.modelDisposables.modified !== undefined && !
|
|
337
|
+
if (this.modelDisposables.modified !== undefined && !this.modelDisposables.modified.object.isDisposed()) {
|
|
353
338
|
this.modelDisposables.modified.dispose();
|
|
354
339
|
this.modelDisposables.modified = undefined;
|
|
355
340
|
}
|
|
356
|
-
if (this.modelDisposables.original !== undefined && !
|
|
341
|
+
if (this.modelDisposables.original !== undefined && !this.modelDisposables.original.object.isDisposed()) {
|
|
357
342
|
this.modelDisposables.original.dispose();
|
|
358
343
|
this.modelDisposables.original = undefined;
|
|
359
344
|
}
|
|
@@ -369,12 +354,12 @@ export class EditorApp {
|
|
|
369
354
|
if (this.modelRefDisposeTimeout > 0) {
|
|
370
355
|
this.logger.debug('Using async dispose of model references');
|
|
371
356
|
await new Promise(resolve => setTimeout(() => {
|
|
372
|
-
|
|
357
|
+
disposeRefs();
|
|
373
358
|
resolve();
|
|
374
359
|
}, this.modelRefDisposeTimeout));
|
|
375
360
|
}
|
|
376
361
|
else {
|
|
377
|
-
|
|
362
|
+
disposeRefs();
|
|
378
363
|
}
|
|
379
364
|
}
|
|
380
365
|
updateLayout() {
|