@lvce-editor/test-with-playwright-worker 22.5.0 → 22.6.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/workerMain.js +76 -46
  2. package/package.json +1 -1
@@ -213,7 +213,6 @@ const walkValue = (value, transferrables, isTransferrable) => {
213
213
  for (const property of Object.values(value)) {
214
214
  walkValue(property, transferrables, isTransferrable);
215
215
  }
216
- return;
217
216
  }
218
217
  };
219
218
  const getTransferrables = value => {
@@ -367,7 +366,14 @@ class IpcError extends VError {
367
366
  const cause = new Error(message);
368
367
  // @ts-ignore
369
368
  cause.code = code;
370
- cause.stack = stack;
369
+ if (stack) {
370
+ Object.defineProperty(cause, 'stack', {
371
+ configurable: true,
372
+ enumerable: false,
373
+ value: stack,
374
+ writable: true
375
+ });
376
+ }
371
377
  super(cause, betterMessage);
372
378
  } else {
373
379
  super(betterMessage);
@@ -522,8 +528,10 @@ const getCurrentStack = () => {
522
528
  const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
523
529
  return currentStack;
524
530
  };
525
- const getNewLineIndex = (string, startIndex = undefined) => {
526
- return string.indexOf(NewLine, startIndex);
531
+ const getNewLineIndex = (string, startIndex) => {
532
+ {
533
+ return string.indexOf(NewLine);
534
+ }
527
535
  };
528
536
  const getParentStack = error => {
529
537
  let parentStack = error.stack || error.data || error.message || '';
@@ -534,55 +542,77 @@ const getParentStack = error => {
534
542
  };
535
543
  const MethodNotFound = -32601;
536
544
  const Custom = -32001;
545
+ const restoreExistingError = (error, currentStack) => {
546
+ if (typeof error.stack === 'string') {
547
+ error.stack = error.stack + NewLine + currentStack;
548
+ }
549
+ return error;
550
+ };
551
+ const restoreMethodNotFoundError = (error, currentStack) => {
552
+ const restoredError = new JsonRpcError(error.message);
553
+ const parentStack = getParentStack(error);
554
+ restoredError.stack = parentStack + NewLine + currentStack;
555
+ return restoredError;
556
+ };
557
+ const restoreStackFromData = (restoredError, error, currentStack) => {
558
+ if (error.data.stack && error.data.type && error.message) {
559
+ restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
560
+ return;
561
+ }
562
+ if (error.data.stack) {
563
+ restoredError.stack = error.data.stack;
564
+ }
565
+ };
566
+ const applyDataProperties = (restoredError, error) => {
567
+ if (!error.data) {
568
+ return;
569
+ }
570
+ restoreStackFromData(restoredError, error, getCurrentStack());
571
+ if (error.data.codeFrame) {
572
+ // @ts-ignore
573
+ restoredError.codeFrame = error.data.codeFrame;
574
+ }
575
+ if (error.data.code) {
576
+ // @ts-ignore
577
+ restoredError.code = error.data.code;
578
+ }
579
+ if (error.data.type) {
580
+ // @ts-ignore
581
+ restoredError.name = error.data.type;
582
+ }
583
+ };
584
+ const applyDirectProperties = (restoredError, error) => {
585
+ if (error.stack) {
586
+ const lowerStack = restoredError.stack || '';
587
+ const indexNewLine = getNewLineIndex(lowerStack);
588
+ const parentStack = getParentStack(error);
589
+ // @ts-ignore
590
+ restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
591
+ }
592
+ if (error.codeFrame) {
593
+ // @ts-ignore
594
+ restoredError.codeFrame = error.codeFrame;
595
+ }
596
+ };
597
+ const restoreMessageError = (error, _currentStack) => {
598
+ const restoredError = constructError(error.message, error.type, error.name);
599
+ if (error.data) {
600
+ applyDataProperties(restoredError, error);
601
+ } else {
602
+ applyDirectProperties(restoredError, error);
603
+ }
604
+ return restoredError;
605
+ };
537
606
  const restoreJsonRpcError = error => {
538
607
  const currentStack = getCurrentStack();
539
608
  if (error && error instanceof Error) {
540
- if (typeof error.stack === 'string') {
541
- error.stack = error.stack + NewLine + currentStack;
542
- }
543
- return error;
609
+ return restoreExistingError(error, currentStack);
544
610
  }
545
611
  if (error && error.code && error.code === MethodNotFound) {
546
- const restoredError = new JsonRpcError(error.message);
547
- const parentStack = getParentStack(error);
548
- restoredError.stack = parentStack + NewLine + currentStack;
549
- return restoredError;
612
+ return restoreMethodNotFoundError(error, currentStack);
550
613
  }
551
614
  if (error && error.message) {
552
- const restoredError = constructError(error.message, error.type, error.name);
553
- if (error.data) {
554
- if (error.data.stack && error.data.type && error.message) {
555
- restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
556
- } else if (error.data.stack) {
557
- restoredError.stack = error.data.stack;
558
- }
559
- if (error.data.codeFrame) {
560
- // @ts-ignore
561
- restoredError.codeFrame = error.data.codeFrame;
562
- }
563
- if (error.data.code) {
564
- // @ts-ignore
565
- restoredError.code = error.data.code;
566
- }
567
- if (error.data.type) {
568
- // @ts-ignore
569
- restoredError.name = error.data.type;
570
- }
571
- } else {
572
- if (error.stack) {
573
- const lowerStack = restoredError.stack || '';
574
- // @ts-ignore
575
- const indexNewLine = getNewLineIndex(lowerStack);
576
- const parentStack = getParentStack(error);
577
- // @ts-ignore
578
- restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
579
- }
580
- if (error.codeFrame) {
581
- // @ts-ignore
582
- restoredError.codeFrame = error.codeFrame;
583
- }
584
- }
585
- return restoredError;
615
+ return restoreMessageError(error);
586
616
  }
587
617
  if (typeof error === 'string') {
588
618
  return new Error(`JsonRpc Error: ${error}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-with-playwright-worker",
3
- "version": "22.5.0",
3
+ "version": "22.6.0",
4
4
  "description": "Worker package for test-with-playwright",
5
5
  "repository": {
6
6
  "type": "git",