@lvce-editor/file-system-worker 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fileSystemWorkerMain.js +38 -20
- package/package.json +1 -1
|
@@ -627,6 +627,16 @@ const constructError = (message, type, name) => {
|
|
|
627
627
|
}
|
|
628
628
|
return new ErrorConstructor(message);
|
|
629
629
|
};
|
|
630
|
+
const joinLines = lines => {
|
|
631
|
+
return lines.join(NewLine);
|
|
632
|
+
};
|
|
633
|
+
const splitLines = lines => {
|
|
634
|
+
return lines.split(NewLine);
|
|
635
|
+
};
|
|
636
|
+
const getCurrentStack = () => {
|
|
637
|
+
const currentStack = joinLines(splitLines(new Error().stack || '').slice(2));
|
|
638
|
+
return currentStack;
|
|
639
|
+
};
|
|
630
640
|
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
631
641
|
return string.indexOf(NewLine, startIndex);
|
|
632
642
|
};
|
|
@@ -637,19 +647,16 @@ const getParentStack = error => {
|
|
|
637
647
|
}
|
|
638
648
|
return parentStack;
|
|
639
649
|
};
|
|
640
|
-
const joinLines = lines => {
|
|
641
|
-
return lines.join(NewLine);
|
|
642
|
-
};
|
|
643
650
|
const MethodNotFound = -32601;
|
|
644
651
|
const Custom = -32001;
|
|
645
|
-
const splitLines = lines => {
|
|
646
|
-
return lines.split(NewLine);
|
|
647
|
-
};
|
|
648
652
|
const restoreJsonRpcError = error => {
|
|
653
|
+
const currentStack = getCurrentStack();
|
|
649
654
|
if (error && error instanceof Error) {
|
|
655
|
+
if (typeof error.stack === 'string') {
|
|
656
|
+
error.stack = error.stack + NewLine + currentStack;
|
|
657
|
+
}
|
|
650
658
|
return error;
|
|
651
659
|
}
|
|
652
|
-
const currentStack = joinLines(splitLines(new Error().stack || '').slice(1));
|
|
653
660
|
if (error && error.code && error.code === MethodNotFound) {
|
|
654
661
|
const restoredError = new JsonRpcError(error.message);
|
|
655
662
|
const parentStack = getParentStack(error);
|
|
@@ -730,6 +737,17 @@ const getErrorType = prettyError => {
|
|
|
730
737
|
}
|
|
731
738
|
return undefined;
|
|
732
739
|
};
|
|
740
|
+
const isAlreadyStack = line => {
|
|
741
|
+
return line.trim().startsWith('at ');
|
|
742
|
+
};
|
|
743
|
+
const getStack = prettyError => {
|
|
744
|
+
const stackString = prettyError.stack || '';
|
|
745
|
+
const newLineIndex = stackString.indexOf('\n');
|
|
746
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
747
|
+
return stackString.slice(newLineIndex + 1);
|
|
748
|
+
}
|
|
749
|
+
return stackString;
|
|
750
|
+
};
|
|
733
751
|
const getErrorProperty = (error, prettyError) => {
|
|
734
752
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
735
753
|
return {
|
|
@@ -742,7 +760,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
742
760
|
code: Custom,
|
|
743
761
|
message: prettyError.message,
|
|
744
762
|
data: {
|
|
745
|
-
stack: prettyError
|
|
763
|
+
stack: getStack(prettyError),
|
|
746
764
|
codeFrame: prettyError.codeFrame,
|
|
747
765
|
type: getErrorType(prettyError),
|
|
748
766
|
code: prettyError.code,
|
|
@@ -1002,7 +1020,7 @@ const WebWorkerRpcClient = {
|
|
|
1002
1020
|
};
|
|
1003
1021
|
|
|
1004
1022
|
const rpcs = Object.create(null);
|
|
1005
|
-
const set$
|
|
1023
|
+
const set$b = (id, rpc) => {
|
|
1006
1024
|
rpcs[id] = rpc;
|
|
1007
1025
|
};
|
|
1008
1026
|
const get = id => {
|
|
@@ -1026,7 +1044,7 @@ const create = rpcId => {
|
|
|
1026
1044
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1027
1045
|
},
|
|
1028
1046
|
set(rpc) {
|
|
1029
|
-
set$
|
|
1047
|
+
set$b(rpcId, rpc);
|
|
1030
1048
|
}
|
|
1031
1049
|
};
|
|
1032
1050
|
};
|
|
@@ -1037,21 +1055,21 @@ const RpcId = {
|
|
|
1037
1055
|
__proto__: null,
|
|
1038
1056
|
FileSystemWorker: FileSystemWorker$1};
|
|
1039
1057
|
const {
|
|
1040
|
-
|
|
1041
|
-
set: set$
|
|
1042
|
-
} = create(
|
|
1043
|
-
const
|
|
1058
|
+
invoke: invoke$6,
|
|
1059
|
+
set: set$6
|
|
1060
|
+
} = create(FileSystemProcess$1);
|
|
1061
|
+
const FileSystemProcess = {
|
|
1044
1062
|
__proto__: null,
|
|
1045
|
-
|
|
1046
|
-
set: set$
|
|
1063
|
+
invoke: invoke$6,
|
|
1064
|
+
set: set$6
|
|
1047
1065
|
};
|
|
1048
1066
|
const {
|
|
1049
|
-
|
|
1067
|
+
invokeAndTransfer: invokeAndTransfer$2,
|
|
1050
1068
|
set: set$2
|
|
1051
|
-
} = create(
|
|
1052
|
-
const
|
|
1069
|
+
} = create(RendererWorker$1);
|
|
1070
|
+
const RendererWorker = {
|
|
1053
1071
|
__proto__: null,
|
|
1054
|
-
|
|
1072
|
+
invokeAndTransfer: invokeAndTransfer$2,
|
|
1055
1073
|
set: set$2
|
|
1056
1074
|
};
|
|
1057
1075
|
|