@lvce-editor/main-process 6.11.1 → 6.12.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.
@@ -2784,10 +2784,12 @@ const get$4 = id => {
2784
2784
  const remove$2 = id => {
2785
2785
  delete callbacks[id];
2786
2786
  };
2787
- let id$1 = 0;
2788
- const create$3$1 = () => {
2789
- return ++id$1;
2790
- };
2787
+ const create$3$1 = (() => {
2788
+ let id = 0;
2789
+ return () => {
2790
+ return ++id;
2791
+ };
2792
+ })();
2791
2793
  const registerPromise$1 = () => {
2792
2794
  const id = create$3$1();
2793
2795
  const {
@@ -2861,7 +2863,10 @@ const constructError = (message, type, name) => {
2861
2863
  if (ErrorConstructor === Error) {
2862
2864
  const error = new Error(message);
2863
2865
  if (name && name !== 'VError') {
2864
- error.name = name;
2866
+ Object.defineProperty(error, 'name', {
2867
+ configurable: true,
2868
+ value: name
2869
+ });
2865
2870
  }
2866
2871
  return error;
2867
2872
  }
@@ -2892,31 +2897,45 @@ const getParentStack = error => {
2892
2897
  };
2893
2898
  const MethodNotFound = -32601;
2894
2899
  const Custom = -32001;
2900
+ const setStack = (error, stack) => {
2901
+ const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
2902
+ if (descriptor) {
2903
+ if (!descriptor.configurable && !descriptor.writable) {
2904
+ return;
2905
+ }
2906
+ if (!descriptor.configurable && descriptor.writable) {
2907
+ error.stack = stack;
2908
+ return;
2909
+ }
2910
+ }
2911
+ Object.defineProperty(error, 'stack', {
2912
+ configurable: true,
2913
+ value: stack,
2914
+ writable: true
2915
+ });
2916
+ };
2895
2917
  const restoreExistingError = (error, currentStack) => {
2896
2918
  if (typeof error.stack === 'string') {
2897
- error.stack = error.stack + NewLine + currentStack;
2919
+ setStack(error, `${error.stack}${NewLine}${currentStack}`);
2898
2920
  }
2899
2921
  return error;
2900
2922
  };
2901
2923
  const restoreMethodNotFoundError = (error, currentStack) => {
2902
2924
  const restoredError = new JsonRpcError(error.message);
2903
2925
  const parentStack = getParentStack(error);
2904
- restoredError.stack = parentStack + NewLine + currentStack;
2926
+ setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
2905
2927
  return restoredError;
2906
2928
  };
2907
2929
  const restoreStackFromData = (restoredError, error, currentStack) => {
2908
2930
  if (error.data.stack && error.data.type && error.message) {
2909
- restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
2931
+ setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
2910
2932
  return;
2911
2933
  }
2912
2934
  if (error.data.stack) {
2913
- restoredError.stack = error.data.stack;
2935
+ setStack(restoredError, error.data.stack);
2914
2936
  }
2915
2937
  };
2916
2938
  const applyDataProperties = (restoredError, error) => {
2917
- if (!error.data) {
2918
- return;
2919
- }
2920
2939
  restoreStackFromData(restoredError, error, getCurrentStack());
2921
2940
  if (error.data.codeFrame) {
2922
2941
  // @ts-ignore
@@ -2937,7 +2956,7 @@ const applyDirectProperties = (restoredError, error) => {
2937
2956
  const indexNewLine = getNewLineIndex(lowerStack);
2938
2957
  const parentStack = getParentStack(error);
2939
2958
  // @ts-ignore
2940
- restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
2959
+ setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
2941
2960
  }
2942
2961
  if (error.codeFrame) {
2943
2962
  // @ts-ignore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-process",
3
- "version": "6.11.1",
3
+ "version": "6.12.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "electron"