@typefox/monaco-editor-react 7.3.0-next.2 → 7.3.0-next.4
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 +3 -3
- package/lib/index.d.ts +5 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +175 -127
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +185 -148
package/CHANGELOG.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to npm module [@typefox/monaco-editor-react](https://www.npmjs.com/package/@typefox/monaco-editor-react) are documented in this file.
|
|
4
4
|
|
|
5
|
-
## [7.3.0-next.
|
|
5
|
+
## [7.3.0-next.4] - 2025-11-13
|
|
6
6
|
|
|
7
7
|
- Fixed re-rendering issues with React StrictMode [#986](https://github.com/TypeFox/monaco-languageclient/pull/986).
|
|
8
|
-
- Updated to `monaco-languageclient@10.3.0-next.
|
|
9
|
-
- Updated all `@codingame/monaco-vscode` packages to `22.1.
|
|
8
|
+
- Updated to `monaco-languageclient@10.3.0-next.4`.
|
|
9
|
+
- Updated all `@codingame/monaco-vscode` packages to `22.1.9`.
|
|
10
10
|
|
|
11
11
|
## [7.2.0] - 2025-10-20
|
|
12
12
|
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LogLevel } from '@codingame/monaco-vscode-api';
|
|
1
2
|
import { EditorApp, type EditorAppConfig, type TextContents } from 'monaco-languageclient/editorApp';
|
|
2
3
|
import { type LanguageClientConfig, LanguageClientManager } from 'monaco-languageclient/lcwrapper';
|
|
3
4
|
import { type MonacoVscodeApiConfig, MonacoVscodeApiWrapper } from 'monaco-languageclient/vscodeApiWrapper';
|
|
@@ -6,19 +7,18 @@ export type ResolveFc = (value: void | PromiseLike<void>) => void;
|
|
|
6
7
|
export type MonacoEditorProps = {
|
|
7
8
|
style?: CSSProperties;
|
|
8
9
|
className?: string;
|
|
9
|
-
vscodeApiConfig
|
|
10
|
+
vscodeApiConfig?: MonacoVscodeApiConfig;
|
|
10
11
|
editorAppConfig?: EditorAppConfig;
|
|
11
12
|
languageClientConfig?: LanguageClientConfig;
|
|
12
|
-
enforceDisposeLanguageClient?: boolean;
|
|
13
13
|
onVscodeApiInitDone?: (monacoVscodeApiManager: MonacoVscodeApiWrapper) => void;
|
|
14
14
|
onEditorStartDone?: (editorApp?: EditorApp) => void;
|
|
15
|
-
onLanguageClientsStartDone?: (lcsManager
|
|
15
|
+
onLanguageClientsStartDone?: (lcsManager: LanguageClientManager) => void;
|
|
16
16
|
onTextChanged?: (textChanges: TextContents) => void;
|
|
17
|
+
onConfigProcessed?: (editorApp?: EditorApp) => void;
|
|
17
18
|
onError?: (error: Error) => void;
|
|
18
19
|
onDisposeEditor?: () => void;
|
|
19
20
|
onDisposeLanguageClient?: () => void;
|
|
20
|
-
|
|
21
|
-
originalTextValue?: string;
|
|
21
|
+
logLevel?: LogLevel | number;
|
|
22
22
|
};
|
|
23
23
|
export declare const MonacoEditorReactComp: React.FC<MonacoEditorProps>;
|
|
24
24
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACrG,OAAO,EAAE,KAAK,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACnG,OAAO,EAAgC,KAAK,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAC1I,OAAO,KAAK,EAAE,EAAE,KAAK,aAAa,EAAqB,MAAM,OAAO,CAAC;AAErE,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,KAA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,CAAC,EAAE,SAAS,KAAK,IAAI,CAAC;IACpD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,uBAAuB,CAAC,EAAE,MAAM,IAAI,CAAC;IACrC,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;CAChC,CAAA;AAwED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA8O7D,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
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 { LogLevel } from '@codingame/monaco-vscode-api';
|
|
6
|
+
import * as monaco from '@codingame/monaco-vscode-editor-api';
|
|
7
|
+
import { ConsoleLogger } from 'monaco-languageclient/common';
|
|
5
8
|
import { EditorApp } from 'monaco-languageclient/editorApp';
|
|
6
9
|
import { LanguageClientManager } from 'monaco-languageclient/lcwrapper';
|
|
7
10
|
import { getEnhancedMonacoEnvironment, MonacoVscodeApiWrapper } from 'monaco-languageclient/vscodeApiWrapper';
|
|
@@ -12,56 +15,73 @@ const lcsManager = new LanguageClientManager();
|
|
|
12
15
|
const haveEditorService = () => {
|
|
13
16
|
return getEnhancedMonacoEnvironment().viewServiceType === 'EditorService';
|
|
14
17
|
};
|
|
18
|
+
const logger = new ConsoleLogger(LogLevel.Debug);
|
|
15
19
|
const runQueue = [];
|
|
16
|
-
let
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
debugLogging(`QUEUE SIZE before: ${runQueue.length}`);
|
|
29
|
-
runQueue.push({ id, func });
|
|
30
|
-
};
|
|
31
|
-
const triggerQueue = () => {
|
|
32
|
-
setInterval(() => {
|
|
33
|
-
if (queueAwait === undefined) {
|
|
34
|
-
queueAwait = new Promise((resolve) => {
|
|
35
|
-
queueResolve = resolve;
|
|
36
|
-
});
|
|
37
|
-
executeQueue();
|
|
38
|
-
}
|
|
39
|
-
}, 50);
|
|
40
|
-
};
|
|
41
|
-
const executeQueue = async () => {
|
|
20
|
+
let queueLock = true;
|
|
21
|
+
let intervalId = undefined;
|
|
22
|
+
const addQueue = (id, func) => {
|
|
23
|
+
debugLogging('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
|
|
24
|
+
debugLogging(`Adding to queue: ${id}: QUEUE SIZE before: ${runQueue.length}`);
|
|
25
|
+
runQueue.push({ id, func });
|
|
26
|
+
kickQueue();
|
|
27
|
+
};
|
|
28
|
+
const executeQueue = async () => {
|
|
29
|
+
console.log(`Queue size: ${runQueue.length}`);
|
|
30
|
+
if (runQueue.length > 0) {
|
|
31
|
+
queueLock = true;
|
|
42
32
|
while (runQueue.length > 0) {
|
|
33
|
+
const lengthBefore = runQueue.length;
|
|
43
34
|
const queueObj = runQueue.shift();
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
await queueObj
|
|
48
|
-
debugLogging(`QUEUE ${queueObj.id} SIZE after: ${runQueue.length}`);
|
|
49
|
-
debugLogging(`QUEUE ${queueObj.id} end`);
|
|
35
|
+
debugLogging('<<<<<<<<<<<<<<<<<<<<<<<<<<<<<');
|
|
36
|
+
debugLogging(`QUEUE ${queueObj?.id} start: SIZE before: ${lengthBefore}`, true);
|
|
37
|
+
try {
|
|
38
|
+
await queueObj?.func();
|
|
50
39
|
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
queueLock = false;
|
|
42
|
+
debugLogging(`QUEUE ${queueObj?.id} ERROR: SIZE after: ${runQueue.length}`);
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
debugLogging(`QUEUE ${queueObj?.id} end: SIZE after: ${runQueue.length}`);
|
|
51
46
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
47
|
+
queueLock = false;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const kickQueue = () => {
|
|
51
|
+
if (intervalId === undefined && runQueue.length > 0) {
|
|
52
|
+
intervalId = setInterval(async () => {
|
|
53
|
+
debugLogging('Checking queue...' + queueLock);
|
|
54
|
+
if (!queueLock) {
|
|
55
|
+
await executeQueue();
|
|
56
|
+
stopQueue();
|
|
57
|
+
}
|
|
58
|
+
}, 50);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const stopQueue = () => {
|
|
62
|
+
if (intervalId !== undefined && runQueue.length === 0) {
|
|
63
|
+
debugLogging('Stopping queue...');
|
|
64
|
+
clearInterval(intervalId);
|
|
65
|
+
intervalId = undefined;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const debugLogging = (id, useTime) => {
|
|
69
|
+
if (useTime === true) {
|
|
70
|
+
logger.debug(`${id}: ${Date.now()}`);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
logger.debug(id);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
export const MonacoEditorReactComp = (props) => {
|
|
77
|
+
const { style, className, vscodeApiConfig, editorAppConfig, languageClientConfig, onVscodeApiInitDone, onEditorStartDone, onLanguageClientsStartDone, onTextChanged, onConfigProcessed, onError, onDisposeEditor, onDisposeLanguageClient, logLevel } = props;
|
|
78
|
+
const editorAppRef = useRef(undefined);
|
|
79
|
+
const containerRef = useRef(null);
|
|
80
|
+
const onTextChangedRef = useRef(onTextChanged);
|
|
81
|
+
const launchingRef = useRef(false);
|
|
82
|
+
const editorAppConfigRef = useRef(undefined);
|
|
64
83
|
const performErrorHandling = (error) => {
|
|
84
|
+
debugLogging(`ERROR: ${error.message}`, true);
|
|
65
85
|
if (onError) {
|
|
66
86
|
onError(error);
|
|
67
87
|
}
|
|
@@ -69,25 +89,15 @@ export const MonacoEditorReactComp = (props) => {
|
|
|
69
89
|
throw error;
|
|
70
90
|
}
|
|
71
91
|
};
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
// this is only available if EditorService is configured
|
|
74
|
-
if (haveEditorService() && modifiedTextValue !== undefined) {
|
|
75
|
-
modifiedCode.current = modifiedTextValue;
|
|
76
|
-
editorAppRef.current?.updateCode({ modified: modifiedTextValue });
|
|
77
|
-
}
|
|
78
|
-
}, [modifiedTextValue]);
|
|
79
|
-
useEffect(() => {
|
|
80
|
-
// this is only available if EditorService is configured
|
|
81
|
-
if (haveEditorService() && originalTextValue !== undefined) {
|
|
82
|
-
originalCode.current = originalTextValue;
|
|
83
|
-
editorAppRef.current?.updateCode({ original: originalTextValue });
|
|
84
|
-
}
|
|
85
|
-
}, [originalTextValue]);
|
|
86
92
|
const performGlobalInit = async () => {
|
|
87
93
|
if (containerRef.current === null) {
|
|
88
94
|
performErrorHandling(new Error('No htmlContainer found! Aborting...'));
|
|
89
95
|
}
|
|
90
96
|
const envEnhanced = getEnhancedMonacoEnvironment();
|
|
97
|
+
// let apiConfig: MonacoVscodeApiConfig;
|
|
98
|
+
if (vscodeApiConfig === undefined && envEnhanced.vscodeApiInitialised !== true) {
|
|
99
|
+
throw new Error('vscodeApiConfig is not provided, but the monaco-vscode-api is not initialized! Aborting...');
|
|
100
|
+
}
|
|
91
101
|
// init will only performed once
|
|
92
102
|
if (envEnhanced.vscodeApiInitialising !== true) {
|
|
93
103
|
apiWrapper = new MonacoVscodeApiWrapper(vscodeApiConfig);
|
|
@@ -103,10 +113,9 @@ export const MonacoEditorReactComp = (props) => {
|
|
|
103
113
|
});
|
|
104
114
|
}
|
|
105
115
|
await apiWrapper.start();
|
|
106
|
-
lcsManager.setLogger(apiWrapper.getLogger());
|
|
107
116
|
onVscodeApiInitDone?.(apiWrapper);
|
|
108
|
-
triggerQueue();
|
|
109
117
|
debugLogging('GLOBAL INIT DONE', true);
|
|
118
|
+
queueLock = false;
|
|
110
119
|
}
|
|
111
120
|
catch (error) {
|
|
112
121
|
performErrorHandling(error);
|
|
@@ -114,28 +123,16 @@ export const MonacoEditorReactComp = (props) => {
|
|
|
114
123
|
};
|
|
115
124
|
globalInitFunc();
|
|
116
125
|
}
|
|
117
|
-
else if (envEnhanced.vscodeApiInitialised === true) {
|
|
118
|
-
triggerQueue();
|
|
119
|
-
}
|
|
120
126
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const recreateEditor = editorAppRef.current === undefined || currentEditorConfig.current === undefined ||
|
|
129
|
-
JSON.stringify(editorAppConfig) !== JSON.stringify(currentEditorConfig.current);
|
|
130
|
-
const editorInitFunc = async () => {
|
|
131
|
-
try {
|
|
132
|
-
debugLogging('INIT', true);
|
|
133
|
-
// it is possible to run without an editorApp, for example when using the ViewsService
|
|
134
|
-
if (recreateEditor && haveEditorService()) {
|
|
127
|
+
const editorInitFunc = async () => {
|
|
128
|
+
try {
|
|
129
|
+
debugLogging('INIT EDITOR', true);
|
|
130
|
+
// it is possible to run without an editorApp, when the ViewsService or WorkbenchService
|
|
131
|
+
if (haveEditorService()) {
|
|
132
|
+
if (editorAppRef.current === undefined && !launchingRef.current) {
|
|
133
|
+
launchingRef.current = true;
|
|
135
134
|
debugLogging('INIT: Creating editor', true);
|
|
136
|
-
|
|
137
|
-
currentEditorConfig.current = editorAppConfig;
|
|
138
|
-
editorAppRef.current = new EditorApp(editorAppConfig);
|
|
135
|
+
editorAppRef.current = new EditorApp(editorAppConfigRef.current);
|
|
139
136
|
if (editorAppRef.current.isStarting() === true || editorAppRef.current.isDisposing() === true) {
|
|
140
137
|
await Promise.all([
|
|
141
138
|
editorAppRef.current.getStartingAwait(),
|
|
@@ -143,51 +140,110 @@ export const MonacoEditorReactComp = (props) => {
|
|
|
143
140
|
]);
|
|
144
141
|
}
|
|
145
142
|
editorAppRef.current.registerOnTextChangedCallback((textChanges) => {
|
|
146
|
-
if (textChanges.modified !== undefined) {
|
|
147
|
-
modifiedCode.current = textChanges.modified;
|
|
148
|
-
}
|
|
149
|
-
if (textChanges.original !== undefined) {
|
|
150
|
-
originalCode.current = textChanges.original;
|
|
151
|
-
}
|
|
152
143
|
if (onTextChangedRef.current !== undefined) {
|
|
153
144
|
onTextChangedRef.current(textChanges);
|
|
154
145
|
}
|
|
155
146
|
});
|
|
156
147
|
await editorAppRef.current.start(containerRef.current);
|
|
157
148
|
onEditorStartDone?.(editorAppRef.current);
|
|
149
|
+
launchingRef.current = false;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
debugLogging('INIT EDITOR: Editor already created', true);
|
|
158
153
|
}
|
|
159
|
-
debugLogging('INIT DONE', true);
|
|
160
154
|
}
|
|
161
|
-
|
|
162
|
-
|
|
155
|
+
else {
|
|
156
|
+
debugLogging('INIT EDITOR: Do nothing: Using ViewsService', true);
|
|
163
157
|
}
|
|
164
|
-
|
|
158
|
+
debugLogging('INIT EDITOR: Done', true);
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
performErrorHandling(error);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
const configProcessedFunc = () => {
|
|
165
|
+
debugLogging('CONFIG PROCESSED', true);
|
|
166
|
+
if (!launchingRef.current) {
|
|
167
|
+
if (editorAppConfigRef.current?.codeResources !== undefined && editorAppRef.current) {
|
|
168
|
+
editorAppRef.current.updateCodeResources(editorAppConfigRef.current.codeResources);
|
|
169
|
+
editorAppRef.current.updateCode({
|
|
170
|
+
modified: editorAppConfigRef.current.codeResources.modified?.text,
|
|
171
|
+
original: editorAppConfigRef.current.codeResources.original?.text
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
if (editorAppConfigRef.current?.editorOptions !== undefined && editorAppRef.current) {
|
|
175
|
+
if (!editorAppRef.current.isDiffEditor()) {
|
|
176
|
+
editorAppRef.current.getEditor()?.updateOptions(editorAppConfigRef.current.editorOptions);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (editorAppConfigRef.current?.diffEditorOptions !== undefined && editorAppRef.current) {
|
|
180
|
+
if (editorAppRef.current.isDiffEditor()) {
|
|
181
|
+
editorAppRef.current.getDiffEditor()?.updateOptions(editorAppConfigRef.current.diffEditorOptions);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
onConfigProcessed?.(editorAppRef.current);
|
|
186
|
+
debugLogging('CONFIG PROCESSED: Done', true);
|
|
187
|
+
};
|
|
188
|
+
useEffect(() => {
|
|
189
|
+
// fast-fail
|
|
190
|
+
if (editorAppConfig === undefined)
|
|
191
|
+
return;
|
|
192
|
+
// always try to perform global init. Reason: we cannot ensure order
|
|
193
|
+
performGlobalInit();
|
|
194
|
+
editorAppConfigRef.current = editorAppConfig;
|
|
165
195
|
addQueue('editorInit', editorInitFunc);
|
|
196
|
+
// it is possible to run without an editorApp, when the ViewsService or WorkbenchService
|
|
197
|
+
if (haveEditorService()) {
|
|
198
|
+
if (editorAppRef.current !== undefined && !launchingRef.current) {
|
|
199
|
+
configProcessedFunc();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
166
202
|
}, [editorAppConfig]);
|
|
167
|
-
const handleEditorDispose = async () => {
|
|
168
|
-
await editorAppRef.current?.dispose();
|
|
169
|
-
editorAppRef.current = undefined;
|
|
170
|
-
onDisposeEditor?.();
|
|
171
|
-
};
|
|
172
203
|
useEffect(() => {
|
|
173
204
|
// fast-fail
|
|
174
205
|
if (languageClientConfig === undefined)
|
|
175
206
|
return;
|
|
176
207
|
// always try to perform global init. Reason: we cannot ensure order
|
|
177
208
|
performGlobalInit();
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
209
|
+
if (languageClientConfig.enforceDispose === true) {
|
|
210
|
+
const disposeLCFunc = async () => {
|
|
211
|
+
// dispose editor if used
|
|
212
|
+
try {
|
|
213
|
+
debugLogging('DISPOSE LC ENFORCED', true);
|
|
214
|
+
await lcsManager.dispose();
|
|
215
|
+
onDisposeLanguageClient?.();
|
|
216
|
+
debugLogging('DISPOSE LC ENFORCED DONE', true);
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
// The language client may throw an error during disposal, but we want to continue anyway
|
|
220
|
+
performErrorHandling(new Error(`Unexpected error occurred during disposal of the language client: ${error}`));
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
addQueue('dispose lc', disposeLCFunc);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
const lcInitFunc = async () => {
|
|
227
|
+
try {
|
|
228
|
+
debugLogging('INIT LC', true);
|
|
229
|
+
lcsManager.setLogLevel(languageClientConfig.logLevel);
|
|
230
|
+
await lcsManager.setConfig(languageClientConfig);
|
|
231
|
+
if (!lcsManager.isStarted()) {
|
|
232
|
+
await lcsManager.start();
|
|
233
|
+
onLanguageClientsStartDone?.(lcsManager);
|
|
234
|
+
debugLogging('INIT LC: Language client started', true);
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
debugLogging('INIT LC: Language client is not (re-)started', true);
|
|
238
|
+
}
|
|
239
|
+
debugLogging('INIT LC DONE', true);
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
performErrorHandling(error);
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
addQueue('lcInit', lcInitFunc);
|
|
246
|
+
}
|
|
191
247
|
}, [languageClientConfig]);
|
|
192
248
|
useEffect(() => {
|
|
193
249
|
// this part runs on mount (componentDidMount)
|
|
@@ -198,32 +254,24 @@ export const MonacoEditorReactComp = (props) => {
|
|
|
198
254
|
const disposeFunc = async () => {
|
|
199
255
|
// dispose editor if used
|
|
200
256
|
debugLogging('DISPOSE', true);
|
|
201
|
-
|
|
257
|
+
if (editorAppRef.current !== undefined) {
|
|
258
|
+
await editorAppRef.current.dispose();
|
|
259
|
+
editorAppRef.current = undefined;
|
|
260
|
+
onDisposeEditor?.();
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
debugLogging('DISPOSE: EditorApp is not disposed', true);
|
|
264
|
+
}
|
|
202
265
|
debugLogging('DISPOSE DONE', true);
|
|
203
266
|
};
|
|
204
267
|
addQueue('dispose', disposeFunc);
|
|
205
268
|
};
|
|
206
269
|
}, []);
|
|
207
270
|
useEffect(() => {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
if (enforceDisposeLanguageClient === true) {
|
|
211
|
-
const disposeLCFunc = async () => {
|
|
212
|
-
// dispose editor if used
|
|
213
|
-
try {
|
|
214
|
-
debugLogging('DISPOSE LC', true);
|
|
215
|
-
await lcsManager.dispose();
|
|
216
|
-
onDisposeLanguageClient?.();
|
|
217
|
-
debugLogging('DISPOSE LC DONE', true);
|
|
218
|
-
}
|
|
219
|
-
catch (error) {
|
|
220
|
-
// The language client may throw an error during disposal, but we want to continue anyway
|
|
221
|
-
performErrorHandling(new Error(`Unexpected error occurred during disposal of the language client: ${error}`));
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
addQueue('dispose lc', disposeLCFunc);
|
|
271
|
+
if (logLevel !== undefined) {
|
|
272
|
+
logger.setLevel(logLevel);
|
|
225
273
|
}
|
|
226
|
-
}, [
|
|
274
|
+
}, [logLevel]);
|
|
227
275
|
return (React.createElement("div", { ref: containerRef, style: style, className: className }));
|
|
228
276
|
};
|
|
229
277
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F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,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,GACtB,CACL,CAAC;AAAA,CACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typefox/monaco-editor-react",
|
|
3
|
-
"version": "7.3.0-next.
|
|
3
|
+
"version": "7.3.0-next.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React component for Monaco-Editor and Monaco Languageclient",
|
|
6
6
|
"keywords": [
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"npm": "10.9.3"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@codingame/monaco-vscode-editor-api": "^22.1.
|
|
49
|
+
"@codingame/monaco-vscode-editor-api": "^22.1.9",
|
|
50
50
|
"react": ">=18.0.0 || <20.0.0"
|
|
51
51
|
},
|
|
52
52
|
"repository": {
|
package/src/index.tsx
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
* Licensed under the MIT License. See LICENSE in the package root for license information.
|
|
4
4
|
* ------------------------------------------------------------------------------------------ */
|
|
5
5
|
|
|
6
|
+
import { LogLevel } from '@codingame/monaco-vscode-api';
|
|
7
|
+
import * as monaco from '@codingame/monaco-vscode-editor-api';
|
|
8
|
+
import { ConsoleLogger } from 'monaco-languageclient/common';
|
|
6
9
|
import { EditorApp, type EditorAppConfig, type TextContents } from 'monaco-languageclient/editorApp';
|
|
7
10
|
import { type LanguageClientConfig, LanguageClientManager } from 'monaco-languageclient/lcwrapper';
|
|
8
11
|
import { getEnhancedMonacoEnvironment, type MonacoVscodeApiConfig, MonacoVscodeApiWrapper } from 'monaco-languageclient/vscodeApiWrapper';
|
|
@@ -13,19 +16,18 @@ export type ResolveFc = (value: void | PromiseLike<void>) => void;
|
|
|
13
16
|
export type MonacoEditorProps = {
|
|
14
17
|
style?: CSSProperties;
|
|
15
18
|
className?: string;
|
|
16
|
-
vscodeApiConfig
|
|
19
|
+
vscodeApiConfig?: MonacoVscodeApiConfig;
|
|
17
20
|
editorAppConfig?: EditorAppConfig;
|
|
18
21
|
languageClientConfig?: LanguageClientConfig;
|
|
19
|
-
enforceDisposeLanguageClient?: boolean;
|
|
20
22
|
onVscodeApiInitDone?: (monacoVscodeApiManager: MonacoVscodeApiWrapper) => void;
|
|
21
23
|
onEditorStartDone?: (editorApp?: EditorApp) => void;
|
|
22
|
-
onLanguageClientsStartDone?: (lcsManager
|
|
24
|
+
onLanguageClientsStartDone?: (lcsManager: LanguageClientManager) => void;
|
|
23
25
|
onTextChanged?: (textChanges: TextContents) => void;
|
|
26
|
+
onConfigProcessed?: (editorApp?: EditorApp) => void;
|
|
24
27
|
onError?: (error: Error) => void;
|
|
25
28
|
onDisposeEditor?: () => void;
|
|
26
29
|
onDisposeLanguageClient?: () => void;
|
|
27
|
-
|
|
28
|
-
originalTextValue?: string;
|
|
30
|
+
logLevel?: LogLevel | number;
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
// All must be outside of the component as they ars valid across all instances and should not be re-created
|
|
@@ -34,10 +36,69 @@ const lcsManager = new LanguageClientManager();
|
|
|
34
36
|
const haveEditorService = () => {
|
|
35
37
|
return getEnhancedMonacoEnvironment().viewServiceType === 'EditorService';
|
|
36
38
|
};
|
|
39
|
+
const logger = new ConsoleLogger(LogLevel.Debug);
|
|
37
40
|
|
|
38
41
|
const runQueue: Array<{id: string, func: () => Promise<void>}> = [];
|
|
39
|
-
let
|
|
40
|
-
let
|
|
42
|
+
let queueLock = true;
|
|
43
|
+
let intervalId: number | unknown | undefined = undefined;
|
|
44
|
+
|
|
45
|
+
const addQueue = (id: string, func: () => Promise<void>) => {
|
|
46
|
+
debugLogging('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
|
|
47
|
+
debugLogging(`Adding to queue: ${id}: QUEUE SIZE before: ${runQueue.length}`);
|
|
48
|
+
runQueue.push({id, func});
|
|
49
|
+
kickQueue();
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const executeQueue = async () => {
|
|
53
|
+
console.log(`Queue size: ${runQueue.length}`);
|
|
54
|
+
|
|
55
|
+
if (runQueue.length > 0) {
|
|
56
|
+
queueLock = true;
|
|
57
|
+
while (runQueue.length > 0) {
|
|
58
|
+
const lengthBefore = runQueue.length;
|
|
59
|
+
const queueObj = runQueue.shift();
|
|
60
|
+
debugLogging('<<<<<<<<<<<<<<<<<<<<<<<<<<<<<');
|
|
61
|
+
debugLogging(`QUEUE ${queueObj?.id} start: SIZE before: ${lengthBefore}`, true);
|
|
62
|
+
try {
|
|
63
|
+
await queueObj?.func();
|
|
64
|
+
} catch (error) {
|
|
65
|
+
queueLock = false;
|
|
66
|
+
debugLogging(`QUEUE ${queueObj?.id} ERROR: SIZE after: ${runQueue.length}`);
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
debugLogging(`QUEUE ${queueObj?.id} end: SIZE after: ${runQueue.length}`);
|
|
70
|
+
}
|
|
71
|
+
queueLock = false;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const kickQueue = () => {
|
|
76
|
+
if (intervalId === undefined && runQueue.length > 0) {
|
|
77
|
+
intervalId = setInterval(async () => {
|
|
78
|
+
debugLogging('Checking queue...' + queueLock);
|
|
79
|
+
if (!queueLock) {
|
|
80
|
+
await executeQueue();
|
|
81
|
+
stopQueue();
|
|
82
|
+
}
|
|
83
|
+
}, 50);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const stopQueue = () => {
|
|
88
|
+
if (intervalId !== undefined && runQueue.length === 0) {
|
|
89
|
+
debugLogging('Stopping queue...');
|
|
90
|
+
clearInterval(intervalId as number);
|
|
91
|
+
intervalId = undefined;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const debugLogging = (id: string, useTime?: boolean) => {
|
|
96
|
+
if (useTime === true) {
|
|
97
|
+
logger.debug(`${id}: ${Date.now()}`);
|
|
98
|
+
} else {
|
|
99
|
+
logger.debug(id);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
41
102
|
|
|
42
103
|
export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
|
|
43
104
|
const {
|
|
@@ -46,67 +107,25 @@ export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
|
|
|
46
107
|
vscodeApiConfig,
|
|
47
108
|
editorAppConfig,
|
|
48
109
|
languageClientConfig,
|
|
49
|
-
enforceDisposeLanguageClient,
|
|
50
110
|
onVscodeApiInitDone,
|
|
51
111
|
onEditorStartDone,
|
|
52
112
|
onLanguageClientsStartDone,
|
|
53
113
|
onTextChanged,
|
|
114
|
+
onConfigProcessed,
|
|
54
115
|
onError,
|
|
55
116
|
onDisposeEditor,
|
|
56
117
|
onDisposeLanguageClient,
|
|
57
|
-
|
|
58
|
-
originalTextValue
|
|
118
|
+
logLevel
|
|
59
119
|
} = props;
|
|
60
120
|
|
|
61
|
-
const currentEditorConfig = useRef<EditorAppConfig | undefined>(undefined);
|
|
62
121
|
const editorAppRef = useRef<EditorApp>(undefined);
|
|
63
122
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
64
123
|
const onTextChangedRef = useRef(onTextChanged);
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
const addQueue = (id: string, func: () => Promise<void>) => {
|
|
69
|
-
debugLogging(`Adding to queue: ${id}`);
|
|
70
|
-
debugLogging(`QUEUE SIZE before: ${runQueue.length}`);
|
|
71
|
-
runQueue.push({id, func});
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const triggerQueue = () => {
|
|
75
|
-
setInterval(() => {
|
|
76
|
-
if (queueAwait === undefined) {
|
|
77
|
-
queueAwait = new Promise<void>((resolve) => {
|
|
78
|
-
queueResolve = resolve;
|
|
79
|
-
});
|
|
80
|
-
executeQueue();
|
|
81
|
-
}
|
|
82
|
-
}, 50);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const executeQueue = async () => {
|
|
86
|
-
while (runQueue.length > 0) {
|
|
87
|
-
const queueObj = runQueue.shift();
|
|
88
|
-
if (queueObj !== undefined) {
|
|
89
|
-
debugLogging(`QUEUE ${queueObj.id} SIZE before: ${runQueue.length}`);
|
|
90
|
-
debugLogging(`QUEUE ${queueObj.id} start`, true);
|
|
91
|
-
await queueObj.func();
|
|
92
|
-
debugLogging(`QUEUE ${queueObj.id} SIZE after: ${runQueue.length}`);
|
|
93
|
-
debugLogging(`QUEUE ${queueObj.id} end`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
queueResolve?.();
|
|
97
|
-
queueAwait = undefined;
|
|
98
|
-
queueResolve = undefined;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const debugLogging = (id: string, useTime?: boolean) => {
|
|
102
|
-
if (useTime === true) {
|
|
103
|
-
apiWrapper?.getLogger().debug(`${id}: ${Date.now()}`);
|
|
104
|
-
} else {
|
|
105
|
-
apiWrapper?.getLogger().debug(id);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
124
|
+
const launchingRef = useRef<boolean>(false);
|
|
125
|
+
const editorAppConfigRef = useRef<EditorAppConfig>(undefined);
|
|
108
126
|
|
|
109
127
|
const performErrorHandling = (error: Error) => {
|
|
128
|
+
debugLogging(`ERROR: ${error.message}`, true);
|
|
110
129
|
if (onError) {
|
|
111
130
|
onError(error);
|
|
112
131
|
} else {
|
|
@@ -114,35 +133,25 @@ export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
|
|
|
114
133
|
}
|
|
115
134
|
};
|
|
116
135
|
|
|
117
|
-
useEffect(() => {
|
|
118
|
-
// this is only available if EditorService is configured
|
|
119
|
-
if (haveEditorService() && modifiedTextValue !== undefined) {
|
|
120
|
-
modifiedCode.current = modifiedTextValue;
|
|
121
|
-
editorAppRef.current?.updateCode({modified: modifiedTextValue});
|
|
122
|
-
}
|
|
123
|
-
}, [modifiedTextValue]);
|
|
124
|
-
|
|
125
|
-
useEffect(() => {
|
|
126
|
-
// this is only available if EditorService is configured
|
|
127
|
-
if (haveEditorService() && originalTextValue !== undefined) {
|
|
128
|
-
originalCode.current = originalTextValue;
|
|
129
|
-
editorAppRef.current?.updateCode({original: originalTextValue});
|
|
130
|
-
}
|
|
131
|
-
}, [originalTextValue]);
|
|
132
|
-
|
|
133
136
|
const performGlobalInit = async () => {
|
|
134
137
|
if (containerRef.current === null) {
|
|
135
138
|
performErrorHandling(new Error('No htmlContainer found! Aborting...'));
|
|
136
139
|
}
|
|
137
140
|
const envEnhanced = getEnhancedMonacoEnvironment();
|
|
138
141
|
|
|
142
|
+
// let apiConfig: MonacoVscodeApiConfig;
|
|
143
|
+
if (vscodeApiConfig === undefined && envEnhanced.vscodeApiInitialised !== true) {
|
|
144
|
+
throw new Error('vscodeApiConfig is not provided, but the monaco-vscode-api is not initialized! Aborting...');
|
|
145
|
+
}
|
|
146
|
+
|
|
139
147
|
// init will only performed once
|
|
140
148
|
if (envEnhanced.vscodeApiInitialising !== true) {
|
|
141
149
|
|
|
142
|
-
apiWrapper = new MonacoVscodeApiWrapper(vscodeApiConfig);
|
|
150
|
+
apiWrapper = new MonacoVscodeApiWrapper(vscodeApiConfig!);
|
|
143
151
|
const globalInitFunc = async () => {
|
|
144
152
|
try {
|
|
145
153
|
debugLogging('GLOBAL INIT', true);
|
|
154
|
+
|
|
146
155
|
if (apiWrapper === undefined) throw new Error('Unexpected error occurred: apiWrapper is not available! Aborting...');
|
|
147
156
|
|
|
148
157
|
if (apiWrapper.getMonacoVscodeApiConfig().viewsConfig.$type === 'EditorService') {
|
|
@@ -152,44 +161,29 @@ export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
|
|
|
152
161
|
});
|
|
153
162
|
}
|
|
154
163
|
await apiWrapper.start();
|
|
155
|
-
|
|
156
|
-
lcsManager.setLogger(apiWrapper.getLogger());
|
|
157
|
-
|
|
158
164
|
onVscodeApiInitDone?.(apiWrapper);
|
|
159
|
-
|
|
165
|
+
|
|
160
166
|
debugLogging('GLOBAL INIT DONE', true);
|
|
167
|
+
|
|
168
|
+
queueLock = false;
|
|
161
169
|
} catch (error) {
|
|
162
170
|
performErrorHandling(error as Error);
|
|
163
171
|
}
|
|
164
172
|
};
|
|
165
173
|
globalInitFunc();
|
|
166
|
-
} else if (envEnhanced.vscodeApiInitialised === true) {
|
|
167
|
-
triggerQueue();
|
|
168
174
|
}
|
|
169
175
|
};
|
|
170
176
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
// re-create editor if config changed
|
|
179
|
-
const recreateEditor = editorAppRef.current === undefined || currentEditorConfig.current === undefined ||
|
|
180
|
-
JSON.stringify(editorAppConfig) !== JSON.stringify(currentEditorConfig.current);
|
|
181
|
-
const editorInitFunc = async () => {
|
|
182
|
-
try {
|
|
183
|
-
debugLogging('INIT', true);
|
|
184
|
-
|
|
185
|
-
// it is possible to run without an editorApp, for example when using the ViewsService
|
|
186
|
-
if (recreateEditor && haveEditorService()) {
|
|
177
|
+
const editorInitFunc = async () => {
|
|
178
|
+
try {
|
|
179
|
+
debugLogging('INIT EDITOR', true);
|
|
180
|
+
// it is possible to run without an editorApp, when the ViewsService or WorkbenchService
|
|
181
|
+
if (haveEditorService()) {
|
|
182
|
+
if (editorAppRef.current === undefined && !launchingRef.current) {
|
|
183
|
+
launchingRef.current = true;
|
|
187
184
|
debugLogging('INIT: Creating editor', true);
|
|
188
185
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
currentEditorConfig.current = editorAppConfig;
|
|
192
|
-
editorAppRef.current = new EditorApp(editorAppConfig);
|
|
186
|
+
editorAppRef.current = new EditorApp(editorAppConfigRef.current);
|
|
193
187
|
if (editorAppRef.current.isStarting() === true || editorAppRef.current.isDisposing() === true) {
|
|
194
188
|
await Promise.all([
|
|
195
189
|
editorAppRef.current.getStartingAwait(),
|
|
@@ -198,12 +192,6 @@ export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
|
|
|
198
192
|
}
|
|
199
193
|
|
|
200
194
|
editorAppRef.current.registerOnTextChangedCallback((textChanges) => {
|
|
201
|
-
if (textChanges.modified !== undefined) {
|
|
202
|
-
modifiedCode.current = textChanges.modified;
|
|
203
|
-
}
|
|
204
|
-
if (textChanges.original !== undefined) {
|
|
205
|
-
originalCode.current = textChanges.original;
|
|
206
|
-
}
|
|
207
195
|
if (onTextChangedRef.current !== undefined) {
|
|
208
196
|
onTextChangedRef.current(textChanges);
|
|
209
197
|
}
|
|
@@ -211,22 +199,61 @@ export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
|
|
|
211
199
|
await editorAppRef.current.start(containerRef.current!);
|
|
212
200
|
|
|
213
201
|
onEditorStartDone?.(editorAppRef.current);
|
|
202
|
+
launchingRef.current = false;
|
|
203
|
+
} else {
|
|
204
|
+
debugLogging('INIT EDITOR: Editor already created', true);
|
|
214
205
|
}
|
|
206
|
+
} else {
|
|
207
|
+
debugLogging('INIT EDITOR: Do nothing: Using ViewsService', true);
|
|
208
|
+
}
|
|
209
|
+
debugLogging('INIT EDITOR: Done', true);
|
|
210
|
+
} catch (error) {
|
|
211
|
+
performErrorHandling(error as Error);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
215
214
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
215
|
+
const configProcessedFunc = () => {
|
|
216
|
+
debugLogging('CONFIG PROCESSED', true);
|
|
217
|
+
if (!launchingRef.current) {
|
|
218
|
+
if (editorAppConfigRef.current?.codeResources !== undefined && editorAppRef.current) {
|
|
219
|
+
editorAppRef.current.updateCodeResources(editorAppConfigRef.current.codeResources);
|
|
220
|
+
editorAppRef.current.updateCode({
|
|
221
|
+
modified: editorAppConfigRef.current.codeResources.modified?.text,
|
|
222
|
+
original: editorAppConfigRef.current.codeResources.original?.text
|
|
223
|
+
});
|
|
219
224
|
}
|
|
220
|
-
|
|
225
|
+
if (editorAppConfigRef.current?.editorOptions !== undefined && editorAppRef.current) {
|
|
226
|
+
if (!editorAppRef.current.isDiffEditor()) {
|
|
227
|
+
editorAppRef.current.getEditor()?.updateOptions(editorAppConfigRef.current.editorOptions as monaco.editor.IEditorOptions);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (editorAppConfigRef.current?.diffEditorOptions !== undefined && editorAppRef.current) {
|
|
231
|
+
if (editorAppRef.current.isDiffEditor()) {
|
|
232
|
+
editorAppRef.current.getDiffEditor()?.updateOptions(editorAppConfigRef.current.diffEditorOptions as monaco.editor.IDiffEditorOptions);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
onConfigProcessed?.(editorAppRef.current);
|
|
237
|
+
debugLogging('CONFIG PROCESSED: Done', true);
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
useEffect(() => {
|
|
241
|
+
// fast-fail
|
|
242
|
+
if (editorAppConfig === undefined) return;
|
|
243
|
+
|
|
244
|
+
// always try to perform global init. Reason: we cannot ensure order
|
|
245
|
+
performGlobalInit();
|
|
246
|
+
|
|
247
|
+
editorAppConfigRef.current = editorAppConfig;
|
|
221
248
|
addQueue('editorInit', editorInitFunc);
|
|
249
|
+
// it is possible to run without an editorApp, when the ViewsService or WorkbenchService
|
|
250
|
+
if (haveEditorService()) {
|
|
251
|
+
if (editorAppRef.current !== undefined && !launchingRef.current) {
|
|
252
|
+
configProcessedFunc();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
222
255
|
}, [editorAppConfig]);
|
|
223
256
|
|
|
224
|
-
const handleEditorDispose = async () => {
|
|
225
|
-
await editorAppRef.current?.dispose();
|
|
226
|
-
editorAppRef.current = undefined;
|
|
227
|
-
onDisposeEditor?.();
|
|
228
|
-
};
|
|
229
|
-
|
|
230
257
|
useEffect(() => {
|
|
231
258
|
// fast-fail
|
|
232
259
|
if (languageClientConfig === undefined) return;
|
|
@@ -234,21 +261,43 @@ export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
|
|
|
234
261
|
// always try to perform global init. Reason: we cannot ensure order
|
|
235
262
|
performGlobalInit();
|
|
236
263
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
await lcsManager.start();
|
|
264
|
+
if (languageClientConfig.enforceDispose === true) {
|
|
265
|
+
const disposeLCFunc = async () => {
|
|
266
|
+
// dispose editor if used
|
|
267
|
+
try {
|
|
268
|
+
debugLogging('DISPOSE LC ENFORCED', true);
|
|
243
269
|
|
|
244
|
-
|
|
270
|
+
await lcsManager.dispose();
|
|
271
|
+
onDisposeLanguageClient?.();
|
|
245
272
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
273
|
+
debugLogging('DISPOSE LC ENFORCED DONE', true);
|
|
274
|
+
} catch (error) {
|
|
275
|
+
// The language client may throw an error during disposal, but we want to continue anyway
|
|
276
|
+
performErrorHandling(new Error(`Unexpected error occurred during disposal of the language client: ${error}`));
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
addQueue('dispose lc', disposeLCFunc);
|
|
280
|
+
} else {
|
|
281
|
+
const lcInitFunc = async () => {
|
|
282
|
+
try {
|
|
283
|
+
debugLogging('INIT LC', true);
|
|
284
|
+
|
|
285
|
+
lcsManager.setLogLevel(languageClientConfig.logLevel);
|
|
286
|
+
await lcsManager.setConfig(languageClientConfig);
|
|
287
|
+
if (!lcsManager.isStarted()) {
|
|
288
|
+
await lcsManager.start();
|
|
289
|
+
onLanguageClientsStartDone?.(lcsManager);
|
|
290
|
+
debugLogging('INIT LC: Language client started', true);
|
|
291
|
+
} else {
|
|
292
|
+
debugLogging('INIT LC: Language client is not (re-)started', true);
|
|
293
|
+
}
|
|
294
|
+
debugLogging('INIT LC DONE', true);
|
|
295
|
+
} catch (error) {
|
|
296
|
+
performErrorHandling(error as Error);
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
addQueue('lcInit', lcInitFunc);
|
|
300
|
+
}
|
|
252
301
|
}, [languageClientConfig]);
|
|
253
302
|
|
|
254
303
|
useEffect(() => {
|
|
@@ -263,8 +312,13 @@ export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
|
|
|
263
312
|
// dispose editor if used
|
|
264
313
|
debugLogging('DISPOSE', true);
|
|
265
314
|
|
|
266
|
-
|
|
267
|
-
|
|
315
|
+
if (editorAppRef.current !== undefined) {
|
|
316
|
+
await editorAppRef.current.dispose();
|
|
317
|
+
editorAppRef.current = undefined;
|
|
318
|
+
onDisposeEditor?.();
|
|
319
|
+
} else {
|
|
320
|
+
debugLogging('DISPOSE: EditorApp is not disposed', true);
|
|
321
|
+
}
|
|
268
322
|
debugLogging('DISPOSE DONE', true);
|
|
269
323
|
};
|
|
270
324
|
addQueue('dispose', disposeFunc);
|
|
@@ -272,27 +326,10 @@ export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
|
|
|
272
326
|
}, []);
|
|
273
327
|
|
|
274
328
|
useEffect(() => {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
if (enforceDisposeLanguageClient === true) {
|
|
279
|
-
const disposeLCFunc = async () => {
|
|
280
|
-
// dispose editor if used
|
|
281
|
-
try {
|
|
282
|
-
debugLogging('DISPOSE LC', true);
|
|
283
|
-
|
|
284
|
-
await lcsManager.dispose();
|
|
285
|
-
onDisposeLanguageClient?.();
|
|
286
|
-
|
|
287
|
-
debugLogging('DISPOSE LC DONE', true);
|
|
288
|
-
} catch (error) {
|
|
289
|
-
// The language client may throw an error during disposal, but we want to continue anyway
|
|
290
|
-
performErrorHandling(new Error(`Unexpected error occurred during disposal of the language client: ${error}`));
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
addQueue('dispose lc', disposeLCFunc);
|
|
329
|
+
if (logLevel !== undefined) {
|
|
330
|
+
logger.setLevel(logLevel);
|
|
294
331
|
}
|
|
295
|
-
}, [
|
|
332
|
+
}, [logLevel]);
|
|
296
333
|
|
|
297
334
|
return (
|
|
298
335
|
<div
|