@lvce-editor/editor-worker 7.2.0 → 7.4.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/dist/editorWorkerMain.js +1226 -1309
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1,406 +1,3 @@
|
|
|
1
|
-
const commands = Object.create(null);
|
|
2
|
-
const register = commandMap => {
|
|
3
|
-
Object.assign(commands, commandMap);
|
|
4
|
-
};
|
|
5
|
-
const getCommand = key => {
|
|
6
|
-
return commands[key];
|
|
7
|
-
};
|
|
8
|
-
const execute$1 = (command, ...args) => {
|
|
9
|
-
const fn = getCommand(command);
|
|
10
|
-
if (!fn) {
|
|
11
|
-
throw new Error(`command not found ${command}`);
|
|
12
|
-
}
|
|
13
|
-
return fn(...args);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const state$9 = {
|
|
17
|
-
/**
|
|
18
|
-
* @type {any}
|
|
19
|
-
*/
|
|
20
|
-
ipc: undefined
|
|
21
|
-
};
|
|
22
|
-
const get$7 = () => {
|
|
23
|
-
return state$9.ipc;
|
|
24
|
-
};
|
|
25
|
-
const set$7 = ipc => {
|
|
26
|
-
state$9.ipc = ipc;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const Two = '2.0';
|
|
30
|
-
const create$4$1 = (method, params) => {
|
|
31
|
-
return {
|
|
32
|
-
jsonrpc: Two,
|
|
33
|
-
method,
|
|
34
|
-
params
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
const callbacks = Object.create(null);
|
|
38
|
-
const set$6 = (id, fn) => {
|
|
39
|
-
callbacks[id] = fn;
|
|
40
|
-
};
|
|
41
|
-
const get$6 = id => {
|
|
42
|
-
return callbacks[id];
|
|
43
|
-
};
|
|
44
|
-
const remove$8 = id => {
|
|
45
|
-
delete callbacks[id];
|
|
46
|
-
};
|
|
47
|
-
let id = 0;
|
|
48
|
-
const create$3$1 = () => {
|
|
49
|
-
return ++id;
|
|
50
|
-
};
|
|
51
|
-
const registerPromise = () => {
|
|
52
|
-
const id = create$3$1();
|
|
53
|
-
const {
|
|
54
|
-
resolve,
|
|
55
|
-
promise
|
|
56
|
-
} = Promise.withResolvers();
|
|
57
|
-
set$6(id, resolve);
|
|
58
|
-
return {
|
|
59
|
-
id,
|
|
60
|
-
promise
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
const create$2$1 = (method, params) => {
|
|
64
|
-
const {
|
|
65
|
-
id,
|
|
66
|
-
promise
|
|
67
|
-
} = registerPromise();
|
|
68
|
-
const message = {
|
|
69
|
-
jsonrpc: Two,
|
|
70
|
-
method,
|
|
71
|
-
params,
|
|
72
|
-
id
|
|
73
|
-
};
|
|
74
|
-
return {
|
|
75
|
-
message,
|
|
76
|
-
promise
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
class JsonRpcError extends Error {
|
|
80
|
-
constructor(message) {
|
|
81
|
-
super(message);
|
|
82
|
-
this.name = 'JsonRpcError';
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
const NewLine$3 = '\n';
|
|
86
|
-
const DomException = 'DOMException';
|
|
87
|
-
const ReferenceError$1 = 'ReferenceError';
|
|
88
|
-
const SyntaxError$1 = 'SyntaxError';
|
|
89
|
-
const TypeError$1 = 'TypeError';
|
|
90
|
-
const getErrorConstructor = (message, type) => {
|
|
91
|
-
if (type) {
|
|
92
|
-
switch (type) {
|
|
93
|
-
case DomException:
|
|
94
|
-
return DOMException;
|
|
95
|
-
case TypeError$1:
|
|
96
|
-
return TypeError;
|
|
97
|
-
case SyntaxError$1:
|
|
98
|
-
return SyntaxError;
|
|
99
|
-
case ReferenceError$1:
|
|
100
|
-
return ReferenceError;
|
|
101
|
-
default:
|
|
102
|
-
return Error;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (message.startsWith('TypeError: ')) {
|
|
106
|
-
return TypeError;
|
|
107
|
-
}
|
|
108
|
-
if (message.startsWith('SyntaxError: ')) {
|
|
109
|
-
return SyntaxError;
|
|
110
|
-
}
|
|
111
|
-
if (message.startsWith('ReferenceError: ')) {
|
|
112
|
-
return ReferenceError;
|
|
113
|
-
}
|
|
114
|
-
return Error;
|
|
115
|
-
};
|
|
116
|
-
const constructError = (message, type, name) => {
|
|
117
|
-
const ErrorConstructor = getErrorConstructor(message, type);
|
|
118
|
-
if (ErrorConstructor === DOMException && name) {
|
|
119
|
-
return new ErrorConstructor(message, name);
|
|
120
|
-
}
|
|
121
|
-
if (ErrorConstructor === Error) {
|
|
122
|
-
const error = new Error(message);
|
|
123
|
-
if (name && name !== 'VError') {
|
|
124
|
-
error.name = name;
|
|
125
|
-
}
|
|
126
|
-
return error;
|
|
127
|
-
}
|
|
128
|
-
return new ErrorConstructor(message);
|
|
129
|
-
};
|
|
130
|
-
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
131
|
-
return string.indexOf(NewLine$3, startIndex);
|
|
132
|
-
};
|
|
133
|
-
const getParentStack = error => {
|
|
134
|
-
let parentStack = error.stack || error.data || error.message || '';
|
|
135
|
-
if (parentStack.startsWith(' at')) {
|
|
136
|
-
parentStack = error.message + NewLine$3 + parentStack;
|
|
137
|
-
}
|
|
138
|
-
return parentStack;
|
|
139
|
-
};
|
|
140
|
-
const joinLines$2 = lines => {
|
|
141
|
-
return lines.join(NewLine$3);
|
|
142
|
-
};
|
|
143
|
-
const MethodNotFound = -32601;
|
|
144
|
-
const Custom = -32001;
|
|
145
|
-
const splitLines$2 = lines => {
|
|
146
|
-
return lines.split(NewLine$3);
|
|
147
|
-
};
|
|
148
|
-
const restoreJsonRpcError = error => {
|
|
149
|
-
if (error && error instanceof Error) {
|
|
150
|
-
return error;
|
|
151
|
-
}
|
|
152
|
-
const currentStack = joinLines$2(splitLines$2(new Error().stack || '').slice(1));
|
|
153
|
-
if (error && error.code && error.code === MethodNotFound) {
|
|
154
|
-
const restoredError = new JsonRpcError(error.message);
|
|
155
|
-
const parentStack = getParentStack(error);
|
|
156
|
-
restoredError.stack = parentStack + NewLine$3 + currentStack;
|
|
157
|
-
return restoredError;
|
|
158
|
-
}
|
|
159
|
-
if (error && error.message) {
|
|
160
|
-
const restoredError = constructError(error.message, error.type, error.name);
|
|
161
|
-
if (error.data) {
|
|
162
|
-
if (error.data.stack && error.data.type && error.message) {
|
|
163
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine$3 + error.data.stack + NewLine$3 + currentStack;
|
|
164
|
-
} else if (error.data.stack) {
|
|
165
|
-
restoredError.stack = error.data.stack;
|
|
166
|
-
}
|
|
167
|
-
if (error.data.codeFrame) {
|
|
168
|
-
// @ts-ignore
|
|
169
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
170
|
-
}
|
|
171
|
-
if (error.data.code) {
|
|
172
|
-
// @ts-ignore
|
|
173
|
-
restoredError.code = error.data.code;
|
|
174
|
-
}
|
|
175
|
-
if (error.data.type) {
|
|
176
|
-
// @ts-ignore
|
|
177
|
-
restoredError.name = error.data.type;
|
|
178
|
-
}
|
|
179
|
-
} else {
|
|
180
|
-
if (error.stack) {
|
|
181
|
-
const lowerStack = restoredError.stack || '';
|
|
182
|
-
// @ts-ignore
|
|
183
|
-
const indexNewLine = getNewLineIndex$1(lowerStack);
|
|
184
|
-
const parentStack = getParentStack(error);
|
|
185
|
-
// @ts-ignore
|
|
186
|
-
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
187
|
-
}
|
|
188
|
-
if (error.codeFrame) {
|
|
189
|
-
// @ts-ignore
|
|
190
|
-
restoredError.codeFrame = error.codeFrame;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return restoredError;
|
|
194
|
-
}
|
|
195
|
-
if (typeof error === 'string') {
|
|
196
|
-
return new Error(`JsonRpc Error: ${error}`);
|
|
197
|
-
}
|
|
198
|
-
return new Error(`JsonRpc Error: ${error}`);
|
|
199
|
-
};
|
|
200
|
-
const unwrapJsonRpcResult = responseMessage => {
|
|
201
|
-
if ('error' in responseMessage) {
|
|
202
|
-
const restoredError = restoreJsonRpcError(responseMessage.error);
|
|
203
|
-
throw restoredError;
|
|
204
|
-
}
|
|
205
|
-
if ('result' in responseMessage) {
|
|
206
|
-
return responseMessage.result;
|
|
207
|
-
}
|
|
208
|
-
throw new JsonRpcError('unexpected response message');
|
|
209
|
-
};
|
|
210
|
-
const warn$1 = (...args) => {
|
|
211
|
-
console.warn(...args);
|
|
212
|
-
};
|
|
213
|
-
const resolve = (id, response) => {
|
|
214
|
-
const fn = get$6(id);
|
|
215
|
-
if (!fn) {
|
|
216
|
-
console.log(response);
|
|
217
|
-
warn$1(`callback ${id} may already be disposed`);
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
fn(response);
|
|
221
|
-
remove$8(id);
|
|
222
|
-
};
|
|
223
|
-
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
224
|
-
const getErrorType = prettyError => {
|
|
225
|
-
if (prettyError && prettyError.type) {
|
|
226
|
-
return prettyError.type;
|
|
227
|
-
}
|
|
228
|
-
if (prettyError && prettyError.constructor && prettyError.constructor.name) {
|
|
229
|
-
return prettyError.constructor.name;
|
|
230
|
-
}
|
|
231
|
-
return undefined;
|
|
232
|
-
};
|
|
233
|
-
const getErrorProperty = (error, prettyError) => {
|
|
234
|
-
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
235
|
-
return {
|
|
236
|
-
code: MethodNotFound,
|
|
237
|
-
message: error.message,
|
|
238
|
-
data: error.stack
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
return {
|
|
242
|
-
code: Custom,
|
|
243
|
-
message: prettyError.message,
|
|
244
|
-
data: {
|
|
245
|
-
stack: prettyError.stack,
|
|
246
|
-
codeFrame: prettyError.codeFrame,
|
|
247
|
-
type: getErrorType(prettyError),
|
|
248
|
-
code: prettyError.code,
|
|
249
|
-
name: prettyError.name
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
};
|
|
253
|
-
const create$1$1 = (message, error) => {
|
|
254
|
-
return {
|
|
255
|
-
jsonrpc: Two,
|
|
256
|
-
id: message.id,
|
|
257
|
-
error
|
|
258
|
-
};
|
|
259
|
-
};
|
|
260
|
-
const getErrorResponse = (message, error, preparePrettyError, logError) => {
|
|
261
|
-
const prettyError = preparePrettyError(error);
|
|
262
|
-
logError(error, prettyError);
|
|
263
|
-
const errorProperty = getErrorProperty(error, prettyError);
|
|
264
|
-
return create$1$1(message, errorProperty);
|
|
265
|
-
};
|
|
266
|
-
const create$d = (message, result) => {
|
|
267
|
-
return {
|
|
268
|
-
jsonrpc: Two,
|
|
269
|
-
id: message.id,
|
|
270
|
-
result: result ?? null
|
|
271
|
-
};
|
|
272
|
-
};
|
|
273
|
-
const getSuccessResponse = (message, result) => {
|
|
274
|
-
const resultProperty = result ?? null;
|
|
275
|
-
return create$d(message, resultProperty);
|
|
276
|
-
};
|
|
277
|
-
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
278
|
-
try {
|
|
279
|
-
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
280
|
-
return getSuccessResponse(message, result);
|
|
281
|
-
} catch (error) {
|
|
282
|
-
return getErrorResponse(message, error, preparePrettyError, logError);
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
const defaultPreparePrettyError = error => {
|
|
286
|
-
return error;
|
|
287
|
-
};
|
|
288
|
-
const defaultLogError = () => {
|
|
289
|
-
// ignore
|
|
290
|
-
};
|
|
291
|
-
const defaultRequiresSocket = () => {
|
|
292
|
-
return false;
|
|
293
|
-
};
|
|
294
|
-
const defaultResolve = resolve;
|
|
295
|
-
|
|
296
|
-
// TODO maybe remove this in v6 or v7, only accept options object to simplify the code
|
|
297
|
-
const normalizeParams = args => {
|
|
298
|
-
if (args.length === 1) {
|
|
299
|
-
const options = args[0];
|
|
300
|
-
return {
|
|
301
|
-
ipc: options.ipc,
|
|
302
|
-
message: options.message,
|
|
303
|
-
execute: options.execute,
|
|
304
|
-
resolve: options.resolve || defaultResolve,
|
|
305
|
-
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
306
|
-
logError: options.logError || defaultLogError,
|
|
307
|
-
requiresSocket: options.requiresSocket || defaultRequiresSocket
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
return {
|
|
311
|
-
ipc: args[0],
|
|
312
|
-
message: args[1],
|
|
313
|
-
execute: args[2],
|
|
314
|
-
resolve: args[3],
|
|
315
|
-
preparePrettyError: args[4],
|
|
316
|
-
logError: args[5],
|
|
317
|
-
requiresSocket: args[6]
|
|
318
|
-
};
|
|
319
|
-
};
|
|
320
|
-
const handleJsonRpcMessage = async (...args) => {
|
|
321
|
-
const options = normalizeParams(args);
|
|
322
|
-
const {
|
|
323
|
-
message,
|
|
324
|
-
ipc,
|
|
325
|
-
execute,
|
|
326
|
-
resolve,
|
|
327
|
-
preparePrettyError,
|
|
328
|
-
logError,
|
|
329
|
-
requiresSocket
|
|
330
|
-
} = options;
|
|
331
|
-
if ('id' in message) {
|
|
332
|
-
if ('method' in message) {
|
|
333
|
-
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
334
|
-
try {
|
|
335
|
-
ipc.send(response);
|
|
336
|
-
} catch (error) {
|
|
337
|
-
const errorResponse = getErrorResponse(message, error, preparePrettyError, logError);
|
|
338
|
-
ipc.send(errorResponse);
|
|
339
|
-
}
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
resolve(message.id, message);
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
if ('method' in message) {
|
|
346
|
-
await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
347
|
-
return;
|
|
348
|
-
}
|
|
349
|
-
throw new JsonRpcError('unexpected message');
|
|
350
|
-
};
|
|
351
|
-
const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
352
|
-
const {
|
|
353
|
-
message,
|
|
354
|
-
promise
|
|
355
|
-
} = create$2$1(method, params);
|
|
356
|
-
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
357
|
-
ipc.sendAndTransfer(message);
|
|
358
|
-
} else {
|
|
359
|
-
ipc.send(message);
|
|
360
|
-
}
|
|
361
|
-
const responseMessage = await promise;
|
|
362
|
-
return unwrapJsonRpcResult(responseMessage);
|
|
363
|
-
};
|
|
364
|
-
const send = (transport, method, ...params) => {
|
|
365
|
-
const message = create$4$1(method, params);
|
|
366
|
-
transport.send(message);
|
|
367
|
-
};
|
|
368
|
-
const invoke$9 = (ipc, method, ...params) => {
|
|
369
|
-
return invokeHelper(ipc, method, params, false);
|
|
370
|
-
};
|
|
371
|
-
const invokeAndTransfer$2 = (ipc, method, ...params) => {
|
|
372
|
-
return invokeHelper(ipc, method, params, true);
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
const invoke$8 = async (method, ...params) => {
|
|
376
|
-
const ipc = get$7();
|
|
377
|
-
return invoke$9(ipc, method, ...params);
|
|
378
|
-
};
|
|
379
|
-
const invokeAndTransfer$1 = async (method, ...params) => {
|
|
380
|
-
const ipc = get$7();
|
|
381
|
-
return invokeAndTransfer$2(ipc, method, ...params);
|
|
382
|
-
};
|
|
383
|
-
const listen$5 = ipc => {
|
|
384
|
-
set$7(ipc);
|
|
385
|
-
};
|
|
386
|
-
|
|
387
|
-
const invoke$7 = async (method, ...params) => {
|
|
388
|
-
return invoke$8(method, ...params);
|
|
389
|
-
};
|
|
390
|
-
const invokeAndTransfer = async (method, ...params) => {
|
|
391
|
-
return invokeAndTransfer$1(method, ...params);
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
// TODO add tests for this
|
|
395
|
-
const activateByEvent = async event => {
|
|
396
|
-
await invoke$7('ExtensionHostManagement.activateByEvent', event);
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
const codeGeneratorAccept = state => {
|
|
400
|
-
// TODO close code generator widget
|
|
401
|
-
return state;
|
|
402
|
-
};
|
|
403
|
-
|
|
404
1
|
const normalizeLine = line => {
|
|
405
2
|
if (line.startsWith('Error: ')) {
|
|
406
3
|
return line.slice('Error: '.length);
|
|
@@ -417,16 +14,16 @@ const getCombinedMessage = (error, message) => {
|
|
|
417
14
|
}
|
|
418
15
|
return stringifiedError;
|
|
419
16
|
};
|
|
420
|
-
const NewLine$
|
|
421
|
-
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
422
|
-
return string.indexOf(NewLine$
|
|
17
|
+
const NewLine$3 = '\n';
|
|
18
|
+
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
19
|
+
return string.indexOf(NewLine$3, startIndex);
|
|
423
20
|
};
|
|
424
21
|
const mergeStacks = (parent, child) => {
|
|
425
22
|
if (!child) {
|
|
426
23
|
return parent;
|
|
427
24
|
}
|
|
428
|
-
const parentNewLineIndex = getNewLineIndex(parent);
|
|
429
|
-
const childNewLineIndex = getNewLineIndex(child);
|
|
25
|
+
const parentNewLineIndex = getNewLineIndex$1(parent);
|
|
26
|
+
const childNewLineIndex = getNewLineIndex$1(child);
|
|
430
27
|
if (childNewLineIndex === -1) {
|
|
431
28
|
return parent;
|
|
432
29
|
}
|
|
@@ -589,9 +186,9 @@ class Ipc extends EventTarget {
|
|
|
589
186
|
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
590
187
|
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
591
188
|
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
592
|
-
const NewLine$
|
|
593
|
-
const joinLines$
|
|
594
|
-
return lines.join(NewLine$
|
|
189
|
+
const NewLine$2 = '\n';
|
|
190
|
+
const joinLines$2 = lines => {
|
|
191
|
+
return lines.join(NewLine$2);
|
|
595
192
|
};
|
|
596
193
|
const RE_AT = /^\s+at/;
|
|
597
194
|
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
@@ -602,7 +199,7 @@ const getDetails = lines => {
|
|
|
602
199
|
const index = lines.findIndex(isNormalStackLine);
|
|
603
200
|
if (index === -1) {
|
|
604
201
|
return {
|
|
605
|
-
actualMessage: joinLines$
|
|
202
|
+
actualMessage: joinLines$2(lines),
|
|
606
203
|
rest: []
|
|
607
204
|
};
|
|
608
205
|
}
|
|
@@ -617,8 +214,8 @@ const getDetails = lines => {
|
|
|
617
214
|
rest: lines.slice(index, lastIndex)
|
|
618
215
|
};
|
|
619
216
|
};
|
|
620
|
-
const splitLines$
|
|
621
|
-
return lines.split(NewLine$
|
|
217
|
+
const splitLines$2 = lines => {
|
|
218
|
+
return lines.split(NewLine$2);
|
|
622
219
|
};
|
|
623
220
|
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
624
221
|
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
@@ -629,7 +226,7 @@ const isMessageCodeBlockEndIndex = line => {
|
|
|
629
226
|
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
630
227
|
};
|
|
631
228
|
const getMessageCodeBlock = stderr => {
|
|
632
|
-
const lines = splitLines$
|
|
229
|
+
const lines = splitLines$2(stderr);
|
|
633
230
|
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
634
231
|
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
635
232
|
const relevantLines = lines.slice(startIndex, endIndex);
|
|
@@ -640,7 +237,7 @@ const isModuleNotFoundMessage = line => {
|
|
|
640
237
|
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
641
238
|
};
|
|
642
239
|
const getModuleNotFoundError = stderr => {
|
|
643
|
-
const lines = splitLines$
|
|
240
|
+
const lines = splitLines$2(stderr);
|
|
644
241
|
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
645
242
|
const message = lines[messageIndex];
|
|
646
243
|
return {
|
|
@@ -688,7 +285,7 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
688
285
|
if (isModuleNotFoundError(stderr)) {
|
|
689
286
|
return getModuleNotFoundError(stderr);
|
|
690
287
|
}
|
|
691
|
-
const lines = splitLines$
|
|
288
|
+
const lines = splitLines$2(stderr);
|
|
692
289
|
const {
|
|
693
290
|
actualMessage,
|
|
694
291
|
rest
|
|
@@ -699,7 +296,7 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
699
296
|
stack: rest
|
|
700
297
|
};
|
|
701
298
|
};
|
|
702
|
-
|
|
299
|
+
class IpcError extends VError {
|
|
703
300
|
// @ts-ignore
|
|
704
301
|
constructor(betterMessage, stdout = '', stderr = '') {
|
|
705
302
|
if (stdout || stderr) {
|
|
@@ -724,23 +321,182 @@ let IpcError$1 = class IpcError extends VError {
|
|
|
724
321
|
// @ts-ignore
|
|
725
322
|
this.stderr = stderr;
|
|
726
323
|
}
|
|
727
|
-
}
|
|
324
|
+
}
|
|
728
325
|
const readyMessage = 'ready';
|
|
729
326
|
const getData$2 = event => {
|
|
730
327
|
return event.data;
|
|
731
328
|
};
|
|
732
|
-
const listen$
|
|
733
|
-
|
|
329
|
+
const listen$7 = () => {
|
|
330
|
+
// @ts-ignore
|
|
331
|
+
if (typeof WorkerGlobalScope === 'undefined') {
|
|
332
|
+
throw new TypeError('module is not in web worker scope');
|
|
333
|
+
}
|
|
334
|
+
return globalThis;
|
|
335
|
+
};
|
|
336
|
+
const signal$8 = global => {
|
|
337
|
+
global.postMessage(readyMessage);
|
|
338
|
+
};
|
|
339
|
+
class IpcChildWithModuleWorker extends Ipc {
|
|
340
|
+
getData(event) {
|
|
341
|
+
return getData$2(event);
|
|
342
|
+
}
|
|
343
|
+
send(message) {
|
|
344
|
+
// @ts-ignore
|
|
345
|
+
this._rawIpc.postMessage(message);
|
|
346
|
+
}
|
|
347
|
+
sendAndTransfer(message) {
|
|
348
|
+
const transfer = getTransferrables(message);
|
|
349
|
+
// @ts-ignore
|
|
350
|
+
this._rawIpc.postMessage(message, transfer);
|
|
351
|
+
}
|
|
352
|
+
dispose() {
|
|
353
|
+
// ignore
|
|
354
|
+
}
|
|
355
|
+
onClose(callback) {
|
|
356
|
+
// ignore
|
|
357
|
+
}
|
|
358
|
+
onMessage(callback) {
|
|
359
|
+
this._rawIpc.addEventListener('message', callback);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
const wrap$f = global => {
|
|
363
|
+
return new IpcChildWithModuleWorker(global);
|
|
364
|
+
};
|
|
365
|
+
const waitForFirstMessage = async port => {
|
|
366
|
+
const {
|
|
367
|
+
resolve,
|
|
368
|
+
promise
|
|
369
|
+
} = Promise.withResolvers();
|
|
370
|
+
port.addEventListener('message', resolve, {
|
|
371
|
+
once: true
|
|
372
|
+
});
|
|
373
|
+
const event = await promise;
|
|
374
|
+
// @ts-ignore
|
|
375
|
+
return event.data;
|
|
376
|
+
};
|
|
377
|
+
const listen$6 = async () => {
|
|
378
|
+
const parentIpcRaw = listen$7();
|
|
379
|
+
signal$8(parentIpcRaw);
|
|
380
|
+
const parentIpc = wrap$f(parentIpcRaw);
|
|
381
|
+
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
382
|
+
if (firstMessage.method !== 'initialize') {
|
|
383
|
+
throw new IpcError('unexpected first message');
|
|
384
|
+
}
|
|
385
|
+
const type = firstMessage.params[0];
|
|
386
|
+
if (type === 'message-port') {
|
|
387
|
+
parentIpc.send({
|
|
388
|
+
jsonrpc: '2.0',
|
|
389
|
+
id: firstMessage.id,
|
|
390
|
+
result: null
|
|
391
|
+
});
|
|
392
|
+
parentIpc.dispose();
|
|
393
|
+
const port = firstMessage.params[1];
|
|
394
|
+
return port;
|
|
395
|
+
}
|
|
396
|
+
return globalThis;
|
|
397
|
+
};
|
|
398
|
+
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
399
|
+
getData(event) {
|
|
400
|
+
return getData$2(event);
|
|
401
|
+
}
|
|
402
|
+
send(message) {
|
|
403
|
+
this._rawIpc.postMessage(message);
|
|
404
|
+
}
|
|
405
|
+
sendAndTransfer(message) {
|
|
406
|
+
const transfer = getTransferrables(message);
|
|
407
|
+
this._rawIpc.postMessage(message, transfer);
|
|
408
|
+
}
|
|
409
|
+
dispose() {
|
|
410
|
+
if (this._rawIpc.close) {
|
|
411
|
+
this._rawIpc.close();
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
onClose(callback) {
|
|
415
|
+
// ignore
|
|
416
|
+
}
|
|
417
|
+
onMessage(callback) {
|
|
418
|
+
this._rawIpc.addEventListener('message', callback);
|
|
419
|
+
this._rawIpc.start();
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
const wrap$e = port => {
|
|
423
|
+
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
424
|
+
};
|
|
425
|
+
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
426
|
+
__proto__: null,
|
|
427
|
+
listen: listen$6,
|
|
428
|
+
wrap: wrap$e
|
|
429
|
+
};
|
|
430
|
+
const addListener = (emitter, type, callback) => {
|
|
431
|
+
if ('addEventListener' in emitter) {
|
|
432
|
+
emitter.addEventListener(type, callback);
|
|
433
|
+
} else {
|
|
434
|
+
emitter.on(type, callback);
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
const removeListener = (emitter, type, callback) => {
|
|
438
|
+
if ('removeEventListener' in emitter) {
|
|
439
|
+
emitter.removeEventListener(type, callback);
|
|
440
|
+
} else {
|
|
441
|
+
emitter.off(type, callback);
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
445
|
+
const {
|
|
446
|
+
resolve,
|
|
447
|
+
promise
|
|
448
|
+
} = Promise.withResolvers();
|
|
449
|
+
const listenerMap = Object.create(null);
|
|
450
|
+
const cleanup = value => {
|
|
451
|
+
for (const event of Object.keys(eventMap)) {
|
|
452
|
+
removeListener(eventEmitter, event, listenerMap[event]);
|
|
453
|
+
}
|
|
454
|
+
resolve(value);
|
|
455
|
+
};
|
|
456
|
+
for (const [event, type] of Object.entries(eventMap)) {
|
|
457
|
+
const listener = event => {
|
|
458
|
+
cleanup({
|
|
459
|
+
type,
|
|
460
|
+
event
|
|
461
|
+
});
|
|
462
|
+
};
|
|
463
|
+
addListener(eventEmitter, event, listener);
|
|
464
|
+
listenerMap[event] = listener;
|
|
465
|
+
}
|
|
466
|
+
return promise;
|
|
467
|
+
};
|
|
468
|
+
const Message$1 = 3;
|
|
469
|
+
const create$5$1 = async ({
|
|
470
|
+
messagePort,
|
|
471
|
+
isMessagePortOpen
|
|
734
472
|
}) => {
|
|
735
|
-
|
|
473
|
+
if (!isMessagePort(messagePort)) {
|
|
474
|
+
throw new IpcError('port must be of type MessagePort');
|
|
475
|
+
}
|
|
476
|
+
if (isMessagePortOpen) {
|
|
477
|
+
return messagePort;
|
|
478
|
+
}
|
|
479
|
+
const eventPromise = getFirstEvent(messagePort, {
|
|
480
|
+
message: Message$1
|
|
481
|
+
});
|
|
482
|
+
messagePort.start();
|
|
483
|
+
const {
|
|
484
|
+
type,
|
|
485
|
+
event
|
|
486
|
+
} = await eventPromise;
|
|
487
|
+
if (type !== Message$1) {
|
|
488
|
+
throw new IpcError('Failed to wait for ipc message');
|
|
489
|
+
}
|
|
490
|
+
if (event.data !== readyMessage) {
|
|
491
|
+
throw new IpcError('unexpected first message');
|
|
492
|
+
}
|
|
493
|
+
return messagePort;
|
|
736
494
|
};
|
|
737
|
-
const signal$
|
|
738
|
-
|
|
495
|
+
const signal$1 = messagePort => {
|
|
496
|
+
messagePort.start();
|
|
739
497
|
};
|
|
740
|
-
class
|
|
741
|
-
getData
|
|
742
|
-
return getData$2(event);
|
|
743
|
-
}
|
|
498
|
+
class IpcParentWithMessagePort extends Ipc {
|
|
499
|
+
getData = getData$2;
|
|
744
500
|
send(message) {
|
|
745
501
|
this._rawIpc.postMessage(message);
|
|
746
502
|
}
|
|
@@ -749,228 +505,418 @@ class IpcChildWithMessagePort extends Ipc {
|
|
|
749
505
|
this._rawIpc.postMessage(message, transfer);
|
|
750
506
|
}
|
|
751
507
|
dispose() {
|
|
752
|
-
|
|
753
|
-
}
|
|
754
|
-
onClose(callback) {
|
|
755
|
-
// ignore
|
|
508
|
+
this._rawIpc.close();
|
|
756
509
|
}
|
|
757
510
|
onMessage(callback) {
|
|
758
511
|
this._rawIpc.addEventListener('message', callback);
|
|
759
|
-
this._rawIpc.start();
|
|
760
512
|
}
|
|
513
|
+
onClose(callback) {}
|
|
761
514
|
}
|
|
762
|
-
const wrap$
|
|
763
|
-
return new
|
|
515
|
+
const wrap$5 = messagePort => {
|
|
516
|
+
return new IpcParentWithMessagePort(messagePort);
|
|
764
517
|
};
|
|
765
|
-
const
|
|
518
|
+
const IpcParentWithMessagePort$1 = {
|
|
766
519
|
__proto__: null,
|
|
767
|
-
|
|
768
|
-
signal: signal$
|
|
769
|
-
wrap: wrap$
|
|
520
|
+
create: create$5$1,
|
|
521
|
+
signal: signal$1,
|
|
522
|
+
wrap: wrap$5
|
|
770
523
|
};
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
524
|
+
|
|
525
|
+
const Two = '2.0';
|
|
526
|
+
const create$4$1 = (method, params) => {
|
|
527
|
+
return {
|
|
528
|
+
jsonrpc: Two,
|
|
529
|
+
method,
|
|
530
|
+
params
|
|
531
|
+
};
|
|
777
532
|
};
|
|
778
|
-
const
|
|
779
|
-
|
|
533
|
+
const callbacks = Object.create(null);
|
|
534
|
+
const set$a = (id, fn) => {
|
|
535
|
+
callbacks[id] = fn;
|
|
780
536
|
};
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
537
|
+
const get$7 = id => {
|
|
538
|
+
return callbacks[id];
|
|
539
|
+
};
|
|
540
|
+
const remove$8 = id => {
|
|
541
|
+
delete callbacks[id];
|
|
542
|
+
};
|
|
543
|
+
let id = 0;
|
|
544
|
+
const create$3$2 = () => {
|
|
545
|
+
return ++id;
|
|
546
|
+
};
|
|
547
|
+
const registerPromise = () => {
|
|
548
|
+
const id = create$3$2();
|
|
549
|
+
const {
|
|
550
|
+
resolve,
|
|
551
|
+
promise
|
|
552
|
+
} = Promise.withResolvers();
|
|
553
|
+
set$a(id, resolve);
|
|
554
|
+
return {
|
|
555
|
+
id,
|
|
556
|
+
promise
|
|
557
|
+
};
|
|
558
|
+
};
|
|
559
|
+
const create$2$2 = (method, params) => {
|
|
560
|
+
const {
|
|
561
|
+
id,
|
|
562
|
+
promise
|
|
563
|
+
} = registerPromise();
|
|
564
|
+
const message = {
|
|
565
|
+
jsonrpc: Two,
|
|
566
|
+
method,
|
|
567
|
+
params,
|
|
568
|
+
id
|
|
569
|
+
};
|
|
570
|
+
return {
|
|
571
|
+
message,
|
|
572
|
+
promise
|
|
573
|
+
};
|
|
574
|
+
};
|
|
575
|
+
class JsonRpcError extends Error {
|
|
576
|
+
constructor(message) {
|
|
577
|
+
super(message);
|
|
578
|
+
this.name = 'JsonRpcError';
|
|
784
579
|
}
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
580
|
+
}
|
|
581
|
+
const NewLine$1 = '\n';
|
|
582
|
+
const DomException = 'DOMException';
|
|
583
|
+
const ReferenceError$1 = 'ReferenceError';
|
|
584
|
+
const SyntaxError$1 = 'SyntaxError';
|
|
585
|
+
const TypeError$1 = 'TypeError';
|
|
586
|
+
const getErrorConstructor = (message, type) => {
|
|
587
|
+
if (type) {
|
|
588
|
+
switch (type) {
|
|
589
|
+
case DomException:
|
|
590
|
+
return DOMException;
|
|
591
|
+
case TypeError$1:
|
|
592
|
+
return TypeError;
|
|
593
|
+
case SyntaxError$1:
|
|
594
|
+
return SyntaxError;
|
|
595
|
+
case ReferenceError$1:
|
|
596
|
+
return ReferenceError;
|
|
597
|
+
default:
|
|
598
|
+
return Error;
|
|
599
|
+
}
|
|
788
600
|
}
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
// @ts-ignore
|
|
792
|
-
this._rawIpc.postMessage(message, transfer);
|
|
601
|
+
if (message.startsWith('TypeError: ')) {
|
|
602
|
+
return TypeError;
|
|
793
603
|
}
|
|
794
|
-
|
|
795
|
-
|
|
604
|
+
if (message.startsWith('SyntaxError: ')) {
|
|
605
|
+
return SyntaxError;
|
|
796
606
|
}
|
|
797
|
-
|
|
798
|
-
|
|
607
|
+
if (message.startsWith('ReferenceError: ')) {
|
|
608
|
+
return ReferenceError;
|
|
799
609
|
}
|
|
800
|
-
|
|
801
|
-
|
|
610
|
+
return Error;
|
|
611
|
+
};
|
|
612
|
+
const constructError = (message, type, name) => {
|
|
613
|
+
const ErrorConstructor = getErrorConstructor(message, type);
|
|
614
|
+
if (ErrorConstructor === DOMException && name) {
|
|
615
|
+
return new ErrorConstructor(message, name);
|
|
802
616
|
}
|
|
803
|
-
|
|
804
|
-
const
|
|
805
|
-
|
|
617
|
+
if (ErrorConstructor === Error) {
|
|
618
|
+
const error = new Error(message);
|
|
619
|
+
if (name && name !== 'VError') {
|
|
620
|
+
error.name = name;
|
|
621
|
+
}
|
|
622
|
+
return error;
|
|
623
|
+
}
|
|
624
|
+
return new ErrorConstructor(message);
|
|
806
625
|
};
|
|
807
|
-
const
|
|
808
|
-
|
|
809
|
-
listen: listen$7,
|
|
810
|
-
signal: signal$8,
|
|
811
|
-
wrap: wrap$f
|
|
626
|
+
const joinLines$1 = lines => {
|
|
627
|
+
return lines.join(NewLine$1);
|
|
812
628
|
};
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
resolve,
|
|
816
|
-
promise
|
|
817
|
-
} = Promise.withResolvers();
|
|
818
|
-
port.addEventListener('message', resolve, {
|
|
819
|
-
once: true
|
|
820
|
-
});
|
|
821
|
-
const event = await promise;
|
|
822
|
-
// @ts-ignore
|
|
823
|
-
return event.data;
|
|
629
|
+
const splitLines$1 = lines => {
|
|
630
|
+
return lines.split(NewLine$1);
|
|
824
631
|
};
|
|
825
|
-
const
|
|
826
|
-
const
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
if (
|
|
835
|
-
|
|
836
|
-
jsonrpc: '2.0',
|
|
837
|
-
id: firstMessage.id,
|
|
838
|
-
result: null
|
|
839
|
-
});
|
|
840
|
-
parentIpc.dispose();
|
|
841
|
-
const port = firstMessage.params[1];
|
|
842
|
-
return port;
|
|
632
|
+
const getCurrentStack = () => {
|
|
633
|
+
const currentStack = joinLines$1(splitLines$1(new Error().stack || '').slice(2));
|
|
634
|
+
return currentStack;
|
|
635
|
+
};
|
|
636
|
+
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
637
|
+
return string.indexOf(NewLine$1, startIndex);
|
|
638
|
+
};
|
|
639
|
+
const getParentStack = error => {
|
|
640
|
+
let parentStack = error.stack || error.data || error.message || '';
|
|
641
|
+
if (parentStack.startsWith(' at')) {
|
|
642
|
+
parentStack = error.message + NewLine$1 + parentStack;
|
|
843
643
|
}
|
|
844
|
-
return
|
|
644
|
+
return parentStack;
|
|
845
645
|
};
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
646
|
+
const MethodNotFound = -32601;
|
|
647
|
+
const Custom = -32001;
|
|
648
|
+
const restoreJsonRpcError = error => {
|
|
649
|
+
const currentStack = getCurrentStack();
|
|
650
|
+
if (error && error instanceof Error) {
|
|
651
|
+
if (typeof error.stack === 'string') {
|
|
652
|
+
error.stack = error.stack + NewLine$1 + currentStack;
|
|
653
|
+
}
|
|
654
|
+
return error;
|
|
849
655
|
}
|
|
850
|
-
|
|
851
|
-
|
|
656
|
+
if (error && error.code && error.code === MethodNotFound) {
|
|
657
|
+
const restoredError = new JsonRpcError(error.message);
|
|
658
|
+
const parentStack = getParentStack(error);
|
|
659
|
+
restoredError.stack = parentStack + NewLine$1 + currentStack;
|
|
660
|
+
return restoredError;
|
|
852
661
|
}
|
|
853
|
-
|
|
854
|
-
const
|
|
855
|
-
|
|
662
|
+
if (error && error.message) {
|
|
663
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
664
|
+
if (error.data) {
|
|
665
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
666
|
+
restoredError.stack = error.data.type + ': ' + error.message + NewLine$1 + error.data.stack + NewLine$1 + currentStack;
|
|
667
|
+
} else if (error.data.stack) {
|
|
668
|
+
restoredError.stack = error.data.stack;
|
|
669
|
+
}
|
|
670
|
+
if (error.data.codeFrame) {
|
|
671
|
+
// @ts-ignore
|
|
672
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
673
|
+
}
|
|
674
|
+
if (error.data.code) {
|
|
675
|
+
// @ts-ignore
|
|
676
|
+
restoredError.code = error.data.code;
|
|
677
|
+
}
|
|
678
|
+
if (error.data.type) {
|
|
679
|
+
// @ts-ignore
|
|
680
|
+
restoredError.name = error.data.type;
|
|
681
|
+
}
|
|
682
|
+
} else {
|
|
683
|
+
if (error.stack) {
|
|
684
|
+
const lowerStack = restoredError.stack || '';
|
|
685
|
+
// @ts-ignore
|
|
686
|
+
const indexNewLine = getNewLineIndex(lowerStack);
|
|
687
|
+
const parentStack = getParentStack(error);
|
|
688
|
+
// @ts-ignore
|
|
689
|
+
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
690
|
+
}
|
|
691
|
+
if (error.codeFrame) {
|
|
692
|
+
// @ts-ignore
|
|
693
|
+
restoredError.codeFrame = error.codeFrame;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
return restoredError;
|
|
697
|
+
}
|
|
698
|
+
if (typeof error === 'string') {
|
|
699
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
700
|
+
}
|
|
701
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
702
|
+
};
|
|
703
|
+
const unwrapJsonRpcResult = responseMessage => {
|
|
704
|
+
if ('error' in responseMessage) {
|
|
705
|
+
const restoredError = restoreJsonRpcError(responseMessage.error);
|
|
706
|
+
throw restoredError;
|
|
707
|
+
}
|
|
708
|
+
if ('result' in responseMessage) {
|
|
709
|
+
return responseMessage.result;
|
|
856
710
|
}
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
711
|
+
throw new JsonRpcError('unexpected response message');
|
|
712
|
+
};
|
|
713
|
+
const warn$1 = (...args) => {
|
|
714
|
+
console.warn(...args);
|
|
715
|
+
};
|
|
716
|
+
const resolve = (id, response) => {
|
|
717
|
+
const fn = get$7(id);
|
|
718
|
+
if (!fn) {
|
|
719
|
+
console.log(response);
|
|
720
|
+
warn$1(`callback ${id} may already be disposed`);
|
|
721
|
+
return;
|
|
861
722
|
}
|
|
862
|
-
|
|
863
|
-
|
|
723
|
+
fn(response);
|
|
724
|
+
remove$8(id);
|
|
725
|
+
};
|
|
726
|
+
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
727
|
+
const getErrorType = prettyError => {
|
|
728
|
+
if (prettyError && prettyError.type) {
|
|
729
|
+
return prettyError.type;
|
|
864
730
|
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
this._rawIpc.start();
|
|
731
|
+
if (prettyError && prettyError.constructor && prettyError.constructor.name) {
|
|
732
|
+
return prettyError.constructor.name;
|
|
868
733
|
}
|
|
869
|
-
|
|
870
|
-
const wrap$e = port => {
|
|
871
|
-
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
734
|
+
return undefined;
|
|
872
735
|
};
|
|
873
|
-
const
|
|
874
|
-
|
|
875
|
-
listen: listen$6,
|
|
876
|
-
wrap: wrap$e
|
|
736
|
+
const isAlreadyStack = line => {
|
|
737
|
+
return line.trim().startsWith('at ');
|
|
877
738
|
};
|
|
878
|
-
const
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
739
|
+
const getStack = prettyError => {
|
|
740
|
+
const stackString = prettyError.stack || '';
|
|
741
|
+
const newLineIndex = stackString.indexOf('\n');
|
|
742
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
743
|
+
return stackString.slice(newLineIndex + 1);
|
|
883
744
|
}
|
|
745
|
+
return stackString;
|
|
884
746
|
};
|
|
885
|
-
const
|
|
886
|
-
if (
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
747
|
+
const getErrorProperty = (error, prettyError) => {
|
|
748
|
+
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
749
|
+
return {
|
|
750
|
+
code: MethodNotFound,
|
|
751
|
+
message: error.message,
|
|
752
|
+
data: error.stack
|
|
753
|
+
};
|
|
890
754
|
}
|
|
755
|
+
return {
|
|
756
|
+
code: Custom,
|
|
757
|
+
message: prettyError.message,
|
|
758
|
+
data: {
|
|
759
|
+
stack: getStack(prettyError),
|
|
760
|
+
codeFrame: prettyError.codeFrame,
|
|
761
|
+
type: getErrorType(prettyError),
|
|
762
|
+
code: prettyError.code,
|
|
763
|
+
name: prettyError.name
|
|
764
|
+
}
|
|
765
|
+
};
|
|
891
766
|
};
|
|
892
|
-
const
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
767
|
+
const create$1$1 = (id, error) => {
|
|
768
|
+
return {
|
|
769
|
+
jsonrpc: Two,
|
|
770
|
+
id,
|
|
771
|
+
error
|
|
772
|
+
};
|
|
773
|
+
};
|
|
774
|
+
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
775
|
+
const prettyError = preparePrettyError(error);
|
|
776
|
+
logError(error, prettyError);
|
|
777
|
+
const errorProperty = getErrorProperty(error, prettyError);
|
|
778
|
+
return create$1$1(id, errorProperty);
|
|
779
|
+
};
|
|
780
|
+
const create$b = (message, result) => {
|
|
781
|
+
return {
|
|
782
|
+
jsonrpc: Two,
|
|
783
|
+
id: message.id,
|
|
784
|
+
result: result ?? null
|
|
785
|
+
};
|
|
786
|
+
};
|
|
787
|
+
const getSuccessResponse = (message, result) => {
|
|
788
|
+
const resultProperty = result ?? null;
|
|
789
|
+
return create$b(message, resultProperty);
|
|
790
|
+
};
|
|
791
|
+
const getErrorResponseSimple = (id, error) => {
|
|
792
|
+
return {
|
|
793
|
+
jsonrpc: Two,
|
|
794
|
+
id,
|
|
795
|
+
error: {
|
|
796
|
+
code: Custom,
|
|
797
|
+
// @ts-ignore
|
|
798
|
+
message: error.message,
|
|
799
|
+
data: error
|
|
901
800
|
}
|
|
902
|
-
resolve(value);
|
|
903
801
|
};
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
802
|
+
};
|
|
803
|
+
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
804
|
+
try {
|
|
805
|
+
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
806
|
+
return getSuccessResponse(message, result);
|
|
807
|
+
} catch (error) {
|
|
808
|
+
if (ipc.canUseSimpleErrorResponse) {
|
|
809
|
+
return getErrorResponseSimple(message.id, error);
|
|
810
|
+
}
|
|
811
|
+
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
812
|
+
}
|
|
813
|
+
};
|
|
814
|
+
const defaultPreparePrettyError = error => {
|
|
815
|
+
return error;
|
|
816
|
+
};
|
|
817
|
+
const defaultLogError = () => {
|
|
818
|
+
// ignore
|
|
819
|
+
};
|
|
820
|
+
const defaultRequiresSocket = () => {
|
|
821
|
+
return false;
|
|
822
|
+
};
|
|
823
|
+
const defaultResolve = resolve;
|
|
824
|
+
|
|
825
|
+
// TODO maybe remove this in v6 or v7, only accept options object to simplify the code
|
|
826
|
+
const normalizeParams = args => {
|
|
827
|
+
if (args.length === 1) {
|
|
828
|
+
const options = args[0];
|
|
829
|
+
return {
|
|
830
|
+
ipc: options.ipc,
|
|
831
|
+
message: options.message,
|
|
832
|
+
execute: options.execute,
|
|
833
|
+
resolve: options.resolve || defaultResolve,
|
|
834
|
+
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
835
|
+
logError: options.logError || defaultLogError,
|
|
836
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket
|
|
910
837
|
};
|
|
911
|
-
addListener(eventEmitter, event, listener);
|
|
912
|
-
listenerMap[event] = listener;
|
|
913
838
|
}
|
|
914
|
-
return
|
|
839
|
+
return {
|
|
840
|
+
ipc: args[0],
|
|
841
|
+
message: args[1],
|
|
842
|
+
execute: args[2],
|
|
843
|
+
resolve: args[3],
|
|
844
|
+
preparePrettyError: args[4],
|
|
845
|
+
logError: args[5],
|
|
846
|
+
requiresSocket: args[6]
|
|
847
|
+
};
|
|
915
848
|
};
|
|
916
|
-
const
|
|
917
|
-
const
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
849
|
+
const handleJsonRpcMessage = async (...args) => {
|
|
850
|
+
const options = normalizeParams(args);
|
|
851
|
+
const {
|
|
852
|
+
message,
|
|
853
|
+
ipc,
|
|
854
|
+
execute,
|
|
855
|
+
resolve,
|
|
856
|
+
preparePrettyError,
|
|
857
|
+
logError,
|
|
858
|
+
requiresSocket
|
|
859
|
+
} = options;
|
|
860
|
+
if ('id' in message) {
|
|
861
|
+
if ('method' in message) {
|
|
862
|
+
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
863
|
+
try {
|
|
864
|
+
ipc.send(response);
|
|
865
|
+
} catch (error) {
|
|
866
|
+
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
867
|
+
ipc.send(errorResponse);
|
|
868
|
+
}
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
resolve(message.id, message);
|
|
872
|
+
return;
|
|
923
873
|
}
|
|
924
|
-
if (
|
|
925
|
-
|
|
874
|
+
if ('method' in message) {
|
|
875
|
+
await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
876
|
+
return;
|
|
926
877
|
}
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
messagePort.start();
|
|
878
|
+
throw new JsonRpcError('unexpected message');
|
|
879
|
+
};
|
|
880
|
+
const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
931
881
|
const {
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
} =
|
|
935
|
-
if (
|
|
936
|
-
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
throw new IpcError$1('unexpected first message');
|
|
882
|
+
message,
|
|
883
|
+
promise
|
|
884
|
+
} = create$2$2(method, params);
|
|
885
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
886
|
+
ipc.sendAndTransfer(message);
|
|
887
|
+
} else {
|
|
888
|
+
ipc.send(message);
|
|
940
889
|
}
|
|
941
|
-
|
|
890
|
+
const responseMessage = await promise;
|
|
891
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
942
892
|
};
|
|
943
|
-
const
|
|
944
|
-
|
|
893
|
+
const send = (transport, method, ...params) => {
|
|
894
|
+
const message = create$4$1(method, params);
|
|
895
|
+
transport.send(message);
|
|
945
896
|
};
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
send(message) {
|
|
949
|
-
this._rawIpc.postMessage(message);
|
|
950
|
-
}
|
|
951
|
-
sendAndTransfer(message) {
|
|
952
|
-
const transfer = getTransferrables(message);
|
|
953
|
-
this._rawIpc.postMessage(message, transfer);
|
|
954
|
-
}
|
|
955
|
-
dispose() {
|
|
956
|
-
this._rawIpc.close();
|
|
957
|
-
}
|
|
958
|
-
onMessage(callback) {
|
|
959
|
-
this._rawIpc.addEventListener('message', callback);
|
|
960
|
-
}
|
|
961
|
-
onClose(callback) {}
|
|
962
|
-
}
|
|
963
|
-
const wrap$5 = messagePort => {
|
|
964
|
-
return new IpcParentWithMessagePort(messagePort);
|
|
897
|
+
const invoke$a = (ipc, method, ...params) => {
|
|
898
|
+
return invokeHelper(ipc, method, params, false);
|
|
965
899
|
};
|
|
966
|
-
const
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
900
|
+
const invokeAndTransfer$1 = (ipc, method, ...params) => {
|
|
901
|
+
return invokeHelper(ipc, method, params, true);
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
const commands = Object.create(null);
|
|
905
|
+
const register = commandMap => {
|
|
906
|
+
Object.assign(commands, commandMap);
|
|
907
|
+
};
|
|
908
|
+
const getCommand = key => {
|
|
909
|
+
return commands[key];
|
|
910
|
+
};
|
|
911
|
+
const execute$1 = (command, ...args) => {
|
|
912
|
+
const fn = getCommand(command);
|
|
913
|
+
if (!fn) {
|
|
914
|
+
throw new Error(`command not found ${command}`);
|
|
915
|
+
}
|
|
916
|
+
return fn(...args);
|
|
971
917
|
};
|
|
972
918
|
|
|
973
|
-
const createRpc
|
|
919
|
+
const createRpc = ipc => {
|
|
974
920
|
const rpc = {
|
|
975
921
|
// @ts-ignore
|
|
976
922
|
ipc,
|
|
@@ -981,10 +927,10 @@ const createRpc$1 = ipc => {
|
|
|
981
927
|
send(ipc, method, ...params);
|
|
982
928
|
},
|
|
983
929
|
invoke(method, ...params) {
|
|
984
|
-
return invoke$
|
|
930
|
+
return invoke$a(ipc, method, ...params);
|
|
985
931
|
},
|
|
986
932
|
invokeAndTransfer(method, ...params) {
|
|
987
|
-
return invokeAndTransfer$
|
|
933
|
+
return invokeAndTransfer$1(ipc, method, ...params);
|
|
988
934
|
},
|
|
989
935
|
async dispose() {
|
|
990
936
|
await ipc?.dispose();
|
|
@@ -992,27 +938,35 @@ const createRpc$1 = ipc => {
|
|
|
992
938
|
};
|
|
993
939
|
return rpc;
|
|
994
940
|
};
|
|
995
|
-
const requiresSocket
|
|
941
|
+
const requiresSocket = () => {
|
|
996
942
|
return false;
|
|
997
943
|
};
|
|
998
|
-
const preparePrettyError
|
|
944
|
+
const preparePrettyError = error => {
|
|
999
945
|
return error;
|
|
1000
946
|
};
|
|
1001
|
-
const logError$
|
|
947
|
+
const logError$1 = () => {
|
|
1002
948
|
// handled by renderer worker
|
|
1003
949
|
};
|
|
1004
|
-
const handleMessage
|
|
1005
|
-
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket
|
|
950
|
+
const handleMessage = event => {
|
|
951
|
+
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
1006
952
|
const actualExecute = event?.target?.execute || execute$1;
|
|
1007
|
-
return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError
|
|
953
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError, logError$1, actualRequiresSocket);
|
|
1008
954
|
};
|
|
1009
|
-
const handleIpc
|
|
955
|
+
const handleIpc = ipc => {
|
|
1010
956
|
if ('addEventListener' in ipc) {
|
|
1011
|
-
ipc.addEventListener('message', handleMessage
|
|
957
|
+
ipc.addEventListener('message', handleMessage);
|
|
1012
958
|
} else if ('on' in ipc) {
|
|
1013
959
|
// deprecated
|
|
1014
|
-
ipc.on('message', handleMessage
|
|
960
|
+
ipc.on('message', handleMessage);
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
const listen$1 = async (module, options) => {
|
|
964
|
+
const rawIpc = await module.listen(options);
|
|
965
|
+
if (module.signal) {
|
|
966
|
+
module.signal(rawIpc);
|
|
1015
967
|
}
|
|
968
|
+
const ipc = module.wrap(rawIpc);
|
|
969
|
+
return ipc;
|
|
1016
970
|
};
|
|
1017
971
|
const create$9$1 = async ({
|
|
1018
972
|
commandMap,
|
|
@@ -1026,14 +980,173 @@ const create$9$1 = async ({
|
|
|
1026
980
|
isMessagePortOpen
|
|
1027
981
|
});
|
|
1028
982
|
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
1029
|
-
handleIpc
|
|
1030
|
-
const rpc = createRpc
|
|
983
|
+
handleIpc(ipc);
|
|
984
|
+
const rpc = createRpc(ipc);
|
|
1031
985
|
return rpc;
|
|
1032
986
|
};
|
|
1033
987
|
const MessagePortRpcParent = {
|
|
1034
988
|
__proto__: null,
|
|
1035
989
|
create: create$9$1
|
|
1036
990
|
};
|
|
991
|
+
const create$3$1 = async ({
|
|
992
|
+
commandMap,
|
|
993
|
+
messagePort
|
|
994
|
+
}) => {
|
|
995
|
+
// TODO create a commandMap per rpc instance
|
|
996
|
+
register(commandMap);
|
|
997
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
998
|
+
messagePort,
|
|
999
|
+
isMessagePortOpen: true
|
|
1000
|
+
});
|
|
1001
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
1002
|
+
handleIpc(ipc);
|
|
1003
|
+
const rpc = createRpc(ipc);
|
|
1004
|
+
messagePort.start();
|
|
1005
|
+
return rpc;
|
|
1006
|
+
};
|
|
1007
|
+
const create$2$1 = async ({
|
|
1008
|
+
commandMap,
|
|
1009
|
+
messagePort
|
|
1010
|
+
}) => {
|
|
1011
|
+
return create$3$1({
|
|
1012
|
+
commandMap,
|
|
1013
|
+
messagePort
|
|
1014
|
+
});
|
|
1015
|
+
};
|
|
1016
|
+
const PlainMessagePortRpcParent = {
|
|
1017
|
+
__proto__: null,
|
|
1018
|
+
create: create$2$1
|
|
1019
|
+
};
|
|
1020
|
+
const create$a = async ({
|
|
1021
|
+
commandMap
|
|
1022
|
+
}) => {
|
|
1023
|
+
// TODO create a commandMap per rpc instance
|
|
1024
|
+
register(commandMap);
|
|
1025
|
+
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
1026
|
+
handleIpc(ipc);
|
|
1027
|
+
const rpc = createRpc(ipc);
|
|
1028
|
+
return rpc;
|
|
1029
|
+
};
|
|
1030
|
+
const WebWorkerRpcClient = {
|
|
1031
|
+
__proto__: null,
|
|
1032
|
+
create: create$a
|
|
1033
|
+
};
|
|
1034
|
+
|
|
1035
|
+
const rpcs = Object.create(null);
|
|
1036
|
+
const set$c = (id, rpc) => {
|
|
1037
|
+
rpcs[id] = rpc;
|
|
1038
|
+
};
|
|
1039
|
+
const get$6 = id => {
|
|
1040
|
+
return rpcs[id];
|
|
1041
|
+
};
|
|
1042
|
+
|
|
1043
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1044
|
+
|
|
1045
|
+
const create$9 = rpcId => {
|
|
1046
|
+
return {
|
|
1047
|
+
// @ts-ignore
|
|
1048
|
+
invoke(method, ...params) {
|
|
1049
|
+
const rpc = get$6(rpcId);
|
|
1050
|
+
// @ts-ignore
|
|
1051
|
+
return rpc.invoke(method, ...params);
|
|
1052
|
+
},
|
|
1053
|
+
// @ts-ignore
|
|
1054
|
+
invokeAndTransfer(method, ...params) {
|
|
1055
|
+
const rpc = get$6(rpcId);
|
|
1056
|
+
// @ts-ignore
|
|
1057
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1058
|
+
},
|
|
1059
|
+
set(rpc) {
|
|
1060
|
+
set$c(rpcId, rpc);
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
};
|
|
1064
|
+
const DebugWorker = 55;
|
|
1065
|
+
const EditorWorker$1 = 99;
|
|
1066
|
+
const ExtensionHostWorker = 44;
|
|
1067
|
+
const MainProcess$1 = -5;
|
|
1068
|
+
const RendererWorker$1 = 1;
|
|
1069
|
+
const SearchProcess$1 = 77;
|
|
1070
|
+
const SearchProcessElectron = 2;
|
|
1071
|
+
const SharedProcess$1 = 1;
|
|
1072
|
+
const SourceControlWorker = 66;
|
|
1073
|
+
const EmbedsProcess$1 = 207;
|
|
1074
|
+
const EmbedsWorker = 208;
|
|
1075
|
+
const FileSystemWorker$1 = 209;
|
|
1076
|
+
const FileSystemProcess$1 = 210;
|
|
1077
|
+
const MarkdownWorker$1 = 300;
|
|
1078
|
+
const CompletionWorker = 301;
|
|
1079
|
+
const ColorPickerWorker = 302;
|
|
1080
|
+
const SourceActionWorker = 303;
|
|
1081
|
+
const ErrorWorker$1 = 3308;
|
|
1082
|
+
const SyntaxHighlightingWorker$1 = 3309;
|
|
1083
|
+
const RpcId = {
|
|
1084
|
+
__proto__: null,
|
|
1085
|
+
ColorPickerWorker,
|
|
1086
|
+
CompletionWorker,
|
|
1087
|
+
DebugWorker,
|
|
1088
|
+
EditorWorker: EditorWorker$1,
|
|
1089
|
+
EmbedsProcess: EmbedsProcess$1,
|
|
1090
|
+
EmbedsWorker,
|
|
1091
|
+
ErrorWorker: ErrorWorker$1,
|
|
1092
|
+
ExtensionHostWorker,
|
|
1093
|
+
FileSystemProcess: FileSystemProcess$1,
|
|
1094
|
+
FileSystemWorker: FileSystemWorker$1,
|
|
1095
|
+
MainProcess: MainProcess$1,
|
|
1096
|
+
MarkdownWorker: MarkdownWorker$1,
|
|
1097
|
+
RendererWorker: RendererWorker$1,
|
|
1098
|
+
SearchProcess: SearchProcess$1,
|
|
1099
|
+
SearchProcessElectron,
|
|
1100
|
+
SharedProcess: SharedProcess$1,
|
|
1101
|
+
SourceActionWorker,
|
|
1102
|
+
SourceControlWorker,
|
|
1103
|
+
SyntaxHighlightingWorker: SyntaxHighlightingWorker$1
|
|
1104
|
+
};
|
|
1105
|
+
const {
|
|
1106
|
+
invoke: invoke$8,
|
|
1107
|
+
set: set$8$1
|
|
1108
|
+
} = create$9(ExtensionHostWorker);
|
|
1109
|
+
const ExtensionHost = {
|
|
1110
|
+
__proto__: null,
|
|
1111
|
+
invoke: invoke$8,
|
|
1112
|
+
set: set$8$1
|
|
1113
|
+
};
|
|
1114
|
+
const {
|
|
1115
|
+
invoke: invoke$3$1,
|
|
1116
|
+
invokeAndTransfer: invokeAndTransfer$3,
|
|
1117
|
+
set: set$3$1
|
|
1118
|
+
} = create$9(RendererWorker$1);
|
|
1119
|
+
const RendererWorker = {
|
|
1120
|
+
__proto__: null,
|
|
1121
|
+
invoke: invoke$3$1,
|
|
1122
|
+
invokeAndTransfer: invokeAndTransfer$3,
|
|
1123
|
+
set: set$3$1
|
|
1124
|
+
};
|
|
1125
|
+
const {
|
|
1126
|
+
invoke: invoke$9,
|
|
1127
|
+
set: set$9
|
|
1128
|
+
} = create$9(MarkdownWorker$1);
|
|
1129
|
+
const SyntaxHighlightingWorker = {
|
|
1130
|
+
__proto__: null,
|
|
1131
|
+
invoke: invoke$9,
|
|
1132
|
+
set: set$9
|
|
1133
|
+
};
|
|
1134
|
+
|
|
1135
|
+
const {
|
|
1136
|
+
set: set$8,
|
|
1137
|
+
invoke: invoke$7,
|
|
1138
|
+
invokeAndTransfer
|
|
1139
|
+
} = RendererWorker;
|
|
1140
|
+
|
|
1141
|
+
// TODO add tests for this
|
|
1142
|
+
const activateByEvent = async event => {
|
|
1143
|
+
await invoke$7('ExtensionHostManagement.activateByEvent', event);
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1146
|
+
const codeGeneratorAccept = state => {
|
|
1147
|
+
// TODO close code generator widget
|
|
1148
|
+
return state;
|
|
1149
|
+
};
|
|
1037
1150
|
|
|
1038
1151
|
const getPortTuple = () => {
|
|
1039
1152
|
const {
|
|
@@ -1048,15 +1161,15 @@ const getPortTuple = () => {
|
|
|
1048
1161
|
|
|
1049
1162
|
const ModuleWorkerAndWorkaroundForChromeDevtoolsBug = 6;
|
|
1050
1163
|
|
|
1051
|
-
const
|
|
1052
|
-
const name = 'Color Picker Worker';
|
|
1164
|
+
const launchWorker = async (name, url) => {
|
|
1053
1165
|
const {
|
|
1054
1166
|
port1,
|
|
1055
1167
|
port2
|
|
1056
1168
|
} = getPortTuple();
|
|
1169
|
+
// @ts-ignore
|
|
1057
1170
|
await invokeAndTransfer('IpcParent.create', {
|
|
1058
1171
|
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
|
|
1059
|
-
url
|
|
1172
|
+
url,
|
|
1060
1173
|
name: name,
|
|
1061
1174
|
raw: true,
|
|
1062
1175
|
port: port1
|
|
@@ -1070,15 +1183,21 @@ const launchColorPickerWorker = async () => {
|
|
|
1070
1183
|
return rpc;
|
|
1071
1184
|
};
|
|
1072
1185
|
|
|
1073
|
-
|
|
1074
|
-
const
|
|
1075
|
-
|
|
1076
|
-
|
|
1186
|
+
const launchColorPickerWorker = async () => {
|
|
1187
|
+
const name = 'Color Picker Worker';
|
|
1188
|
+
const url = 'colorPickerWorkerMain.js';
|
|
1189
|
+
return launchWorker(name, url);
|
|
1190
|
+
};
|
|
1191
|
+
|
|
1192
|
+
let workerPromise$4;
|
|
1193
|
+
const getOrCreate$5 = () => {
|
|
1194
|
+
if (!workerPromise$4) {
|
|
1195
|
+
workerPromise$4 = launchColorPickerWorker();
|
|
1077
1196
|
}
|
|
1078
|
-
return workerPromise$
|
|
1197
|
+
return workerPromise$4;
|
|
1079
1198
|
};
|
|
1080
1199
|
const invoke$6 = async (method, ...params) => {
|
|
1081
|
-
const worker = await getOrCreate$
|
|
1200
|
+
const worker = await getOrCreate$5();
|
|
1082
1201
|
return await worker.invoke(method, ...params);
|
|
1083
1202
|
};
|
|
1084
1203
|
|
|
@@ -1118,19 +1237,19 @@ const LineComment = 'lineComment';
|
|
|
1118
1237
|
const ToggleBlockComment$1 = 'toggleBlockComment';
|
|
1119
1238
|
|
|
1120
1239
|
const map$1 = Object.create(null);
|
|
1121
|
-
const set$
|
|
1240
|
+
const set$7 = (id, widget) => {
|
|
1122
1241
|
map$1[id] = widget;
|
|
1123
1242
|
};
|
|
1124
1243
|
const get$5 = id => {
|
|
1125
1244
|
return map$1[id];
|
|
1126
1245
|
};
|
|
1127
1246
|
|
|
1128
|
-
const getModule
|
|
1247
|
+
const getModule = id => {
|
|
1129
1248
|
return get$5(id);
|
|
1130
1249
|
};
|
|
1131
1250
|
|
|
1132
1251
|
const applyWidgetChange = async (editor, widget, changes) => {
|
|
1133
|
-
const module = getModule
|
|
1252
|
+
const module = getModule(widget.id);
|
|
1134
1253
|
if (changes.length === 1 && changes[0].origin === EditorType && module.handleEditorType) {
|
|
1135
1254
|
const newState = await module.handleEditorType(widget.newState);
|
|
1136
1255
|
return {
|
|
@@ -1168,7 +1287,7 @@ const get$4 = id => {
|
|
|
1168
1287
|
number(id);
|
|
1169
1288
|
return editors[id];
|
|
1170
1289
|
};
|
|
1171
|
-
const set$
|
|
1290
|
+
const set$6 = (id, oldEditor, newEditor) => {
|
|
1172
1291
|
object(oldEditor);
|
|
1173
1292
|
object(newEditor);
|
|
1174
1293
|
editors[id] = {
|
|
@@ -1498,7 +1617,7 @@ const createMeasureContext = () => {
|
|
|
1498
1617
|
const state$8 = {
|
|
1499
1618
|
ctx: undefined
|
|
1500
1619
|
};
|
|
1501
|
-
const getOrCreate$
|
|
1620
|
+
const getOrCreate$4 = createCtx => {
|
|
1502
1621
|
if (state$8.ctx) {
|
|
1503
1622
|
return state$8.ctx;
|
|
1504
1623
|
}
|
|
@@ -1507,7 +1626,7 @@ const getOrCreate$3 = createCtx => {
|
|
|
1507
1626
|
};
|
|
1508
1627
|
|
|
1509
1628
|
const getContext = () => {
|
|
1510
|
-
const ctx = getOrCreate$
|
|
1629
|
+
const ctx = getOrCreate$4(createMeasureContext);
|
|
1511
1630
|
return ctx;
|
|
1512
1631
|
};
|
|
1513
1632
|
|
|
@@ -1908,7 +2027,7 @@ const scheduleDocumentAndCursorsSelections = async (editor, changes, selectionCh
|
|
|
1908
2027
|
invalidStartIndex,
|
|
1909
2028
|
autoClosingRanges
|
|
1910
2029
|
};
|
|
1911
|
-
set$
|
|
2030
|
+
set$6(editor.uid, editor, newEditor);
|
|
1912
2031
|
const newWidgets = await applyWidgetChanges(newEditor, changes);
|
|
1913
2032
|
const newEditor2 = {
|
|
1914
2033
|
...newEditor,
|
|
@@ -1994,321 +2113,43 @@ const setBounds = (editor, x, y, width, height, columnWidth) => {
|
|
|
1994
2113
|
y,
|
|
1995
2114
|
width,
|
|
1996
2115
|
height,
|
|
1997
|
-
columnWidth,
|
|
1998
|
-
numberOfVisibleLines,
|
|
1999
|
-
maxLineY,
|
|
2000
|
-
finalY,
|
|
2001
|
-
finalDeltaY
|
|
2002
|
-
};
|
|
2003
|
-
};
|
|
2004
|
-
const setText = (editor, text) => {
|
|
2005
|
-
const lines = splitLines(text);
|
|
2006
|
-
const {
|
|
2007
|
-
itemHeight,
|
|
2008
|
-
numberOfVisibleLines,
|
|
2009
|
-
minimumSliderSize
|
|
2010
|
-
} = editor;
|
|
2011
|
-
const total = lines.length;
|
|
2012
|
-
const maxLineY = Math.min(numberOfVisibleLines, total);
|
|
2013
|
-
const finalY = Math.max(total - numberOfVisibleLines, 0);
|
|
2014
|
-
const finalDeltaY = finalY * itemHeight;
|
|
2015
|
-
const contentHeight = lines.length * editor.rowHeight;
|
|
2016
|
-
const scrollBarHeight = getScrollBarSize(editor.height, contentHeight, minimumSliderSize);
|
|
2017
|
-
return {
|
|
2018
|
-
...editor,
|
|
2019
|
-
lines,
|
|
2020
|
-
maxLineY,
|
|
2021
|
-
finalY,
|
|
2022
|
-
finalDeltaY,
|
|
2023
|
-
scrollBarHeight
|
|
2024
|
-
};
|
|
2025
|
-
};
|
|
2026
|
-
|
|
2027
|
-
const HoverExecute = 'ExtensionHostHover.execute';
|
|
2028
|
-
const TabCompletionExecuteTabCompletionProvider = 'ExtensionHost.executeTabCompletionProvider';
|
|
2029
|
-
const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
|
|
2030
|
-
|
|
2031
|
-
const requiresSocket = () => {
|
|
2032
|
-
return false;
|
|
2033
|
-
};
|
|
2034
|
-
const preparePrettyError = error => {
|
|
2035
|
-
return error;
|
|
2036
|
-
};
|
|
2037
|
-
const logError$1 = error => {
|
|
2038
|
-
// handled in renderer worker
|
|
2039
|
-
};
|
|
2040
|
-
const handleMessage = async event => {
|
|
2041
|
-
return handleJsonRpcMessage(event.target, event.data, execute$1, resolve, preparePrettyError, logError$1, requiresSocket);
|
|
2042
|
-
};
|
|
2043
|
-
|
|
2044
|
-
const handleIpc = ipc => {
|
|
2045
|
-
if ('addEventListener' in ipc) {
|
|
2046
|
-
ipc.addEventListener('message', handleMessage);
|
|
2047
|
-
} else {
|
|
2048
|
-
// deprecated
|
|
2049
|
-
ipc.onmessage = handleMessage;
|
|
2050
|
-
}
|
|
2051
|
-
};
|
|
2052
|
-
|
|
2053
|
-
const RendererProcess = 9;
|
|
2054
|
-
const ExtensionHostWorker = 10;
|
|
2055
|
-
const SyntaxHighlightingWorker = 11;
|
|
2056
|
-
|
|
2057
|
-
// @ts-ignore
|
|
2058
|
-
const getData = event => {
|
|
2059
|
-
return event.data;
|
|
2060
|
-
};
|
|
2061
|
-
|
|
2062
|
-
class IpcError extends Error {
|
|
2063
|
-
constructor(message) {
|
|
2064
|
-
super(message);
|
|
2065
|
-
this.name = 'IpcError';
|
|
2066
|
-
}
|
|
2067
|
-
}
|
|
2068
|
-
|
|
2069
|
-
const sendMessagePortToExtensionHostWorker = async port => {
|
|
2070
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, 'HandleMessagePort.handleMessagePort');
|
|
2071
|
-
};
|
|
2072
|
-
const sendMessagePortToExtensionHostWorker2 = async (port, initialCommand, rpcId) => {
|
|
2073
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, initialCommand, rpcId);
|
|
2074
|
-
};
|
|
2075
|
-
|
|
2076
|
-
const withResolvers = () => {
|
|
2077
|
-
let _resolve;
|
|
2078
|
-
const promise = new Promise(resolve => {
|
|
2079
|
-
_resolve = resolve;
|
|
2080
|
-
});
|
|
2081
|
-
return {
|
|
2082
|
-
resolve: _resolve,
|
|
2083
|
-
promise
|
|
2084
|
-
};
|
|
2085
|
-
};
|
|
2086
|
-
|
|
2087
|
-
const waitForFirstMessage = async port => {
|
|
2088
|
-
const {
|
|
2089
|
-
resolve,
|
|
2090
|
-
promise
|
|
2091
|
-
} = withResolvers();
|
|
2092
|
-
const cleanup = value => {
|
|
2093
|
-
port.onmessage = null;
|
|
2094
|
-
resolve(value);
|
|
2095
|
-
};
|
|
2096
|
-
const handleMessage = event => {
|
|
2097
|
-
cleanup(event);
|
|
2098
|
-
};
|
|
2099
|
-
port.onmessage = handleMessage;
|
|
2100
|
-
const event = await promise;
|
|
2101
|
-
return event;
|
|
2102
|
-
};
|
|
2103
|
-
|
|
2104
|
-
const create$c = async () => {
|
|
2105
|
-
const {
|
|
2106
|
-
port1,
|
|
2107
|
-
port2
|
|
2108
|
-
} = getPortTuple();
|
|
2109
|
-
await sendMessagePortToExtensionHostWorker(port1);
|
|
2110
|
-
const event = await waitForFirstMessage(port2);
|
|
2111
|
-
if (event.data !== 'ready') {
|
|
2112
|
-
throw new IpcError('unexpected first message');
|
|
2113
|
-
}
|
|
2114
|
-
return port2;
|
|
2115
|
-
};
|
|
2116
|
-
const wrap$2 = port => {
|
|
2117
|
-
return {
|
|
2118
|
-
port,
|
|
2119
|
-
/**
|
|
2120
|
-
* @type {any}
|
|
2121
|
-
*/
|
|
2122
|
-
listener: undefined,
|
|
2123
|
-
get onmessage() {
|
|
2124
|
-
return this.listener;
|
|
2125
|
-
},
|
|
2126
|
-
set onmessage(listener) {
|
|
2127
|
-
this.listener = listener;
|
|
2128
|
-
const wrappedListener = event => {
|
|
2129
|
-
const data = getData(event);
|
|
2130
|
-
// @ts-ignore
|
|
2131
|
-
listener({
|
|
2132
|
-
target: this,
|
|
2133
|
-
data
|
|
2134
|
-
});
|
|
2135
|
-
};
|
|
2136
|
-
this.port.onmessage = wrappedListener;
|
|
2137
|
-
},
|
|
2138
|
-
send(message) {
|
|
2139
|
-
this.port.postMessage(message);
|
|
2140
|
-
},
|
|
2141
|
-
sendAndTransfer(message, transfer) {
|
|
2142
|
-
this.port.postMessage(message, transfer);
|
|
2143
|
-
}
|
|
2144
|
-
};
|
|
2145
|
-
};
|
|
2146
|
-
|
|
2147
|
-
const IpcParentWithExtensionHostWorker = {
|
|
2148
|
-
__proto__: null,
|
|
2149
|
-
create: create$c,
|
|
2150
|
-
wrap: wrap$2
|
|
2151
|
-
};
|
|
2152
|
-
|
|
2153
|
-
const sendMessagePortToRendererProcess = async port => {
|
|
2154
|
-
await invokeAndTransfer('SendMessagePortToRendererProcess.sendMessagePortToRendererProcess', port, 'HandleMessagePort.handleMessagePort');
|
|
2155
|
-
};
|
|
2156
|
-
|
|
2157
|
-
const create$b = async () => {
|
|
2158
|
-
const {
|
|
2159
|
-
port1,
|
|
2160
|
-
port2
|
|
2161
|
-
} = getPortTuple();
|
|
2162
|
-
await sendMessagePortToRendererProcess(port1);
|
|
2163
|
-
const event = await waitForFirstMessage(port2);
|
|
2164
|
-
if (event.data !== 'ready') {
|
|
2165
|
-
throw new IpcError('unexpected first message');
|
|
2166
|
-
}
|
|
2167
|
-
return port2;
|
|
2168
|
-
};
|
|
2169
|
-
const wrap$1 = port => {
|
|
2170
|
-
return {
|
|
2171
|
-
port,
|
|
2172
|
-
/**
|
|
2173
|
-
* @type {any}
|
|
2174
|
-
*/
|
|
2175
|
-
listener: undefined,
|
|
2176
|
-
get onmessage() {
|
|
2177
|
-
return this.listener;
|
|
2178
|
-
},
|
|
2179
|
-
set onmessage(listener) {
|
|
2180
|
-
this.listener = listener;
|
|
2181
|
-
const wrappedListener = event => {
|
|
2182
|
-
const data = getData(event);
|
|
2183
|
-
// @ts-ignore
|
|
2184
|
-
listener({
|
|
2185
|
-
target: this,
|
|
2186
|
-
data
|
|
2187
|
-
});
|
|
2188
|
-
};
|
|
2189
|
-
this.port.onmessage = wrappedListener;
|
|
2190
|
-
},
|
|
2191
|
-
send(message) {
|
|
2192
|
-
this.port.postMessage(message);
|
|
2193
|
-
},
|
|
2194
|
-
sendAndTransfer(message, transfer) {
|
|
2195
|
-
this.port.postMessage(message, transfer);
|
|
2196
|
-
}
|
|
2197
|
-
};
|
|
2198
|
-
};
|
|
2199
|
-
|
|
2200
|
-
const IpcParentWithRendererProcess = {
|
|
2201
|
-
__proto__: null,
|
|
2202
|
-
create: create$b,
|
|
2203
|
-
wrap: wrap$1
|
|
2204
|
-
};
|
|
2205
|
-
|
|
2206
|
-
const sendMessagePortToSyntaxHighlightingWorker = async port => {
|
|
2207
|
-
await invokeAndTransfer('SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort');
|
|
2208
|
-
};
|
|
2209
|
-
|
|
2210
|
-
const create$a = async () => {
|
|
2211
|
-
const {
|
|
2212
|
-
port1,
|
|
2213
|
-
port2
|
|
2214
|
-
} = getPortTuple();
|
|
2215
|
-
await sendMessagePortToSyntaxHighlightingWorker(port1);
|
|
2216
|
-
const event = await waitForFirstMessage(port2);
|
|
2217
|
-
if (event.data !== 'ready') {
|
|
2218
|
-
throw new IpcError('unexpected first message');
|
|
2219
|
-
}
|
|
2220
|
-
return port2;
|
|
2221
|
-
};
|
|
2222
|
-
const wrap = port => {
|
|
2223
|
-
return {
|
|
2224
|
-
port,
|
|
2225
|
-
/**
|
|
2226
|
-
* @type {any}
|
|
2227
|
-
*/
|
|
2228
|
-
listener: undefined,
|
|
2229
|
-
get onmessage() {
|
|
2230
|
-
return this.listener;
|
|
2231
|
-
},
|
|
2232
|
-
set onmessage(listener) {
|
|
2233
|
-
this.listener = listener;
|
|
2234
|
-
const wrappedListener = event => {
|
|
2235
|
-
const data = getData(event);
|
|
2236
|
-
// @ts-ignore
|
|
2237
|
-
listener({
|
|
2238
|
-
target: this,
|
|
2239
|
-
data
|
|
2240
|
-
});
|
|
2241
|
-
};
|
|
2242
|
-
this.port.onmessage = wrappedListener;
|
|
2243
|
-
},
|
|
2244
|
-
send(message) {
|
|
2245
|
-
this.port.postMessage(message);
|
|
2246
|
-
},
|
|
2247
|
-
sendAndTransfer(message, transfer) {
|
|
2248
|
-
this.port.postMessage(message, transfer);
|
|
2249
|
-
}
|
|
2250
|
-
};
|
|
2251
|
-
};
|
|
2252
|
-
|
|
2253
|
-
const IpcParentWithSyntaxHighlightingWorker = {
|
|
2254
|
-
__proto__: null,
|
|
2255
|
-
create: create$a,
|
|
2256
|
-
wrap
|
|
2257
|
-
};
|
|
2258
|
-
|
|
2259
|
-
const getModule$1 = method => {
|
|
2260
|
-
switch (method) {
|
|
2261
|
-
case RendererProcess:
|
|
2262
|
-
return IpcParentWithRendererProcess;
|
|
2263
|
-
case ExtensionHostWorker:
|
|
2264
|
-
return IpcParentWithExtensionHostWorker;
|
|
2265
|
-
case SyntaxHighlightingWorker:
|
|
2266
|
-
return IpcParentWithSyntaxHighlightingWorker;
|
|
2267
|
-
default:
|
|
2268
|
-
throw new Error('unexpected ipc type');
|
|
2269
|
-
}
|
|
2270
|
-
};
|
|
2271
|
-
|
|
2272
|
-
const create$9 = async ({
|
|
2273
|
-
method,
|
|
2274
|
-
...options
|
|
2275
|
-
}) => {
|
|
2276
|
-
const module = getModule$1(method);
|
|
2277
|
-
// @ts-ignore
|
|
2278
|
-
const rawIpc = await module.create(options);
|
|
2279
|
-
// @ts-ignore
|
|
2280
|
-
if (options.raw) {
|
|
2281
|
-
return rawIpc;
|
|
2282
|
-
}
|
|
2283
|
-
const ipc = module.wrap(rawIpc);
|
|
2284
|
-
return ipc;
|
|
2285
|
-
};
|
|
2286
|
-
|
|
2287
|
-
const createRpc = method => {
|
|
2288
|
-
let _ipc;
|
|
2289
|
-
const listen = async () => {
|
|
2290
|
-
const ipc = await create$9({
|
|
2291
|
-
method
|
|
2292
|
-
});
|
|
2293
|
-
handleIpc(ipc);
|
|
2294
|
-
_ipc = ipc;
|
|
2295
|
-
};
|
|
2296
|
-
const invoke = async (method, ...params) => {
|
|
2297
|
-
return invoke$9(_ipc, method, ...params);
|
|
2298
|
-
};
|
|
2299
|
-
const invokeAndTransfer = async (method, ...params) => {
|
|
2300
|
-
return invokeAndTransfer$2(_ipc, method, ...params);
|
|
2116
|
+
columnWidth,
|
|
2117
|
+
numberOfVisibleLines,
|
|
2118
|
+
maxLineY,
|
|
2119
|
+
finalY,
|
|
2120
|
+
finalDeltaY
|
|
2301
2121
|
};
|
|
2122
|
+
};
|
|
2123
|
+
const setText = (editor, text) => {
|
|
2124
|
+
const lines = splitLines(text);
|
|
2125
|
+
const {
|
|
2126
|
+
itemHeight,
|
|
2127
|
+
numberOfVisibleLines,
|
|
2128
|
+
minimumSliderSize
|
|
2129
|
+
} = editor;
|
|
2130
|
+
const total = lines.length;
|
|
2131
|
+
const maxLineY = Math.min(numberOfVisibleLines, total);
|
|
2132
|
+
const finalY = Math.max(total - numberOfVisibleLines, 0);
|
|
2133
|
+
const finalDeltaY = finalY * itemHeight;
|
|
2134
|
+
const contentHeight = lines.length * editor.rowHeight;
|
|
2135
|
+
const scrollBarHeight = getScrollBarSize(editor.height, contentHeight, minimumSliderSize);
|
|
2302
2136
|
return {
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2137
|
+
...editor,
|
|
2138
|
+
lines,
|
|
2139
|
+
maxLineY,
|
|
2140
|
+
finalY,
|
|
2141
|
+
finalDeltaY,
|
|
2142
|
+
scrollBarHeight
|
|
2306
2143
|
};
|
|
2307
2144
|
};
|
|
2308
2145
|
|
|
2146
|
+
const HoverExecute = 'ExtensionHostHover.execute';
|
|
2147
|
+
const TabCompletionExecuteTabCompletionProvider = 'ExtensionHost.executeTabCompletionProvider';
|
|
2148
|
+
const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
|
|
2149
|
+
|
|
2309
2150
|
const {
|
|
2310
|
-
|
|
2311
|
-
invoke: invoke$5} =
|
|
2151
|
+
set: set$5,
|
|
2152
|
+
invoke: invoke$5} = ExtensionHost;
|
|
2312
2153
|
|
|
2313
2154
|
const ColorPicker$1 = 41;
|
|
2314
2155
|
const EditorCompletion = 9;
|
|
@@ -2404,6 +2245,7 @@ const updateDiagnostics = async newState => {
|
|
|
2404
2245
|
|
|
2405
2246
|
// TODO don't really need text document sync response
|
|
2406
2247
|
// could perhaps save a lot of messages by using send instead of invoke
|
|
2248
|
+
// @ts-ignore
|
|
2407
2249
|
await invoke$5(TextDocumentSyncFull, newState.uri, newState.id, newState.languageId, content);
|
|
2408
2250
|
const diagnostics = await executeDiagnosticProvider(newState);
|
|
2409
2251
|
const latest = get$4(newState.id);
|
|
@@ -2416,7 +2258,8 @@ const updateDiagnostics = async newState => {
|
|
|
2416
2258
|
diagnostics,
|
|
2417
2259
|
decorations
|
|
2418
2260
|
};
|
|
2419
|
-
set$
|
|
2261
|
+
set$6(newState.id, latest.oldState, newEditor);
|
|
2262
|
+
// @ts-ignore
|
|
2420
2263
|
await invoke$7('Editor.rerender', newState.id);
|
|
2421
2264
|
return newEditor;
|
|
2422
2265
|
} catch (error) {
|
|
@@ -2450,7 +2293,9 @@ const emptyEditor = {
|
|
|
2450
2293
|
undoStack: [],
|
|
2451
2294
|
lineCache: [],
|
|
2452
2295
|
selections: new Uint32Array(),
|
|
2453
|
-
diagnostics: []
|
|
2296
|
+
diagnostics: [],
|
|
2297
|
+
highlightedLine: -1,
|
|
2298
|
+
debugEnabled: false
|
|
2454
2299
|
};
|
|
2455
2300
|
const createEditor = async ({
|
|
2456
2301
|
id,
|
|
@@ -2550,7 +2395,8 @@ const createEditor = async ({
|
|
|
2550
2395
|
...newEditor3,
|
|
2551
2396
|
focused: true
|
|
2552
2397
|
};
|
|
2553
|
-
set$
|
|
2398
|
+
set$6(id, emptyEditor, newEditor4);
|
|
2399
|
+
// @ts-ignore
|
|
2554
2400
|
await invoke$5(TextDocumentSyncFull, uri, id, languageId, content);
|
|
2555
2401
|
if (diagnosticsEnabled) {
|
|
2556
2402
|
updateDiagnostics(newEditor4);
|
|
@@ -2620,7 +2466,7 @@ const applyEdit = async (editor, changes) => {
|
|
|
2620
2466
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
2621
2467
|
};
|
|
2622
2468
|
|
|
2623
|
-
const handleBlur = editor => {
|
|
2469
|
+
const handleBlur$1 = editor => {
|
|
2624
2470
|
if (editor.focusKey !== Empty) {
|
|
2625
2471
|
return editor;
|
|
2626
2472
|
}
|
|
@@ -2862,6 +2708,7 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, isError
|
|
|
2862
2708
|
const x$1 = x(editor, rowIndex, columnIndex);
|
|
2863
2709
|
const y$1 = y(editor, rowIndex);
|
|
2864
2710
|
const displayErrorMessage = message;
|
|
2711
|
+
// @ts-ignore
|
|
2865
2712
|
await invoke$7('Editor.showOverlayMessage', editor, 'Viewlet.send', editor.uid, 'showOverlayMessage', x$1, y$1, displayErrorMessage);
|
|
2866
2713
|
if (!isError) {
|
|
2867
2714
|
const handleTimeout = () => {
|
|
@@ -2918,6 +2765,7 @@ const braceCompletion = async (editor, text) => {
|
|
|
2918
2765
|
try {
|
|
2919
2766
|
// @ts-ignore
|
|
2920
2767
|
const offset = offsetAt(editor, editor.cursor);
|
|
2768
|
+
// @ts-ignore
|
|
2921
2769
|
const result = await invoke$7('ExtensionHostBraceCompletion.executeBraceCompletionProvider', editor, offset, text);
|
|
2922
2770
|
if (result) {
|
|
2923
2771
|
const closingBrace = getMatchingClosingBrace$1(text);
|
|
@@ -3011,35 +2859,19 @@ const closeFind = editor => {
|
|
|
3011
2859
|
|
|
3012
2860
|
const launchRenameWorker = async () => {
|
|
3013
2861
|
const name = 'Rename Worker';
|
|
3014
|
-
const
|
|
3015
|
-
|
|
3016
|
-
port2
|
|
3017
|
-
} = getPortTuple();
|
|
3018
|
-
await invokeAndTransfer('IpcParent.create', {
|
|
3019
|
-
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
|
|
3020
|
-
url: 'renameWorkerMain.js',
|
|
3021
|
-
name: name,
|
|
3022
|
-
raw: true,
|
|
3023
|
-
port: port1
|
|
3024
|
-
});
|
|
3025
|
-
const rpc = await MessagePortRpcParent.create({
|
|
3026
|
-
commandMap: {},
|
|
3027
|
-
messagePort: port2,
|
|
3028
|
-
isMessagePortOpen: true
|
|
3029
|
-
});
|
|
3030
|
-
port2.start();
|
|
3031
|
-
return rpc;
|
|
2862
|
+
const url = 'renameWorkerMain.js';
|
|
2863
|
+
return launchWorker(name, url);
|
|
3032
2864
|
};
|
|
3033
2865
|
|
|
3034
|
-
let workerPromise$
|
|
3035
|
-
const getOrCreate$
|
|
3036
|
-
if (!workerPromise$
|
|
3037
|
-
workerPromise$
|
|
2866
|
+
let workerPromise$3;
|
|
2867
|
+
const getOrCreate$3 = () => {
|
|
2868
|
+
if (!workerPromise$3) {
|
|
2869
|
+
workerPromise$3 = launchRenameWorker();
|
|
3038
2870
|
}
|
|
3039
|
-
return workerPromise$
|
|
2871
|
+
return workerPromise$3;
|
|
3040
2872
|
};
|
|
3041
2873
|
const invoke$4 = async (method, ...params) => {
|
|
3042
|
-
const worker = await getOrCreate$
|
|
2874
|
+
const worker = await getOrCreate$3();
|
|
3043
2875
|
return await worker.invoke(method, ...params);
|
|
3044
2876
|
};
|
|
3045
2877
|
|
|
@@ -3093,6 +2925,7 @@ const hasWidget = (widgets, id) => {
|
|
|
3093
2925
|
};
|
|
3094
2926
|
|
|
3095
2927
|
const setAdditionalFocus = async focusKey => {
|
|
2928
|
+
// @ts-ignore
|
|
3096
2929
|
await invoke$7('Focus.setAdditionalFocus', focusKey);
|
|
3097
2930
|
};
|
|
3098
2931
|
|
|
@@ -3106,6 +2939,7 @@ const unsetAdditionalFocus = async focusKey => {
|
|
|
3106
2939
|
if (!focusKey) {
|
|
3107
2940
|
return;
|
|
3108
2941
|
}
|
|
2942
|
+
// @ts-ignore
|
|
3109
2943
|
await invoke$7('Focus.removeAdditionalFocus', focusKey);
|
|
3110
2944
|
};
|
|
3111
2945
|
|
|
@@ -3861,6 +3695,7 @@ const deleteWordRight = editor => {
|
|
|
3861
3695
|
};
|
|
3862
3696
|
|
|
3863
3697
|
const findAllReferences = async editor => {
|
|
3698
|
+
// @ts-ignore
|
|
3864
3699
|
await invoke$7('SideBar.show', 'References', /* focus */true);
|
|
3865
3700
|
return editor;
|
|
3866
3701
|
};
|
|
@@ -3991,6 +3826,7 @@ const getWordBefore = (editor, rowIndex, columnIndex) => {
|
|
|
3991
3826
|
|
|
3992
3827
|
// @ts-ignore
|
|
3993
3828
|
const getDefinition = async (editor, offset) => {
|
|
3829
|
+
// @ts-ignore
|
|
3994
3830
|
const definition = await invoke$7('ExtensionHostDefinition.executeDefinitionProvider', editor, offset);
|
|
3995
3831
|
return definition;
|
|
3996
3832
|
};
|
|
@@ -4251,6 +4087,7 @@ const getNoLocationFoundMessage = info => {
|
|
|
4251
4087
|
};
|
|
4252
4088
|
|
|
4253
4089
|
const getTypeDefinition = async (editor, offset) => {
|
|
4090
|
+
// @ts-ignore
|
|
4254
4091
|
const definition = await invoke$7('ExtensionHostTypeDefinition.executeTypeDefinitionProvider', editor, offset);
|
|
4255
4092
|
return definition;
|
|
4256
4093
|
};
|
|
@@ -4326,7 +4163,7 @@ const handleDoubleClick = (editor, modifier, x, y) => {
|
|
|
4326
4163
|
};
|
|
4327
4164
|
|
|
4328
4165
|
const WhenExpressionEditorText = 12;
|
|
4329
|
-
const handleFocus = editor => {
|
|
4166
|
+
const handleFocus$1 = editor => {
|
|
4330
4167
|
// TODO make change events functional,
|
|
4331
4168
|
// when rendering, send focus changes to renderer worker
|
|
4332
4169
|
invoke$7('Focus.setFocus', WhenExpressionEditorText);
|
|
@@ -4492,7 +4329,7 @@ const state$4 = {
|
|
|
4492
4329
|
const get$3 = () => {
|
|
4493
4330
|
return state$4;
|
|
4494
4331
|
};
|
|
4495
|
-
const set$
|
|
4332
|
+
const set$4 = (editor, timeout, x, y) => {
|
|
4496
4333
|
state$4.editor = editor;
|
|
4497
4334
|
state$4.timeout = timeout;
|
|
4498
4335
|
state$4.x = x;
|
|
@@ -4534,7 +4371,7 @@ const handleMouseMove = (editor, x, y) => {
|
|
|
4534
4371
|
clearTimeout(oldState.timeout);
|
|
4535
4372
|
}
|
|
4536
4373
|
const timeout = setTimeout(onHoverIdle, hoverDelay);
|
|
4537
|
-
set$
|
|
4374
|
+
set$4(editor, timeout, x, y);
|
|
4538
4375
|
return editor;
|
|
4539
4376
|
};
|
|
4540
4377
|
|
|
@@ -4987,6 +4824,7 @@ const indentMore = editor => {
|
|
|
4987
4824
|
};
|
|
4988
4825
|
|
|
4989
4826
|
const getLanguageConfiguration = async editor => {
|
|
4827
|
+
// @ts-ignore
|
|
4990
4828
|
return invoke$7('Languages.getLanguageConfiguration', {
|
|
4991
4829
|
uri: editor.uri,
|
|
4992
4830
|
languageId: editor.languageId
|
|
@@ -5331,36 +5169,19 @@ const create$4 = () => {
|
|
|
5331
5169
|
|
|
5332
5170
|
const launchCompletionWorker = async () => {
|
|
5333
5171
|
const name = 'Completion Worker';
|
|
5334
|
-
const
|
|
5335
|
-
|
|
5336
|
-
port2
|
|
5337
|
-
} = getPortTuple();
|
|
5338
|
-
await invokeAndTransfer('IpcParent.create', {
|
|
5339
|
-
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
|
|
5340
|
-
url: 'completionWorkerMain.js',
|
|
5341
|
-
name: name,
|
|
5342
|
-
raw: true,
|
|
5343
|
-
port: port1
|
|
5344
|
-
});
|
|
5345
|
-
const rpc = await MessagePortRpcParent.create({
|
|
5346
|
-
commandMap: {},
|
|
5347
|
-
messagePort: port2,
|
|
5348
|
-
isMessagePortOpen: true
|
|
5349
|
-
});
|
|
5350
|
-
port2.start();
|
|
5351
|
-
await rpc.invoke('Completions.initialize');
|
|
5352
|
-
return rpc;
|
|
5172
|
+
const url = 'completionWorkerMain.js';
|
|
5173
|
+
return launchWorker(name, url);
|
|
5353
5174
|
};
|
|
5354
5175
|
|
|
5355
|
-
let workerPromise$
|
|
5356
|
-
const getOrCreate$
|
|
5357
|
-
if (!workerPromise$
|
|
5358
|
-
workerPromise$
|
|
5176
|
+
let workerPromise$2;
|
|
5177
|
+
const getOrCreate$2 = () => {
|
|
5178
|
+
if (!workerPromise$2) {
|
|
5179
|
+
workerPromise$2 = launchCompletionWorker();
|
|
5359
5180
|
}
|
|
5360
|
-
return workerPromise$
|
|
5181
|
+
return workerPromise$2;
|
|
5361
5182
|
};
|
|
5362
5183
|
const invoke$3 = async (method, ...params) => {
|
|
5363
|
-
const worker = await getOrCreate$
|
|
5184
|
+
const worker = await getOrCreate$2();
|
|
5364
5185
|
return await worker.invoke(method, ...params);
|
|
5365
5186
|
};
|
|
5366
5187
|
|
|
@@ -5418,35 +5239,19 @@ const create$3 = () => {
|
|
|
5418
5239
|
|
|
5419
5240
|
const launchFindWidgetWorker = async () => {
|
|
5420
5241
|
const name = 'Find Widget Worker';
|
|
5421
|
-
const
|
|
5422
|
-
|
|
5423
|
-
port2
|
|
5424
|
-
} = getPortTuple();
|
|
5425
|
-
await invokeAndTransfer('IpcParent.create', {
|
|
5426
|
-
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
|
|
5427
|
-
url: 'findWidgetWorkerMain.js',
|
|
5428
|
-
name: name,
|
|
5429
|
-
raw: true,
|
|
5430
|
-
port: port1
|
|
5431
|
-
});
|
|
5432
|
-
const rpc = await MessagePortRpcParent.create({
|
|
5433
|
-
commandMap: {},
|
|
5434
|
-
messagePort: port2,
|
|
5435
|
-
isMessagePortOpen: true
|
|
5436
|
-
});
|
|
5437
|
-
port2.start();
|
|
5438
|
-
return rpc;
|
|
5242
|
+
const url = 'findWidgetWorkerMain.js';
|
|
5243
|
+
return launchWorker(name, url);
|
|
5439
5244
|
};
|
|
5440
5245
|
|
|
5441
|
-
let workerPromise;
|
|
5442
|
-
const getOrCreate = () => {
|
|
5443
|
-
if (!workerPromise) {
|
|
5444
|
-
workerPromise = launchFindWidgetWorker();
|
|
5246
|
+
let workerPromise$1;
|
|
5247
|
+
const getOrCreate$1 = () => {
|
|
5248
|
+
if (!workerPromise$1) {
|
|
5249
|
+
workerPromise$1 = launchFindWidgetWorker();
|
|
5445
5250
|
}
|
|
5446
|
-
return workerPromise;
|
|
5251
|
+
return workerPromise$1;
|
|
5447
5252
|
};
|
|
5448
5253
|
const invoke$2 = async (method, ...params) => {
|
|
5449
|
-
const worker = await getOrCreate();
|
|
5254
|
+
const worker = await getOrCreate$1();
|
|
5450
5255
|
return await worker.invoke(method, ...params);
|
|
5451
5256
|
};
|
|
5452
5257
|
|
|
@@ -5481,14 +5286,6 @@ const loadContent$1 = async (state, parentUid) => {
|
|
|
5481
5286
|
commands
|
|
5482
5287
|
};
|
|
5483
5288
|
};
|
|
5484
|
-
const close$1 = async state => {
|
|
5485
|
-
// TODO
|
|
5486
|
-
// await Viewlet.closeWidget(uid)
|
|
5487
|
-
return {
|
|
5488
|
-
...state,
|
|
5489
|
-
disposed: true
|
|
5490
|
-
};
|
|
5491
|
-
};
|
|
5492
5289
|
|
|
5493
5290
|
const newStateGenerator$2 = (state, parentUid) => {
|
|
5494
5291
|
return loadContent$1(state, parentUid);
|
|
@@ -5600,6 +5397,7 @@ const pasteText = (editor, text) => {
|
|
|
5600
5397
|
};
|
|
5601
5398
|
|
|
5602
5399
|
const paste = async editor => {
|
|
5400
|
+
// @ts-ignore
|
|
5603
5401
|
const text = await invoke$7('ClipBoard.readText');
|
|
5604
5402
|
string(text);
|
|
5605
5403
|
return pasteText(editor, text);
|
|
@@ -6048,6 +5846,7 @@ const selectInsideString = editor => {
|
|
|
6048
5846
|
// import * as ExtensionHostSelection from '../ExtensionHost/ExtensionHostSelection.ts'
|
|
6049
5847
|
|
|
6050
5848
|
const getNewSelections = async (editor, selections) => {
|
|
5849
|
+
// @ts-ignore
|
|
6051
5850
|
const newSelections = await invoke$7('ExtensionHostSelection.executeGrowSelection', editor, selections);
|
|
6052
5851
|
if (newSelections.length === 0) {
|
|
6053
5852
|
return selections;
|
|
@@ -6301,9 +6100,8 @@ const getEnabled$1 = () => {
|
|
|
6301
6100
|
};
|
|
6302
6101
|
|
|
6303
6102
|
const {
|
|
6304
|
-
|
|
6305
|
-
invoke: invoke$1
|
|
6306
|
-
} = createRpc(SyntaxHighlightingWorker);
|
|
6103
|
+
set: set$3,
|
|
6104
|
+
invoke: invoke$1} = SyntaxHighlightingWorker;
|
|
6307
6105
|
|
|
6308
6106
|
/**
|
|
6309
6107
|
* @enum number
|
|
@@ -6372,6 +6170,7 @@ const loadTokenizer = async (languageId, tokenizePath) => {
|
|
|
6372
6170
|
return;
|
|
6373
6171
|
}
|
|
6374
6172
|
if (getEnabled$1()) {
|
|
6173
|
+
// @ts-ignore
|
|
6375
6174
|
const tokenMap = await invoke$1('Tokenizer.load', languageId, tokenizePath);
|
|
6376
6175
|
set$1(languageId, tokenMap);
|
|
6377
6176
|
return;
|
|
@@ -6529,20 +6328,10 @@ const getHover = async (editor, offset) => {
|
|
|
6529
6328
|
return hover;
|
|
6530
6329
|
};
|
|
6531
6330
|
|
|
6532
|
-
let _ipc;
|
|
6533
|
-
const listen$2 = async () => {
|
|
6534
|
-
const ipc = await create$9({
|
|
6535
|
-
method: RendererProcess
|
|
6536
|
-
});
|
|
6537
|
-
handleIpc(ipc);
|
|
6538
|
-
_ipc = ipc;
|
|
6539
|
-
};
|
|
6540
|
-
const invoke = async (method, ...args) => {
|
|
6541
|
-
return invoke$9(_ipc, method, ...args);
|
|
6542
|
-
};
|
|
6543
|
-
|
|
6544
6331
|
const measureTextBlockHeight = async (text, fontFamily, fontSize, lineHeight, width) => {
|
|
6545
|
-
|
|
6332
|
+
// @ts-ignore
|
|
6333
|
+
// return RendererProcess.invoke('MeasureTextBlockHeight.measureTextBlockHeight', text, fontSize, fontFamily, lineHeight, width)
|
|
6334
|
+
return 100;
|
|
6546
6335
|
};
|
|
6547
6336
|
|
|
6548
6337
|
const deepCopy = value => {
|
|
@@ -6660,16 +6449,6 @@ const getMatchingDiagnostics = (diagnostics, rowIndex, columnIndex) => {
|
|
|
6660
6449
|
return matching;
|
|
6661
6450
|
};
|
|
6662
6451
|
const fallbackDisplayStringLanguageId = 'typescript'; // TODO remove this
|
|
6663
|
-
|
|
6664
|
-
const hoverDocumentationFontSize = 15;
|
|
6665
|
-
const hoverDocumentationFontFamily = 'Fira Code';
|
|
6666
|
-
const hoverDocumentationLineHeight = '1.33333';
|
|
6667
|
-
const hoverBorderLeft = 1;
|
|
6668
|
-
const hoverBorderRight = 1;
|
|
6669
|
-
const hoverPaddingLeft = 8;
|
|
6670
|
-
const hoverPaddingRight = 8;
|
|
6671
|
-
const hovverFullWidth = 400;
|
|
6672
|
-
const hoverDocumentationWidth = hovverFullWidth - hoverPaddingLeft - hoverPaddingRight - hoverBorderLeft - hoverBorderRight;
|
|
6673
6452
|
const getHoverPositionXy = (editor, rowIndex, wordStart, documentationHeight) => {
|
|
6674
6453
|
const x$1 = x(editor, rowIndex, wordStart);
|
|
6675
6454
|
const y$1 = editor.height - y(editor, rowIndex) + editor.y + 40;
|
|
@@ -6703,7 +6482,7 @@ const getEditorHoverInfo = async (editorUid, position) => {
|
|
|
6703
6482
|
const lineInfos = await tokenizeCodeBlock(displayString, displayStringLanguageId || fallbackDisplayStringLanguageId, tokenizerPath);
|
|
6704
6483
|
const wordPart = getWordBefore(editor, rowIndex, columnIndex);
|
|
6705
6484
|
const wordStart = columnIndex - wordPart.length;
|
|
6706
|
-
await measureTextBlockHeight(
|
|
6485
|
+
await measureTextBlockHeight();
|
|
6707
6486
|
const {
|
|
6708
6487
|
x,
|
|
6709
6488
|
y
|
|
@@ -6759,6 +6538,7 @@ const showHover = async state => {
|
|
|
6759
6538
|
|
|
6760
6539
|
// TODO ask extension host worker instead
|
|
6761
6540
|
const getEditorSourceActions = async () => {
|
|
6541
|
+
// @ts-ignore
|
|
6762
6542
|
const sourceActions = await invoke$7('GetEditorSourceActions.getEditorSourceActions');
|
|
6763
6543
|
return sourceActions;
|
|
6764
6544
|
};
|
|
@@ -7419,6 +7199,7 @@ const typeWithAutoClosingQuote = (editor, text) => {
|
|
|
7419
7199
|
|
|
7420
7200
|
const typeWithAutoClosingTag = async (editor, text) => {
|
|
7421
7201
|
const offset = offsetAt(editor, editor.selections[0], editor.selections[1]);
|
|
7202
|
+
// @ts-ignore
|
|
7422
7203
|
const result = await invoke$7('ExtensionHostClosingTagCompletion.executeClosingTagProvider', editor, offset, text);
|
|
7423
7204
|
if (!result) {
|
|
7424
7205
|
const changes = editorReplaceSelections(editor, [text], EditorType);
|
|
@@ -7678,6 +7459,78 @@ const addWidget$1 = (widget, id, render) => {
|
|
|
7678
7459
|
return allCommands;
|
|
7679
7460
|
};
|
|
7680
7461
|
|
|
7462
|
+
const getWidgetInvoke = widgetId => {
|
|
7463
|
+
switch (widgetId) {
|
|
7464
|
+
case ColorPicker:
|
|
7465
|
+
return invoke$6;
|
|
7466
|
+
case Completion:
|
|
7467
|
+
return invoke$3;
|
|
7468
|
+
case Find:
|
|
7469
|
+
return invoke$2;
|
|
7470
|
+
case Rename:
|
|
7471
|
+
return invoke$4;
|
|
7472
|
+
default:
|
|
7473
|
+
return undefined;
|
|
7474
|
+
}
|
|
7475
|
+
};
|
|
7476
|
+
|
|
7477
|
+
const updateWidget = (editor, widgetId, newState) => {
|
|
7478
|
+
// TODO avoid closure
|
|
7479
|
+
const isWidget = widget => {
|
|
7480
|
+
return widget.id === widgetId;
|
|
7481
|
+
};
|
|
7482
|
+
const childIndex = editor.widgets.findIndex(isWidget);
|
|
7483
|
+
if (childIndex === -1) {
|
|
7484
|
+
return editor;
|
|
7485
|
+
}
|
|
7486
|
+
// TODO scroll up/down if necessary
|
|
7487
|
+
const childWidget = editor.widgets[childIndex];
|
|
7488
|
+
const newWidget = {
|
|
7489
|
+
...childWidget,
|
|
7490
|
+
oldState: childWidget.newState,
|
|
7491
|
+
newState
|
|
7492
|
+
};
|
|
7493
|
+
const newWidgets = [...editor.widgets.slice(0, childIndex), newWidget, ...editor.widgets.slice(childIndex + 1)];
|
|
7494
|
+
return {
|
|
7495
|
+
...editor,
|
|
7496
|
+
widgets: newWidgets
|
|
7497
|
+
};
|
|
7498
|
+
};
|
|
7499
|
+
|
|
7500
|
+
const createFn = (key, name, widgetId) => {
|
|
7501
|
+
const isWidget = widget => {
|
|
7502
|
+
return widget.id === widgetId;
|
|
7503
|
+
};
|
|
7504
|
+
const fn = async (editor, ...args) => {
|
|
7505
|
+
const childIndex = editor.widgets.findIndex(isWidget);
|
|
7506
|
+
// TODO scroll up/down if necessary
|
|
7507
|
+
const childWidget = editor.widgets[childIndex];
|
|
7508
|
+
const state = childWidget.newState;
|
|
7509
|
+
const {
|
|
7510
|
+
uid
|
|
7511
|
+
} = state;
|
|
7512
|
+
const invoke = getWidgetInvoke(widgetId);
|
|
7513
|
+
await invoke(`${name}.${key}`, uid, ...args);
|
|
7514
|
+
const diff = await invoke(`${name}.diff2`, uid);
|
|
7515
|
+
const commands = await invoke(`${name}.render2`, uid, diff);
|
|
7516
|
+
const newState = {
|
|
7517
|
+
...state,
|
|
7518
|
+
commands
|
|
7519
|
+
};
|
|
7520
|
+
const latest = get$4(editor.uid).newState;
|
|
7521
|
+
const newEditor = updateWidget(latest, widgetId, newState);
|
|
7522
|
+
return newEditor;
|
|
7523
|
+
};
|
|
7524
|
+
return fn;
|
|
7525
|
+
};
|
|
7526
|
+
const createFns = (keys, name, widgetId) => {
|
|
7527
|
+
const fns = Object.create(null);
|
|
7528
|
+
for (const key of keys) {
|
|
7529
|
+
fns[key] = createFn(key, name, widgetId);
|
|
7530
|
+
}
|
|
7531
|
+
return fns;
|
|
7532
|
+
};
|
|
7533
|
+
|
|
7681
7534
|
const AppendToBody = 'Viewlet.appendToBody';
|
|
7682
7535
|
const Focus = 'focus';
|
|
7683
7536
|
const RegisterEventListeners = 'Viewlet.registerEventListeners';
|
|
@@ -7718,34 +7571,12 @@ const add$7 = widget => {
|
|
|
7718
7571
|
const remove$7 = widget => {
|
|
7719
7572
|
return [['Viewlet.dispose', widget.newState.uid]];
|
|
7720
7573
|
};
|
|
7721
|
-
const createFn = key => {
|
|
7722
|
-
const fn = async (state, ...args) => {
|
|
7723
|
-
const {
|
|
7724
|
-
uid
|
|
7725
|
-
} = state;
|
|
7726
|
-
await invoke$3(`Completions.${key}`, uid, ...args);
|
|
7727
|
-
const diff = await invoke$3('Completions.diff2', uid);
|
|
7728
|
-
const commands = await invoke$3('Completions.render2', uid, diff);
|
|
7729
|
-
return {
|
|
7730
|
-
...state,
|
|
7731
|
-
commands
|
|
7732
|
-
};
|
|
7733
|
-
};
|
|
7734
|
-
return fn;
|
|
7735
|
-
};
|
|
7736
|
-
const createFns = keys => {
|
|
7737
|
-
const fns = Object.create(null);
|
|
7738
|
-
for (const key of keys) {
|
|
7739
|
-
fns[key] = createFn(key);
|
|
7740
|
-
}
|
|
7741
|
-
return fns;
|
|
7742
|
-
};
|
|
7743
7574
|
const {
|
|
7744
7575
|
focusFirst,
|
|
7745
7576
|
focusIndex: focusIndex$1,
|
|
7746
7577
|
focusLast,
|
|
7747
|
-
focusNext: focusNext$
|
|
7748
|
-
focusPrevious,
|
|
7578
|
+
focusNext: focusNext$2,
|
|
7579
|
+
focusPrevious: focusPrevious$1,
|
|
7749
7580
|
handleEditorBlur,
|
|
7750
7581
|
handleEditorClick,
|
|
7751
7582
|
handleEditorDeleteLeft: handleEditorDeleteLeft$1,
|
|
@@ -7756,30 +7587,104 @@ const {
|
|
|
7756
7587
|
toggleDetails,
|
|
7757
7588
|
closeDetails,
|
|
7758
7589
|
handleWheel,
|
|
7759
|
-
close
|
|
7760
|
-
} = createFns(['handleEditorType', 'focusFirst', 'focusNext', 'focusPrevious', 'focusLast', 'handleEditorDeleteLeft', 'openDetails', 'focusIndex', 'handleEditorBlur', 'handleEditorClick', 'openDetails', 'selectCurrent', 'selectIndex', 'toggleDetails', 'closeDetails', 'handleWheel', 'close']);
|
|
7590
|
+
close: close$1
|
|
7591
|
+
} = createFns(['handleEditorType', 'focusFirst', 'focusNext', 'focusPrevious', 'focusLast', 'handleEditorDeleteLeft', 'openDetails', 'focusIndex', 'handleEditorBlur', 'handleEditorClick', 'openDetails', 'selectCurrent', 'selectIndex', 'toggleDetails', 'closeDetails', 'handleWheel', 'close'], 'Completions', Completion);
|
|
7592
|
+
|
|
7593
|
+
const EditorCompletionWidget = {
|
|
7594
|
+
__proto__: null,
|
|
7595
|
+
add: add$7,
|
|
7596
|
+
close: close$1,
|
|
7597
|
+
closeDetails,
|
|
7598
|
+
focusFirst,
|
|
7599
|
+
focusIndex: focusIndex$1,
|
|
7600
|
+
focusLast,
|
|
7601
|
+
focusNext: focusNext$2,
|
|
7602
|
+
focusPrevious: focusPrevious$1,
|
|
7603
|
+
handleEditorBlur,
|
|
7604
|
+
handleEditorClick,
|
|
7605
|
+
handleEditorDeleteLeft: handleEditorDeleteLeft$1,
|
|
7606
|
+
handleEditorType: handleEditorType$1,
|
|
7607
|
+
handleWheel,
|
|
7608
|
+
openDetails,
|
|
7609
|
+
remove: remove$7,
|
|
7610
|
+
render: render$c,
|
|
7611
|
+
selectCurrent,
|
|
7612
|
+
selectIndex,
|
|
7613
|
+
toggleDetails
|
|
7614
|
+
};
|
|
7615
|
+
|
|
7616
|
+
const renderFull$3 = (oldState, newState) => {
|
|
7617
|
+
const commands = [...newState.commands];
|
|
7618
|
+
// @ts-ignore
|
|
7619
|
+
newState.commands = [];
|
|
7620
|
+
return commands;
|
|
7621
|
+
};
|
|
7622
|
+
|
|
7623
|
+
const render$b = widget => {
|
|
7624
|
+
const commands = renderFull$3(widget.oldState, widget.newState);
|
|
7625
|
+
const wrappedCommands = [];
|
|
7626
|
+
const {
|
|
7627
|
+
uid
|
|
7628
|
+
} = widget.newState;
|
|
7629
|
+
for (const command of commands) {
|
|
7630
|
+
if (command[0] === SetDom2 || command[0] === SetCss || command[0] === AppendToBody || command[0] === SetBounds2 || command[0] === RegisterEventListeners || command[0] === SetSelectionByName || command[0] === SetValueByName || command[0] === SetFocusContext || command[0] === SetUid || command[0] === 'Viewlet.focusSelector') {
|
|
7631
|
+
wrappedCommands.push(command);
|
|
7632
|
+
} else {
|
|
7633
|
+
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
7634
|
+
}
|
|
7635
|
+
}
|
|
7636
|
+
return wrappedCommands;
|
|
7637
|
+
};
|
|
7638
|
+
const add$6 = widget => {
|
|
7639
|
+
return addWidget$1(widget, 'FindWidget', render$b);
|
|
7640
|
+
};
|
|
7641
|
+
const remove$6 = widget => {
|
|
7642
|
+
return [['Viewlet.dispose', widget.newState.uid]];
|
|
7643
|
+
};
|
|
7644
|
+
const {
|
|
7645
|
+
close,
|
|
7646
|
+
focusCloseButton,
|
|
7647
|
+
focusFind,
|
|
7648
|
+
focusNext: focusNext$1,
|
|
7649
|
+
focusNextMatchButton,
|
|
7650
|
+
focusPrevious,
|
|
7651
|
+
focusPreviousMatchButton,
|
|
7652
|
+
focusReplace,
|
|
7653
|
+
focusReplaceAllButton,
|
|
7654
|
+
focusReplaceButton,
|
|
7655
|
+
focusToggleReplace,
|
|
7656
|
+
handleBlur,
|
|
7657
|
+
handleFocus,
|
|
7658
|
+
handleInput,
|
|
7659
|
+
handleReplaceFocus,
|
|
7660
|
+
handleReplaceInput,
|
|
7661
|
+
handleToggleReplaceFocus,
|
|
7662
|
+
toggleReplace
|
|
7663
|
+
} = createFns(['close', 'focusCloseButton', 'focusFind', 'focusNext', 'focusNextMatchButton', 'focusPrevious', 'focusPreviousMatchButton', 'focusReplace', 'focusReplaceAllButton', 'focusReplaceButton', 'focusToggleReplace', 'handleBlur', 'handleFocus', 'handleInput', 'handleReplaceFocus', 'handleReplaceInput', 'handleToggleReplaceFocus', 'toggleReplace'], 'FindWidget', Find);
|
|
7761
7664
|
|
|
7762
|
-
const
|
|
7665
|
+
const EditorFindWidget = {
|
|
7763
7666
|
__proto__: null,
|
|
7764
|
-
add: add$
|
|
7667
|
+
add: add$6,
|
|
7765
7668
|
close,
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
focusIndex: focusIndex$1,
|
|
7769
|
-
focusLast,
|
|
7669
|
+
focusCloseButton,
|
|
7670
|
+
focusFind,
|
|
7770
7671
|
focusNext: focusNext$1,
|
|
7672
|
+
focusNextMatchButton,
|
|
7771
7673
|
focusPrevious,
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
7674
|
+
focusPreviousMatchButton,
|
|
7675
|
+
focusReplace,
|
|
7676
|
+
focusReplaceAllButton,
|
|
7677
|
+
focusReplaceButton,
|
|
7678
|
+
focusToggleReplace,
|
|
7679
|
+
handleBlur,
|
|
7680
|
+
handleFocus,
|
|
7681
|
+
handleInput,
|
|
7682
|
+
handleReplaceFocus,
|
|
7683
|
+
handleReplaceInput,
|
|
7684
|
+
handleToggleReplaceFocus,
|
|
7685
|
+
remove: remove$6,
|
|
7686
|
+
render: render$b,
|
|
7687
|
+
toggleReplace
|
|
7783
7688
|
};
|
|
7784
7689
|
|
|
7785
7690
|
const loadContent = async (editorUid, state, position) => {
|
|
@@ -7831,6 +7736,7 @@ const CompletionDetailContent = 'CompletionDetailContent';
|
|
|
7831
7736
|
const Diagnostic = 'Diagnostic';
|
|
7832
7737
|
const EditorCursor = 'EditorCursor';
|
|
7833
7738
|
const EditorRow = 'EditorRow';
|
|
7739
|
+
const EditorRowHighlighted = 'EditorRowHighlighted';
|
|
7834
7740
|
const EditorSelection = 'EditorSelection';
|
|
7835
7741
|
const EditorSourceActions = 'EditorSourceActions';
|
|
7836
7742
|
const EditorSourceActionsList = 'EditorSourceActionsList';
|
|
@@ -7977,10 +7883,10 @@ const renderBounds$3 = {
|
|
|
7977
7883
|
return [SetBounds, x, y, width, height];
|
|
7978
7884
|
}
|
|
7979
7885
|
};
|
|
7980
|
-
const render$
|
|
7886
|
+
const render$a = [renderHoverDom, renderBounds$3];
|
|
7981
7887
|
const renderHover = (oldState, newState) => {
|
|
7982
7888
|
const commands = [];
|
|
7983
|
-
for (const item of render$
|
|
7889
|
+
for (const item of render$a) {
|
|
7984
7890
|
if (!item.isEqual(oldState, newState)) {
|
|
7985
7891
|
commands.push(item.apply(oldState, newState));
|
|
7986
7892
|
}
|
|
@@ -8006,41 +7912,6 @@ const focusNext = state => {
|
|
|
8006
7912
|
return focusIndex(state, nextIndex);
|
|
8007
7913
|
};
|
|
8008
7914
|
|
|
8009
|
-
const getWidgetInvoke = widgetId => {
|
|
8010
|
-
switch (widgetId) {
|
|
8011
|
-
case ColorPicker:
|
|
8012
|
-
return invoke$6;
|
|
8013
|
-
case Completion:
|
|
8014
|
-
return invoke$3;
|
|
8015
|
-
case Find:
|
|
8016
|
-
return invoke$2;
|
|
8017
|
-
case Rename:
|
|
8018
|
-
return invoke$4;
|
|
8019
|
-
default:
|
|
8020
|
-
return undefined;
|
|
8021
|
-
}
|
|
8022
|
-
};
|
|
8023
|
-
|
|
8024
|
-
const updateWidget = (editor, widgetId, newState) => {
|
|
8025
|
-
// TODO avoid closure
|
|
8026
|
-
const isWidget = widget => {
|
|
8027
|
-
return widget.id === widgetId;
|
|
8028
|
-
};
|
|
8029
|
-
const childIndex = editor.widgets.findIndex(isWidget);
|
|
8030
|
-
// TODO scroll up/down if necessary
|
|
8031
|
-
const childWidget = editor.widgets[childIndex];
|
|
8032
|
-
const newWidget = {
|
|
8033
|
-
...childWidget,
|
|
8034
|
-
oldState: childWidget.newState,
|
|
8035
|
-
newState
|
|
8036
|
-
};
|
|
8037
|
-
const newWidgets = [...editor.widgets.slice(0, childIndex), newWidget, ...editor.widgets.slice(childIndex + 1)];
|
|
8038
|
-
return {
|
|
8039
|
-
...editor,
|
|
8040
|
-
widgets: newWidgets
|
|
8041
|
-
};
|
|
8042
|
-
};
|
|
8043
|
-
|
|
8044
7915
|
const executeWidgetCommand = async (editor, name, method, _uid, widgetId, ...params) => {
|
|
8045
7916
|
const invoke = getWidgetInvoke(widgetId);
|
|
8046
7917
|
const actualMethod = method.slice(name.length + 1);
|
|
@@ -8142,6 +8013,14 @@ const getSelections2 = editorUid => {
|
|
|
8142
8013
|
} = editor;
|
|
8143
8014
|
return selections;
|
|
8144
8015
|
};
|
|
8016
|
+
const setSelections2 = (editorUid, selections) => {
|
|
8017
|
+
const editor = getEditor(editorUid);
|
|
8018
|
+
const newEditor = {
|
|
8019
|
+
...editor,
|
|
8020
|
+
selections
|
|
8021
|
+
};
|
|
8022
|
+
set$6(editorUid, editor, newEditor);
|
|
8023
|
+
};
|
|
8145
8024
|
const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocus$1) => {
|
|
8146
8025
|
const editor = getEditor(editorUid);
|
|
8147
8026
|
const invoke = getWidgetInvoke(widgetId);
|
|
@@ -8159,7 +8038,7 @@ const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocu
|
|
|
8159
8038
|
widgets: newWidgets,
|
|
8160
8039
|
focused: true
|
|
8161
8040
|
};
|
|
8162
|
-
set$
|
|
8041
|
+
set$6(editorUid, editor, newEditor);
|
|
8163
8042
|
await setFocus(FocusEditorText);
|
|
8164
8043
|
if (unsetAdditionalFocus$1) {
|
|
8165
8044
|
await unsetAdditionalFocus(unsetAdditionalFocus$1);
|
|
@@ -8171,7 +8050,7 @@ const closeFind2 = async editorUid => {
|
|
|
8171
8050
|
const applyEdits2 = async (editorUid, edits) => {
|
|
8172
8051
|
const editor = getEditor(editorUid);
|
|
8173
8052
|
const newEditor = await applyEdit(editor, edits);
|
|
8174
|
-
set$
|
|
8053
|
+
set$6(editorUid, editor, newEditor);
|
|
8175
8054
|
};
|
|
8176
8055
|
|
|
8177
8056
|
const pending = Object.create(null);
|
|
@@ -8297,6 +8176,10 @@ const getKeyBindings = () => {
|
|
|
8297
8176
|
key: Enter,
|
|
8298
8177
|
command: 'FindWidget.focusNext',
|
|
8299
8178
|
when: FocusFindWidget
|
|
8179
|
+
}, {
|
|
8180
|
+
key: CtrlCmd | KeyF,
|
|
8181
|
+
command: 'FindWidget.preventDefaultBrowserFind',
|
|
8182
|
+
when: FocusFindWidget
|
|
8300
8183
|
}, {
|
|
8301
8184
|
key: Shift | F4,
|
|
8302
8185
|
command: 'FindWidget.focusPrevious',
|
|
@@ -8732,6 +8615,56 @@ const handleTab = async editor => {
|
|
|
8732
8615
|
return applyTabCompletion(editor, result);
|
|
8733
8616
|
};
|
|
8734
8617
|
|
|
8618
|
+
const sendMessagePortToExtensionHostWorker2 = async (port, initialCommand, rpcId) => {
|
|
8619
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, initialCommand, rpcId);
|
|
8620
|
+
};
|
|
8621
|
+
|
|
8622
|
+
const createExtensionHostRpc = async () => {
|
|
8623
|
+
try {
|
|
8624
|
+
const {
|
|
8625
|
+
port1,
|
|
8626
|
+
port2
|
|
8627
|
+
} = getPortTuple();
|
|
8628
|
+
const initialCommand = 'HandleMessagePort.handleMessagePort2';
|
|
8629
|
+
await sendMessagePortToExtensionHostWorker2(port2, initialCommand, RpcId.EditorWorker);
|
|
8630
|
+
const rpc = await PlainMessagePortRpcParent.create({
|
|
8631
|
+
commandMap: {},
|
|
8632
|
+
messagePort: port1
|
|
8633
|
+
});
|
|
8634
|
+
return rpc;
|
|
8635
|
+
} catch (error) {
|
|
8636
|
+
throw new VError(error, `Failed to create extension host rpc`);
|
|
8637
|
+
}
|
|
8638
|
+
};
|
|
8639
|
+
|
|
8640
|
+
const initializeExtensionHost = async () => {
|
|
8641
|
+
const extensionHostRpc = await createExtensionHostRpc();
|
|
8642
|
+
set$5(extensionHostRpc);
|
|
8643
|
+
};
|
|
8644
|
+
|
|
8645
|
+
const sendMessagePortToSyntaxHighlightingWorker = async port => {
|
|
8646
|
+
await invokeAndTransfer(
|
|
8647
|
+
// @ts-ignore
|
|
8648
|
+
'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort');
|
|
8649
|
+
};
|
|
8650
|
+
|
|
8651
|
+
const createSyntaxHighlightingWorkerRpc = async () => {
|
|
8652
|
+
try {
|
|
8653
|
+
const {
|
|
8654
|
+
port1,
|
|
8655
|
+
port2
|
|
8656
|
+
} = getPortTuple();
|
|
8657
|
+
await sendMessagePortToSyntaxHighlightingWorker(port2);
|
|
8658
|
+
const rpc = await PlainMessagePortRpcParent.create({
|
|
8659
|
+
commandMap: {},
|
|
8660
|
+
messagePort: port1
|
|
8661
|
+
});
|
|
8662
|
+
return rpc;
|
|
8663
|
+
} catch (error) {
|
|
8664
|
+
throw new VError(error, `Failed to create synax highlighting worker rpc`);
|
|
8665
|
+
}
|
|
8666
|
+
};
|
|
8667
|
+
|
|
8735
8668
|
let enabled = false;
|
|
8736
8669
|
const setEnabled = value => {
|
|
8737
8670
|
enabled = value;
|
|
@@ -8740,16 +8673,19 @@ const getEnabled = () => {
|
|
|
8740
8673
|
return enabled;
|
|
8741
8674
|
};
|
|
8742
8675
|
|
|
8743
|
-
const
|
|
8744
|
-
await listen$2();
|
|
8676
|
+
const initializeSyntaxHighlighting = async (syntaxHighlightingEnabled, syncIncremental) => {
|
|
8745
8677
|
if (syntaxHighlightingEnabled) {
|
|
8746
8678
|
setEnabled$1(true);
|
|
8747
|
-
await
|
|
8679
|
+
const syntaxRpc = await createSyntaxHighlightingWorkerRpc();
|
|
8680
|
+
set$3(syntaxRpc);
|
|
8748
8681
|
}
|
|
8749
8682
|
if (syncIncremental) {
|
|
8750
8683
|
setEnabled(true);
|
|
8751
8684
|
}
|
|
8752
|
-
|
|
8685
|
+
};
|
|
8686
|
+
|
|
8687
|
+
const intialize = async (syntaxHighlightingEnabled, syncIncremental) => {
|
|
8688
|
+
await Promise.all([initializeSyntaxHighlighting(syntaxHighlightingEnabled, syncIncremental), initializeExtensionHost()]);
|
|
8753
8689
|
};
|
|
8754
8690
|
|
|
8755
8691
|
// TODO move cursor
|
|
@@ -8807,6 +8743,36 @@ const moveLineUp = editor => {
|
|
|
8807
8743
|
return editor;
|
|
8808
8744
|
};
|
|
8809
8745
|
|
|
8746
|
+
const launchDebugWorker = async () => {
|
|
8747
|
+
const name = 'Debug Worker';
|
|
8748
|
+
const url = 'debugWorkerMain.js';
|
|
8749
|
+
return launchWorker(name, url);
|
|
8750
|
+
};
|
|
8751
|
+
|
|
8752
|
+
let workerPromise;
|
|
8753
|
+
const getOrCreate = async () => {
|
|
8754
|
+
if (!workerPromise) {
|
|
8755
|
+
workerPromise = launchDebugWorker();
|
|
8756
|
+
}
|
|
8757
|
+
return workerPromise;
|
|
8758
|
+
};
|
|
8759
|
+
const invoke = async (method, ...params) => {
|
|
8760
|
+
const worker = await getOrCreate();
|
|
8761
|
+
return worker.invoke(method, ...params);
|
|
8762
|
+
};
|
|
8763
|
+
|
|
8764
|
+
const getHighlightedLine = async editor => {
|
|
8765
|
+
if (!editor.debugEnabled) {
|
|
8766
|
+
return -1;
|
|
8767
|
+
}
|
|
8768
|
+
try {
|
|
8769
|
+
return await invoke('Debug.getHighlightedLine', editor.uid);
|
|
8770
|
+
} catch (error) {
|
|
8771
|
+
console.error('Failed to get highlighted line:', error);
|
|
8772
|
+
return -1;
|
|
8773
|
+
}
|
|
8774
|
+
};
|
|
8775
|
+
|
|
8810
8776
|
const Link$1 = 'Link';
|
|
8811
8777
|
const Function = 'Function';
|
|
8812
8778
|
const Parameter = 'Parameter';
|
|
@@ -9038,9 +9004,12 @@ const getTokensViewport2 = async (editor, startLineIndex, endLineIndex, syncIncr
|
|
|
9038
9004
|
languageId,
|
|
9039
9005
|
invalidStartIndex
|
|
9040
9006
|
};
|
|
9041
|
-
return invoke$1('GetTokensViewport.getTokensViewport', slimEditor,
|
|
9007
|
+
return invoke$1('GetTokensViewport.getTokensViewport', slimEditor,
|
|
9008
|
+
// @ts-ignore
|
|
9009
|
+
startLineIndex, endLineIndex, hasLinesToSend, id, linesToSend);
|
|
9042
9010
|
}
|
|
9043
9011
|
// TODO only send needed lines of text
|
|
9012
|
+
// @ts-ignore
|
|
9044
9013
|
return invoke$1('GetTokensViewport.getTokensViewport', editor, startLineIndex, endLineIndex, true, editor.id, editor.lines);
|
|
9045
9014
|
}
|
|
9046
9015
|
return getTokensViewport(editor, startLineIndex, endLineIndex);
|
|
@@ -9269,6 +9238,7 @@ const getVisible = async (editor, syncIncremental) => {
|
|
|
9269
9238
|
charWidth
|
|
9270
9239
|
} = editor;
|
|
9271
9240
|
const maxLineY = Math.min(minLineY + numberOfVisibleLines, lines.length);
|
|
9241
|
+
// @ts-ignore
|
|
9272
9242
|
const {
|
|
9273
9243
|
tokens,
|
|
9274
9244
|
tokenizersToLoad,
|
|
@@ -9357,14 +9327,18 @@ const getEditorGutterVirtualDom = gutterInfos => {
|
|
|
9357
9327
|
return dom;
|
|
9358
9328
|
};
|
|
9359
9329
|
|
|
9360
|
-
const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true) => {
|
|
9330
|
+
const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1) => {
|
|
9361
9331
|
const dom = [];
|
|
9362
9332
|
for (let i = 0; i < textInfos.length; i++) {
|
|
9363
9333
|
const textInfo = textInfos[i];
|
|
9364
9334
|
const difference = differences[i];
|
|
9335
|
+
let className = EditorRow;
|
|
9336
|
+
if (i === highlightedLine) {
|
|
9337
|
+
className += ' ' + EditorRowHighlighted;
|
|
9338
|
+
}
|
|
9365
9339
|
dom.push({
|
|
9366
9340
|
type: Div,
|
|
9367
|
-
className
|
|
9341
|
+
className,
|
|
9368
9342
|
translate: px(difference),
|
|
9369
9343
|
childCount: textInfo.length / 2
|
|
9370
9344
|
});
|
|
@@ -9397,7 +9371,9 @@ const getIncrementalEdits = async (oldState, newState) => {
|
|
|
9397
9371
|
} = newState;
|
|
9398
9372
|
const oldLine = oldState.lines[rowIndex];
|
|
9399
9373
|
const newLine = lines[rowIndex];
|
|
9400
|
-
const incrementalEdits = await invoke$1('TokenizeIncremental.tokenizeIncremental', newState.uid,
|
|
9374
|
+
const incrementalEdits = await invoke$1('TokenizeIncremental.tokenizeIncremental', newState.uid,
|
|
9375
|
+
// @ts-ignore
|
|
9376
|
+
newState.languageId, oldLine, newLine, rowIndex, newState.minLineY);
|
|
9401
9377
|
if (incrementalEdits && incrementalEdits.length === 1) {
|
|
9402
9378
|
return incrementalEdits;
|
|
9403
9379
|
}
|
|
@@ -9449,7 +9425,7 @@ const removeWidget$1 = widget => {
|
|
|
9449
9425
|
|
|
9450
9426
|
const renderLines = {
|
|
9451
9427
|
isEqual(oldState, newState) {
|
|
9452
|
-
return oldState.lines === newState.lines && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.deltaX === newState.deltaX && oldState.width === newState.width;
|
|
9428
|
+
return oldState.lines === newState.lines && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.debugEnabled === newState.debugEnabled;
|
|
9453
9429
|
},
|
|
9454
9430
|
async apply(oldState, newState) {
|
|
9455
9431
|
const incrementalEdits = await getIncrementalEdits(oldState, newState);
|
|
@@ -9462,7 +9438,8 @@ const renderLines = {
|
|
|
9462
9438
|
differences
|
|
9463
9439
|
} = await getVisible(newState, syncIncremental);
|
|
9464
9440
|
newState.differences = differences;
|
|
9465
|
-
const
|
|
9441
|
+
const highlightedLine = await getHighlightedLine(newState);
|
|
9442
|
+
const dom = getEditorRowsVirtualDom(textInfos, differences, true, highlightedLine);
|
|
9466
9443
|
return [/* method */'setText', dom];
|
|
9467
9444
|
}
|
|
9468
9445
|
};
|
|
@@ -9599,7 +9576,7 @@ const renderWidgets = {
|
|
|
9599
9576
|
},
|
|
9600
9577
|
multiple: true
|
|
9601
9578
|
};
|
|
9602
|
-
const render$
|
|
9579
|
+
const render$9 = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets];
|
|
9603
9580
|
const renderEditor = async id => {
|
|
9604
9581
|
const instance = get$4(id);
|
|
9605
9582
|
if (!instance) {
|
|
@@ -9610,8 +9587,8 @@ const renderEditor = async id => {
|
|
|
9610
9587
|
newState
|
|
9611
9588
|
} = instance;
|
|
9612
9589
|
const commands = [];
|
|
9613
|
-
set$
|
|
9614
|
-
for (const item of render$
|
|
9590
|
+
set$6(id, newState, newState);
|
|
9591
|
+
for (const item of render$9) {
|
|
9615
9592
|
if (!item.isEqual(oldState, newState)) {
|
|
9616
9593
|
const result = await item.apply(oldState, newState);
|
|
9617
9594
|
// @ts-ignore
|
|
@@ -9662,6 +9639,10 @@ const renderEventListeners = () => {
|
|
|
9662
9639
|
}];
|
|
9663
9640
|
};
|
|
9664
9641
|
|
|
9642
|
+
const setDebugEnabled = (state, enabled) => {
|
|
9643
|
+
return state;
|
|
9644
|
+
};
|
|
9645
|
+
|
|
9665
9646
|
const editorDiagnosticEffect = {
|
|
9666
9647
|
isActive(oldEditor, newEditor) {
|
|
9667
9648
|
// TODO avoid slow comparison
|
|
@@ -9679,7 +9660,7 @@ const keep = [
|
|
|
9679
9660
|
// 'ColorPicker.loadContent',
|
|
9680
9661
|
'Editor.create', 'Editor.getWordAt', 'Editor.getWordBefore', 'Editor.offsetAt', 'Editor.render', 'Editor.getKeyBindings', 'Editor.getPositionAtCursor', 'Editor.getWordAt2', 'Editor.getWordAtOffset2', 'Editor.getWordBefore2', 'Editor.getLines2', 'Editor.applyEdit2', 'Editor.applyEdits2', 'Editor.closeFind2', 'Editor.closeWidget2', 'Editor.getSelections2', 'Editor.getQuickPickMenuEntries',
|
|
9681
9662
|
// 'ColorPicker.render',
|
|
9682
|
-
'Editor.getText', 'Editor.getSelections', 'Font.ensure', 'SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', 'Hover.getHoverInfo', 'Hover.handleSashPointerDown', 'Hover.handleSashPointerMove', 'Hover.handleSashPointerUp', 'Hover.loadContent', 'Hover.render', 'Initialize.initialize', 'ActivateByEvent.activateByEvent'];
|
|
9663
|
+
'Editor.getText', 'Editor.getSelections', 'Editor.setSelections2', 'Font.ensure', 'SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', 'Hover.getHoverInfo', 'Hover.handleSashPointerDown', 'Hover.handleSashPointerMove', 'Hover.handleSashPointerUp', 'Hover.loadContent', 'Hover.render', 'Initialize.initialize', 'ActivateByEvent.activateByEvent'];
|
|
9683
9664
|
|
|
9684
9665
|
const wrapWidgetCommand = (widgetId, fn) => {
|
|
9685
9666
|
const isWidget = widget => {
|
|
@@ -9719,13 +9700,16 @@ const widgetCommands = {
|
|
|
9719
9700
|
'FindWidget.focusReplaceAllButton': Find,
|
|
9720
9701
|
'FindWidget.focusNextMatchButton': Find,
|
|
9721
9702
|
'FindWidget.focusPreviousMatchButton': Find,
|
|
9722
|
-
'FindWidget.focusCloseButton': Find
|
|
9723
|
-
|
|
9724
|
-
'EditorCompletion.
|
|
9725
|
-
'EditorCompletion.
|
|
9726
|
-
'EditorCompletion.
|
|
9727
|
-
'EditorCompletion.
|
|
9728
|
-
'EditorCompletion.
|
|
9703
|
+
'FindWidget.focusCloseButton': Find
|
|
9704
|
+
|
|
9705
|
+
// 'EditorCompletion.handleWheel': WidgetId.Completion,
|
|
9706
|
+
// 'EditorCompletion.focusFirst': WidgetId.Completion,
|
|
9707
|
+
// 'EditorCompletion.focusNext': WidgetId.Completion,
|
|
9708
|
+
// 'EditorCompletion.focusPrevious': WidgetId.Completion,
|
|
9709
|
+
// 'EditorCompletion.focusIndex': WidgetId.Completion,
|
|
9710
|
+
// 'EditorCompletion.focusLast': WidgetId.Completion,
|
|
9711
|
+
// 'EditorCompletion.selectCurrent': WidgetId.Completion,
|
|
9712
|
+
// 'EditorCompletion.selectIndex': WidgetId.Completion,
|
|
9729
9713
|
};
|
|
9730
9714
|
|
|
9731
9715
|
// TODO wrap commands globally, not per editor
|
|
@@ -9740,7 +9724,7 @@ const wrapCommand = fn => async (editorUid, ...args) => {
|
|
|
9740
9724
|
effect.apply(newEditor);
|
|
9741
9725
|
}
|
|
9742
9726
|
}
|
|
9743
|
-
set$
|
|
9727
|
+
set$6(editorUid, oldInstance.newState, newEditor);
|
|
9744
9728
|
// TODO if possible, rendering should be sync
|
|
9745
9729
|
const commands = await renderEditor(editorUid);
|
|
9746
9730
|
newEditor.commands = commands;
|
|
@@ -9765,12 +9749,15 @@ const commandMap = {
|
|
|
9765
9749
|
'Editor.addCursorAbove': addCursorAbove,
|
|
9766
9750
|
'Editor.addCursorBelow': addCursorBelow,
|
|
9767
9751
|
'Editor.applyEdit': applyEdit,
|
|
9752
|
+
'Editor.applyEdit2': applyEdits2,
|
|
9768
9753
|
'Editor.braceCompletion': braceCompletion,
|
|
9769
9754
|
'Editor.cancelSelection': cancelSelection,
|
|
9770
9755
|
'Editor.closeCodeGenerator': closeCodeGenerator,
|
|
9771
9756
|
'Editor.closeFind': closeFind,
|
|
9757
|
+
'Editor.closeFind2': closeFind2,
|
|
9772
9758
|
'Editor.closeRename': closeRename,
|
|
9773
9759
|
'Editor.closeSourceAction': closeSourceAction,
|
|
9760
|
+
'Editor.closeWidget2': closeWidget2,
|
|
9774
9761
|
'Editor.compositionEnd': compositionEnd,
|
|
9775
9762
|
'Editor.compositionStart': compositionStart,
|
|
9776
9763
|
'Editor.compositionUpdate': compositionUpdate,
|
|
@@ -9802,9 +9789,6 @@ const commandMap = {
|
|
|
9802
9789
|
'Editor.deleteRight': deleteCharacterRight,
|
|
9803
9790
|
'Editor.deleteWordLeft': deleteWordLeft,
|
|
9804
9791
|
'Editor.deleteWordPartLeft': deleteWordPartLeft,
|
|
9805
|
-
'Editor.applyEdit2': applyEdits2,
|
|
9806
|
-
'Editor.closeFind2': closeFind2,
|
|
9807
|
-
'Editor.closeWidget2': closeWidget2,
|
|
9808
9792
|
'Editor.deleteWordPartRight': deleteWordPartRight,
|
|
9809
9793
|
'Editor.deleteWordRight': deleteWordRight,
|
|
9810
9794
|
'Editor.executeWidgetCommand': executeWidgetCommand,
|
|
@@ -9826,10 +9810,10 @@ const commandMap = {
|
|
|
9826
9810
|
'Editor.goToTypeDefinition': goToTypeDefinition,
|
|
9827
9811
|
'Editor.handleBeforeInput': handleBeforeInput,
|
|
9828
9812
|
'Editor.handleBeforeInputFromContentEditable': handleBeforeInputFromContentEditable,
|
|
9829
|
-
'Editor.handleBlur': handleBlur,
|
|
9813
|
+
'Editor.handleBlur': handleBlur$1,
|
|
9830
9814
|
'Editor.handleContextMenu': handleContextMenu,
|
|
9831
9815
|
'Editor.handleDoubleClick': handleDoubleClick,
|
|
9832
|
-
'Editor.handleFocus': handleFocus,
|
|
9816
|
+
'Editor.handleFocus': handleFocus$1,
|
|
9833
9817
|
'Editor.handleMouseDown': handleMouseDown,
|
|
9834
9818
|
'Editor.handleMouseMove': handleMouseMove,
|
|
9835
9819
|
'Editor.handleMouseMoveWithAltKey': handleMouseMoveWithAltKey,
|
|
@@ -9862,21 +9846,6 @@ const commandMap = {
|
|
|
9862
9846
|
'Editor.openCodeGenerator': openCodeGenerator,
|
|
9863
9847
|
'Editor.openColorPicker': openColorPicker,
|
|
9864
9848
|
'Editor.openCompletion': openCompletion,
|
|
9865
|
-
'EditorCompletion.closeDetails': closeDetails,
|
|
9866
|
-
'EditorCompletion.focusFirst': focusFirst,
|
|
9867
|
-
'EditorCompletion.focusIndex': focusIndex$1,
|
|
9868
|
-
'EditorCompletion.focusNext': focusNext$1,
|
|
9869
|
-
'EditorCompletion.focusPrevious': focusPrevious,
|
|
9870
|
-
'EditorCompletion.handleEditorBlur': handleEditorBlur,
|
|
9871
|
-
'EditorCompletion.handleEditorClick': handleEditorClick,
|
|
9872
|
-
'EditorCompletion.handleEditorDeleteLeft': handleEditorDeleteLeft$1,
|
|
9873
|
-
'EditorCompletion.handleEditorType': handleEditorType$1,
|
|
9874
|
-
'EditorCompletion.handleWheel': handleWheel,
|
|
9875
|
-
'EditorCompletion.openDetails': openDetails,
|
|
9876
|
-
'EditorCompletion.selectCurrent': selectCurrent,
|
|
9877
|
-
'EditorCompletion.close': close,
|
|
9878
|
-
'EditorCompletion.selectIndex': selectIndex,
|
|
9879
|
-
'EditorCompletion.toggleDetails': toggleDetails,
|
|
9880
9849
|
'Editor.openFind': openFind,
|
|
9881
9850
|
'Editor.openFind2': openFind2,
|
|
9882
9851
|
'Editor.openRename': openRename,
|
|
@@ -9904,11 +9873,13 @@ const commandMap = {
|
|
|
9904
9873
|
'Editor.selectWord': selectWord,
|
|
9905
9874
|
'Editor.selectWordLeft': selectWordLeft,
|
|
9906
9875
|
'Editor.selectWordRight': selectWordRight,
|
|
9876
|
+
'Editor.setDebugEnabled': setDebugEnabled,
|
|
9907
9877
|
'Editor.setDecorations': setDecorations,
|
|
9908
9878
|
'Editor.setDelta': setDelta,
|
|
9909
9879
|
'Editor.setDeltaY': setDeltaY,
|
|
9910
9880
|
'Editor.setLanguageId': setLanguageId,
|
|
9911
9881
|
'Editor.setSelections': setSelections,
|
|
9882
|
+
'Editor.setSelections2': setSelections2,
|
|
9912
9883
|
'Editor.showHover': showHover,
|
|
9913
9884
|
'Editor.showHover2': showHover2,
|
|
9914
9885
|
'Editor.showSourceActions': showSourceActions,
|
|
@@ -9923,9 +9894,41 @@ const commandMap = {
|
|
|
9923
9894
|
'Editor.undo': undo,
|
|
9924
9895
|
'Editor.unIndent': editorUnindent,
|
|
9925
9896
|
'Editor.updateDiagnostics': updateDiagnostics,
|
|
9897
|
+
'EditorCompletion.close': close$1,
|
|
9898
|
+
'EditorCompletion.closeDetails': closeDetails,
|
|
9899
|
+
'EditorCompletion.focusFirst': focusFirst,
|
|
9900
|
+
'EditorCompletion.focusIndex': focusIndex$1,
|
|
9901
|
+
'EditorCompletion.focusNext': focusNext$2,
|
|
9902
|
+
'EditorCompletion.focusPrevious': focusPrevious$1,
|
|
9903
|
+
'EditorCompletion.handleEditorBlur': handleEditorBlur,
|
|
9904
|
+
'EditorCompletion.handleEditorClick': handleEditorClick,
|
|
9905
|
+
'EditorCompletion.handleEditorDeleteLeft': handleEditorDeleteLeft$1,
|
|
9906
|
+
'EditorCompletion.handleEditorType': handleEditorType$1,
|
|
9907
|
+
'EditorCompletion.handleWheel': handleWheel,
|
|
9908
|
+
'EditorCompletion.openDetails': openDetails,
|
|
9909
|
+
'EditorCompletion.selectCurrent': selectCurrent,
|
|
9910
|
+
'EditorCompletion.selectIndex': selectIndex,
|
|
9911
|
+
'EditorCompletion.toggleDetails': toggleDetails,
|
|
9926
9912
|
'EditorSourceActions.focusNext': focusNext,
|
|
9927
|
-
'FindWidget.close': close
|
|
9913
|
+
'FindWidget.close': close,
|
|
9914
|
+
'FindWidget.focusCloseButton': focusCloseButton,
|
|
9915
|
+
'FindWidget.focusFind': focusFind,
|
|
9916
|
+
'FindWidget.focusNext': focusNext$1,
|
|
9917
|
+
'FindWidget.focusNextMatchButton': focusNextMatchButton,
|
|
9918
|
+
'FindWidget.focusPrevious': focusPrevious,
|
|
9919
|
+
'FindWidget.focusPreviousMatchButton': focusPreviousMatchButton,
|
|
9920
|
+
'FindWidget.focusReplace': focusReplace,
|
|
9921
|
+
'FindWidget.focusReplaceAllButton': focusReplaceAllButton,
|
|
9922
|
+
'FindWidget.focusReplaceButton': focusReplaceButton,
|
|
9923
|
+
'FindWidget.focusToggleReplace': focusToggleReplace,
|
|
9924
|
+
'FindWidget.handleBlur': handleBlur,
|
|
9925
|
+
'FindWidget.handleFocus': handleFocus,
|
|
9926
|
+
'FindWidget.handleInput': handleInput,
|
|
9927
|
+
'FindWidget.handleReplaceFocus': handleReplaceFocus,
|
|
9928
|
+
'FindWidget.handleReplaceInput': handleReplaceInput,
|
|
9929
|
+
'FindWidget.handleToggleReplaceFocus': handleToggleReplaceFocus,
|
|
9928
9930
|
'FindWidget.loadContent': loadContent$1,
|
|
9931
|
+
'FindWidget.toggleReplace': toggleReplace,
|
|
9929
9932
|
'Font.ensure': ensure,
|
|
9930
9933
|
'Hover.getHoverInfo': getEditorHoverInfo,
|
|
9931
9934
|
'Hover.handleSashPointerDown': handleSashPointerDown,
|
|
@@ -9938,59 +9941,11 @@ const commandMap = {
|
|
|
9938
9941
|
};
|
|
9939
9942
|
wrapCommands(commandMap);
|
|
9940
9943
|
|
|
9941
|
-
const MessagePort$1 = 1;
|
|
9942
|
-
const ModuleWorker = 2;
|
|
9943
|
-
const ReferencePort = 3;
|
|
9944
|
-
const ModuleWorkerAndMessagePort = 8;
|
|
9945
|
-
const Auto = () => {
|
|
9946
|
-
// @ts-ignore
|
|
9947
|
-
if (globalThis.acceptPort) {
|
|
9948
|
-
return MessagePort$1;
|
|
9949
|
-
}
|
|
9950
|
-
// @ts-ignore
|
|
9951
|
-
if (globalThis.acceptReferencePort) {
|
|
9952
|
-
return ReferencePort;
|
|
9953
|
-
}
|
|
9954
|
-
return ModuleWorkerAndMessagePort;
|
|
9955
|
-
};
|
|
9956
|
-
|
|
9957
|
-
const getModule = method => {
|
|
9958
|
-
switch (method) {
|
|
9959
|
-
case ModuleWorker:
|
|
9960
|
-
return IpcChildWithModuleWorker$1;
|
|
9961
|
-
case ModuleWorkerAndMessagePort:
|
|
9962
|
-
return IpcChildWithModuleWorkerAndMessagePort$1;
|
|
9963
|
-
case MessagePort$1:
|
|
9964
|
-
return IpcChildWithMessagePort$1;
|
|
9965
|
-
default:
|
|
9966
|
-
throw new Error('unexpected ipc type');
|
|
9967
|
-
}
|
|
9968
|
-
};
|
|
9969
|
-
|
|
9970
|
-
// @ts-ignore
|
|
9971
|
-
const listen$1 = async ({
|
|
9972
|
-
method
|
|
9973
|
-
}) => {
|
|
9974
|
-
const module = await getModule(method);
|
|
9975
|
-
// @ts-ignore
|
|
9976
|
-
const rawIpc = await module.listen();
|
|
9977
|
-
// @ts-ignore
|
|
9978
|
-
if (module.signal) {
|
|
9979
|
-
// @ts-ignore
|
|
9980
|
-
module.signal(rawIpc);
|
|
9981
|
-
}
|
|
9982
|
-
// @ts-ignore
|
|
9983
|
-
const ipc = module.wrap(rawIpc);
|
|
9984
|
-
return ipc;
|
|
9985
|
-
};
|
|
9986
|
-
|
|
9987
9944
|
const listen = async () => {
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
method: Auto()
|
|
9945
|
+
const rpc = await WebWorkerRpcClient.create({
|
|
9946
|
+
commandMap: commandMap
|
|
9991
9947
|
});
|
|
9992
|
-
|
|
9993
|
-
listen$5(ipc);
|
|
9948
|
+
set$8(rpc);
|
|
9994
9949
|
};
|
|
9995
9950
|
|
|
9996
9951
|
const removeWidget = widget => {
|
|
@@ -10051,10 +10006,10 @@ const renderFocus = {
|
|
|
10051
10006
|
return [Focus, '.CodeGeneratorInput', newState.focusSource];
|
|
10052
10007
|
}
|
|
10053
10008
|
};
|
|
10054
|
-
const render$
|
|
10055
|
-
const renderFull$
|
|
10009
|
+
const render$8 = [renderContent$1, renderBounds$2, renderFocus];
|
|
10010
|
+
const renderFull$2 = (oldState, newState) => {
|
|
10056
10011
|
const commands = [];
|
|
10057
|
-
for (const item of render$
|
|
10012
|
+
for (const item of render$8) {
|
|
10058
10013
|
if (!item.isEqual(oldState, newState)) {
|
|
10059
10014
|
commands.push(item.apply(oldState, newState));
|
|
10060
10015
|
}
|
|
@@ -10062,8 +10017,8 @@ const renderFull$3 = (oldState, newState) => {
|
|
|
10062
10017
|
return commands;
|
|
10063
10018
|
};
|
|
10064
10019
|
|
|
10065
|
-
const render$
|
|
10066
|
-
const commands = renderFull$
|
|
10020
|
+
const render$7 = widget => {
|
|
10021
|
+
const commands = renderFull$2(widget.oldState, widget.newState);
|
|
10067
10022
|
const wrappedCommands = [];
|
|
10068
10023
|
const {
|
|
10069
10024
|
uid
|
|
@@ -10078,27 +10033,27 @@ const render$8 = widget => {
|
|
|
10078
10033
|
}
|
|
10079
10034
|
return wrappedCommands;
|
|
10080
10035
|
};
|
|
10081
|
-
const add$
|
|
10082
|
-
return addWidget$1(widget, 'EditorCodeGenerator', render$
|
|
10036
|
+
const add$5 = widget => {
|
|
10037
|
+
return addWidget$1(widget, 'EditorCodeGenerator', render$7);
|
|
10083
10038
|
};
|
|
10084
|
-
const remove$
|
|
10039
|
+
const remove$5 = removeWidget;
|
|
10085
10040
|
|
|
10086
10041
|
const EditorCodeGeneratorWidget = {
|
|
10087
10042
|
__proto__: null,
|
|
10088
|
-
add: add$
|
|
10089
|
-
remove: remove$
|
|
10090
|
-
render: render$
|
|
10043
|
+
add: add$5,
|
|
10044
|
+
remove: remove$5,
|
|
10045
|
+
render: render$7
|
|
10091
10046
|
};
|
|
10092
10047
|
|
|
10093
|
-
const renderFull$
|
|
10048
|
+
const renderFull$1 = (oldState, newState) => {
|
|
10094
10049
|
const commands = [...newState.commands];
|
|
10095
10050
|
// @ts-ignore
|
|
10096
10051
|
newState.commands = [];
|
|
10097
10052
|
return commands;
|
|
10098
10053
|
};
|
|
10099
10054
|
|
|
10100
|
-
const render$
|
|
10101
|
-
const commands = renderFull$
|
|
10055
|
+
const render$6 = widget => {
|
|
10056
|
+
const commands = renderFull$1(widget.oldState, widget.newState);
|
|
10102
10057
|
const wrappedCommands = [];
|
|
10103
10058
|
const {
|
|
10104
10059
|
uid
|
|
@@ -10112,18 +10067,18 @@ const render$7 = widget => {
|
|
|
10112
10067
|
}
|
|
10113
10068
|
return wrappedCommands;
|
|
10114
10069
|
};
|
|
10115
|
-
const add$
|
|
10116
|
-
return addWidget$1(widget, 'ColorPicker', render$
|
|
10070
|
+
const add$4 = widget => {
|
|
10071
|
+
return addWidget$1(widget, 'ColorPicker', render$6);
|
|
10117
10072
|
};
|
|
10118
|
-
const remove$
|
|
10119
|
-
const Commands
|
|
10073
|
+
const remove$4 = removeWidget;
|
|
10074
|
+
const Commands = {};
|
|
10120
10075
|
|
|
10121
10076
|
const EditorColorPickerWidget = {
|
|
10122
10077
|
__proto__: null,
|
|
10123
|
-
Commands
|
|
10124
|
-
add: add$
|
|
10125
|
-
remove: remove$
|
|
10126
|
-
render: render$
|
|
10078
|
+
Commands,
|
|
10079
|
+
add: add$4,
|
|
10080
|
+
remove: remove$4,
|
|
10081
|
+
render: render$6
|
|
10127
10082
|
};
|
|
10128
10083
|
|
|
10129
10084
|
const getCompletionDetailVirtualDom = content => {
|
|
@@ -10181,9 +10136,9 @@ const renderBounds$1 = {
|
|
|
10181
10136
|
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
10182
10137
|
}
|
|
10183
10138
|
};
|
|
10184
|
-
const render$
|
|
10185
|
-
const renderFull
|
|
10186
|
-
return renderParts(render$
|
|
10139
|
+
const render$5 = [renderContent, renderBounds$1];
|
|
10140
|
+
const renderFull = (oldState, newState) => {
|
|
10141
|
+
return renderParts(render$5, oldState, newState);
|
|
10187
10142
|
};
|
|
10188
10143
|
|
|
10189
10144
|
const getWidgetState = (editor, id) => {
|
|
@@ -10202,8 +10157,8 @@ const getCompletionState = editor => {
|
|
|
10202
10157
|
return getWidgetState(editor, Completion);
|
|
10203
10158
|
};
|
|
10204
10159
|
|
|
10205
|
-
const render$
|
|
10206
|
-
const commands = renderFull
|
|
10160
|
+
const render$4 = widget => {
|
|
10161
|
+
const commands = renderFull(widget.oldState, widget.newState);
|
|
10207
10162
|
const wrappedCommands = [];
|
|
10208
10163
|
const {
|
|
10209
10164
|
uid
|
|
@@ -10217,10 +10172,10 @@ const render$5 = widget => {
|
|
|
10217
10172
|
}
|
|
10218
10173
|
return wrappedCommands;
|
|
10219
10174
|
};
|
|
10220
|
-
const add$
|
|
10221
|
-
return addWidget$1(widget, 'EditorCompletionDetails', render$
|
|
10175
|
+
const add$3 = widget => {
|
|
10176
|
+
return addWidget$1(widget, 'EditorCompletionDetails', render$4);
|
|
10222
10177
|
};
|
|
10223
|
-
const remove$
|
|
10178
|
+
const remove$3 = removeWidget;
|
|
10224
10179
|
const handleEditorType = (editor, state) => {
|
|
10225
10180
|
const completionState = getCompletionState(editor);
|
|
10226
10181
|
if (!completionState) {
|
|
@@ -10252,47 +10207,9 @@ const handleEditorDeleteLeft = (editor, state) => {
|
|
|
10252
10207
|
|
|
10253
10208
|
const EditorCompletionDetailWidget = {
|
|
10254
10209
|
__proto__: null,
|
|
10255
|
-
add: add$
|
|
10210
|
+
add: add$3,
|
|
10256
10211
|
handleEditorDeleteLeft,
|
|
10257
10212
|
handleEditorType,
|
|
10258
|
-
remove: remove$4,
|
|
10259
|
-
render: render$5
|
|
10260
|
-
};
|
|
10261
|
-
|
|
10262
|
-
const renderFull = (oldState, newState) => {
|
|
10263
|
-
const commands = [...newState.commands];
|
|
10264
|
-
// @ts-ignore
|
|
10265
|
-
newState.commands = [];
|
|
10266
|
-
return commands;
|
|
10267
|
-
};
|
|
10268
|
-
|
|
10269
|
-
const render$4 = widget => {
|
|
10270
|
-
const commands = renderFull(widget.oldState, widget.newState);
|
|
10271
|
-
const wrappedCommands = [];
|
|
10272
|
-
const {
|
|
10273
|
-
uid
|
|
10274
|
-
} = widget.newState;
|
|
10275
|
-
for (const command of commands) {
|
|
10276
|
-
if (command[0] === SetDom2 || command[0] === SetCss || command[0] === AppendToBody || command[0] === SetBounds2 || command[0] === RegisterEventListeners || command[0] === SetSelectionByName || command[0] === SetValueByName || command[0] === SetFocusContext || command[0] === SetUid || command[0] === 'Viewlet.focusSelector') {
|
|
10277
|
-
wrappedCommands.push(command);
|
|
10278
|
-
} else {
|
|
10279
|
-
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
10280
|
-
}
|
|
10281
|
-
}
|
|
10282
|
-
return wrappedCommands;
|
|
10283
|
-
};
|
|
10284
|
-
const add$3 = widget => {
|
|
10285
|
-
return addWidget$1(widget, 'FindWidget', render$4);
|
|
10286
|
-
};
|
|
10287
|
-
const remove$3 = widget => {
|
|
10288
|
-
return [['Viewlet.dispose', widget.newState.uid]];
|
|
10289
|
-
};
|
|
10290
|
-
const Commands = {};
|
|
10291
|
-
|
|
10292
|
-
const EditorFindWidget = {
|
|
10293
|
-
__proto__: null,
|
|
10294
|
-
Commands,
|
|
10295
|
-
add: add$3,
|
|
10296
10213
|
remove: remove$3,
|
|
10297
10214
|
render: render$4
|
|
10298
10215
|
};
|
|
@@ -10488,14 +10405,14 @@ const EditorSourceActionWidget = {
|
|
|
10488
10405
|
};
|
|
10489
10406
|
|
|
10490
10407
|
const registerWidgets = () => {
|
|
10491
|
-
set$
|
|
10492
|
-
set$
|
|
10493
|
-
set$
|
|
10494
|
-
set$
|
|
10495
|
-
set$
|
|
10496
|
-
set$
|
|
10497
|
-
set$
|
|
10498
|
-
set$
|
|
10408
|
+
set$7(ColorPicker, EditorColorPickerWidget);
|
|
10409
|
+
set$7(Completion, EditorCompletionWidget);
|
|
10410
|
+
set$7(CompletionDetail, EditorCompletionDetailWidget);
|
|
10411
|
+
set$7(Find, EditorFindWidget);
|
|
10412
|
+
set$7(Hover, EditorHoverWidget);
|
|
10413
|
+
set$7(Rename, EditorRenameWidget);
|
|
10414
|
+
set$7(SourceAction$1, EditorSourceActionWidget);
|
|
10415
|
+
set$7(CodeGenerator, EditorCodeGeneratorWidget);
|
|
10499
10416
|
};
|
|
10500
10417
|
|
|
10501
10418
|
const handleUnhandledRejection = event => {
|