@lvce-editor/explorer-view 3.19.0 → 3.20.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.
@@ -1372,7 +1372,7 @@ const getWebViewSecret = async key => {
1372
1372
  const setWebViewPort = async (uid, port, origin, portType) => {
1373
1373
  return invokeAndTransfer('WebView.setPort', uid, port, origin, portType);
1374
1374
  };
1375
- const setFocus$1 = key => {
1375
+ const setFocus = key => {
1376
1376
  return invoke$2('Focus.setFocus', key);
1377
1377
  };
1378
1378
  const getFileIcon = async options => {
@@ -1632,7 +1632,7 @@ const RendererWorker = {
1632
1632
  setAdditionalFocus,
1633
1633
  setColorTheme,
1634
1634
  setExtensionsSearchValue,
1635
- setFocus: setFocus$1,
1635
+ setFocus,
1636
1636
  setWebViewPort,
1637
1637
  setWorkspacePath,
1638
1638
  showContextMenu: showContextMenu$1,
@@ -1798,94 +1798,6 @@ const Rename$1 = 3;
1798
1798
  const List = 1;
1799
1799
  const Input$1 = 2;
1800
1800
 
1801
- // TODO optimize this function to return the minimum number
1802
- // of visible items needed, e.g. when not scrolled 5 items with
1803
- // 20px fill 100px but when scrolled 6 items are needed
1804
- const getNumberOfVisibleItems = (listHeight, itemHeight) => {
1805
- return Math.ceil(listHeight / itemHeight) + 1;
1806
- };
1807
-
1808
- const getExplorerMaxLineY = (minLineY, height, itemHeight, direntsLength) => {
1809
- const maxLineY = minLineY + Math.min(getNumberOfVisibleItems(height, itemHeight), direntsLength);
1810
- return maxLineY;
1811
- };
1812
-
1813
- const getIconsCached = (dirents, fileIconCache) => {
1814
- return dirents.map(dirent => fileIconCache[dirent]);
1815
- };
1816
-
1817
- const getMissingIconRequests = (dirents, fileIconCache) => {
1818
- const missingRequests = [];
1819
- for (const dirent of dirents) {
1820
- if (!(dirent.path in fileIconCache)) {
1821
- missingRequests.push({
1822
- type: dirent.type,
1823
- name: dirent.name,
1824
- path: dirent.path
1825
- });
1826
- }
1827
- }
1828
- return missingRequests;
1829
- };
1830
-
1831
- const getPath = item => {
1832
- return item.path;
1833
- };
1834
-
1835
- const getPaths = items => {
1836
- return items.map(getPath);
1837
- };
1838
-
1839
- const getSimpleIconRequestType = direntType => {
1840
- if (direntType === Directory || direntType === DirectoryExpanded || direntType === EditingDirectoryExpanded || direntType === EditingFolder) {
1841
- return 2;
1842
- }
1843
- return 1;
1844
- };
1845
-
1846
- const toSimpleIconRequest = request => {
1847
- return {
1848
- name: request.name,
1849
- type: getSimpleIconRequestType(request.type)
1850
- };
1851
- };
1852
-
1853
- const requestFileIcons = async requests => {
1854
- if (requests.length === 0) {
1855
- return [];
1856
- }
1857
- const simpleRequests = requests.map(toSimpleIconRequest);
1858
- const icons = await invoke$1('IconTheme.getIcons', simpleRequests);
1859
- return icons;
1860
- };
1861
-
1862
- const updateIconCache = (iconCache, missingRequests, newIcons) => {
1863
- if (missingRequests.length === 0) {
1864
- return iconCache;
1865
- }
1866
- const newFileIconCache = {
1867
- ...iconCache
1868
- };
1869
- for (let i = 0; i < missingRequests.length; i++) {
1870
- const request = missingRequests[i];
1871
- const icon = newIcons[i];
1872
- newFileIconCache[request.path] = icon;
1873
- }
1874
- return newFileIconCache;
1875
- };
1876
-
1877
- const getFileIcons = async (dirents, fileIconCache) => {
1878
- const missingRequests = getMissingIconRequests(dirents, fileIconCache);
1879
- const newIcons = await requestFileIcons(missingRequests);
1880
- const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
1881
- const paths = getPaths(dirents);
1882
- const icons = getIconsCached(paths, newFileIconCache);
1883
- return {
1884
- icons,
1885
- newFileIconCache
1886
- };
1887
- };
1888
-
1889
1801
  const getFileOperationsNestedPath = (path, root, pathSeparator) => {
1890
1802
  const parts = path.slice(root.length).split(pathSeparator);
1891
1803
  const operations = [];
@@ -2297,10 +2209,6 @@ const validateFileName2 = name => {
2297
2209
  const acceptCreate = async (state, newDirentType) => {
2298
2210
  const {
2299
2211
  editingValue,
2300
- minLineY,
2301
- height,
2302
- itemHeight,
2303
- fileIconCache,
2304
2212
  pathSeparator,
2305
2213
  root,
2306
2214
  focusedIndex,
@@ -2332,22 +2240,13 @@ const acceptCreate = async (state, newDirentType) => {
2332
2240
  const newItems = treeToArray(merged, root);
2333
2241
  const dirents = newItems;
2334
2242
  const newFocusedIndex = getIndex(newItems, absolutePath);
2335
- const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, dirents.length);
2336
- const visible = dirents.slice(minLineY, maxLineY);
2337
- const {
2338
- icons,
2339
- newFileIconCache
2340
- } = await getFileIcons(visible, fileIconCache);
2341
2243
  return {
2342
2244
  ...state,
2343
2245
  items: dirents,
2344
2246
  editingIndex: -1,
2345
2247
  focusedIndex: newFocusedIndex,
2346
2248
  editingType: None$5,
2347
- maxLineY,
2348
- focus: List,
2349
- icons,
2350
- fileIconCache: newFileIconCache
2249
+ focus: List
2351
2250
  };
2352
2251
  };
2353
2252
 
@@ -2402,11 +2301,7 @@ const acceptRename = async state => {
2402
2301
  editingIndex,
2403
2302
  editingValue,
2404
2303
  items,
2405
- root,
2406
- minLineY,
2407
- height,
2408
- itemHeight,
2409
- fileIconCache
2304
+ root
2410
2305
  } = state;
2411
2306
  const editingErrorMessage = validateFileName2(editingValue);
2412
2307
  if (editingErrorMessage) {
@@ -2433,12 +2328,6 @@ const acceptRename = async state => {
2433
2328
  const newTree = updateTree2(tree, update);
2434
2329
  const newDirents = treeToArray(newTree, root);
2435
2330
  const newFocusedIndex = getIndex(newDirents, newUri);
2436
- const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, newDirents.length);
2437
- const visible = newDirents.slice(minLineY, maxLineY);
2438
- const {
2439
- icons,
2440
- newFileIconCache
2441
- } = await getFileIcons(visible, fileIconCache);
2442
2331
  return {
2443
2332
  ...state,
2444
2333
  editingIndex: -1,
@@ -2449,8 +2338,6 @@ const acceptRename = async state => {
2449
2338
  focused: true,
2450
2339
  focus: List,
2451
2340
  items: newDirents,
2452
- icons,
2453
- fileIconCache: newFileIconCache,
2454
2341
  editingSelectionEnd: 0,
2455
2342
  editingSelectionStart: 0
2456
2343
  };
@@ -2479,14 +2366,9 @@ const isNormalItem = item => {
2479
2366
  const cancelEditCreate = async (state, keepFocus) => {
2480
2367
  const {
2481
2368
  editingIndex,
2482
- items,
2483
- fileIconCache
2369
+ items
2484
2370
  } = state;
2485
2371
  const filteredItems = items.filter(isNormalItem);
2486
- const {
2487
- icons,
2488
- newFileIconCache
2489
- } = await getFileIcons(filteredItems, fileIconCache);
2490
2372
  return {
2491
2373
  ...state,
2492
2374
  items: filteredItems,
@@ -2496,9 +2378,7 @@ const cancelEditCreate = async (state, keepFocus) => {
2496
2378
  editingValue: '',
2497
2379
  editingErrorMessage: '',
2498
2380
  editingType: None$5,
2499
- focus: List,
2500
- icons,
2501
- fileIconCache: newFileIconCache
2381
+ focus: List
2502
2382
  };
2503
2383
  };
2504
2384
 
@@ -2573,25 +2453,12 @@ const toCollapsedDirent = dirent => {
2573
2453
 
2574
2454
  const collapseAll = async state => {
2575
2455
  const {
2576
- minLineY,
2577
- height,
2578
- itemHeight,
2579
- fileIconCache,
2580
2456
  items
2581
2457
  } = state;
2582
2458
  const newDirents = items.filter(isTopLevel).map(toCollapsedDirent);
2583
- const dirents = newDirents;
2584
- const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, dirents.length);
2585
- const visible = dirents.slice(minLineY, maxLineY);
2586
- const {
2587
- icons,
2588
- newFileIconCache
2589
- } = await getFileIcons(visible, fileIconCache);
2590
2459
  return {
2591
2460
  ...state,
2592
- items: newDirents,
2593
- icons,
2594
- fileIconCache: newFileIconCache
2461
+ items: newDirents
2595
2462
  };
2596
2463
  };
2597
2464
 
@@ -2641,6 +2508,94 @@ const copyRelativePath = async state => {
2641
2508
  return state;
2642
2509
  };
2643
2510
 
2511
+ // TODO optimize this function to return the minimum number
2512
+ // of visible items needed, e.g. when not scrolled 5 items with
2513
+ // 20px fill 100px but when scrolled 6 items are needed
2514
+ const getNumberOfVisibleItems = (listHeight, itemHeight) => {
2515
+ return Math.ceil(listHeight / itemHeight) + 1;
2516
+ };
2517
+
2518
+ const getExplorerMaxLineY = (minLineY, height, itemHeight, direntsLength) => {
2519
+ const maxLineY = minLineY + Math.min(getNumberOfVisibleItems(height, itemHeight), direntsLength);
2520
+ return maxLineY;
2521
+ };
2522
+
2523
+ const getIconsCached = (dirents, fileIconCache) => {
2524
+ return dirents.map(dirent => fileIconCache[dirent]);
2525
+ };
2526
+
2527
+ const getMissingIconRequests = (dirents, fileIconCache) => {
2528
+ const missingRequests = [];
2529
+ for (const dirent of dirents) {
2530
+ if (!(dirent.path in fileIconCache)) {
2531
+ missingRequests.push({
2532
+ type: dirent.type,
2533
+ name: dirent.name,
2534
+ path: dirent.path
2535
+ });
2536
+ }
2537
+ }
2538
+ return missingRequests;
2539
+ };
2540
+
2541
+ const getPath = item => {
2542
+ return item.path;
2543
+ };
2544
+
2545
+ const getPaths = items => {
2546
+ return items.map(getPath);
2547
+ };
2548
+
2549
+ const getSimpleIconRequestType = direntType => {
2550
+ if (direntType === Directory || direntType === DirectoryExpanded || direntType === EditingDirectoryExpanded || direntType === EditingFolder) {
2551
+ return 2;
2552
+ }
2553
+ return 1;
2554
+ };
2555
+
2556
+ const toSimpleIconRequest = request => {
2557
+ return {
2558
+ name: request.name,
2559
+ type: getSimpleIconRequestType(request.type)
2560
+ };
2561
+ };
2562
+
2563
+ const requestFileIcons = async requests => {
2564
+ if (requests.length === 0) {
2565
+ return [];
2566
+ }
2567
+ const simpleRequests = requests.map(toSimpleIconRequest);
2568
+ const icons = await invoke$1('IconTheme.getIcons', simpleRequests);
2569
+ return icons;
2570
+ };
2571
+
2572
+ const updateIconCache = (iconCache, missingRequests, newIcons) => {
2573
+ if (missingRequests.length === 0) {
2574
+ return iconCache;
2575
+ }
2576
+ const newFileIconCache = {
2577
+ ...iconCache
2578
+ };
2579
+ for (let i = 0; i < missingRequests.length; i++) {
2580
+ const request = missingRequests[i];
2581
+ const icon = newIcons[i];
2582
+ newFileIconCache[request.path] = icon;
2583
+ }
2584
+ return newFileIconCache;
2585
+ };
2586
+
2587
+ const getFileIcons = async (dirents, fileIconCache) => {
2588
+ const missingRequests = getMissingIconRequests(dirents, fileIconCache);
2589
+ const newIcons = await requestFileIcons(missingRequests);
2590
+ const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
2591
+ const paths = getPaths(dirents);
2592
+ const icons = getIconsCached(paths, newFileIconCache);
2593
+ return {
2594
+ icons,
2595
+ newFileIconCache
2596
+ };
2597
+ };
2598
+
2644
2599
  const None$4 = 0;
2645
2600
  const Right = 1;
2646
2601
  const Down = 2;
@@ -2826,6 +2781,50 @@ const {
2826
2781
  getCommandIds,
2827
2782
  wrapGetter
2828
2783
  } = create$2();
2784
+ const wrapListItemCommand = fn => {
2785
+ const wrappedCommand = async (id, ...args) => {
2786
+ const {
2787
+ newState
2788
+ } = get(id);
2789
+ const updatedState = await fn(newState, ...args);
2790
+ const {
2791
+ items,
2792
+ minLineY,
2793
+ focusedIndex,
2794
+ editingIndex,
2795
+ editingType,
2796
+ editingValue,
2797
+ editingErrorMessage,
2798
+ useChevrons,
2799
+ dropTargets,
2800
+ editingIcon,
2801
+ cutItems,
2802
+ sourceControlIgnoredUris,
2803
+ height,
2804
+ itemHeight,
2805
+ fileIconCache
2806
+ } = updatedState;
2807
+ const intermediate = get(id);
2808
+ set(id, intermediate.oldState, updatedState);
2809
+ const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, items.length);
2810
+ const visible = items.slice(minLineY, maxLineY);
2811
+ const {
2812
+ icons,
2813
+ newFileIconCache
2814
+ } = await getFileIcons(visible, fileIconCache);
2815
+ const visibleExplorerItems = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
2816
+ const finalState = {
2817
+ ...updatedState,
2818
+ visibleExplorerItems,
2819
+ fileIconCache: newFileIconCache,
2820
+ icons,
2821
+ maxLineY
2822
+ };
2823
+ const intermediate2 = get(id);
2824
+ set(id, intermediate2.oldState, finalState);
2825
+ };
2826
+ return wrappedCommand;
2827
+ };
2829
2828
 
2830
2829
  const ListItem = 22;
2831
2830
 
@@ -3006,10 +3005,7 @@ const expandAll = async state => {
3006
3005
  const {
3007
3006
  items,
3008
3007
  focusedIndex,
3009
- pathSeparator,
3010
- minLineY,
3011
- height,
3012
- itemHeight
3008
+ pathSeparator
3013
3009
  } = state;
3014
3010
  if (focusedIndex === -1) {
3015
3011
  return state;
@@ -3040,18 +3036,9 @@ const expandAll = async state => {
3040
3036
  // await expand(state, dirent.index)
3041
3037
  }
3042
3038
  }
3043
- const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, newDirents.length);
3044
- const visible = newDirents.slice(minLineY, maxLineY);
3045
- const {
3046
- icons,
3047
- newFileIconCache
3048
- } = await getFileIcons(visible, state.fileIconCache);
3049
3039
  return {
3050
3040
  ...state,
3051
- items: newDirents,
3052
- icons,
3053
- fileIconCache: newFileIconCache,
3054
- maxLineY
3041
+ items: newDirents
3055
3042
  };
3056
3043
  };
3057
3044
 
@@ -3099,10 +3086,7 @@ const expandRecursively = async state => {
3099
3086
  items,
3100
3087
  focusedIndex,
3101
3088
  pathSeparator,
3102
- root,
3103
- height,
3104
- itemHeight,
3105
- minLineY
3089
+ root
3106
3090
  } = state;
3107
3091
  const dirent = focusedIndex < 0 ? {
3108
3092
  type: Directory,
@@ -3121,33 +3105,15 @@ const expandRecursively = async state => {
3121
3105
  if (focusedIndex >= 0) {
3122
3106
  const endIndex = getParentEndIndex(items, focusedIndex);
3123
3107
  const newDirents = [...items.slice(0, startIndex), ...childDirents, ...items.slice(endIndex)];
3124
- const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, newDirents.length);
3125
- const visible = newDirents.slice(minLineY, maxLineY);
3126
- const {
3127
- icons,
3128
- newFileIconCache
3129
- } = await getFileIcons(visible, state.fileIconCache);
3130
3108
  return {
3131
3109
  ...state,
3132
- items: newDirents,
3133
- maxLineY,
3134
- icons,
3135
- fileIconCache: newFileIconCache
3110
+ items: newDirents
3136
3111
  };
3137
3112
  }
3138
3113
  const newDirents = childDirents.slice(1);
3139
- const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, newDirents.length);
3140
- const visible = newDirents.slice(minLineY, maxLineY);
3141
- const {
3142
- icons,
3143
- newFileIconCache
3144
- } = await getFileIcons(visible, state.fileIconCache);
3145
3114
  return {
3146
3115
  ...state,
3147
- items: newDirents,
3148
- maxLineY,
3149
- icons,
3150
- fileIconCache: newFileIconCache
3116
+ items: newDirents
3151
3117
  };
3152
3118
  };
3153
3119
 
@@ -3551,17 +3517,6 @@ const handleClickDirectoryExpanded = async (state, dirent, index, keepFocus) =>
3551
3517
  minLineY,
3552
3518
  maxLineY,
3553
3519
  itemHeight,
3554
- fileIconCache,
3555
- cutItems,
3556
- sourceControlIgnoredUris,
3557
- dropTargets,
3558
- editingErrorMessage,
3559
- editingIcon,
3560
- editingIndex,
3561
- editingType,
3562
- editingValue,
3563
- focusedIndex,
3564
- useChevrons,
3565
3520
  items
3566
3521
  } = state;
3567
3522
  // @ts-ignore
@@ -3579,39 +3534,21 @@ const handleClickDirectoryExpanded = async (state, dirent, index, keepFocus) =>
3579
3534
  const newMaxLineY = Math.min(maxLineY, newTotal);
3580
3535
  const newMinLineY = newMaxLineY - visibleItems;
3581
3536
  const deltaY = newMinLineY * itemHeight;
3582
- const parts = newDirents.slice(newMinLineY, newMaxLineY);
3583
- const {
3584
- icons,
3585
- newFileIconCache
3586
- } = await getFileIcons(parts, fileIconCache);
3587
- const visibleExplorerItems = getVisibleExplorerItems(newDirents, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
3588
3537
  return {
3589
3538
  ...state,
3590
3539
  deltaY,
3591
- fileIconCache: newFileIconCache,
3592
3540
  focused: keepFocus,
3593
3541
  focusedIndex: index,
3594
- icons,
3595
3542
  items: newDirents,
3596
3543
  maxLineY: newMaxLineY,
3597
- minLineY: newMinLineY,
3598
- visibleExplorerItems
3544
+ minLineY: newMinLineY
3599
3545
  };
3600
3546
  }
3601
- const parts = newDirents.slice(minLineY, maxLineY);
3602
- const {
3603
- icons,
3604
- newFileIconCache
3605
- } = await getFileIcons(parts, fileIconCache);
3606
- const visibleExplorerItems = getVisibleExplorerItems(newDirents, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
3607
3547
  return {
3608
3548
  ...state,
3609
- fileIconCache: newFileIconCache,
3610
3549
  focused: keepFocus,
3611
3550
  focusedIndex: index,
3612
- icons,
3613
- items: newDirents,
3614
- visibleExplorerItems
3551
+ items: newDirents
3615
3552
  };
3616
3553
  };
3617
3554
 
@@ -3652,23 +3589,7 @@ const handleArrowRightDirectoryExpanded = (state, dirent) => {
3652
3589
  return state;
3653
3590
  };
3654
3591
 
3655
- const setFocus = key => {
3656
- return invoke$1('Focus.setFocus', key);
3657
- };
3658
-
3659
3592
  const handleClickDirectory = async (state, dirent, index, keepFocus) => {
3660
- const {
3661
- cutItems,
3662
- sourceControlIgnoredUris,
3663
- dropTargets,
3664
- editingErrorMessage,
3665
- editingIcon,
3666
- editingIndex,
3667
- editingType,
3668
- editingValue,
3669
- focusedIndex,
3670
- useChevrons
3671
- } = state;
3672
3593
  // @ts-ignore
3673
3594
  dirent.type = DirectoryExpanding;
3674
3595
  // TODO handle error
@@ -3689,31 +3610,14 @@ const handleClickDirectory = async (state, dirent, index, keepFocus) => {
3689
3610
  dirent.type = DirectoryExpanded;
3690
3611
  // @ts-ignore
3691
3612
  dirent.icon = '';
3692
- const {
3693
- height,
3694
- itemHeight,
3695
- minLineY
3696
- } = state2;
3697
3613
  // TODO when focused index has changed while expanding, don't update it
3698
- const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, newDirents.length);
3699
- const parts = newDirents.slice(minLineY, maxLineY);
3700
- const {
3701
- icons,
3702
- newFileIconCache
3703
- } = await getFileIcons(parts, state.fileIconCache);
3704
- const visibleExplorerItems = getVisibleExplorerItems(newDirents, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
3705
3614
 
3706
- // TODO use functional focus rendering
3707
- await setFocus(FocusExplorer);
3708
3615
  return {
3709
3616
  ...state,
3710
- fileIconCache: newFileIconCache,
3711
3617
  focused: keepFocus,
3712
3618
  focusedIndex: newIndex,
3713
- icons,
3714
3619
  items: newDirents,
3715
- maxLineY,
3716
- visibleExplorerItems
3620
+ focus: List
3717
3621
  };
3718
3622
  };
3719
3623
 
@@ -4266,21 +4170,8 @@ const sortPathDirentsMap = map => {
4266
4170
  const refresh = async state => {
4267
4171
  const {
4268
4172
  root,
4269
- minLineY,
4270
- height,
4271
- itemHeight,
4272
- fileIconCache,
4273
- cutItems,
4274
- sourceControlIgnoredUris,
4275
- dropTargets,
4276
- editingErrorMessage,
4277
- editingIcon,
4278
- editingIndex,
4279
- editingType,
4280
- editingValue,
4281
4173
  focusedIndex,
4282
- items,
4283
- useChevrons
4174
+ items
4284
4175
  } = state;
4285
4176
  const expandedDirents = getExpandedDirents(items);
4286
4177
  const expandedPaths = getPaths(expandedDirents);
@@ -4288,25 +4179,14 @@ const refresh = async state => {
4288
4179
  const pathToDirents = await getPathDirentsMap(allPaths);
4289
4180
  const sortedPathDirents = sortPathDirentsMap(pathToDirents);
4290
4181
  const newItems = getProtoMap(root, sortedPathDirents, expandedPaths);
4291
- const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, newItems.length);
4292
- const visible = newItems.slice(minLineY, maxLineY);
4293
- const {
4294
- icons,
4295
- newFileIconCache
4296
- } = await getFileIcons(visible, fileIconCache);
4297
4182
  let newFocusedIndex = focusedIndex;
4298
4183
  if (focusedIndex >= newItems.length) {
4299
4184
  newFocusedIndex = newItems.length - 1;
4300
4185
  }
4301
- const visibleExplorerItems = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
4302
4186
  return {
4303
4187
  ...state,
4304
- fileIconCache: newFileIconCache,
4305
4188
  focusedIndex: newFocusedIndex,
4306
- icons,
4307
- items: newItems,
4308
- maxLineY,
4309
- visibleExplorerItems
4189
+ items: newItems
4310
4190
  };
4311
4191
  };
4312
4192
 
@@ -4604,8 +4484,10 @@ const handleEscape = async state => {
4604
4484
  };
4605
4485
 
4606
4486
  const handleFocus = async state => {
4607
- await setFocus(FocusExplorer);
4608
- return state;
4487
+ return {
4488
+ ...state,
4489
+ focus: List
4490
+ };
4609
4491
  };
4610
4492
 
4611
4493
  const updateIcons = async state => {
@@ -4954,9 +4836,8 @@ const handlePaste = async state => {
4954
4836
  // Use the pasteShouldMove flag to determine whether to cut or copy
4955
4837
  if (state.pasteShouldMove) {
4956
4838
  return handlePasteCut(state, nativeFiles);
4957
- } else {
4958
- return handlePasteCopy(state, nativeFiles);
4959
4839
  }
4840
+ return handlePasteCopy(state, nativeFiles);
4960
4841
  };
4961
4842
 
4962
4843
  const handlePointerDown = (state, button, x, y) => {
@@ -4994,17 +4875,7 @@ const handleUpload = async (state, dirents) => {
4994
4875
  const setDeltaY = async (state, deltaY) => {
4995
4876
  const {
4996
4877
  itemHeight,
4997
- useChevrons,
4998
4878
  height,
4999
- cutItems,
5000
- sourceControlIgnoredUris,
5001
- dropTargets,
5002
- editingErrorMessage,
5003
- editingIcon,
5004
- editingIndex,
5005
- editingType,
5006
- editingValue,
5007
- focusedIndex,
5008
4879
  items
5009
4880
  } = state;
5010
4881
  if (deltaY < 0) {
@@ -5017,20 +4888,11 @@ const setDeltaY = async (state, deltaY) => {
5017
4888
  }
5018
4889
  const minLineY = Math.round(deltaY / itemHeight);
5019
4890
  const maxLineY = minLineY + Math.round(height / itemHeight);
5020
- const visible = items.slice(minLineY, maxLineY);
5021
- const {
5022
- icons,
5023
- newFileIconCache
5024
- } = await getFileIcons(visible, state.fileIconCache);
5025
- const visibleExplorerItems = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
5026
4891
  return {
5027
4892
  ...state,
5028
4893
  deltaY,
5029
- fileIconCache: newFileIconCache,
5030
- icons,
5031
4894
  maxLineY,
5032
- minLineY,
5033
- visibleExplorerItems
4895
+ minLineY
5034
4896
  };
5035
4897
  };
5036
4898
 
@@ -5176,18 +5038,6 @@ const getSavedRoot = (savedState, workspacePath) => {
5176
5038
  return workspacePath;
5177
5039
  };
5178
5040
  const loadContent = async (state, savedState) => {
5179
- const {
5180
- fileIconCache,
5181
- cutItems,
5182
- sourceControlIgnoredUris,
5183
- dropTargets,
5184
- editingErrorMessage,
5185
- editingIcon,
5186
- editingIndex,
5187
- editingType,
5188
- editingValue,
5189
- focusedIndex
5190
- } = state;
5191
5041
  const {
5192
5042
  useChevrons,
5193
5043
  confirmDelete
@@ -5198,10 +5048,6 @@ const loadContent = async (state, savedState) => {
5198
5048
  const pathSeparator = await getPathSeparator(root); // TODO only load path separator once
5199
5049
  const excluded = getExcluded();
5200
5050
  const restoredDirents = await restoreExpandedState(savedState, root, pathSeparator, excluded);
5201
- const {
5202
- itemHeight,
5203
- height
5204
- } = state;
5205
5051
  let minLineY = 0;
5206
5052
  if (savedState && typeof savedState.minLineY === 'number') {
5207
5053
  minLineY = savedState.minLineY;
@@ -5210,28 +5056,17 @@ const loadContent = async (state, savedState) => {
5210
5056
  if (savedState && typeof savedState.deltaY === 'number') {
5211
5057
  deltaY = savedState.deltaY;
5212
5058
  }
5213
- const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, restoredDirents.length);
5214
- const visible = restoredDirents.slice(minLineY, maxLineY);
5215
- const {
5216
- icons,
5217
- newFileIconCache
5218
- } = await getFileIcons(visible, fileIconCache);
5219
- const visibleExplorerItems = getVisibleExplorerItems(restoredDirents, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
5220
5059
  return {
5221
5060
  ...state,
5222
5061
  confirmDelete,
5223
5062
  deltaY,
5224
5063
  excluded,
5225
- fileIconCache: newFileIconCache,
5226
- icons,
5227
5064
  items: restoredDirents,
5228
5065
  maxIndent: 10,
5229
- maxLineY,
5230
5066
  minLineY,
5231
5067
  pathSeparator,
5232
5068
  root,
5233
- useChevrons,
5234
- visibleExplorerItems
5069
+ useChevrons
5235
5070
  };
5236
5071
  };
5237
5072
 
@@ -5270,8 +5105,6 @@ const initialize = async () => {
5270
5105
  await initializeFileSystemWorker();
5271
5106
  };
5272
5107
 
5273
- const ExplorerEditBox = FocusExplorerEditBox;
5274
-
5275
5108
  const getNewChildDirentsForNewDirent = async (items, depth, parentPath, direntType) => {
5276
5109
  // Get existing children or query them if they don't exist
5277
5110
  let existingChildren = items.filter(item => item.depth === depth && item.path.startsWith(parentPath));
@@ -5364,48 +5197,24 @@ const getFittingIndex = (dirents, startIndex) => {
5364
5197
  return -1;
5365
5198
  };
5366
5199
  const newDirent = async (state, editingType) => {
5367
- // TODO make focus functional instead of side effect
5368
- await setFocus(ExplorerEditBox);
5369
5200
  // TODO do it like vscode, select position between folders and files
5370
5201
  const {
5371
- minLineY,
5372
- height,
5373
- itemHeight,
5374
5202
  root,
5375
- fileIconCache,
5376
- cutItems,
5377
- sourceControlIgnoredUris,
5378
- dropTargets,
5379
- editingErrorMessage,
5380
- editingIcon,
5381
- editingValue,
5382
5203
  focusedIndex,
5383
- items,
5384
- useChevrons
5204
+ items
5385
5205
  } = state;
5386
5206
  const index = getFittingIndex(items, focusedIndex);
5387
5207
  const direntType = getNewDirentType(editingType);
5388
5208
  const newDirents = await getNewDirentsForNewDirent(items, index, direntType, root);
5389
- const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, newDirents.length);
5390
- const visible = newDirents.slice(minLineY, maxLineY);
5391
- const {
5392
- icons,
5393
- newFileIconCache
5394
- } = await getFileIcons(visible, fileIconCache);
5395
5209
  const editingIndex = newDirents.findIndex(item => item.type === EditingFile || item.type === EditingFolder);
5396
- const visibleExplorerItems = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
5397
5210
  return {
5398
5211
  ...state,
5399
5212
  editingIndex,
5400
5213
  editingType,
5401
5214
  editingValue: '',
5402
- fileIconCache: newFileIconCache,
5403
5215
  focus: Input$1,
5404
5216
  focusedIndex: editingIndex,
5405
- icons,
5406
- items: newDirents,
5407
- maxLineY,
5408
- visibleExplorerItems
5217
+ items: newDirents
5409
5218
  };
5410
5219
  };
5411
5220
 
@@ -5524,7 +5333,7 @@ const getRenameSelectionRange = name => {
5524
5333
  const User = 1;
5525
5334
  const Script = 2;
5526
5335
 
5527
- const renameDirent = state => {
5336
+ const renameDirent = async state => {
5528
5337
  const {
5529
5338
  focusedIndex,
5530
5339
  items,
@@ -6447,14 +6256,14 @@ const updateEditingValue = async (state, value, inputSource = User) => {
6447
6256
  };
6448
6257
 
6449
6258
  const commandMap = {
6450
- 'Explorer.acceptEdit': wrapCommand(acceptEdit),
6451
- 'Explorer.cancelEdit': wrapCommand(cancelEdit),
6259
+ 'Explorer.acceptEdit': wrapListItemCommand(acceptEdit),
6260
+ 'Explorer.cancelEdit': wrapListItemCommand(cancelEdit),
6452
6261
  'Explorer.cancelTypeAhead': wrapCommand(cancelTypeAhead),
6453
- 'Explorer.collapseAll': wrapCommand(collapseAll),
6262
+ 'Explorer.collapseAll': wrapListItemCommand(collapseAll),
6454
6263
  'Explorer.copyPath': wrapCommand(copyPath),
6455
6264
  'Explorer.copyRelativePath': wrapCommand(copyRelativePath),
6456
- 'Explorer.expandAll': wrapCommand(expandAll),
6457
- 'Explorer.expandRecursively': wrapCommand(expandRecursively),
6265
+ 'Explorer.expandAll': wrapListItemCommand(expandAll),
6266
+ 'Explorer.expandRecursively': wrapListItemCommand(expandRecursively),
6458
6267
  'Explorer.focus': wrapCommand(focus),
6459
6268
  'Explorer.focusFirst': wrapCommand(focusFirst),
6460
6269
  'Explorer.focusIndex': wrapCommand(focusIndex),
@@ -6471,7 +6280,7 @@ const commandMap = {
6471
6280
  'Explorer.handleArrowRight': wrapCommand(handleArrowRight),
6472
6281
  'Explorer.handleEscape': wrapCommand(handleEscape),
6473
6282
  'Explorer.handleBlur': wrapCommand(handleBlur),
6474
- 'Explorer.handleClick': wrapCommand(handleClick),
6283
+ 'Explorer.handleClick': wrapListItemCommand(handleClick),
6475
6284
  'Explorer.handleClickAt': wrapCommand(handleClickAt),
6476
6285
  'Explorer.handleClickCurrent': wrapCommand(handleClickCurrent),
6477
6286
  'Explorer.handleClickCurrentButKeepFocus': wrapCommand(handleClickCurrentButKeepFocus),
@@ -6489,25 +6298,25 @@ const commandMap = {
6489
6298
  'Explorer.handleInputClick': wrapCommand(handleInputClick),
6490
6299
  'Explorer.handleInputKeyDown': wrapCommand(handleInputKeyDown),
6491
6300
  'Explorer.handleKeyDown': wrapCommand(handleKeyDown),
6492
- 'Explorer.handlePaste': wrapCommand(handlePaste),
6301
+ 'Explorer.handlePaste': wrapListItemCommand(handlePaste),
6493
6302
  'Explorer.handlePointerDown': wrapCommand(handlePointerDown),
6494
6303
  'Explorer.handleUpload': wrapCommand(handleUpload),
6495
6304
  'Explorer.handleWheel': wrapCommand(handleWheel),
6496
- 'Explorer.handleWorkspaceChange': wrapCommand(handleWorkspaceChange),
6497
- 'Explorer.loadContent': wrapCommand(loadContent),
6498
- 'Explorer.newFile': wrapCommand(newFile),
6499
- 'Explorer.newFolder': wrapCommand(newFolder),
6305
+ 'Explorer.handleWorkspaceChange': wrapListItemCommand(handleWorkspaceChange),
6306
+ 'Explorer.loadContent': wrapListItemCommand(loadContent),
6307
+ 'Explorer.newFile': wrapListItemCommand(newFile),
6308
+ 'Explorer.newFolder': wrapListItemCommand(newFolder),
6500
6309
  'Explorer.openContainingFolder': wrapCommand(openContainingFolder),
6501
- 'Explorer.refresh': wrapCommand(refresh),
6502
- 'Explorer.removeDirent': wrapCommand(removeDirent),
6503
- 'Explorer.renameDirent': wrapCommand(renameDirent),
6310
+ 'Explorer.refresh': wrapListItemCommand(refresh),
6311
+ 'Explorer.removeDirent': wrapListItemCommand(removeDirent),
6312
+ 'Explorer.renameDirent': wrapListItemCommand(renameDirent),
6504
6313
  'Explorer.restoreState': restoreState,
6505
6314
  'Explorer.revealItem': wrapCommand(revealItem),
6506
6315
  'Explorer.selectAll': wrapCommand(selectAll),
6507
6316
  'Explorer.selectDown': wrapCommand(selectDown),
6508
6317
  'Explorer.selectIndices': wrapCommand(setSelectedIndices),
6509
6318
  'Explorer.selectUp': wrapCommand(selectUp),
6510
- 'Explorer.setDeltaY': wrapCommand(setDeltaY),
6319
+ 'Explorer.setDeltaY': wrapListItemCommand(setDeltaY),
6511
6320
  'Explorer.setSelectedIndices': wrapCommand(setSelectedIndices),
6512
6321
  'Explorer.toggleIndividualSelection': wrapCommand(toggleIndividualSelection),
6513
6322
  'Explorer.updateEditingValue': wrapCommand(updateEditingValue),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "3.19.0",
3
+ "version": "3.20.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",