@lvce-editor/renderer-process 30.1.0 → 30.3.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/rendererProcessMain.js +73 -45
- package/package.json +1 -1
|
@@ -1381,6 +1381,10 @@ const removeProp = ($Element, key) => {
|
|
|
1381
1381
|
detachEvent($Element, eventName);
|
|
1382
1382
|
return;
|
|
1383
1383
|
}
|
|
1384
|
+
if ((key === 'height' || key === 'width') && $Element instanceof HTMLImageElement) {
|
|
1385
|
+
$Element.removeAttribute(key);
|
|
1386
|
+
return;
|
|
1387
|
+
}
|
|
1384
1388
|
if (pixelStyleProps.has(key)) {
|
|
1385
1389
|
$Element.style[key] = '';
|
|
1386
1390
|
return;
|
|
@@ -1835,7 +1839,7 @@ const showDirectoryPicker = options => {
|
|
|
1835
1839
|
};
|
|
1836
1840
|
const showFilePicker = options => {
|
|
1837
1841
|
// @ts-expect-error
|
|
1838
|
-
return window.
|
|
1842
|
+
return window.showOpenFilePicker(options);
|
|
1839
1843
|
};
|
|
1840
1844
|
const showSaveFilePicker = options => {
|
|
1841
1845
|
// @ts-expect-error
|
|
@@ -2816,8 +2820,10 @@ const getCurrentStack = () => {
|
|
|
2816
2820
|
const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
|
|
2817
2821
|
return currentStack;
|
|
2818
2822
|
};
|
|
2819
|
-
const getNewLineIndex = (string, startIndex
|
|
2820
|
-
|
|
2823
|
+
const getNewLineIndex = (string, startIndex) => {
|
|
2824
|
+
{
|
|
2825
|
+
return string.indexOf(NewLine);
|
|
2826
|
+
}
|
|
2821
2827
|
};
|
|
2822
2828
|
const getParentStack = error => {
|
|
2823
2829
|
let parentStack = error.stack || error.data || error.message || '';
|
|
@@ -2828,55 +2834,77 @@ const getParentStack = error => {
|
|
|
2828
2834
|
};
|
|
2829
2835
|
const MethodNotFound = -32601;
|
|
2830
2836
|
const Custom = -32001;
|
|
2837
|
+
const restoreExistingError = (error, currentStack) => {
|
|
2838
|
+
if (typeof error.stack === 'string') {
|
|
2839
|
+
error.stack = error.stack + NewLine + currentStack;
|
|
2840
|
+
}
|
|
2841
|
+
return error;
|
|
2842
|
+
};
|
|
2843
|
+
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
2844
|
+
const restoredError = new JsonRpcError(error.message);
|
|
2845
|
+
const parentStack = getParentStack(error);
|
|
2846
|
+
restoredError.stack = parentStack + NewLine + currentStack;
|
|
2847
|
+
return restoredError;
|
|
2848
|
+
};
|
|
2849
|
+
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
2850
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
2851
|
+
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
2852
|
+
return;
|
|
2853
|
+
}
|
|
2854
|
+
if (error.data.stack) {
|
|
2855
|
+
restoredError.stack = error.data.stack;
|
|
2856
|
+
}
|
|
2857
|
+
};
|
|
2858
|
+
const applyDataProperties = (restoredError, error) => {
|
|
2859
|
+
if (!error.data) {
|
|
2860
|
+
return;
|
|
2861
|
+
}
|
|
2862
|
+
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
2863
|
+
if (error.data.codeFrame) {
|
|
2864
|
+
// @ts-ignore
|
|
2865
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
2866
|
+
}
|
|
2867
|
+
if (error.data.code) {
|
|
2868
|
+
// @ts-ignore
|
|
2869
|
+
restoredError.code = error.data.code;
|
|
2870
|
+
}
|
|
2871
|
+
if (error.data.type) {
|
|
2872
|
+
// @ts-ignore
|
|
2873
|
+
restoredError.name = error.data.type;
|
|
2874
|
+
}
|
|
2875
|
+
};
|
|
2876
|
+
const applyDirectProperties = (restoredError, error) => {
|
|
2877
|
+
if (error.stack) {
|
|
2878
|
+
const lowerStack = restoredError.stack || '';
|
|
2879
|
+
const indexNewLine = getNewLineIndex(lowerStack);
|
|
2880
|
+
const parentStack = getParentStack(error);
|
|
2881
|
+
// @ts-ignore
|
|
2882
|
+
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
2883
|
+
}
|
|
2884
|
+
if (error.codeFrame) {
|
|
2885
|
+
// @ts-ignore
|
|
2886
|
+
restoredError.codeFrame = error.codeFrame;
|
|
2887
|
+
}
|
|
2888
|
+
};
|
|
2889
|
+
const restoreMessageError = (error, _currentStack) => {
|
|
2890
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
2891
|
+
if (error.data) {
|
|
2892
|
+
applyDataProperties(restoredError, error);
|
|
2893
|
+
} else {
|
|
2894
|
+
applyDirectProperties(restoredError, error);
|
|
2895
|
+
}
|
|
2896
|
+
return restoredError;
|
|
2897
|
+
};
|
|
2831
2898
|
const restoreJsonRpcError = error => {
|
|
2832
2899
|
const currentStack = getCurrentStack();
|
|
2833
2900
|
if (error && error instanceof Error) {
|
|
2834
|
-
|
|
2835
|
-
error.stack = error.stack + NewLine + currentStack;
|
|
2836
|
-
}
|
|
2837
|
-
return error;
|
|
2901
|
+
return restoreExistingError(error, currentStack);
|
|
2838
2902
|
}
|
|
2839
2903
|
if (error && error.code && error.code === MethodNotFound) {
|
|
2840
|
-
|
|
2841
|
-
const parentStack = getParentStack(error);
|
|
2842
|
-
restoredError.stack = parentStack + NewLine + currentStack;
|
|
2843
|
-
return restoredError;
|
|
2904
|
+
return restoreMethodNotFoundError(error, currentStack);
|
|
2844
2905
|
}
|
|
2845
2906
|
if (error && error.message) {
|
|
2846
|
-
|
|
2847
|
-
if (error.data) {
|
|
2848
|
-
if (error.data.stack && error.data.type && error.message) {
|
|
2849
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
2850
|
-
} else if (error.data.stack) {
|
|
2851
|
-
restoredError.stack = error.data.stack;
|
|
2852
|
-
}
|
|
2853
|
-
if (error.data.codeFrame) {
|
|
2854
|
-
// @ts-ignore
|
|
2855
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
2856
|
-
}
|
|
2857
|
-
if (error.data.code) {
|
|
2858
|
-
// @ts-ignore
|
|
2859
|
-
restoredError.code = error.data.code;
|
|
2860
|
-
}
|
|
2861
|
-
if (error.data.type) {
|
|
2862
|
-
// @ts-ignore
|
|
2863
|
-
restoredError.name = error.data.type;
|
|
2864
|
-
}
|
|
2865
|
-
} else {
|
|
2866
|
-
if (error.stack) {
|
|
2867
|
-
const lowerStack = restoredError.stack || '';
|
|
2868
|
-
// @ts-ignore
|
|
2869
|
-
const indexNewLine = getNewLineIndex(lowerStack);
|
|
2870
|
-
const parentStack = getParentStack(error);
|
|
2871
|
-
// @ts-ignore
|
|
2872
|
-
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
2873
|
-
}
|
|
2874
|
-
if (error.codeFrame) {
|
|
2875
|
-
// @ts-ignore
|
|
2876
|
-
restoredError.codeFrame = error.codeFrame;
|
|
2877
|
-
}
|
|
2878
|
-
}
|
|
2879
|
-
return restoredError;
|
|
2907
|
+
return restoreMessageError(error);
|
|
2880
2908
|
}
|
|
2881
2909
|
if (typeof error === 'string') {
|
|
2882
2910
|
return new Error(`JsonRpc Error: ${error}`);
|