@lvce-editor/explorer-view 7.9.0 → 7.9.1

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.
@@ -856,7 +856,10 @@ const constructError = (message, type, name) => {
856
856
  if (ErrorConstructor === Error) {
857
857
  const error = new Error(message);
858
858
  if (name && name !== 'VError') {
859
- error.name = name;
859
+ Object.defineProperty(error, 'name', {
860
+ configurable: true,
861
+ value: name
862
+ });
860
863
  }
861
864
  return error;
862
865
  }
@@ -887,31 +890,45 @@ const getParentStack = error => {
887
890
  };
888
891
  const MethodNotFound = -32601;
889
892
  const Custom = -32001;
893
+ const setStack = (error, stack) => {
894
+ const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
895
+ if (descriptor) {
896
+ if (!descriptor.configurable && !descriptor.writable) {
897
+ return;
898
+ }
899
+ if (!descriptor.configurable && descriptor.writable) {
900
+ error.stack = stack;
901
+ return;
902
+ }
903
+ }
904
+ Object.defineProperty(error, 'stack', {
905
+ configurable: true,
906
+ value: stack,
907
+ writable: true
908
+ });
909
+ };
890
910
  const restoreExistingError = (error, currentStack) => {
891
911
  if (typeof error.stack === 'string') {
892
- error.stack = error.stack + NewLine + currentStack;
912
+ setStack(error, `${error.stack}${NewLine}${currentStack}`);
893
913
  }
894
914
  return error;
895
915
  };
896
916
  const restoreMethodNotFoundError = (error, currentStack) => {
897
917
  const restoredError = new JsonRpcError(error.message);
898
918
  const parentStack = getParentStack(error);
899
- restoredError.stack = parentStack + NewLine + currentStack;
919
+ setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
900
920
  return restoredError;
901
921
  };
902
922
  const restoreStackFromData = (restoredError, error, currentStack) => {
903
923
  if (error.data.stack && error.data.type && error.message) {
904
- restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
924
+ setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
905
925
  return;
906
926
  }
907
927
  if (error.data.stack) {
908
- restoredError.stack = error.data.stack;
928
+ setStack(restoredError, error.data.stack);
909
929
  }
910
930
  };
911
931
  const applyDataProperties = (restoredError, error) => {
912
- if (!error.data) {
913
- return;
914
- }
915
932
  restoreStackFromData(restoredError, error, getCurrentStack());
916
933
  if (error.data.codeFrame) {
917
934
  // @ts-ignore
@@ -932,7 +949,7 @@ const applyDirectProperties = (restoredError, error) => {
932
949
  const indexNewLine = getNewLineIndex(lowerStack);
933
950
  const parentStack = getParentStack(error);
934
951
  // @ts-ignore
935
- restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
952
+ setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
936
953
  }
937
954
  if (error.codeFrame) {
938
955
  // @ts-ignore
@@ -2227,7 +2244,18 @@ const mergeTrees = (a, b) => {
2227
2244
  };
2228
2245
  };
2229
2246
 
2230
- const openUri = async (uri, focus) => {
2247
+ const openUri = async (uri, focus, options) => {
2248
+ if (options) {
2249
+ await invoke$2('Main.openInput', {
2250
+ editorInput: {
2251
+ type: 'editor',
2252
+ uri
2253
+ },
2254
+ focu: focus,
2255
+ preview: options.preview ?? false
2256
+ });
2257
+ return;
2258
+ }
2231
2259
  await openUri$1(uri, /* focus */focus);
2232
2260
  };
2233
2261
 
@@ -2530,6 +2558,15 @@ const getFileOperationsRename = (oldAbsolutePath, newFileName) => {
2530
2558
  return operations;
2531
2559
  };
2532
2560
 
2561
+ const getRenameSiblingFileNames = (items, editingIndex, pathSeparator) => {
2562
+ const editingItem = items[editingIndex];
2563
+ if (!editingItem) {
2564
+ return [];
2565
+ }
2566
+ const parentPath = dirname(pathSeparator, editingItem.path);
2567
+ return items.filter((item, index) => index !== editingIndex && dirname(pathSeparator, item.path) === parentPath).map(item => item.name);
2568
+ };
2569
+
2533
2570
  const updateTree2 = (tree, update) => {
2534
2571
  const updatedTree = {
2535
2572
  ...tree,
@@ -2547,7 +2584,8 @@ const acceptRename = async state => {
2547
2584
  pathSeparator,
2548
2585
  root
2549
2586
  } = state;
2550
- const editingErrorMessage = validateFileName2(editingValue);
2587
+ const siblingFileNames = getRenameSiblingFileNames(items, editingIndex, pathSeparator);
2588
+ const editingErrorMessage = validateFileName2(editingValue, siblingFileNames);
2551
2589
  if (editingErrorMessage) {
2552
2590
  return {
2553
2591
  ...state,
@@ -2555,6 +2593,9 @@ const acceptRename = async state => {
2555
2593
  };
2556
2594
  }
2557
2595
  const renamedDirent = items[editingIndex];
2596
+ const oldUri = renamedDirent.path;
2597
+ const dirname = dirname2(oldUri);
2598
+ const newUri = join2(dirname, editingValue);
2558
2599
  const operations = getFileOperationsRename(renamedDirent.path, editingValue);
2559
2600
  const renameErrorMessage = await applyFileOperations(operations);
2560
2601
  if (renameErrorMessage) {
@@ -2563,9 +2604,7 @@ const acceptRename = async state => {
2563
2604
  editingErrorMessage: renameErrorMessage
2564
2605
  };
2565
2606
  }
2566
- const oldUri = renamedDirent.path;
2567
- const dirname = dirname2(oldUri);
2568
- const newUri = join2(dirname, editingValue);
2607
+ await invoke$2('Main.handleUriChange', oldUri, newUri);
2569
2608
  const children = await getChildDirents(pathSeparator, dirname, renamedDirent.depth - 1, excluded, root);
2570
2609
  const tree = createTree(items, root);
2571
2610
  const update = computeExplorerRenamedDirentUpdate(root, dirname, oldUri, children, tree, newUri);
@@ -4507,7 +4546,9 @@ const handleClickDirectory = async (state, dirent, index, keepFocus) => {
4507
4546
  };
4508
4547
 
4509
4548
  const handleClickFile = async (state, dirent, index, keepFocus = false) => {
4510
- await openUri(dirent.path, !keepFocus);
4549
+ await openUri(dirent.path, !keepFocus, {
4550
+ preview: true
4551
+ });
4511
4552
  return {
4512
4553
  ...state,
4513
4554
  focused: keepFocus,
@@ -5427,7 +5468,7 @@ const getSettings = async () => {
5427
5468
  const useChevronsRaw = await invoke$2('Preferences.get', 'explorer.useChevrons');
5428
5469
  const useChevrons = useChevronsRaw === false ? false : true;
5429
5470
  const confirmDeleteRaw = await invoke$2('Preferences.get', 'explorer.confirmdelete');
5430
- const confirmDelete = confirmDeleteRaw === false ? false : false;
5471
+ const confirmDelete = confirmDeleteRaw === false ? false : true;
5431
5472
  const confirmPasteRaw = await invoke$2('Preferences.get', 'explorer.confirmpaste');
5432
5473
  const confirmPaste = confirmPasteRaw === false ? false : false;
5433
5474
  const excludedRaw = await invoke$2('Preferences.get', 'files.exclude');
@@ -6194,26 +6235,19 @@ const generateUniqueName = (baseName, existingPaths, root) => {
6194
6235
  }
6195
6236
  };
6196
6237
 
6197
- const getFileOperationsCopy = (root, existingUris, files, focusedUri) => {
6238
+ const getFileOperationsCopy = (targetUri, existingUris, files) => {
6198
6239
  const operations = [];
6240
+ const reservedUris = [...existingUris];
6199
6241
  for (const file of files) {
6200
6242
  const baseName = getBaseName('/', file);
6201
- if (existingUris.includes(file)) {
6202
- operations.push({
6203
- from: file,
6204
- path: join2(focusedUri, baseName),
6205
- type: Rename$2
6206
- });
6207
- } else {
6208
- const uniqueName = generateUniqueName(baseName, existingUris, root);
6209
- const newUri = join2(root, uniqueName);
6210
- operations.push({
6211
- from: file,
6212
- // TODO ensure file is uri
6213
- path: newUri,
6214
- type: Copy$1
6215
- });
6216
- }
6243
+ const uniqueName = generateUniqueName(baseName, reservedUris, targetUri);
6244
+ const newUri = join2(targetUri, uniqueName);
6245
+ operations.push({
6246
+ from: file,
6247
+ path: newUri,
6248
+ type: Copy$1
6249
+ });
6250
+ reservedUris.push(newUri);
6217
6251
  }
6218
6252
  return operations;
6219
6253
  };
@@ -6229,11 +6263,13 @@ const handlePasteCopy = async (state, nativeFiles) => {
6229
6263
  const {
6230
6264
  focusedIndex,
6231
6265
  items,
6266
+ pathSeparator,
6232
6267
  root
6233
6268
  } = state;
6234
- const focusedUri = items[focusedIndex]?.path || root;
6235
- const existingUris = items.map(item => item.path);
6236
- const operations = getFileOperationsCopy(root, existingUris, nativeFiles.files, focusedUri);
6269
+ const targetUri = getParentFolder(items, focusedIndex, root, pathSeparator);
6270
+ const targetDirents = await readDirWithFileTypes(targetUri);
6271
+ const existingUris = targetDirents.map(dirent => join2(targetUri, dirent.name));
6272
+ const operations = getFileOperationsCopy(targetUri, existingUris, nativeFiles.files);
6237
6273
  // TODO handle error?
6238
6274
  await applyFileOperations(operations);
6239
6275
 
@@ -7193,11 +7229,12 @@ const applyRender = (oldState, newState, diffResult) => {
7193
7229
  return commands;
7194
7230
  };
7195
7231
 
7196
- const render2 = (uid, diffResult) => {
7232
+ const render2 = (uid, _diffResult) => {
7197
7233
  const {
7198
7234
  oldState,
7199
7235
  scheduledState
7200
7236
  } = get(uid);
7237
+ const diffResult = diff(oldState, scheduledState);
7201
7238
  set(uid, scheduledState, scheduledState);
7202
7239
  const commands = applyRender(oldState, scheduledState, diffResult);
7203
7240
  return commands;
@@ -7644,13 +7681,16 @@ const updateEditingValue = async (state, value, inputSource = User) => {
7644
7681
  editingIndex,
7645
7682
  editingType,
7646
7683
  focusedIndex,
7647
- items} = state;
7684
+ items,
7685
+ pathSeparator} = state;
7648
7686
  const editingIcon = await getEditingIcon(editingType, value, items[editingIndex]?.type);
7649
7687
 
7650
7688
  // Get sibling file names for validation during file/folder creation
7651
7689
  let siblingFileNames = [];
7652
7690
  if (editingType === CreateFile || editingType === CreateFolder) {
7653
7691
  siblingFileNames = getSiblingFileNames(items, focusedIndex);
7692
+ } else if (editingType === Rename$1) {
7693
+ siblingFileNames = getRenameSiblingFileNames(items, editingIndex, pathSeparator);
7654
7694
  }
7655
7695
  const editingErrorMessage = validateFileName2(value, siblingFileNames);
7656
7696
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "7.9.0",
3
+ "version": "7.9.1",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",