@lvce-editor/explorer-view 1.24.0 → 1.26.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.
@@ -779,12 +779,12 @@ const invokeAndTransfer = (ipc, method, ...params) => {
779
779
  return invokeHelper(ipc, method, params, true);
780
780
  };
781
781
 
782
- const commands$1 = Object.create(null);
782
+ const commands = Object.create(null);
783
783
  const register = commandMap => {
784
- Object.assign(commands$1, commandMap);
784
+ Object.assign(commands, commandMap);
785
785
  };
786
786
  const getCommand = key => {
787
- return commands$1[key];
787
+ return commands[key];
788
788
  };
789
789
  const execute = (command, ...args) => {
790
790
  const fn = getCommand(command);
@@ -898,18 +898,6 @@ const compareDirent = (direntA, direntB) => {
898
898
  return compareDirentType(direntA, direntB) || compareDirentName(direntA, direntB);
899
899
  };
900
900
 
901
- const getFileIcon = ({
902
- name
903
- }) => {
904
- return '';
905
- };
906
- const getIcon = dirent => {
907
- return '';
908
- };
909
- const getFolderIcon = dirent => {
910
- return '';
911
- };
912
-
913
901
  // TODO use posInSet and setSize properties to compute more effectively
914
902
  const computeExplorerRenamedDirent = (dirents, index, newName) => {
915
903
  let startIndex = index;
@@ -921,9 +909,7 @@ const computeExplorerRenamedDirent = (dirents, index, newName) => {
921
909
  ...oldDirent,
922
910
  name: newName,
923
911
  path: oldDirent.path.slice(0, -oldDirent.name.length) + newName,
924
- icon: getFileIcon({
925
- name: newName
926
- })
912
+ icon: ''
927
913
  };
928
914
  const {
929
915
  depth
@@ -1111,7 +1097,7 @@ const acceptCreate = async (state, newDirentType, createFn) => {
1111
1097
  type: newDirentType,
1112
1098
  icon: ''
1113
1099
  };
1114
- newDirent.icon = getIcon();
1100
+ newDirent.icon = '';
1115
1101
  let insertIndex = state.focusedIndex;
1116
1102
  let deltaPosInSet = 0;
1117
1103
  let posInSet = 1;
@@ -1441,7 +1427,7 @@ const toDisplayDirents = (pathSeparator, rawDirents, parentDirent, excluded) =>
1441
1427
  type: rawDirent.type,
1442
1428
  path,
1443
1429
  // TODO storing absolute path might be too costly, could also store relative path here
1444
- icon: getIcon()
1430
+ icon: ''
1445
1431
  };
1446
1432
  };
1447
1433
  const result = [];
@@ -1903,9 +1889,10 @@ const getActions = root => {
1903
1889
  }];
1904
1890
  };
1905
1891
 
1906
- const commands = ['acceptEdit', 'cancelEdit', 'collapseAll', 'copyPath', 'copyRelativePath', 'expandAll', 'expandRecursively', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusNone', 'focusPrevious', 'getFocusedDirent', 'handleArrowLeft', 'handleArrowLeft', 'handleArrowRight', 'handleArrowRight', 'handleBlur', 'handleClick', 'handleClickAt', 'handleClickCurrent', 'handleClickCurrentButKeepFocus', 'handleClickOpenFolder', 'handleContextMenu', 'handleCopy', 'handleDragOver', 'handleDrop', 'handleFocus', 'handleIconThemeChange', 'handleLanguagesChanged', 'handleMouseEnter', 'handleMouseLeave', 'handlePaste', 'handlePointerDown', 'handleUpload', 'handleWheel', 'handleWorkspaceChange', 'hotReload', 'newFile', 'newFolder', 'openContainingFolder', 'refresh', 'refresh', 'relealItem', 'removeDirent', 'rename', 'renameDirent', 'revealItem', 'scrollDown', 'scrollUp', 'setDeltaY', 'updateEditingValue', 'updateIcons'];
1892
+ const commandIds = ['acceptEdit', 'cancelEdit', 'collapseAll', 'copyPath', 'copyRelativePath', 'expandAll', 'expandRecursively', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusNone', 'focusPrevious', 'getFocusedDirent', 'handleArrowLeft', 'handleArrowLeft', 'handleArrowRight', 'handleArrowRight', 'handleBlur', 'handleClick', 'handleClickAt', 'handleClickCurrent', 'handleClickCurrentButKeepFocus', 'handleClickOpenFolder', 'handleContextMenu', 'handleCopy', 'handleDragOver', 'handleDrop', 'handleFocus', 'handleIconThemeChange', 'handleLanguagesChanged', 'handleMouseEnter', 'handleMouseLeave', 'handlePaste', 'handlePointerDown', 'handleUpload', 'handleWheel', 'handleWorkspaceChange', 'hotReload', 'newFile', 'newFolder', 'openContainingFolder', 'refresh', 'refresh', 'relealItem', 'removeDirent', 'rename', 'renameDirent', 'revealItem', 'scrollDown', 'scrollUp', 'setDeltaY', 'renderEventListeners', 'updateEditingValue', 'updateIcons'];
1893
+
1907
1894
  const getCommandIds = () => {
1908
- return commands;
1895
+ return commandIds;
1909
1896
  };
1910
1897
 
1911
1898
  const None$4 = 'none';
@@ -2078,6 +2065,12 @@ const getExplorerWelcomeVirtualDom = isWide => {
2078
2065
  }, text(openFolder$1())];
2079
2066
  };
2080
2067
 
2068
+ const getActiveDescendant = focusedIndex => {
2069
+ if (focusedIndex >= 0) {
2070
+ return 'TreeItemActive';
2071
+ }
2072
+ return undefined;
2073
+ };
2081
2074
  const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused) => {
2082
2075
  if (!root) {
2083
2076
  return getExplorerWelcomeVirtualDom(isWide);
@@ -2090,7 +2083,7 @@ const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused
2090
2083
  role: Tree,
2091
2084
  ariaLabel: filesExplorer(),
2092
2085
  childCount: visibleItems.length,
2093
- ariaActiveDescendant: focusedIndex >= 0 ? 'TreeItemActive' : undefined,
2086
+ ariaActiveDescendant: getActiveDescendant(focusedIndex),
2094
2087
  onFocus: HandleFocus,
2095
2088
  onBlur: HandleBlur,
2096
2089
  onContextMenu: HandleContextMenu,
@@ -2437,7 +2430,7 @@ const handleClickDirectoryExpanded = async (state, dirent, index, keepFocus) =>
2437
2430
  // @ts-ignore
2438
2431
  dirent.type = Directory;
2439
2432
  // @ts-ignore
2440
- dirent.icon = getIcon();
2433
+ dirent.icon = '';
2441
2434
  const endIndex = getParentEndIndex(state.items, index);
2442
2435
  const removeCount = endIndex - index - 1;
2443
2436
  // TODO race conditions and side effects are everywhere
@@ -2538,7 +2531,7 @@ const handleClickDirectory = async (state, dirent, index, keepFocus) => {
2538
2531
  // @ts-ignore
2539
2532
  dirent.type = DirectoryExpanded;
2540
2533
  // @ts-ignore
2541
- dirent.icon = getIcon();
2534
+ dirent.icon = '';
2542
2535
  const {
2543
2536
  height,
2544
2537
  itemHeight,
@@ -2631,7 +2624,7 @@ const handleClickDirectoryExpanding = async (state, dirent, index, keepFocus) =>
2631
2624
  // @ts-ignore
2632
2625
  dirent.type = Directory;
2633
2626
  // @ts-ignore
2634
- dirent.icon = getIcon();
2627
+ dirent.icon = '';
2635
2628
  return {
2636
2629
  ...state,
2637
2630
  focusedIndex: index,
@@ -3056,15 +3049,27 @@ const handleFocus = async state => {
3056
3049
  const updateIcon = dirent => {
3057
3050
  return {
3058
3051
  ...dirent,
3059
- icon: getIcon()
3052
+ icon: ''
3060
3053
  };
3061
3054
  };
3062
3055
 
3063
- const updateIcons = state => {
3056
+ const updateIcons = async state => {
3064
3057
  const newDirents = state.items.map(updateIcon);
3058
+ const {
3059
+ items,
3060
+ minLineY,
3061
+ maxLineY
3062
+ } = state;
3063
+ const visible = items.slice(minLineY, maxLineY);
3064
+ const {
3065
+ icons,
3066
+ newFileIconCache
3067
+ } = await getFileIcons(visible, Object.create(null));
3065
3068
  return {
3066
3069
  ...state,
3067
- items: newDirents
3070
+ items: newDirents,
3071
+ icons,
3072
+ fileIconCache: newFileIconCache
3068
3073
  };
3069
3074
  };
3070
3075
 
@@ -3298,7 +3303,7 @@ const getSavedChildDirents = (map, path, depth, excluded, pathSeparator) => {
3298
3303
  depth,
3299
3304
  posInSet: i + 1,
3300
3305
  setSize: visibleLength,
3301
- icon: getFolderIcon(),
3306
+ icon: '',
3302
3307
  name,
3303
3308
  path: childPath,
3304
3309
  type: DirectoryExpanded
@@ -3309,7 +3314,7 @@ const getSavedChildDirents = (map, path, depth, excluded, pathSeparator) => {
3309
3314
  depth,
3310
3315
  posInSet: i + 1,
3311
3316
  setSize: visibleLength,
3312
- icon: getIcon(),
3317
+ icon: '',
3313
3318
  name,
3314
3319
  path: childPath,
3315
3320
  type
@@ -3962,14 +3967,9 @@ const isExpandedDirectory = dirent => {
3962
3967
  };
3963
3968
 
3964
3969
  const saveState = uid => {
3965
- let newState;
3966
- if (typeof uid === 'number') {
3967
- const value = get(uid);
3968
- newState = value.newState;
3969
- } else {
3970
- // deprecated
3971
- newState = uid;
3972
- }
3970
+ number(uid);
3971
+ const value = get(uid);
3972
+ const newState = value.newState;
3973
3973
  const {
3974
3974
  items,
3975
3975
  root,
@@ -3992,9 +3992,7 @@ const terminate = () => {
3992
3992
  };
3993
3993
 
3994
3994
  const updateEditingValue = (state, value) => {
3995
- const editingIcon = getFileIcon({
3996
- name: value
3997
- });
3995
+ const editingIcon = '';
3998
3996
  return {
3999
3997
  ...state,
4000
3998
  editingValue: value,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "1.24.0",
3
+ "version": "1.26.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",