@lvce-editor/explorer-view 3.19.0 → 3.21.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.
@@ -1173,6 +1173,7 @@ const RendererWorker$1 = 1;
1173
1173
  const FocusElementByName = 'Viewlet.focusElementByName';
1174
1174
  const FocusSelector = 'Viewlet.focusSelector';
1175
1175
  const SetCss = 'Viewlet.setCss';
1176
+ const SetDom2 = 'Viewlet.setDom2';
1176
1177
  const SetFocusContext = 'Viewlet.setFocusContext';
1177
1178
 
1178
1179
  const FocusExplorer = 13;
@@ -1372,7 +1373,7 @@ const getWebViewSecret = async key => {
1372
1373
  const setWebViewPort = async (uid, port, origin, portType) => {
1373
1374
  return invokeAndTransfer('WebView.setPort', uid, port, origin, portType);
1374
1375
  };
1375
- const setFocus$1 = key => {
1376
+ const setFocus = key => {
1376
1377
  return invoke$2('Focus.setFocus', key);
1377
1378
  };
1378
1379
  const getFileIcon = async options => {
@@ -1632,7 +1633,7 @@ const RendererWorker = {
1632
1633
  setAdditionalFocus,
1633
1634
  setColorTheme,
1634
1635
  setExtensionsSearchValue,
1635
- setFocus: setFocus$1,
1636
+ setFocus,
1636
1637
  setWebViewPort,
1637
1638
  setWorkspacePath,
1638
1639
  showContextMenu: showContextMenu$1,
@@ -1798,94 +1799,6 @@ const Rename$1 = 3;
1798
1799
  const List = 1;
1799
1800
  const Input$1 = 2;
1800
1801
 
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
1802
  const getFileOperationsNestedPath = (path, root, pathSeparator) => {
1890
1803
  const parts = path.slice(root.length).split(pathSeparator);
1891
1804
  const operations = [];
@@ -2297,10 +2210,6 @@ const validateFileName2 = name => {
2297
2210
  const acceptCreate = async (state, newDirentType) => {
2298
2211
  const {
2299
2212
  editingValue,
2300
- minLineY,
2301
- height,
2302
- itemHeight,
2303
- fileIconCache,
2304
2213
  pathSeparator,
2305
2214
  root,
2306
2215
  focusedIndex,
@@ -2332,22 +2241,13 @@ const acceptCreate = async (state, newDirentType) => {
2332
2241
  const newItems = treeToArray(merged, root);
2333
2242
  const dirents = newItems;
2334
2243
  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
2244
  return {
2342
2245
  ...state,
2343
2246
  items: dirents,
2344
2247
  editingIndex: -1,
2345
2248
  focusedIndex: newFocusedIndex,
2346
2249
  editingType: None$5,
2347
- maxLineY,
2348
- focus: List,
2349
- icons,
2350
- fileIconCache: newFileIconCache
2250
+ focus: List
2351
2251
  };
2352
2252
  };
2353
2253
 
@@ -2402,11 +2302,7 @@ const acceptRename = async state => {
2402
2302
  editingIndex,
2403
2303
  editingValue,
2404
2304
  items,
2405
- root,
2406
- minLineY,
2407
- height,
2408
- itemHeight,
2409
- fileIconCache
2305
+ root
2410
2306
  } = state;
2411
2307
  const editingErrorMessage = validateFileName2(editingValue);
2412
2308
  if (editingErrorMessage) {
@@ -2433,12 +2329,6 @@ const acceptRename = async state => {
2433
2329
  const newTree = updateTree2(tree, update);
2434
2330
  const newDirents = treeToArray(newTree, root);
2435
2331
  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
2332
  return {
2443
2333
  ...state,
2444
2334
  editingIndex: -1,
@@ -2449,8 +2339,6 @@ const acceptRename = async state => {
2449
2339
  focused: true,
2450
2340
  focus: List,
2451
2341
  items: newDirents,
2452
- icons,
2453
- fileIconCache: newFileIconCache,
2454
2342
  editingSelectionEnd: 0,
2455
2343
  editingSelectionStart: 0
2456
2344
  };
@@ -2479,14 +2367,9 @@ const isNormalItem = item => {
2479
2367
  const cancelEditCreate = async (state, keepFocus) => {
2480
2368
  const {
2481
2369
  editingIndex,
2482
- items,
2483
- fileIconCache
2370
+ items
2484
2371
  } = state;
2485
2372
  const filteredItems = items.filter(isNormalItem);
2486
- const {
2487
- icons,
2488
- newFileIconCache
2489
- } = await getFileIcons(filteredItems, fileIconCache);
2490
2373
  return {
2491
2374
  ...state,
2492
2375
  items: filteredItems,
@@ -2496,9 +2379,7 @@ const cancelEditCreate = async (state, keepFocus) => {
2496
2379
  editingValue: '',
2497
2380
  editingErrorMessage: '',
2498
2381
  editingType: None$5,
2499
- focus: List,
2500
- icons,
2501
- fileIconCache: newFileIconCache
2382
+ focus: List
2502
2383
  };
2503
2384
  };
2504
2385
 
@@ -2573,25 +2454,12 @@ const toCollapsedDirent = dirent => {
2573
2454
 
2574
2455
  const collapseAll = async state => {
2575
2456
  const {
2576
- minLineY,
2577
- height,
2578
- itemHeight,
2579
- fileIconCache,
2580
2457
  items
2581
2458
  } = state;
2582
2459
  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
2460
  return {
2591
2461
  ...state,
2592
- items: newDirents,
2593
- icons,
2594
- fileIconCache: newFileIconCache
2462
+ items: newDirents
2595
2463
  };
2596
2464
  };
2597
2465
 
@@ -2641,6 +2509,94 @@ const copyRelativePath = async state => {
2641
2509
  return state;
2642
2510
  };
2643
2511
 
2512
+ // TODO optimize this function to return the minimum number
2513
+ // of visible items needed, e.g. when not scrolled 5 items with
2514
+ // 20px fill 100px but when scrolled 6 items are needed
2515
+ const getNumberOfVisibleItems = (listHeight, itemHeight) => {
2516
+ return Math.ceil(listHeight / itemHeight) + 1;
2517
+ };
2518
+
2519
+ const getExplorerMaxLineY = (minLineY, height, itemHeight, direntsLength) => {
2520
+ const maxLineY = minLineY + Math.min(getNumberOfVisibleItems(height, itemHeight), direntsLength);
2521
+ return maxLineY;
2522
+ };
2523
+
2524
+ const getIconsCached = (dirents, fileIconCache) => {
2525
+ return dirents.map(dirent => fileIconCache[dirent]);
2526
+ };
2527
+
2528
+ const getMissingIconRequests = (dirents, fileIconCache) => {
2529
+ const missingRequests = [];
2530
+ for (const dirent of dirents) {
2531
+ if (!(dirent.path in fileIconCache)) {
2532
+ missingRequests.push({
2533
+ type: dirent.type,
2534
+ name: dirent.name,
2535
+ path: dirent.path
2536
+ });
2537
+ }
2538
+ }
2539
+ return missingRequests;
2540
+ };
2541
+
2542
+ const getPath = item => {
2543
+ return item.path;
2544
+ };
2545
+
2546
+ const getPaths = items => {
2547
+ return items.map(getPath);
2548
+ };
2549
+
2550
+ const getSimpleIconRequestType = direntType => {
2551
+ if (direntType === Directory || direntType === DirectoryExpanded || direntType === EditingDirectoryExpanded || direntType === EditingFolder) {
2552
+ return 2;
2553
+ }
2554
+ return 1;
2555
+ };
2556
+
2557
+ const toSimpleIconRequest = request => {
2558
+ return {
2559
+ name: request.name,
2560
+ type: getSimpleIconRequestType(request.type)
2561
+ };
2562
+ };
2563
+
2564
+ const requestFileIcons = async requests => {
2565
+ if (requests.length === 0) {
2566
+ return [];
2567
+ }
2568
+ const simpleRequests = requests.map(toSimpleIconRequest);
2569
+ const icons = await invoke$1('IconTheme.getIcons', simpleRequests);
2570
+ return icons;
2571
+ };
2572
+
2573
+ const updateIconCache = (iconCache, missingRequests, newIcons) => {
2574
+ if (missingRequests.length === 0) {
2575
+ return iconCache;
2576
+ }
2577
+ const newFileIconCache = {
2578
+ ...iconCache
2579
+ };
2580
+ for (let i = 0; i < missingRequests.length; i++) {
2581
+ const request = missingRequests[i];
2582
+ const icon = newIcons[i];
2583
+ newFileIconCache[request.path] = icon;
2584
+ }
2585
+ return newFileIconCache;
2586
+ };
2587
+
2588
+ const getFileIcons = async (dirents, fileIconCache) => {
2589
+ const missingRequests = getMissingIconRequests(dirents, fileIconCache);
2590
+ const newIcons = await requestFileIcons(missingRequests);
2591
+ const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
2592
+ const paths = getPaths(dirents);
2593
+ const icons = getIconsCached(paths, newFileIconCache);
2594
+ return {
2595
+ icons,
2596
+ newFileIconCache
2597
+ };
2598
+ };
2599
+
2644
2600
  const None$4 = 0;
2645
2601
  const Right = 1;
2646
2602
  const Down = 2;
@@ -2821,11 +2777,57 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
2821
2777
  const {
2822
2778
  get,
2823
2779
  set,
2824
- wrapCommand,
2825
2780
  registerCommands,
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
+ if (items === intermediate.newState.items && minLineY === intermediate.newState.minLineY && editingIcon === intermediate.newState.editingIcon && cutItems === intermediate.newState.cutItems && editingErrorMessage === intermediate.newState.editingErrorMessage) {
2811
+ return;
2812
+ }
2813
+ const visible = items.slice(minLineY, maxLineY);
2814
+ const {
2815
+ icons,
2816
+ newFileIconCache
2817
+ } = await getFileIcons(visible, fileIconCache);
2818
+ const visibleExplorerItems = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
2819
+ const finalState = {
2820
+ ...updatedState,
2821
+ visibleExplorerItems,
2822
+ fileIconCache: newFileIconCache,
2823
+ icons,
2824
+ maxLineY
2825
+ };
2826
+ const intermediate2 = get(id);
2827
+ set(id, intermediate2.oldState, finalState);
2828
+ };
2829
+ return wrappedCommand;
2830
+ };
2829
2831
 
2830
2832
  const ListItem = 22;
2831
2833
 
@@ -3006,10 +3008,7 @@ const expandAll = async state => {
3006
3008
  const {
3007
3009
  items,
3008
3010
  focusedIndex,
3009
- pathSeparator,
3010
- minLineY,
3011
- height,
3012
- itemHeight
3011
+ pathSeparator
3013
3012
  } = state;
3014
3013
  if (focusedIndex === -1) {
3015
3014
  return state;
@@ -3040,18 +3039,9 @@ const expandAll = async state => {
3040
3039
  // await expand(state, dirent.index)
3041
3040
  }
3042
3041
  }
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
3042
  return {
3050
3043
  ...state,
3051
- items: newDirents,
3052
- icons,
3053
- fileIconCache: newFileIconCache,
3054
- maxLineY
3044
+ items: newDirents
3055
3045
  };
3056
3046
  };
3057
3047
 
@@ -3099,10 +3089,7 @@ const expandRecursively = async state => {
3099
3089
  items,
3100
3090
  focusedIndex,
3101
3091
  pathSeparator,
3102
- root,
3103
- height,
3104
- itemHeight,
3105
- minLineY
3092
+ root
3106
3093
  } = state;
3107
3094
  const dirent = focusedIndex < 0 ? {
3108
3095
  type: Directory,
@@ -3121,33 +3108,15 @@ const expandRecursively = async state => {
3121
3108
  if (focusedIndex >= 0) {
3122
3109
  const endIndex = getParentEndIndex(items, focusedIndex);
3123
3110
  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
3111
  return {
3131
3112
  ...state,
3132
- items: newDirents,
3133
- maxLineY,
3134
- icons,
3135
- fileIconCache: newFileIconCache
3113
+ items: newDirents
3136
3114
  };
3137
3115
  }
3138
3116
  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
3117
  return {
3146
3118
  ...state,
3147
- items: newDirents,
3148
- maxLineY,
3149
- icons,
3150
- fileIconCache: newFileIconCache
3119
+ items: newDirents
3151
3120
  };
3152
3121
  };
3153
3122
 
@@ -3551,17 +3520,6 @@ const handleClickDirectoryExpanded = async (state, dirent, index, keepFocus) =>
3551
3520
  minLineY,
3552
3521
  maxLineY,
3553
3522
  itemHeight,
3554
- fileIconCache,
3555
- cutItems,
3556
- sourceControlIgnoredUris,
3557
- dropTargets,
3558
- editingErrorMessage,
3559
- editingIcon,
3560
- editingIndex,
3561
- editingType,
3562
- editingValue,
3563
- focusedIndex,
3564
- useChevrons,
3565
3523
  items
3566
3524
  } = state;
3567
3525
  // @ts-ignore
@@ -3579,39 +3537,21 @@ const handleClickDirectoryExpanded = async (state, dirent, index, keepFocus) =>
3579
3537
  const newMaxLineY = Math.min(maxLineY, newTotal);
3580
3538
  const newMinLineY = newMaxLineY - visibleItems;
3581
3539
  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
3540
  return {
3589
3541
  ...state,
3590
3542
  deltaY,
3591
- fileIconCache: newFileIconCache,
3592
3543
  focused: keepFocus,
3593
3544
  focusedIndex: index,
3594
- icons,
3595
3545
  items: newDirents,
3596
3546
  maxLineY: newMaxLineY,
3597
- minLineY: newMinLineY,
3598
- visibleExplorerItems
3547
+ minLineY: newMinLineY
3599
3548
  };
3600
3549
  }
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
3550
  return {
3608
3551
  ...state,
3609
- fileIconCache: newFileIconCache,
3610
3552
  focused: keepFocus,
3611
3553
  focusedIndex: index,
3612
- icons,
3613
- items: newDirents,
3614
- visibleExplorerItems
3554
+ items: newDirents
3615
3555
  };
3616
3556
  };
3617
3557
 
@@ -3652,23 +3592,7 @@ const handleArrowRightDirectoryExpanded = (state, dirent) => {
3652
3592
  return state;
3653
3593
  };
3654
3594
 
3655
- const setFocus = key => {
3656
- return invoke$1('Focus.setFocus', key);
3657
- };
3658
-
3659
3595
  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
3596
  // @ts-ignore
3673
3597
  dirent.type = DirectoryExpanding;
3674
3598
  // TODO handle error
@@ -3689,31 +3613,14 @@ const handleClickDirectory = async (state, dirent, index, keepFocus) => {
3689
3613
  dirent.type = DirectoryExpanded;
3690
3614
  // @ts-ignore
3691
3615
  dirent.icon = '';
3692
- const {
3693
- height,
3694
- itemHeight,
3695
- minLineY
3696
- } = state2;
3697
3616
  // 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
3617
 
3706
- // TODO use functional focus rendering
3707
- await setFocus(FocusExplorer);
3708
3618
  return {
3709
3619
  ...state,
3710
- fileIconCache: newFileIconCache,
3711
3620
  focused: keepFocus,
3712
3621
  focusedIndex: newIndex,
3713
- icons,
3714
3622
  items: newDirents,
3715
- maxLineY,
3716
- visibleExplorerItems
3623
+ focus: List
3717
3624
  };
3718
3625
  };
3719
3626
 
@@ -4266,21 +4173,8 @@ const sortPathDirentsMap = map => {
4266
4173
  const refresh = async state => {
4267
4174
  const {
4268
4175
  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
4176
  focusedIndex,
4282
- items,
4283
- useChevrons
4177
+ items
4284
4178
  } = state;
4285
4179
  const expandedDirents = getExpandedDirents(items);
4286
4180
  const expandedPaths = getPaths(expandedDirents);
@@ -4288,25 +4182,14 @@ const refresh = async state => {
4288
4182
  const pathToDirents = await getPathDirentsMap(allPaths);
4289
4183
  const sortedPathDirents = sortPathDirentsMap(pathToDirents);
4290
4184
  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
4185
  let newFocusedIndex = focusedIndex;
4298
4186
  if (focusedIndex >= newItems.length) {
4299
4187
  newFocusedIndex = newItems.length - 1;
4300
4188
  }
4301
- const visibleExplorerItems = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
4302
4189
  return {
4303
4190
  ...state,
4304
- fileIconCache: newFileIconCache,
4305
4191
  focusedIndex: newFocusedIndex,
4306
- icons,
4307
- items: newItems,
4308
- maxLineY,
4309
- visibleExplorerItems
4192
+ items: newItems
4310
4193
  };
4311
4194
  };
4312
4195
 
@@ -4604,8 +4487,10 @@ const handleEscape = async state => {
4604
4487
  };
4605
4488
 
4606
4489
  const handleFocus = async state => {
4607
- await setFocus(FocusExplorer);
4608
- return state;
4490
+ return {
4491
+ ...state,
4492
+ focus: List
4493
+ };
4609
4494
  };
4610
4495
 
4611
4496
  const updateIcons = async state => {
@@ -4954,9 +4839,8 @@ const handlePaste = async state => {
4954
4839
  // Use the pasteShouldMove flag to determine whether to cut or copy
4955
4840
  if (state.pasteShouldMove) {
4956
4841
  return handlePasteCut(state, nativeFiles);
4957
- } else {
4958
- return handlePasteCopy(state, nativeFiles);
4959
4842
  }
4843
+ return handlePasteCopy(state, nativeFiles);
4960
4844
  };
4961
4845
 
4962
4846
  const handlePointerDown = (state, button, x, y) => {
@@ -4994,17 +4878,7 @@ const handleUpload = async (state, dirents) => {
4994
4878
  const setDeltaY = async (state, deltaY) => {
4995
4879
  const {
4996
4880
  itemHeight,
4997
- useChevrons,
4998
4881
  height,
4999
- cutItems,
5000
- sourceControlIgnoredUris,
5001
- dropTargets,
5002
- editingErrorMessage,
5003
- editingIcon,
5004
- editingIndex,
5005
- editingType,
5006
- editingValue,
5007
- focusedIndex,
5008
4882
  items
5009
4883
  } = state;
5010
4884
  if (deltaY < 0) {
@@ -5017,20 +4891,11 @@ const setDeltaY = async (state, deltaY) => {
5017
4891
  }
5018
4892
  const minLineY = Math.round(deltaY / itemHeight);
5019
4893
  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
4894
  return {
5027
4895
  ...state,
5028
4896
  deltaY,
5029
- fileIconCache: newFileIconCache,
5030
- icons,
5031
4897
  maxLineY,
5032
- minLineY,
5033
- visibleExplorerItems
4898
+ minLineY
5034
4899
  };
5035
4900
  };
5036
4901
 
@@ -5176,18 +5041,6 @@ const getSavedRoot = (savedState, workspacePath) => {
5176
5041
  return workspacePath;
5177
5042
  };
5178
5043
  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
5044
  const {
5192
5045
  useChevrons,
5193
5046
  confirmDelete
@@ -5198,10 +5051,6 @@ const loadContent = async (state, savedState) => {
5198
5051
  const pathSeparator = await getPathSeparator(root); // TODO only load path separator once
5199
5052
  const excluded = getExcluded();
5200
5053
  const restoredDirents = await restoreExpandedState(savedState, root, pathSeparator, excluded);
5201
- const {
5202
- itemHeight,
5203
- height
5204
- } = state;
5205
5054
  let minLineY = 0;
5206
5055
  if (savedState && typeof savedState.minLineY === 'number') {
5207
5056
  minLineY = savedState.minLineY;
@@ -5210,28 +5059,17 @@ const loadContent = async (state, savedState) => {
5210
5059
  if (savedState && typeof savedState.deltaY === 'number') {
5211
5060
  deltaY = savedState.deltaY;
5212
5061
  }
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
5062
  return {
5221
5063
  ...state,
5222
5064
  confirmDelete,
5223
5065
  deltaY,
5224
5066
  excluded,
5225
- fileIconCache: newFileIconCache,
5226
- icons,
5227
5067
  items: restoredDirents,
5228
5068
  maxIndent: 10,
5229
- maxLineY,
5230
5069
  minLineY,
5231
5070
  pathSeparator,
5232
5071
  root,
5233
- useChevrons,
5234
- visibleExplorerItems
5072
+ useChevrons
5235
5073
  };
5236
5074
  };
5237
5075
 
@@ -5270,8 +5108,6 @@ const initialize = async () => {
5270
5108
  await initializeFileSystemWorker();
5271
5109
  };
5272
5110
 
5273
- const ExplorerEditBox = FocusExplorerEditBox;
5274
-
5275
5111
  const getNewChildDirentsForNewDirent = async (items, depth, parentPath, direntType) => {
5276
5112
  // Get existing children or query them if they don't exist
5277
5113
  let existingChildren = items.filter(item => item.depth === depth && item.path.startsWith(parentPath));
@@ -5364,48 +5200,24 @@ const getFittingIndex = (dirents, startIndex) => {
5364
5200
  return -1;
5365
5201
  };
5366
5202
  const newDirent = async (state, editingType) => {
5367
- // TODO make focus functional instead of side effect
5368
- await setFocus(ExplorerEditBox);
5369
5203
  // TODO do it like vscode, select position between folders and files
5370
5204
  const {
5371
- minLineY,
5372
- height,
5373
- itemHeight,
5374
5205
  root,
5375
- fileIconCache,
5376
- cutItems,
5377
- sourceControlIgnoredUris,
5378
- dropTargets,
5379
- editingErrorMessage,
5380
- editingIcon,
5381
- editingValue,
5382
5206
  focusedIndex,
5383
- items,
5384
- useChevrons
5207
+ items
5385
5208
  } = state;
5386
5209
  const index = getFittingIndex(items, focusedIndex);
5387
5210
  const direntType = getNewDirentType(editingType);
5388
5211
  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
5212
  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
5213
  return {
5398
5214
  ...state,
5399
5215
  editingIndex,
5400
5216
  editingType,
5401
5217
  editingValue: '',
5402
- fileIconCache: newFileIconCache,
5403
5218
  focus: Input$1,
5404
5219
  focusedIndex: editingIndex,
5405
- icons,
5406
- items: newDirents,
5407
- maxLineY,
5408
- visibleExplorerItems
5220
+ items: newDirents
5409
5221
  };
5410
5222
  };
5411
5223
 
@@ -5524,7 +5336,7 @@ const getRenameSelectionRange = name => {
5524
5336
  const User = 1;
5525
5337
  const Script = 2;
5526
5338
 
5527
- const renameDirent = state => {
5339
+ const renameDirent = async state => {
5528
5340
  const {
5529
5341
  focusedIndex,
5530
5342
  items,
@@ -5932,28 +5744,19 @@ const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused
5932
5744
 
5933
5745
  const renderItems = (oldState, newState) => {
5934
5746
  const {
5935
- cutItems,
5936
- sourceControlIgnoredUris,
5937
5747
  deltaY,
5938
5748
  dropTargets,
5939
5749
  editingErrorMessage,
5940
- editingIcon,
5941
- editingIndex,
5942
- editingType,
5943
- editingValue,
5944
5750
  focused,
5945
5751
  focusedIndex,
5946
5752
  height,
5947
- icons,
5948
5753
  itemHeight,
5949
5754
  items,
5950
- maxLineY,
5951
5755
  minLineY,
5952
5756
  root,
5953
- useChevrons,
5954
5757
  width
5955
5758
  } = newState;
5956
- const visibleDirents = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
5759
+ const visibleDirents = newState.visibleExplorerItems;
5957
5760
  const isWide = width > 450;
5958
5761
  const contentHeight = items.length * itemHeight;
5959
5762
  const depth = items[focusedIndex]?.depth || 0;
@@ -5967,7 +5770,7 @@ const renderItems = (oldState, newState) => {
5967
5770
  left
5968
5771
  } = getErrorMessagePosition(itemHeight, focusedIndex, minLineY, depth, indent, fileIconWidth, padding + defaultPaddingLeft + chevronSpace);
5969
5772
  const dom = getExplorerVirtualDom(visibleDirents, focusedIndex, root, isWide, focused, dropTargets, height, contentHeight, deltaY, editingErrorMessage, top, left);
5970
- return ['Viewlet.setDom2', dom];
5773
+ return [SetDom2, dom];
5971
5774
  };
5972
5775
 
5973
5776
  const renderValue = (oldState, newState) => {
@@ -6447,71 +6250,71 @@ const updateEditingValue = async (state, value, inputSource = User) => {
6447
6250
  };
6448
6251
 
6449
6252
  const commandMap = {
6450
- 'Explorer.acceptEdit': wrapCommand(acceptEdit),
6451
- 'Explorer.cancelEdit': wrapCommand(cancelEdit),
6452
- 'Explorer.cancelTypeAhead': wrapCommand(cancelTypeAhead),
6453
- 'Explorer.collapseAll': wrapCommand(collapseAll),
6454
- 'Explorer.copyPath': wrapCommand(copyPath),
6455
- 'Explorer.copyRelativePath': wrapCommand(copyRelativePath),
6456
- 'Explorer.expandAll': wrapCommand(expandAll),
6457
- 'Explorer.expandRecursively': wrapCommand(expandRecursively),
6458
- 'Explorer.focus': wrapCommand(focus),
6459
- 'Explorer.focusFirst': wrapCommand(focusFirst),
6460
- 'Explorer.focusIndex': wrapCommand(focusIndex),
6461
- 'Explorer.focusLast': wrapCommand(focusLast),
6462
- 'Explorer.handleDragStart': wrapCommand(handleDragStart),
6463
- 'Explorer.handleDragOverIndex': wrapCommand(handleDragOverIndex),
6464
- 'Explorer.focusNext': wrapCommand(focusNext),
6465
- 'Explorer.focusNone': wrapCommand(focusNone),
6466
- 'Explorer.focusPrevious': wrapCommand(focusPrevious),
6253
+ 'Explorer.acceptEdit': wrapListItemCommand(acceptEdit),
6254
+ 'Explorer.cancelEdit': wrapListItemCommand(cancelEdit),
6255
+ 'Explorer.cancelTypeAhead': wrapListItemCommand(cancelTypeAhead),
6256
+ 'Explorer.collapseAll': wrapListItemCommand(collapseAll),
6257
+ 'Explorer.copyPath': wrapListItemCommand(copyPath),
6258
+ 'Explorer.copyRelativePath': wrapListItemCommand(copyRelativePath),
6259
+ 'Explorer.expandAll': wrapListItemCommand(expandAll),
6260
+ 'Explorer.expandRecursively': wrapListItemCommand(expandRecursively),
6261
+ 'Explorer.focus': wrapListItemCommand(focus),
6262
+ 'Explorer.focusFirst': wrapListItemCommand(focusFirst),
6263
+ 'Explorer.focusIndex': wrapListItemCommand(focusIndex),
6264
+ 'Explorer.focusLast': wrapListItemCommand(focusLast),
6265
+ 'Explorer.handleDragStart': wrapListItemCommand(handleDragStart),
6266
+ 'Explorer.handleDragOverIndex': wrapListItemCommand(handleDragOverIndex),
6267
+ 'Explorer.focusNext': wrapListItemCommand(focusNext),
6268
+ 'Explorer.focusNone': wrapListItemCommand(focusNone),
6269
+ 'Explorer.focusPrevious': wrapListItemCommand(focusPrevious),
6467
6270
  'Explorer.getCommandIds': getCommandIds,
6468
6271
  'Explorer.getMenuEntries2': getMenuEntries2,
6469
6272
  'Explorer.getMouseActions': getMouseActions,
6470
- 'Explorer.handleArrowLeft': wrapCommand(handleArrowLeft),
6471
- 'Explorer.handleArrowRight': wrapCommand(handleArrowRight),
6472
- 'Explorer.handleEscape': wrapCommand(handleEscape),
6473
- 'Explorer.handleBlur': wrapCommand(handleBlur),
6474
- 'Explorer.handleClick': wrapCommand(handleClick),
6475
- 'Explorer.handleClickAt': wrapCommand(handleClickAt),
6476
- 'Explorer.handleClickCurrent': wrapCommand(handleClickCurrent),
6477
- 'Explorer.handleClickCurrentButKeepFocus': wrapCommand(handleClickCurrentButKeepFocus),
6478
- 'Explorer.handleClickOpenFolder': wrapCommand(handleClickOpenFolder),
6479
- 'Explorer.handleContextMenu': wrapCommand(handleContextMenu),
6480
- 'Explorer.handleContextMenuKeyboard': wrapCommand(handleContextMenuKeyboard),
6481
- 'Explorer.handleCopy': wrapCommand(handleCopy),
6482
- 'Explorer.handleCut': wrapCommand(handleCut),
6483
- 'Explorer.handleDragLeave': wrapCommand(handleDragLeave),
6484
- 'Explorer.handleDragOver': wrapCommand(handleDragOver),
6485
- 'Explorer.handleDrop': wrapCommand(handleDrop),
6486
- 'Explorer.handleFocus': wrapCommand(handleFocus),
6487
- 'Explorer.handleIconThemeChange': wrapCommand(handleIconThemeChange),
6488
- 'Explorer.handleInputBlur': wrapCommand(handleInputBlur),
6489
- 'Explorer.handleInputClick': wrapCommand(handleInputClick),
6490
- 'Explorer.handleInputKeyDown': wrapCommand(handleInputKeyDown),
6491
- 'Explorer.handleKeyDown': wrapCommand(handleKeyDown),
6492
- 'Explorer.handlePaste': wrapCommand(handlePaste),
6493
- 'Explorer.handlePointerDown': wrapCommand(handlePointerDown),
6494
- 'Explorer.handleUpload': wrapCommand(handleUpload),
6495
- 'Explorer.handleWheel': wrapCommand(handleWheel),
6496
- 'Explorer.handleWorkspaceChange': wrapCommand(handleWorkspaceChange),
6497
- 'Explorer.loadContent': wrapCommand(loadContent),
6498
- 'Explorer.newFile': wrapCommand(newFile),
6499
- 'Explorer.newFolder': wrapCommand(newFolder),
6500
- 'Explorer.openContainingFolder': wrapCommand(openContainingFolder),
6501
- 'Explorer.refresh': wrapCommand(refresh),
6502
- 'Explorer.removeDirent': wrapCommand(removeDirent),
6503
- 'Explorer.renameDirent': wrapCommand(renameDirent),
6273
+ 'Explorer.handleArrowLeft': wrapListItemCommand(handleArrowLeft),
6274
+ 'Explorer.handleArrowRight': wrapListItemCommand(handleArrowRight),
6275
+ 'Explorer.handleEscape': wrapListItemCommand(handleEscape),
6276
+ 'Explorer.handleBlur': wrapListItemCommand(handleBlur),
6277
+ 'Explorer.handleClick': wrapListItemCommand(handleClick),
6278
+ 'Explorer.handleClickAt': wrapListItemCommand(handleClickAt),
6279
+ 'Explorer.handleClickCurrent': wrapListItemCommand(handleClickCurrent),
6280
+ 'Explorer.handleClickCurrentButKeepFocus': wrapListItemCommand(handleClickCurrentButKeepFocus),
6281
+ 'Explorer.handleClickOpenFolder': wrapListItemCommand(handleClickOpenFolder),
6282
+ 'Explorer.handleContextMenu': wrapListItemCommand(handleContextMenu),
6283
+ 'Explorer.handleContextMenuKeyboard': wrapListItemCommand(handleContextMenuKeyboard),
6284
+ 'Explorer.handleCopy': wrapListItemCommand(handleCopy),
6285
+ 'Explorer.handleCut': wrapListItemCommand(handleCut),
6286
+ 'Explorer.handleDragLeave': wrapListItemCommand(handleDragLeave),
6287
+ 'Explorer.handleDragOver': wrapListItemCommand(handleDragOver),
6288
+ 'Explorer.handleDrop': wrapListItemCommand(handleDrop),
6289
+ 'Explorer.handleFocus': wrapListItemCommand(handleFocus),
6290
+ 'Explorer.handleIconThemeChange': wrapListItemCommand(handleIconThemeChange),
6291
+ 'Explorer.handleInputBlur': wrapListItemCommand(handleInputBlur),
6292
+ 'Explorer.handleInputClick': wrapListItemCommand(handleInputClick),
6293
+ 'Explorer.handleInputKeyDown': wrapListItemCommand(handleInputKeyDown),
6294
+ 'Explorer.handleKeyDown': wrapListItemCommand(handleKeyDown),
6295
+ 'Explorer.handlePaste': wrapListItemCommand(handlePaste),
6296
+ 'Explorer.handlePointerDown': wrapListItemCommand(handlePointerDown),
6297
+ 'Explorer.handleUpload': wrapListItemCommand(handleUpload),
6298
+ 'Explorer.handleWheel': wrapListItemCommand(handleWheel),
6299
+ 'Explorer.handleWorkspaceChange': wrapListItemCommand(handleWorkspaceChange),
6300
+ 'Explorer.loadContent': wrapListItemCommand(loadContent),
6301
+ 'Explorer.newFile': wrapListItemCommand(newFile),
6302
+ 'Explorer.newFolder': wrapListItemCommand(newFolder),
6303
+ 'Explorer.openContainingFolder': wrapListItemCommand(openContainingFolder),
6304
+ 'Explorer.refresh': wrapListItemCommand(refresh),
6305
+ 'Explorer.removeDirent': wrapListItemCommand(removeDirent),
6306
+ 'Explorer.renameDirent': wrapListItemCommand(renameDirent),
6504
6307
  'Explorer.restoreState': restoreState,
6505
- 'Explorer.revealItem': wrapCommand(revealItem),
6506
- 'Explorer.selectAll': wrapCommand(selectAll),
6507
- 'Explorer.selectDown': wrapCommand(selectDown),
6508
- 'Explorer.selectIndices': wrapCommand(setSelectedIndices),
6509
- 'Explorer.selectUp': wrapCommand(selectUp),
6510
- 'Explorer.setDeltaY': wrapCommand(setDeltaY),
6511
- 'Explorer.setSelectedIndices': wrapCommand(setSelectedIndices),
6512
- 'Explorer.toggleIndividualSelection': wrapCommand(toggleIndividualSelection),
6513
- 'Explorer.updateEditingValue': wrapCommand(updateEditingValue),
6514
- 'Explorer.updateIcons': wrapCommand(updateIcons),
6308
+ 'Explorer.revealItem': wrapListItemCommand(revealItem),
6309
+ 'Explorer.selectAll': wrapListItemCommand(selectAll),
6310
+ 'Explorer.selectDown': wrapListItemCommand(selectDown),
6311
+ 'Explorer.selectIndices': wrapListItemCommand(setSelectedIndices),
6312
+ 'Explorer.selectUp': wrapListItemCommand(selectUp),
6313
+ 'Explorer.setDeltaY': wrapListItemCommand(setDeltaY),
6314
+ 'Explorer.setSelectedIndices': wrapListItemCommand(setSelectedIndices),
6315
+ 'Explorer.toggleIndividualSelection': wrapListItemCommand(toggleIndividualSelection),
6316
+ 'Explorer.updateEditingValue': wrapListItemCommand(updateEditingValue),
6317
+ 'Explorer.updateIcons': wrapListItemCommand(updateIcons),
6515
6318
  // not wrapped
6516
6319
  'Explorer.create2': create2,
6517
6320
  'Explorer.diff2': diff2,
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.21.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",