@lvce-editor/main-process 2.10.0 → 2.11.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/mainProcessMain.js +50 -17
- package/package.json +1 -1
package/dist/mainProcessMain.js
CHANGED
|
@@ -2799,6 +2799,16 @@ const constructError = (message, type, name) => {
|
|
|
2799
2799
|
}
|
|
2800
2800
|
return new ErrorConstructor(message);
|
|
2801
2801
|
};
|
|
2802
|
+
const joinLines = lines => {
|
|
2803
|
+
return lines.join(NewLine);
|
|
2804
|
+
};
|
|
2805
|
+
const splitLines = lines => {
|
|
2806
|
+
return lines.split(NewLine);
|
|
2807
|
+
};
|
|
2808
|
+
const getCurrentStack = () => {
|
|
2809
|
+
const currentStack = joinLines(splitLines(new Error().stack || '').slice(2));
|
|
2810
|
+
return currentStack;
|
|
2811
|
+
};
|
|
2802
2812
|
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
2803
2813
|
return string.indexOf(NewLine, startIndex);
|
|
2804
2814
|
};
|
|
@@ -2809,19 +2819,16 @@ const getParentStack = error => {
|
|
|
2809
2819
|
}
|
|
2810
2820
|
return parentStack;
|
|
2811
2821
|
};
|
|
2812
|
-
const joinLines = lines => {
|
|
2813
|
-
return lines.join(NewLine);
|
|
2814
|
-
};
|
|
2815
2822
|
const MethodNotFound = -32601;
|
|
2816
2823
|
const Custom = -32001;
|
|
2817
|
-
const splitLines = lines => {
|
|
2818
|
-
return lines.split(NewLine);
|
|
2819
|
-
};
|
|
2820
2824
|
const restoreJsonRpcError = error => {
|
|
2825
|
+
const currentStack = getCurrentStack();
|
|
2821
2826
|
if (error && error instanceof Error) {
|
|
2827
|
+
if (typeof error.stack === 'string') {
|
|
2828
|
+
error.stack = error.stack + NewLine + currentStack;
|
|
2829
|
+
}
|
|
2822
2830
|
return error;
|
|
2823
2831
|
}
|
|
2824
|
-
const currentStack = joinLines(splitLines(new Error().stack || '').slice(1));
|
|
2825
2832
|
if (error && error.code && error.code === MethodNotFound) {
|
|
2826
2833
|
const restoredError = new JsonRpcError(error.message);
|
|
2827
2834
|
const parentStack = getParentStack(error);
|
|
@@ -2902,6 +2909,17 @@ const getErrorType = prettyError => {
|
|
|
2902
2909
|
}
|
|
2903
2910
|
return undefined;
|
|
2904
2911
|
};
|
|
2912
|
+
const isAlreadyStack = line => {
|
|
2913
|
+
return line.trim().startsWith('at ');
|
|
2914
|
+
};
|
|
2915
|
+
const getStack = prettyError => {
|
|
2916
|
+
const stackString = prettyError.stack || '';
|
|
2917
|
+
const newLineIndex = stackString.indexOf('\n');
|
|
2918
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
2919
|
+
return stackString.slice(newLineIndex + 1);
|
|
2920
|
+
}
|
|
2921
|
+
return stackString;
|
|
2922
|
+
};
|
|
2905
2923
|
const getErrorProperty = (error, prettyError) => {
|
|
2906
2924
|
if (error && error.code === E_COMMAND_NOT_FOUND$1) {
|
|
2907
2925
|
return {
|
|
@@ -2914,7 +2932,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
2914
2932
|
code: Custom,
|
|
2915
2933
|
message: prettyError.message,
|
|
2916
2934
|
data: {
|
|
2917
|
-
stack: prettyError
|
|
2935
|
+
stack: getStack(prettyError),
|
|
2918
2936
|
codeFrame: prettyError.codeFrame,
|
|
2919
2937
|
type: getErrorType(prettyError),
|
|
2920
2938
|
code: prettyError.code,
|
|
@@ -2922,18 +2940,18 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
2922
2940
|
}
|
|
2923
2941
|
};
|
|
2924
2942
|
};
|
|
2925
|
-
const create$1$1 = (
|
|
2943
|
+
const create$1$1 = (id, error) => {
|
|
2926
2944
|
return {
|
|
2927
2945
|
jsonrpc: Two,
|
|
2928
|
-
id
|
|
2946
|
+
id,
|
|
2929
2947
|
error
|
|
2930
2948
|
};
|
|
2931
2949
|
};
|
|
2932
|
-
const getErrorResponse = (
|
|
2950
|
+
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
2933
2951
|
const prettyError = preparePrettyError(error);
|
|
2934
2952
|
logError(error, prettyError);
|
|
2935
2953
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
2936
|
-
return create$1$1(
|
|
2954
|
+
return create$1$1(id, errorProperty);
|
|
2937
2955
|
};
|
|
2938
2956
|
const create$5 = (message, result) => {
|
|
2939
2957
|
return {
|
|
@@ -2946,12 +2964,27 @@ const getSuccessResponse = (message, result) => {
|
|
|
2946
2964
|
const resultProperty = result ?? null;
|
|
2947
2965
|
return create$5(message, resultProperty);
|
|
2948
2966
|
};
|
|
2967
|
+
const getErrorResponseSimple = (id, error) => {
|
|
2968
|
+
return {
|
|
2969
|
+
jsonrpc: Two,
|
|
2970
|
+
id,
|
|
2971
|
+
error: {
|
|
2972
|
+
code: Custom,
|
|
2973
|
+
// @ts-ignore
|
|
2974
|
+
message: error.message,
|
|
2975
|
+
data: error
|
|
2976
|
+
}
|
|
2977
|
+
};
|
|
2978
|
+
};
|
|
2949
2979
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
2950
2980
|
try {
|
|
2951
2981
|
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
2952
2982
|
return getSuccessResponse(message, result);
|
|
2953
2983
|
} catch (error) {
|
|
2954
|
-
|
|
2984
|
+
if (ipc.canUseSimpleErrorResponse) {
|
|
2985
|
+
return getErrorResponseSimple(message.id, error);
|
|
2986
|
+
}
|
|
2987
|
+
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
2955
2988
|
}
|
|
2956
2989
|
};
|
|
2957
2990
|
const defaultPreparePrettyError = error => {
|
|
@@ -3006,7 +3039,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
3006
3039
|
try {
|
|
3007
3040
|
ipc.send(response);
|
|
3008
3041
|
} catch (error) {
|
|
3009
|
-
const errorResponse = getErrorResponse(message, error, preparePrettyError, logError);
|
|
3042
|
+
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
3010
3043
|
ipc.send(errorResponse);
|
|
3011
3044
|
}
|
|
3012
3045
|
return;
|
|
@@ -5544,7 +5577,7 @@ const createPidMap = () => {
|
|
|
5544
5577
|
};
|
|
5545
5578
|
|
|
5546
5579
|
const rpcs = Object.create(null);
|
|
5547
|
-
const set$
|
|
5580
|
+
const set$d = (id, rpc) => {
|
|
5548
5581
|
rpcs[id] = rpc;
|
|
5549
5582
|
};
|
|
5550
5583
|
const get = id => {
|
|
@@ -5557,7 +5590,7 @@ const createUtilityProcessRpc = async options => {
|
|
|
5557
5590
|
...options
|
|
5558
5591
|
});
|
|
5559
5592
|
const rpcId = options.targetRpcId || options.rpcId || options.ipcId;
|
|
5560
|
-
set$
|
|
5593
|
+
set$d(rpcId, rpc);
|
|
5561
5594
|
};
|
|
5562
5595
|
|
|
5563
5596
|
const serializeDeskopCapturerSource = source => {
|
|
@@ -7008,7 +7041,7 @@ const handleElectronMessagePort = async (messagePort, rpcId) => {
|
|
|
7008
7041
|
requiresSocket: requiresSocket
|
|
7009
7042
|
});
|
|
7010
7043
|
if (rpcId) {
|
|
7011
|
-
set$
|
|
7044
|
+
set$d(rpcId, rpc);
|
|
7012
7045
|
}
|
|
7013
7046
|
};
|
|
7014
7047
|
|