@lvce-editor/explorer-view 2.13.0 → 2.14.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.
@@ -981,6 +981,10 @@ const getMissingIconRequests = (dirents, fileIconCache) => {
981
981
  return missingRequests;
982
982
  };
983
983
 
984
+ const getPath = dirent => {
985
+ return dirent.path;
986
+ };
987
+
984
988
  const BlockDevice = 1;
985
989
  const CharacterDevice = 2;
986
990
  const Directory = 3;
@@ -1037,7 +1041,7 @@ const getFileIcons = async (dirents, fileIconCache) => {
1037
1041
  const missingRequests = getMissingIconRequests(dirents, fileIconCache);
1038
1042
  const newIcons = await requestFileIcons(missingRequests);
1039
1043
  const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
1040
- const paths = dirents.map(dirent => dirent.path);
1044
+ const paths = dirents.map(getPath);
1041
1045
  const icons = getIconsCached(paths, newFileIconCache);
1042
1046
  return {
1043
1047
  icons,
@@ -2598,12 +2602,14 @@ const handleContextMenuMouseAt = async (state, x, y) => {
2598
2602
  number(x);
2599
2603
  number(y);
2600
2604
  const focusedIndex = getIndexFromPosition(state, x, y);
2601
- await show(x, y, Explorer$1);
2602
- return {
2605
+ const newState = {
2603
2606
  ...state,
2604
2607
  focusedIndex,
2605
2608
  focused: false
2606
2609
  };
2610
+ set(state.uid, state, newState);
2611
+ await show(x, y, Explorer$1);
2612
+ return state;
2607
2613
  };
2608
2614
 
2609
2615
  const getContextMenuHandler = button => {
@@ -3072,15 +3078,7 @@ const handleFocus = async state => {
3072
3078
  return state;
3073
3079
  };
3074
3080
 
3075
- const updateIcon = dirent => {
3076
- return {
3077
- ...dirent,
3078
- icon: ''
3079
- };
3080
- };
3081
-
3082
3081
  const updateIcons = async state => {
3083
- const newDirents = state.items.map(updateIcon);
3084
3082
  const {
3085
3083
  items,
3086
3084
  minLineY,
@@ -3093,7 +3091,6 @@ const updateIcons = async state => {
3093
3091
  } = await getFileIcons(visible, Object.create(null));
3094
3092
  return {
3095
3093
  ...state,
3096
- items: newDirents,
3097
3094
  icons,
3098
3095
  fileIconCache: newFileIconCache
3099
3096
  };
@@ -3489,7 +3486,7 @@ const newFolder = state => {
3489
3486
  return newDirent(state, CreateFolder);
3490
3487
  };
3491
3488
 
3492
- const getContaingingFolder = (root, dirents, focusedIndex, pathSeparator) => {
3489
+ const getContainingFolder = (root, dirents, focusedIndex, pathSeparator) => {
3493
3490
  if (focusedIndex < 0) {
3494
3491
  return root;
3495
3492
  }
@@ -3499,13 +3496,18 @@ const getContaingingFolder = (root, dirents, focusedIndex, pathSeparator) => {
3499
3496
  const path = `${direntParentPath}`;
3500
3497
  return path;
3501
3498
  };
3499
+
3500
+ const openNativeFolder = async path => {
3501
+ await invoke('OpenNativeFolder.openNativeFolder', /* path */path);
3502
+ };
3503
+
3502
3504
  const openContainingFolder = async state => {
3503
3505
  const {
3504
3506
  focusedIndex,
3505
3507
  root,
3506
3508
  items} = state;
3507
- const path = getContaingingFolder(root, items, focusedIndex);
3508
- await invoke('OpenNativeFolder.openNativeFolder', /* path */path);
3509
+ const path = getContainingFolder(root, items, focusedIndex);
3510
+ await openNativeFolder(path);
3509
3511
  return state;
3510
3512
  };
3511
3513
 
@@ -4166,23 +4168,22 @@ const orderDirents = dirents => {
4166
4168
  if (dirents.length === 0) {
4167
4169
  return dirents;
4168
4170
  }
4169
- // const parentMap = Object.create(null)
4170
- // for(const dirent of dirents){
4171
- // const parentPath = dirent.slice(0, dirent.lastIndexOf('/'))
4172
- // parentMap[parentPath]||=[]
4173
- // parentMap[parentPath].push(dirent)
4174
- // }
4175
- const withDeepChildren = parent => {
4171
+ const withDeepChildren = (parent, processed) => {
4172
+ if (processed.has(parent.path)) {
4173
+ return [];
4174
+ }
4175
+ processed.add(parent.path);
4176
4176
  const children = [];
4177
4177
  for (const dirent of dirents) {
4178
4178
  if (dirent.depth === parent.depth + 1 && dirent.path.startsWith(parent.path)) {
4179
- children.push(dirent, ...withDeepChildren(dirent));
4179
+ children.push(...withDeepChildren(dirent, processed));
4180
4180
  }
4181
4181
  }
4182
4182
  return [parent, ...children];
4183
4183
  };
4184
4184
  const topLevelDirents = dirents.filter(isTopLevel);
4185
- const ordered = topLevelDirents.flatMap(withDeepChildren);
4185
+ const processed = new Set();
4186
+ const ordered = topLevelDirents.flatMap(dirent => withDeepChildren(dirent, processed));
4186
4187
  return ordered;
4187
4188
  };
4188
4189
 
@@ -4355,10 +4356,6 @@ const revealItem = async (state, uri) => {
4355
4356
  return revealItemVisible(state, index);
4356
4357
  };
4357
4358
 
4358
- const getPath = dirent => {
4359
- return dirent.path;
4360
- };
4361
-
4362
4359
  const isExpandedDirectory = dirent => {
4363
4360
  return dirent.type === DirectoryExpanded;
4364
4361
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "2.13.0",
3
+ "version": "2.14.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",