monaco-languageclient 10.7.0 → 11.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 +13 -4
- package/LICENSE +0 -0
- package/README.md +63 -63
- package/lib/common/commonTypes.d.ts +1 -1
- package/lib/common/commonTypes.d.ts.map +1 -1
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +2 -2
- package/lib/common/utils.js.map +1 -1
- package/lib/debugger/index.d.ts +1 -1
- package/lib/debugger/index.d.ts.map +1 -1
- package/lib/debugger/index.js +2 -4
- package/lib/debugger/index.js.map +1 -1
- package/lib/editorApp/config.d.ts +11 -11
- package/lib/editorApp/config.d.ts.map +1 -1
- package/lib/editorApp/config.js +0 -1
- package/lib/editorApp/config.js.map +1 -1
- package/lib/editorApp/editorApp.d.ts +5 -5
- package/lib/editorApp/editorApp.d.ts.map +1 -1
- package/lib/editorApp/editorApp.js +21 -23
- package/lib/editorApp/editorApp.js.map +1 -1
- package/lib/fs/definitions.d.ts.map +1 -1
- package/lib/fs/endpoints/defaultEndpoint.d.ts.map +1 -1
- package/lib/fs/endpoints/defaultEndpoint.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/vscode/apiWrapper.d.ts +2 -2
- package/lib/vscode/apiWrapper.d.ts.map +1 -1
- package/lib/vscode/apiWrapper.js +18 -20
- package/lib/vscode/apiWrapper.js.map +1 -1
- package/lib/vscode/config.d.ts +4 -4
- package/lib/vscode/config.d.ts.map +1 -1
- package/lib/vscode/config.js +0 -1
- package/lib/vscode/config.js.map +1 -1
- package/lib/vscode/locales.d.ts +1 -1
- package/lib/vscode/locales.d.ts.map +1 -1
- package/lib/vscode/locales.js +35 -18
- package/lib/vscode/locales.js.map +1 -1
- package/lib/vscode/utils.d.ts +3 -3
- package/lib/vscode/utils.d.ts.map +1 -1
- package/lib/vscode/utils.js +3 -10
- package/lib/vscode/utils.js.map +1 -1
- package/lib/vscode/viewsService.d.ts.map +1 -1
- package/lib/vscode/viewsService.js +13 -7
- package/lib/vscode/viewsService.js.map +1 -1
- package/lib/worker/index.d.ts +1 -1
- package/lib/worker/index.d.ts.map +1 -1
- package/lib/worker/index.js.map +1 -1
- package/lib/wrapper/lcconfig.d.ts +2 -2
- package/lib/wrapper/lcconfig.d.ts.map +1 -1
- package/lib/wrapper/lcmanager.d.ts.map +1 -1
- 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 +17 -16
- package/lib/wrapper/lcwrapper.js.map +1 -1
- package/package.json +70 -96
- package/src/common/commonTypes.ts +35 -30
- package/src/common/index.ts +0 -1
- package/src/common/utils.ts +45 -45
- package/src/debugger/index.ts +130 -133
- package/src/editorApp/config.ts +33 -33
- package/src/editorApp/editorApp.ts +382 -370
- package/src/fs/definitions.ts +72 -75
- package/src/fs/endpoints/defaultEndpoint.ts +50 -41
- package/src/index.ts +18 -18
- package/src/vscode/apiWrapper.ts +302 -295
- package/src/vscode/config.ts +30 -30
- package/src/vscode/locales.ts +127 -110
- package/src/vscode/utils.ts +20 -26
- package/src/vscode/viewsService.ts +44 -37
- package/src/worker/index.ts +38 -45
- package/src/wrapper/lcconfig.ts +16 -16
- package/src/wrapper/lcmanager.ts +68 -69
- package/src/wrapper/lcwrapper.ts +256 -249
package/src/vscode/apiWrapper.ts
CHANGED
|
@@ -4,10 +4,16 @@
|
|
|
4
4
|
* ------------------------------------------------------------------------------------------ */
|
|
5
5
|
|
|
6
6
|
import { initialize, LogLevel } from '@codingame/monaco-vscode-api';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
ExtensionHostKind,
|
|
9
|
+
getBuiltinExtensions,
|
|
10
|
+
registerExtension,
|
|
11
|
+
type IExtensionManifest,
|
|
12
|
+
type RegisterExtensionResult
|
|
13
|
+
} from '@codingame/monaco-vscode-api/extensions';
|
|
8
14
|
import { DisposableStore, setUnexpectedErrorHandler } from '@codingame/monaco-vscode-api/monaco';
|
|
9
15
|
import getConfigurationServiceOverride, { initUserConfiguration } from '@codingame/monaco-vscode-configuration-service-override';
|
|
10
|
-
import
|
|
16
|
+
import type { editor } from '@codingame/monaco-vscode-editor-api';
|
|
11
17
|
import getLogServiceOverride, { ConsoleLogger, type ILogger } from '@codingame/monaco-vscode-log-service-override';
|
|
12
18
|
import getModelServiceOverride from '@codingame/monaco-vscode-model-service-override';
|
|
13
19
|
import { encodeStringOrUrlToDataUrl } from 'monaco-languageclient/common';
|
|
@@ -18,350 +24,351 @@ import type { ExtensionConfig, MonacoVscodeApiConfig, ViewsConfig } from './conf
|
|
|
18
24
|
import { getEnhancedMonacoEnvironment, mergeServices, reportServiceLoading, useOpenEditorStub } from './utils.js';
|
|
19
25
|
|
|
20
26
|
export interface MonacoVscodeApiConfigRuntime extends MonacoVscodeApiConfig {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
serviceOverrides: editor.IEditorOverrideServices;
|
|
28
|
+
logLevel: LogLevel | number;
|
|
29
|
+
viewsConfig: ViewsConfig;
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
export interface StartInstructions {
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
caller?: string;
|
|
34
|
+
performServiceConsistencyChecks?: boolean;
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
export class MonacoVscodeApiWrapper {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
private logger: ILogger = new ConsoleLogger();
|
|
39
|
+
private extensionRegisterResults: Map<string, RegisterExtensionResult> = new Map();
|
|
40
|
+
private disposableStore: DisposableStore = new DisposableStore();
|
|
41
|
+
private apiConfig: MonacoVscodeApiConfigRuntime;
|
|
42
|
+
|
|
43
|
+
constructor(apiConfig: MonacoVscodeApiConfig) {
|
|
44
|
+
this.apiConfig = {
|
|
45
|
+
...apiConfig,
|
|
46
|
+
serviceOverrides: apiConfig.serviceOverrides ?? {},
|
|
47
|
+
logLevel: apiConfig.logLevel ?? LogLevel.Off
|
|
48
|
+
};
|
|
49
|
+
this.logger.setLevel(this.apiConfig.logLevel);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
getExtensionRegisterResult(extensionName: string) {
|
|
53
|
+
return this.extensionRegisterResults.get(extensionName);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
getMonacoVscodeApiConfig(): MonacoVscodeApiConfig {
|
|
57
|
+
return this.apiConfig;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
protected configureMonacoWorkers() {
|
|
61
|
+
if (typeof this.apiConfig.monacoWorkerFactory === 'function') {
|
|
62
|
+
this.apiConfig.monacoWorkerFactory(this.logger);
|
|
63
|
+
} else {
|
|
64
|
+
useWorkerFactory({
|
|
65
|
+
logger: this.logger
|
|
66
|
+
});
|
|
45
67
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private performErrorHandling = (message: string) => {
|
|
71
|
+
getEnhancedMonacoEnvironment().vscodeApiInitialising = false;
|
|
72
|
+
throw new Error(message);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
protected async configureHighlightingServices() {
|
|
76
|
+
if (this.apiConfig.$type === 'extended') {
|
|
77
|
+
const getTextmateServiceOverride = (await import('@codingame/monaco-vscode-textmate-service-override')).default;
|
|
78
|
+
const getThemeServiceOverride = (await import('@codingame/monaco-vscode-theme-service-override')).default;
|
|
79
|
+
const getLanguagesServiceOverride = (await import('@codingame/monaco-vscode-languages-service-override')).default;
|
|
80
|
+
mergeServices(this.apiConfig.serviceOverrides, {
|
|
81
|
+
...getLanguagesServiceOverride(),
|
|
82
|
+
...getTextmateServiceOverride(),
|
|
83
|
+
...getThemeServiceOverride()
|
|
84
|
+
});
|
|
85
|
+
} else {
|
|
86
|
+
const getMonarchServiceOverride = (await import('@codingame/monaco-vscode-monarch-service-override')).default;
|
|
87
|
+
mergeServices(this.apiConfig.serviceOverrides, {
|
|
88
|
+
...getMonarchServiceOverride()
|
|
89
|
+
});
|
|
49
90
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
protected async configureViewsServices() {
|
|
94
|
+
const viewsConfigType = this.apiConfig.viewsConfig.$type;
|
|
95
|
+
if (viewsConfigType === 'ViewsService' || viewsConfigType === 'WorkbenchService') {
|
|
96
|
+
if (this.apiConfig.$type === 'classic') {
|
|
97
|
+
this.performErrorHandling(`View Service Type "${viewsConfigType}" cannot be used with classic configuration.`);
|
|
98
|
+
}
|
|
99
|
+
if (this.apiConfig.viewsConfig.htmlContainer === undefined) {
|
|
100
|
+
this.performErrorHandling(`View Service Type "${viewsConfigType}" requires a HTMLElement.`);
|
|
101
|
+
}
|
|
53
102
|
}
|
|
54
103
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
104
|
+
const envEnhanced = getEnhancedMonacoEnvironment();
|
|
105
|
+
if (viewsConfigType === 'ViewsService') {
|
|
106
|
+
const getViewsServiceOverride = (await import('@codingame/monaco-vscode-views-service-override')).default;
|
|
107
|
+
mergeServices(this.apiConfig.serviceOverrides, {
|
|
108
|
+
...getViewsServiceOverride(this.apiConfig.viewsConfig.openEditorFunc ?? useOpenEditorStub)
|
|
109
|
+
});
|
|
110
|
+
envEnhanced.viewServiceType = 'ViewsService';
|
|
111
|
+
} else if (viewsConfigType === 'WorkbenchService') {
|
|
112
|
+
const getWorkbenchServiceOverride = (await import('@codingame/monaco-vscode-workbench-service-override')).default;
|
|
113
|
+
mergeServices(this.apiConfig.serviceOverrides, {
|
|
114
|
+
...getWorkbenchServiceOverride()
|
|
115
|
+
});
|
|
116
|
+
envEnhanced.viewServiceType = 'WorkbenchService';
|
|
117
|
+
} else {
|
|
118
|
+
const getEditorServiceOverride = (await import('@codingame/monaco-vscode-editor-service-override')).default;
|
|
119
|
+
mergeServices(this.apiConfig.serviceOverrides, {
|
|
120
|
+
...getEditorServiceOverride(this.apiConfig.viewsConfig.openEditorFunc ?? useOpenEditorStub)
|
|
121
|
+
});
|
|
122
|
+
envEnhanced.viewServiceType = 'EditorService';
|
|
63
123
|
}
|
|
124
|
+
}
|
|
64
125
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
protected async configureHighlightingServices() {
|
|
71
|
-
if (this.apiConfig.$type === 'extended') {
|
|
72
|
-
const getTextmateServiceOverride = (await import('@codingame/monaco-vscode-textmate-service-override')).default;
|
|
73
|
-
const getThemeServiceOverride = (await import('@codingame/monaco-vscode-theme-service-override')).default;
|
|
74
|
-
const getLanguagesServiceOverride = (await import('@codingame/monaco-vscode-languages-service-override')).default;
|
|
75
|
-
mergeServices(this.apiConfig.serviceOverrides, {
|
|
76
|
-
...getLanguagesServiceOverride(),
|
|
77
|
-
...getTextmateServiceOverride(),
|
|
78
|
-
...getThemeServiceOverride()
|
|
79
|
-
});
|
|
80
|
-
} else {
|
|
81
|
-
const getMonarchServiceOverride = (await import('@codingame/monaco-vscode-monarch-service-override')).default;
|
|
82
|
-
mergeServices(this.apiConfig.serviceOverrides, {
|
|
83
|
-
...getMonarchServiceOverride()
|
|
84
|
-
});
|
|
85
|
-
}
|
|
126
|
+
protected async applyViewsPostConfig() {
|
|
127
|
+
const viewsConfigType = this.apiConfig.viewsConfig.$type;
|
|
128
|
+
if (viewsConfigType === 'ViewsService' || viewsConfigType === 'WorkbenchService') {
|
|
129
|
+
this.apiConfig.viewsConfig.htmlAugmentationInstructions?.(this.apiConfig.viewsConfig.htmlContainer);
|
|
130
|
+
await this.apiConfig.viewsConfig.viewsInitFunc?.();
|
|
86
131
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
mergeServices(this.apiConfig.serviceOverrides, {
|
|
103
|
-
...getViewsServiceOverride(this.apiConfig.viewsConfig.openEditorFunc ?? useOpenEditorStub)
|
|
104
|
-
});
|
|
105
|
-
envEnhanced.viewServiceType = 'ViewsService';
|
|
106
|
-
} else if (viewsConfigType === 'WorkbenchService') {
|
|
107
|
-
const getWorkbenchServiceOverride = (await import('@codingame/monaco-vscode-workbench-service-override')).default;
|
|
108
|
-
mergeServices(this.apiConfig.serviceOverrides, {
|
|
109
|
-
...getWorkbenchServiceOverride()
|
|
110
|
-
});
|
|
111
|
-
envEnhanced.viewServiceType = 'WorkbenchService';
|
|
112
|
-
} else {
|
|
113
|
-
const getEditorServiceOverride = (await import('@codingame/monaco-vscode-editor-service-override')).default;
|
|
114
|
-
mergeServices(this.apiConfig.serviceOverrides, {
|
|
115
|
-
...getEditorServiceOverride(this.apiConfig.viewsConfig.openEditorFunc ?? useOpenEditorStub)
|
|
116
|
-
});
|
|
117
|
-
envEnhanced.viewServiceType = 'EditorService';
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
protected async applyViewsPostConfig() {
|
|
122
|
-
const viewsConfigType = this.apiConfig.viewsConfig.$type;
|
|
123
|
-
if (viewsConfigType === 'ViewsService' || viewsConfigType === 'WorkbenchService') {
|
|
124
|
-
this.apiConfig.viewsConfig.htmlAugmentationInstructions?.(this.apiConfig.viewsConfig.htmlContainer);
|
|
125
|
-
await this.apiConfig.viewsConfig.viewsInitFunc?.();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Adding the default workspace config if not provided
|
|
136
|
+
*/
|
|
137
|
+
protected configureWorkspaceConfig() {
|
|
138
|
+
this.apiConfig.workspaceConfig ??= {
|
|
139
|
+
workspaceProvider: {
|
|
140
|
+
trusted: true,
|
|
141
|
+
workspace: {
|
|
142
|
+
workspaceUri: vscode.Uri.file('/workspace.code-workspace')
|
|
143
|
+
},
|
|
144
|
+
async open() {
|
|
145
|
+
window.open(window.location.href);
|
|
146
|
+
return true;
|
|
126
147
|
}
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Set the log-level via the development settings.
|
|
154
|
+
* VSCode developmentOptions are read-only. There are no functions exposed to set options directly.
|
|
155
|
+
* Therefore the Object properties need to be manipulated directly via Object.assign.
|
|
156
|
+
*/
|
|
157
|
+
protected configureDevLogLevel() {
|
|
158
|
+
const devLogLevel = this.apiConfig.workspaceConfig?.developmentOptions?.logLevel;
|
|
159
|
+
if (devLogLevel === undefined) {
|
|
160
|
+
const devOptions: Record<string, unknown> = {
|
|
161
|
+
...this.apiConfig.workspaceConfig!.developmentOptions
|
|
162
|
+
};
|
|
163
|
+
devOptions.logLevel = this.apiConfig.logLevel;
|
|
164
|
+
(this.apiConfig.workspaceConfig!.developmentOptions as Record<string, unknown>) = Object.assign({}, devOptions);
|
|
165
|
+
} else if (devLogLevel !== this.apiConfig.logLevel) {
|
|
166
|
+
this.performErrorHandling(
|
|
167
|
+
`You have configured mismatching logLevels: ${this.apiConfig.logLevel} (wrapperConfig) ${devLogLevel} (workspaceConfig.developmentOptions)`
|
|
168
|
+
);
|
|
169
|
+
} else {
|
|
170
|
+
this.logger.debug('Development log level and api log level are in aligned.');
|
|
127
171
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
async open() {
|
|
141
|
-
window.open(window.location.href);
|
|
142
|
-
return true;
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
};
|
|
146
|
-
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* enable semantic highlighting in the default configuration
|
|
176
|
+
*/
|
|
177
|
+
protected configureSemanticHighlighting() {
|
|
178
|
+
if (this.apiConfig.advanced?.enforceSemanticHighlighting === true) {
|
|
179
|
+
const configDefaults: Record<string, unknown> = {
|
|
180
|
+
...(this.apiConfig.workspaceConfig!.configurationDefaults ?? {})
|
|
181
|
+
};
|
|
182
|
+
configDefaults['editor.semanticHighlighting.enabled'] = true;
|
|
183
|
+
(this.apiConfig.workspaceConfig!.configurationDefaults as Record<string, unknown>) = Object.assign({}, configDefaults);
|
|
147
184
|
}
|
|
185
|
+
}
|
|
148
186
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
* Therefore the Object properties need to be manipulated directly via Object.assign.
|
|
153
|
-
*/
|
|
154
|
-
protected configureDevLogLevel() {
|
|
155
|
-
const devLogLevel = this.apiConfig.workspaceConfig?.developmentOptions?.logLevel;
|
|
156
|
-
if (devLogLevel === undefined) {
|
|
157
|
-
const devOptions: Record<string, unknown> = {
|
|
158
|
-
...this.apiConfig.workspaceConfig!.developmentOptions
|
|
159
|
-
};
|
|
160
|
-
devOptions.logLevel = this.apiConfig.logLevel;
|
|
161
|
-
(this.apiConfig.workspaceConfig!.developmentOptions as Record<string, unknown>) = Object.assign({}, devOptions);
|
|
162
|
-
} else if (devLogLevel !== this.apiConfig.logLevel) {
|
|
163
|
-
this.performErrorHandling(`You have configured mismatching logLevels: ${this.apiConfig.logLevel} (wrapperConfig) ${devLogLevel} (workspaceConfig.developmentOptions)`);
|
|
164
|
-
} else {
|
|
165
|
-
this.logger.debug('Development log level and api log level are in aligned.');
|
|
166
|
-
}
|
|
187
|
+
protected async initUserConfiguration() {
|
|
188
|
+
if (this.apiConfig.userConfiguration?.json !== undefined) {
|
|
189
|
+
await initUserConfiguration(this.apiConfig.userConfiguration.json);
|
|
167
190
|
}
|
|
191
|
+
}
|
|
168
192
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
193
|
+
protected async supplyRequiredServices() {
|
|
194
|
+
return {
|
|
195
|
+
...getConfigurationServiceOverride(),
|
|
196
|
+
...getLogServiceOverride(),
|
|
197
|
+
...getModelServiceOverride()
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
protected checkServiceConsistency() {
|
|
202
|
+
const userServices = this.apiConfig.serviceOverrides;
|
|
203
|
+
const haveThemeService = Object.keys(userServices).includes('themeService');
|
|
204
|
+
const haveTextmateService = Object.keys(userServices).includes('textMateTokenizationFeature');
|
|
205
|
+
const haveMarkersService = Object.keys(userServices).includes('markersService');
|
|
206
|
+
const haveViewsService = Object.keys(userServices).includes('viewsService');
|
|
207
|
+
|
|
208
|
+
// theme requires textmate
|
|
209
|
+
if (haveThemeService && !haveTextmateService) {
|
|
210
|
+
this.performErrorHandling('"theme" service requires "textmate" service. Please add it to the "userServices".');
|
|
180
211
|
}
|
|
181
212
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
213
|
+
// markers service requires views service
|
|
214
|
+
if (haveMarkersService && !haveViewsService) {
|
|
215
|
+
this.performErrorHandling('"markers" service requires "views" service. Please add it to the "userServices".');
|
|
186
216
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* monaco-vscode-api automatically loads the following services:
|
|
221
|
+
* - layout
|
|
222
|
+
* - environment
|
|
223
|
+
* - extension
|
|
224
|
+
* - files
|
|
225
|
+
* - quickAccess
|
|
226
|
+
* monaco-languageclient always adds the following services:
|
|
227
|
+
* - languages
|
|
228
|
+
* - log
|
|
229
|
+
* - model
|
|
230
|
+
* - configuration services
|
|
231
|
+
*/
|
|
232
|
+
protected async initAllServices(performServiceConsistencyChecks?: boolean) {
|
|
233
|
+
const services = await this.supplyRequiredServices();
|
|
234
|
+
|
|
235
|
+
mergeServices(services, this.apiConfig.serviceOverrides);
|
|
236
|
+
if (this.apiConfig.advanced?.loadExtensionServices === undefined ? true : this.apiConfig.advanced.loadExtensionServices === true) {
|
|
237
|
+
const { default: getExtensionServiceOverride } = await import('@codingame/monaco-vscode-extensions-service-override');
|
|
238
|
+
mergeServices(services, {
|
|
239
|
+
...getExtensionServiceOverride({
|
|
240
|
+
enableWorkerExtensionHost: this.apiConfig.advanced?.enableExtHostWorker === true
|
|
241
|
+
})
|
|
242
|
+
});
|
|
194
243
|
}
|
|
195
244
|
|
|
196
|
-
|
|
197
|
-
const userServices = this.apiConfig.serviceOverrides;
|
|
198
|
-
const haveThemeService = Object.keys(userServices).includes('themeService');
|
|
199
|
-
const haveTextmateService = Object.keys(userServices).includes('textMateTokenizationFeature');
|
|
200
|
-
const haveMarkersService = Object.keys(userServices).includes('markersService');
|
|
201
|
-
const haveViewsService = Object.keys(userServices).includes('viewsService');
|
|
202
|
-
|
|
203
|
-
// theme requires textmate
|
|
204
|
-
if (haveThemeService && !haveTextmateService) {
|
|
205
|
-
this.performErrorHandling('"theme" service requires "textmate" service. Please add it to the "userServices".');
|
|
206
|
-
}
|
|
245
|
+
reportServiceLoading(services, this.logger);
|
|
207
246
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
this.performErrorHandling('"markers" service requires "views" service. Please add it to the "userServices".');
|
|
211
|
-
}
|
|
247
|
+
if (performServiceConsistencyChecks ?? true) {
|
|
248
|
+
this.checkServiceConsistency();
|
|
212
249
|
}
|
|
213
250
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
* - extension
|
|
219
|
-
* - files
|
|
220
|
-
* - quickAccess
|
|
221
|
-
* monaco-languageclient always adds the following services:
|
|
222
|
-
* - languages
|
|
223
|
-
* - log
|
|
224
|
-
* - model
|
|
225
|
-
* - configuration services
|
|
226
|
-
*/
|
|
227
|
-
protected async initAllServices(performServiceConsistencyChecks?: boolean) {
|
|
228
|
-
const services = await this.supplyRequiredServices();
|
|
229
|
-
|
|
230
|
-
mergeServices(services, this.apiConfig.serviceOverrides);
|
|
231
|
-
if (this.apiConfig.advanced?.loadExtensionServices === undefined ? true : this.apiConfig.advanced.loadExtensionServices === true) {
|
|
232
|
-
const { default: getExtensionServiceOverride } = await import('@codingame/monaco-vscode-extensions-service-override');
|
|
233
|
-
mergeServices(services, {
|
|
234
|
-
...getExtensionServiceOverride({
|
|
235
|
-
enableWorkerExtensionHost: this.apiConfig.advanced?.enableExtHostWorker === true
|
|
236
|
-
})
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
reportServiceLoading(services, this.logger);
|
|
241
|
-
|
|
242
|
-
if (performServiceConsistencyChecks ?? true) {
|
|
243
|
-
this.checkServiceConsistency();
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (this.apiConfig.viewsConfig.$type === 'ViewsService' || this.apiConfig.viewsConfig.$type === 'WorkbenchService') {
|
|
247
|
-
await initialize(services, this.apiConfig.viewsConfig.htmlContainer, this.apiConfig.workspaceConfig, this.apiConfig.envOptions);
|
|
248
|
-
} else {
|
|
249
|
-
await initialize(services, undefined, this.apiConfig.workspaceConfig, this.apiConfig.envOptions);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
setUnexpectedErrorHandler((e) => {
|
|
253
|
-
const message = 'Unexpected error';
|
|
254
|
-
if (this.logger.getLevel() !== LogLevel.Off) {
|
|
255
|
-
this.logger.error(message, e);
|
|
256
|
-
}
|
|
257
|
-
});
|
|
251
|
+
if (this.apiConfig.viewsConfig.$type === 'ViewsService' || this.apiConfig.viewsConfig.$type === 'WorkbenchService') {
|
|
252
|
+
await initialize(services, this.apiConfig.viewsConfig.htmlContainer, this.apiConfig.workspaceConfig, this.apiConfig.envOptions);
|
|
253
|
+
} else {
|
|
254
|
+
await initialize(services, undefined, this.apiConfig.workspaceConfig, this.apiConfig.envOptions);
|
|
258
255
|
}
|
|
259
256
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
allPromises.push(this.initExtension(extensionConfig, extensionIds));
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
await Promise.all(allPromises);
|
|
278
|
-
}
|
|
257
|
+
setUnexpectedErrorHandler((e) => {
|
|
258
|
+
const message = 'Unexpected error';
|
|
259
|
+
if (this.logger.getLevel() !== LogLevel.Off) {
|
|
260
|
+
this.logger.error(message, e);
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
async initExtensions(): Promise<void> {
|
|
266
|
+
if (
|
|
267
|
+
this.apiConfig.$type === 'extended' &&
|
|
268
|
+
(this.apiConfig.advanced?.loadThemes === undefined ? true : this.apiConfig.advanced.loadThemes === true)
|
|
269
|
+
) {
|
|
270
|
+
await import('@codingame/monaco-vscode-theme-defaults-default-extension');
|
|
279
271
|
}
|
|
280
272
|
|
|
281
|
-
|
|
273
|
+
const extensions = this.apiConfig.extensions;
|
|
274
|
+
if (this.apiConfig.extensions !== undefined && this.apiConfig.extensions.length > 0) {
|
|
275
|
+
const allPromises: Array<Promise<void>> = [];
|
|
276
|
+
const extensionIds: string[] = [];
|
|
277
|
+
getBuiltinExtensions().forEach((ext) => {
|
|
278
|
+
extensionIds.push(ext.identifier.id);
|
|
279
|
+
});
|
|
280
|
+
for (const extensionConfig of extensions ?? []) {
|
|
282
281
|
if (!extensionIds.includes(`${extensionConfig.config.publisher}.${extensionConfig.config.name}`)) {
|
|
283
|
-
|
|
284
|
-
const extRegResult = registerExtension(manifest, ExtensionHostKind.LocalProcess);
|
|
285
|
-
this.extensionRegisterResults.set(manifest.name, extRegResult);
|
|
286
|
-
if (extensionConfig.filesOrContents && Object.hasOwn(extRegResult, 'registerFileUrl')) {
|
|
287
|
-
for (const entry of extensionConfig.filesOrContents) {
|
|
288
|
-
this.disposableStore.add(extRegResult.registerFileUrl(entry[0], encodeStringOrUrlToDataUrl(entry[1])));
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
return extRegResult.whenReady();
|
|
292
|
-
} else {
|
|
293
|
-
return Promise.resolve();
|
|
282
|
+
allPromises.push(this.initExtension(extensionConfig, extensionIds));
|
|
294
283
|
}
|
|
284
|
+
}
|
|
285
|
+
await Promise.all(allPromises);
|
|
295
286
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
protected initExtension(extensionConfig: ExtensionConfig, extensionIds: string[]): Promise<void> {
|
|
290
|
+
if (!extensionIds.includes(`${extensionConfig.config.publisher}.${extensionConfig.config.name}`)) {
|
|
291
|
+
const manifest = extensionConfig.config as IExtensionManifest;
|
|
292
|
+
const extRegResult = registerExtension(manifest, ExtensionHostKind.LocalProcess);
|
|
293
|
+
this.extensionRegisterResults.set(manifest.name, extRegResult);
|
|
294
|
+
if (extensionConfig.filesOrContents !== undefined && Object.hasOwn(extRegResult, 'registerFileUrl')) {
|
|
295
|
+
for (const entry of extensionConfig.filesOrContents) {
|
|
296
|
+
this.disposableStore.add(extRegResult.registerFileUrl(entry[0], encodeStringOrUrlToDataUrl(entry[1])));
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return extRegResult.whenReady();
|
|
300
|
+
} else {
|
|
301
|
+
return Promise.resolve();
|
|
304
302
|
}
|
|
303
|
+
}
|
|
305
304
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
envEnhanced.vscodeApiGlobalInitResolve?.();
|
|
305
|
+
protected markGlobalInit() {
|
|
306
|
+
this.logger.debug('markGlobalInit');
|
|
309
307
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
308
|
+
const envEnhanced = getEnhancedMonacoEnvironment();
|
|
309
|
+
envEnhanced.vscodeApiGlobalInitAwait = new Promise<void>((resolve) => {
|
|
310
|
+
envEnhanced.vscodeApiGlobalInitResolve = resolve;
|
|
311
|
+
});
|
|
312
|
+
}
|
|
315
313
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
this.logger.warn('Initialization of monaco-vscode api can only performed once!');
|
|
320
|
-
} else {
|
|
321
|
-
if (!(envEnhanced.vscodeApiInitialising === true)) {
|
|
314
|
+
protected markGlobalInitDone() {
|
|
315
|
+
const envEnhanced = getEnhancedMonacoEnvironment();
|
|
316
|
+
envEnhanced.vscodeApiGlobalInitResolve?.();
|
|
322
317
|
|
|
323
|
-
|
|
324
|
-
|
|
318
|
+
envEnhanced.vscodeApiInitialised = true;
|
|
319
|
+
envEnhanced.vscodeApiGlobalInitAwait = undefined;
|
|
320
|
+
envEnhanced.vscodeApiGlobalInitResolve = undefined;
|
|
321
|
+
this.logger.debug('markGlobalInitDone');
|
|
322
|
+
}
|
|
325
323
|
|
|
326
|
-
|
|
327
|
-
|
|
324
|
+
async start(startInstructions?: StartInstructions): Promise<void> {
|
|
325
|
+
const envEnhanced = getEnhancedMonacoEnvironment();
|
|
326
|
+
if (envEnhanced.vscodeApiInitialised === true) {
|
|
327
|
+
this.logger.warn('Initialization of monaco-vscode api can only performed once!');
|
|
328
|
+
} else {
|
|
329
|
+
if (!(envEnhanced.vscodeApiInitialising === true)) {
|
|
330
|
+
envEnhanced.vscodeApiInitialising = true;
|
|
331
|
+
this.markGlobalInit();
|
|
328
332
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
this.logger.info(`Initializing monaco-vscode api. Caller: ${startInstructions?.caller ?? 'unknown'}`);
|
|
333
|
+
// ensures "vscodeApiConfig.workspaceConfig" is available
|
|
334
|
+
this.configureWorkspaceConfig();
|
|
332
335
|
|
|
333
|
-
|
|
336
|
+
// ensure logging and development logging options are in-line
|
|
337
|
+
this.configureDevLogLevel();
|
|
338
|
+
this.logger.info(`Initializing monaco-vscode api. Caller: ${startInstructions?.caller ?? 'unknown'}`);
|
|
334
339
|
|
|
335
|
-
|
|
336
|
-
await this.configureHighlightingServices();
|
|
340
|
+
this.configureMonacoWorkers();
|
|
337
341
|
|
|
338
|
-
|
|
339
|
-
|
|
342
|
+
// ensure either classic (monarch) or textmate (extended) highlighting is used
|
|
343
|
+
await this.configureHighlightingServices();
|
|
340
344
|
|
|
341
|
-
|
|
342
|
-
|
|
345
|
+
// ensure one of the three potential view services are configured
|
|
346
|
+
await this.configureViewsServices();
|
|
343
347
|
|
|
344
|
-
|
|
348
|
+
// enforce semantic highlighting if configured
|
|
349
|
+
this.configureSemanticHighlighting();
|
|
345
350
|
|
|
346
|
-
|
|
351
|
+
await this.initUserConfiguration();
|
|
347
352
|
|
|
348
|
-
|
|
353
|
+
await this.initAllServices(startInstructions?.performServiceConsistencyChecks);
|
|
349
354
|
|
|
350
|
-
|
|
355
|
+
await this.applyViewsPostConfig();
|
|
351
356
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
357
|
+
await this.initExtensions();
|
|
358
|
+
|
|
359
|
+
this.markGlobalInitDone();
|
|
360
|
+
this.logger.debug('Initialization of monaco-vscode api completed successfully.');
|
|
361
|
+
} else {
|
|
362
|
+
this.logger.debug('Initialization of monaco-vscode api is already ongoing.');
|
|
363
|
+
}
|
|
358
364
|
}
|
|
365
|
+
}
|
|
359
366
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
367
|
+
dispose() {
|
|
368
|
+
this.extensionRegisterResults.forEach((k) => k.dispose());
|
|
369
|
+
this.disposableStore.dispose();
|
|
363
370
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
371
|
+
// re-create disposable stores
|
|
372
|
+
this.disposableStore = new DisposableStore();
|
|
373
|
+
}
|
|
367
374
|
}
|