@lvce-editor/iframe-worker 5.33.0 → 5.34.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.
@@ -497,7 +497,7 @@ const registerPromise = () => {
497
497
  promise
498
498
  };
499
499
  };
500
- const create$2 = (method, params) => {
500
+ const create$2$1 = (method, params) => {
501
501
  const {
502
502
  id,
503
503
  promise
@@ -564,6 +564,16 @@ const constructError = (message, type, name) => {
564
564
  }
565
565
  return new ErrorConstructor(message);
566
566
  };
567
+ const joinLines = lines => {
568
+ return lines.join(NewLine);
569
+ };
570
+ const splitLines = lines => {
571
+ return lines.split(NewLine);
572
+ };
573
+ const getCurrentStack = () => {
574
+ const currentStack = joinLines(splitLines(new Error().stack || '').slice(2));
575
+ return currentStack;
576
+ };
567
577
  const getNewLineIndex = (string, startIndex = undefined) => {
568
578
  return string.indexOf(NewLine, startIndex);
569
579
  };
@@ -574,19 +584,16 @@ const getParentStack = error => {
574
584
  }
575
585
  return parentStack;
576
586
  };
577
- const joinLines = lines => {
578
- return lines.join(NewLine);
579
- };
580
587
  const MethodNotFound = -32601;
581
588
  const Custom = -32001;
582
- const splitLines = lines => {
583
- return lines.split(NewLine);
584
- };
585
589
  const restoreJsonRpcError = error => {
590
+ const currentStack = getCurrentStack();
586
591
  if (error && error instanceof Error) {
592
+ if (typeof error.stack === 'string') {
593
+ error.stack = error.stack + NewLine + currentStack;
594
+ }
587
595
  return error;
588
596
  }
589
- const currentStack = joinLines(splitLines(new Error().stack || '').slice(1));
590
597
  if (error && error.code && error.code === MethodNotFound) {
591
598
  const restoredError = new JsonRpcError(error.message);
592
599
  const parentStack = getParentStack(error);
@@ -667,6 +674,17 @@ const getErrorType = prettyError => {
667
674
  }
668
675
  return undefined;
669
676
  };
677
+ const isAlreadyStack = line => {
678
+ return line.trim().startsWith('at ');
679
+ };
680
+ const getStack = prettyError => {
681
+ const stackString = prettyError.stack || '';
682
+ const newLineIndex = stackString.indexOf('\n');
683
+ if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
684
+ return stackString.slice(newLineIndex + 1);
685
+ }
686
+ return stackString;
687
+ };
670
688
  const getErrorProperty = (error, prettyError) => {
671
689
  if (error && error.code === E_COMMAND_NOT_FOUND) {
672
690
  return {
@@ -679,7 +697,7 @@ const getErrorProperty = (error, prettyError) => {
679
697
  code: Custom,
680
698
  message: prettyError.message,
681
699
  data: {
682
- stack: prettyError.stack,
700
+ stack: getStack(prettyError),
683
701
  codeFrame: prettyError.codeFrame,
684
702
  type: getErrorType(prettyError),
685
703
  code: prettyError.code,
@@ -687,7 +705,7 @@ const getErrorProperty = (error, prettyError) => {
687
705
  }
688
706
  };
689
707
  };
690
- const create$1$2 = (message, error) => {
708
+ const create$1$1 = (message, error) => {
691
709
  return {
692
710
  jsonrpc: Two,
693
711
  id: message.id,
@@ -698,7 +716,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
698
716
  const prettyError = preparePrettyError(error);
699
717
  logError(error, prettyError);
700
718
  const errorProperty = getErrorProperty(error, prettyError);
701
- return create$1$2(message, errorProperty);
719
+ return create$1$1(message, errorProperty);
702
720
  };
703
721
  const create$5 = (message, result) => {
704
722
  return {
@@ -789,7 +807,7 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
789
807
  const {
790
808
  message,
791
809
  promise
792
- } = create$2(method, params);
810
+ } = create$2$1(method, params);
793
811
  if (useSendAndTransfer && ipc.sendAndTransfer) {
794
812
  ipc.sendAndTransfer(message);
795
813
  } else {
@@ -876,7 +894,7 @@ const listen$1 = async (module, options) => {
876
894
  const ipc = module.wrap(rawIpc);
877
895
  return ipc;
878
896
  };
879
- const create$a = async ({
897
+ const create$9 = async ({
880
898
  commandMap,
881
899
  messagePort,
882
900
  isMessagePortOpen
@@ -894,9 +912,9 @@ const create$a = async ({
894
912
  };
895
913
  const MessagePortRpcParent = {
896
914
  __proto__: null,
897
- create: create$a
915
+ create: create$9
898
916
  };
899
- const create$1$1 = async ({
917
+ const create$2 = async ({
900
918
  commandMap
901
919
  }) => {
902
920
  // TODO create a commandMap per rpc instance
@@ -908,7 +926,7 @@ const create$1$1 = async ({
908
926
  };
909
927
  const WebWorkerRpcClient = {
910
928
  __proto__: null,
911
- create: create$1$1
929
+ create: create$2
912
930
  };
913
931
 
914
932
  const RendererWorker = 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/iframe-worker",
3
- "version": "5.33.0",
3
+ "version": "5.34.0",
4
4
  "description": "Web Worker to manage creation and lifecycle of iframes in Lvce Editor",
5
5
  "keywords": [
6
6
  "iframe"