@lvce-editor/test-worker 1.14.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.
Files changed (2) hide show
  1. package/dist/testWorkerMain.js +1187 -1252
  2. package/package.json +1 -1
@@ -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
- let AssertionError$1 = class AssertionError extends Error {
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$1.callbacks[id] = fn;
6
+ state$2.callbacks[id] = fn;
74
7
  };
75
8
  const get = id => {
76
- return state$1.callbacks[id];
9
+ return state$2.callbacks[id];
77
10
  };
78
11
  const remove = id => {
79
- delete state$1.callbacks[id];
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 ++state$2.id;
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$1();
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, args) => {
116
- number(id);
33
+ const resolve = (id, response) => {
117
34
  const fn = get(id);
118
35
  if (!fn) {
119
- console.log(args);
36
+ console.log(response);
120
37
  warn(`callback ${id} may already be disposed`);
121
38
  return;
122
39
  }
123
- fn(args);
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 getType$2 = prettyError => {
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: getType$2(prettyError),
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
- const handleJsonRpcMessage = async (...args) => {
346
- let message;
347
- let ipc;
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 arg = args[0];
355
- message = arg.message;
356
- ipc = arg.ipc;
357
- execute = arg.execute;
358
- preparePrettyError = arg.preparePrettyError || defaultPreparePrettyError;
359
- logError = arg.logError || defaultLogError;
360
- requiresSocket = arg.requiresSocket || defaultRequiresSocket;
361
- resolve = arg.resolve || defaultResolve;
362
- } else {
363
- ipc = args[0];
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 invoke$1 = async (ipc, method, ...params) => {
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(message);
323
+ if (useSendAndTransfer && ipc.sendAndTransfer) {
324
+ ipc.sendAndTransfer(message);
325
+ } else {
326
+ ipc.send(message);
327
+ }
407
328
  const responseMessage = await promise;
408
- const result = unwrapJsonRpcResult(responseMessage);
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 invokeAndTransfer = (method, ...params) => {
417
- const ipc = get$1();
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 listen$2 = ipc => {
421
- set$1(ipc);
334
+ const invokeAndTransfer$1 = (ipc, method, ...params) => {
335
+ return invokeHelper(ipc, method, params, true);
422
336
  };
423
337
 
424
- const Rpc = {
425
- __proto__: null,
426
- invoke,
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
- const Fail = 'fail';
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 normalizeLine$1 = line => {
439
- if (line.startsWith('Error: ')) {
440
- return line.slice(`Error: `.length);
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 line;
350
+ return fn(...args);
446
351
  };
447
- const getCombinedMessage$1 = (error, message) => {
448
- const stringifiedError = normalizeLine$1(`${error}`);
449
- if (message) {
450
- return `${message}: ${stringifiedError}`;
451
- }
452
- return stringifiedError;
352
+
353
+ const getData$1 = event => {
354
+ return event.data;
453
355
  };
454
- const NewLine$2 = '\n';
455
- const getNewLineIndex$1 = (string, startIndex = undefined) => {
456
- return string.indexOf(NewLine$2, startIndex);
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
- const mergeStacks$1 = (parent, child) => {
459
- if (!child) {
460
- return parent;
369
+ class Ipc extends EventTarget {
370
+ constructor(rawIpc) {
371
+ super();
372
+ this._rawIpc = rawIpc;
373
+ attachEvents(this);
461
374
  }
462
- const parentNewLineIndex = getNewLineIndex$1(parent);
463
- const childNewLineIndex = getNewLineIndex$1(child);
464
- if (childNewLineIndex === -1) {
465
- return parent;
375
+ }
376
+ const readyMessage = 'ready';
377
+ const walkValue = (value, transferrables, isTransferrable) => {
378
+ if (!value) {
379
+ return;
466
380
  }
467
- const parentFirstLine = parent.slice(0, parentNewLineIndex);
468
- const childRest = child.slice(childNewLineIndex);
469
- const childFirstLine = normalizeLine$1(child.slice(0, childNewLineIndex));
470
- if (parentFirstLine.includes(childFirstLine)) {
471
- return parentFirstLine + childRest;
381
+ if (isTransferrable(value)) {
382
+ transferrables.push(value);
383
+ return;
472
384
  }
473
- return child;
474
- };
475
- let VError$1 = class VError extends Error {
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
- if (error.code) {
488
- // @ts-ignore
489
- this.code = error.code;
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
- const printError = error => {
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 stringifyError = error => {
502
- if (!error) {
503
- return `${error}`;
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
- if (error && error.message && error.constructor.name && error.constructor.name !== 'Error' && error.constructor.name !== 'VError') {
506
- return `${error}`;
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 `${error.message}`;
432
+ return globalThis;
509
433
  };
510
- const formatDuration = duration => {
511
- return duration.toFixed(2) + 'ms';
434
+ const signal$2 = global => {
435
+ global.postMessage(readyMessage);
512
436
  };
513
- const executeTest = async (name, fn, globals = {}) => {
514
- let _error;
515
- let _start;
516
- let _end;
517
- let _duration;
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
- error.message.startsWith('Failed to load command TestFrameWork.')) {
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$1)) {
536
- error = new VError$1(error, `Test failed: ${name}`);
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$1(error, 'Failed to import test');
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, fnName, options) => {
1132
+ const performAction = async (locator, action, options) => {
752
1133
  const {
753
1134
  invoke
754
1135
  } = locator.webView || Rpc;
755
- return invoke('TestFrameWork.performAction', locator, fnName, options);
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 (id, fn) => {
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);
@@ -1026,1176 +1407,730 @@ const organizeImports = async () => {
1026
1407
  await invoke('Editor.organizeImports');
1027
1408
  };
1028
1409
  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
- const showHover = async () => {
1086
- await invoke('Editor.showHover2');
1087
- };
1088
- const openRename = async () => {
1089
- await invoke('Editor.openRename');
1090
- };
1091
-
1092
- const TestFrameWorkComponentEditor = {
1093
- __proto__: null,
1094
- addAllMissingImports,
1095
- closeColorPicker,
1096
- closeCompletionDetails,
1097
- copy,
1098
- copyLineDown,
1099
- copyLineUp,
1100
- cursorCharacterLeft,
1101
- cursorCharacterRight,
1102
- cursorDown,
1103
- cursorEnd,
1104
- cursorHome,
1105
- cursorUp,
1106
- cursorWordLeft,
1107
- cursorWordPartLeft,
1108
- cursorWordPartRight,
1109
- cursorWordRight,
1110
- deleteAllLeft,
1111
- deleteAllRight,
1112
- executeTabCompletion,
1113
- findAllImplementations,
1114
- findAllReferences,
1115
- format,
1116
- getText,
1117
- goToDefinition,
1118
- goToTypeDefinition,
1119
- insertLineBreak,
1120
- invokeBraceCompletion,
1121
- invokeTabCompletion,
1122
- openColorPicker,
1123
- openCompletion,
1124
- openCompletionDetails,
1125
- openContextMenu: openContextMenu$1,
1126
- openEditorContextMenu,
1127
- openFind,
1128
- openFindWidget,
1129
- openHover,
1130
- openRename,
1131
- openSourceActions,
1132
- organizeImports,
1133
- rename: rename$1,
1134
- selectAll,
1135
- setCursor,
1136
- setDeltaY,
1137
- setSelections,
1138
- showHover,
1139
- sortImports,
1140
- sourceActionsSelectCurrent,
1141
- toggleBlockComment,
1142
- toggleCompletionDetails,
1143
- toggleLineComment,
1144
- type
1145
- };
1146
-
1147
- const openContextMenu = async index => {
1148
- await invoke('Explorer.handleContextMenuKeyboard', index);
1149
- };
1150
- const focus$1 = async () => {
1151
- await invoke('Explorer.focusIndex', -1);
1152
- };
1153
- const focusNext$3 = async () => {
1154
- await invoke('Explorer.focusNext');
1155
- };
1156
- const focusIndex$2 = async index => {
1157
- await invoke('Explorer.focusIndex', index);
1158
- };
1159
- const clickCurrent = async () => {
1160
- await invoke('Explorer.handleClickCurrent');
1161
- };
1162
- const handleArrowLeft = async () => {
1163
- await invoke('Explorer.handleArrowLeft');
1164
- };
1165
- const focusLast$1 = async () => {
1166
- await invoke('Explorer.focusLast');
1167
- };
1168
- const focusFirst$1 = async () => {
1169
- await invoke('Explorer.focusFirst');
1170
- };
1171
- const removeDirent = async () => {
1172
- await invoke('Explorer.removeDirent');
1173
- };
1174
- const expandRecursively = async () => {
1175
- await invoke('Explorer.expandRecursively');
1176
- };
1177
- const newFile = async () => {
1178
- await invoke('Explorer.newFile');
1179
- };
1180
- const handleClick = async index => {
1181
- await invoke('Explorer.handleClick', index);
1182
- };
1183
- const rename = async () => {
1184
- await invoke('Explorer.rename');
1185
- };
1186
- const cancelEdit = async () => {
1187
- await invoke('Explorer.cancelEdit');
1188
- };
1189
- const acceptEdit = async () => {
1190
- await invoke('Explorer.acceptEdit');
1191
- };
1192
- const updateEditingValue = async value => {
1193
- await invoke('Explorer.updateEditingValue', value);
1194
- };
1195
- const expandAll = async value => {
1196
- await invoke('Explorer.expandAll', value);
1197
- };
1198
-
1199
- const TestFrameWorkComponentExplorer = {
1200
- __proto__: null,
1201
- acceptEdit,
1202
- cancelEdit,
1203
- clickCurrent,
1204
- expandAll,
1205
- expandRecursively,
1206
- focus: focus$1,
1207
- focusFirst: focusFirst$1,
1208
- focusIndex: focusIndex$2,
1209
- focusLast: focusLast$1,
1210
- focusNext: focusNext$3,
1211
- handleArrowLeft,
1212
- handleClick,
1213
- newFile,
1214
- openContextMenu,
1215
- removeDirent,
1216
- rename,
1217
- updateEditingValue
1218
- };
1219
-
1220
- const addWebExtension = async relativePath => {
1221
- // TODO compute absolutePath
1222
- const absolutePath = relativePath;
1223
- await invoke('ExtensionMeta.addWebExtension', absolutePath);
1224
- };
1225
- const addNodeExtension = async relativePath => {
1226
- // TODO compute absolutePath
1227
- const absolutePath = relativePath;
1228
- await invoke('ExtensionMeta.addNodeExtension', absolutePath);
1229
- };
1230
-
1231
- const TestFrameWorkComponentExtension = {
1232
- __proto__: null,
1233
- addNodeExtension,
1234
- addWebExtension
1235
- };
1236
-
1237
- const Memfs = 'memfs';
1238
-
1239
- const Slash$1 = '/';
1240
-
1241
- const Slash = Slash$1;
1242
-
1243
- const writeFile = async (path, content) => {
1244
- await invoke('FileSystem.writeFile', path, content);
1245
- };
1246
- const mkdir = async path => {
1247
- await invoke('FileSystem.mkdir', path);
1248
- };
1249
- const getTmpDir = async ({
1250
- scheme = Memfs
1251
- } = {}) => {
1252
- switch (scheme) {
1253
- case Memfs:
1254
- return 'memfs:///workspace';
1255
- default:
1256
- return invoke('PlatformPaths.getTmpDir');
1257
- }
1258
- };
1259
- const chmod = async (uri, permissions) => {
1260
- await invoke('FileSystem.chmod', uri, permissions);
1410
+ await invoke('Editor.addAllMissingImports');
1261
1411
  };
1262
- const createExecutable = async content => {
1263
- const tmpDir = await getTmpDir({
1264
- scheme: 'file'
1265
- });
1266
- const nodePath = await invoke('PlatformPaths.getNodePath');
1267
- const gitPath = `${tmpDir}/git`;
1268
- await writeFile(gitPath, `#!${nodePath}
1269
- ${content}`);
1270
- await chmod(gitPath, '755');
1271
- return gitPath;
1412
+ const sortImports = async () => {
1413
+ await invoke('Editor.sortImports');
1272
1414
  };
1273
- const createExecutableFrom = async path => {
1274
- const testPath = await invoke('PlatformPaths.getTestPath');
1275
- const absolutePath = testPath + Slash + path;
1276
- const content = await invoke('Ajax.getText', absolutePath);
1277
- return createExecutable(content);
1415
+ const toggleLineComment = async () => {
1416
+ await invoke('Editor.toggleLineComment');
1278
1417
  };
1279
-
1280
- const TestFrameWorkComponentFileSystem = {
1281
- __proto__: null,
1282
- chmod,
1283
- createExecutable,
1284
- createExecutableFrom,
1285
- getTmpDir,
1286
- mkdir,
1287
- writeFile
1418
+ const toggleBlockComment = async () => {
1419
+ await invoke('Editor.toggleBlockComment');
1288
1420
  };
1289
-
1290
- const focusNext$2 = async () => {
1291
- await invoke('FindWidget.focusNext');
1421
+ const selectAll = async () => {
1422
+ await invoke('Editor.toggleBlockComment');
1292
1423
  };
1293
- const setValue$2 = async value => {
1294
- await invoke('FindWidget.handleInput', value);
1424
+ const openColorPicker = async () => {
1425
+ await invoke('Editor.openColorPicker');
1295
1426
  };
1296
-
1297
- const TestFrameWorkComponentFindWidget = {
1298
- __proto__: null,
1299
- focusNext: focusNext$2,
1300
- setValue: setValue$2
1427
+ const openFind = async () => {
1428
+ await invoke('Editor.openFind2');
1301
1429
  };
1302
-
1303
- const setIconTheme = async id => {
1304
- await invoke('IconTheme.setIconTheme', id);
1430
+ const deleteAllLeft = async () => {
1431
+ await invoke('Editor.deleteAllLeft');
1305
1432
  };
1306
-
1307
- const TestFrameWorkComponentIconTheme = {
1308
- __proto__: null,
1309
- setIconTheme
1433
+ const deleteAllRight = async () => {
1434
+ await invoke('Editor.deleteAllRight');
1310
1435
  };
1311
-
1312
- const getKeyOptions = rawKey => {
1313
- if (rawKey.includes('+')) {
1314
- const parts = rawKey.split('+');
1315
- let ctrlKey = false;
1316
- let altKey = false;
1317
- let key = '';
1318
- for (const part of parts) {
1319
- switch (part) {
1320
- case 'Control':
1321
- ctrlKey = true;
1322
- break;
1323
- case 'Space':
1324
- key = ' ';
1325
- break;
1326
- case 'Alt':
1327
- altKey = true;
1328
- break;
1329
- default:
1330
- key = part;
1331
- break;
1332
- }
1333
- }
1334
- return {
1335
- key,
1336
- ctrlKey,
1337
- altKey
1338
- };
1339
- }
1340
- return {
1341
- key: rawKey,
1342
- ctrlKey: false,
1343
- altKey: false
1344
- };
1436
+ const cursorWordPartLeft = async () => {
1437
+ await invoke('Editor.cursorWordPartLeft');
1345
1438
  };
1346
-
1347
- const press = async key => {
1348
- const keyOptions = getKeyOptions(key);
1349
- const options = {
1350
- cancelable: true,
1351
- bubbles: true,
1352
- ...keyOptions
1353
- };
1354
- await invoke('TestFrameWork.performKeyBoardAction', 'press', options);
1439
+ const cursorWordPartRight = async () => {
1440
+ await invoke('Editor.cursorWordPartRight');
1355
1441
  };
1356
-
1357
- const TestFrameWorkComponentKeyBoard = {
1358
- __proto__: null,
1359
- press
1442
+ const cursorEnd = async () => {
1443
+ await invoke('Editor.cursorEnd');
1360
1444
  };
1361
-
1362
- const openUri = async uri => {
1363
- await invoke('Main.openUri', uri);
1445
+ const cursorHome = async () => {
1446
+ await invoke('Editor.cursorHome');
1364
1447
  };
1365
- const splitRight = async () => {
1366
- await invoke('Main.splitRight');
1448
+ const copyLineUp = async () => {
1449
+ await invoke('Editor.copyLineUp');
1367
1450
  };
1368
-
1369
- const TestFrameWorkComponentMain = {
1370
- __proto__: null,
1371
- openUri,
1372
- splitRight
1451
+ const copy = async () => {
1452
+ await invoke('Editor.copy');
1373
1453
  };
1374
-
1375
- const open$2 = async id => {
1376
- await invoke('Layout.showPanel', id);
1454
+ const closeColorPicker = async () => {
1455
+ await invoke('Editor.closeColorPicker');
1377
1456
  };
1378
-
1379
- const TestFrameWorkComponentPanel = {
1380
- __proto__: null,
1381
- open: open$2
1457
+ const openContextMenu$1 = async () => {
1458
+ await invoke('Editor.contextMenu');
1382
1459
  };
1383
-
1384
- const getIsFirefox = () => {
1385
- if (typeof navigator === 'undefined') {
1386
- return false;
1387
- }
1388
- if (
1389
- // @ts-expect-error
1390
- navigator.userAgentData?.brands) {
1391
- // @ts-expect-error
1392
- return navigator.userAgentData.brands.includes('Firefox');
1393
- }
1394
- return navigator.userAgent.toLowerCase().includes('firefox');
1460
+ const getText = async () => {
1461
+ return invoke('Editor.getText');
1395
1462
  };
1396
-
1397
- /**
1398
- * @type {boolean}
1399
- */
1400
- const isFirefox$1 = getIsFirefox();
1401
-
1402
- const getNodePath$1 = () => {
1403
- return invoke(/* Platform.getNodePath */'Platform.getNodePath');
1463
+ const rename$1 = async () => {
1464
+ await invoke('Editor.rename');
1404
1465
  };
1405
-
1406
- const getNodePath = () => {
1407
- return getNodePath$1();
1466
+ const showHover = async () => {
1467
+ await invoke('Editor.showHover2');
1408
1468
  };
1409
- const isFirefox = () => {
1410
- return isFirefox$1;
1469
+ const openRename = async () => {
1470
+ await invoke('Editor.openRename');
1411
1471
  };
1412
1472
 
1413
- const TestFrameWorkComponentPlatform = {
1473
+ const TestFrameWorkComponentEditor = {
1414
1474
  __proto__: null,
1415
- getNodePath,
1416
- isFirefox
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
1417
1526
  };
1418
1527
 
1419
- const show = async () => {
1420
- await invoke('Panel.selectIndex', 0);
1528
+ const openContextMenu = async index => {
1529
+ await invoke('Explorer.handleContextMenuKeyboard', index);
1421
1530
  };
1422
-
1423
- const TestFrameWorkComponentProblems = {
1424
- __proto__: null,
1425
- show
1531
+ const focus$1 = async () => {
1532
+ await invoke('Explorer.focusIndex', -1);
1426
1533
  };
1427
-
1428
- const QuickPick = 'QuickPick';
1429
-
1430
- const open$1 = async () => {
1431
- await invoke('Viewlet.openWidget', QuickPick, 'everything');
1534
+ const focusNext$3 = async () => {
1535
+ await invoke('Explorer.focusNext');
1432
1536
  };
1433
- const setValue$1 = async value => {
1434
- await invoke('QuickPick.handleInput', value, 0);
1537
+ const focusIndex$2 = async index => {
1538
+ await invoke('Explorer.focusIndex', index);
1435
1539
  };
1436
- const focusNext$1 = async () => {
1437
- await invoke('QuickPick.focusNext');
1540
+ const clickCurrent = async () => {
1541
+ await invoke('Explorer.handleClickCurrent');
1438
1542
  };
1439
- const focusIndex$1 = async index => {
1440
- await invoke('QuickPick.focusIndex', index);
1543
+ const handleArrowLeft = async () => {
1544
+ await invoke('Explorer.handleArrowLeft');
1545
+ };
1546
+ const focusLast$1 = async () => {
1547
+ await invoke('Explorer.focusLast');
1441
1548
  };
1442
- const focusPrevious$1 = async () => {
1443
- await invoke('QuickPick.focusPrevious');
1549
+ const focusFirst$1 = async () => {
1550
+ await invoke('Explorer.focusFirst');
1444
1551
  };
1445
- const selectItem = async label => {
1446
- await invoke('QuickPick.selectItem', label);
1552
+ const removeDirent = async () => {
1553
+ await invoke('Explorer.removeDirent');
1447
1554
  };
1448
- const executeCommand = async label => {
1449
- await invoke('QuickPick.showCommands');
1450
- await invoke('QuickPick.handleInput', label, 0);
1451
- await invoke('QuickPick.selectItem', label);
1555
+ const expandRecursively = async () => {
1556
+ await invoke('Explorer.expandRecursively');
1452
1557
  };
1453
-
1454
- const TestFrameWorkComponentQuickPick = {
1455
- __proto__: null,
1456
- executeCommand,
1457
- focusIndex: focusIndex$1,
1458
- focusNext: focusNext$1,
1459
- focusPrevious: focusPrevious$1,
1460
- open: open$1,
1461
- selectItem,
1462
- setValue: setValue$1
1558
+ const newFile = async () => {
1559
+ await invoke('Explorer.newFile');
1463
1560
  };
1464
-
1465
- const setValue = async value => {
1466
- await invoke('Search.handleInput', value);
1561
+ const handleClick = async index => {
1562
+ await invoke('Explorer.handleClick', index);
1467
1563
  };
1468
-
1469
- const TestFrameWorkComponentSearch = {
1470
- __proto__: null,
1471
- setValue
1564
+ const rename = async () => {
1565
+ await invoke('Explorer.rename');
1472
1566
  };
1473
-
1474
- const update$1 = settings => {
1475
- return invoke('Preferences.update', settings);
1567
+ const cancelEdit = async () => {
1568
+ await invoke('Explorer.cancelEdit');
1476
1569
  };
1477
-
1478
- const TestFrameWorkComponentSettings = {
1479
- __proto__: null,
1480
- update: update$1
1570
+ const acceptEdit = async () => {
1571
+ await invoke('Explorer.acceptEdit');
1481
1572
  };
1482
-
1483
- const open = async id => {
1484
- await invoke('SideBar.openViewlet', id);
1573
+ const updateEditingValue = async value => {
1574
+ await invoke('Explorer.updateEditingValue', value);
1485
1575
  };
1486
- const hide = async () => {
1487
- await invoke('Layout.hideSideBar');
1576
+ const expandAll = async value => {
1577
+ await invoke('Explorer.expandAll', value);
1488
1578
  };
1489
1579
 
1490
- const TestFrameWorkComponentSideBar = {
1580
+ const TestFrameWorkComponentExplorer = {
1491
1581
  __proto__: null,
1492
- hide,
1493
- open
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
1494
1599
  };
1495
1600
 
1496
- const acceptInput = async () => {
1497
- await invoke('Source Control.acceptInput');
1601
+ const addWebExtension = async relativePath => {
1602
+ // TODO compute absolutePath
1603
+ const absolutePath = relativePath;
1604
+ await invoke('ExtensionMeta.addWebExtension', absolutePath);
1498
1605
  };
1499
- const handleInput = async text => {
1500
- await invoke('Source Control.handleInput', text);
1606
+ const addNodeExtension = async relativePath => {
1607
+ // TODO compute absolutePath
1608
+ const absolutePath = relativePath;
1609
+ await invoke('ExtensionMeta.addNodeExtension', absolutePath);
1501
1610
  };
1502
1611
 
1503
- const TestFrameWorkComponentSourceControl = {
1612
+ const TestFrameWorkComponentExtension = {
1504
1613
  __proto__: null,
1505
- acceptInput,
1506
- handleInput
1614
+ addNodeExtension,
1615
+ addWebExtension
1507
1616
  };
1508
1617
 
1509
- const update = async () => {
1510
- await invoke('StatusBar.updateStatusBarItems');
1511
- };
1618
+ const Memfs = 'memfs';
1512
1619
 
1513
- const TestFrameWorkComponentStatusBar = {
1514
- __proto__: null,
1515
- update
1516
- };
1620
+ const Slash$1 = '/';
1517
1621
 
1518
- const closeMenu = async () => {
1519
- await invoke('TitleBarMenuBar.closeMenu');
1520
- };
1521
- const focus = async () => {
1522
- await invoke('TitleBarMenuBar.focus');
1523
- };
1524
- const focusFirst = async () => {
1525
- await invoke('TitleBarMenuBar.focusFirst');
1526
- };
1527
- const focusIndex = async index => {
1528
- await invoke('TitleBarMenuBar.focusIndex', index);
1529
- };
1530
- const focusLast = async () => {
1531
- await invoke('TitleBarMenuBar.focusLast');
1532
- };
1533
- const focusNext = async () => {
1534
- await invoke('TitleBarMenuBar.focusNext');
1535
- };
1536
- const focusPrevious = async () => {
1537
- await invoke('TitleBarMenuBar.focusPrevious');
1622
+ const Slash = Slash$1;
1623
+
1624
+ const writeFile = async (path, content) => {
1625
+ await invoke('FileSystem.writeFile', path, content);
1538
1626
  };
1539
- const handleKeyArrowDown = async () => {
1540
- await invoke('TitleBarMenuBar.handleKeyArrowDown');
1627
+ const mkdir = async path => {
1628
+ await invoke('FileSystem.mkdir', path);
1541
1629
  };
1542
- const handleKeyArrowLeft = async () => {
1543
- await invoke('TitleBarMenuBar.handleKeyArrowLeft');
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
+ }
1544
1639
  };
1545
- const handleKeyArrowRight = async () => {
1546
- await invoke('TitleBarMenuBar.handleKeyArrowRight');
1640
+ const chmod = async (uri, permissions) => {
1641
+ await invoke('FileSystem.chmod', uri, permissions);
1547
1642
  };
1548
- const handleKeyArrowUp = async () => {
1549
- await invoke('TitleBarMenuBar.handleKeyArrowUp');
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;
1550
1653
  };
1551
- const handleKeyEnd = async () => {
1552
- await invoke('TitleBarMenuBar.handleKeyEnd');
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);
1553
1659
  };
1554
- const handleKeyHome = async () => {
1555
- await invoke('TitleBarMenuBar.handleKeyHome');
1660
+
1661
+ const TestFrameWorkComponentFileSystem = {
1662
+ __proto__: null,
1663
+ chmod,
1664
+ createExecutable,
1665
+ createExecutableFrom,
1666
+ getTmpDir,
1667
+ mkdir,
1668
+ writeFile
1556
1669
  };
1557
- const handleKeySpace = async () => {
1558
- await invoke('TitleBarMenuBar.handleKeySpace');
1670
+
1671
+ const focusNext$2 = async () => {
1672
+ await invoke('FindWidget.focusNext');
1559
1673
  };
1560
- const handleKeyEscape = async () => {
1561
- await invoke('TitleBarMenuBar.handleKeyEscape');
1674
+ const setValue$2 = async value => {
1675
+ await invoke('FindWidget.handleInput', value);
1562
1676
  };
1563
- const toggleIndex = async index => {
1564
- await invoke('TitleBarMenuBar.toggleIndex', index);
1677
+
1678
+ const TestFrameWorkComponentFindWidget = {
1679
+ __proto__: null,
1680
+ focusNext: focusNext$2,
1681
+ setValue: setValue$2
1565
1682
  };
1566
- const toggleMenu = async () => {
1567
- await invoke('TitleBarMenuBar.toggleMenu');
1683
+
1684
+ const setIconTheme = async id => {
1685
+ await invoke('IconTheme.setIconTheme', id);
1568
1686
  };
1569
1687
 
1570
- const TestFrameWorkComponentTitleBarMenuBar = {
1688
+ const TestFrameWorkComponentIconTheme = {
1571
1689
  __proto__: null,
1572
- closeMenu,
1573
- focus,
1574
- focusFirst,
1575
- focusIndex,
1576
- focusLast,
1577
- focusNext,
1578
- focusPrevious,
1579
- handleKeyArrowDown,
1580
- handleKeyArrowLeft,
1581
- handleKeyArrowRight,
1582
- handleKeyArrowUp,
1583
- handleKeyEnd,
1584
- handleKeyEscape,
1585
- handleKeyHome,
1586
- handleKeySpace,
1587
- toggleIndex,
1588
- toggleMenu
1690
+ setIconTheme
1589
1691
  };
1590
1692
 
1591
- const getPortTuple = () => {
1592
- const {
1593
- port1,
1594
- port2
1595
- } = new MessageChannel();
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
+ }
1596
1721
  return {
1597
- port1,
1598
- port2
1722
+ key: rawKey,
1723
+ ctrlKey: false,
1724
+ altKey: false
1599
1725
  };
1600
1726
  };
1601
1727
 
1602
- const sendPortToWebView = async (webviewId, port) => {
1603
- await invokeAndTransfer('Transferrable.transferToRendererProcess', webviewId, port);
1604
- console.log('did send port to renderer process');
1605
- // TODO ask renderer process to transfer the port to the webview
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);
1606
1736
  };
1607
1737
 
1608
- const preparePrettyError$1 = error => {
1609
- return error;
1738
+ const TestFrameWorkComponentKeyBoard = {
1739
+ __proto__: null,
1740
+ press
1610
1741
  };
1611
- const logError$1 = () => {
1612
- // ignore
1742
+
1743
+ const openUri = async uri => {
1744
+ await invoke('Main.openUri', uri);
1613
1745
  };
1614
- const execute$1 = () => {};
1615
- const requiresSocket$1 = () => {
1616
- return false;
1746
+ const splitRight = async () => {
1747
+ await invoke('Main.splitRight');
1617
1748
  };
1618
- const createPortIpc = async webViewId => {
1619
- const {
1620
- port1,
1621
- port2
1622
- } = getPortTuple();
1623
- const firstEventPromise = new Promise(resolve => {
1624
- port1.onmessage = resolve;
1625
- });
1626
- await sendPortToWebView(webViewId, port2);
1627
- const firstEvent = await firstEventPromise;
1628
- // @ts-ignore
1629
- if (firstEvent.data !== 'ready') {
1630
- throw new Error('unexpected first message');
1631
- }
1632
- const handleOtherMessage = async event => {
1633
- // @ts-ignore
1634
- await handleJsonRpcMessage(ipc, event.data, resolve, preparePrettyError$1, execute$1, logError$1, requiresSocket$1);
1635
- };
1636
- port1.onmessage = handleOtherMessage;
1637
- const ipc = {
1638
- send(message) {
1639
- port1.postMessage(message);
1640
- }
1641
- };
1642
- return ipc;
1749
+
1750
+ const TestFrameWorkComponentMain = {
1751
+ __proto__: null,
1752
+ openUri,
1753
+ splitRight
1643
1754
  };
1644
1755
 
1645
- const fromId = async webViewId => {
1646
- const ipc = await createPortIpc(webViewId);
1647
- // TODO
1648
- // 1. create messagechannel
1649
- // 2. send one message port to webview
1650
- // 3. setup rpc connection and wait for webview to be ready
1651
- // 4. send test commands like locator.toBeVisible to webview
1652
- const webViewRpc = {
1653
- invoke(method, ...params) {
1654
- return invoke$1(ipc, method, ...params);
1655
- }
1656
- };
1657
- return {
1658
- locator(selector, options) {
1659
- const baseLocator = create(selector, options);
1660
- baseLocator.webView = webViewRpc;
1661
- return baseLocator;
1662
- },
1663
- expect: expect$1
1664
- };
1756
+ const open$2 = async id => {
1757
+ await invoke('Layout.showPanel', id);
1665
1758
  };
1666
1759
 
1667
- const TestFrameWorkComponentWebView = {
1760
+ const TestFrameWorkComponentPanel = {
1668
1761
  __proto__: null,
1669
- fromId
1762
+ open: open$2
1670
1763
  };
1671
1764
 
1672
- const setPath = async path => {
1673
- await invoke('Workspace.setPath', path);
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');
1674
1776
  };
1675
1777
 
1676
- const TestFrameWorkComponentWorkspace = {
1677
- __proto__: null,
1678
- setPath
1778
+ /**
1779
+ * @type {boolean}
1780
+ */
1781
+ const isFirefox$1 = getIsFirefox();
1782
+
1783
+ const getNodePath$1 = () => {
1784
+ return invoke(/* Platform.getNodePath */'Platform.getNodePath');
1679
1785
  };
1680
1786
 
1681
- const TestFrameWorkComponent = {
1682
- __proto__: null,
1683
- ActivityBar: TestFrameworkComponentActivityBar,
1684
- BaseUrl: TestFrameWorkComponentBaseUrl,
1685
- Command: TestFrameWorkComponentCommand,
1686
- ContextMenu: TestFrameWorkComponentContextMenu,
1687
- Editor: TestFrameWorkComponentEditor,
1688
- Explorer: TestFrameWorkComponentExplorer,
1689
- Extension: TestFrameWorkComponentExtension,
1690
- FileSystem: TestFrameWorkComponentFileSystem,
1691
- FindWidget: TestFrameWorkComponentFindWidget,
1692
- IconTheme: TestFrameWorkComponentIconTheme,
1693
- KeyBoard: TestFrameWorkComponentKeyBoard,
1694
- Main: TestFrameWorkComponentMain,
1695
- Panel: TestFrameWorkComponentPanel,
1696
- Platform: TestFrameWorkComponentPlatform,
1697
- Problems: TestFrameWorkComponentProblems,
1698
- QuickPick: TestFrameWorkComponentQuickPick,
1699
- Search: TestFrameWorkComponentSearch,
1700
- Settings: TestFrameWorkComponentSettings,
1701
- SideBar: TestFrameWorkComponentSideBar,
1702
- SourceControl: TestFrameWorkComponentSourceControl,
1703
- StatusBar: TestFrameWorkComponentStatusBar,
1704
- TitleBarMenuBar: TestFrameWorkComponentTitleBarMenuBar,
1705
- WebView: TestFrameWorkComponentWebView,
1706
- Workspace: TestFrameWorkComponentWorkspace
1787
+ const getNodePath = () => {
1788
+ return getNodePath$1();
1789
+ };
1790
+ const isFirefox = () => {
1791
+ return isFirefox$1;
1707
1792
  };
1708
1793
 
1709
- const execute = async href => {
1710
- const globals = {
1711
- ...TestFrameWorkComponent,
1712
- ...TestFrameWork
1713
- };
1714
- // TODO
1715
- // 0. wait for page to be ready
1716
- // 1. get script to import from renderer process (url or from html)
1717
- const scriptUrl = href;
1718
- // 2. import that script
1719
- const module = await importTest(scriptUrl);
1720
- if (module.mockRpc) {
1721
- setMockRpc(module.mockRpc);
1722
- }
1723
- if (module.test) {
1724
- if (module.skip) {
1725
- await test.skip(module.name, () => {});
1726
- } else {
1727
- await executeTest(module.name, module.test, globals);
1728
- }
1729
- } else {
1730
- const tests = getTests();
1731
- for (const test of tests) {
1732
- // @ts-ignore
1733
- await executeTest(test.name, test.fn);
1734
- }
1735
- }
1736
- // 3. if import fails, display error message
1794
+ const TestFrameWorkComponentPlatform = {
1795
+ __proto__: null,
1796
+ getNodePath,
1797
+ isFirefox
1798
+ };
1737
1799
 
1738
- // 4. run the test
1739
- // 5. if test fails, display error message
1740
- // 6. if test succeeds, display success message
1800
+ const show = async () => {
1801
+ await invoke('Panel.selectIndex', 0);
1741
1802
  };
1742
1803
 
1743
- const commandMap = {
1744
- 'Test.execute': execute
1804
+ const TestFrameWorkComponentProblems = {
1805
+ __proto__: null,
1806
+ show
1745
1807
  };
1746
1808
 
1747
- const requiresSocket = () => {
1748
- return false;
1809
+ const QuickPick = 'QuickPick';
1810
+
1811
+ const open$1 = async () => {
1812
+ await invoke('Viewlet.openWidget', QuickPick, 'everything');
1749
1813
  };
1750
- const preparePrettyError = error => {
1751
- return error;
1814
+ const setValue$1 = async value => {
1815
+ await invoke('QuickPick.handleInput', value, 0);
1752
1816
  };
1753
- const logError = error => {
1754
- console.error(error);
1817
+ const focusNext$1 = async () => {
1818
+ await invoke('QuickPick.focusNext');
1755
1819
  };
1756
- const handleMessage = event => {
1757
- return handleJsonRpcMessage(event.target, event.data, execute$3, resolve, preparePrettyError, logError, requiresSocket);
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);
1758
1833
  };
1759
1834
 
1760
- const handleIpc = ipc => {
1761
- ipc.addEventListener('message', handleMessage);
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
1762
1844
  };
1763
1845
 
1764
- const MessagePort$1 = 1;
1765
- const ModuleWorker = 2;
1766
- const ReferencePort = 3;
1767
- const ModuleWorkerAndMessagePort = 8;
1768
- const Auto = () => {
1769
- // @ts-ignore
1770
- if (globalThis.acceptPort) {
1771
- return MessagePort$1;
1772
- }
1773
- // @ts-ignore
1774
- if (globalThis.acceptReferencePort) {
1775
- return ReferencePort;
1776
- }
1777
- return ModuleWorkerAndMessagePort;
1846
+ const setValue = async value => {
1847
+ await invoke('Search.handleInput', value);
1778
1848
  };
1779
1849
 
1780
- const getData$1 = event => {
1781
- return event.data;
1850
+ const TestFrameWorkComponentSearch = {
1851
+ __proto__: null,
1852
+ setValue
1782
1853
  };
1783
- const walkValue = (value, transferrables, isTransferrable) => {
1784
- if (!value) {
1785
- return;
1786
- }
1787
- if (isTransferrable(value)) {
1788
- transferrables.push(value);
1789
- return;
1790
- }
1791
- if (Array.isArray(value)) {
1792
- for (const item of value) {
1793
- walkValue(item, transferrables, isTransferrable);
1794
- }
1795
- return;
1796
- }
1797
- if (typeof value === 'object') {
1798
- for (const property of Object.values(value)) {
1799
- walkValue(property, transferrables, isTransferrable);
1800
- }
1801
- return;
1802
- }
1854
+
1855
+ const update$1 = settings => {
1856
+ return invoke('Preferences.update', settings);
1803
1857
  };
1804
- const isMessagePort = value => {
1805
- return value && value instanceof MessagePort;
1858
+
1859
+ const TestFrameWorkComponentSettings = {
1860
+ __proto__: null,
1861
+ update: update$1
1806
1862
  };
1807
- const isMessagePortMain = value => {
1808
- return value && value.constructor && value.constructor.name === 'MessagePortMain';
1863
+
1864
+ const open = async id => {
1865
+ await invoke('SideBar.openViewlet', id);
1809
1866
  };
1810
- const isOffscreenCanvas = value => {
1811
- return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
1867
+ const hide = async () => {
1868
+ await invoke('Layout.hideSideBar');
1812
1869
  };
1813
- const isInstanceOf = (value, constructorName) => {
1814
- return value?.constructor?.name === constructorName;
1870
+
1871
+ const TestFrameWorkComponentSideBar = {
1872
+ __proto__: null,
1873
+ hide,
1874
+ open
1815
1875
  };
1816
- const isSocket = value => {
1817
- return isInstanceOf(value, 'Socket');
1876
+
1877
+ const acceptInput = async () => {
1878
+ await invoke('Source Control.acceptInput');
1818
1879
  };
1819
- const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
1820
- const isTransferrable = value => {
1821
- for (const fn of transferrables) {
1822
- if (fn(value)) {
1823
- return true;
1824
- }
1825
- }
1826
- return false;
1880
+ const handleInput = async text => {
1881
+ await invoke('Source Control.handleInput', text);
1827
1882
  };
1828
- const getTransferrables = value => {
1829
- const transferrables = [];
1830
- walkValue(value, transferrables, isTransferrable);
1831
- return transferrables;
1883
+
1884
+ const TestFrameWorkComponentSourceControl = {
1885
+ __proto__: null,
1886
+ acceptInput,
1887
+ handleInput
1832
1888
  };
1833
- const attachEvents = that => {
1834
- const handleMessage = (...args) => {
1835
- const data = that.getData(...args);
1836
- that.dispatchEvent(new MessageEvent('message', {
1837
- data
1838
- }));
1839
- };
1840
- that.onMessage(handleMessage);
1841
- const handleClose = event => {
1842
- that.dispatchEvent(new Event('close'));
1843
- };
1844
- that.onClose(handleClose);
1889
+
1890
+ const update = async () => {
1891
+ await invoke('StatusBar.updateStatusBarItems');
1845
1892
  };
1846
- class Ipc extends EventTarget {
1847
- constructor(rawIpc) {
1848
- super();
1849
- this._rawIpc = rawIpc;
1850
- attachEvents(this);
1851
- }
1852
- }
1853
- const readyMessage = 'ready';
1854
- const listen$4 = () => {
1855
- // @ts-ignore
1856
- if (typeof WorkerGlobalScope === 'undefined') {
1857
- throw new TypeError('module is not in web worker scope');
1858
- }
1859
- return globalThis;
1893
+
1894
+ const TestFrameWorkComponentStatusBar = {
1895
+ __proto__: null,
1896
+ update
1860
1897
  };
1861
- const signal$3 = global => {
1862
- global.postMessage(readyMessage);
1898
+
1899
+ const closeMenu = async () => {
1900
+ await invoke('TitleBarMenuBar.closeMenu');
1863
1901
  };
1864
- class IpcChildWithModuleWorker extends Ipc {
1865
- getData(event) {
1866
- return getData$1(event);
1867
- }
1868
- send(message) {
1869
- // @ts-ignore
1870
- this._rawIpc.postMessage(message);
1871
- }
1872
- sendAndTransfer(message) {
1873
- const transfer = getTransferrables(message);
1874
- // @ts-ignore
1875
- this._rawIpc.postMessage(message, transfer);
1876
- }
1877
- dispose() {
1878
- // ignore
1879
- }
1880
- onClose(callback) {
1881
- // ignore
1882
- }
1883
- onMessage(callback) {
1884
- this._rawIpc.addEventListener('message', callback);
1885
- }
1886
- }
1887
- const wrap$6 = global => {
1888
- return new IpcChildWithModuleWorker(global);
1902
+ const focus = async () => {
1903
+ await invoke('TitleBarMenuBar.focus');
1889
1904
  };
1890
- const IpcChildWithModuleWorker$1 = {
1891
- __proto__: null,
1892
- listen: listen$4,
1893
- signal: signal$3,
1894
- wrap: wrap$6
1905
+ const focusFirst = async () => {
1906
+ await invoke('TitleBarMenuBar.focusFirst');
1895
1907
  };
1896
- const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
1897
- const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
1898
- const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
1899
- const NewLine$1 = '\n';
1900
- const joinLines = lines => {
1901
- return lines.join(NewLine$1);
1908
+ const focusIndex = async index => {
1909
+ await invoke('TitleBarMenuBar.focusIndex', index);
1902
1910
  };
1903
- const splitLines = lines => {
1904
- return lines.split(NewLine$1);
1911
+ const focusLast = async () => {
1912
+ await invoke('TitleBarMenuBar.focusLast');
1905
1913
  };
1906
- const isModuleNotFoundMessage = line => {
1907
- return line.includes('[ERR_MODULE_NOT_FOUND]');
1914
+ const focusNext = async () => {
1915
+ await invoke('TitleBarMenuBar.focusNext');
1908
1916
  };
1909
- const getModuleNotFoundError = stderr => {
1910
- const lines = splitLines(stderr);
1911
- const messageIndex = lines.findIndex(isModuleNotFoundMessage);
1912
- const message = lines[messageIndex];
1913
- return {
1914
- message,
1915
- code: ERR_MODULE_NOT_FOUND
1916
- };
1917
+ const focusPrevious = async () => {
1918
+ await invoke('TitleBarMenuBar.focusPrevious');
1917
1919
  };
1918
- const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
1919
- const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
1920
- const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
1921
- const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
1922
- const RE_AT = /^\s+at/;
1923
- const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
1924
- const isUnhelpfulNativeModuleError = stderr => {
1925
- return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
1920
+ const handleKeyArrowDown = async () => {
1921
+ await invoke('TitleBarMenuBar.handleKeyArrowDown');
1926
1922
  };
1927
- const isMessageCodeBlockStartIndex = line => {
1928
- return RE_MESSAGE_CODE_BLOCK_START.test(line);
1923
+ const handleKeyArrowLeft = async () => {
1924
+ await invoke('TitleBarMenuBar.handleKeyArrowLeft');
1929
1925
  };
1930
- const isMessageCodeBlockEndIndex = line => {
1931
- return RE_MESSAGE_CODE_BLOCK_END.test(line);
1926
+ const handleKeyArrowRight = async () => {
1927
+ await invoke('TitleBarMenuBar.handleKeyArrowRight');
1932
1928
  };
1933
- const getMessageCodeBlock = stderr => {
1934
- const lines = splitLines(stderr);
1935
- const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
1936
- const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
1937
- const relevantLines = lines.slice(startIndex, endIndex);
1938
- const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
1939
- return relevantMessage;
1929
+ const handleKeyArrowUp = async () => {
1930
+ await invoke('TitleBarMenuBar.handleKeyArrowUp');
1940
1931
  };
1941
- const getNativeModuleErrorMessage = stderr => {
1942
- const message = getMessageCodeBlock(stderr);
1943
- return {
1944
- message: `Incompatible native node module: ${message}`,
1945
- code: E_INCOMPATIBLE_NATIVE_MODULE
1946
- };
1932
+ const handleKeyEnd = async () => {
1933
+ await invoke('TitleBarMenuBar.handleKeyEnd');
1947
1934
  };
1948
- const isModulesSyntaxError = stderr => {
1949
- if (!stderr) {
1950
- return false;
1951
- }
1952
- return stderr.includes('SyntaxError: Cannot use import statement outside a module');
1935
+ const handleKeyHome = async () => {
1936
+ await invoke('TitleBarMenuBar.handleKeyHome');
1953
1937
  };
1954
- const getModuleSyntaxError = () => {
1955
- return {
1956
- message: `ES Modules are not supported in electron`,
1957
- code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
1958
- };
1938
+ const handleKeySpace = async () => {
1939
+ await invoke('TitleBarMenuBar.handleKeySpace');
1959
1940
  };
1960
- const isModuleNotFoundError = stderr => {
1961
- if (!stderr) {
1962
- return false;
1963
- }
1964
- return stderr.includes('ERR_MODULE_NOT_FOUND');
1941
+ const handleKeyEscape = async () => {
1942
+ await invoke('TitleBarMenuBar.handleKeyEscape');
1965
1943
  };
1966
- const isNormalStackLine = line => {
1967
- return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
1944
+ const toggleIndex = async index => {
1945
+ await invoke('TitleBarMenuBar.toggleIndex', index);
1968
1946
  };
1969
- const getDetails = lines => {
1970
- const index = lines.findIndex(isNormalStackLine);
1971
- if (index === -1) {
1972
- return {
1973
- actualMessage: joinLines(lines),
1974
- rest: []
1975
- };
1976
- }
1977
- let lastIndex = index - 1;
1978
- while (++lastIndex < lines.length) {
1979
- if (!isNormalStackLine(lines[lastIndex])) {
1980
- break;
1981
- }
1982
- }
1983
- return {
1984
- actualMessage: lines[index - 1],
1985
- rest: lines.slice(index, lastIndex)
1986
- };
1947
+ const toggleMenu = async () => {
1948
+ await invoke('TitleBarMenuBar.toggleMenu');
1987
1949
  };
1988
- const getHelpfulChildProcessError = (stdout, stderr) => {
1989
- if (isUnhelpfulNativeModuleError(stderr)) {
1990
- return getNativeModuleErrorMessage(stderr);
1991
- }
1992
- if (isModulesSyntaxError(stderr)) {
1993
- return getModuleSyntaxError();
1994
- }
1995
- if (isModuleNotFoundError(stderr)) {
1996
- return getModuleNotFoundError(stderr);
1997
- }
1998
- const lines = splitLines(stderr);
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 = () => {
1999
1973
  const {
2000
- actualMessage,
2001
- rest
2002
- } = getDetails(lines);
1974
+ port1,
1975
+ port2
1976
+ } = new MessageChannel();
2003
1977
  return {
2004
- message: `${actualMessage}`,
2005
- code: '',
2006
- stack: rest
1978
+ port1,
1979
+ port2
2007
1980
  };
2008
1981
  };
2009
- const normalizeLine = line => {
2010
- if (line.startsWith('Error: ')) {
2011
- return line.slice(`Error: `.length);
2012
- }
2013
- if (line.startsWith('VError: ')) {
2014
- return line.slice(`VError: `.length);
2015
- }
2016
- return line;
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;
2017
1996
  };
2018
- const getCombinedMessage = (error, message) => {
2019
- const stringifiedError = normalizeLine(`${error}`);
2020
- if (message) {
2021
- return `${message}: ${stringifiedError}`;
2022
- }
2023
- return stringifiedError;
1997
+
1998
+ const preparePrettyError = error => {
1999
+ return error;
2024
2000
  };
2025
- const NewLine = '\n';
2026
- const getNewLineIndex = (string, startIndex = undefined) => {
2027
- return string.indexOf(NewLine, startIndex);
2001
+ const logError = () => {
2002
+ // ignore
2028
2003
  };
2029
- const mergeStacks = (parent, child) => {
2030
- if (!child) {
2031
- return parent;
2032
- }
2033
- const parentNewLineIndex = getNewLineIndex(parent);
2034
- const childNewLineIndex = getNewLineIndex(child);
2035
- if (childNewLineIndex === -1) {
2036
- return parent;
2037
- }
2038
- const parentFirstLine = parent.slice(0, parentNewLineIndex);
2039
- const childRest = child.slice(childNewLineIndex);
2040
- const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
2041
- if (parentFirstLine.includes(childFirstLine)) {
2042
- return parentFirstLine + childRest;
2043
- }
2044
- return child;
2004
+ const execute$1 = () => {};
2005
+ const requiresSocket = () => {
2006
+ return false;
2045
2007
  };
2046
- class VError extends Error {
2047
- constructor(error, message) {
2048
- const combinedMessage = getCombinedMessage(error, message);
2049
- super(combinedMessage);
2050
- this.name = 'VError';
2051
- if (error instanceof Error) {
2052
- this.stack = mergeStacks(this.stack, error.stack);
2053
- }
2054
- if (error.codeFrame) {
2055
- // @ts-ignore
2056
- this.codeFrame = error.codeFrame;
2057
- }
2058
- if (error.code) {
2059
- // @ts-ignore
2060
- this.code = error.code;
2061
- }
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');
2062
2018
  }
2063
- }
2064
- class IpcError extends VError {
2065
- // @ts-ignore
2066
- constructor(betterMessage, stdout = '', stderr = '') {
2067
- if (stdout || stderr) {
2068
- // @ts-ignore
2069
- const {
2070
- message,
2071
- code,
2072
- stack
2073
- } = getHelpfulChildProcessError(stdout, stderr);
2074
- const cause = new Error(message);
2075
- // @ts-ignore
2076
- cause.code = code;
2077
- cause.stack = stack;
2078
- super(cause, betterMessage);
2079
- } else {
2080
- super(betterMessage);
2081
- }
2082
- // @ts-ignore
2083
- this.name = 'IpcError';
2084
- // @ts-ignore
2085
- this.stdout = stdout;
2019
+ const handleOtherMessage = async event => {
2086
2020
  // @ts-ignore
2087
- this.stderr = stderr;
2088
- }
2089
- }
2090
- const withResolvers = () => {
2091
- let _resolve;
2092
- const promise = new Promise(resolve => {
2093
- _resolve = resolve;
2094
- });
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
+ };
2095
2039
  return {
2096
- resolve: _resolve,
2097
- promise
2040
+ locator(selector, options) {
2041
+ const baseLocator = create(selector, options);
2042
+ baseLocator.webView = webViewRpc;
2043
+ return baseLocator;
2044
+ },
2045
+ expect: expect$1
2098
2046
  };
2099
2047
  };
2100
- const waitForFirstMessage = async port => {
2101
- const {
2102
- resolve,
2103
- promise
2104
- } = withResolvers();
2105
- port.addEventListener('message', resolve, {
2106
- once: true
2107
- });
2108
- const event = await promise;
2109
- // @ts-ignore
2110
- return event.data;
2048
+
2049
+ const TestFrameWorkComponentWebView = {
2050
+ __proto__: null,
2051
+ fromId
2111
2052
  };
2112
- const listen$3 = async () => {
2113
- const parentIpcRaw = listen$4();
2114
- signal$3(parentIpcRaw);
2115
- const parentIpc = wrap$6(parentIpcRaw);
2116
- const firstMessage = await waitForFirstMessage(parentIpc);
2117
- if (firstMessage.method !== 'initialize') {
2118
- throw new IpcError('unexpected first message');
2119
- }
2120
- const type = firstMessage.params[0];
2121
- if (type === 'message-port') {
2122
- parentIpc.send({
2123
- jsonrpc: '2.0',
2124
- id: firstMessage.id,
2125
- result: null
2126
- });
2127
- parentIpc.dispose();
2128
- const port = firstMessage.params[1];
2129
- return port;
2130
- }
2131
- return globalThis;
2053
+
2054
+ const setPath = async path => {
2055
+ await invoke('Workspace.setPath', path);
2132
2056
  };
2133
- class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
2134
- constructor(port) {
2135
- super(port);
2136
- }
2137
- getData(event) {
2138
- return getData$1(event);
2139
- }
2140
- send(message) {
2141
- this._rawIpc.postMessage(message);
2142
- }
2143
- sendAndTransfer(message) {
2144
- const transfer = getTransferrables(message);
2145
- this._rawIpc.postMessage(message, transfer);
2146
- }
2147
- dispose() {
2148
- if (this._rawIpc.close) {
2149
- this._rawIpc.close();
2150
- }
2151
- }
2152
- onClose(callback) {
2153
- // ignore
2154
- }
2155
- onMessage(callback) {
2156
- this._rawIpc.addEventListener('message', callback);
2157
- this._rawIpc.start();
2158
- }
2159
- }
2160
- const wrap$5 = port => {
2161
- return new IpcChildWithModuleWorkerAndMessagePort(port);
2057
+
2058
+ const TestFrameWorkComponentWorkspace = {
2059
+ __proto__: null,
2060
+ setPath
2162
2061
  };
2163
- const IpcChildWithModuleWorkerAndMessagePort$1 = {
2062
+
2063
+ const TestFrameWorkComponent = {
2164
2064
  __proto__: null,
2165
- listen: listen$3,
2166
- wrap: wrap$5
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
2167
2089
  };
2168
2090
 
2169
- const getModule = method => {
2170
- switch (method) {
2171
- case ModuleWorker:
2172
- return IpcChildWithModuleWorker$1;
2173
- case ModuleWorkerAndMessagePort:
2174
- return IpcChildWithModuleWorkerAndMessagePort$1;
2175
- default:
2176
- throw new Error('unexpected ipc type');
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
+ }
2177
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
2178
2123
  };
2179
2124
 
2180
- const listen$1 = async ({
2181
- method
2182
- }) => {
2183
- const module = await getModule(method);
2184
- const rawIpc = await module.listen();
2185
- if (module.signal) {
2186
- module.signal(rawIpc);
2187
- }
2188
- const ipc = module.wrap(rawIpc);
2189
- return ipc;
2125
+ const commandMap = {
2126
+ 'Test.execute': execute
2190
2127
  };
2191
2128
 
2192
2129
  const listen = async () => {
2193
- register(commandMap);
2194
- const ipc = await listen$1({
2195
- method: Auto()
2130
+ const rpc = await WebWorkerRpcClient.create({
2131
+ commandMap: commandMap
2196
2132
  });
2197
- handleIpc(ipc);
2198
- listen$2(ipc);
2133
+ setRpc(rpc);
2199
2134
  };
2200
2135
 
2201
2136
  const main = async () => {