@typefox/monaco-editor-react 7.3.0-next.1 → 7.3.0-next.3
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 +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +114 -74
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +130 -79
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.3] - 2025-11-05
|
|
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.3`.
|
|
9
|
+
- Updated all `@codingame/monaco-vscode` packages to `22.1.8`.
|
|
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';
|
|
@@ -14,11 +15,13 @@ export type MonacoEditorProps = {
|
|
|
14
15
|
onEditorStartDone?: (editorApp?: EditorApp) => void;
|
|
15
16
|
onLanguageClientsStartDone?: (lcsManager?: LanguageClientManager) => void;
|
|
16
17
|
onTextChanged?: (textChanges: TextContents) => void;
|
|
18
|
+
onConfigProcessed?: (editorApp?: EditorApp) => void;
|
|
17
19
|
onError?: (error: Error) => void;
|
|
18
20
|
onDisposeEditor?: () => void;
|
|
19
21
|
onDisposeLanguageClient?: () => void;
|
|
20
22
|
modifiedTextValue?: string;
|
|
21
23
|
originalTextValue?: string;
|
|
24
|
+
logLevel?: LogLevel | number;
|
|
22
25
|
};
|
|
23
26
|
export declare const MonacoEditorReactComp: React.FC<MonacoEditorProps>;
|
|
24
27
|
//# 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,KAAK,IAAI,CAAC;AAElE,MAAM,MAAM,iBAAiB,GAAG;IAC5B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,qBAAqB,CAAC;IACvC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,mBAAmB,CAAC,EAAE,CAAC,sBAAsB,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAC/E,i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IACvC,mBAAmB,CAAC,EAAE,CAAC,sBAAsB,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAC/E,iBAAiB,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,SAAS,KAAK,IAAI,CAAC;IACpD,0BAA0B,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAC1E,aAAa,CAAC,EAAE,CAAC,WAAW,EAAE,YAAY,KAAK,IAAI,CAAC;IACpD,iBAAiB,CAAC,EAAE,CAAC,SAAS,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,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;CAChC,CAAA;AAmED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA0P7D,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';
|
|
@@ -10,57 +13,68 @@ import React, { useEffect, useRef } from 'react';
|
|
|
10
13
|
let apiWrapper;
|
|
11
14
|
const lcsManager = new LanguageClientManager();
|
|
12
15
|
const haveEditorService = () => {
|
|
13
|
-
return
|
|
16
|
+
return getEnhancedMonacoEnvironment().viewServiceType === 'EditorService';
|
|
14
17
|
};
|
|
18
|
+
const logger = new ConsoleLogger(LogLevel.Debug);
|
|
15
19
|
const runQueue = [];
|
|
16
|
-
let
|
|
17
|
-
let
|
|
20
|
+
let lock = 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
|
+
lock = true;
|
|
32
|
+
while (runQueue.length > 0) {
|
|
33
|
+
const lengthBefore = runQueue.length;
|
|
34
|
+
const queueObj = runQueue.shift();
|
|
35
|
+
debugLogging('<<<<<<<<<<<<<<<<<<<<<<<<<<<<<');
|
|
36
|
+
debugLogging(`QUEUE ${queueObj?.id} start: SIZE before: ${lengthBefore}`, true);
|
|
37
|
+
await queueObj?.func();
|
|
38
|
+
debugLogging(`QUEUE ${queueObj?.id} end: SIZE after: ${runQueue.length}`);
|
|
39
|
+
}
|
|
40
|
+
lock = false;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const kickQueue = () => {
|
|
44
|
+
if (intervalId === undefined && runQueue.length > 0) {
|
|
45
|
+
intervalId = setInterval(async () => {
|
|
46
|
+
debugLogging('Checking queue...');
|
|
47
|
+
if (!lock) {
|
|
48
|
+
executeQueue();
|
|
49
|
+
stopQueue();
|
|
50
|
+
}
|
|
51
|
+
}, 50);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const stopQueue = () => {
|
|
55
|
+
if (intervalId !== undefined && runQueue.length === 0) {
|
|
56
|
+
debugLogging('Stopping queue...');
|
|
57
|
+
clearInterval(intervalId);
|
|
58
|
+
intervalId = undefined;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const debugLogging = (id, useTime) => {
|
|
62
|
+
if (useTime === true) {
|
|
63
|
+
logger.debug(`${id}: ${Date.now()}`);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
logger.debug(id);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
18
69
|
export const MonacoEditorReactComp = (props) => {
|
|
19
|
-
const { style, className, vscodeApiConfig, editorAppConfig, languageClientConfig, enforceDisposeLanguageClient, onVscodeApiInitDone, onEditorStartDone, onLanguageClientsStartDone, onTextChanged, onError, onDisposeEditor, onDisposeLanguageClient, modifiedTextValue, originalTextValue } = props;
|
|
20
|
-
const currentEditorConfig = useRef(undefined);
|
|
70
|
+
const { style, className, vscodeApiConfig, editorAppConfig, languageClientConfig, enforceDisposeLanguageClient, onVscodeApiInitDone, onEditorStartDone, onLanguageClientsStartDone, onTextChanged, onConfigProcessed, onError, onDisposeEditor, onDisposeLanguageClient, modifiedTextValue, originalTextValue, logLevel } = props;
|
|
21
71
|
const editorAppRef = useRef(undefined);
|
|
22
72
|
const containerRef = useRef(null);
|
|
23
73
|
const onTextChangedRef = useRef(onTextChanged);
|
|
24
74
|
const modifiedCode = useRef(modifiedTextValue);
|
|
25
75
|
const originalCode = useRef(originalTextValue);
|
|
26
|
-
const
|
|
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 () => {
|
|
42
|
-
while (runQueue.length > 0) {
|
|
43
|
-
const queueObj = runQueue.shift();
|
|
44
|
-
if (queueObj !== undefined) {
|
|
45
|
-
debugLogging(`QUEUE ${queueObj.id} SIZE before: ${runQueue.length}`);
|
|
46
|
-
debugLogging(`QUEUE ${queueObj.id} start`, true);
|
|
47
|
-
await queueObj.func();
|
|
48
|
-
debugLogging(`QUEUE ${queueObj.id} SIZE after: ${runQueue.length}`);
|
|
49
|
-
debugLogging(`QUEUE ${queueObj.id} end`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
queueResolve?.();
|
|
53
|
-
queueAwait = undefined;
|
|
54
|
-
queueResolve = undefined;
|
|
55
|
-
};
|
|
56
|
-
const debugLogging = (id, useTime) => {
|
|
57
|
-
if (useTime === true) {
|
|
58
|
-
apiWrapper?.getLogger().debug(`${id}: ${Date.now()}`);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
apiWrapper?.getLogger().debug(id);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
76
|
+
const launchingRef = useRef(false);
|
|
77
|
+
const editorAppConfigRef = useRef(undefined);
|
|
64
78
|
const performErrorHandling = (error) => {
|
|
65
79
|
if (onError) {
|
|
66
80
|
onError(error);
|
|
@@ -96,17 +110,16 @@ export const MonacoEditorReactComp = (props) => {
|
|
|
96
110
|
debugLogging('GLOBAL INIT', true);
|
|
97
111
|
if (apiWrapper === undefined)
|
|
98
112
|
throw new Error('Unexpected error occurred: apiWrapper is not available! Aborting...');
|
|
99
|
-
if (
|
|
113
|
+
if (apiWrapper.getMonacoVscodeApiConfig().viewsConfig.$type === 'EditorService') {
|
|
100
114
|
apiWrapper.overrideViewsConfig({
|
|
101
115
|
$type: 'EditorService',
|
|
102
116
|
htmlContainer: containerRef.current
|
|
103
117
|
});
|
|
104
118
|
}
|
|
105
119
|
await apiWrapper.start();
|
|
106
|
-
lcsManager.setLogger(apiWrapper.getLogger());
|
|
107
120
|
onVscodeApiInitDone?.(apiWrapper);
|
|
108
|
-
triggerQueue();
|
|
109
121
|
debugLogging('GLOBAL INIT DONE', true);
|
|
122
|
+
lock = false;
|
|
110
123
|
}
|
|
111
124
|
catch (error) {
|
|
112
125
|
performErrorHandling(error);
|
|
@@ -114,28 +127,16 @@ export const MonacoEditorReactComp = (props) => {
|
|
|
114
127
|
};
|
|
115
128
|
globalInitFunc();
|
|
116
129
|
}
|
|
117
|
-
else if (envEnhanced.vscodeApiInitialised === true) {
|
|
118
|
-
triggerQueue();
|
|
119
|
-
}
|
|
120
130
|
};
|
|
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()) {
|
|
131
|
+
const editorInitFunc = async () => {
|
|
132
|
+
try {
|
|
133
|
+
debugLogging('INIT', true);
|
|
134
|
+
// it is possible to run without an editorApp, for example when using the ViewsService
|
|
135
|
+
if (haveEditorService()) {
|
|
136
|
+
if (editorAppRef.current === undefined && !launchingRef.current) {
|
|
137
|
+
launchingRef.current = true;
|
|
135
138
|
debugLogging('INIT: Creating editor', true);
|
|
136
|
-
editorAppRef.current
|
|
137
|
-
currentEditorConfig.current = editorAppConfig;
|
|
138
|
-
editorAppRef.current = new EditorApp(editorAppConfig);
|
|
139
|
+
editorAppRef.current = new EditorApp(editorAppConfigRef.current);
|
|
139
140
|
if (editorAppRef.current.isStarting() === true || editorAppRef.current.isDisposing() === true) {
|
|
140
141
|
await Promise.all([
|
|
141
142
|
editorAppRef.current.getStartingAwait(),
|
|
@@ -155,14 +156,45 @@ export const MonacoEditorReactComp = (props) => {
|
|
|
155
156
|
});
|
|
156
157
|
await editorAppRef.current.start(containerRef.current);
|
|
157
158
|
onEditorStartDone?.(editorAppRef.current);
|
|
159
|
+
launchingRef.current = false;
|
|
158
160
|
}
|
|
159
|
-
debugLogging('INIT DONE', true);
|
|
160
161
|
}
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
debugLogging('INIT DONE', true);
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
performErrorHandling(error);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const configProcessedFunc = () => {
|
|
169
|
+
if (!launchingRef.current) {
|
|
170
|
+
if (editorAppConfigRef.current?.codeResources !== undefined && editorAppRef.current) {
|
|
171
|
+
editorAppRef.current.updateCodeResources(editorAppConfigRef.current.codeResources);
|
|
163
172
|
}
|
|
164
|
-
|
|
173
|
+
if (editorAppConfigRef.current?.editorOptions !== undefined && editorAppRef.current) {
|
|
174
|
+
if (!editorAppRef.current.isDiffEditor()) {
|
|
175
|
+
editorAppRef.current.getEditor()?.updateOptions(editorAppConfigRef.current.editorOptions);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (editorAppConfigRef.current?.diffEditorOptions !== undefined && editorAppRef.current) {
|
|
179
|
+
if (editorAppRef.current.isDiffEditor()) {
|
|
180
|
+
editorAppRef.current.getDiffEditor()?.updateOptions(editorAppConfigRef.current.diffEditorOptions);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
onConfigProcessed?.(editorAppRef.current);
|
|
185
|
+
debugLogging('Config processed');
|
|
186
|
+
};
|
|
187
|
+
useEffect(() => {
|
|
188
|
+
// fast-fail
|
|
189
|
+
if (editorAppConfig === undefined)
|
|
190
|
+
return;
|
|
191
|
+
// always try to perform global init. Reason: we cannot ensure order
|
|
192
|
+
performGlobalInit();
|
|
193
|
+
editorAppConfigRef.current = editorAppConfig;
|
|
165
194
|
addQueue('editorInit', editorInitFunc);
|
|
195
|
+
if (editorAppRef.current !== undefined && !launchingRef.current) {
|
|
196
|
+
configProcessedFunc();
|
|
197
|
+
}
|
|
166
198
|
}, [editorAppConfig]);
|
|
167
199
|
useEffect(() => {
|
|
168
200
|
// fast-fail
|
|
@@ -172,7 +204,8 @@ export const MonacoEditorReactComp = (props) => {
|
|
|
172
204
|
performGlobalInit();
|
|
173
205
|
const lcInitFunc = async () => {
|
|
174
206
|
try {
|
|
175
|
-
debugLogging('INIT
|
|
207
|
+
debugLogging('INIT LC', true);
|
|
208
|
+
lcsManager.setLogLevel(languageClientConfig.logLevel);
|
|
176
209
|
await lcsManager.setConfig(languageClientConfig);
|
|
177
210
|
await lcsManager.start();
|
|
178
211
|
onLanguageClientsStartDone?.(lcsManager);
|
|
@@ -193,14 +226,21 @@ export const MonacoEditorReactComp = (props) => {
|
|
|
193
226
|
const disposeFunc = async () => {
|
|
194
227
|
// dispose editor if used
|
|
195
228
|
debugLogging('DISPOSE', true);
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
229
|
+
if (editorAppRef.current !== undefined) {
|
|
230
|
+
await editorAppRef.current.dispose();
|
|
231
|
+
editorAppRef.current = undefined;
|
|
232
|
+
onDisposeEditor?.();
|
|
233
|
+
}
|
|
199
234
|
debugLogging('DISPOSE DONE', true);
|
|
200
235
|
};
|
|
201
236
|
addQueue('dispose', disposeFunc);
|
|
202
237
|
};
|
|
203
238
|
}, []);
|
|
239
|
+
useEffect(() => {
|
|
240
|
+
if (logLevel !== undefined) {
|
|
241
|
+
logger.setLevel(logLevel);
|
|
242
|
+
}
|
|
243
|
+
}, [logLevel]);
|
|
204
244
|
useEffect(() => {
|
|
205
245
|
// always try to perform global init. Reason: we cannot ensure order
|
|
206
246
|
performGlobalInit();
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,SAAS,EAA2C,MAAM,iCAAiC,CAAC;AACrG,OAAO,EAA6B,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACnG,OAAO,EAAE,4BAA4B,EAA8B,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAC1I,OAAO,KAAK,EAAE,EAAsB,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,KAAK,MAAM,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAA2C,MAAM,iCAAiC,CAAC;AACrG,OAAO,EAA6B,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACnG,OAAO,EAAE,4BAA4B,EAA8B,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAC1I,OAAO,KAAK,EAAE,EAAsB,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAwBrE,2GAA2G;AAC3G,IAAI,UAA8C,CAAC;AACnD,MAAM,UAAU,GAAG,IAAI,qBAAqB,EAAE,CAAC;AAC/C,MAAM,iBAAiB,GAAG,GAAG,EAAE,CAAC;IAC5B,OAAO,4BAA4B,EAAE,CAAC,eAAe,KAAK,eAAe,CAAC;AAAA,CAC7E,CAAC;AACF,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAEjD,MAAM,QAAQ,GAAmD,EAAE,CAAC;AACpE,IAAI,IAAI,GAAG,IAAI,CAAC;AAChB,IAAI,UAAU,GAAiC,SAAS,CAAC;AA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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.3",
|
|
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.8",
|
|
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';
|
|
@@ -21,23 +24,79 @@ export type MonacoEditorProps = {
|
|
|
21
24
|
onEditorStartDone?: (editorApp?: EditorApp) => void;
|
|
22
25
|
onLanguageClientsStartDone?: (lcsManager?: LanguageClientManager) => void;
|
|
23
26
|
onTextChanged?: (textChanges: TextContents) => void;
|
|
27
|
+
onConfigProcessed?: (editorApp?: EditorApp) => void;
|
|
24
28
|
onError?: (error: Error) => void;
|
|
25
29
|
onDisposeEditor?: () => void;
|
|
26
30
|
onDisposeLanguageClient?: () => void;
|
|
27
31
|
modifiedTextValue?: string;
|
|
28
32
|
originalTextValue?: string;
|
|
33
|
+
logLevel?: LogLevel | number;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
// All must be outside of the component as they ars valid across all instances and should not be re-created
|
|
32
37
|
let apiWrapper: MonacoVscodeApiWrapper | undefined;
|
|
33
38
|
const lcsManager = new LanguageClientManager();
|
|
34
39
|
const haveEditorService = () => {
|
|
35
|
-
return
|
|
40
|
+
return getEnhancedMonacoEnvironment().viewServiceType === 'EditorService';
|
|
36
41
|
};
|
|
42
|
+
const logger = new ConsoleLogger(LogLevel.Debug);
|
|
37
43
|
|
|
38
44
|
const runQueue: Array<{id: string, func: () => Promise<void>}> = [];
|
|
39
|
-
let
|
|
40
|
-
let
|
|
45
|
+
let lock = true;
|
|
46
|
+
let intervalId: number | unknown | undefined = undefined;
|
|
47
|
+
|
|
48
|
+
const addQueue = (id: string, func: () => Promise<void>) => {
|
|
49
|
+
debugLogging('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
|
|
50
|
+
debugLogging(`Adding to queue: ${id}: QUEUE SIZE before: ${runQueue.length}`);
|
|
51
|
+
runQueue.push({id, func});
|
|
52
|
+
|
|
53
|
+
kickQueue();
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const executeQueue = async () => {
|
|
57
|
+
console.log(`Queue size: ${runQueue.length}`);
|
|
58
|
+
|
|
59
|
+
if (runQueue.length > 0) {
|
|
60
|
+
lock = true;
|
|
61
|
+
while (runQueue.length > 0) {
|
|
62
|
+
const lengthBefore = runQueue.length;
|
|
63
|
+
const queueObj = runQueue.shift();
|
|
64
|
+
debugLogging('<<<<<<<<<<<<<<<<<<<<<<<<<<<<<');
|
|
65
|
+
debugLogging(`QUEUE ${queueObj?.id} start: SIZE before: ${lengthBefore}`, true);
|
|
66
|
+
await queueObj?.func();
|
|
67
|
+
debugLogging(`QUEUE ${queueObj?.id} end: SIZE after: ${runQueue.length}`);
|
|
68
|
+
}
|
|
69
|
+
lock = false;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const kickQueue = () => {
|
|
74
|
+
if (intervalId === undefined && runQueue.length > 0) {
|
|
75
|
+
intervalId = setInterval(async () => {
|
|
76
|
+
debugLogging('Checking queue...');
|
|
77
|
+
if (!lock) {
|
|
78
|
+
executeQueue();
|
|
79
|
+
stopQueue();
|
|
80
|
+
}
|
|
81
|
+
}, 50);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const stopQueue = () => {
|
|
86
|
+
if (intervalId !== undefined && runQueue.length === 0) {
|
|
87
|
+
debugLogging('Stopping queue...');
|
|
88
|
+
clearInterval(intervalId as number);
|
|
89
|
+
intervalId = undefined;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const debugLogging = (id: string, useTime?: boolean) => {
|
|
94
|
+
if (useTime === true) {
|
|
95
|
+
logger.debug(`${id}: ${Date.now()}`);
|
|
96
|
+
} else {
|
|
97
|
+
logger.debug(id);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
41
100
|
|
|
42
101
|
export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
|
|
43
102
|
const {
|
|
@@ -51,60 +110,22 @@ export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
|
|
|
51
110
|
onEditorStartDone,
|
|
52
111
|
onLanguageClientsStartDone,
|
|
53
112
|
onTextChanged,
|
|
113
|
+
onConfigProcessed,
|
|
54
114
|
onError,
|
|
55
115
|
onDisposeEditor,
|
|
56
116
|
onDisposeLanguageClient,
|
|
57
117
|
modifiedTextValue,
|
|
58
|
-
originalTextValue
|
|
118
|
+
originalTextValue,
|
|
119
|
+
logLevel
|
|
59
120
|
} = props;
|
|
60
121
|
|
|
61
|
-
const currentEditorConfig = useRef<EditorAppConfig | undefined>(undefined);
|
|
62
122
|
const editorAppRef = useRef<EditorApp>(undefined);
|
|
63
123
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
64
124
|
const onTextChangedRef = useRef(onTextChanged);
|
|
65
125
|
const modifiedCode = useRef<string>(modifiedTextValue);
|
|
66
126
|
const originalCode = useRef<string>(originalTextValue);
|
|
67
|
-
|
|
68
|
-
const
|
|
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
|
-
};
|
|
127
|
+
const launchingRef = useRef<boolean>(false);
|
|
128
|
+
const editorAppConfigRef = useRef<EditorAppConfig>(undefined);
|
|
108
129
|
|
|
109
130
|
const performErrorHandling = (error: Error) => {
|
|
110
131
|
if (onError) {
|
|
@@ -145,7 +166,7 @@ export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
|
|
|
145
166
|
debugLogging('GLOBAL INIT', true);
|
|
146
167
|
if (apiWrapper === undefined) throw new Error('Unexpected error occurred: apiWrapper is not available! Aborting...');
|
|
147
168
|
|
|
148
|
-
if (
|
|
169
|
+
if (apiWrapper.getMonacoVscodeApiConfig().viewsConfig.$type === 'EditorService') {
|
|
149
170
|
apiWrapper.overrideViewsConfig({
|
|
150
171
|
$type: 'EditorService',
|
|
151
172
|
htmlContainer: containerRef.current!
|
|
@@ -153,43 +174,29 @@ export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
|
|
|
153
174
|
}
|
|
154
175
|
await apiWrapper.start();
|
|
155
176
|
|
|
156
|
-
lcsManager.setLogger(apiWrapper.getLogger());
|
|
157
|
-
|
|
158
177
|
onVscodeApiInitDone?.(apiWrapper);
|
|
159
|
-
triggerQueue();
|
|
160
178
|
debugLogging('GLOBAL INIT DONE', true);
|
|
179
|
+
|
|
180
|
+
lock = false;
|
|
161
181
|
} catch (error) {
|
|
162
182
|
performErrorHandling(error as Error);
|
|
163
183
|
}
|
|
164
184
|
};
|
|
165
185
|
globalInitFunc();
|
|
166
|
-
} else if (envEnhanced.vscodeApiInitialised === true) {
|
|
167
|
-
triggerQueue();
|
|
168
186
|
}
|
|
169
187
|
};
|
|
170
188
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
189
|
+
const editorInitFunc = async () => {
|
|
190
|
+
try {
|
|
191
|
+
debugLogging('INIT', true);
|
|
174
192
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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()) {
|
|
193
|
+
// it is possible to run without an editorApp, for example when using the ViewsService
|
|
194
|
+
if (haveEditorService()) {
|
|
195
|
+
if (editorAppRef.current === undefined && !launchingRef.current) {
|
|
196
|
+
launchingRef.current = true;
|
|
187
197
|
debugLogging('INIT: Creating editor', true);
|
|
188
198
|
|
|
189
|
-
editorAppRef.current
|
|
190
|
-
|
|
191
|
-
currentEditorConfig.current = editorAppConfig;
|
|
192
|
-
editorAppRef.current = new EditorApp(editorAppConfig);
|
|
199
|
+
editorAppRef.current = new EditorApp(editorAppConfigRef.current);
|
|
193
200
|
if (editorAppRef.current.isStarting() === true || editorAppRef.current.isDisposing() === true) {
|
|
194
201
|
await Promise.all([
|
|
195
202
|
editorAppRef.current.getStartingAwait(),
|
|
@@ -211,14 +218,49 @@ export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
|
|
|
211
218
|
await editorAppRef.current.start(containerRef.current!);
|
|
212
219
|
|
|
213
220
|
onEditorStartDone?.(editorAppRef.current);
|
|
221
|
+
launchingRef.current = false;
|
|
214
222
|
}
|
|
223
|
+
}
|
|
215
224
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
225
|
+
debugLogging('INIT DONE', true);
|
|
226
|
+
} catch (error) {
|
|
227
|
+
performErrorHandling(error as Error);
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
const configProcessedFunc = () => {
|
|
232
|
+
if (!launchingRef.current) {
|
|
233
|
+
if (editorAppConfigRef.current?.codeResources !== undefined && editorAppRef.current) {
|
|
234
|
+
editorAppRef.current.updateCodeResources(editorAppConfigRef.current.codeResources);
|
|
219
235
|
}
|
|
220
|
-
|
|
236
|
+
if (editorAppConfigRef.current?.editorOptions !== undefined && editorAppRef.current) {
|
|
237
|
+
if (!editorAppRef.current.isDiffEditor()) {
|
|
238
|
+
editorAppRef.current.getEditor()?.updateOptions(editorAppConfigRef.current.editorOptions as monaco.editor.IEditorOptions);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (editorAppConfigRef.current?.diffEditorOptions !== undefined && editorAppRef.current) {
|
|
242
|
+
if (editorAppRef.current.isDiffEditor()) {
|
|
243
|
+
editorAppRef.current.getDiffEditor()?.updateOptions(editorAppConfigRef.current.diffEditorOptions as monaco.editor.IDiffEditorOptions);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
onConfigProcessed?.(editorAppRef.current);
|
|
248
|
+
debugLogging('Config processed');
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
useEffect(() => {
|
|
252
|
+
// fast-fail
|
|
253
|
+
if (editorAppConfig === undefined) return;
|
|
254
|
+
|
|
255
|
+
// always try to perform global init. Reason: we cannot ensure order
|
|
256
|
+
performGlobalInit();
|
|
257
|
+
|
|
258
|
+
editorAppConfigRef.current = editorAppConfig;
|
|
259
|
+
|
|
221
260
|
addQueue('editorInit', editorInitFunc);
|
|
261
|
+
if (editorAppRef.current !== undefined && !launchingRef.current) {
|
|
262
|
+
configProcessedFunc();
|
|
263
|
+
}
|
|
222
264
|
}, [editorAppConfig]);
|
|
223
265
|
|
|
224
266
|
useEffect(() => {
|
|
@@ -230,8 +272,9 @@ export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
|
|
|
230
272
|
|
|
231
273
|
const lcInitFunc = async () => {
|
|
232
274
|
try {
|
|
233
|
-
debugLogging('INIT
|
|
275
|
+
debugLogging('INIT LC', true);
|
|
234
276
|
|
|
277
|
+
lcsManager.setLogLevel(languageClientConfig.logLevel);
|
|
235
278
|
await lcsManager.setConfig(languageClientConfig);
|
|
236
279
|
await lcsManager.start();
|
|
237
280
|
|
|
@@ -257,9 +300,11 @@ export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
|
|
|
257
300
|
// dispose editor if used
|
|
258
301
|
debugLogging('DISPOSE', true);
|
|
259
302
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
303
|
+
if (editorAppRef.current !== undefined) {
|
|
304
|
+
await editorAppRef.current.dispose();
|
|
305
|
+
editorAppRef.current = undefined;
|
|
306
|
+
onDisposeEditor?.();
|
|
307
|
+
}
|
|
263
308
|
|
|
264
309
|
debugLogging('DISPOSE DONE', true);
|
|
265
310
|
};
|
|
@@ -267,6 +312,12 @@ export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
|
|
|
267
312
|
};
|
|
268
313
|
}, []);
|
|
269
314
|
|
|
315
|
+
useEffect(() => {
|
|
316
|
+
if (logLevel !== undefined) {
|
|
317
|
+
logger.setLevel(logLevel);
|
|
318
|
+
}
|
|
319
|
+
}, [logLevel]);
|
|
320
|
+
|
|
270
321
|
useEffect(() => {
|
|
271
322
|
// always try to perform global init. Reason: we cannot ensure order
|
|
272
323
|
performGlobalInit();
|