@lvce-editor/extension-detail-view 7.15.0 → 7.16.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.
@@ -783,17 +783,14 @@ const diffTrees = (oldTree, newTree, patches, path) => {
783
783
  };
784
784
 
785
785
  const removeTrailingNavigationPatches = patches => {
786
- // Find the last non-navigation patch
787
- let lastNonNavigationIndex = -1;
788
- for (let i = patches.length - 1; i >= 0; i--) {
789
- const patch = patches[i];
786
+ while (patches.length > 0) {
787
+ const patch = patches.at(-1);
790
788
  if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
791
- lastNonNavigationIndex = i;
792
789
  break;
793
790
  }
791
+ patches.pop();
794
792
  }
795
- // Return patches up to and including the last non-navigation patch
796
- return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
793
+ return patches;
797
794
  };
798
795
 
799
796
  const diffTree = (oldNodes, newNodes) => {
@@ -2116,7 +2113,10 @@ const constructError = (message, type, name) => {
2116
2113
  if (ErrorConstructor === Error) {
2117
2114
  const error = new Error(message);
2118
2115
  if (name && name !== 'VError') {
2119
- error.name = name;
2116
+ Object.defineProperty(error, 'name', {
2117
+ configurable: true,
2118
+ value: name
2119
+ });
2120
2120
  }
2121
2121
  return error;
2122
2122
  }
@@ -2147,31 +2147,45 @@ const getParentStack = error => {
2147
2147
  };
2148
2148
  const MethodNotFound = -32601;
2149
2149
  const Custom = -32001;
2150
+ const setStack = (error, stack) => {
2151
+ const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
2152
+ if (descriptor) {
2153
+ if (!descriptor.configurable && !descriptor.writable) {
2154
+ return;
2155
+ }
2156
+ if (!descriptor.configurable && descriptor.writable) {
2157
+ error.stack = stack;
2158
+ return;
2159
+ }
2160
+ }
2161
+ Object.defineProperty(error, 'stack', {
2162
+ configurable: true,
2163
+ value: stack,
2164
+ writable: true
2165
+ });
2166
+ };
2150
2167
  const restoreExistingError = (error, currentStack) => {
2151
2168
  if (typeof error.stack === 'string') {
2152
- error.stack = error.stack + NewLine + currentStack;
2169
+ setStack(error, `${error.stack}${NewLine}${currentStack}`);
2153
2170
  }
2154
2171
  return error;
2155
2172
  };
2156
2173
  const restoreMethodNotFoundError = (error, currentStack) => {
2157
2174
  const restoredError = new JsonRpcError(error.message);
2158
2175
  const parentStack = getParentStack(error);
2159
- restoredError.stack = parentStack + NewLine + currentStack;
2176
+ setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
2160
2177
  return restoredError;
2161
2178
  };
2162
2179
  const restoreStackFromData = (restoredError, error, currentStack) => {
2163
2180
  if (error.data.stack && error.data.type && error.message) {
2164
- restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
2181
+ setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
2165
2182
  return;
2166
2183
  }
2167
2184
  if (error.data.stack) {
2168
- restoredError.stack = error.data.stack;
2185
+ setStack(restoredError, error.data.stack);
2169
2186
  }
2170
2187
  };
2171
2188
  const applyDataProperties = (restoredError, error) => {
2172
- if (!error.data) {
2173
- return;
2174
- }
2175
2189
  restoreStackFromData(restoredError, error, getCurrentStack());
2176
2190
  if (error.data.codeFrame) {
2177
2191
  // @ts-ignore
@@ -2192,7 +2206,7 @@ const applyDirectProperties = (restoredError, error) => {
2192
2206
  const indexNewLine = getNewLineIndex(lowerStack);
2193
2207
  const parentStack = getParentStack(error);
2194
2208
  // @ts-ignore
2195
- restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
2209
+ setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
2196
2210
  }
2197
2211
  if (error.codeFrame) {
2198
2212
  // @ts-ignore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "7.15.0",
3
+ "version": "7.16.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "repository": {
6
6
  "type": "git",