@lvce-editor/test-worker 1.13.0 → 2.0.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/testWorkerMain.js +1190 -1247
- package/package.json +1 -1
package/dist/testWorkerMain.js
CHANGED
|
@@ -1,126 +1,43 @@
|
|
|
1
|
-
const commands = Object.create(null);
|
|
2
|
-
const registerCommand = (key, fn) => {
|
|
3
|
-
commands[key] = fn;
|
|
4
|
-
};
|
|
5
|
-
const register = commandMap => {
|
|
6
|
-
for (const [key, value] of Object.entries(commandMap)) {
|
|
7
|
-
registerCommand(key, value);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
const getCommand = key => {
|
|
11
|
-
return commands[key];
|
|
12
|
-
};
|
|
13
|
-
const execute$3 = (command, ...args) => {
|
|
14
|
-
const fn = getCommand(command);
|
|
15
|
-
if (!fn) {
|
|
16
|
-
throw new Error(`command not found ${command}`);
|
|
17
|
-
}
|
|
18
|
-
return fn(...args);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const state$3 = {
|
|
22
|
-
/**
|
|
23
|
-
* @type {any}
|
|
24
|
-
*/
|
|
25
|
-
ipc: undefined
|
|
26
|
-
};
|
|
27
|
-
const get$1 = () => {
|
|
28
|
-
return state$3.ipc;
|
|
29
|
-
};
|
|
30
|
-
const set$1 = ipc => {
|
|
31
|
-
state$3.ipc = ipc;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
1
|
const Two = '2.0';
|
|
35
|
-
|
|
36
|
-
constructor(message) {
|
|
37
|
-
super(message);
|
|
38
|
-
this.name = 'AssertionError';
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const getType$1 = value => {
|
|
42
|
-
switch (typeof value) {
|
|
43
|
-
case 'number':
|
|
44
|
-
return 'number';
|
|
45
|
-
case 'function':
|
|
46
|
-
return 'function';
|
|
47
|
-
case 'string':
|
|
48
|
-
return 'string';
|
|
49
|
-
case 'object':
|
|
50
|
-
if (value === null) {
|
|
51
|
-
return 'null';
|
|
52
|
-
}
|
|
53
|
-
if (Array.isArray(value)) {
|
|
54
|
-
return 'array';
|
|
55
|
-
}
|
|
56
|
-
return 'object';
|
|
57
|
-
case 'boolean':
|
|
58
|
-
return 'boolean';
|
|
59
|
-
default:
|
|
60
|
-
return 'unknown';
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const number = value => {
|
|
64
|
-
const type = getType$1(value);
|
|
65
|
-
if (type !== 'number') {
|
|
66
|
-
throw new AssertionError$1('expected value to be of type number');
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const state$1 = {
|
|
2
|
+
const state$2 = {
|
|
70
3
|
callbacks: Object.create(null)
|
|
71
4
|
};
|
|
72
5
|
const set = (id, fn) => {
|
|
73
|
-
state$
|
|
6
|
+
state$2.callbacks[id] = fn;
|
|
74
7
|
};
|
|
75
8
|
const get = id => {
|
|
76
|
-
return state$
|
|
9
|
+
return state$2.callbacks[id];
|
|
77
10
|
};
|
|
78
11
|
const remove = id => {
|
|
79
|
-
delete state$
|
|
80
|
-
};
|
|
81
|
-
const state$2 = {
|
|
82
|
-
id: 0
|
|
12
|
+
delete state$2.callbacks[id];
|
|
83
13
|
};
|
|
14
|
+
let id = 0;
|
|
84
15
|
const create$3 = () => {
|
|
85
|
-
return ++
|
|
16
|
+
return ++id;
|
|
86
17
|
};
|
|
87
18
|
const warn = (...args) => {
|
|
88
19
|
console.warn(...args);
|
|
89
20
|
};
|
|
90
|
-
const withResolvers$1 = () => {
|
|
91
|
-
/**
|
|
92
|
-
* @type {any}
|
|
93
|
-
*/
|
|
94
|
-
let _resolve;
|
|
95
|
-
const promise = new Promise(resolve => {
|
|
96
|
-
_resolve = resolve;
|
|
97
|
-
});
|
|
98
|
-
return {
|
|
99
|
-
resolve: _resolve,
|
|
100
|
-
promise
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
21
|
const registerPromise = () => {
|
|
104
22
|
const id = create$3();
|
|
105
23
|
const {
|
|
106
24
|
resolve,
|
|
107
25
|
promise
|
|
108
|
-
} = withResolvers
|
|
26
|
+
} = Promise.withResolvers();
|
|
109
27
|
set(id, resolve);
|
|
110
28
|
return {
|
|
111
29
|
id,
|
|
112
30
|
promise
|
|
113
31
|
};
|
|
114
32
|
};
|
|
115
|
-
const resolve = (id,
|
|
116
|
-
number(id);
|
|
33
|
+
const resolve = (id, response) => {
|
|
117
34
|
const fn = get(id);
|
|
118
35
|
if (!fn) {
|
|
119
|
-
console.log(
|
|
36
|
+
console.log(response);
|
|
120
37
|
warn(`callback ${id} may already be disposed`);
|
|
121
38
|
return;
|
|
122
39
|
}
|
|
123
|
-
fn(
|
|
40
|
+
fn(response);
|
|
124
41
|
remove(id);
|
|
125
42
|
};
|
|
126
43
|
const create$2 = (method, params) => {
|
|
@@ -271,7 +188,7 @@ const unwrapJsonRpcResult = responseMessage => {
|
|
|
271
188
|
throw new JsonRpcError('unexpected response message');
|
|
272
189
|
};
|
|
273
190
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
274
|
-
const
|
|
191
|
+
const getErrorType = prettyError => {
|
|
275
192
|
if (prettyError && prettyError.type) {
|
|
276
193
|
return prettyError.type;
|
|
277
194
|
}
|
|
@@ -294,13 +211,13 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
294
211
|
data: {
|
|
295
212
|
stack: prettyError.stack,
|
|
296
213
|
codeFrame: prettyError.codeFrame,
|
|
297
|
-
type:
|
|
214
|
+
type: getErrorType(prettyError),
|
|
298
215
|
code: prettyError.code,
|
|
299
216
|
name: prettyError.name
|
|
300
217
|
}
|
|
301
218
|
};
|
|
302
219
|
};
|
|
303
|
-
const create$1 = (message, error) => {
|
|
220
|
+
const create$1$1 = (message, error) => {
|
|
304
221
|
return {
|
|
305
222
|
jsonrpc: Two,
|
|
306
223
|
id: message.id,
|
|
@@ -311,7 +228,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
|
|
|
311
228
|
const prettyError = preparePrettyError(error);
|
|
312
229
|
logError(error, prettyError);
|
|
313
230
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
314
|
-
return create$1(message, errorProperty);
|
|
231
|
+
return create$1$1(message, errorProperty);
|
|
315
232
|
};
|
|
316
233
|
const create$4 = (message, result) => {
|
|
317
234
|
return {
|
|
@@ -342,32 +259,42 @@ const defaultRequiresSocket = () => {
|
|
|
342
259
|
return false;
|
|
343
260
|
};
|
|
344
261
|
const defaultResolve = resolve;
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
let execute;
|
|
349
|
-
let preparePrettyError;
|
|
350
|
-
let logError;
|
|
351
|
-
let resolve;
|
|
352
|
-
let requiresSocket;
|
|
262
|
+
|
|
263
|
+
// TODO maybe remove this in v6 or v7, only accept options object to simplify the code
|
|
264
|
+
const normalizeParams = args => {
|
|
353
265
|
if (args.length === 1) {
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
message = args[1];
|
|
365
|
-
execute = args[2];
|
|
366
|
-
resolve = args[3];
|
|
367
|
-
preparePrettyError = args[4];
|
|
368
|
-
logError = args[5];
|
|
369
|
-
requiresSocket = args[6];
|
|
266
|
+
const options = args[0];
|
|
267
|
+
return {
|
|
268
|
+
ipc: options.ipc,
|
|
269
|
+
message: options.message,
|
|
270
|
+
execute: options.execute,
|
|
271
|
+
resolve: options.resolve || defaultResolve,
|
|
272
|
+
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
273
|
+
logError: options.logError || defaultLogError,
|
|
274
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket
|
|
275
|
+
};
|
|
370
276
|
}
|
|
277
|
+
return {
|
|
278
|
+
ipc: args[0],
|
|
279
|
+
message: args[1],
|
|
280
|
+
execute: args[2],
|
|
281
|
+
resolve: args[3],
|
|
282
|
+
preparePrettyError: args[4],
|
|
283
|
+
logError: args[5],
|
|
284
|
+
requiresSocket: args[6]
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
const handleJsonRpcMessage = async (...args) => {
|
|
288
|
+
const options = normalizeParams(args);
|
|
289
|
+
const {
|
|
290
|
+
message,
|
|
291
|
+
ipc,
|
|
292
|
+
execute,
|
|
293
|
+
resolve,
|
|
294
|
+
preparePrettyError,
|
|
295
|
+
logError,
|
|
296
|
+
requiresSocket
|
|
297
|
+
} = options;
|
|
371
298
|
if ('id' in message) {
|
|
372
299
|
if ('method' in message) {
|
|
373
300
|
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
@@ -388,152 +315,606 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
388
315
|
}
|
|
389
316
|
throw new JsonRpcError('unexpected message');
|
|
390
317
|
};
|
|
391
|
-
const
|
|
392
|
-
const {
|
|
393
|
-
message,
|
|
394
|
-
promise
|
|
395
|
-
} = create$2(method, params);
|
|
396
|
-
ipc.send(message);
|
|
397
|
-
const responseMessage = await promise;
|
|
398
|
-
const result = unwrapJsonRpcResult(responseMessage);
|
|
399
|
-
return result;
|
|
400
|
-
};
|
|
401
|
-
const invokeAndTransfer$1 = async (ipc, method, ...params) => {
|
|
318
|
+
const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
402
319
|
const {
|
|
403
320
|
message,
|
|
404
321
|
promise
|
|
405
322
|
} = create$2(method, params);
|
|
406
|
-
ipc.sendAndTransfer
|
|
323
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
324
|
+
ipc.sendAndTransfer(message);
|
|
325
|
+
} else {
|
|
326
|
+
ipc.send(message);
|
|
327
|
+
}
|
|
407
328
|
const responseMessage = await promise;
|
|
408
|
-
|
|
409
|
-
return result;
|
|
410
|
-
};
|
|
411
|
-
|
|
412
|
-
const invoke = (method, ...params) => {
|
|
413
|
-
const ipc = get$1();
|
|
414
|
-
return invoke$1(ipc, method, ...params);
|
|
329
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
415
330
|
};
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
return invokeAndTransfer$1(ipc, method, ...params);
|
|
331
|
+
const invoke$1 = (ipc, method, ...params) => {
|
|
332
|
+
return invokeHelper(ipc, method, params, false);
|
|
419
333
|
};
|
|
420
|
-
const
|
|
421
|
-
|
|
334
|
+
const invokeAndTransfer$1 = (ipc, method, ...params) => {
|
|
335
|
+
return invokeHelper(ipc, method, params, true);
|
|
422
336
|
};
|
|
423
337
|
|
|
424
|
-
const
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
invokeAndTransfer,
|
|
428
|
-
listen: listen$2
|
|
338
|
+
const commands = Object.create(null);
|
|
339
|
+
const register = commandMap => {
|
|
340
|
+
Object.assign(commands, commandMap);
|
|
429
341
|
};
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
const Pass = 'pass';
|
|
433
|
-
|
|
434
|
-
const now = () => {
|
|
435
|
-
return performance.now();
|
|
342
|
+
const getCommand = key => {
|
|
343
|
+
return commands[key];
|
|
436
344
|
};
|
|
437
|
-
|
|
438
|
-
const
|
|
439
|
-
if (
|
|
440
|
-
|
|
441
|
-
}
|
|
442
|
-
if (line.startsWith('VError: ')) {
|
|
443
|
-
return line.slice(`VError: `.length);
|
|
345
|
+
const execute$3 = (command, ...args) => {
|
|
346
|
+
const fn = getCommand(command);
|
|
347
|
+
if (!fn) {
|
|
348
|
+
throw new Error(`command not found ${command}`);
|
|
444
349
|
}
|
|
445
|
-
return
|
|
350
|
+
return fn(...args);
|
|
446
351
|
};
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
return `${message}: ${stringifiedError}`;
|
|
451
|
-
}
|
|
452
|
-
return stringifiedError;
|
|
352
|
+
|
|
353
|
+
const getData$1 = event => {
|
|
354
|
+
return event.data;
|
|
453
355
|
};
|
|
454
|
-
const
|
|
455
|
-
const
|
|
456
|
-
|
|
356
|
+
const attachEvents = that => {
|
|
357
|
+
const handleMessage = (...args) => {
|
|
358
|
+
const data = that.getData(...args);
|
|
359
|
+
that.dispatchEvent(new MessageEvent('message', {
|
|
360
|
+
data
|
|
361
|
+
}));
|
|
362
|
+
};
|
|
363
|
+
that.onMessage(handleMessage);
|
|
364
|
+
const handleClose = event => {
|
|
365
|
+
that.dispatchEvent(new Event('close'));
|
|
366
|
+
};
|
|
367
|
+
that.onClose(handleClose);
|
|
457
368
|
};
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
369
|
+
class Ipc extends EventTarget {
|
|
370
|
+
constructor(rawIpc) {
|
|
371
|
+
super();
|
|
372
|
+
this._rawIpc = rawIpc;
|
|
373
|
+
attachEvents(this);
|
|
461
374
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
375
|
+
}
|
|
376
|
+
const readyMessage = 'ready';
|
|
377
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
378
|
+
if (!value) {
|
|
379
|
+
return;
|
|
466
380
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
if (parentFirstLine.includes(childFirstLine)) {
|
|
471
|
-
return parentFirstLine + childRest;
|
|
381
|
+
if (isTransferrable(value)) {
|
|
382
|
+
transferrables.push(value);
|
|
383
|
+
return;
|
|
472
384
|
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
constructor(error, message) {
|
|
477
|
-
const combinedMessage = getCombinedMessage$1(error, message);
|
|
478
|
-
super(combinedMessage);
|
|
479
|
-
this.name = 'VError';
|
|
480
|
-
if (error instanceof Error) {
|
|
481
|
-
this.stack = mergeStacks$1(this.stack, error.stack);
|
|
482
|
-
}
|
|
483
|
-
if (error.codeFrame) {
|
|
484
|
-
// @ts-ignore
|
|
485
|
-
this.codeFrame = error.codeFrame;
|
|
385
|
+
if (Array.isArray(value)) {
|
|
386
|
+
for (const item of value) {
|
|
387
|
+
walkValue(item, transferrables, isTransferrable);
|
|
486
388
|
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
if (typeof value === 'object') {
|
|
392
|
+
for (const property of Object.values(value)) {
|
|
393
|
+
walkValue(property, transferrables, isTransferrable);
|
|
490
394
|
}
|
|
395
|
+
return;
|
|
491
396
|
}
|
|
492
397
|
};
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
if (error && error.constructor.name === 'AssertionError') {
|
|
496
|
-
console.error(error.message);
|
|
497
|
-
} else {
|
|
498
|
-
console.error(error);
|
|
499
|
-
}
|
|
398
|
+
const isMessagePort = value => {
|
|
399
|
+
return value && value instanceof MessagePort;
|
|
500
400
|
};
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
|
|
401
|
+
const isMessagePortMain = value => {
|
|
402
|
+
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
403
|
+
};
|
|
404
|
+
const isOffscreenCanvas = value => {
|
|
405
|
+
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
406
|
+
};
|
|
407
|
+
const isInstanceOf = (value, constructorName) => {
|
|
408
|
+
return value?.constructor?.name === constructorName;
|
|
409
|
+
};
|
|
410
|
+
const isSocket = value => {
|
|
411
|
+
return isInstanceOf(value, 'Socket');
|
|
412
|
+
};
|
|
413
|
+
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
414
|
+
const isTransferrable = value => {
|
|
415
|
+
for (const fn of transferrables) {
|
|
416
|
+
if (fn(value)) {
|
|
417
|
+
return true;
|
|
418
|
+
}
|
|
504
419
|
}
|
|
505
|
-
|
|
506
|
-
|
|
420
|
+
return false;
|
|
421
|
+
};
|
|
422
|
+
const getTransferrables = value => {
|
|
423
|
+
const transferrables = [];
|
|
424
|
+
walkValue(value, transferrables, isTransferrable);
|
|
425
|
+
return transferrables;
|
|
426
|
+
};
|
|
427
|
+
const listen$2$1 = () => {
|
|
428
|
+
// @ts-ignore
|
|
429
|
+
if (typeof WorkerGlobalScope === 'undefined') {
|
|
430
|
+
throw new TypeError('module is not in web worker scope');
|
|
507
431
|
}
|
|
508
|
-
return
|
|
432
|
+
return globalThis;
|
|
509
433
|
};
|
|
510
|
-
const
|
|
511
|
-
|
|
434
|
+
const signal$2 = global => {
|
|
435
|
+
global.postMessage(readyMessage);
|
|
512
436
|
};
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
let _formattedDuration;
|
|
519
|
-
try {
|
|
520
|
-
_start = now();
|
|
521
|
-
await fn(globals);
|
|
522
|
-
_end = now();
|
|
523
|
-
_duration = _end - _start;
|
|
524
|
-
_formattedDuration = formatDuration(_duration);
|
|
525
|
-
console.info(`PASS ${name} in ${_formattedDuration}`);
|
|
526
|
-
} catch (error) {
|
|
527
|
-
if (error &&
|
|
437
|
+
class IpcChildWithModuleWorker extends Ipc {
|
|
438
|
+
getData(event) {
|
|
439
|
+
return getData$1(event);
|
|
440
|
+
}
|
|
441
|
+
send(message) {
|
|
528
442
|
// @ts-ignore
|
|
529
|
-
|
|
443
|
+
this._rawIpc.postMessage(message);
|
|
444
|
+
}
|
|
445
|
+
sendAndTransfer(message) {
|
|
446
|
+
const transfer = getTransferrables(message);
|
|
447
|
+
// @ts-ignore
|
|
448
|
+
this._rawIpc.postMessage(message, transfer);
|
|
449
|
+
}
|
|
450
|
+
dispose() {
|
|
451
|
+
// ignore
|
|
452
|
+
}
|
|
453
|
+
onClose(callback) {
|
|
454
|
+
// ignore
|
|
455
|
+
}
|
|
456
|
+
onMessage(callback) {
|
|
457
|
+
this._rawIpc.addEventListener('message', callback);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
const wrap$5 = global => {
|
|
461
|
+
return new IpcChildWithModuleWorker(global);
|
|
462
|
+
};
|
|
463
|
+
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
464
|
+
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
465
|
+
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
466
|
+
const NewLine$1 = '\n';
|
|
467
|
+
const joinLines = lines => {
|
|
468
|
+
return lines.join(NewLine$1);
|
|
469
|
+
};
|
|
470
|
+
const splitLines = lines => {
|
|
471
|
+
return lines.split(NewLine$1);
|
|
472
|
+
};
|
|
473
|
+
const isModuleNotFoundMessage = line => {
|
|
474
|
+
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
475
|
+
};
|
|
476
|
+
const getModuleNotFoundError = stderr => {
|
|
477
|
+
const lines = splitLines(stderr);
|
|
478
|
+
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
479
|
+
const message = lines[messageIndex];
|
|
480
|
+
return {
|
|
481
|
+
message,
|
|
482
|
+
code: ERR_MODULE_NOT_FOUND
|
|
483
|
+
};
|
|
484
|
+
};
|
|
485
|
+
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
486
|
+
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
487
|
+
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
488
|
+
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
489
|
+
const RE_AT = /^\s+at/;
|
|
490
|
+
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
491
|
+
const isUnhelpfulNativeModuleError = stderr => {
|
|
492
|
+
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
493
|
+
};
|
|
494
|
+
const isMessageCodeBlockStartIndex = line => {
|
|
495
|
+
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
496
|
+
};
|
|
497
|
+
const isMessageCodeBlockEndIndex = line => {
|
|
498
|
+
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
499
|
+
};
|
|
500
|
+
const getMessageCodeBlock = stderr => {
|
|
501
|
+
const lines = splitLines(stderr);
|
|
502
|
+
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
503
|
+
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
504
|
+
const relevantLines = lines.slice(startIndex, endIndex);
|
|
505
|
+
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
506
|
+
return relevantMessage;
|
|
507
|
+
};
|
|
508
|
+
const getNativeModuleErrorMessage = stderr => {
|
|
509
|
+
const message = getMessageCodeBlock(stderr);
|
|
510
|
+
return {
|
|
511
|
+
message: `Incompatible native node module: ${message}`,
|
|
512
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE
|
|
513
|
+
};
|
|
514
|
+
};
|
|
515
|
+
const isModulesSyntaxError = stderr => {
|
|
516
|
+
if (!stderr) {
|
|
517
|
+
return false;
|
|
518
|
+
}
|
|
519
|
+
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
520
|
+
};
|
|
521
|
+
const getModuleSyntaxError = () => {
|
|
522
|
+
return {
|
|
523
|
+
message: `ES Modules are not supported in electron`,
|
|
524
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
|
|
525
|
+
};
|
|
526
|
+
};
|
|
527
|
+
const isModuleNotFoundError = stderr => {
|
|
528
|
+
if (!stderr) {
|
|
529
|
+
return false;
|
|
530
|
+
}
|
|
531
|
+
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
532
|
+
};
|
|
533
|
+
const isNormalStackLine = line => {
|
|
534
|
+
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
535
|
+
};
|
|
536
|
+
const getDetails = lines => {
|
|
537
|
+
const index = lines.findIndex(isNormalStackLine);
|
|
538
|
+
if (index === -1) {
|
|
539
|
+
return {
|
|
540
|
+
actualMessage: joinLines(lines),
|
|
541
|
+
rest: []
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
let lastIndex = index - 1;
|
|
545
|
+
while (++lastIndex < lines.length) {
|
|
546
|
+
if (!isNormalStackLine(lines[lastIndex])) {
|
|
547
|
+
break;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
return {
|
|
551
|
+
actualMessage: lines[index - 1],
|
|
552
|
+
rest: lines.slice(index, lastIndex)
|
|
553
|
+
};
|
|
554
|
+
};
|
|
555
|
+
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
556
|
+
if (isUnhelpfulNativeModuleError(stderr)) {
|
|
557
|
+
return getNativeModuleErrorMessage(stderr);
|
|
558
|
+
}
|
|
559
|
+
if (isModulesSyntaxError(stderr)) {
|
|
560
|
+
return getModuleSyntaxError();
|
|
561
|
+
}
|
|
562
|
+
if (isModuleNotFoundError(stderr)) {
|
|
563
|
+
return getModuleNotFoundError(stderr);
|
|
564
|
+
}
|
|
565
|
+
const lines = splitLines(stderr);
|
|
566
|
+
const {
|
|
567
|
+
actualMessage,
|
|
568
|
+
rest
|
|
569
|
+
} = getDetails(lines);
|
|
570
|
+
return {
|
|
571
|
+
message: `${actualMessage}`,
|
|
572
|
+
code: '',
|
|
573
|
+
stack: rest
|
|
574
|
+
};
|
|
575
|
+
};
|
|
576
|
+
const normalizeLine$1 = line => {
|
|
577
|
+
if (line.startsWith('Error: ')) {
|
|
578
|
+
return line.slice('Error: '.length);
|
|
579
|
+
}
|
|
580
|
+
if (line.startsWith('VError: ')) {
|
|
581
|
+
return line.slice('VError: '.length);
|
|
582
|
+
}
|
|
583
|
+
return line;
|
|
584
|
+
};
|
|
585
|
+
const getCombinedMessage$1 = (error, message) => {
|
|
586
|
+
const stringifiedError = normalizeLine$1(`${error}`);
|
|
587
|
+
if (message) {
|
|
588
|
+
return `${message}: ${stringifiedError}`;
|
|
589
|
+
}
|
|
590
|
+
return stringifiedError;
|
|
591
|
+
};
|
|
592
|
+
const NewLine$2 = '\n';
|
|
593
|
+
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
594
|
+
return string.indexOf(NewLine$2, startIndex);
|
|
595
|
+
};
|
|
596
|
+
const mergeStacks$1 = (parent, child) => {
|
|
597
|
+
if (!child) {
|
|
598
|
+
return parent;
|
|
599
|
+
}
|
|
600
|
+
const parentNewLineIndex = getNewLineIndex$1(parent);
|
|
601
|
+
const childNewLineIndex = getNewLineIndex$1(child);
|
|
602
|
+
if (childNewLineIndex === -1) {
|
|
603
|
+
return parent;
|
|
604
|
+
}
|
|
605
|
+
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
606
|
+
const childRest = child.slice(childNewLineIndex);
|
|
607
|
+
const childFirstLine = normalizeLine$1(child.slice(0, childNewLineIndex));
|
|
608
|
+
if (parentFirstLine.includes(childFirstLine)) {
|
|
609
|
+
return parentFirstLine + childRest;
|
|
610
|
+
}
|
|
611
|
+
return child;
|
|
612
|
+
};
|
|
613
|
+
let VError$1 = class VError extends Error {
|
|
614
|
+
constructor(error, message) {
|
|
615
|
+
const combinedMessage = getCombinedMessage$1(error, message);
|
|
616
|
+
super(combinedMessage);
|
|
617
|
+
this.name = 'VError';
|
|
618
|
+
if (error instanceof Error) {
|
|
619
|
+
this.stack = mergeStacks$1(this.stack, error.stack);
|
|
620
|
+
}
|
|
621
|
+
if (error.codeFrame) {
|
|
622
|
+
// @ts-ignore
|
|
623
|
+
this.codeFrame = error.codeFrame;
|
|
624
|
+
}
|
|
625
|
+
if (error.code) {
|
|
626
|
+
// @ts-ignore
|
|
627
|
+
this.code = error.code;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
class IpcError extends VError$1 {
|
|
632
|
+
// @ts-ignore
|
|
633
|
+
constructor(betterMessage, stdout = '', stderr = '') {
|
|
634
|
+
if (stdout || stderr) {
|
|
635
|
+
// @ts-ignore
|
|
636
|
+
const {
|
|
637
|
+
message,
|
|
638
|
+
code,
|
|
639
|
+
stack
|
|
640
|
+
} = getHelpfulChildProcessError(stdout, stderr);
|
|
641
|
+
const cause = new Error(message);
|
|
642
|
+
// @ts-ignore
|
|
643
|
+
cause.code = code;
|
|
644
|
+
cause.stack = stack;
|
|
645
|
+
super(cause, betterMessage);
|
|
646
|
+
} else {
|
|
647
|
+
super(betterMessage);
|
|
648
|
+
}
|
|
649
|
+
// @ts-ignore
|
|
650
|
+
this.name = 'IpcError';
|
|
651
|
+
// @ts-ignore
|
|
652
|
+
this.stdout = stdout;
|
|
653
|
+
// @ts-ignore
|
|
654
|
+
this.stderr = stderr;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
const withResolvers = () => {
|
|
658
|
+
let _resolve;
|
|
659
|
+
const promise = new Promise(resolve => {
|
|
660
|
+
_resolve = resolve;
|
|
661
|
+
});
|
|
662
|
+
return {
|
|
663
|
+
resolve: _resolve,
|
|
664
|
+
promise
|
|
665
|
+
};
|
|
666
|
+
};
|
|
667
|
+
const waitForFirstMessage = async port => {
|
|
668
|
+
const {
|
|
669
|
+
resolve,
|
|
670
|
+
promise
|
|
671
|
+
} = withResolvers();
|
|
672
|
+
port.addEventListener('message', resolve, {
|
|
673
|
+
once: true
|
|
674
|
+
});
|
|
675
|
+
const event = await promise;
|
|
676
|
+
// @ts-ignore
|
|
677
|
+
return event.data;
|
|
678
|
+
};
|
|
679
|
+
const listen$1$1 = async () => {
|
|
680
|
+
const parentIpcRaw = listen$2$1();
|
|
681
|
+
signal$2(parentIpcRaw);
|
|
682
|
+
const parentIpc = wrap$5(parentIpcRaw);
|
|
683
|
+
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
684
|
+
if (firstMessage.method !== 'initialize') {
|
|
685
|
+
throw new IpcError('unexpected first message');
|
|
686
|
+
}
|
|
687
|
+
const type = firstMessage.params[0];
|
|
688
|
+
if (type === 'message-port') {
|
|
689
|
+
parentIpc.send({
|
|
690
|
+
jsonrpc: '2.0',
|
|
691
|
+
id: firstMessage.id,
|
|
692
|
+
result: null
|
|
693
|
+
});
|
|
694
|
+
parentIpc.dispose();
|
|
695
|
+
const port = firstMessage.params[1];
|
|
696
|
+
return port;
|
|
697
|
+
}
|
|
698
|
+
return globalThis;
|
|
699
|
+
};
|
|
700
|
+
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
701
|
+
constructor(port) {
|
|
702
|
+
super(port);
|
|
703
|
+
}
|
|
704
|
+
getData(event) {
|
|
705
|
+
return getData$1(event);
|
|
706
|
+
}
|
|
707
|
+
send(message) {
|
|
708
|
+
this._rawIpc.postMessage(message);
|
|
709
|
+
}
|
|
710
|
+
sendAndTransfer(message) {
|
|
711
|
+
const transfer = getTransferrables(message);
|
|
712
|
+
this._rawIpc.postMessage(message, transfer);
|
|
713
|
+
}
|
|
714
|
+
dispose() {
|
|
715
|
+
if (this._rawIpc.close) {
|
|
716
|
+
this._rawIpc.close();
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
onClose(callback) {
|
|
720
|
+
// ignore
|
|
721
|
+
}
|
|
722
|
+
onMessage(callback) {
|
|
723
|
+
this._rawIpc.addEventListener('message', callback);
|
|
724
|
+
this._rawIpc.start();
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
const wrap$4 = port => {
|
|
728
|
+
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
729
|
+
};
|
|
730
|
+
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
731
|
+
__proto__: null,
|
|
732
|
+
listen: listen$1$1,
|
|
733
|
+
wrap: wrap$4
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
const createRpc = ipc => {
|
|
737
|
+
const rpc = {
|
|
738
|
+
invoke(method, ...params) {
|
|
739
|
+
return invoke$1(ipc, method, ...params);
|
|
740
|
+
},
|
|
741
|
+
invokeAndTransfer(method, ...params) {
|
|
742
|
+
return invokeAndTransfer$1(ipc, method, ...params);
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
return rpc;
|
|
746
|
+
};
|
|
747
|
+
const requiresSocket$1 = () => {
|
|
748
|
+
return false;
|
|
749
|
+
};
|
|
750
|
+
const preparePrettyError$1 = error => {
|
|
751
|
+
return error;
|
|
752
|
+
};
|
|
753
|
+
const logError$1 = () => {
|
|
754
|
+
// handled by renderer worker
|
|
755
|
+
};
|
|
756
|
+
const handleMessage = event => {
|
|
757
|
+
return handleJsonRpcMessage(event.target, event.data, execute$3, resolve, preparePrettyError$1, logError$1, requiresSocket$1);
|
|
758
|
+
};
|
|
759
|
+
const handleIpc = ipc => {
|
|
760
|
+
ipc.addEventListener('message', handleMessage);
|
|
761
|
+
};
|
|
762
|
+
|
|
763
|
+
// @ts-ignore
|
|
764
|
+
const listen$2 = async () => {
|
|
765
|
+
const module = IpcChildWithModuleWorkerAndMessagePort$1;
|
|
766
|
+
const rawIpc = await module.listen();
|
|
767
|
+
const ipc = module.wrap(rawIpc);
|
|
768
|
+
return ipc;
|
|
769
|
+
};
|
|
770
|
+
const create$1 = async ({
|
|
771
|
+
commandMap
|
|
772
|
+
}) => {
|
|
773
|
+
// TODO create a commandMap per rpc instance
|
|
774
|
+
register(commandMap);
|
|
775
|
+
const ipc = await listen$2();
|
|
776
|
+
handleIpc(ipc);
|
|
777
|
+
const rpc = createRpc(ipc);
|
|
778
|
+
return rpc;
|
|
779
|
+
};
|
|
780
|
+
const WebWorkerRpcClient = {
|
|
781
|
+
__proto__: null,
|
|
782
|
+
create: create$1
|
|
783
|
+
};
|
|
784
|
+
|
|
785
|
+
const state$1 = {
|
|
786
|
+
rpc: undefined
|
|
787
|
+
};
|
|
788
|
+
const invoke = (method, ...params) => {
|
|
789
|
+
const rpc = state$1.rpc;
|
|
790
|
+
// @ts-ignore
|
|
791
|
+
return rpc.invoke(method, ...params);
|
|
792
|
+
};
|
|
793
|
+
const invokeAndTransfer = (method, ...params) => {
|
|
794
|
+
const rpc = state$1.rpc;
|
|
795
|
+
// @ts-ignore
|
|
796
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
797
|
+
};
|
|
798
|
+
const listen$1 = ipc => {
|
|
799
|
+
};
|
|
800
|
+
const setRpc = rpc => {
|
|
801
|
+
state$1.rpc = rpc;
|
|
802
|
+
};
|
|
803
|
+
|
|
804
|
+
const Rpc = {
|
|
805
|
+
__proto__: null,
|
|
806
|
+
invoke,
|
|
807
|
+
invokeAndTransfer,
|
|
808
|
+
listen: listen$1,
|
|
809
|
+
setRpc
|
|
810
|
+
};
|
|
811
|
+
|
|
812
|
+
const Fail = 'fail';
|
|
813
|
+
const Pass = 'pass';
|
|
814
|
+
|
|
815
|
+
const now = () => {
|
|
816
|
+
return performance.now();
|
|
817
|
+
};
|
|
818
|
+
|
|
819
|
+
const normalizeLine = line => {
|
|
820
|
+
if (line.startsWith('Error: ')) {
|
|
821
|
+
return line.slice('Error: '.length);
|
|
822
|
+
}
|
|
823
|
+
if (line.startsWith('VError: ')) {
|
|
824
|
+
return line.slice('VError: '.length);
|
|
825
|
+
}
|
|
826
|
+
return line;
|
|
827
|
+
};
|
|
828
|
+
const getCombinedMessage = (error, message) => {
|
|
829
|
+
const stringifiedError = normalizeLine(`${error}`);
|
|
830
|
+
if (message) {
|
|
831
|
+
return `${message}: ${stringifiedError}`;
|
|
832
|
+
}
|
|
833
|
+
return stringifiedError;
|
|
834
|
+
};
|
|
835
|
+
const NewLine = '\n';
|
|
836
|
+
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
837
|
+
return string.indexOf(NewLine, startIndex);
|
|
838
|
+
};
|
|
839
|
+
const mergeStacks = (parent, child) => {
|
|
840
|
+
if (!child) {
|
|
841
|
+
return parent;
|
|
842
|
+
}
|
|
843
|
+
const parentNewLineIndex = getNewLineIndex(parent);
|
|
844
|
+
const childNewLineIndex = getNewLineIndex(child);
|
|
845
|
+
if (childNewLineIndex === -1) {
|
|
846
|
+
return parent;
|
|
847
|
+
}
|
|
848
|
+
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
849
|
+
const childRest = child.slice(childNewLineIndex);
|
|
850
|
+
const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
|
|
851
|
+
if (parentFirstLine.includes(childFirstLine)) {
|
|
852
|
+
return parentFirstLine + childRest;
|
|
853
|
+
}
|
|
854
|
+
return child;
|
|
855
|
+
};
|
|
856
|
+
class VError extends Error {
|
|
857
|
+
constructor(error, message) {
|
|
858
|
+
const combinedMessage = getCombinedMessage(error, message);
|
|
859
|
+
super(combinedMessage);
|
|
860
|
+
this.name = 'VError';
|
|
861
|
+
if (error instanceof Error) {
|
|
862
|
+
this.stack = mergeStacks(this.stack, error.stack);
|
|
863
|
+
}
|
|
864
|
+
if (error.codeFrame) {
|
|
865
|
+
// @ts-ignore
|
|
866
|
+
this.codeFrame = error.codeFrame;
|
|
867
|
+
}
|
|
868
|
+
if (error.code) {
|
|
869
|
+
// @ts-ignore
|
|
870
|
+
this.code = error.code;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
const printError = error => {
|
|
876
|
+
if (error && error.constructor.name === 'AssertionError') {
|
|
877
|
+
console.error(error.message);
|
|
878
|
+
} else {
|
|
879
|
+
console.error(error);
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
const stringifyError = error => {
|
|
883
|
+
if (!error) {
|
|
884
|
+
return `${error}`;
|
|
885
|
+
}
|
|
886
|
+
if (error && error.message && error.constructor.name && error.constructor.name !== 'Error' && error.constructor.name !== 'VError') {
|
|
887
|
+
return `${error}`;
|
|
888
|
+
}
|
|
889
|
+
return `${error.message}`;
|
|
890
|
+
};
|
|
891
|
+
const formatDuration = duration => {
|
|
892
|
+
return duration.toFixed(2) + 'ms';
|
|
893
|
+
};
|
|
894
|
+
const executeTest = async (name, fn, globals = {}) => {
|
|
895
|
+
let _error;
|
|
896
|
+
let _start;
|
|
897
|
+
let _end;
|
|
898
|
+
let _duration;
|
|
899
|
+
let _formattedDuration;
|
|
900
|
+
try {
|
|
901
|
+
_start = now();
|
|
902
|
+
await fn(globals);
|
|
903
|
+
_end = now();
|
|
904
|
+
_duration = _end - _start;
|
|
905
|
+
_formattedDuration = formatDuration(_duration);
|
|
906
|
+
console.info(`PASS ${name} in ${_formattedDuration}`);
|
|
907
|
+
} catch (error) {
|
|
908
|
+
if (error &&
|
|
909
|
+
// @ts-ignore
|
|
910
|
+
error.message.startsWith('Failed to load command TestFrameWork.')) {
|
|
530
911
|
console.error(error);
|
|
531
912
|
return;
|
|
532
913
|
}
|
|
533
914
|
// @ts-ignore
|
|
534
915
|
_error = stringifyError(error);
|
|
535
|
-
if (!(error instanceof VError
|
|
536
|
-
error = new VError
|
|
916
|
+
if (!(error instanceof VError)) {
|
|
917
|
+
error = new VError(error, `Test failed: ${name}`);
|
|
537
918
|
}
|
|
538
919
|
// @ts-ignore
|
|
539
920
|
printError(error);
|
|
@@ -568,7 +949,7 @@ const importTest = async url => {
|
|
|
568
949
|
try {
|
|
569
950
|
return await importScript(url);
|
|
570
951
|
} catch (error) {
|
|
571
|
-
throw new VError
|
|
952
|
+
throw new VError(error, 'Failed to import test');
|
|
572
953
|
}
|
|
573
954
|
};
|
|
574
955
|
|
|
@@ -737,7 +1118,7 @@ const setMockRpc = mockRpc => {
|
|
|
737
1118
|
|
|
738
1119
|
// @ts-nocheck
|
|
739
1120
|
|
|
740
|
-
const create = (selector, options) => {
|
|
1121
|
+
const create = (selector, options = {}) => {
|
|
741
1122
|
return new Locator(selector, options);
|
|
742
1123
|
};
|
|
743
1124
|
const Locator = function (selector, {
|
|
@@ -748,11 +1129,11 @@ const Locator = function (selector, {
|
|
|
748
1129
|
this._nth = nth;
|
|
749
1130
|
this._hasText = hasText;
|
|
750
1131
|
};
|
|
751
|
-
const performAction = async (locator,
|
|
1132
|
+
const performAction = async (locator, action, options) => {
|
|
752
1133
|
const {
|
|
753
1134
|
invoke
|
|
754
1135
|
} = locator.webView || Rpc;
|
|
755
|
-
return invoke('TestFrameWork.performAction', locator,
|
|
1136
|
+
return invoke('TestFrameWork.performAction', locator, action, options);
|
|
756
1137
|
};
|
|
757
1138
|
const toButtonNumber = buttonType => {
|
|
758
1139
|
switch (buttonType) {
|
|
@@ -820,7 +1201,7 @@ const test = async (name, fn) => {
|
|
|
820
1201
|
nameAnonymousFunction(fn, `test/${name}`);
|
|
821
1202
|
addTest(name, fn);
|
|
822
1203
|
};
|
|
823
|
-
test.skip = async
|
|
1204
|
+
test.skip = async id => {
|
|
824
1205
|
const state = 'skip';
|
|
825
1206
|
const background = 'yellow';
|
|
826
1207
|
const text = `test skipped ${id}`;
|
|
@@ -984,7 +1365,7 @@ const goToTypeDefinition = async () => {
|
|
|
984
1365
|
await invoke('Editor.goToTypeDefinition');
|
|
985
1366
|
};
|
|
986
1367
|
const type = async text => {
|
|
987
|
-
await invoke('Editor.type');
|
|
1368
|
+
await invoke('Editor.type', text);
|
|
988
1369
|
};
|
|
989
1370
|
const findAllReferences = async () => {
|
|
990
1371
|
await invoke('SideBar.show', 'References', /* focus */true);
|
|
@@ -1022,1172 +1403,734 @@ const closeCompletionDetails = async () => {
|
|
|
1022
1403
|
const toggleCompletionDetails = async () => {
|
|
1023
1404
|
await invoke('EditorCompletion.toggleDetails');
|
|
1024
1405
|
};
|
|
1025
|
-
const organizeImports = async () => {
|
|
1026
|
-
await invoke('Editor.organizeImports');
|
|
1027
|
-
};
|
|
1028
|
-
const addAllMissingImports = async () => {
|
|
1029
|
-
await invoke('Editor.addAllMissingImports');
|
|
1030
|
-
};
|
|
1031
|
-
const sortImports = async () => {
|
|
1032
|
-
await invoke('Editor.sortImports');
|
|
1033
|
-
};
|
|
1034
|
-
const toggleLineComment = async () => {
|
|
1035
|
-
await invoke('Editor.toggleLineComment');
|
|
1036
|
-
};
|
|
1037
|
-
const toggleBlockComment = async () => {
|
|
1038
|
-
await invoke('Editor.toggleBlockComment');
|
|
1039
|
-
};
|
|
1040
|
-
const selectAll = async () => {
|
|
1041
|
-
await invoke('Editor.toggleBlockComment');
|
|
1042
|
-
};
|
|
1043
|
-
const openColorPicker = async () => {
|
|
1044
|
-
await invoke('Editor.openColorPicker');
|
|
1045
|
-
};
|
|
1046
|
-
const openFind = async () => {
|
|
1047
|
-
await invoke('Editor.openFind2');
|
|
1048
|
-
};
|
|
1049
|
-
const deleteAllLeft = async () => {
|
|
1050
|
-
await invoke('Editor.deleteAllLeft');
|
|
1051
|
-
};
|
|
1052
|
-
const deleteAllRight = async () => {
|
|
1053
|
-
await invoke('Editor.deleteAllRight');
|
|
1054
|
-
};
|
|
1055
|
-
const cursorWordPartLeft = async () => {
|
|
1056
|
-
await invoke('Editor.cursorWordPartLeft');
|
|
1057
|
-
};
|
|
1058
|
-
const cursorWordPartRight = async () => {
|
|
1059
|
-
await invoke('Editor.cursorWordPartRight');
|
|
1060
|
-
};
|
|
1061
|
-
const cursorEnd = async () => {
|
|
1062
|
-
await invoke('Editor.cursorEnd');
|
|
1063
|
-
};
|
|
1064
|
-
const cursorHome = async () => {
|
|
1065
|
-
await invoke('Editor.cursorHome');
|
|
1066
|
-
};
|
|
1067
|
-
const copyLineUp = async () => {
|
|
1068
|
-
await invoke('Editor.copyLineUp');
|
|
1069
|
-
};
|
|
1070
|
-
const copy = async () => {
|
|
1071
|
-
await invoke('Editor.copy');
|
|
1072
|
-
};
|
|
1073
|
-
const closeColorPicker = async () => {
|
|
1074
|
-
await invoke('Editor.closeColorPicker');
|
|
1075
|
-
};
|
|
1076
|
-
const openContextMenu$1 = async () => {
|
|
1077
|
-
await invoke('Editor.contextMenu');
|
|
1078
|
-
};
|
|
1079
|
-
const getText = async () => {
|
|
1080
|
-
return invoke('Editor.getText');
|
|
1081
|
-
};
|
|
1082
|
-
const rename$1 = async () => {
|
|
1083
|
-
await invoke('Editor.rename');
|
|
1084
|
-
};
|
|
1085
|
-
|
|
1086
|
-
const TestFrameWorkComponentEditor = {
|
|
1087
|
-
__proto__: null,
|
|
1088
|
-
addAllMissingImports,
|
|
1089
|
-
closeColorPicker,
|
|
1090
|
-
closeCompletionDetails,
|
|
1091
|
-
copy,
|
|
1092
|
-
copyLineDown,
|
|
1093
|
-
copyLineUp,
|
|
1094
|
-
cursorCharacterLeft,
|
|
1095
|
-
cursorCharacterRight,
|
|
1096
|
-
cursorDown,
|
|
1097
|
-
cursorEnd,
|
|
1098
|
-
cursorHome,
|
|
1099
|
-
cursorUp,
|
|
1100
|
-
cursorWordLeft,
|
|
1101
|
-
cursorWordPartLeft,
|
|
1102
|
-
cursorWordPartRight,
|
|
1103
|
-
cursorWordRight,
|
|
1104
|
-
deleteAllLeft,
|
|
1105
|
-
deleteAllRight,
|
|
1106
|
-
executeTabCompletion,
|
|
1107
|
-
findAllImplementations,
|
|
1108
|
-
findAllReferences,
|
|
1109
|
-
format,
|
|
1110
|
-
getText,
|
|
1111
|
-
goToDefinition,
|
|
1112
|
-
goToTypeDefinition,
|
|
1113
|
-
insertLineBreak,
|
|
1114
|
-
invokeBraceCompletion,
|
|
1115
|
-
invokeTabCompletion,
|
|
1116
|
-
openColorPicker,
|
|
1117
|
-
openCompletion,
|
|
1118
|
-
openCompletionDetails,
|
|
1119
|
-
openContextMenu: openContextMenu$1,
|
|
1120
|
-
openEditorContextMenu,
|
|
1121
|
-
openFind,
|
|
1122
|
-
openFindWidget,
|
|
1123
|
-
openHover,
|
|
1124
|
-
openSourceActions,
|
|
1125
|
-
organizeImports,
|
|
1126
|
-
rename: rename$1,
|
|
1127
|
-
selectAll,
|
|
1128
|
-
setCursor,
|
|
1129
|
-
setDeltaY,
|
|
1130
|
-
setSelections,
|
|
1131
|
-
sortImports,
|
|
1132
|
-
sourceActionsSelectCurrent,
|
|
1133
|
-
toggleBlockComment,
|
|
1134
|
-
toggleCompletionDetails,
|
|
1135
|
-
toggleLineComment,
|
|
1136
|
-
type
|
|
1137
|
-
};
|
|
1138
|
-
|
|
1139
|
-
const openContextMenu = async index => {
|
|
1140
|
-
await invoke('Explorer.handleContextMenuKeyboard', index);
|
|
1141
|
-
};
|
|
1142
|
-
const focus$1 = async () => {
|
|
1143
|
-
await invoke('Explorer.focusIndex', -1);
|
|
1144
|
-
};
|
|
1145
|
-
const focusNext$3 = async () => {
|
|
1146
|
-
await invoke('Explorer.focusNext');
|
|
1147
|
-
};
|
|
1148
|
-
const focusIndex$2 = async index => {
|
|
1149
|
-
await invoke('Explorer.focusIndex', index);
|
|
1150
|
-
};
|
|
1151
|
-
const clickCurrent = async () => {
|
|
1152
|
-
await invoke('Explorer.handleClickCurrent');
|
|
1153
|
-
};
|
|
1154
|
-
const handleArrowLeft = async () => {
|
|
1155
|
-
await invoke('Explorer.handleArrowLeft');
|
|
1156
|
-
};
|
|
1157
|
-
const focusLast$1 = async () => {
|
|
1158
|
-
await invoke('Explorer.focusLast');
|
|
1159
|
-
};
|
|
1160
|
-
const focusFirst$1 = async () => {
|
|
1161
|
-
await invoke('Explorer.focusFirst');
|
|
1162
|
-
};
|
|
1163
|
-
const removeDirent = async () => {
|
|
1164
|
-
await invoke('Explorer.removeDirent');
|
|
1165
|
-
};
|
|
1166
|
-
const expandRecursively = async () => {
|
|
1167
|
-
await invoke('Explorer.expandRecursively');
|
|
1168
|
-
};
|
|
1169
|
-
const newFile = async () => {
|
|
1170
|
-
await invoke('Explorer.newFile');
|
|
1171
|
-
};
|
|
1172
|
-
const handleClick = async index => {
|
|
1173
|
-
await invoke('Explorer.handleClick', index);
|
|
1174
|
-
};
|
|
1175
|
-
const rename = async () => {
|
|
1176
|
-
await invoke('Explorer.rename');
|
|
1177
|
-
};
|
|
1178
|
-
const cancelEdit = async () => {
|
|
1179
|
-
await invoke('Explorer.cancelEdit');
|
|
1180
|
-
};
|
|
1181
|
-
const acceptEdit = async () => {
|
|
1182
|
-
await invoke('Explorer.acceptEdit');
|
|
1183
|
-
};
|
|
1184
|
-
const updateEditingValue = async value => {
|
|
1185
|
-
await invoke('Explorer.updateEditingValue', value);
|
|
1186
|
-
};
|
|
1187
|
-
const expandAll = async value => {
|
|
1188
|
-
await invoke('Explorer.expandAll', value);
|
|
1189
|
-
};
|
|
1190
|
-
|
|
1191
|
-
const TestFrameWorkComponentExplorer = {
|
|
1192
|
-
__proto__: null,
|
|
1193
|
-
acceptEdit,
|
|
1194
|
-
cancelEdit,
|
|
1195
|
-
clickCurrent,
|
|
1196
|
-
expandAll,
|
|
1197
|
-
expandRecursively,
|
|
1198
|
-
focus: focus$1,
|
|
1199
|
-
focusFirst: focusFirst$1,
|
|
1200
|
-
focusIndex: focusIndex$2,
|
|
1201
|
-
focusLast: focusLast$1,
|
|
1202
|
-
focusNext: focusNext$3,
|
|
1203
|
-
handleArrowLeft,
|
|
1204
|
-
handleClick,
|
|
1205
|
-
newFile,
|
|
1206
|
-
openContextMenu,
|
|
1207
|
-
removeDirent,
|
|
1208
|
-
rename,
|
|
1209
|
-
updateEditingValue
|
|
1210
|
-
};
|
|
1211
|
-
|
|
1212
|
-
const addWebExtension = async relativePath => {
|
|
1213
|
-
// TODO compute absolutePath
|
|
1214
|
-
const absolutePath = relativePath;
|
|
1215
|
-
await invoke('ExtensionMeta.addWebExtension', absolutePath);
|
|
1216
|
-
};
|
|
1217
|
-
const addNodeExtension = async relativePath => {
|
|
1218
|
-
// TODO compute absolutePath
|
|
1219
|
-
const absolutePath = relativePath;
|
|
1220
|
-
await invoke('ExtensionMeta.addNodeExtension', absolutePath);
|
|
1221
|
-
};
|
|
1222
|
-
|
|
1223
|
-
const TestFrameWorkComponentExtension = {
|
|
1224
|
-
__proto__: null,
|
|
1225
|
-
addNodeExtension,
|
|
1226
|
-
addWebExtension
|
|
1227
|
-
};
|
|
1228
|
-
|
|
1229
|
-
const Memfs = 'memfs';
|
|
1230
|
-
|
|
1231
|
-
const Slash$1 = '/';
|
|
1232
|
-
|
|
1233
|
-
const Slash = Slash$1;
|
|
1234
|
-
|
|
1235
|
-
const writeFile = async (path, content) => {
|
|
1236
|
-
await invoke('FileSystem.writeFile', path, content);
|
|
1237
|
-
};
|
|
1238
|
-
const mkdir = async path => {
|
|
1239
|
-
await invoke('FileSystem.mkdir', path);
|
|
1240
|
-
};
|
|
1241
|
-
const getTmpDir = async ({
|
|
1242
|
-
scheme = Memfs
|
|
1243
|
-
} = {}) => {
|
|
1244
|
-
switch (scheme) {
|
|
1245
|
-
case Memfs:
|
|
1246
|
-
return 'memfs:///workspace';
|
|
1247
|
-
default:
|
|
1248
|
-
return invoke('PlatformPaths.getTmpDir');
|
|
1249
|
-
}
|
|
1406
|
+
const organizeImports = async () => {
|
|
1407
|
+
await invoke('Editor.organizeImports');
|
|
1250
1408
|
};
|
|
1251
|
-
const
|
|
1252
|
-
await invoke('
|
|
1409
|
+
const addAllMissingImports = async () => {
|
|
1410
|
+
await invoke('Editor.addAllMissingImports');
|
|
1253
1411
|
};
|
|
1254
|
-
const
|
|
1255
|
-
|
|
1256
|
-
scheme: 'file'
|
|
1257
|
-
});
|
|
1258
|
-
const nodePath = await invoke('PlatformPaths.getNodePath');
|
|
1259
|
-
const gitPath = `${tmpDir}/git`;
|
|
1260
|
-
await writeFile(gitPath, `#!${nodePath}
|
|
1261
|
-
${content}`);
|
|
1262
|
-
await chmod(gitPath, '755');
|
|
1263
|
-
return gitPath;
|
|
1412
|
+
const sortImports = async () => {
|
|
1413
|
+
await invoke('Editor.sortImports');
|
|
1264
1414
|
};
|
|
1265
|
-
const
|
|
1266
|
-
|
|
1267
|
-
const absolutePath = testPath + Slash + path;
|
|
1268
|
-
const content = await invoke('Ajax.getText', absolutePath);
|
|
1269
|
-
return createExecutable(content);
|
|
1415
|
+
const toggleLineComment = async () => {
|
|
1416
|
+
await invoke('Editor.toggleLineComment');
|
|
1270
1417
|
};
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
__proto__: null,
|
|
1274
|
-
chmod,
|
|
1275
|
-
createExecutable,
|
|
1276
|
-
createExecutableFrom,
|
|
1277
|
-
getTmpDir,
|
|
1278
|
-
mkdir,
|
|
1279
|
-
writeFile
|
|
1418
|
+
const toggleBlockComment = async () => {
|
|
1419
|
+
await invoke('Editor.toggleBlockComment');
|
|
1280
1420
|
};
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
await invoke('FindWidget.focusNext');
|
|
1421
|
+
const selectAll = async () => {
|
|
1422
|
+
await invoke('Editor.toggleBlockComment');
|
|
1284
1423
|
};
|
|
1285
|
-
const
|
|
1286
|
-
await invoke('
|
|
1424
|
+
const openColorPicker = async () => {
|
|
1425
|
+
await invoke('Editor.openColorPicker');
|
|
1287
1426
|
};
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
__proto__: null,
|
|
1291
|
-
focusNext: focusNext$2,
|
|
1292
|
-
setValue: setValue$2
|
|
1427
|
+
const openFind = async () => {
|
|
1428
|
+
await invoke('Editor.openFind2');
|
|
1293
1429
|
};
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
await invoke('IconTheme.setIconTheme', id);
|
|
1430
|
+
const deleteAllLeft = async () => {
|
|
1431
|
+
await invoke('Editor.deleteAllLeft');
|
|
1297
1432
|
};
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
__proto__: null,
|
|
1301
|
-
setIconTheme
|
|
1433
|
+
const deleteAllRight = async () => {
|
|
1434
|
+
await invoke('Editor.deleteAllRight');
|
|
1302
1435
|
};
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
if (rawKey.includes('+')) {
|
|
1306
|
-
const parts = rawKey.split('+');
|
|
1307
|
-
let ctrlKey = false;
|
|
1308
|
-
let altKey = false;
|
|
1309
|
-
let key = '';
|
|
1310
|
-
for (const part of parts) {
|
|
1311
|
-
switch (part) {
|
|
1312
|
-
case 'Control':
|
|
1313
|
-
ctrlKey = true;
|
|
1314
|
-
break;
|
|
1315
|
-
case 'Space':
|
|
1316
|
-
key = ' ';
|
|
1317
|
-
break;
|
|
1318
|
-
case 'Alt':
|
|
1319
|
-
altKey = true;
|
|
1320
|
-
break;
|
|
1321
|
-
default:
|
|
1322
|
-
key = part;
|
|
1323
|
-
break;
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
|
-
return {
|
|
1327
|
-
key,
|
|
1328
|
-
ctrlKey,
|
|
1329
|
-
altKey
|
|
1330
|
-
};
|
|
1331
|
-
}
|
|
1332
|
-
return {
|
|
1333
|
-
key: rawKey,
|
|
1334
|
-
ctrlKey: false,
|
|
1335
|
-
altKey: false
|
|
1336
|
-
};
|
|
1436
|
+
const cursorWordPartLeft = async () => {
|
|
1437
|
+
await invoke('Editor.cursorWordPartLeft');
|
|
1337
1438
|
};
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
const keyOptions = getKeyOptions(key);
|
|
1341
|
-
const options = {
|
|
1342
|
-
cancelable: true,
|
|
1343
|
-
bubbles: true,
|
|
1344
|
-
...keyOptions
|
|
1345
|
-
};
|
|
1346
|
-
await invoke('TestFrameWork.performKeyBoardAction', 'press', options);
|
|
1439
|
+
const cursorWordPartRight = async () => {
|
|
1440
|
+
await invoke('Editor.cursorWordPartRight');
|
|
1347
1441
|
};
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
__proto__: null,
|
|
1351
|
-
press
|
|
1442
|
+
const cursorEnd = async () => {
|
|
1443
|
+
await invoke('Editor.cursorEnd');
|
|
1352
1444
|
};
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
await invoke('Main.openUri', uri);
|
|
1445
|
+
const cursorHome = async () => {
|
|
1446
|
+
await invoke('Editor.cursorHome');
|
|
1356
1447
|
};
|
|
1357
|
-
const
|
|
1358
|
-
await invoke('
|
|
1448
|
+
const copyLineUp = async () => {
|
|
1449
|
+
await invoke('Editor.copyLineUp');
|
|
1359
1450
|
};
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
__proto__: null,
|
|
1363
|
-
openUri,
|
|
1364
|
-
splitRight
|
|
1451
|
+
const copy = async () => {
|
|
1452
|
+
await invoke('Editor.copy');
|
|
1365
1453
|
};
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
await invoke('Layout.showPanel', id);
|
|
1454
|
+
const closeColorPicker = async () => {
|
|
1455
|
+
await invoke('Editor.closeColorPicker');
|
|
1369
1456
|
};
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
__proto__: null,
|
|
1373
|
-
open: open$2
|
|
1457
|
+
const openContextMenu$1 = async () => {
|
|
1458
|
+
await invoke('Editor.contextMenu');
|
|
1374
1459
|
};
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
if (typeof navigator === 'undefined') {
|
|
1378
|
-
return false;
|
|
1379
|
-
}
|
|
1380
|
-
if (
|
|
1381
|
-
// @ts-expect-error
|
|
1382
|
-
navigator.userAgentData?.brands) {
|
|
1383
|
-
// @ts-expect-error
|
|
1384
|
-
return navigator.userAgentData.brands.includes('Firefox');
|
|
1385
|
-
}
|
|
1386
|
-
return navigator.userAgent.toLowerCase().includes('firefox');
|
|
1460
|
+
const getText = async () => {
|
|
1461
|
+
return invoke('Editor.getText');
|
|
1387
1462
|
};
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
* @type {boolean}
|
|
1391
|
-
*/
|
|
1392
|
-
const isFirefox$1 = getIsFirefox();
|
|
1393
|
-
|
|
1394
|
-
const getNodePath$1 = () => {
|
|
1395
|
-
return invoke(/* Platform.getNodePath */'Platform.getNodePath');
|
|
1463
|
+
const rename$1 = async () => {
|
|
1464
|
+
await invoke('Editor.rename');
|
|
1396
1465
|
};
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
return getNodePath$1();
|
|
1466
|
+
const showHover = async () => {
|
|
1467
|
+
await invoke('Editor.showHover2');
|
|
1400
1468
|
};
|
|
1401
|
-
const
|
|
1402
|
-
|
|
1469
|
+
const openRename = async () => {
|
|
1470
|
+
await invoke('Editor.openRename');
|
|
1403
1471
|
};
|
|
1404
1472
|
|
|
1405
|
-
const
|
|
1473
|
+
const TestFrameWorkComponentEditor = {
|
|
1406
1474
|
__proto__: null,
|
|
1407
|
-
|
|
1408
|
-
|
|
1475
|
+
addAllMissingImports,
|
|
1476
|
+
closeColorPicker,
|
|
1477
|
+
closeCompletionDetails,
|
|
1478
|
+
copy,
|
|
1479
|
+
copyLineDown,
|
|
1480
|
+
copyLineUp,
|
|
1481
|
+
cursorCharacterLeft,
|
|
1482
|
+
cursorCharacterRight,
|
|
1483
|
+
cursorDown,
|
|
1484
|
+
cursorEnd,
|
|
1485
|
+
cursorHome,
|
|
1486
|
+
cursorUp,
|
|
1487
|
+
cursorWordLeft,
|
|
1488
|
+
cursorWordPartLeft,
|
|
1489
|
+
cursorWordPartRight,
|
|
1490
|
+
cursorWordRight,
|
|
1491
|
+
deleteAllLeft,
|
|
1492
|
+
deleteAllRight,
|
|
1493
|
+
executeTabCompletion,
|
|
1494
|
+
findAllImplementations,
|
|
1495
|
+
findAllReferences,
|
|
1496
|
+
format,
|
|
1497
|
+
getText,
|
|
1498
|
+
goToDefinition,
|
|
1499
|
+
goToTypeDefinition,
|
|
1500
|
+
insertLineBreak,
|
|
1501
|
+
invokeBraceCompletion,
|
|
1502
|
+
invokeTabCompletion,
|
|
1503
|
+
openColorPicker,
|
|
1504
|
+
openCompletion,
|
|
1505
|
+
openCompletionDetails,
|
|
1506
|
+
openContextMenu: openContextMenu$1,
|
|
1507
|
+
openEditorContextMenu,
|
|
1508
|
+
openFind,
|
|
1509
|
+
openFindWidget,
|
|
1510
|
+
openHover,
|
|
1511
|
+
openRename,
|
|
1512
|
+
openSourceActions,
|
|
1513
|
+
organizeImports,
|
|
1514
|
+
rename: rename$1,
|
|
1515
|
+
selectAll,
|
|
1516
|
+
setCursor,
|
|
1517
|
+
setDeltaY,
|
|
1518
|
+
setSelections,
|
|
1519
|
+
showHover,
|
|
1520
|
+
sortImports,
|
|
1521
|
+
sourceActionsSelectCurrent,
|
|
1522
|
+
toggleBlockComment,
|
|
1523
|
+
toggleCompletionDetails,
|
|
1524
|
+
toggleLineComment,
|
|
1525
|
+
type
|
|
1409
1526
|
};
|
|
1410
1527
|
|
|
1411
|
-
const
|
|
1412
|
-
await invoke('
|
|
1528
|
+
const openContextMenu = async index => {
|
|
1529
|
+
await invoke('Explorer.handleContextMenuKeyboard', index);
|
|
1413
1530
|
};
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
__proto__: null,
|
|
1417
|
-
show
|
|
1531
|
+
const focus$1 = async () => {
|
|
1532
|
+
await invoke('Explorer.focusIndex', -1);
|
|
1418
1533
|
};
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
const open$1 = async () => {
|
|
1423
|
-
await invoke('Viewlet.openWidget', QuickPick, 'everything');
|
|
1534
|
+
const focusNext$3 = async () => {
|
|
1535
|
+
await invoke('Explorer.focusNext');
|
|
1424
1536
|
};
|
|
1425
|
-
const
|
|
1426
|
-
await invoke('
|
|
1537
|
+
const focusIndex$2 = async index => {
|
|
1538
|
+
await invoke('Explorer.focusIndex', index);
|
|
1427
1539
|
};
|
|
1428
|
-
const
|
|
1429
|
-
await invoke('
|
|
1540
|
+
const clickCurrent = async () => {
|
|
1541
|
+
await invoke('Explorer.handleClickCurrent');
|
|
1430
1542
|
};
|
|
1431
|
-
const
|
|
1432
|
-
await invoke('
|
|
1543
|
+
const handleArrowLeft = async () => {
|
|
1544
|
+
await invoke('Explorer.handleArrowLeft');
|
|
1545
|
+
};
|
|
1546
|
+
const focusLast$1 = async () => {
|
|
1547
|
+
await invoke('Explorer.focusLast');
|
|
1433
1548
|
};
|
|
1434
|
-
const
|
|
1435
|
-
await invoke('
|
|
1549
|
+
const focusFirst$1 = async () => {
|
|
1550
|
+
await invoke('Explorer.focusFirst');
|
|
1436
1551
|
};
|
|
1437
|
-
const
|
|
1438
|
-
await invoke('
|
|
1552
|
+
const removeDirent = async () => {
|
|
1553
|
+
await invoke('Explorer.removeDirent');
|
|
1439
1554
|
};
|
|
1440
|
-
const
|
|
1441
|
-
await invoke('
|
|
1442
|
-
await invoke('QuickPick.handleInput', label, 0);
|
|
1443
|
-
await invoke('QuickPick.selectItem', label);
|
|
1555
|
+
const expandRecursively = async () => {
|
|
1556
|
+
await invoke('Explorer.expandRecursively');
|
|
1444
1557
|
};
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
__proto__: null,
|
|
1448
|
-
executeCommand,
|
|
1449
|
-
focusIndex: focusIndex$1,
|
|
1450
|
-
focusNext: focusNext$1,
|
|
1451
|
-
focusPrevious: focusPrevious$1,
|
|
1452
|
-
open: open$1,
|
|
1453
|
-
selectItem,
|
|
1454
|
-
setValue: setValue$1
|
|
1558
|
+
const newFile = async () => {
|
|
1559
|
+
await invoke('Explorer.newFile');
|
|
1455
1560
|
};
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
await invoke('Search.handleInput', value);
|
|
1561
|
+
const handleClick = async index => {
|
|
1562
|
+
await invoke('Explorer.handleClick', index);
|
|
1459
1563
|
};
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
__proto__: null,
|
|
1463
|
-
setValue
|
|
1564
|
+
const rename = async () => {
|
|
1565
|
+
await invoke('Explorer.rename');
|
|
1464
1566
|
};
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
return invoke('Preferences.update', settings);
|
|
1567
|
+
const cancelEdit = async () => {
|
|
1568
|
+
await invoke('Explorer.cancelEdit');
|
|
1468
1569
|
};
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
__proto__: null,
|
|
1472
|
-
update: update$1
|
|
1570
|
+
const acceptEdit = async () => {
|
|
1571
|
+
await invoke('Explorer.acceptEdit');
|
|
1473
1572
|
};
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
await invoke('SideBar.openViewlet', id);
|
|
1573
|
+
const updateEditingValue = async value => {
|
|
1574
|
+
await invoke('Explorer.updateEditingValue', value);
|
|
1477
1575
|
};
|
|
1478
|
-
const
|
|
1479
|
-
await invoke('
|
|
1576
|
+
const expandAll = async value => {
|
|
1577
|
+
await invoke('Explorer.expandAll', value);
|
|
1480
1578
|
};
|
|
1481
1579
|
|
|
1482
|
-
const
|
|
1580
|
+
const TestFrameWorkComponentExplorer = {
|
|
1483
1581
|
__proto__: null,
|
|
1484
|
-
|
|
1485
|
-
|
|
1582
|
+
acceptEdit,
|
|
1583
|
+
cancelEdit,
|
|
1584
|
+
clickCurrent,
|
|
1585
|
+
expandAll,
|
|
1586
|
+
expandRecursively,
|
|
1587
|
+
focus: focus$1,
|
|
1588
|
+
focusFirst: focusFirst$1,
|
|
1589
|
+
focusIndex: focusIndex$2,
|
|
1590
|
+
focusLast: focusLast$1,
|
|
1591
|
+
focusNext: focusNext$3,
|
|
1592
|
+
handleArrowLeft,
|
|
1593
|
+
handleClick,
|
|
1594
|
+
newFile,
|
|
1595
|
+
openContextMenu,
|
|
1596
|
+
removeDirent,
|
|
1597
|
+
rename,
|
|
1598
|
+
updateEditingValue
|
|
1486
1599
|
};
|
|
1487
1600
|
|
|
1488
|
-
const
|
|
1489
|
-
|
|
1601
|
+
const addWebExtension = async relativePath => {
|
|
1602
|
+
// TODO compute absolutePath
|
|
1603
|
+
const absolutePath = relativePath;
|
|
1604
|
+
await invoke('ExtensionMeta.addWebExtension', absolutePath);
|
|
1490
1605
|
};
|
|
1491
|
-
const
|
|
1492
|
-
|
|
1606
|
+
const addNodeExtension = async relativePath => {
|
|
1607
|
+
// TODO compute absolutePath
|
|
1608
|
+
const absolutePath = relativePath;
|
|
1609
|
+
await invoke('ExtensionMeta.addNodeExtension', absolutePath);
|
|
1493
1610
|
};
|
|
1494
1611
|
|
|
1495
|
-
const
|
|
1612
|
+
const TestFrameWorkComponentExtension = {
|
|
1496
1613
|
__proto__: null,
|
|
1497
|
-
|
|
1498
|
-
|
|
1614
|
+
addNodeExtension,
|
|
1615
|
+
addWebExtension
|
|
1499
1616
|
};
|
|
1500
1617
|
|
|
1501
|
-
const
|
|
1502
|
-
await invoke('StatusBar.updateStatusBarItems');
|
|
1503
|
-
};
|
|
1618
|
+
const Memfs = 'memfs';
|
|
1504
1619
|
|
|
1505
|
-
const
|
|
1506
|
-
__proto__: null,
|
|
1507
|
-
update
|
|
1508
|
-
};
|
|
1620
|
+
const Slash$1 = '/';
|
|
1509
1621
|
|
|
1510
|
-
const
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
await invoke('TitleBarMenuBar.focus');
|
|
1515
|
-
};
|
|
1516
|
-
const focusFirst = async () => {
|
|
1517
|
-
await invoke('TitleBarMenuBar.focusFirst');
|
|
1518
|
-
};
|
|
1519
|
-
const focusIndex = async index => {
|
|
1520
|
-
await invoke('TitleBarMenuBar.focusIndex', index);
|
|
1521
|
-
};
|
|
1522
|
-
const focusLast = async () => {
|
|
1523
|
-
await invoke('TitleBarMenuBar.focusLast');
|
|
1524
|
-
};
|
|
1525
|
-
const focusNext = async () => {
|
|
1526
|
-
await invoke('TitleBarMenuBar.focusNext');
|
|
1527
|
-
};
|
|
1528
|
-
const focusPrevious = async () => {
|
|
1529
|
-
await invoke('TitleBarMenuBar.focusPrevious');
|
|
1622
|
+
const Slash = Slash$1;
|
|
1623
|
+
|
|
1624
|
+
const writeFile = async (path, content) => {
|
|
1625
|
+
await invoke('FileSystem.writeFile', path, content);
|
|
1530
1626
|
};
|
|
1531
|
-
const
|
|
1532
|
-
await invoke('
|
|
1627
|
+
const mkdir = async path => {
|
|
1628
|
+
await invoke('FileSystem.mkdir', path);
|
|
1533
1629
|
};
|
|
1534
|
-
const
|
|
1535
|
-
|
|
1630
|
+
const getTmpDir = async ({
|
|
1631
|
+
scheme = Memfs
|
|
1632
|
+
} = {}) => {
|
|
1633
|
+
switch (scheme) {
|
|
1634
|
+
case Memfs:
|
|
1635
|
+
return 'memfs:///workspace';
|
|
1636
|
+
default:
|
|
1637
|
+
return invoke('PlatformPaths.getTmpDir');
|
|
1638
|
+
}
|
|
1536
1639
|
};
|
|
1537
|
-
const
|
|
1538
|
-
await invoke('
|
|
1640
|
+
const chmod = async (uri, permissions) => {
|
|
1641
|
+
await invoke('FileSystem.chmod', uri, permissions);
|
|
1539
1642
|
};
|
|
1540
|
-
const
|
|
1541
|
-
await
|
|
1643
|
+
const createExecutable = async content => {
|
|
1644
|
+
const tmpDir = await getTmpDir({
|
|
1645
|
+
scheme: 'file'
|
|
1646
|
+
});
|
|
1647
|
+
const nodePath = await invoke('PlatformPaths.getNodePath');
|
|
1648
|
+
const gitPath = `${tmpDir}/git`;
|
|
1649
|
+
await writeFile(gitPath, `#!${nodePath}
|
|
1650
|
+
${content}`);
|
|
1651
|
+
await chmod(gitPath, '755');
|
|
1652
|
+
return gitPath;
|
|
1542
1653
|
};
|
|
1543
|
-
const
|
|
1544
|
-
await invoke('
|
|
1654
|
+
const createExecutableFrom = async path => {
|
|
1655
|
+
const testPath = await invoke('PlatformPaths.getTestPath');
|
|
1656
|
+
const absolutePath = testPath + Slash + path;
|
|
1657
|
+
const content = await invoke('Ajax.getText', absolutePath);
|
|
1658
|
+
return createExecutable(content);
|
|
1545
1659
|
};
|
|
1546
|
-
|
|
1547
|
-
|
|
1660
|
+
|
|
1661
|
+
const TestFrameWorkComponentFileSystem = {
|
|
1662
|
+
__proto__: null,
|
|
1663
|
+
chmod,
|
|
1664
|
+
createExecutable,
|
|
1665
|
+
createExecutableFrom,
|
|
1666
|
+
getTmpDir,
|
|
1667
|
+
mkdir,
|
|
1668
|
+
writeFile
|
|
1548
1669
|
};
|
|
1549
|
-
|
|
1550
|
-
|
|
1670
|
+
|
|
1671
|
+
const focusNext$2 = async () => {
|
|
1672
|
+
await invoke('FindWidget.focusNext');
|
|
1551
1673
|
};
|
|
1552
|
-
const
|
|
1553
|
-
await invoke('
|
|
1674
|
+
const setValue$2 = async value => {
|
|
1675
|
+
await invoke('FindWidget.handleInput', value);
|
|
1554
1676
|
};
|
|
1555
|
-
|
|
1556
|
-
|
|
1677
|
+
|
|
1678
|
+
const TestFrameWorkComponentFindWidget = {
|
|
1679
|
+
__proto__: null,
|
|
1680
|
+
focusNext: focusNext$2,
|
|
1681
|
+
setValue: setValue$2
|
|
1557
1682
|
};
|
|
1558
|
-
|
|
1559
|
-
|
|
1683
|
+
|
|
1684
|
+
const setIconTheme = async id => {
|
|
1685
|
+
await invoke('IconTheme.setIconTheme', id);
|
|
1560
1686
|
};
|
|
1561
1687
|
|
|
1562
|
-
const
|
|
1688
|
+
const TestFrameWorkComponentIconTheme = {
|
|
1563
1689
|
__proto__: null,
|
|
1564
|
-
|
|
1565
|
-
focus,
|
|
1566
|
-
focusFirst,
|
|
1567
|
-
focusIndex,
|
|
1568
|
-
focusLast,
|
|
1569
|
-
focusNext,
|
|
1570
|
-
focusPrevious,
|
|
1571
|
-
handleKeyArrowDown,
|
|
1572
|
-
handleKeyArrowLeft,
|
|
1573
|
-
handleKeyArrowRight,
|
|
1574
|
-
handleKeyArrowUp,
|
|
1575
|
-
handleKeyEnd,
|
|
1576
|
-
handleKeyEscape,
|
|
1577
|
-
handleKeyHome,
|
|
1578
|
-
handleKeySpace,
|
|
1579
|
-
toggleIndex,
|
|
1580
|
-
toggleMenu
|
|
1690
|
+
setIconTheme
|
|
1581
1691
|
};
|
|
1582
1692
|
|
|
1583
|
-
const
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1693
|
+
const getKeyOptions = rawKey => {
|
|
1694
|
+
if (rawKey.includes('+')) {
|
|
1695
|
+
const parts = rawKey.split('+');
|
|
1696
|
+
let ctrlKey = false;
|
|
1697
|
+
let altKey = false;
|
|
1698
|
+
let key = '';
|
|
1699
|
+
for (const part of parts) {
|
|
1700
|
+
switch (part) {
|
|
1701
|
+
case 'Control':
|
|
1702
|
+
ctrlKey = true;
|
|
1703
|
+
break;
|
|
1704
|
+
case 'Space':
|
|
1705
|
+
key = ' ';
|
|
1706
|
+
break;
|
|
1707
|
+
case 'Alt':
|
|
1708
|
+
altKey = true;
|
|
1709
|
+
break;
|
|
1710
|
+
default:
|
|
1711
|
+
key = part;
|
|
1712
|
+
break;
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
return {
|
|
1716
|
+
key,
|
|
1717
|
+
ctrlKey,
|
|
1718
|
+
altKey
|
|
1719
|
+
};
|
|
1720
|
+
}
|
|
1588
1721
|
return {
|
|
1589
|
-
|
|
1590
|
-
|
|
1722
|
+
key: rawKey,
|
|
1723
|
+
ctrlKey: false,
|
|
1724
|
+
altKey: false
|
|
1591
1725
|
};
|
|
1592
1726
|
};
|
|
1593
1727
|
|
|
1594
|
-
const
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1728
|
+
const press = async key => {
|
|
1729
|
+
const keyOptions = getKeyOptions(key);
|
|
1730
|
+
const options = {
|
|
1731
|
+
cancelable: true,
|
|
1732
|
+
bubbles: true,
|
|
1733
|
+
...keyOptions
|
|
1734
|
+
};
|
|
1735
|
+
await invoke('TestFrameWork.performKeyBoardAction', 'press', options);
|
|
1598
1736
|
};
|
|
1599
1737
|
|
|
1600
|
-
const
|
|
1601
|
-
|
|
1738
|
+
const TestFrameWorkComponentKeyBoard = {
|
|
1739
|
+
__proto__: null,
|
|
1740
|
+
press
|
|
1602
1741
|
};
|
|
1603
|
-
|
|
1604
|
-
|
|
1742
|
+
|
|
1743
|
+
const openUri = async uri => {
|
|
1744
|
+
await invoke('Main.openUri', uri);
|
|
1605
1745
|
};
|
|
1606
|
-
const
|
|
1607
|
-
|
|
1608
|
-
return false;
|
|
1746
|
+
const splitRight = async () => {
|
|
1747
|
+
await invoke('Main.splitRight');
|
|
1609
1748
|
};
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
const firstEventPromise = new Promise(resolve => {
|
|
1616
|
-
port1.onmessage = resolve;
|
|
1617
|
-
});
|
|
1618
|
-
await sendPortToWebView(webViewId, port2);
|
|
1619
|
-
const firstEvent = await firstEventPromise;
|
|
1620
|
-
// @ts-ignore
|
|
1621
|
-
if (firstEvent.data !== 'ready') {
|
|
1622
|
-
throw new Error('unexpected first message');
|
|
1623
|
-
}
|
|
1624
|
-
const handleOtherMessage = async event => {
|
|
1625
|
-
// @ts-ignore
|
|
1626
|
-
await handleJsonRpcMessage(ipc, event.data, resolve, preparePrettyError$1, execute$1, logError$1, requiresSocket$1);
|
|
1627
|
-
};
|
|
1628
|
-
port1.onmessage = handleOtherMessage;
|
|
1629
|
-
const ipc = {
|
|
1630
|
-
send(message) {
|
|
1631
|
-
port1.postMessage(message);
|
|
1632
|
-
}
|
|
1633
|
-
};
|
|
1634
|
-
return ipc;
|
|
1749
|
+
|
|
1750
|
+
const TestFrameWorkComponentMain = {
|
|
1751
|
+
__proto__: null,
|
|
1752
|
+
openUri,
|
|
1753
|
+
splitRight
|
|
1635
1754
|
};
|
|
1636
1755
|
|
|
1637
|
-
const
|
|
1638
|
-
|
|
1639
|
-
// TODO
|
|
1640
|
-
// 1. create messagechannel
|
|
1641
|
-
// 2. send one message port to webview
|
|
1642
|
-
// 3. setup rpc connection and wait for webview to be ready
|
|
1643
|
-
// 4. send test commands like locator.toBeVisible to webview
|
|
1644
|
-
const webViewRpc = {
|
|
1645
|
-
invoke(method, ...params) {
|
|
1646
|
-
return invoke$1(ipc, method, ...params);
|
|
1647
|
-
}
|
|
1648
|
-
};
|
|
1649
|
-
return {
|
|
1650
|
-
locator(selector, options) {
|
|
1651
|
-
const baseLocator = create(selector, options);
|
|
1652
|
-
baseLocator.webView = webViewRpc;
|
|
1653
|
-
return baseLocator;
|
|
1654
|
-
},
|
|
1655
|
-
expect: expect$1
|
|
1656
|
-
};
|
|
1756
|
+
const open$2 = async id => {
|
|
1757
|
+
await invoke('Layout.showPanel', id);
|
|
1657
1758
|
};
|
|
1658
1759
|
|
|
1659
|
-
const
|
|
1760
|
+
const TestFrameWorkComponentPanel = {
|
|
1660
1761
|
__proto__: null,
|
|
1661
|
-
|
|
1762
|
+
open: open$2
|
|
1662
1763
|
};
|
|
1663
1764
|
|
|
1664
|
-
const
|
|
1665
|
-
|
|
1765
|
+
const getIsFirefox = () => {
|
|
1766
|
+
if (typeof navigator === 'undefined') {
|
|
1767
|
+
return false;
|
|
1768
|
+
}
|
|
1769
|
+
if (
|
|
1770
|
+
// @ts-expect-error
|
|
1771
|
+
navigator.userAgentData?.brands) {
|
|
1772
|
+
// @ts-expect-error
|
|
1773
|
+
return navigator.userAgentData.brands.includes('Firefox');
|
|
1774
|
+
}
|
|
1775
|
+
return navigator.userAgent.toLowerCase().includes('firefox');
|
|
1666
1776
|
};
|
|
1667
1777
|
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1778
|
+
/**
|
|
1779
|
+
* @type {boolean}
|
|
1780
|
+
*/
|
|
1781
|
+
const isFirefox$1 = getIsFirefox();
|
|
1782
|
+
|
|
1783
|
+
const getNodePath$1 = () => {
|
|
1784
|
+
return invoke(/* Platform.getNodePath */'Platform.getNodePath');
|
|
1671
1785
|
};
|
|
1672
1786
|
|
|
1673
|
-
const
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
ContextMenu: TestFrameWorkComponentContextMenu,
|
|
1679
|
-
Editor: TestFrameWorkComponentEditor,
|
|
1680
|
-
Explorer: TestFrameWorkComponentExplorer,
|
|
1681
|
-
Extension: TestFrameWorkComponentExtension,
|
|
1682
|
-
FileSystem: TestFrameWorkComponentFileSystem,
|
|
1683
|
-
FindWidget: TestFrameWorkComponentFindWidget,
|
|
1684
|
-
IconTheme: TestFrameWorkComponentIconTheme,
|
|
1685
|
-
KeyBoard: TestFrameWorkComponentKeyBoard,
|
|
1686
|
-
Main: TestFrameWorkComponentMain,
|
|
1687
|
-
Panel: TestFrameWorkComponentPanel,
|
|
1688
|
-
Platform: TestFrameWorkComponentPlatform,
|
|
1689
|
-
Problems: TestFrameWorkComponentProblems,
|
|
1690
|
-
QuickPick: TestFrameWorkComponentQuickPick,
|
|
1691
|
-
Search: TestFrameWorkComponentSearch,
|
|
1692
|
-
Settings: TestFrameWorkComponentSettings,
|
|
1693
|
-
SideBar: TestFrameWorkComponentSideBar,
|
|
1694
|
-
SourceControl: TestFrameWorkComponentSourceControl,
|
|
1695
|
-
StatusBar: TestFrameWorkComponentStatusBar,
|
|
1696
|
-
TitleBarMenuBar: TestFrameWorkComponentTitleBarMenuBar,
|
|
1697
|
-
WebView: TestFrameWorkComponentWebView,
|
|
1698
|
-
Workspace: TestFrameWorkComponentWorkspace
|
|
1787
|
+
const getNodePath = () => {
|
|
1788
|
+
return getNodePath$1();
|
|
1789
|
+
};
|
|
1790
|
+
const isFirefox = () => {
|
|
1791
|
+
return isFirefox$1;
|
|
1699
1792
|
};
|
|
1700
1793
|
|
|
1701
|
-
const
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
// TODO
|
|
1707
|
-
// 0. wait for page to be ready
|
|
1708
|
-
// 1. get script to import from renderer process (url or from html)
|
|
1709
|
-
const scriptUrl = href;
|
|
1710
|
-
// 2. import that script
|
|
1711
|
-
const module = await importTest(scriptUrl);
|
|
1712
|
-
if (module.mockRpc) {
|
|
1713
|
-
setMockRpc(module.mockRpc);
|
|
1714
|
-
}
|
|
1715
|
-
if (module.test) {
|
|
1716
|
-
if (module.skip) {
|
|
1717
|
-
await test.skip(module.name, () => {});
|
|
1718
|
-
} else {
|
|
1719
|
-
await executeTest(module.name, module.test, globals);
|
|
1720
|
-
}
|
|
1721
|
-
} else {
|
|
1722
|
-
const tests = getTests();
|
|
1723
|
-
for (const test of tests) {
|
|
1724
|
-
// @ts-ignore
|
|
1725
|
-
await executeTest(test.name, test.fn);
|
|
1726
|
-
}
|
|
1727
|
-
}
|
|
1728
|
-
// 3. if import fails, display error message
|
|
1794
|
+
const TestFrameWorkComponentPlatform = {
|
|
1795
|
+
__proto__: null,
|
|
1796
|
+
getNodePath,
|
|
1797
|
+
isFirefox
|
|
1798
|
+
};
|
|
1729
1799
|
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
// 6. if test succeeds, display success message
|
|
1800
|
+
const show = async () => {
|
|
1801
|
+
await invoke('Panel.selectIndex', 0);
|
|
1733
1802
|
};
|
|
1734
1803
|
|
|
1735
|
-
const
|
|
1736
|
-
|
|
1804
|
+
const TestFrameWorkComponentProblems = {
|
|
1805
|
+
__proto__: null,
|
|
1806
|
+
show
|
|
1737
1807
|
};
|
|
1738
1808
|
|
|
1739
|
-
const
|
|
1740
|
-
|
|
1809
|
+
const QuickPick = 'QuickPick';
|
|
1810
|
+
|
|
1811
|
+
const open$1 = async () => {
|
|
1812
|
+
await invoke('Viewlet.openWidget', QuickPick, 'everything');
|
|
1741
1813
|
};
|
|
1742
|
-
const
|
|
1743
|
-
|
|
1814
|
+
const setValue$1 = async value => {
|
|
1815
|
+
await invoke('QuickPick.handleInput', value, 0);
|
|
1744
1816
|
};
|
|
1745
|
-
const
|
|
1746
|
-
|
|
1817
|
+
const focusNext$1 = async () => {
|
|
1818
|
+
await invoke('QuickPick.focusNext');
|
|
1747
1819
|
};
|
|
1748
|
-
const
|
|
1749
|
-
|
|
1820
|
+
const focusIndex$1 = async index => {
|
|
1821
|
+
await invoke('QuickPick.focusIndex', index);
|
|
1822
|
+
};
|
|
1823
|
+
const focusPrevious$1 = async () => {
|
|
1824
|
+
await invoke('QuickPick.focusPrevious');
|
|
1825
|
+
};
|
|
1826
|
+
const selectItem = async label => {
|
|
1827
|
+
await invoke('QuickPick.selectItem', label);
|
|
1828
|
+
};
|
|
1829
|
+
const executeCommand = async label => {
|
|
1830
|
+
await invoke('QuickPick.showCommands');
|
|
1831
|
+
await invoke('QuickPick.handleInput', label, 0);
|
|
1832
|
+
await invoke('QuickPick.selectItem', label);
|
|
1750
1833
|
};
|
|
1751
1834
|
|
|
1752
|
-
const
|
|
1753
|
-
|
|
1835
|
+
const TestFrameWorkComponentQuickPick = {
|
|
1836
|
+
__proto__: null,
|
|
1837
|
+
executeCommand,
|
|
1838
|
+
focusIndex: focusIndex$1,
|
|
1839
|
+
focusNext: focusNext$1,
|
|
1840
|
+
focusPrevious: focusPrevious$1,
|
|
1841
|
+
open: open$1,
|
|
1842
|
+
selectItem,
|
|
1843
|
+
setValue: setValue$1
|
|
1754
1844
|
};
|
|
1755
1845
|
|
|
1756
|
-
const
|
|
1757
|
-
|
|
1758
|
-
const ReferencePort = 3;
|
|
1759
|
-
const ModuleWorkerAndMessagePort = 8;
|
|
1760
|
-
const Auto = () => {
|
|
1761
|
-
// @ts-ignore
|
|
1762
|
-
if (globalThis.acceptPort) {
|
|
1763
|
-
return MessagePort$1;
|
|
1764
|
-
}
|
|
1765
|
-
// @ts-ignore
|
|
1766
|
-
if (globalThis.acceptReferencePort) {
|
|
1767
|
-
return ReferencePort;
|
|
1768
|
-
}
|
|
1769
|
-
return ModuleWorkerAndMessagePort;
|
|
1846
|
+
const setValue = async value => {
|
|
1847
|
+
await invoke('Search.handleInput', value);
|
|
1770
1848
|
};
|
|
1771
1849
|
|
|
1772
|
-
const
|
|
1773
|
-
|
|
1850
|
+
const TestFrameWorkComponentSearch = {
|
|
1851
|
+
__proto__: null,
|
|
1852
|
+
setValue
|
|
1774
1853
|
};
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
}
|
|
1779
|
-
if (isTransferrable(value)) {
|
|
1780
|
-
transferrables.push(value);
|
|
1781
|
-
return;
|
|
1782
|
-
}
|
|
1783
|
-
if (Array.isArray(value)) {
|
|
1784
|
-
for (const item of value) {
|
|
1785
|
-
walkValue(item, transferrables, isTransferrable);
|
|
1786
|
-
}
|
|
1787
|
-
return;
|
|
1788
|
-
}
|
|
1789
|
-
if (typeof value === 'object') {
|
|
1790
|
-
for (const property of Object.values(value)) {
|
|
1791
|
-
walkValue(property, transferrables, isTransferrable);
|
|
1792
|
-
}
|
|
1793
|
-
return;
|
|
1794
|
-
}
|
|
1854
|
+
|
|
1855
|
+
const update$1 = settings => {
|
|
1856
|
+
return invoke('Preferences.update', settings);
|
|
1795
1857
|
};
|
|
1796
|
-
|
|
1797
|
-
|
|
1858
|
+
|
|
1859
|
+
const TestFrameWorkComponentSettings = {
|
|
1860
|
+
__proto__: null,
|
|
1861
|
+
update: update$1
|
|
1798
1862
|
};
|
|
1799
|
-
|
|
1800
|
-
|
|
1863
|
+
|
|
1864
|
+
const open = async id => {
|
|
1865
|
+
await invoke('SideBar.openViewlet', id);
|
|
1801
1866
|
};
|
|
1802
|
-
const
|
|
1803
|
-
|
|
1867
|
+
const hide = async () => {
|
|
1868
|
+
await invoke('Layout.hideSideBar');
|
|
1804
1869
|
};
|
|
1805
|
-
|
|
1806
|
-
|
|
1870
|
+
|
|
1871
|
+
const TestFrameWorkComponentSideBar = {
|
|
1872
|
+
__proto__: null,
|
|
1873
|
+
hide,
|
|
1874
|
+
open
|
|
1807
1875
|
};
|
|
1808
|
-
|
|
1809
|
-
|
|
1876
|
+
|
|
1877
|
+
const acceptInput = async () => {
|
|
1878
|
+
await invoke('Source Control.acceptInput');
|
|
1810
1879
|
};
|
|
1811
|
-
const
|
|
1812
|
-
|
|
1813
|
-
for (const fn of transferrables) {
|
|
1814
|
-
if (fn(value)) {
|
|
1815
|
-
return true;
|
|
1816
|
-
}
|
|
1817
|
-
}
|
|
1818
|
-
return false;
|
|
1880
|
+
const handleInput = async text => {
|
|
1881
|
+
await invoke('Source Control.handleInput', text);
|
|
1819
1882
|
};
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1883
|
+
|
|
1884
|
+
const TestFrameWorkComponentSourceControl = {
|
|
1885
|
+
__proto__: null,
|
|
1886
|
+
acceptInput,
|
|
1887
|
+
handleInput
|
|
1824
1888
|
};
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
that.dispatchEvent(new MessageEvent('message', {
|
|
1829
|
-
data
|
|
1830
|
-
}));
|
|
1831
|
-
};
|
|
1832
|
-
that.onMessage(handleMessage);
|
|
1833
|
-
const handleClose = event => {
|
|
1834
|
-
that.dispatchEvent(new Event('close'));
|
|
1835
|
-
};
|
|
1836
|
-
that.onClose(handleClose);
|
|
1889
|
+
|
|
1890
|
+
const update = async () => {
|
|
1891
|
+
await invoke('StatusBar.updateStatusBarItems');
|
|
1837
1892
|
};
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
attachEvents(this);
|
|
1843
|
-
}
|
|
1844
|
-
}
|
|
1845
|
-
const readyMessage = 'ready';
|
|
1846
|
-
const listen$4 = () => {
|
|
1847
|
-
// @ts-ignore
|
|
1848
|
-
if (typeof WorkerGlobalScope === 'undefined') {
|
|
1849
|
-
throw new TypeError('module is not in web worker scope');
|
|
1850
|
-
}
|
|
1851
|
-
return globalThis;
|
|
1893
|
+
|
|
1894
|
+
const TestFrameWorkComponentStatusBar = {
|
|
1895
|
+
__proto__: null,
|
|
1896
|
+
update
|
|
1852
1897
|
};
|
|
1853
|
-
|
|
1854
|
-
|
|
1898
|
+
|
|
1899
|
+
const closeMenu = async () => {
|
|
1900
|
+
await invoke('TitleBarMenuBar.closeMenu');
|
|
1855
1901
|
};
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
return getData$1(event);
|
|
1859
|
-
}
|
|
1860
|
-
send(message) {
|
|
1861
|
-
// @ts-ignore
|
|
1862
|
-
this._rawIpc.postMessage(message);
|
|
1863
|
-
}
|
|
1864
|
-
sendAndTransfer(message) {
|
|
1865
|
-
const transfer = getTransferrables(message);
|
|
1866
|
-
// @ts-ignore
|
|
1867
|
-
this._rawIpc.postMessage(message, transfer);
|
|
1868
|
-
}
|
|
1869
|
-
dispose() {
|
|
1870
|
-
// ignore
|
|
1871
|
-
}
|
|
1872
|
-
onClose(callback) {
|
|
1873
|
-
// ignore
|
|
1874
|
-
}
|
|
1875
|
-
onMessage(callback) {
|
|
1876
|
-
this._rawIpc.addEventListener('message', callback);
|
|
1877
|
-
}
|
|
1878
|
-
}
|
|
1879
|
-
const wrap$6 = global => {
|
|
1880
|
-
return new IpcChildWithModuleWorker(global);
|
|
1902
|
+
const focus = async () => {
|
|
1903
|
+
await invoke('TitleBarMenuBar.focus');
|
|
1881
1904
|
};
|
|
1882
|
-
const
|
|
1883
|
-
|
|
1884
|
-
listen: listen$4,
|
|
1885
|
-
signal: signal$3,
|
|
1886
|
-
wrap: wrap$6
|
|
1905
|
+
const focusFirst = async () => {
|
|
1906
|
+
await invoke('TitleBarMenuBar.focusFirst');
|
|
1887
1907
|
};
|
|
1888
|
-
const
|
|
1889
|
-
|
|
1890
|
-
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
1891
|
-
const NewLine$1 = '\n';
|
|
1892
|
-
const joinLines = lines => {
|
|
1893
|
-
return lines.join(NewLine$1);
|
|
1908
|
+
const focusIndex = async index => {
|
|
1909
|
+
await invoke('TitleBarMenuBar.focusIndex', index);
|
|
1894
1910
|
};
|
|
1895
|
-
const
|
|
1896
|
-
|
|
1911
|
+
const focusLast = async () => {
|
|
1912
|
+
await invoke('TitleBarMenuBar.focusLast');
|
|
1897
1913
|
};
|
|
1898
|
-
const
|
|
1899
|
-
|
|
1914
|
+
const focusNext = async () => {
|
|
1915
|
+
await invoke('TitleBarMenuBar.focusNext');
|
|
1900
1916
|
};
|
|
1901
|
-
const
|
|
1902
|
-
|
|
1903
|
-
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
1904
|
-
const message = lines[messageIndex];
|
|
1905
|
-
return {
|
|
1906
|
-
message,
|
|
1907
|
-
code: ERR_MODULE_NOT_FOUND
|
|
1908
|
-
};
|
|
1917
|
+
const focusPrevious = async () => {
|
|
1918
|
+
await invoke('TitleBarMenuBar.focusPrevious');
|
|
1909
1919
|
};
|
|
1910
|
-
const
|
|
1911
|
-
|
|
1912
|
-
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
1913
|
-
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
1914
|
-
const RE_AT = /^\s+at/;
|
|
1915
|
-
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
1916
|
-
const isUnhelpfulNativeModuleError = stderr => {
|
|
1917
|
-
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
1920
|
+
const handleKeyArrowDown = async () => {
|
|
1921
|
+
await invoke('TitleBarMenuBar.handleKeyArrowDown');
|
|
1918
1922
|
};
|
|
1919
|
-
const
|
|
1920
|
-
|
|
1923
|
+
const handleKeyArrowLeft = async () => {
|
|
1924
|
+
await invoke('TitleBarMenuBar.handleKeyArrowLeft');
|
|
1921
1925
|
};
|
|
1922
|
-
const
|
|
1923
|
-
|
|
1926
|
+
const handleKeyArrowRight = async () => {
|
|
1927
|
+
await invoke('TitleBarMenuBar.handleKeyArrowRight');
|
|
1924
1928
|
};
|
|
1925
|
-
const
|
|
1926
|
-
|
|
1927
|
-
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
1928
|
-
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
1929
|
-
const relevantLines = lines.slice(startIndex, endIndex);
|
|
1930
|
-
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
1931
|
-
return relevantMessage;
|
|
1929
|
+
const handleKeyArrowUp = async () => {
|
|
1930
|
+
await invoke('TitleBarMenuBar.handleKeyArrowUp');
|
|
1932
1931
|
};
|
|
1933
|
-
const
|
|
1934
|
-
|
|
1935
|
-
return {
|
|
1936
|
-
message: `Incompatible native node module: ${message}`,
|
|
1937
|
-
code: E_INCOMPATIBLE_NATIVE_MODULE
|
|
1938
|
-
};
|
|
1932
|
+
const handleKeyEnd = async () => {
|
|
1933
|
+
await invoke('TitleBarMenuBar.handleKeyEnd');
|
|
1939
1934
|
};
|
|
1940
|
-
const
|
|
1941
|
-
|
|
1942
|
-
return false;
|
|
1943
|
-
}
|
|
1944
|
-
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
1935
|
+
const handleKeyHome = async () => {
|
|
1936
|
+
await invoke('TitleBarMenuBar.handleKeyHome');
|
|
1945
1937
|
};
|
|
1946
|
-
const
|
|
1947
|
-
|
|
1948
|
-
message: `ES Modules are not supported in electron`,
|
|
1949
|
-
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
|
|
1950
|
-
};
|
|
1938
|
+
const handleKeySpace = async () => {
|
|
1939
|
+
await invoke('TitleBarMenuBar.handleKeySpace');
|
|
1951
1940
|
};
|
|
1952
|
-
const
|
|
1953
|
-
|
|
1954
|
-
return false;
|
|
1955
|
-
}
|
|
1956
|
-
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
1941
|
+
const handleKeyEscape = async () => {
|
|
1942
|
+
await invoke('TitleBarMenuBar.handleKeyEscape');
|
|
1957
1943
|
};
|
|
1958
|
-
const
|
|
1959
|
-
|
|
1944
|
+
const toggleIndex = async index => {
|
|
1945
|
+
await invoke('TitleBarMenuBar.toggleIndex', index);
|
|
1960
1946
|
};
|
|
1961
|
-
const
|
|
1962
|
-
|
|
1963
|
-
if (index === -1) {
|
|
1964
|
-
return {
|
|
1965
|
-
actualMessage: joinLines(lines),
|
|
1966
|
-
rest: []
|
|
1967
|
-
};
|
|
1968
|
-
}
|
|
1969
|
-
let lastIndex = index - 1;
|
|
1970
|
-
while (++lastIndex < lines.length) {
|
|
1971
|
-
if (!isNormalStackLine(lines[lastIndex])) {
|
|
1972
|
-
break;
|
|
1973
|
-
}
|
|
1974
|
-
}
|
|
1975
|
-
return {
|
|
1976
|
-
actualMessage: lines[index - 1],
|
|
1977
|
-
rest: lines.slice(index, lastIndex)
|
|
1978
|
-
};
|
|
1947
|
+
const toggleMenu = async () => {
|
|
1948
|
+
await invoke('TitleBarMenuBar.toggleMenu');
|
|
1979
1949
|
};
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1950
|
+
|
|
1951
|
+
const TestFrameWorkComponentTitleBarMenuBar = {
|
|
1952
|
+
__proto__: null,
|
|
1953
|
+
closeMenu,
|
|
1954
|
+
focus,
|
|
1955
|
+
focusFirst,
|
|
1956
|
+
focusIndex,
|
|
1957
|
+
focusLast,
|
|
1958
|
+
focusNext,
|
|
1959
|
+
focusPrevious,
|
|
1960
|
+
handleKeyArrowDown,
|
|
1961
|
+
handleKeyArrowLeft,
|
|
1962
|
+
handleKeyArrowRight,
|
|
1963
|
+
handleKeyArrowUp,
|
|
1964
|
+
handleKeyEnd,
|
|
1965
|
+
handleKeyEscape,
|
|
1966
|
+
handleKeyHome,
|
|
1967
|
+
handleKeySpace,
|
|
1968
|
+
toggleIndex,
|
|
1969
|
+
toggleMenu
|
|
1970
|
+
};
|
|
1971
|
+
|
|
1972
|
+
const getPortTuple = () => {
|
|
1991
1973
|
const {
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
} =
|
|
1974
|
+
port1,
|
|
1975
|
+
port2
|
|
1976
|
+
} = new MessageChannel();
|
|
1995
1977
|
return {
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
stack: rest
|
|
1978
|
+
port1,
|
|
1979
|
+
port2
|
|
1999
1980
|
};
|
|
2000
1981
|
};
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
1982
|
+
|
|
1983
|
+
const sendPortToWebView = async (webviewId, port) => {
|
|
1984
|
+
await invokeAndTransfer('Transferrable.transferToRendererProcess', webviewId, port);
|
|
1985
|
+
console.log('did send port to renderer process');
|
|
1986
|
+
};
|
|
1987
|
+
|
|
1988
|
+
const waitForFirstEventEvent = async port => {
|
|
1989
|
+
const {
|
|
1990
|
+
resolve,
|
|
1991
|
+
promise
|
|
1992
|
+
} = Promise.withResolvers();
|
|
1993
|
+
port.onmessage = resolve;
|
|
1994
|
+
const firstEvent = await promise;
|
|
1995
|
+
return firstEvent;
|
|
2009
1996
|
};
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
return `${message}: ${stringifiedError}`;
|
|
2014
|
-
}
|
|
2015
|
-
return stringifiedError;
|
|
1997
|
+
|
|
1998
|
+
const preparePrettyError = error => {
|
|
1999
|
+
return error;
|
|
2016
2000
|
};
|
|
2017
|
-
const
|
|
2018
|
-
|
|
2019
|
-
return string.indexOf(NewLine, startIndex);
|
|
2001
|
+
const logError = () => {
|
|
2002
|
+
// ignore
|
|
2020
2003
|
};
|
|
2021
|
-
const
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
}
|
|
2025
|
-
const parentNewLineIndex = getNewLineIndex(parent);
|
|
2026
|
-
const childNewLineIndex = getNewLineIndex(child);
|
|
2027
|
-
if (childNewLineIndex === -1) {
|
|
2028
|
-
return parent;
|
|
2029
|
-
}
|
|
2030
|
-
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
2031
|
-
const childRest = child.slice(childNewLineIndex);
|
|
2032
|
-
const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
|
|
2033
|
-
if (parentFirstLine.includes(childFirstLine)) {
|
|
2034
|
-
return parentFirstLine + childRest;
|
|
2035
|
-
}
|
|
2036
|
-
return child;
|
|
2004
|
+
const execute$1 = () => {};
|
|
2005
|
+
const requiresSocket = () => {
|
|
2006
|
+
return false;
|
|
2037
2007
|
};
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
this.codeFrame = error.codeFrame;
|
|
2049
|
-
}
|
|
2050
|
-
if (error.code) {
|
|
2051
|
-
// @ts-ignore
|
|
2052
|
-
this.code = error.code;
|
|
2053
|
-
}
|
|
2008
|
+
const createPortIpc = async webViewId => {
|
|
2009
|
+
const {
|
|
2010
|
+
port1,
|
|
2011
|
+
port2
|
|
2012
|
+
} = getPortTuple();
|
|
2013
|
+
const firstEventPromise = waitForFirstEventEvent(port1);
|
|
2014
|
+
await sendPortToWebView(webViewId, port2);
|
|
2015
|
+
const firstEvent = await firstEventPromise;
|
|
2016
|
+
if (firstEvent.data !== 'ready') {
|
|
2017
|
+
throw new Error('unexpected first message');
|
|
2054
2018
|
}
|
|
2055
|
-
|
|
2056
|
-
class IpcError extends VError {
|
|
2057
|
-
// @ts-ignore
|
|
2058
|
-
constructor(betterMessage, stdout = '', stderr = '') {
|
|
2059
|
-
if (stdout || stderr) {
|
|
2060
|
-
// @ts-ignore
|
|
2061
|
-
const {
|
|
2062
|
-
message,
|
|
2063
|
-
code,
|
|
2064
|
-
stack
|
|
2065
|
-
} = getHelpfulChildProcessError(stdout, stderr);
|
|
2066
|
-
const cause = new Error(message);
|
|
2067
|
-
// @ts-ignore
|
|
2068
|
-
cause.code = code;
|
|
2069
|
-
cause.stack = stack;
|
|
2070
|
-
super(cause, betterMessage);
|
|
2071
|
-
} else {
|
|
2072
|
-
super(betterMessage);
|
|
2073
|
-
}
|
|
2074
|
-
// @ts-ignore
|
|
2075
|
-
this.name = 'IpcError';
|
|
2076
|
-
// @ts-ignore
|
|
2077
|
-
this.stdout = stdout;
|
|
2019
|
+
const handleOtherMessage = async event => {
|
|
2078
2020
|
// @ts-ignore
|
|
2079
|
-
|
|
2080
|
-
}
|
|
2081
|
-
|
|
2082
|
-
const
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
}
|
|
2021
|
+
await handleJsonRpcMessage(ipc, event.data, resolve, preparePrettyError, execute$1, logError, requiresSocket);
|
|
2022
|
+
};
|
|
2023
|
+
port1.onmessage = handleOtherMessage;
|
|
2024
|
+
const ipc = {
|
|
2025
|
+
send(message) {
|
|
2026
|
+
port1.postMessage(message);
|
|
2027
|
+
}
|
|
2028
|
+
};
|
|
2029
|
+
return ipc;
|
|
2030
|
+
};
|
|
2031
|
+
|
|
2032
|
+
const fromId = async webViewId => {
|
|
2033
|
+
const ipc = await createPortIpc(webViewId);
|
|
2034
|
+
const webViewRpc = {
|
|
2035
|
+
invoke(method, ...params) {
|
|
2036
|
+
return invoke$1(ipc, method, ...params);
|
|
2037
|
+
}
|
|
2038
|
+
};
|
|
2087
2039
|
return {
|
|
2088
|
-
|
|
2089
|
-
|
|
2040
|
+
locator(selector, options) {
|
|
2041
|
+
const baseLocator = create(selector, options);
|
|
2042
|
+
baseLocator.webView = webViewRpc;
|
|
2043
|
+
return baseLocator;
|
|
2044
|
+
},
|
|
2045
|
+
expect: expect$1
|
|
2090
2046
|
};
|
|
2091
2047
|
};
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
} = withResolvers();
|
|
2097
|
-
port.addEventListener('message', resolve, {
|
|
2098
|
-
once: true
|
|
2099
|
-
});
|
|
2100
|
-
const event = await promise;
|
|
2101
|
-
// @ts-ignore
|
|
2102
|
-
return event.data;
|
|
2048
|
+
|
|
2049
|
+
const TestFrameWorkComponentWebView = {
|
|
2050
|
+
__proto__: null,
|
|
2051
|
+
fromId
|
|
2103
2052
|
};
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
const parentIpc = wrap$6(parentIpcRaw);
|
|
2108
|
-
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
2109
|
-
if (firstMessage.method !== 'initialize') {
|
|
2110
|
-
throw new IpcError('unexpected first message');
|
|
2111
|
-
}
|
|
2112
|
-
const type = firstMessage.params[0];
|
|
2113
|
-
if (type === 'message-port') {
|
|
2114
|
-
parentIpc.send({
|
|
2115
|
-
jsonrpc: '2.0',
|
|
2116
|
-
id: firstMessage.id,
|
|
2117
|
-
result: null
|
|
2118
|
-
});
|
|
2119
|
-
parentIpc.dispose();
|
|
2120
|
-
const port = firstMessage.params[1];
|
|
2121
|
-
return port;
|
|
2122
|
-
}
|
|
2123
|
-
return globalThis;
|
|
2053
|
+
|
|
2054
|
+
const setPath = async path => {
|
|
2055
|
+
await invoke('Workspace.setPath', path);
|
|
2124
2056
|
};
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
getData(event) {
|
|
2130
|
-
return getData$1(event);
|
|
2131
|
-
}
|
|
2132
|
-
send(message) {
|
|
2133
|
-
this._rawIpc.postMessage(message);
|
|
2134
|
-
}
|
|
2135
|
-
sendAndTransfer(message) {
|
|
2136
|
-
const transfer = getTransferrables(message);
|
|
2137
|
-
this._rawIpc.postMessage(message, transfer);
|
|
2138
|
-
}
|
|
2139
|
-
dispose() {
|
|
2140
|
-
if (this._rawIpc.close) {
|
|
2141
|
-
this._rawIpc.close();
|
|
2142
|
-
}
|
|
2143
|
-
}
|
|
2144
|
-
onClose(callback) {
|
|
2145
|
-
// ignore
|
|
2146
|
-
}
|
|
2147
|
-
onMessage(callback) {
|
|
2148
|
-
this._rawIpc.addEventListener('message', callback);
|
|
2149
|
-
this._rawIpc.start();
|
|
2150
|
-
}
|
|
2151
|
-
}
|
|
2152
|
-
const wrap$5 = port => {
|
|
2153
|
-
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
2057
|
+
|
|
2058
|
+
const TestFrameWorkComponentWorkspace = {
|
|
2059
|
+
__proto__: null,
|
|
2060
|
+
setPath
|
|
2154
2061
|
};
|
|
2155
|
-
|
|
2062
|
+
|
|
2063
|
+
const TestFrameWorkComponent = {
|
|
2156
2064
|
__proto__: null,
|
|
2157
|
-
|
|
2158
|
-
|
|
2065
|
+
ActivityBar: TestFrameworkComponentActivityBar,
|
|
2066
|
+
BaseUrl: TestFrameWorkComponentBaseUrl,
|
|
2067
|
+
Command: TestFrameWorkComponentCommand,
|
|
2068
|
+
ContextMenu: TestFrameWorkComponentContextMenu,
|
|
2069
|
+
Editor: TestFrameWorkComponentEditor,
|
|
2070
|
+
Explorer: TestFrameWorkComponentExplorer,
|
|
2071
|
+
Extension: TestFrameWorkComponentExtension,
|
|
2072
|
+
FileSystem: TestFrameWorkComponentFileSystem,
|
|
2073
|
+
FindWidget: TestFrameWorkComponentFindWidget,
|
|
2074
|
+
IconTheme: TestFrameWorkComponentIconTheme,
|
|
2075
|
+
KeyBoard: TestFrameWorkComponentKeyBoard,
|
|
2076
|
+
Main: TestFrameWorkComponentMain,
|
|
2077
|
+
Panel: TestFrameWorkComponentPanel,
|
|
2078
|
+
Platform: TestFrameWorkComponentPlatform,
|
|
2079
|
+
Problems: TestFrameWorkComponentProblems,
|
|
2080
|
+
QuickPick: TestFrameWorkComponentQuickPick,
|
|
2081
|
+
Search: TestFrameWorkComponentSearch,
|
|
2082
|
+
Settings: TestFrameWorkComponentSettings,
|
|
2083
|
+
SideBar: TestFrameWorkComponentSideBar,
|
|
2084
|
+
SourceControl: TestFrameWorkComponentSourceControl,
|
|
2085
|
+
StatusBar: TestFrameWorkComponentStatusBar,
|
|
2086
|
+
TitleBarMenuBar: TestFrameWorkComponentTitleBarMenuBar,
|
|
2087
|
+
WebView: TestFrameWorkComponentWebView,
|
|
2088
|
+
Workspace: TestFrameWorkComponentWorkspace
|
|
2159
2089
|
};
|
|
2160
2090
|
|
|
2161
|
-
const
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2091
|
+
const execute = async href => {
|
|
2092
|
+
const globals = {
|
|
2093
|
+
...TestFrameWorkComponent,
|
|
2094
|
+
...TestFrameWork
|
|
2095
|
+
};
|
|
2096
|
+
// TODO
|
|
2097
|
+
// 0. wait for page to be ready
|
|
2098
|
+
// 1. get script to import from renderer process (url or from html)
|
|
2099
|
+
const scriptUrl = href;
|
|
2100
|
+
// 2. import that script
|
|
2101
|
+
const module = await importTest(scriptUrl);
|
|
2102
|
+
if (module.mockRpc) {
|
|
2103
|
+
setMockRpc(module.mockRpc);
|
|
2104
|
+
}
|
|
2105
|
+
if (module.test) {
|
|
2106
|
+
if (module.skip) {
|
|
2107
|
+
await test.skip(module.name);
|
|
2108
|
+
} else {
|
|
2109
|
+
await executeTest(module.name, module.test, globals);
|
|
2110
|
+
}
|
|
2111
|
+
} else {
|
|
2112
|
+
const tests = getTests();
|
|
2113
|
+
for (const test of tests) {
|
|
2114
|
+
// @ts-ignore
|
|
2115
|
+
await executeTest(test.name, test.fn);
|
|
2116
|
+
}
|
|
2169
2117
|
}
|
|
2118
|
+
// 3. if import fails, display error message
|
|
2119
|
+
|
|
2120
|
+
// 4. run the test
|
|
2121
|
+
// 5. if test fails, display error message
|
|
2122
|
+
// 6. if test succeeds, display success message
|
|
2170
2123
|
};
|
|
2171
2124
|
|
|
2172
|
-
const
|
|
2173
|
-
|
|
2174
|
-
}) => {
|
|
2175
|
-
const module = await getModule(method);
|
|
2176
|
-
const rawIpc = await module.listen();
|
|
2177
|
-
if (module.signal) {
|
|
2178
|
-
module.signal(rawIpc);
|
|
2179
|
-
}
|
|
2180
|
-
const ipc = module.wrap(rawIpc);
|
|
2181
|
-
return ipc;
|
|
2125
|
+
const commandMap = {
|
|
2126
|
+
'Test.execute': execute
|
|
2182
2127
|
};
|
|
2183
2128
|
|
|
2184
2129
|
const listen = async () => {
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
method: Auto()
|
|
2130
|
+
const rpc = await WebWorkerRpcClient.create({
|
|
2131
|
+
commandMap: commandMap
|
|
2188
2132
|
});
|
|
2189
|
-
|
|
2190
|
-
listen$2(ipc);
|
|
2133
|
+
setRpc(rpc);
|
|
2191
2134
|
};
|
|
2192
2135
|
|
|
2193
2136
|
const main = async () => {
|