@lvce-editor/editor-worker 7.3.0 → 7.5.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 +1215 -1298
- 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) {
|
|
@@ -717,30 +314,189 @@ let IpcError$1 = class IpcError extends VError {
|
|
|
717
314
|
} else {
|
|
718
315
|
super(betterMessage);
|
|
719
316
|
}
|
|
720
|
-
// @ts-ignore
|
|
721
|
-
this.name = 'IpcError';
|
|
722
|
-
// @ts-ignore
|
|
723
|
-
this.stdout = stdout;
|
|
724
|
-
// @ts-ignore
|
|
725
|
-
this.stderr = stderr;
|
|
317
|
+
// @ts-ignore
|
|
318
|
+
this.name = 'IpcError';
|
|
319
|
+
// @ts-ignore
|
|
320
|
+
this.stdout = stdout;
|
|
321
|
+
// @ts-ignore
|
|
322
|
+
this.stderr = stderr;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
const readyMessage = 'ready';
|
|
326
|
+
const getData$2 = event => {
|
|
327
|
+
return event.data;
|
|
328
|
+
};
|
|
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;
|
|
726
465
|
}
|
|
466
|
+
return promise;
|
|
727
467
|
};
|
|
728
|
-
const
|
|
729
|
-
const
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
const listen$8 = ({
|
|
733
|
-
port
|
|
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
|
-
|
|
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;
|
|
643
|
+
}
|
|
644
|
+
return parentStack;
|
|
645
|
+
};
|
|
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;
|
|
655
|
+
}
|
|
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;
|
|
661
|
+
}
|
|
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;
|
|
832
697
|
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
parentIpc.send({
|
|
836
|
-
jsonrpc: '2.0',
|
|
837
|
-
id: firstMessage.id,
|
|
838
|
-
result: null
|
|
839
|
-
});
|
|
840
|
-
parentIpc.dispose();
|
|
841
|
-
const port = firstMessage.params[1];
|
|
842
|
-
return port;
|
|
698
|
+
if (typeof error === 'string') {
|
|
699
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
843
700
|
}
|
|
844
|
-
return
|
|
701
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
845
702
|
};
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
send(message) {
|
|
851
|
-
this._rawIpc.postMessage(message);
|
|
703
|
+
const unwrapJsonRpcResult = responseMessage => {
|
|
704
|
+
if ('error' in responseMessage) {
|
|
705
|
+
const restoredError = restoreJsonRpcError(responseMessage.error);
|
|
706
|
+
throw restoredError;
|
|
852
707
|
}
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
this._rawIpc.postMessage(message, transfer);
|
|
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
|
|
|
1186
|
+
const launchColorPickerWorker = async () => {
|
|
1187
|
+
const name = 'Color Picker Worker';
|
|
1188
|
+
const url = 'colorPickerWorkerMain.js';
|
|
1189
|
+
return launchWorker(name, url);
|
|
1190
|
+
};
|
|
1191
|
+
|
|
1073
1192
|
let workerPromise$3;
|
|
1074
|
-
const getOrCreate$
|
|
1193
|
+
const getOrCreate$5 = () => {
|
|
1075
1194
|
if (!workerPromise$3) {
|
|
1076
1195
|
workerPromise$3 = launchColorPickerWorker();
|
|
1077
1196
|
}
|
|
1078
1197
|
return workerPromise$3;
|
|
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,
|
|
@@ -1979,336 +2098,58 @@ const hasSelection = editor => {
|
|
|
1979
2098
|
// TODO editor.selections should always be defined
|
|
1980
2099
|
return editor.selections && editor.selections.length > 0;
|
|
1981
2100
|
};
|
|
1982
|
-
const setBounds = (editor, x, y, width, height, columnWidth) => {
|
|
1983
|
-
const {
|
|
1984
|
-
itemHeight
|
|
1985
|
-
} = editor;
|
|
1986
|
-
const numberOfVisibleLines = Math.floor(height / itemHeight);
|
|
1987
|
-
const total = editor.lines.length;
|
|
1988
|
-
const maxLineY = Math.min(numberOfVisibleLines, total);
|
|
1989
|
-
const finalY = Math.max(total - numberOfVisibleLines, 0);
|
|
1990
|
-
const finalDeltaY = finalY * itemHeight;
|
|
1991
|
-
return {
|
|
1992
|
-
...editor,
|
|
1993
|
-
x,
|
|
1994
|
-
y,
|
|
1995
|
-
width,
|
|
1996
|
-
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 () => {
|
|
2101
|
+
const setBounds = (editor, x, y, width, height, columnWidth) => {
|
|
2211
2102
|
const {
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
const
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
}
|
|
2220
|
-
return port2;
|
|
2221
|
-
};
|
|
2222
|
-
const wrap = port => {
|
|
2103
|
+
itemHeight
|
|
2104
|
+
} = editor;
|
|
2105
|
+
const numberOfVisibleLines = Math.floor(height / itemHeight);
|
|
2106
|
+
const total = editor.lines.length;
|
|
2107
|
+
const maxLineY = Math.min(numberOfVisibleLines, total);
|
|
2108
|
+
const finalY = Math.max(total - numberOfVisibleLines, 0);
|
|
2109
|
+
const finalDeltaY = finalY * itemHeight;
|
|
2223
2110
|
return {
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
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
|
-
}
|
|
2111
|
+
...editor,
|
|
2112
|
+
x,
|
|
2113
|
+
y,
|
|
2114
|
+
width,
|
|
2115
|
+
height,
|
|
2116
|
+
columnWidth,
|
|
2117
|
+
numberOfVisibleLines,
|
|
2118
|
+
maxLineY,
|
|
2119
|
+
finalY,
|
|
2120
|
+
finalDeltaY
|
|
2250
2121
|
};
|
|
2251
2122
|
};
|
|
2252
|
-
|
|
2253
|
-
const
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
const
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
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);
|
|
2301
|
-
};
|
|
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
2866
|
let workerPromise$2;
|
|
3035
|
-
const getOrCreate$
|
|
2867
|
+
const getOrCreate$3 = () => {
|
|
3036
2868
|
if (!workerPromise$2) {
|
|
3037
2869
|
workerPromise$2 = launchRenameWorker();
|
|
3038
2870
|
}
|
|
3039
2871
|
return workerPromise$2;
|
|
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
5176
|
let workerPromise$1;
|
|
5356
|
-
const getOrCreate$
|
|
5177
|
+
const getOrCreate$2 = () => {
|
|
5357
5178
|
if (!workerPromise$1) {
|
|
5358
5179
|
workerPromise$1 = launchCompletionWorker();
|
|
5359
5180
|
}
|
|
5360
5181
|
return workerPromise$1;
|
|
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
5246
|
let workerPromise;
|
|
5442
|
-
const getOrCreate = () => {
|
|
5247
|
+
const getOrCreate$1 = () => {
|
|
5443
5248
|
if (!workerPromise) {
|
|
5444
5249
|
workerPromise = launchFindWidgetWorker();
|
|
5445
5250
|
}
|
|
5446
5251
|
return workerPromise;
|
|
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,23 +7459,19 @@ const addWidget$1 = (widget, id, render) => {
|
|
|
7678
7459
|
return allCommands;
|
|
7679
7460
|
};
|
|
7680
7461
|
|
|
7681
|
-
const
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
const commands = [...newState.commands];
|
|
7695
|
-
// @ts-ignore
|
|
7696
|
-
newState.commands = [];
|
|
7697
|
-
return commands;
|
|
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
|
+
}
|
|
7698
7475
|
};
|
|
7699
7476
|
|
|
7700
7477
|
const updateWidget = (editor, widgetId, newState) => {
|
|
@@ -7720,29 +7497,7 @@ const updateWidget = (editor, widgetId, newState) => {
|
|
|
7720
7497
|
};
|
|
7721
7498
|
};
|
|
7722
7499
|
|
|
7723
|
-
const
|
|
7724
|
-
const commands = renderFull$4(widget.oldState, widget.newState);
|
|
7725
|
-
const wrappedCommands = [];
|
|
7726
|
-
const {
|
|
7727
|
-
uid
|
|
7728
|
-
} = widget.newState;
|
|
7729
|
-
for (const command of commands) {
|
|
7730
|
-
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') {
|
|
7731
|
-
wrappedCommands.push(command);
|
|
7732
|
-
} else {
|
|
7733
|
-
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
7734
|
-
}
|
|
7735
|
-
}
|
|
7736
|
-
return wrappedCommands;
|
|
7737
|
-
};
|
|
7738
|
-
const add$7 = widget => {
|
|
7739
|
-
return addWidget$1(widget, 'EditorRename', render$c);
|
|
7740
|
-
};
|
|
7741
|
-
const remove$7 = widget => {
|
|
7742
|
-
return [['Viewlet.dispose', widget.newState.uid]];
|
|
7743
|
-
};
|
|
7744
|
-
const createFn = key => {
|
|
7745
|
-
const widgetId = Completion;
|
|
7500
|
+
const createFn = (key, name, widgetId) => {
|
|
7746
7501
|
const isWidget = widget => {
|
|
7747
7502
|
return widget.id === widgetId;
|
|
7748
7503
|
};
|
|
@@ -7754,9 +7509,10 @@ const createFn = key => {
|
|
|
7754
7509
|
const {
|
|
7755
7510
|
uid
|
|
7756
7511
|
} = state;
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
const
|
|
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);
|
|
7760
7516
|
const newState = {
|
|
7761
7517
|
...state,
|
|
7762
7518
|
commands
|
|
@@ -7767,19 +7523,60 @@ const createFn = key => {
|
|
|
7767
7523
|
};
|
|
7768
7524
|
return fn;
|
|
7769
7525
|
};
|
|
7770
|
-
const createFns = keys => {
|
|
7526
|
+
const createFns = (keys, name, widgetId) => {
|
|
7771
7527
|
const fns = Object.create(null);
|
|
7772
7528
|
for (const key of keys) {
|
|
7773
|
-
fns[key] = createFn(key);
|
|
7529
|
+
fns[key] = createFn(key, name, widgetId);
|
|
7774
7530
|
}
|
|
7775
7531
|
return fns;
|
|
7776
7532
|
};
|
|
7533
|
+
|
|
7534
|
+
const AppendToBody = 'Viewlet.appendToBody';
|
|
7535
|
+
const Focus = 'focus';
|
|
7536
|
+
const RegisterEventListeners = 'Viewlet.registerEventListeners';
|
|
7537
|
+
const SetSelectionByName = 'Viewlet.setSelectionByName';
|
|
7538
|
+
const SetValueByName = 'Viewlet.setValueByName';
|
|
7539
|
+
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
7540
|
+
const SetBounds = 'setBounds';
|
|
7541
|
+
const SetBounds2 = 'Viewlet.setBounds';
|
|
7542
|
+
const SetCss = 'Viewlet.setCss';
|
|
7543
|
+
const SetDom2 = 'Viewlet.setDom2';
|
|
7544
|
+
const SetUid = 'Viewlet.setUid';
|
|
7545
|
+
|
|
7546
|
+
const renderFull$4 = (oldState, newState) => {
|
|
7547
|
+
const commands = [...newState.commands];
|
|
7548
|
+
// @ts-ignore
|
|
7549
|
+
newState.commands = [];
|
|
7550
|
+
return commands;
|
|
7551
|
+
};
|
|
7552
|
+
|
|
7553
|
+
const render$c = widget => {
|
|
7554
|
+
const commands = renderFull$4(widget.oldState, widget.newState);
|
|
7555
|
+
const wrappedCommands = [];
|
|
7556
|
+
const {
|
|
7557
|
+
uid
|
|
7558
|
+
} = widget.newState;
|
|
7559
|
+
for (const command of commands) {
|
|
7560
|
+
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') {
|
|
7561
|
+
wrappedCommands.push(command);
|
|
7562
|
+
} else {
|
|
7563
|
+
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
7564
|
+
}
|
|
7565
|
+
}
|
|
7566
|
+
return wrappedCommands;
|
|
7567
|
+
};
|
|
7568
|
+
const add$7 = widget => {
|
|
7569
|
+
return addWidget$1(widget, 'EditorRename', render$c);
|
|
7570
|
+
};
|
|
7571
|
+
const remove$7 = widget => {
|
|
7572
|
+
return [['Viewlet.dispose', widget.newState.uid]];
|
|
7573
|
+
};
|
|
7777
7574
|
const {
|
|
7778
7575
|
focusFirst,
|
|
7779
7576
|
focusIndex: focusIndex$1,
|
|
7780
7577
|
focusLast,
|
|
7781
|
-
focusNext: focusNext$
|
|
7782
|
-
focusPrevious,
|
|
7578
|
+
focusNext: focusNext$2,
|
|
7579
|
+
focusPrevious: focusPrevious$1,
|
|
7783
7580
|
handleEditorBlur,
|
|
7784
7581
|
handleEditorClick,
|
|
7785
7582
|
handleEditorDeleteLeft: handleEditorDeleteLeft$1,
|
|
@@ -7790,19 +7587,19 @@ const {
|
|
|
7790
7587
|
toggleDetails,
|
|
7791
7588
|
closeDetails,
|
|
7792
7589
|
handleWheel,
|
|
7793
|
-
close
|
|
7794
|
-
} = 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);
|
|
7795
7592
|
|
|
7796
7593
|
const EditorCompletionWidget = {
|
|
7797
7594
|
__proto__: null,
|
|
7798
7595
|
add: add$7,
|
|
7799
|
-
close,
|
|
7596
|
+
close: close$1,
|
|
7800
7597
|
closeDetails,
|
|
7801
7598
|
focusFirst,
|
|
7802
7599
|
focusIndex: focusIndex$1,
|
|
7803
7600
|
focusLast,
|
|
7804
|
-
focusNext: focusNext$
|
|
7805
|
-
focusPrevious,
|
|
7601
|
+
focusNext: focusNext$2,
|
|
7602
|
+
focusPrevious: focusPrevious$1,
|
|
7806
7603
|
handleEditorBlur,
|
|
7807
7604
|
handleEditorClick,
|
|
7808
7605
|
handleEditorDeleteLeft: handleEditorDeleteLeft$1,
|
|
@@ -7816,6 +7613,80 @@ const EditorCompletionWidget = {
|
|
|
7816
7613
|
toggleDetails
|
|
7817
7614
|
};
|
|
7818
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);
|
|
7664
|
+
|
|
7665
|
+
const EditorFindWidget = {
|
|
7666
|
+
__proto__: null,
|
|
7667
|
+
add: add$6,
|
|
7668
|
+
close,
|
|
7669
|
+
focusCloseButton,
|
|
7670
|
+
focusFind,
|
|
7671
|
+
focusNext: focusNext$1,
|
|
7672
|
+
focusNextMatchButton,
|
|
7673
|
+
focusPrevious,
|
|
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
|
|
7688
|
+
};
|
|
7689
|
+
|
|
7819
7690
|
const loadContent = async (editorUid, state, position) => {
|
|
7820
7691
|
const hoverInfo = await getEditorHoverInfo(editorUid, position);
|
|
7821
7692
|
if (!hoverInfo) {
|
|
@@ -7865,6 +7736,7 @@ const CompletionDetailContent = 'CompletionDetailContent';
|
|
|
7865
7736
|
const Diagnostic = 'Diagnostic';
|
|
7866
7737
|
const EditorCursor = 'EditorCursor';
|
|
7867
7738
|
const EditorRow = 'EditorRow';
|
|
7739
|
+
const EditorRowHighlighted = 'EditorRowHighlighted';
|
|
7868
7740
|
const EditorSelection = 'EditorSelection';
|
|
7869
7741
|
const EditorSourceActions = 'EditorSourceActions';
|
|
7870
7742
|
const EditorSourceActionsList = 'EditorSourceActionsList';
|
|
@@ -8011,10 +7883,10 @@ const renderBounds$3 = {
|
|
|
8011
7883
|
return [SetBounds, x, y, width, height];
|
|
8012
7884
|
}
|
|
8013
7885
|
};
|
|
8014
|
-
const render$
|
|
7886
|
+
const render$a = [renderHoverDom, renderBounds$3];
|
|
8015
7887
|
const renderHover = (oldState, newState) => {
|
|
8016
7888
|
const commands = [];
|
|
8017
|
-
for (const item of render$
|
|
7889
|
+
for (const item of render$a) {
|
|
8018
7890
|
if (!item.isEqual(oldState, newState)) {
|
|
8019
7891
|
commands.push(item.apply(oldState, newState));
|
|
8020
7892
|
}
|
|
@@ -8040,21 +7912,6 @@ const focusNext = state => {
|
|
|
8040
7912
|
return focusIndex(state, nextIndex);
|
|
8041
7913
|
};
|
|
8042
7914
|
|
|
8043
|
-
const getWidgetInvoke = widgetId => {
|
|
8044
|
-
switch (widgetId) {
|
|
8045
|
-
case ColorPicker:
|
|
8046
|
-
return invoke$6;
|
|
8047
|
-
case Completion:
|
|
8048
|
-
return invoke$3;
|
|
8049
|
-
case Find:
|
|
8050
|
-
return invoke$2;
|
|
8051
|
-
case Rename:
|
|
8052
|
-
return invoke$4;
|
|
8053
|
-
default:
|
|
8054
|
-
return undefined;
|
|
8055
|
-
}
|
|
8056
|
-
};
|
|
8057
|
-
|
|
8058
7915
|
const executeWidgetCommand = async (editor, name, method, _uid, widgetId, ...params) => {
|
|
8059
7916
|
const invoke = getWidgetInvoke(widgetId);
|
|
8060
7917
|
const actualMethod = method.slice(name.length + 1);
|
|
@@ -8156,6 +8013,14 @@ const getSelections2 = editorUid => {
|
|
|
8156
8013
|
} = editor;
|
|
8157
8014
|
return selections;
|
|
8158
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
|
+
};
|
|
8159
8024
|
const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocus$1) => {
|
|
8160
8025
|
const editor = getEditor(editorUid);
|
|
8161
8026
|
const invoke = getWidgetInvoke(widgetId);
|
|
@@ -8173,7 +8038,7 @@ const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocu
|
|
|
8173
8038
|
widgets: newWidgets,
|
|
8174
8039
|
focused: true
|
|
8175
8040
|
};
|
|
8176
|
-
set$
|
|
8041
|
+
set$6(editorUid, editor, newEditor);
|
|
8177
8042
|
await setFocus(FocusEditorText);
|
|
8178
8043
|
if (unsetAdditionalFocus$1) {
|
|
8179
8044
|
await unsetAdditionalFocus(unsetAdditionalFocus$1);
|
|
@@ -8185,7 +8050,7 @@ const closeFind2 = async editorUid => {
|
|
|
8185
8050
|
const applyEdits2 = async (editorUid, edits) => {
|
|
8186
8051
|
const editor = getEditor(editorUid);
|
|
8187
8052
|
const newEditor = await applyEdit(editor, edits);
|
|
8188
|
-
set$
|
|
8053
|
+
set$6(editorUid, editor, newEditor);
|
|
8189
8054
|
};
|
|
8190
8055
|
|
|
8191
8056
|
const pending = Object.create(null);
|
|
@@ -8311,6 +8176,10 @@ const getKeyBindings = () => {
|
|
|
8311
8176
|
key: Enter,
|
|
8312
8177
|
command: 'FindWidget.focusNext',
|
|
8313
8178
|
when: FocusFindWidget
|
|
8179
|
+
}, {
|
|
8180
|
+
key: CtrlCmd | KeyF,
|
|
8181
|
+
command: 'FindWidget.preventDefaultBrowserFind',
|
|
8182
|
+
when: FocusFindWidget
|
|
8314
8183
|
}, {
|
|
8315
8184
|
key: Shift | F4,
|
|
8316
8185
|
command: 'FindWidget.focusPrevious',
|
|
@@ -8733,6 +8602,16 @@ const handleBeforeInput = (editor, inputType, data) => {
|
|
|
8733
8602
|
}
|
|
8734
8603
|
};
|
|
8735
8604
|
|
|
8605
|
+
const handleMessagePort = async (port, rpcId) => {
|
|
8606
|
+
const rpc = await PlainMessagePortRpcParent.create({
|
|
8607
|
+
messagePort: port,
|
|
8608
|
+
commandMap: {}
|
|
8609
|
+
});
|
|
8610
|
+
if (rpcId) {
|
|
8611
|
+
set$c(rpcId, rpc);
|
|
8612
|
+
}
|
|
8613
|
+
};
|
|
8614
|
+
|
|
8736
8615
|
const applyTabCompletion = (editor, result) => {
|
|
8737
8616
|
return editorSnippet(editor, result);
|
|
8738
8617
|
};
|
|
@@ -8746,6 +8625,68 @@ const handleTab = async editor => {
|
|
|
8746
8625
|
return applyTabCompletion(editor, result);
|
|
8747
8626
|
};
|
|
8748
8627
|
|
|
8628
|
+
const sendMessagePortToExtensionHostWorker2 = async (port, initialCommand, rpcId) => {
|
|
8629
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, initialCommand, rpcId);
|
|
8630
|
+
};
|
|
8631
|
+
|
|
8632
|
+
const createExtensionHostRpc = async () => {
|
|
8633
|
+
try {
|
|
8634
|
+
const {
|
|
8635
|
+
port1,
|
|
8636
|
+
port2
|
|
8637
|
+
} = getPortTuple();
|
|
8638
|
+
const initialCommand = 'HandleMessagePort.handleMessagePort2';
|
|
8639
|
+
await sendMessagePortToExtensionHostWorker2(port2, initialCommand, RpcId.EditorWorker);
|
|
8640
|
+
const rpc = await PlainMessagePortRpcParent.create({
|
|
8641
|
+
commandMap: {},
|
|
8642
|
+
messagePort: port1
|
|
8643
|
+
});
|
|
8644
|
+
return rpc;
|
|
8645
|
+
} catch (error) {
|
|
8646
|
+
throw new VError(error, `Failed to create extension host rpc`);
|
|
8647
|
+
}
|
|
8648
|
+
};
|
|
8649
|
+
|
|
8650
|
+
const initializeExtensionHost = async () => {
|
|
8651
|
+
const extensionHostRpc = await createExtensionHostRpc();
|
|
8652
|
+
set$5(extensionHostRpc);
|
|
8653
|
+
};
|
|
8654
|
+
|
|
8655
|
+
const sendMessagePortToSyntaxHighlightingWorker = async () => {
|
|
8656
|
+
try {
|
|
8657
|
+
const {
|
|
8658
|
+
port1,
|
|
8659
|
+
port2
|
|
8660
|
+
} = getPortTuple();
|
|
8661
|
+
await invokeAndTransfer(
|
|
8662
|
+
// @ts-ignore
|
|
8663
|
+
'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port1, 'HandleMessagePort.handleMessagePort2');
|
|
8664
|
+
return port2;
|
|
8665
|
+
} catch {
|
|
8666
|
+
const {
|
|
8667
|
+
port1,
|
|
8668
|
+
port2
|
|
8669
|
+
} = getPortTuple();
|
|
8670
|
+
await invokeAndTransfer(
|
|
8671
|
+
// @ts-ignore
|
|
8672
|
+
'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port1, 'HandleMessagePort.handleMessagePort');
|
|
8673
|
+
return port2;
|
|
8674
|
+
}
|
|
8675
|
+
};
|
|
8676
|
+
|
|
8677
|
+
const createSyntaxHighlightingWorkerRpc = async () => {
|
|
8678
|
+
try {
|
|
8679
|
+
const port = await sendMessagePortToSyntaxHighlightingWorker();
|
|
8680
|
+
const rpc = await PlainMessagePortRpcParent.create({
|
|
8681
|
+
commandMap: {},
|
|
8682
|
+
messagePort: port
|
|
8683
|
+
});
|
|
8684
|
+
return rpc;
|
|
8685
|
+
} catch (error) {
|
|
8686
|
+
throw new VError(error, `Failed to create syntax highlighting worker rpc`);
|
|
8687
|
+
}
|
|
8688
|
+
};
|
|
8689
|
+
|
|
8749
8690
|
let enabled = false;
|
|
8750
8691
|
const setEnabled = value => {
|
|
8751
8692
|
enabled = value;
|
|
@@ -8754,16 +8695,19 @@ const getEnabled = () => {
|
|
|
8754
8695
|
return enabled;
|
|
8755
8696
|
};
|
|
8756
8697
|
|
|
8757
|
-
const
|
|
8758
|
-
await listen$2();
|
|
8698
|
+
const initializeSyntaxHighlighting = async (syntaxHighlightingEnabled, syncIncremental) => {
|
|
8759
8699
|
if (syntaxHighlightingEnabled) {
|
|
8760
8700
|
setEnabled$1(true);
|
|
8761
|
-
await
|
|
8701
|
+
const syntaxRpc = await createSyntaxHighlightingWorkerRpc();
|
|
8702
|
+
set$3(syntaxRpc);
|
|
8762
8703
|
}
|
|
8763
8704
|
if (syncIncremental) {
|
|
8764
8705
|
setEnabled(true);
|
|
8765
8706
|
}
|
|
8766
|
-
|
|
8707
|
+
};
|
|
8708
|
+
|
|
8709
|
+
const intialize = async (syntaxHighlightingEnabled, syncIncremental) => {
|
|
8710
|
+
await Promise.all([initializeSyntaxHighlighting(syntaxHighlightingEnabled, syncIncremental), initializeExtensionHost()]);
|
|
8767
8711
|
};
|
|
8768
8712
|
|
|
8769
8713
|
// TODO move cursor
|
|
@@ -8821,6 +8765,26 @@ const moveLineUp = editor => {
|
|
|
8821
8765
|
return editor;
|
|
8822
8766
|
};
|
|
8823
8767
|
|
|
8768
|
+
const getOrCreate = async () => {
|
|
8769
|
+
return {};
|
|
8770
|
+
};
|
|
8771
|
+
const invoke = async (method, ...params) => {
|
|
8772
|
+
const worker = await getOrCreate();
|
|
8773
|
+
return worker.invoke(method, ...params);
|
|
8774
|
+
};
|
|
8775
|
+
|
|
8776
|
+
const getHighlightedLine = async editor => {
|
|
8777
|
+
if (!editor.debugEnabled) {
|
|
8778
|
+
return -1;
|
|
8779
|
+
}
|
|
8780
|
+
try {
|
|
8781
|
+
return await invoke('Debug.getHighlightedLine', editor.uid);
|
|
8782
|
+
} catch (error) {
|
|
8783
|
+
console.error('Failed to get highlighted line:', error);
|
|
8784
|
+
return -1;
|
|
8785
|
+
}
|
|
8786
|
+
};
|
|
8787
|
+
|
|
8824
8788
|
const Link$1 = 'Link';
|
|
8825
8789
|
const Function = 'Function';
|
|
8826
8790
|
const Parameter = 'Parameter';
|
|
@@ -9052,9 +9016,12 @@ const getTokensViewport2 = async (editor, startLineIndex, endLineIndex, syncIncr
|
|
|
9052
9016
|
languageId,
|
|
9053
9017
|
invalidStartIndex
|
|
9054
9018
|
};
|
|
9055
|
-
return invoke$1('GetTokensViewport.getTokensViewport', slimEditor,
|
|
9019
|
+
return invoke$1('GetTokensViewport.getTokensViewport', slimEditor,
|
|
9020
|
+
// @ts-ignore
|
|
9021
|
+
startLineIndex, endLineIndex, hasLinesToSend, id, linesToSend);
|
|
9056
9022
|
}
|
|
9057
9023
|
// TODO only send needed lines of text
|
|
9024
|
+
// @ts-ignore
|
|
9058
9025
|
return invoke$1('GetTokensViewport.getTokensViewport', editor, startLineIndex, endLineIndex, true, editor.id, editor.lines);
|
|
9059
9026
|
}
|
|
9060
9027
|
return getTokensViewport(editor, startLineIndex, endLineIndex);
|
|
@@ -9283,6 +9250,7 @@ const getVisible = async (editor, syncIncremental) => {
|
|
|
9283
9250
|
charWidth
|
|
9284
9251
|
} = editor;
|
|
9285
9252
|
const maxLineY = Math.min(minLineY + numberOfVisibleLines, lines.length);
|
|
9253
|
+
// @ts-ignore
|
|
9286
9254
|
const {
|
|
9287
9255
|
tokens,
|
|
9288
9256
|
tokenizersToLoad,
|
|
@@ -9371,14 +9339,18 @@ const getEditorGutterVirtualDom = gutterInfos => {
|
|
|
9371
9339
|
return dom;
|
|
9372
9340
|
};
|
|
9373
9341
|
|
|
9374
|
-
const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true) => {
|
|
9342
|
+
const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1) => {
|
|
9375
9343
|
const dom = [];
|
|
9376
9344
|
for (let i = 0; i < textInfos.length; i++) {
|
|
9377
9345
|
const textInfo = textInfos[i];
|
|
9378
9346
|
const difference = differences[i];
|
|
9347
|
+
let className = EditorRow;
|
|
9348
|
+
if (i === highlightedLine) {
|
|
9349
|
+
className += ' ' + EditorRowHighlighted;
|
|
9350
|
+
}
|
|
9379
9351
|
dom.push({
|
|
9380
9352
|
type: Div,
|
|
9381
|
-
className
|
|
9353
|
+
className,
|
|
9382
9354
|
translate: px(difference),
|
|
9383
9355
|
childCount: textInfo.length / 2
|
|
9384
9356
|
});
|
|
@@ -9411,7 +9383,9 @@ const getIncrementalEdits = async (oldState, newState) => {
|
|
|
9411
9383
|
} = newState;
|
|
9412
9384
|
const oldLine = oldState.lines[rowIndex];
|
|
9413
9385
|
const newLine = lines[rowIndex];
|
|
9414
|
-
const incrementalEdits = await invoke$1('TokenizeIncremental.tokenizeIncremental', newState.uid,
|
|
9386
|
+
const incrementalEdits = await invoke$1('TokenizeIncremental.tokenizeIncremental', newState.uid,
|
|
9387
|
+
// @ts-ignore
|
|
9388
|
+
newState.languageId, oldLine, newLine, rowIndex, newState.minLineY);
|
|
9415
9389
|
if (incrementalEdits && incrementalEdits.length === 1) {
|
|
9416
9390
|
return incrementalEdits;
|
|
9417
9391
|
}
|
|
@@ -9463,7 +9437,7 @@ const removeWidget$1 = widget => {
|
|
|
9463
9437
|
|
|
9464
9438
|
const renderLines = {
|
|
9465
9439
|
isEqual(oldState, newState) {
|
|
9466
|
-
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;
|
|
9440
|
+
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;
|
|
9467
9441
|
},
|
|
9468
9442
|
async apply(oldState, newState) {
|
|
9469
9443
|
const incrementalEdits = await getIncrementalEdits(oldState, newState);
|
|
@@ -9476,7 +9450,8 @@ const renderLines = {
|
|
|
9476
9450
|
differences
|
|
9477
9451
|
} = await getVisible(newState, syncIncremental);
|
|
9478
9452
|
newState.differences = differences;
|
|
9479
|
-
const
|
|
9453
|
+
const highlightedLine = await getHighlightedLine(newState);
|
|
9454
|
+
const dom = getEditorRowsVirtualDom(textInfos, differences, true, highlightedLine);
|
|
9480
9455
|
return [/* method */'setText', dom];
|
|
9481
9456
|
}
|
|
9482
9457
|
};
|
|
@@ -9613,7 +9588,7 @@ const renderWidgets = {
|
|
|
9613
9588
|
},
|
|
9614
9589
|
multiple: true
|
|
9615
9590
|
};
|
|
9616
|
-
const render$
|
|
9591
|
+
const render$9 = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets];
|
|
9617
9592
|
const renderEditor = async id => {
|
|
9618
9593
|
const instance = get$4(id);
|
|
9619
9594
|
if (!instance) {
|
|
@@ -9624,8 +9599,8 @@ const renderEditor = async id => {
|
|
|
9624
9599
|
newState
|
|
9625
9600
|
} = instance;
|
|
9626
9601
|
const commands = [];
|
|
9627
|
-
set$
|
|
9628
|
-
for (const item of render$
|
|
9602
|
+
set$6(id, newState, newState);
|
|
9603
|
+
for (const item of render$9) {
|
|
9629
9604
|
if (!item.isEqual(oldState, newState)) {
|
|
9630
9605
|
const result = await item.apply(oldState, newState);
|
|
9631
9606
|
// @ts-ignore
|
|
@@ -9676,6 +9651,14 @@ const renderEventListeners = () => {
|
|
|
9676
9651
|
}];
|
|
9677
9652
|
};
|
|
9678
9653
|
|
|
9654
|
+
const setDebugEnabled = (state, enabled) => {
|
|
9655
|
+
return state;
|
|
9656
|
+
};
|
|
9657
|
+
|
|
9658
|
+
const updateDebugInfo = info => {
|
|
9659
|
+
// TODO query all editors and update them with debug information if needed, then rerender them
|
|
9660
|
+
};
|
|
9661
|
+
|
|
9679
9662
|
const editorDiagnosticEffect = {
|
|
9680
9663
|
isActive(oldEditor, newEditor) {
|
|
9681
9664
|
// TODO avoid slow comparison
|
|
@@ -9687,13 +9670,12 @@ const editorDiagnosticEffect = {
|
|
|
9687
9670
|
}
|
|
9688
9671
|
};
|
|
9689
9672
|
|
|
9690
|
-
const keep = [
|
|
9673
|
+
const keep = ['ActivateByEvent.activateByEvent', 'Editor.applyEdit2', 'Editor.applyEdits2', 'Editor.closeFind2', 'Editor.closeWidget2', 'Editor.create', 'Editor.getKeyBindings', 'Editor.getLines2', 'Editor.getPositionAtCursor', 'Editor.getQuickPickMenuEntries', 'Editor.getSelections', 'Editor.getSelections2', 'Editor.getText', 'Editor.getWordAt', 'Editor.getWordAt2', 'Editor.getWordAtOffset2', 'Editor.getWordBefore', 'Editor.getWordBefore2', 'Editor.offsetAt', 'Editor.render', 'Editor.setSelections2', 'Editor.updateDebugInfo', 'Font.ensure', 'HandleMessagePort.handleMessagePort', 'Hover.getHoverInfo', 'Hover.handleSashPointerDown', 'Hover.handleSashPointerMove', 'Hover.handleSashPointerUp', 'Hover.loadContent', 'Hover.render', 'Initialize.initialize', 'SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker'
|
|
9691
9674
|
// 'ColorPicker.handleSliderPointerDown',
|
|
9692
9675
|
// 'ColorPicker.handleSliderPointerMove',
|
|
9693
9676
|
// 'ColorPicker.loadContent',
|
|
9694
|
-
'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',
|
|
9695
9677
|
// 'ColorPicker.render',
|
|
9696
|
-
|
|
9678
|
+
];
|
|
9697
9679
|
|
|
9698
9680
|
const wrapWidgetCommand = (widgetId, fn) => {
|
|
9699
9681
|
const isWidget = widget => {
|
|
@@ -9757,7 +9739,7 @@ const wrapCommand = fn => async (editorUid, ...args) => {
|
|
|
9757
9739
|
effect.apply(newEditor);
|
|
9758
9740
|
}
|
|
9759
9741
|
}
|
|
9760
|
-
set$
|
|
9742
|
+
set$6(editorUid, oldInstance.newState, newEditor);
|
|
9761
9743
|
// TODO if possible, rendering should be sync
|
|
9762
9744
|
const commands = await renderEditor(editorUid);
|
|
9763
9745
|
newEditor.commands = commands;
|
|
@@ -9782,12 +9764,15 @@ const commandMap = {
|
|
|
9782
9764
|
'Editor.addCursorAbove': addCursorAbove,
|
|
9783
9765
|
'Editor.addCursorBelow': addCursorBelow,
|
|
9784
9766
|
'Editor.applyEdit': applyEdit,
|
|
9767
|
+
'Editor.applyEdit2': applyEdits2,
|
|
9785
9768
|
'Editor.braceCompletion': braceCompletion,
|
|
9786
9769
|
'Editor.cancelSelection': cancelSelection,
|
|
9787
9770
|
'Editor.closeCodeGenerator': closeCodeGenerator,
|
|
9788
9771
|
'Editor.closeFind': closeFind,
|
|
9772
|
+
'Editor.closeFind2': closeFind2,
|
|
9789
9773
|
'Editor.closeRename': closeRename,
|
|
9790
9774
|
'Editor.closeSourceAction': closeSourceAction,
|
|
9775
|
+
'Editor.closeWidget2': closeWidget2,
|
|
9791
9776
|
'Editor.compositionEnd': compositionEnd,
|
|
9792
9777
|
'Editor.compositionStart': compositionStart,
|
|
9793
9778
|
'Editor.compositionUpdate': compositionUpdate,
|
|
@@ -9819,9 +9804,6 @@ const commandMap = {
|
|
|
9819
9804
|
'Editor.deleteRight': deleteCharacterRight,
|
|
9820
9805
|
'Editor.deleteWordLeft': deleteWordLeft,
|
|
9821
9806
|
'Editor.deleteWordPartLeft': deleteWordPartLeft,
|
|
9822
|
-
'Editor.applyEdit2': applyEdits2,
|
|
9823
|
-
'Editor.closeFind2': closeFind2,
|
|
9824
|
-
'Editor.closeWidget2': closeWidget2,
|
|
9825
9807
|
'Editor.deleteWordPartRight': deleteWordPartRight,
|
|
9826
9808
|
'Editor.deleteWordRight': deleteWordRight,
|
|
9827
9809
|
'Editor.executeWidgetCommand': executeWidgetCommand,
|
|
@@ -9843,10 +9825,10 @@ const commandMap = {
|
|
|
9843
9825
|
'Editor.goToTypeDefinition': goToTypeDefinition,
|
|
9844
9826
|
'Editor.handleBeforeInput': handleBeforeInput,
|
|
9845
9827
|
'Editor.handleBeforeInputFromContentEditable': handleBeforeInputFromContentEditable,
|
|
9846
|
-
'Editor.handleBlur': handleBlur,
|
|
9828
|
+
'Editor.handleBlur': handleBlur$1,
|
|
9847
9829
|
'Editor.handleContextMenu': handleContextMenu,
|
|
9848
9830
|
'Editor.handleDoubleClick': handleDoubleClick,
|
|
9849
|
-
'Editor.handleFocus': handleFocus,
|
|
9831
|
+
'Editor.handleFocus': handleFocus$1,
|
|
9850
9832
|
'Editor.handleMouseDown': handleMouseDown,
|
|
9851
9833
|
'Editor.handleMouseMove': handleMouseMove,
|
|
9852
9834
|
'Editor.handleMouseMoveWithAltKey': handleMouseMoveWithAltKey,
|
|
@@ -9879,21 +9861,6 @@ const commandMap = {
|
|
|
9879
9861
|
'Editor.openCodeGenerator': openCodeGenerator,
|
|
9880
9862
|
'Editor.openColorPicker': openColorPicker,
|
|
9881
9863
|
'Editor.openCompletion': openCompletion,
|
|
9882
|
-
'EditorCompletion.closeDetails': closeDetails,
|
|
9883
|
-
'EditorCompletion.focusFirst': focusFirst,
|
|
9884
|
-
'EditorCompletion.focusIndex': focusIndex$1,
|
|
9885
|
-
'EditorCompletion.focusNext': focusNext$1,
|
|
9886
|
-
'EditorCompletion.focusPrevious': focusPrevious,
|
|
9887
|
-
'EditorCompletion.handleEditorBlur': handleEditorBlur,
|
|
9888
|
-
'EditorCompletion.handleEditorClick': handleEditorClick,
|
|
9889
|
-
'EditorCompletion.handleEditorDeleteLeft': handleEditorDeleteLeft$1,
|
|
9890
|
-
'EditorCompletion.handleEditorType': handleEditorType$1,
|
|
9891
|
-
'EditorCompletion.handleWheel': handleWheel,
|
|
9892
|
-
'EditorCompletion.openDetails': openDetails,
|
|
9893
|
-
'EditorCompletion.selectCurrent': selectCurrent,
|
|
9894
|
-
'EditorCompletion.close': close,
|
|
9895
|
-
'EditorCompletion.selectIndex': selectIndex,
|
|
9896
|
-
'EditorCompletion.toggleDetails': toggleDetails,
|
|
9897
9864
|
'Editor.openFind': openFind,
|
|
9898
9865
|
'Editor.openFind2': openFind2,
|
|
9899
9866
|
'Editor.openRename': openRename,
|
|
@@ -9921,11 +9888,13 @@ const commandMap = {
|
|
|
9921
9888
|
'Editor.selectWord': selectWord,
|
|
9922
9889
|
'Editor.selectWordLeft': selectWordLeft,
|
|
9923
9890
|
'Editor.selectWordRight': selectWordRight,
|
|
9891
|
+
'Editor.setDebugEnabled': setDebugEnabled,
|
|
9924
9892
|
'Editor.setDecorations': setDecorations,
|
|
9925
9893
|
'Editor.setDelta': setDelta,
|
|
9926
9894
|
'Editor.setDeltaY': setDeltaY,
|
|
9927
9895
|
'Editor.setLanguageId': setLanguageId,
|
|
9928
9896
|
'Editor.setSelections': setSelections,
|
|
9897
|
+
'Editor.setSelections2': setSelections2,
|
|
9929
9898
|
'Editor.showHover': showHover,
|
|
9930
9899
|
'Editor.showHover2': showHover2,
|
|
9931
9900
|
'Editor.showSourceActions': showSourceActions,
|
|
@@ -9939,11 +9908,45 @@ const commandMap = {
|
|
|
9939
9908
|
'Editor.typeWithAutoClosing': typeWithAutoClosing,
|
|
9940
9909
|
'Editor.undo': undo,
|
|
9941
9910
|
'Editor.unIndent': editorUnindent,
|
|
9911
|
+
'Editor.updateDebugInfo': updateDebugInfo,
|
|
9942
9912
|
'Editor.updateDiagnostics': updateDiagnostics,
|
|
9913
|
+
'EditorCompletion.close': close$1,
|
|
9914
|
+
'EditorCompletion.closeDetails': closeDetails,
|
|
9915
|
+
'EditorCompletion.focusFirst': focusFirst,
|
|
9916
|
+
'EditorCompletion.focusIndex': focusIndex$1,
|
|
9917
|
+
'EditorCompletion.focusNext': focusNext$2,
|
|
9918
|
+
'EditorCompletion.focusPrevious': focusPrevious$1,
|
|
9919
|
+
'EditorCompletion.handleEditorBlur': handleEditorBlur,
|
|
9920
|
+
'EditorCompletion.handleEditorClick': handleEditorClick,
|
|
9921
|
+
'EditorCompletion.handleEditorDeleteLeft': handleEditorDeleteLeft$1,
|
|
9922
|
+
'EditorCompletion.handleEditorType': handleEditorType$1,
|
|
9923
|
+
'EditorCompletion.handleWheel': handleWheel,
|
|
9924
|
+
'EditorCompletion.openDetails': openDetails,
|
|
9925
|
+
'EditorCompletion.selectCurrent': selectCurrent,
|
|
9926
|
+
'EditorCompletion.selectIndex': selectIndex,
|
|
9927
|
+
'EditorCompletion.toggleDetails': toggleDetails,
|
|
9943
9928
|
'EditorSourceActions.focusNext': focusNext,
|
|
9944
|
-
'FindWidget.close': close
|
|
9929
|
+
'FindWidget.close': close,
|
|
9930
|
+
'FindWidget.focusCloseButton': focusCloseButton,
|
|
9931
|
+
'FindWidget.focusFind': focusFind,
|
|
9932
|
+
'FindWidget.focusNext': focusNext$1,
|
|
9933
|
+
'FindWidget.focusNextMatchButton': focusNextMatchButton,
|
|
9934
|
+
'FindWidget.focusPrevious': focusPrevious,
|
|
9935
|
+
'FindWidget.focusPreviousMatchButton': focusPreviousMatchButton,
|
|
9936
|
+
'FindWidget.focusReplace': focusReplace,
|
|
9937
|
+
'FindWidget.focusReplaceAllButton': focusReplaceAllButton,
|
|
9938
|
+
'FindWidget.focusReplaceButton': focusReplaceButton,
|
|
9939
|
+
'FindWidget.focusToggleReplace': focusToggleReplace,
|
|
9940
|
+
'FindWidget.handleBlur': handleBlur,
|
|
9941
|
+
'FindWidget.handleFocus': handleFocus,
|
|
9942
|
+
'FindWidget.handleInput': handleInput,
|
|
9943
|
+
'FindWidget.handleReplaceFocus': handleReplaceFocus,
|
|
9944
|
+
'FindWidget.handleReplaceInput': handleReplaceInput,
|
|
9945
|
+
'FindWidget.handleToggleReplaceFocus': handleToggleReplaceFocus,
|
|
9945
9946
|
'FindWidget.loadContent': loadContent$1,
|
|
9947
|
+
'FindWidget.toggleReplace': toggleReplace,
|
|
9946
9948
|
'Font.ensure': ensure,
|
|
9949
|
+
'HandleMessagePort.handleMessagePort': handleMessagePort,
|
|
9947
9950
|
'Hover.getHoverInfo': getEditorHoverInfo,
|
|
9948
9951
|
'Hover.handleSashPointerDown': handleSashPointerDown,
|
|
9949
9952
|
'Hover.handleSashPointerMove': handleSashPointerMove,
|
|
@@ -9955,59 +9958,11 @@ const commandMap = {
|
|
|
9955
9958
|
};
|
|
9956
9959
|
wrapCommands(commandMap);
|
|
9957
9960
|
|
|
9958
|
-
const MessagePort$1 = 1;
|
|
9959
|
-
const ModuleWorker = 2;
|
|
9960
|
-
const ReferencePort = 3;
|
|
9961
|
-
const ModuleWorkerAndMessagePort = 8;
|
|
9962
|
-
const Auto = () => {
|
|
9963
|
-
// @ts-ignore
|
|
9964
|
-
if (globalThis.acceptPort) {
|
|
9965
|
-
return MessagePort$1;
|
|
9966
|
-
}
|
|
9967
|
-
// @ts-ignore
|
|
9968
|
-
if (globalThis.acceptReferencePort) {
|
|
9969
|
-
return ReferencePort;
|
|
9970
|
-
}
|
|
9971
|
-
return ModuleWorkerAndMessagePort;
|
|
9972
|
-
};
|
|
9973
|
-
|
|
9974
|
-
const getModule = method => {
|
|
9975
|
-
switch (method) {
|
|
9976
|
-
case ModuleWorker:
|
|
9977
|
-
return IpcChildWithModuleWorker$1;
|
|
9978
|
-
case ModuleWorkerAndMessagePort:
|
|
9979
|
-
return IpcChildWithModuleWorkerAndMessagePort$1;
|
|
9980
|
-
case MessagePort$1:
|
|
9981
|
-
return IpcChildWithMessagePort$1;
|
|
9982
|
-
default:
|
|
9983
|
-
throw new Error('unexpected ipc type');
|
|
9984
|
-
}
|
|
9985
|
-
};
|
|
9986
|
-
|
|
9987
|
-
// @ts-ignore
|
|
9988
|
-
const listen$1 = async ({
|
|
9989
|
-
method
|
|
9990
|
-
}) => {
|
|
9991
|
-
const module = await getModule(method);
|
|
9992
|
-
// @ts-ignore
|
|
9993
|
-
const rawIpc = await module.listen();
|
|
9994
|
-
// @ts-ignore
|
|
9995
|
-
if (module.signal) {
|
|
9996
|
-
// @ts-ignore
|
|
9997
|
-
module.signal(rawIpc);
|
|
9998
|
-
}
|
|
9999
|
-
// @ts-ignore
|
|
10000
|
-
const ipc = module.wrap(rawIpc);
|
|
10001
|
-
return ipc;
|
|
10002
|
-
};
|
|
10003
|
-
|
|
10004
9961
|
const listen = async () => {
|
|
10005
|
-
|
|
10006
|
-
|
|
10007
|
-
method: Auto()
|
|
9962
|
+
const rpc = await WebWorkerRpcClient.create({
|
|
9963
|
+
commandMap: commandMap
|
|
10008
9964
|
});
|
|
10009
|
-
|
|
10010
|
-
listen$5(ipc);
|
|
9965
|
+
set$8(rpc);
|
|
10011
9966
|
};
|
|
10012
9967
|
|
|
10013
9968
|
const removeWidget = widget => {
|
|
@@ -10068,10 +10023,10 @@ const renderFocus = {
|
|
|
10068
10023
|
return [Focus, '.CodeGeneratorInput', newState.focusSource];
|
|
10069
10024
|
}
|
|
10070
10025
|
};
|
|
10071
|
-
const render$
|
|
10072
|
-
const renderFull$
|
|
10026
|
+
const render$8 = [renderContent$1, renderBounds$2, renderFocus];
|
|
10027
|
+
const renderFull$2 = (oldState, newState) => {
|
|
10073
10028
|
const commands = [];
|
|
10074
|
-
for (const item of render$
|
|
10029
|
+
for (const item of render$8) {
|
|
10075
10030
|
if (!item.isEqual(oldState, newState)) {
|
|
10076
10031
|
commands.push(item.apply(oldState, newState));
|
|
10077
10032
|
}
|
|
@@ -10079,8 +10034,8 @@ const renderFull$3 = (oldState, newState) => {
|
|
|
10079
10034
|
return commands;
|
|
10080
10035
|
};
|
|
10081
10036
|
|
|
10082
|
-
const render$
|
|
10083
|
-
const commands = renderFull$
|
|
10037
|
+
const render$7 = widget => {
|
|
10038
|
+
const commands = renderFull$2(widget.oldState, widget.newState);
|
|
10084
10039
|
const wrappedCommands = [];
|
|
10085
10040
|
const {
|
|
10086
10041
|
uid
|
|
@@ -10095,27 +10050,27 @@ const render$8 = widget => {
|
|
|
10095
10050
|
}
|
|
10096
10051
|
return wrappedCommands;
|
|
10097
10052
|
};
|
|
10098
|
-
const add$
|
|
10099
|
-
return addWidget$1(widget, 'EditorCodeGenerator', render$
|
|
10053
|
+
const add$5 = widget => {
|
|
10054
|
+
return addWidget$1(widget, 'EditorCodeGenerator', render$7);
|
|
10100
10055
|
};
|
|
10101
|
-
const remove$
|
|
10056
|
+
const remove$5 = removeWidget;
|
|
10102
10057
|
|
|
10103
10058
|
const EditorCodeGeneratorWidget = {
|
|
10104
10059
|
__proto__: null,
|
|
10105
|
-
add: add$
|
|
10106
|
-
remove: remove$
|
|
10107
|
-
render: render$
|
|
10060
|
+
add: add$5,
|
|
10061
|
+
remove: remove$5,
|
|
10062
|
+
render: render$7
|
|
10108
10063
|
};
|
|
10109
10064
|
|
|
10110
|
-
const renderFull$
|
|
10065
|
+
const renderFull$1 = (oldState, newState) => {
|
|
10111
10066
|
const commands = [...newState.commands];
|
|
10112
10067
|
// @ts-ignore
|
|
10113
10068
|
newState.commands = [];
|
|
10114
10069
|
return commands;
|
|
10115
10070
|
};
|
|
10116
10071
|
|
|
10117
|
-
const render$
|
|
10118
|
-
const commands = renderFull$
|
|
10072
|
+
const render$6 = widget => {
|
|
10073
|
+
const commands = renderFull$1(widget.oldState, widget.newState);
|
|
10119
10074
|
const wrappedCommands = [];
|
|
10120
10075
|
const {
|
|
10121
10076
|
uid
|
|
@@ -10129,18 +10084,18 @@ const render$7 = widget => {
|
|
|
10129
10084
|
}
|
|
10130
10085
|
return wrappedCommands;
|
|
10131
10086
|
};
|
|
10132
|
-
const add$
|
|
10133
|
-
return addWidget$1(widget, 'ColorPicker', render$
|
|
10087
|
+
const add$4 = widget => {
|
|
10088
|
+
return addWidget$1(widget, 'ColorPicker', render$6);
|
|
10134
10089
|
};
|
|
10135
|
-
const remove$
|
|
10136
|
-
const Commands
|
|
10090
|
+
const remove$4 = removeWidget;
|
|
10091
|
+
const Commands = {};
|
|
10137
10092
|
|
|
10138
10093
|
const EditorColorPickerWidget = {
|
|
10139
10094
|
__proto__: null,
|
|
10140
|
-
Commands
|
|
10141
|
-
add: add$
|
|
10142
|
-
remove: remove$
|
|
10143
|
-
render: render$
|
|
10095
|
+
Commands,
|
|
10096
|
+
add: add$4,
|
|
10097
|
+
remove: remove$4,
|
|
10098
|
+
render: render$6
|
|
10144
10099
|
};
|
|
10145
10100
|
|
|
10146
10101
|
const getCompletionDetailVirtualDom = content => {
|
|
@@ -10198,9 +10153,9 @@ const renderBounds$1 = {
|
|
|
10198
10153
|
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
10199
10154
|
}
|
|
10200
10155
|
};
|
|
10201
|
-
const render$
|
|
10202
|
-
const renderFull
|
|
10203
|
-
return renderParts(render$
|
|
10156
|
+
const render$5 = [renderContent, renderBounds$1];
|
|
10157
|
+
const renderFull = (oldState, newState) => {
|
|
10158
|
+
return renderParts(render$5, oldState, newState);
|
|
10204
10159
|
};
|
|
10205
10160
|
|
|
10206
10161
|
const getWidgetState = (editor, id) => {
|
|
@@ -10219,8 +10174,8 @@ const getCompletionState = editor => {
|
|
|
10219
10174
|
return getWidgetState(editor, Completion);
|
|
10220
10175
|
};
|
|
10221
10176
|
|
|
10222
|
-
const render$
|
|
10223
|
-
const commands = renderFull
|
|
10177
|
+
const render$4 = widget => {
|
|
10178
|
+
const commands = renderFull(widget.oldState, widget.newState);
|
|
10224
10179
|
const wrappedCommands = [];
|
|
10225
10180
|
const {
|
|
10226
10181
|
uid
|
|
@@ -10234,10 +10189,10 @@ const render$5 = widget => {
|
|
|
10234
10189
|
}
|
|
10235
10190
|
return wrappedCommands;
|
|
10236
10191
|
};
|
|
10237
|
-
const add$
|
|
10238
|
-
return addWidget$1(widget, 'EditorCompletionDetails', render$
|
|
10192
|
+
const add$3 = widget => {
|
|
10193
|
+
return addWidget$1(widget, 'EditorCompletionDetails', render$4);
|
|
10239
10194
|
};
|
|
10240
|
-
const remove$
|
|
10195
|
+
const remove$3 = removeWidget;
|
|
10241
10196
|
const handleEditorType = (editor, state) => {
|
|
10242
10197
|
const completionState = getCompletionState(editor);
|
|
10243
10198
|
if (!completionState) {
|
|
@@ -10269,47 +10224,9 @@ const handleEditorDeleteLeft = (editor, state) => {
|
|
|
10269
10224
|
|
|
10270
10225
|
const EditorCompletionDetailWidget = {
|
|
10271
10226
|
__proto__: null,
|
|
10272
|
-
add: add$
|
|
10227
|
+
add: add$3,
|
|
10273
10228
|
handleEditorDeleteLeft,
|
|
10274
10229
|
handleEditorType,
|
|
10275
|
-
remove: remove$4,
|
|
10276
|
-
render: render$5
|
|
10277
|
-
};
|
|
10278
|
-
|
|
10279
|
-
const renderFull = (oldState, newState) => {
|
|
10280
|
-
const commands = [...newState.commands];
|
|
10281
|
-
// @ts-ignore
|
|
10282
|
-
newState.commands = [];
|
|
10283
|
-
return commands;
|
|
10284
|
-
};
|
|
10285
|
-
|
|
10286
|
-
const render$4 = widget => {
|
|
10287
|
-
const commands = renderFull(widget.oldState, widget.newState);
|
|
10288
|
-
const wrappedCommands = [];
|
|
10289
|
-
const {
|
|
10290
|
-
uid
|
|
10291
|
-
} = widget.newState;
|
|
10292
|
-
for (const command of commands) {
|
|
10293
|
-
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') {
|
|
10294
|
-
wrappedCommands.push(command);
|
|
10295
|
-
} else {
|
|
10296
|
-
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
10297
|
-
}
|
|
10298
|
-
}
|
|
10299
|
-
return wrappedCommands;
|
|
10300
|
-
};
|
|
10301
|
-
const add$3 = widget => {
|
|
10302
|
-
return addWidget$1(widget, 'FindWidget', render$4);
|
|
10303
|
-
};
|
|
10304
|
-
const remove$3 = widget => {
|
|
10305
|
-
return [['Viewlet.dispose', widget.newState.uid]];
|
|
10306
|
-
};
|
|
10307
|
-
const Commands = {};
|
|
10308
|
-
|
|
10309
|
-
const EditorFindWidget = {
|
|
10310
|
-
__proto__: null,
|
|
10311
|
-
Commands,
|
|
10312
|
-
add: add$3,
|
|
10313
10230
|
remove: remove$3,
|
|
10314
10231
|
render: render$4
|
|
10315
10232
|
};
|
|
@@ -10505,14 +10422,14 @@ const EditorSourceActionWidget = {
|
|
|
10505
10422
|
};
|
|
10506
10423
|
|
|
10507
10424
|
const registerWidgets = () => {
|
|
10508
|
-
set$
|
|
10509
|
-
set$
|
|
10510
|
-
set$
|
|
10511
|
-
set$
|
|
10512
|
-
set$
|
|
10513
|
-
set$
|
|
10514
|
-
set$
|
|
10515
|
-
set$
|
|
10425
|
+
set$7(ColorPicker, EditorColorPickerWidget);
|
|
10426
|
+
set$7(Completion, EditorCompletionWidget);
|
|
10427
|
+
set$7(CompletionDetail, EditorCompletionDetailWidget);
|
|
10428
|
+
set$7(Find, EditorFindWidget);
|
|
10429
|
+
set$7(Hover, EditorHoverWidget);
|
|
10430
|
+
set$7(Rename, EditorRenameWidget);
|
|
10431
|
+
set$7(SourceAction$1, EditorSourceActionWidget);
|
|
10432
|
+
set$7(CodeGenerator, EditorCodeGeneratorWidget);
|
|
10516
10433
|
};
|
|
10517
10434
|
|
|
10518
10435
|
const handleUnhandledRejection = event => {
|