@lvce-editor/explorer-view 5.4.0 → 5.6.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.
@@ -1393,14 +1393,14 @@ const copy$1 = async (oldUri, newUri) => {
1393
1393
 
1394
1394
  const applyOperation = operation => {
1395
1395
  switch (operation.type) {
1396
- case CreateFolder$1:
1397
- return mkdir(operation.path);
1398
1396
  case Copy$1:
1399
1397
  return copy$1(operation.from || '', operation.path);
1400
- case Rename$2:
1401
- return rename$1(operation.from || '', operation.path);
1398
+ case CreateFolder$1:
1399
+ return mkdir(operation.path);
1402
1400
  case Remove:
1403
1401
  return remove(operation.path);
1402
+ case Rename$2:
1403
+ return rename$1(operation.from || '', operation.path);
1404
1404
  default:
1405
1405
  return writeFile(operation.path, operation.text);
1406
1406
  }
@@ -1473,9 +1473,9 @@ const createTree = (items, root) => {
1473
1473
  });
1474
1474
  for (const item of items) {
1475
1475
  const {
1476
- type,
1477
1476
  name,
1478
- path
1477
+ path,
1478
+ type
1479
1479
  } = item;
1480
1480
  const relativePath = path.slice(rootLength);
1481
1481
  const dirname = dirname2(relativePath);
@@ -1506,8 +1506,8 @@ const getFileOperationsNestedPath = (path, root, pathSeparator) => {
1506
1506
  if (!part) continue;
1507
1507
  currentPath = join2(currentPath, part);
1508
1508
  operations.push({
1509
- type: CreateFolder$1,
1510
- path: join2(root, currentPath)
1509
+ path: join2(root, currentPath),
1510
+ type: CreateFolder$1
1511
1511
  });
1512
1512
  }
1513
1513
  return operations;
@@ -1518,14 +1518,14 @@ const getFileOperationsCreate = (newFileName, newDirentType, pathSeparator, abso
1518
1518
  operations.push(...getFileOperationsNestedPath(parentPath, root, pathSeparator));
1519
1519
  if (newDirentType === File) {
1520
1520
  operations.push({
1521
- type: CreateFile$1,
1522
1521
  path: absolutePath,
1523
- text: ''
1522
+ text: '',
1523
+ type: CreateFile$1
1524
1524
  });
1525
1525
  } else if (newDirentType === Directory) {
1526
1526
  operations.push({
1527
- type: CreateFolder$1,
1528
- path: absolutePath
1527
+ path: absolutePath,
1528
+ type: CreateFolder$1
1529
1529
  });
1530
1530
  }
1531
1531
  return operations;
@@ -1555,11 +1555,11 @@ const getPathParts = (root, uri, pathSeparator) => {
1555
1555
  while ((index = uri.indexOf(pathSeparator, index + 1)) !== -1) {
1556
1556
  const partUri = uri.slice(0, index);
1557
1557
  parts.push({
1558
- path: partUri,
1559
1558
  depth: depth++,
1560
- root,
1559
+ expanded: true,
1560
+ path: partUri,
1561
1561
  pathSeparator,
1562
- expanded: true
1562
+ root
1563
1563
  });
1564
1564
  }
1565
1565
  return parts;
@@ -1577,10 +1577,10 @@ const ENOENT = 'ENOENT';
1577
1577
 
1578
1578
  const getSymlinkType = type => {
1579
1579
  switch (type) {
1580
- case File:
1581
- return SymLinkFile;
1582
1580
  case Directory:
1583
1581
  return SymLinkFolder;
1582
+ case File:
1583
+ return SymLinkFile;
1584
1584
  default:
1585
1585
  return Symlink;
1586
1586
  }
@@ -1645,11 +1645,11 @@ const compareStringNumeric = (a, b) => {
1645
1645
 
1646
1646
  const priorityMapFoldersFirst = {
1647
1647
  [Directory]: 1,
1648
- [SymLinkFolder]: 1,
1649
1648
  [File]: 0,
1649
+ [Socket]: 0,
1650
1650
  [SymLinkFile]: 0,
1651
- [Unknown]: 0,
1652
- [Socket]: 0
1651
+ [SymLinkFolder]: 1,
1652
+ [Unknown]: 0
1653
1653
  };
1654
1654
  const compareDirentType = (direntA, direntB) => {
1655
1655
  return priorityMapFoldersFirst[direntB.type] - priorityMapFoldersFirst[direntA.type];
@@ -1669,15 +1669,15 @@ const sortExplorerItems = rawDirents => {
1669
1669
  const toDisplayDirent = (parentPath, parentDepth, rawDirentType, rawDirentName, index, length) => {
1670
1670
  const path = join2(parentPath, rawDirentName);
1671
1671
  return {
1672
- name: rawDirentName,
1673
- posInSet: index + 1,
1674
- setSize: length,
1675
1672
  depth: parentDepth + 1,
1676
- type: rawDirentType,
1673
+ icon: '',
1674
+ name: rawDirentName,
1677
1675
  path,
1678
1676
  // TODO storing absolute path might be too costly, could also store relative path here
1679
- icon: '',
1680
- selected: false
1677
+ posInSet: index + 1,
1678
+ selected: false,
1679
+ setSize: length,
1680
+ type: rawDirentType
1681
1681
  };
1682
1682
  };
1683
1683
 
@@ -1773,6 +1773,15 @@ const mergeTrees = (a, b) => {
1773
1773
  };
1774
1774
  };
1775
1775
 
1776
+ const refreshWorkspace = async () => {
1777
+ // TODO maybe pass an application id to this?
1778
+ try {
1779
+ await invoke$2('Layout.handleWorkspaceRefresh');
1780
+ } catch {
1781
+ // ignore
1782
+ }
1783
+ };
1784
+
1776
1785
  const treeToArrayInternal = (map, root, items, path, depth) => {
1777
1786
  const children = map[path];
1778
1787
  if (!children) {
@@ -1785,12 +1794,12 @@ const treeToArrayInternal = (map, root, items, path, depth) => {
1785
1794
  const absolutePath = join2(root, childPath);
1786
1795
  items.push({
1787
1796
  depth,
1788
- posInSet: i + 1,
1789
- setSize: count,
1790
1797
  icon: '',
1798
+ name: child.name,
1791
1799
  path: absolutePath,
1800
+ posInSet: i + 1,
1792
1801
  selected: false,
1793
- name: child.name,
1802
+ setSize: count,
1794
1803
  type: child.type
1795
1804
  });
1796
1805
  treeToArrayInternal(map, root, items, childPath, depth + 1);
@@ -1805,7 +1814,6 @@ const treeToArray = (map, root) => {
1805
1814
 
1806
1815
  const EmptyString = '';
1807
1816
  const Slash$1 = '/';
1808
- const Dot = '.';
1809
1817
  const BackSlash = '\\';
1810
1818
 
1811
1819
  const emptyObject = {};
@@ -1829,7 +1837,6 @@ const Delete = 'Delete';
1829
1837
  const FileNameCannotStartWithSlash = 'A file or folder name cannot start with a slash.';
1830
1838
  const FileOrFolderAlreadyExists = 'A file or folder **{PH1}** already exists at this location. Please choose a different name.';
1831
1839
  const FileOrFolderNameMustBeProvider = 'A file or folder name must be provided.';
1832
- const FileCannotStartWithDot = 'A file or folder name cannot start with a dot.';
1833
1840
  const FileCannotStartWithBackSlash = 'A file or folder name cannot start with a backslash.';
1834
1841
  const FilesExplorer = 'Files Explorer';
1835
1842
  const NewFile$1 = 'New File...';
@@ -1840,6 +1847,7 @@ const OpenInIntegratedTerminal = 'Open in integrated Terminal';
1840
1847
  const Paste = 'Paste';
1841
1848
  const RefreshExplorer = 'Refresh Explorer';
1842
1849
  const Rename = 'Rename';
1850
+ const TheNameIsNotValid = 'The name **{0}** is not valid as a file or folder name. Please choose a different name.';
1843
1851
  const TypeAFileName = 'Type file name. Press Enter to confirm or Escape to cancel.'; // TODO use keybinding
1844
1852
  const YouHaveNotYetOpenedAFolder = 'You have not yet opened a folder';
1845
1853
 
@@ -1897,9 +1905,6 @@ const fileOrFolderNameMustBeProvided = () => {
1897
1905
  const fileCannotStartWithSlash = () => {
1898
1906
  return i18nString(FileNameCannotStartWithSlash);
1899
1907
  };
1900
- const fileCannotStartWithDot = () => {
1901
- return i18nString(FileCannotStartWithDot);
1902
- };
1903
1908
  const fileCannotStartWithBackSlash = () => {
1904
1909
  return i18nString(FileCannotStartWithBackSlash);
1905
1910
  };
@@ -1911,15 +1916,15 @@ const fileOrFolderAlreadyExists = name => {
1911
1916
  PH1: name
1912
1917
  });
1913
1918
  };
1919
+ const theNameIsNotValid = () => {
1920
+ return i18nString(TheNameIsNotValid);
1921
+ };
1914
1922
 
1915
1923
  const validateFileName2 = (name, siblingFileNames = []) => {
1916
1924
  if (!name) {
1917
1925
  const editingErrorMessage = fileOrFolderNameMustBeProvided();
1918
1926
  return editingErrorMessage;
1919
1927
  }
1920
- if (name.startsWith(Dot)) {
1921
- return fileCannotStartWithDot();
1922
- }
1923
1928
  if (name.startsWith(Slash$1)) {
1924
1929
  return fileCannotStartWithSlash();
1925
1930
  }
@@ -1927,6 +1932,16 @@ const validateFileName2 = (name, siblingFileNames = []) => {
1927
1932
  return fileCannotStartWithBackSlash();
1928
1933
  }
1929
1934
 
1935
+ // Disallow reserved directory names
1936
+ if (name === '.' || name === '..' || name === '...') {
1937
+ return theNameIsNotValid();
1938
+ }
1939
+
1940
+ // Disallow any filename starting with ../
1941
+ if (name.startsWith('../')) {
1942
+ return theNameIsNotValid();
1943
+ }
1944
+
1930
1945
  // Check if file already exists
1931
1946
  if (siblingFileNames.includes(name)) {
1932
1947
  return fileOrFolderAlreadyExists(name);
@@ -1937,10 +1952,10 @@ const validateFileName2 = (name, siblingFileNames = []) => {
1937
1952
  const acceptCreate = async (state, newDirentType) => {
1938
1953
  const {
1939
1954
  editingValue,
1940
- pathSeparator,
1941
- root,
1942
1955
  focusedIndex,
1943
- items
1956
+ items,
1957
+ pathSeparator,
1958
+ root
1944
1959
  } = state;
1945
1960
  const newFileName = editingValue;
1946
1961
  const siblingFileNames = getSiblingFileNames(items, focusedIndex);
@@ -1969,13 +1984,14 @@ const acceptCreate = async (state, newDirentType) => {
1969
1984
  const newItems = treeToArray(merged, root);
1970
1985
  const dirents = newItems;
1971
1986
  const newFocusedIndex = getIndex(newItems, absolutePath);
1987
+ await refreshWorkspace();
1972
1988
  return {
1973
1989
  ...state,
1974
- items: dirents,
1975
1990
  editingIndex: -1,
1976
- focusedIndex: newFocusedIndex,
1977
1991
  editingType: None$5,
1978
- focus: List
1992
+ focus: List,
1993
+ focusedIndex: newFocusedIndex,
1994
+ items: dirents
1979
1995
  };
1980
1996
  };
1981
1997
 
@@ -2010,9 +2026,9 @@ const getFileOperationsRename = (oldAbsolutePath, newFileName) => {
2010
2026
  const oldParentPath = dirname2(oldAbsolutePath);
2011
2027
  const newAbsolutePath = join2(oldParentPath, newFileName);
2012
2028
  operations.push({
2013
- type: Rename$2,
2029
+ from: oldAbsolutePath,
2014
2030
  path: newAbsolutePath,
2015
- from: oldAbsolutePath
2031
+ type: Rename$2
2016
2032
  });
2017
2033
  return operations;
2018
2034
  };
@@ -2059,16 +2075,16 @@ const acceptRename = async state => {
2059
2075
  const newFocusedIndex = getIndex(newDirents, newUri);
2060
2076
  return {
2061
2077
  ...state,
2078
+ editingIcon: '',
2062
2079
  editingIndex: -1,
2063
- editingValue: '',
2080
+ editingSelectionEnd: 0,
2081
+ editingSelectionStart: 0,
2064
2082
  editingType: None$5,
2065
- editingIcon: '',
2066
- focusedIndex: newFocusedIndex,
2067
- focused: true,
2083
+ editingValue: '',
2068
2084
  focus: List,
2069
- items: newDirents,
2070
- editingSelectionEnd: 0,
2071
- editingSelectionStart: 0
2085
+ focused: true,
2086
+ focusedIndex: newFocusedIndex,
2087
+ items: newDirents
2072
2088
  };
2073
2089
  };
2074
2090
 
@@ -2088,6 +2104,11 @@ const acceptEdit = async state => {
2088
2104
  }
2089
2105
  };
2090
2106
 
2107
+ const getFocusedIndexCancel = (items, editingIndex) => {
2108
+ const newFocusedIndex = editingIndex > items.length ? items.length - 1 : editingIndex;
2109
+ return newFocusedIndex;
2110
+ };
2111
+
2091
2112
  const isNormalItem = item => {
2092
2113
  return item.type !== EditingFile && item.type !== EditingFolder;
2093
2114
  };
@@ -2098,16 +2119,17 @@ const cancelEditCreate = async (state, keepFocus) => {
2098
2119
  items
2099
2120
  } = state;
2100
2121
  const filteredItems = items.filter(isNormalItem);
2122
+ const newFocusedIndex = getFocusedIndexCancel(items, editingIndex);
2101
2123
  return {
2102
2124
  ...state,
2103
- items: filteredItems,
2104
- focusedIndex: editingIndex,
2105
- focused: keepFocus,
2106
- editingIndex: -1,
2107
- editingValue: '',
2108
2125
  editingErrorMessage: '',
2126
+ editingIndex: -1,
2109
2127
  editingType: None$5,
2110
- focus: List
2128
+ editingValue: '',
2129
+ focus: List,
2130
+ focused: keepFocus,
2131
+ focusedIndex: newFocusedIndex,
2132
+ items: filteredItems
2111
2133
  };
2112
2134
  };
2113
2135
 
@@ -2134,18 +2156,19 @@ const cancelEditRename = (state, keepFocus) => {
2134
2156
  items
2135
2157
  } = state;
2136
2158
  const newItems = getNewDirentsForCancelRename(items, editingIndex);
2159
+ const newFocusedIndex = getFocusedIndexCancel(items, editingIndex);
2137
2160
  return {
2138
2161
  ...state,
2139
- items: newItems,
2140
- focusedIndex: editingIndex,
2141
- focused: keepFocus,
2162
+ editingErrorMessage: '',
2142
2163
  editingIndex: -1,
2143
- editingValue: '',
2164
+ editingSelectionEnd: 0,
2165
+ editingSelectionStart: 0,
2144
2166
  editingType: None$5,
2145
- editingErrorMessage: '',
2167
+ editingValue: '',
2146
2168
  focus: List,
2147
- editingSelectionStart: 0,
2148
- editingSelectionEnd: 0
2169
+ focused: keepFocus,
2170
+ focusedIndex: newFocusedIndex,
2171
+ items: newItems
2149
2172
  };
2150
2173
  };
2151
2174
 
@@ -2194,8 +2217,8 @@ const collapseAll = async state => {
2194
2217
  const getFocusedDirent$1 = state => {
2195
2218
  const {
2196
2219
  focusedIndex,
2197
- minLineY,
2198
- items
2220
+ items,
2221
+ minLineY
2199
2222
  } = state;
2200
2223
  const dirent = items[focusedIndex + minLineY];
2201
2224
  return dirent;
@@ -2267,9 +2290,9 @@ const getMissingDirents = (dirents, fileIconCache) => {
2267
2290
  };
2268
2291
  const toIconRequest = dirent => {
2269
2292
  return {
2270
- type: dirent.type,
2271
2293
  name: dirent.name,
2272
- path: dirent.path
2294
+ path: dirent.path,
2295
+ type: dirent.type
2273
2296
  };
2274
2297
  };
2275
2298
  const getMissingIconRequests = (dirents, fileIconCache) => {
@@ -2382,8 +2405,8 @@ const getExpandedType = type => {
2382
2405
  switch (type) {
2383
2406
  case Directory:
2384
2407
  return Collapsed;
2385
- case DirectoryExpanding:
2386
2408
  case DirectoryExpanded:
2409
+ case DirectoryExpanding:
2387
2410
  return Expanded;
2388
2411
  default:
2389
2412
  return None$3;
@@ -2519,21 +2542,21 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
2519
2542
  }
2520
2543
  visible.push({
2521
2544
  ...item,
2522
- posInSet: item.posInSet ?? i + 1,
2523
- setSize: item.setSize ?? items.length,
2524
- isEditing: isEditing,
2525
- hasEditingError: isEditing && Boolean(editingErrorMessage),
2526
- icon,
2527
- indent,
2528
2545
  ariaExpanded,
2529
2546
  chevron,
2530
- id,
2531
2547
  className,
2548
+ // @ts-ignore
2549
+ decoration,
2550
+ hasEditingError: isEditing && Boolean(editingErrorMessage),
2551
+ icon,
2552
+ id,
2553
+ indent,
2554
+ index: i,
2532
2555
  isCut,
2556
+ isEditing: isEditing,
2533
2557
  isIgnored,
2534
- index: i,
2535
- // @ts-ignore
2536
- decoration
2558
+ posInSet: item.posInSet ?? i + 1,
2559
+ setSize: item.setSize ?? items.length
2537
2560
  });
2538
2561
  }
2539
2562
  return visible;
@@ -2541,9 +2564,9 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
2541
2564
 
2542
2565
  const {
2543
2566
  get,
2544
- set,
2545
- registerCommands,
2546
2567
  getCommandIds,
2568
+ registerCommands,
2569
+ set,
2547
2570
  wrapGetter
2548
2571
  } = create$1();
2549
2572
  const wrapListItemCommand = fn => {
@@ -2553,20 +2576,20 @@ const wrapListItemCommand = fn => {
2553
2576
  } = get(id);
2554
2577
  const updatedState = await fn(newState, ...args);
2555
2578
  const {
2556
- items,
2557
- minLineY,
2558
- focusedIndex,
2559
- editingIndex,
2560
- editingErrorMessage,
2561
- useChevrons,
2579
+ cutItems,
2580
+ decorations,
2562
2581
  dropTargets,
2582
+ editingErrorMessage,
2563
2583
  editingIcon,
2564
- cutItems,
2565
- sourceControlIgnoredUris,
2584
+ editingIndex,
2585
+ fileIconCache,
2586
+ focusedIndex,
2566
2587
  height,
2567
2588
  itemHeight,
2568
- fileIconCache,
2569
- decorations
2589
+ items,
2590
+ minLineY,
2591
+ sourceControlIgnoredUris,
2592
+ useChevrons
2570
2593
  } = updatedState;
2571
2594
  const intermediate = get(id);
2572
2595
  set(id, intermediate.oldState, updatedState);
@@ -2582,10 +2605,10 @@ const wrapListItemCommand = fn => {
2582
2605
  const visibleExplorerItems = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris, decorations);
2583
2606
  const finalState = {
2584
2607
  ...updatedState,
2585
- visibleExplorerItems,
2586
2608
  fileIconCache: newFileIconCache,
2587
2609
  icons,
2588
- maxLineY
2610
+ maxLineY,
2611
+ visibleExplorerItems
2589
2612
  };
2590
2613
  const intermediate2 = get(id);
2591
2614
  set(id, intermediate2.oldState, finalState);
@@ -2600,58 +2623,58 @@ const Slash = '/';
2600
2623
  // TODO parentUid might ot be needed
2601
2624
  const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) => {
2602
2625
  const state = {
2603
- uid: id,
2604
- parentUid,
2605
- root: '',
2606
- items: [],
2607
- focusedIndex: -1,
2608
- focused: false,
2609
- hoverIndex: -1,
2610
- x,
2611
- y,
2612
- width,
2613
- height,
2626
+ confirmDelete: false,
2627
+ confirmPaste: false,
2628
+ cutItems: [],
2629
+ decorations: [],
2614
2630
  deltaY: 0,
2615
- minLineY: 0,
2616
- maxLineY: 0,
2617
- pathSeparator: Slash,
2618
- version: 0,
2619
- editingIndex: -1,
2620
- itemHeight: ListItem,
2621
2631
  dropTargets: [],
2622
- excluded: [],
2623
- editingValue: '',
2624
- editingType: None$5,
2632
+ editingErrorMessage: '',
2625
2633
  editingIcon: '',
2634
+ editingIndex: -1,
2635
+ editingSelectionEnd: 0,
2636
+ editingSelectionStart: 0,
2637
+ editingType: None$5,
2638
+ editingValue: '',
2639
+ errorMessageLeft: 0,
2640
+ errorMessageTop: 0,
2641
+ errorMessageWidth: 0,
2642
+ excluded: [],
2626
2643
  fileIconCache: Object.create(null),
2627
- useChevrons: false,
2628
- confirmDelete: false,
2629
- icons: [],
2630
- platform,
2644
+ finalDeltaY: 0,
2631
2645
  focus: 0,
2632
- editingErrorMessage: '',
2633
- inputSource: 0,
2634
- editingSelectionStart: 0,
2635
- editingSelectionEnd: 0,
2646
+ focused: false,
2647
+ focusedIndex: -1,
2636
2648
  focusWord: '',
2637
2649
  focusWordTimeout: 800,
2638
- finalDeltaY: 0,
2639
2650
  handleOffset: 0,
2640
- scrollBarActive: false,
2641
- scrollBarHeight: 0,
2642
- confirmPaste: false,
2643
- pasteShouldMove: false,
2644
- cutItems: [],
2651
+ height,
2652
+ hoverIndex: -1,
2653
+ icons: [],
2654
+ inputSource: 0,
2645
2655
  isPointerDown: false,
2656
+ itemHeight: ListItem,
2657
+ items: [],
2658
+ maxIndent: 0,
2659
+ maxLineY: 0,
2660
+ minLineY: 0,
2661
+ parentUid,
2662
+ pasteShouldMove: false,
2663
+ pathSeparator: Slash,
2664
+ platform,
2646
2665
  pointerDownIndex: -1,
2666
+ root: '',
2667
+ scrollBarActive: false,
2668
+ scrollBarHeight: 0,
2669
+ sourceControlDecorations: false,
2647
2670
  sourceControlIgnoredUris: [],
2648
- maxIndent: 0,
2649
- errorMessageLeft: 0,
2650
- errorMessageTop: 0,
2671
+ uid: id,
2672
+ useChevrons: false,
2673
+ version: 0,
2651
2674
  visibleExplorerItems: [],
2652
- errorMessageWidth: 0,
2653
- decorations: [],
2654
- sourceControlDecorations: false
2675
+ width,
2676
+ x,
2677
+ y
2655
2678
  };
2656
2679
  set(state.uid, state, state);
2657
2680
  return state;
@@ -2666,7 +2689,7 @@ const isEqual$6 = (oldState, newState) => {
2666
2689
  // TODO compute css more optimized
2667
2690
  // maybe only when items change, and even then not
2668
2691
  // always, but only when it affects the css
2669
- return oldState.errorMessageLeft === newState.errorMessageLeft && oldState.errorMessageTop === newState.errorMessageTop && oldState.maxIndent === newState.maxIndent && oldState.scrollBarActive === newState.scrollBarActive && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.visibleExplorerItems === newState.visibleExplorerItems && oldState.editingErrorMessage === newState.editingErrorMessage;
2692
+ return oldState.editingErrorMessage === newState.editingErrorMessage && oldState.errorMessageLeft === newState.errorMessageLeft && oldState.errorMessageTop === newState.errorMessageTop && oldState.maxIndent === newState.maxIndent && oldState.scrollBarActive === newState.scrollBarActive && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.visibleExplorerItems === newState.visibleExplorerItems && oldState.width === newState.width;
2670
2693
  };
2671
2694
 
2672
2695
  const isEqual$5 = (oldState, newState) => {
@@ -2716,8 +2739,8 @@ const diff = (oldState, newState) => {
2716
2739
 
2717
2740
  const diff2 = uid => {
2718
2741
  const {
2719
- oldState,
2720
- newState
2742
+ newState,
2743
+ oldState
2721
2744
  } = get(uid);
2722
2745
  const result = diff(oldState, newState);
2723
2746
  return result;
@@ -2725,8 +2748,8 @@ const diff2 = uid => {
2725
2748
 
2726
2749
  const expandAll = async state => {
2727
2750
  const {
2728
- items,
2729
2751
  focusedIndex,
2752
+ items,
2730
2753
  pathSeparator
2731
2754
  } = state;
2732
2755
  if (focusedIndex === -1) {
@@ -2777,11 +2800,9 @@ const makeExpanded = dirent => {
2777
2800
  // TODO this is very inefficient
2778
2801
  const getChildDirentsRecursively = async (dirent, pathSeparator) => {
2779
2802
  switch (dirent.type) {
2780
- case File:
2781
- return [dirent];
2782
2803
  case Directory:
2783
- case DirectoryExpanding:
2784
2804
  case DirectoryExpanded:
2805
+ case DirectoryExpanding:
2785
2806
  const childDirents = await getChildDirents(pathSeparator, dirent.path, dirent.depth);
2786
2807
  const all = [makeExpanded(dirent)];
2787
2808
  for (const childDirent of childDirents) {
@@ -2789,6 +2810,8 @@ const getChildDirentsRecursively = async (dirent, pathSeparator) => {
2789
2810
  all.push(...childAll);
2790
2811
  }
2791
2812
  return all;
2813
+ case File:
2814
+ return [dirent];
2792
2815
  default:
2793
2816
  return [];
2794
2817
  }
@@ -2808,15 +2831,15 @@ const getParentEndIndex = (dirents, index) => {
2808
2831
 
2809
2832
  const expandRecursively = async state => {
2810
2833
  const {
2811
- items,
2812
2834
  focusedIndex,
2835
+ items,
2813
2836
  pathSeparator,
2814
2837
  root
2815
2838
  } = state;
2816
2839
  const dirent = focusedIndex < 0 ? {
2817
- type: Directory,
2840
+ depth: 0,
2818
2841
  path: root,
2819
- depth: 0
2842
+ type: Directory
2820
2843
  } : items[focusedIndex];
2821
2844
  if (dirent.type !== Directory && dirent.type !== DirectoryExpanding && dirent.type !== DirectoryExpanded) {
2822
2845
  return state;
@@ -2854,9 +2877,9 @@ const focus = state => {
2854
2877
 
2855
2878
  const focusIndex = (state, index) => {
2856
2879
  const {
2857
- minLineY,
2880
+ items,
2858
2881
  maxLineY,
2859
- items
2882
+ minLineY
2860
2883
  } = state;
2861
2884
  const newItems = items.map((item, i) => ({
2862
2885
  ...item,
@@ -2866,37 +2889,37 @@ const focusIndex = (state, index) => {
2866
2889
  if (index < 0) {
2867
2890
  return {
2868
2891
  ...state,
2869
- items: newItems,
2892
+ focused: true,
2870
2893
  focusedIndex: index,
2871
- focused: true
2894
+ items: newItems
2872
2895
  };
2873
2896
  }
2874
2897
  const diff = maxLineY - minLineY;
2875
2898
  return {
2876
2899
  ...state,
2877
- items: newItems,
2878
- focusedIndex: index,
2879
2900
  focused: true,
2880
- minLineY: index,
2881
- maxLineY: index + diff
2901
+ focusedIndex: index,
2902
+ items: newItems,
2903
+ maxLineY: index + diff,
2904
+ minLineY: index
2882
2905
  };
2883
2906
  }
2884
2907
  if (index >= maxLineY) {
2885
2908
  const diff = maxLineY - minLineY;
2886
2909
  return {
2887
2910
  ...state,
2888
- items: newItems,
2889
- focusedIndex: index,
2890
2911
  focused: true,
2891
- minLineY: index + 1 - diff,
2892
- maxLineY: index + 1
2912
+ focusedIndex: index,
2913
+ items: newItems,
2914
+ maxLineY: index + 1,
2915
+ minLineY: index + 1 - diff
2893
2916
  };
2894
2917
  }
2895
2918
  return {
2896
2919
  ...state,
2897
- items: newItems,
2920
+ focused: true,
2898
2921
  focusedIndex: index,
2899
- focused: true
2922
+ items: newItems
2900
2923
  };
2901
2924
  };
2902
2925
 
@@ -2975,96 +2998,96 @@ const focusPrevious = state => {
2975
2998
 
2976
2999
  const getKeyBindings = () => {
2977
3000
  return [{
2978
- key: Shift | UpArrow,
2979
3001
  command: 'Explorer.selectUp',
3002
+ key: Shift | UpArrow,
2980
3003
  when: FocusExplorer
2981
3004
  }, {
2982
- key: Shift | DownArrow,
2983
3005
  command: 'Explorer.selectDown',
3006
+ key: Shift | DownArrow,
2984
3007
  when: FocusExplorer
2985
3008
  }, {
2986
- key: RightArrow,
2987
3009
  command: 'Explorer.handleArrowRight',
3010
+ key: RightArrow,
2988
3011
  when: FocusExplorer
2989
3012
  }, {
2990
- key: LeftArrow,
2991
3013
  command: 'Explorer.handleArrowLeft',
3014
+ key: LeftArrow,
2992
3015
  when: FocusExplorer
2993
3016
  }, {
2994
- key: Home,
2995
3017
  command: 'Explorer.focusFirst',
3018
+ key: Home,
2996
3019
  when: FocusExplorer
2997
3020
  }, {
2998
- key: End,
2999
3021
  command: 'Explorer.focusLast',
3022
+ key: End,
3000
3023
  when: FocusExplorer
3001
3024
  }, {
3002
- key: UpArrow,
3003
3025
  command: 'Explorer.focusPrevious',
3026
+ key: UpArrow,
3004
3027
  when: FocusExplorer
3005
3028
  }, {
3006
- key: DownArrow,
3007
3029
  command: 'Explorer.focusNext',
3030
+ key: DownArrow,
3008
3031
  when: FocusExplorer
3009
3032
  }, {
3010
- key: CtrlCmd | Star,
3011
3033
  command: 'Explorer.expandAll',
3034
+ key: CtrlCmd | Star,
3012
3035
  when: FocusExplorer
3013
3036
  }, {
3014
- key: Alt | RightArrow,
3015
3037
  command: 'Explorer.expandRecursively',
3038
+ key: Alt | RightArrow,
3016
3039
  when: FocusExplorer
3017
3040
  }, {
3018
- key: CtrlCmd | LeftArrow,
3019
3041
  command: 'Explorer.collapseAll',
3042
+ key: CtrlCmd | LeftArrow,
3020
3043
  when: FocusExplorer
3021
3044
  }, {
3022
- key: CtrlCmd | KeyV,
3023
3045
  command: 'Explorer.handlePaste',
3046
+ key: CtrlCmd | KeyV,
3024
3047
  when: FocusExplorer
3025
3048
  }, {
3026
- key: CtrlCmd | KeyC,
3027
3049
  command: 'Explorer.handleCopy',
3050
+ key: CtrlCmd | KeyC,
3028
3051
  when: FocusExplorer
3029
3052
  }, {
3030
- key: CtrlCmd | KeyX,
3031
3053
  command: 'Explorer.handleCut',
3054
+ key: CtrlCmd | KeyX,
3032
3055
  when: FocusExplorer
3033
3056
  }, {
3034
- key: F2,
3035
3057
  command: 'Explorer.renameDirent',
3058
+ key: F2,
3036
3059
  when: FocusExplorer
3037
3060
  }, {
3038
- key: Escape,
3039
3061
  command: 'Explorer.cancelEdit',
3062
+ key: Escape,
3040
3063
  when: FocusExplorerEditBox
3041
3064
  }, {
3042
- key: Enter,
3043
3065
  command: 'Explorer.acceptEdit',
3066
+ key: Enter,
3044
3067
  when: FocusExplorerEditBox
3045
3068
  }, {
3046
- key: Delete$1,
3047
3069
  command: 'Explorer.removeDirent',
3070
+ key: Delete$1,
3048
3071
  when: FocusExplorer
3049
3072
  }, {
3050
- key: Escape,
3051
3073
  command: 'Explorer.focusNone',
3074
+ key: Escape,
3052
3075
  when: FocusExplorer
3053
3076
  }, {
3054
- key: Space,
3055
3077
  command: 'Explorer.handleClickCurrentButKeepFocus',
3078
+ key: Space,
3056
3079
  when: FocusExplorer
3057
3080
  }, {
3058
- key: Enter,
3059
3081
  command: 'Explorer.handleClickCurrent',
3082
+ key: Enter,
3060
3083
  when: FocusExplorer
3061
3084
  }, {
3062
- key: Escape,
3063
3085
  command: 'Explorer.handleEscape',
3086
+ key: Escape,
3064
3087
  when: FocusExplorer
3065
3088
  }, {
3066
- key: CtrlCmd | KeyA,
3067
3089
  command: 'Explorer.selectAll',
3090
+ key: CtrlCmd | KeyA,
3068
3091
  when: FocusExplorer
3069
3092
  }];
3070
3093
  };
@@ -3074,77 +3097,77 @@ const None$2 = 0;
3074
3097
  const RestoreFocus = 6;
3075
3098
 
3076
3099
  const menuEntrySeparator = {
3077
- id: 'separator',
3078
- label: '',
3100
+ command: '',
3079
3101
  flags: Separator,
3080
- command: ''
3102
+ id: 'separator',
3103
+ label: ''
3081
3104
  };
3082
3105
 
3083
3106
  const menuEntryNewFile = {
3084
- id: 'newFile',
3085
- label: newFile$1(),
3107
+ command: 'Explorer.newFile',
3086
3108
  flags: None$2,
3087
- command: 'Explorer.newFile'
3109
+ id: 'newFile',
3110
+ label: newFile$1()
3088
3111
  };
3089
3112
  const menuEntryNewFolder = {
3090
- id: 'newFolder',
3091
- label: newFolder$1(),
3113
+ command: 'Explorer.newFolder',
3092
3114
  flags: None$2,
3093
- command: 'Explorer.newFolder'
3115
+ id: 'newFolder',
3116
+ label: newFolder$1()
3094
3117
  };
3095
3118
  const menuEntryOpenContainingFolder = {
3096
- id: 'openContainingFolder',
3097
- label: openContainingFolder$1(),
3119
+ command: 'Explorer.openContainingFolder',
3098
3120
  flags: RestoreFocus,
3099
- command: 'Explorer.openContainingFolder'
3121
+ id: 'openContainingFolder',
3122
+ label: openContainingFolder$1()
3100
3123
  };
3101
3124
  const menuEntryOpenInIntegratedTerminal = {
3102
- id: 'openInIntegratedTerminal',
3103
- label: openInIntegratedTerminal(),
3125
+ command: /* TODO */'-1',
3104
3126
  flags: None$2,
3105
- command: /* TODO */'-1'
3127
+ id: 'openInIntegratedTerminal',
3128
+ label: openInIntegratedTerminal()
3106
3129
  };
3107
3130
  const menuEntryCut = {
3108
- id: 'cut',
3109
- label: cut(),
3131
+ command: 'Explorer.handleCut',
3110
3132
  flags: RestoreFocus,
3111
- command: 'Explorer.handleCut'
3133
+ id: 'cut',
3134
+ label: cut()
3112
3135
  };
3113
3136
  const menuEntryCopy = {
3114
- id: 'copy',
3115
- label: copy(),
3137
+ command: 'Explorer.handleCopy',
3116
3138
  flags: RestoreFocus,
3117
- command: 'Explorer.handleCopy'
3139
+ id: 'copy',
3140
+ label: copy()
3118
3141
  };
3119
3142
  const menuEntryPaste = {
3120
- id: 'paste',
3121
- label: paste(),
3143
+ command: 'Explorer.handlePaste',
3122
3144
  flags: None$2,
3123
- command: 'Explorer.handlePaste'
3145
+ id: 'paste',
3146
+ label: paste()
3124
3147
  };
3125
3148
  const menuEntryCopyPath = {
3126
- id: 'copyPath',
3127
- label: copyPath$1(),
3149
+ command: 'Explorer.copyPath',
3128
3150
  flags: RestoreFocus,
3129
- command: 'Explorer.copyPath'
3151
+ id: 'copyPath',
3152
+ label: copyPath$1()
3130
3153
  };
3131
3154
  const menuEntryCopyRelativePath = {
3132
- id: 'copyRelativePath',
3133
- label: copyRelativePath$1(),
3155
+ command: 'Explorer.copyRelativePath',
3134
3156
  flags: RestoreFocus,
3135
- command: 'Explorer.copyRelativePath'
3157
+ id: 'copyRelativePath',
3158
+ label: copyRelativePath$1()
3136
3159
  };
3137
3160
  const menuEntryRename = {
3138
- id: 'rename',
3139
- label: rename(),
3161
+ command: 'Explorer.renameDirent',
3140
3162
  flags: None$2,
3141
- command: 'Explorer.renameDirent'
3163
+ id: 'rename',
3164
+ label: rename()
3142
3165
  };
3143
3166
  const menuEntryDelete = {
3144
- id: 'delete',
3145
- label: deleteItem(),
3167
+ command: 'Explorer.removeDirent',
3146
3168
  flags: None$2,
3147
- command: 'Explorer.removeDirent'
3169
+ id: 'delete',
3170
+ label: deleteItem()
3148
3171
  };
3149
3172
  const ALL_ENTRIES = [menuEntryNewFile, menuEntryNewFolder, menuEntryOpenContainingFolder, menuEntryOpenInIntegratedTerminal, menuEntrySeparator, menuEntryCut, menuEntryCopy, menuEntryPaste, menuEntrySeparator, menuEntryCopyPath, menuEntryCopyRelativePath, menuEntrySeparator, menuEntryRename, menuEntryDelete];
3150
3173
 
@@ -3193,26 +3216,26 @@ const LeftClick = 0;
3193
3216
 
3194
3217
  const getMouseActions = () => {
3195
3218
  return [{
3196
- description: 'Open file on click',
3197
3219
  button: LeftClick,
3198
- modifiers: {},
3199
3220
  command: 'Explorer.openFile',
3221
+ description: 'Open file on click',
3222
+ modifiers: {},
3200
3223
  when: FocusExplorer
3201
3224
  }, {
3202
- description: 'Toggle selection with Ctrl+Click',
3203
3225
  button: LeftClick,
3226
+ command: 'Explorer.toggleSelection',
3227
+ description: 'Toggle selection with Ctrl+Click',
3204
3228
  modifiers: {
3205
3229
  ctrl: true
3206
3230
  },
3207
- command: 'Explorer.toggleSelection',
3208
3231
  when: FocusExplorer
3209
3232
  }, {
3210
- description: 'Select range with Shift+Click',
3211
3233
  button: LeftClick,
3234
+ command: 'Explorer.rangeSelection',
3235
+ description: 'Select range with Shift+Click',
3212
3236
  modifiers: {
3213
3237
  shift: true
3214
3238
  },
3215
- command: 'Explorer.rangeSelection',
3216
3239
  when: FocusExplorer
3217
3240
  }];
3218
3241
  };
@@ -3236,10 +3259,10 @@ const focusParentFolder = state => {
3236
3259
 
3237
3260
  const handleClickDirectoryExpanded = async (state, dirent, index, keepFocus) => {
3238
3261
  const {
3239
- minLineY,
3240
- maxLineY,
3241
3262
  itemHeight,
3242
- items
3263
+ items,
3264
+ maxLineY,
3265
+ minLineY
3243
3266
  } = state;
3244
3267
  // @ts-ignore
3245
3268
  dirent.type = Directory;
@@ -3276,8 +3299,8 @@ const handleClickDirectoryExpanded = async (state, dirent, index, keepFocus) =>
3276
3299
 
3277
3300
  const handleArrowLeft = state => {
3278
3301
  const {
3279
- items,
3280
- focusedIndex
3302
+ focusedIndex,
3303
+ items
3281
3304
  } = state;
3282
3305
  if (focusedIndex === -1) {
3283
3306
  return state;
@@ -3298,8 +3321,8 @@ const handleArrowLeft = state => {
3298
3321
 
3299
3322
  const handleArrowRightDirectoryExpanded = (state, dirent) => {
3300
3323
  const {
3301
- items,
3302
- focusedIndex
3324
+ focusedIndex,
3325
+ items
3303
3326
  } = state;
3304
3327
  if (focusedIndex === items.length - 1) {
3305
3328
  return state;
@@ -3336,10 +3359,10 @@ const handleClickDirectory = async (state, dirent, index, keepFocus) => {
3336
3359
 
3337
3360
  return {
3338
3361
  ...state,
3362
+ focus: List,
3339
3363
  focused: keepFocus,
3340
3364
  focusedIndex: newIndex,
3341
- items: newDirents,
3342
- focus: List
3365
+ items: newDirents
3343
3366
  };
3344
3367
  };
3345
3368
 
@@ -3351,8 +3374,8 @@ const handleClickFile = async (state, dirent, index, keepFocus = false) => {
3351
3374
  await openUri(dirent.path, !keepFocus);
3352
3375
  return {
3353
3376
  ...state,
3354
- focusedIndex: index,
3355
- focused: keepFocus
3377
+ focused: keepFocus,
3378
+ focusedIndex: index
3356
3379
  };
3357
3380
  };
3358
3381
 
@@ -3369,23 +3392,23 @@ const handleClickSymLink = async (state, dirent, index) => {
3369
3392
 
3370
3393
  const handleArrowRight = async state => {
3371
3394
  const {
3372
- items,
3373
- focusedIndex
3395
+ focusedIndex,
3396
+ items
3374
3397
  } = state;
3375
3398
  if (focusedIndex === -1) {
3376
3399
  return state;
3377
3400
  }
3378
3401
  const dirent = items[focusedIndex];
3379
3402
  switch (dirent.type) {
3380
- case File:
3381
- case SymLinkFile:
3382
- return state;
3383
3403
  case Directory:
3384
3404
  case SymLinkFolder:
3385
3405
  // @ts-ignore
3386
3406
  return handleClickDirectory(state, dirent);
3387
3407
  case DirectoryExpanded:
3388
3408
  return handleArrowRightDirectoryExpanded(state, dirent);
3409
+ case File:
3410
+ case SymLinkFile:
3411
+ return state;
3389
3412
  case Symlink:
3390
3413
  return handleClickSymLink(state, dirent, focusedIndex);
3391
3414
  default:
@@ -3426,8 +3449,8 @@ const handleClickDirectoryExpanding = async (state, dirent, index, keepFocus) =>
3426
3449
  dirent.icon = '';
3427
3450
  return {
3428
3451
  ...state,
3429
- focusedIndex: index,
3430
- focused: keepFocus
3452
+ focused: keepFocus,
3453
+ focusedIndex: index
3431
3454
  };
3432
3455
  };
3433
3456
 
@@ -3450,16 +3473,16 @@ const handleClickDirectoryExpanding = async (state, dirent, index, keepFocus) =>
3450
3473
 
3451
3474
  const getClickFn = direntType => {
3452
3475
  switch (direntType) {
3453
- case File:
3454
- case SymLinkFile:
3455
- return handleClickFile;
3456
3476
  case Directory:
3457
3477
  case SymLinkFolder:
3458
3478
  return handleClickDirectory;
3459
- case DirectoryExpanding:
3460
- return handleClickDirectoryExpanding;
3461
3479
  case DirectoryExpanded:
3462
3480
  return handleClickDirectoryExpanded;
3481
+ case DirectoryExpanding:
3482
+ return handleClickDirectoryExpanding;
3483
+ case File:
3484
+ case SymLinkFile:
3485
+ return handleClickFile;
3463
3486
  case Symlink:
3464
3487
  return handleClickSymLink;
3465
3488
  case CharacterDevice:
@@ -3474,15 +3497,15 @@ const getClickFn = direntType => {
3474
3497
  };
3475
3498
 
3476
3499
  const resetEditing = {
3477
- editingIndex: -1,
3478
- editingValue: '',
3479
- editingType: None$5,
3480
- editingIcon: '',
3481
3500
  editingErrorMessage: '',
3501
+ editingIcon: '',
3502
+ editingIndex: -1,
3482
3503
  editingSelection: {
3483
- start: 0,
3484
- end: 0
3485
- }
3504
+ end: 0,
3505
+ start: 0
3506
+ },
3507
+ editingType: None$5,
3508
+ editingValue: ''
3486
3509
  };
3487
3510
 
3488
3511
  // TODO viewlet should only have create and refresh functions
@@ -3535,9 +3558,9 @@ const handleClick = async (state, index, keepFocus = false) => {
3535
3558
 
3536
3559
  const getIndexFromPosition = (state, eventX, eventY) => {
3537
3560
  const {
3538
- y,
3539
3561
  itemHeight,
3540
- items
3562
+ items,
3563
+ y
3541
3564
  } = state;
3542
3565
  const index = Math.floor((eventY - y) / itemHeight);
3543
3566
  if (index < 0) {
@@ -3659,8 +3682,8 @@ const handleContextMenuAtIndex = async (state, index, x, y) => {
3659
3682
  } = state;
3660
3683
  const newState = {
3661
3684
  ...state,
3662
- focusedIndex: index,
3663
- focused: false
3685
+ focused: false,
3686
+ focusedIndex: index
3664
3687
  };
3665
3688
  set(uid, state, newState);
3666
3689
  await show2(uid, Explorer, x, y, {
@@ -3672,10 +3695,10 @@ const handleContextMenuAtIndex = async (state, index, x, y) => {
3672
3695
  const handleContextMenuKeyboard = async state => {
3673
3696
  const {
3674
3697
  focusedIndex,
3675
- x,
3676
- y,
3698
+ itemHeight,
3677
3699
  minLineY,
3678
- itemHeight
3700
+ x,
3701
+ y
3679
3702
  } = state;
3680
3703
  const menuX = x;
3681
3704
  const menuY = y + (focusedIndex - minLineY + 1) * itemHeight;
@@ -3732,8 +3755,8 @@ const handleCut = async state => {
3732
3755
  // TODO handle multiple files
3733
3756
  // TODO if not file is selected, what happens?
3734
3757
  const {
3735
- items,
3736
- focusedIndex
3758
+ focusedIndex,
3759
+ items
3737
3760
  } = state;
3738
3761
  const dirents = getSelectedItems(items, focusedIndex);
3739
3762
  if (dirents.length === 0) {
@@ -3743,8 +3766,8 @@ const handleCut = async state => {
3743
3766
  await writeNativeFiles('cut', files);
3744
3767
  return {
3745
3768
  ...state,
3746
- pasteShouldMove: true,
3747
- cutItems: files
3769
+ cutItems: files,
3770
+ pasteShouldMove: true
3748
3771
  };
3749
3772
  };
3750
3773
 
@@ -3871,14 +3894,14 @@ const getProtoMapInternal = (root, pathToDirents, expandedPaths, depth) => {
3871
3894
  const item = items[i];
3872
3895
  const path = join2(root, item.name);
3873
3896
  const displayDirent = {
3897
+ depth,
3898
+ icon: '',
3874
3899
  name: item.name,
3900
+ path,
3875
3901
  posInSet: i + 1,
3902
+ selected: false,
3876
3903
  setSize: items.length,
3877
- depth,
3878
- type: restoreDirentType(item.type, path, expandedPaths),
3879
- path,
3880
- icon: '',
3881
- selected: false
3904
+ type: restoreDirentType(item.type, path, expandedPaths)
3882
3905
  };
3883
3906
  const children = getProtoMapInternal(path, pathToDirents, expandedPaths, depth + 1);
3884
3907
  protoMap.push(displayDirent, ...children);
@@ -3901,9 +3924,9 @@ const sortPathDirentsMap = map => {
3901
3924
 
3902
3925
  const refresh = async state => {
3903
3926
  const {
3904
- root,
3905
3927
  focusedIndex,
3906
- items
3928
+ items,
3929
+ root
3907
3930
  } = state;
3908
3931
  const expandedDirents = getExpandedDirents(items);
3909
3932
  const expandedPaths = getPaths(expandedDirents);
@@ -3969,15 +3992,15 @@ const getFileOperations = (root, uploadTree) => {
3969
3992
  const fullPath = currentPath ? join2(currentPath, path) : path;
3970
3993
  if (typeof value === 'object') {
3971
3994
  operations.push({
3972
- type: CreateFolder$1,
3973
- path: join2(root, fullPath)
3995
+ path: join2(root, fullPath),
3996
+ type: CreateFolder$1
3974
3997
  });
3975
3998
  processTree(value, fullPath);
3976
3999
  } else if (typeof value === 'string') {
3977
4000
  operations.push({
3978
- type: CreateFile$1,
3979
4001
  path: join2(root, fullPath),
3980
- text: value
4002
+ text: value,
4003
+ type: CreateFile$1
3981
4004
  });
3982
4005
  }
3983
4006
  }
@@ -4009,9 +4032,9 @@ const getMergedDirents$2 = async (root, pathSeparator, dirents) => {
4009
4032
  };
4010
4033
  const handleDrop$2 = async (state, fileHandles, files) => {
4011
4034
  const {
4012
- root,
4035
+ items,
4013
4036
  pathSeparator,
4014
- items
4037
+ root
4015
4038
  } = state;
4016
4039
  const handled = await uploadFileSystemHandles(root, pathSeparator, fileHandles);
4017
4040
  if (handled) {
@@ -4024,8 +4047,8 @@ const handleDrop$2 = async (state, fileHandles, files) => {
4024
4047
  const mergedDirents = await getMergedDirents$2(root, pathSeparator, items);
4025
4048
  return {
4026
4049
  ...state,
4027
- items: mergedDirents,
4028
- dropTargets: []
4050
+ dropTargets: [],
4051
+ items: mergedDirents
4029
4052
  };
4030
4053
  };
4031
4054
 
@@ -4038,9 +4061,9 @@ const getFileOperationsElectron = async (root, paths, fileHandles, pathSeparator
4038
4061
  } = fileHandle;
4039
4062
  const path = paths[i];
4040
4063
  operations.push({
4041
- type: Copy$1,
4064
+ from: path,
4042
4065
  path: join(pathSeparator, root, name),
4043
- from: path
4066
+ type: Copy$1
4044
4067
  });
4045
4068
  }
4046
4069
  return operations;
@@ -4063,16 +4086,16 @@ const getMergedDirents$1 = async (root, pathSeparator, dirents) => {
4063
4086
  };
4064
4087
  const handleDrop$1 = async (state, fileHandles, files, paths) => {
4065
4088
  const {
4066
- root,
4089
+ items,
4067
4090
  pathSeparator,
4068
- items
4091
+ root
4069
4092
  } = state;
4070
4093
  await copyFilesElectron(root, fileHandles, files, paths);
4071
4094
  const mergedDirents = await getMergedDirents$1(root, pathSeparator, items);
4072
4095
  return {
4073
4096
  ...state,
4074
- items: mergedDirents,
4075
- dropTargets: []
4097
+ dropTargets: [],
4098
+ items: mergedDirents
4076
4099
  };
4077
4100
  };
4078
4101
 
@@ -4109,8 +4132,8 @@ const getMergedDirents = (items, index, dirent, childDirents) => {
4109
4132
  };
4110
4133
  const handleDropIntoFolder = async (state, dirent, index, fileHandles, files, paths) => {
4111
4134
  const {
4112
- pathSeparator,
4113
- items
4135
+ items,
4136
+ pathSeparator
4114
4137
  } = state;
4115
4138
  // @ts-ignore
4116
4139
  for (const file of fileHandles) {
@@ -4125,8 +4148,8 @@ const handleDropIntoFolder = async (state, dirent, index, fileHandles, files, pa
4125
4148
  // TODO update maxlineY
4126
4149
  return {
4127
4150
  ...state,
4128
- items: mergedDirents,
4129
- dropTargets: []
4151
+ dropTargets: [],
4152
+ items: mergedDirents
4130
4153
  };
4131
4154
  };
4132
4155
  const handleDropIntoFile = (state, dirent, index, fileHandles, files, paths) => {
@@ -4225,8 +4248,8 @@ const handleFocus = async state => {
4225
4248
  const updateIcons = async state => {
4226
4249
  const {
4227
4250
  items,
4228
- minLineY,
4229
- maxLineY
4251
+ maxLineY,
4252
+ minLineY
4230
4253
  } = state;
4231
4254
  const visible = items.slice(minLineY, maxLineY);
4232
4255
  const {
@@ -4235,8 +4258,8 @@ const updateIcons = async state => {
4235
4258
  } = await getFileIcons(visible, Object.create(null));
4236
4259
  return {
4237
4260
  ...state,
4238
- icons,
4239
- fileIconCache: newFileIconCache
4261
+ fileIconCache: newFileIconCache,
4262
+ icons
4240
4263
  };
4241
4264
  };
4242
4265
 
@@ -4294,10 +4317,10 @@ const isAscii = key => {
4294
4317
  let timeout;
4295
4318
  const handleKeyDown = (state, key) => {
4296
4319
  const {
4297
- focusWord,
4298
- items,
4299
4320
  focusedIndex,
4300
- focusWordTimeout
4321
+ focusWord,
4322
+ focusWordTimeout,
4323
+ items
4301
4324
  } = state;
4302
4325
  if (focusWord && key === '') {
4303
4326
  return cancelTypeAhead(state);
@@ -4324,8 +4347,8 @@ const handleKeyDown = (state, key) => {
4324
4347
  }
4325
4348
  return {
4326
4349
  ...state,
4327
- focusWord: newFocusWord,
4328
- focusedIndex: matchingIndex
4350
+ focusedIndex: matchingIndex,
4351
+ focusWord: newFocusWord
4329
4352
  };
4330
4353
  };
4331
4354
 
@@ -4335,40 +4358,40 @@ const scrollInto = (index, minLineY, maxLineY) => {
4335
4358
  const largerHalf = diff - smallerHalf;
4336
4359
  if (index < minLineY) {
4337
4360
  return {
4338
- newMinLineY: index - smallerHalf,
4339
- newMaxLineY: index + largerHalf
4361
+ newMaxLineY: index + largerHalf,
4362
+ newMinLineY: index - smallerHalf
4340
4363
  };
4341
4364
  }
4342
4365
  if (index >= maxLineY) {
4343
4366
  return {
4344
- newMinLineY: index - smallerHalf,
4345
- newMaxLineY: index + largerHalf
4367
+ newMaxLineY: index + largerHalf,
4368
+ newMinLineY: index - smallerHalf
4346
4369
  };
4347
4370
  }
4348
4371
  return {
4349
- newMinLineY: minLineY,
4350
- newMaxLineY: maxLineY
4372
+ newMaxLineY: maxLineY,
4373
+ newMinLineY: minLineY
4351
4374
  };
4352
4375
  };
4353
4376
 
4354
4377
  const adjustScrollAfterPaste = (state, focusedIndex) => {
4355
4378
  const {
4356
- minLineY,
4379
+ itemHeight,
4357
4380
  maxLineY,
4358
- itemHeight
4381
+ minLineY
4359
4382
  } = state;
4360
4383
  const {
4361
- newMinLineY,
4362
- newMaxLineY
4384
+ newMaxLineY,
4385
+ newMinLineY
4363
4386
  } = scrollInto(focusedIndex, minLineY, maxLineY);
4364
4387
  const newDeltaY = newMinLineY * itemHeight;
4365
4388
  return {
4366
4389
  ...state,
4367
- focusedIndex,
4390
+ deltaY: newDeltaY,
4368
4391
  focused: true,
4369
- minLineY: newMinLineY,
4392
+ focusedIndex,
4370
4393
  maxLineY: newMaxLineY,
4371
- deltaY: newDeltaY
4394
+ minLineY: newMinLineY
4372
4395
  };
4373
4396
  };
4374
4397
 
@@ -4417,18 +4440,18 @@ const getFileOperationsCopy = (root, existingUris, files, focusedUri) => {
4417
4440
  const baseName = getBaseName('/', file);
4418
4441
  if (existingUris.includes(file)) {
4419
4442
  operations.push({
4420
- type: Rename$2,
4421
4443
  from: file,
4422
- path: join2(focusedUri, baseName)
4444
+ path: join2(focusedUri, baseName),
4445
+ type: Rename$2
4423
4446
  });
4424
4447
  } else {
4425
4448
  const uniqueName = generateUniqueName(baseName, existingUris, root);
4426
4449
  const newUri = join2(root, uniqueName);
4427
4450
  operations.push({
4428
- type: Copy$1,
4429
4451
  from: file,
4430
4452
  // TODO ensure file is uri
4431
- path: newUri
4453
+ path: newUri,
4454
+ type: Copy$1
4432
4455
  });
4433
4456
  }
4434
4457
  }
@@ -4444,9 +4467,9 @@ const handlePasteCopy = async (state, nativeFiles) => {
4444
4467
 
4445
4468
  // TODO use file operations and bulk edit
4446
4469
  const {
4470
+ focusedIndex,
4447
4471
  items,
4448
- root,
4449
- focusedIndex
4472
+ root
4450
4473
  } = state;
4451
4474
  const focusedUri = items[focusedIndex]?.path || root;
4452
4475
  const existingUris = items.map(item => item.path);
@@ -4491,9 +4514,9 @@ const getOperations = (toUri, files) => {
4491
4514
  const baseName = getBaseName('/', file);
4492
4515
  const newUri = join2(toUri, baseName);
4493
4516
  operations.push({
4494
- type: Rename$2,
4495
4517
  from: file,
4496
- path: newUri
4518
+ path: newUri,
4519
+ type: Rename$2
4497
4520
  });
4498
4521
  }
4499
4522
  return operations;
@@ -4506,10 +4529,10 @@ const getTargetUri = (root, items, index) => {
4506
4529
  };
4507
4530
  const handlePasteCut = async (state, nativeFiles) => {
4508
4531
  const {
4509
- root,
4510
- pathSeparator,
4532
+ focusedIndex,
4511
4533
  items,
4512
- focusedIndex
4534
+ pathSeparator,
4535
+ root
4513
4536
  } = state;
4514
4537
  // TODO root is not necessrily target uri
4515
4538
  const targetUri = getTargetUri(root, items, focusedIndex);
@@ -4528,15 +4551,15 @@ const handlePasteCut = async (state, nativeFiles) => {
4528
4551
  const adjustedState = adjustScrollAfterPaste(latestState, pastedFileIndex);
4529
4552
  return {
4530
4553
  ...adjustedState,
4531
- pasteShouldMove: false,
4532
- cutItems: []
4554
+ cutItems: [],
4555
+ pasteShouldMove: false
4533
4556
  };
4534
4557
  }
4535
4558
  }
4536
4559
  return {
4537
4560
  ...latestState,
4538
- pasteShouldMove: false,
4539
- cutItems: []
4561
+ cutItems: [],
4562
+ pasteShouldMove: false
4540
4563
  };
4541
4564
  };
4542
4565
 
@@ -4577,9 +4600,9 @@ const handlePointerDown = (state, button, x, y) => {
4577
4600
  if (button === LeftClick && index === -1) {
4578
4601
  return {
4579
4602
  ...state,
4603
+ focus: List,
4580
4604
  focused: true,
4581
- focusedIndex: -1,
4582
- focus: List
4605
+ focusedIndex: -1
4583
4606
  };
4584
4607
  }
4585
4608
  return state;
@@ -4587,8 +4610,8 @@ const handlePointerDown = (state, button, x, y) => {
4587
4610
 
4588
4611
  const handleUpload = async (state, dirents) => {
4589
4612
  const {
4590
- root,
4591
- pathSeparator
4613
+ pathSeparator,
4614
+ root
4592
4615
  } = state;
4593
4616
  for (const dirent of dirents) {
4594
4617
  // TODO switch
@@ -4606,8 +4629,8 @@ const handleUpload = async (state, dirents) => {
4606
4629
 
4607
4630
  const setDeltaY = async (state, deltaY) => {
4608
4631
  const {
4609
- itemHeight,
4610
4632
  height,
4633
+ itemHeight,
4611
4634
  items
4612
4635
  } = state;
4613
4636
  if (deltaY < 0) {
@@ -4688,10 +4711,10 @@ const getSettings = async () => {
4688
4711
  const sourceControlDecorationsRaw = await invoke$2('Preferences.get', 'explorer.sourceControlDecorations');
4689
4712
  const sourceControlDecorations = sourceControlDecorationsRaw === false ? false : true;
4690
4713
  return {
4691
- useChevrons,
4692
4714
  confirmDelete,
4693
4715
  confirmPaste,
4694
- sourceControlDecorations
4716
+ sourceControlDecorations,
4717
+ useChevrons
4695
4718
  };
4696
4719
  };
4697
4720
 
@@ -4721,22 +4744,22 @@ const getSavedChildDirents = (map, path, depth, excluded, pathSeparator) => {
4721
4744
  if ((child.type === Directory || child.type === SymLinkFolder) && childPath in map) {
4722
4745
  dirents.push({
4723
4746
  depth,
4724
- posInSet: i + 1,
4725
- setSize: visibleLength,
4726
4747
  icon: '',
4727
4748
  name,
4728
4749
  path: childPath,
4750
+ posInSet: i + 1,
4751
+ setSize: visibleLength,
4729
4752
  type: DirectoryExpanded
4730
4753
  });
4731
4754
  dirents.push(...getSavedChildDirents(map, childPath, depth + 1, excluded, pathSeparator));
4732
4755
  } else {
4733
4756
  dirents.push({
4734
4757
  depth,
4735
- posInSet: i + 1,
4736
- setSize: visibleLength,
4737
4758
  icon: '',
4738
4759
  name,
4739
4760
  path: childPath,
4761
+ posInSet: i + 1,
4762
+ setSize: visibleLength,
4740
4763
  type
4741
4764
  });
4742
4765
  }
@@ -4806,9 +4829,9 @@ const getSavedRoot = (savedState, workspacePath) => {
4806
4829
  };
4807
4830
  const loadContent = async (state, savedState) => {
4808
4831
  const {
4809
- useChevrons,
4810
4832
  confirmDelete,
4811
- sourceControlDecorations
4833
+ sourceControlDecorations,
4834
+ useChevrons
4812
4835
  } = await getSettings();
4813
4836
  const workspacePath = await getWorkspacePath();
4814
4837
  const root = getSavedRoot(savedState, workspacePath);
@@ -4932,14 +4955,14 @@ const getNewChildDirentsForNewDirent = async (items, depth, parentPath, direntTy
4932
4955
  if (existingChildren.length === 0) {
4933
4956
  const childDirents = await readDirWithFileTypes(parentPath);
4934
4957
  existingChildren = childDirents.map((dirent, index) => ({
4958
+ depth,
4959
+ icon: '',
4935
4960
  name: dirent.name,
4936
- type: dirent.type,
4937
4961
  path: join2(parentPath, dirent.name),
4938
- depth,
4939
- selected: false,
4940
4962
  posInSet: index + 1,
4963
+ selected: false,
4941
4964
  setSize: childDirents.length,
4942
- icon: ''
4965
+ type: dirent.type
4943
4966
  }));
4944
4967
  }
4945
4968
  const updatedChildren = existingChildren.map((child, index) => ({
@@ -4948,14 +4971,14 @@ const getNewChildDirentsForNewDirent = async (items, depth, parentPath, direntTy
4948
4971
  setSize: existingChildren.length + 2
4949
4972
  }));
4950
4973
  const newDirent = {
4974
+ depth,
4975
+ icon: '',
4951
4976
  name: '',
4952
- type: direntType,
4953
4977
  path: parentPath,
4954
- depth,
4955
- selected: false,
4956
4978
  posInSet: updatedChildren.length + 1,
4979
+ selected: false,
4957
4980
  setSize: existingChildren.length + 2,
4958
- icon: ''
4981
+ type: direntType
4959
4982
  };
4960
4983
  const allChildDirents = [...updatedChildren, newDirent];
4961
4984
  return allChildDirents;
@@ -4964,14 +4987,14 @@ const getNewChildDirentsForNewDirent = async (items, depth, parentPath, direntTy
4964
4987
  const getNewDirentsForNewDirent = async (items, focusedIndex, type, root) => {
4965
4988
  if (items.length === 0 || focusedIndex === -1) {
4966
4989
  const newDirent = {
4990
+ depth: 0,
4991
+ icon: '',
4967
4992
  name: '',
4968
- type,
4969
4993
  path: root,
4970
- depth: 0,
4971
- selected: false,
4972
4994
  posInSet: 1,
4995
+ selected: false,
4973
4996
  setSize: 1,
4974
- icon: ''
4997
+ type
4975
4998
  };
4976
4999
  return [...items, newDirent];
4977
5000
  }
@@ -5020,9 +5043,9 @@ const getFittingIndex = (dirents, startIndex) => {
5020
5043
  const newDirent = async (state, editingType) => {
5021
5044
  // TODO do it like vscode, select position between folders and files
5022
5045
  const {
5023
- root,
5024
5046
  focusedIndex,
5025
- items
5047
+ items,
5048
+ root
5026
5049
  } = state;
5027
5050
  const index = getFittingIndex(items, focusedIndex);
5028
5051
  const direntType = getNewDirentType(editingType);
@@ -5066,8 +5089,9 @@ const openNativeFolder = async path => {
5066
5089
  const openContainingFolder = async state => {
5067
5090
  const {
5068
5091
  focusedIndex,
5069
- root,
5070
- items} = state;
5092
+ items,
5093
+ root
5094
+ } = state;
5071
5095
  const path = getContainingFolder(root, items, focusedIndex);
5072
5096
  await openNativeFolder(path);
5073
5097
  return state;
@@ -5087,9 +5111,9 @@ const showErrorAlert = async errorMessage => {
5087
5111
 
5088
5112
  const removeDirent = async state => {
5089
5113
  const {
5090
- items,
5114
+ confirmDelete: confirmDelete$1,
5091
5115
  focusedIndex,
5092
- confirmDelete: confirmDelete$1
5116
+ items
5093
5117
  } = state;
5094
5118
  const selectedItems = getSelectedItems(items, focusedIndex);
5095
5119
  if (selectedItems.length === 0) {
@@ -5104,8 +5128,8 @@ const removeDirent = async state => {
5104
5128
  }
5105
5129
  const fileOperations = toRemove.map(item => {
5106
5130
  return {
5107
- type: Remove,
5108
- path: item
5131
+ path: item,
5132
+ type: Remove
5109
5133
  };
5110
5134
  });
5111
5135
  // TODO use bulk edit and explorer refresh
@@ -5117,8 +5141,8 @@ const removeDirent = async state => {
5117
5141
  const newState = await refresh(state);
5118
5142
  return {
5119
5143
  ...newState,
5120
- focused: true,
5121
- focus: List
5144
+ focus: List,
5145
+ focused: true
5122
5146
  };
5123
5147
  };
5124
5148
 
@@ -5145,13 +5169,13 @@ const getRenameSelectionRange = name => {
5145
5169
  const dotIndex = name.lastIndexOf('.');
5146
5170
  if (dotIndex === -1) {
5147
5171
  return {
5148
- start: 0,
5149
- end: name.length
5172
+ end: name.length,
5173
+ start: 0
5150
5174
  };
5151
5175
  }
5152
5176
  return {
5153
- start: 0,
5154
- end: dotIndex
5177
+ end: dotIndex,
5178
+ start: 0
5155
5179
  };
5156
5180
  };
5157
5181
 
@@ -5161,8 +5185,8 @@ const Script = 2;
5161
5185
  const renameDirent = async state => {
5162
5186
  const {
5163
5187
  focusedIndex,
5164
- items,
5165
5188
  icons,
5189
+ items,
5166
5190
  minLineY
5167
5191
  } = state;
5168
5192
  if (items.length === 0) {
@@ -5171,20 +5195,20 @@ const renameDirent = async state => {
5171
5195
  const item = items[focusedIndex];
5172
5196
  const newItems = getNewDirentsForRename(items, focusedIndex);
5173
5197
  const {
5174
- start,
5175
- end
5198
+ end,
5199
+ start
5176
5200
  } = getRenameSelectionRange(item.name);
5177
5201
  return {
5178
5202
  ...state,
5179
- items: newItems,
5203
+ editingIcon: icons[focusedIndex - minLineY],
5180
5204
  editingIndex: focusedIndex,
5205
+ editingSelectionEnd: end,
5206
+ editingSelectionStart: start,
5181
5207
  editingType: Rename$1,
5182
5208
  editingValue: item.name,
5183
- editingIcon: icons[focusedIndex - minLineY],
5184
- editingSelectionStart: start,
5185
- editingSelectionEnd: end,
5186
5209
  focus: Input$1,
5187
- inputSource: Script
5210
+ inputSource: Script,
5211
+ items: newItems
5188
5212
  };
5189
5213
  };
5190
5214
 
@@ -5209,9 +5233,9 @@ const getErrorMessagePosition = (itemHeight, focusedIndex, minLineY, depth, inde
5209
5233
  const left = depth * indent + fileIconWidth + padding;
5210
5234
  const errorMessageWidth = width - left;
5211
5235
  return {
5212
- top,
5236
+ errorMessageWidth,
5213
5237
  left,
5214
- errorMessageWidth
5238
+ top
5215
5239
  };
5216
5240
  };
5217
5241
 
@@ -5227,14 +5251,14 @@ const getUnique = items => {
5227
5251
 
5228
5252
  const renderCss = (oldState, newState) => {
5229
5253
  const {
5230
- width,
5254
+ focusedIndex,
5255
+ itemHeight,
5231
5256
  items,
5257
+ minLineY,
5232
5258
  scrollBarHeight,
5233
5259
  uid,
5234
5260
  visibleExplorerItems,
5235
- itemHeight,
5236
- focusedIndex,
5237
- minLineY
5261
+ width
5238
5262
  } = newState;
5239
5263
  const indents = visibleExplorerItems.map(item => item.indent);
5240
5264
  const uniqueIndents = getUnique(indents);
@@ -5245,9 +5269,9 @@ const renderCss = (oldState, newState) => {
5245
5269
  const chevronSpace = 22;
5246
5270
  const depth = items[focusedIndex]?.depth || 0;
5247
5271
  const {
5248
- top,
5272
+ errorMessageWidth,
5249
5273
  left,
5250
- errorMessageWidth
5274
+ top
5251
5275
  } = getErrorMessagePosition(itemHeight, focusedIndex, minLineY, depth, indent, fileIconWidth, padding + defaultPaddingLeft + chevronSpace, width);
5252
5276
  const css = getCss(scrollBarHeight, uniqueIndents, left, top, errorMessageWidth);
5253
5277
  return [SetCss, uid, css];
@@ -5269,11 +5293,11 @@ const toUri = path => {
5269
5293
  const getDragData = urls => {
5270
5294
  const data = urls.map(toUri).join('\n');
5271
5295
  const dragData = [{
5272
- type: 'text/uri-list',
5273
- data
5296
+ data,
5297
+ type: 'text/uri-list'
5274
5298
  }, {
5275
- type: 'text/plain',
5276
- data
5299
+ data,
5300
+ type: 'text/plain'
5277
5301
  }];
5278
5302
  // @ts-ignore
5279
5303
  dragData.label = getDragLabel(urls);
@@ -5282,8 +5306,8 @@ const getDragData = urls => {
5282
5306
 
5283
5307
  const renderDragData = (oldState, newState) => {
5284
5308
  const {
5285
- items,
5286
- focusedIndex
5309
+ focusedIndex,
5310
+ items
5287
5311
  } = newState;
5288
5312
  const selected = items.filter((item, index) => item.selected || index === focusedIndex);
5289
5313
  const urls = selected.map(item => item.path);
@@ -5296,8 +5320,8 @@ const OpenFolder = 'OpenFolder';
5296
5320
 
5297
5321
  const renderEditingSelection = (oldState, newState) => {
5298
5322
  const {
5299
- editingSelectionStart,
5300
5323
  editingSelectionEnd,
5324
+ editingSelectionStart,
5301
5325
  uid
5302
5326
  } = newState;
5303
5327
  return ['Viewlet.setSelectionByName', uid, ExplorerInput, editingSelectionStart, editingSelectionEnd];
@@ -5345,9 +5369,9 @@ const getErrorMessageDom = errorMessage => {
5345
5369
  return [];
5346
5370
  }
5347
5371
  return [{
5348
- type: Div,
5372
+ childCount: 1,
5349
5373
  className: mergeClassNames(ExplorerErrorMessage),
5350
- childCount: 1
5374
+ type: Div
5351
5375
  }, text(errorMessage)];
5352
5376
  };
5353
5377
 
@@ -5368,37 +5392,37 @@ const HandleDragStart = 17;
5368
5392
 
5369
5393
  const getExplorerWelcomeVirtualDom = isWide => {
5370
5394
  return [{
5371
- type: Div,
5395
+ childCount: 1,
5372
5396
  className: mergeClassNames(Viewlet, Explorer$1),
5373
5397
  tabIndex: 0,
5374
- childCount: 1
5398
+ type: Div
5375
5399
  }, {
5376
- type: Div,
5400
+ childCount: 2,
5377
5401
  className: Welcome,
5378
- childCount: 2
5402
+ type: Div
5379
5403
  }, {
5380
- type: P,
5404
+ childCount: 1,
5381
5405
  className: WelcomeMessage,
5382
- childCount: 1
5406
+ type: P
5383
5407
  }, text(youHaveNotYetOpenedAFolder()), {
5384
- type: Button$1,
5408
+ childCount: 1,
5385
5409
  className: mergeClassNames(Button$2, ButtonPrimary, isWide ? ButtonWide : ButtonNarrow),
5386
5410
  name: OpenFolder,
5387
- childCount: 1,
5388
- onClick: HandleClickOpenFolder
5411
+ onClick: HandleClickOpenFolder,
5412
+ type: Button$1
5389
5413
  }, text(openFolder$1())];
5390
5414
  };
5391
5415
 
5392
5416
  const chevronDownVirtualDom = {
5393
- type: Div,
5417
+ childCount: 0,
5394
5418
  className: mergeClassNames(Chevron, MaskIconChevronDown),
5395
- childCount: 0
5419
+ type: Div
5396
5420
  };
5397
5421
 
5398
5422
  const chevronRightVirtualDom = {
5399
- type: Div,
5423
+ childCount: 0,
5400
5424
  className: mergeClassNames(Chevron, MaskIconChevronRight),
5401
- childCount: 0
5425
+ type: Div
5402
5426
  };
5403
5427
 
5404
5428
  const chevronDomNodes = [[], [chevronRightVirtualDom], [chevronDownVirtualDom]];
@@ -5408,11 +5432,11 @@ const getChevronVirtualDom = chevronType => {
5408
5432
 
5409
5433
  const getFileIconVirtualDom = icon => {
5410
5434
  return {
5411
- type: Img,
5435
+ childCount: 0,
5412
5436
  className: FileIcon,
5413
- src: icon,
5414
5437
  role: None,
5415
- childCount: 0
5438
+ src: icon,
5439
+ type: Img
5416
5440
  };
5417
5441
  };
5418
5442
 
@@ -5429,9 +5453,9 @@ const getInputDom = (isEditing, hasEditingError) => {
5429
5453
  }
5430
5454
  const ariaLabel = typeAFileName();
5431
5455
  return [{
5432
- type: Input,
5433
5456
  ariaLabel: ariaLabel,
5434
5457
  autocapitalize: 'off',
5458
+ autocomplete: 'off',
5435
5459
  autocorrect: 'off',
5436
5460
  childCount: 0,
5437
5461
  className: getInputClassName(hasEditingError),
@@ -5440,14 +5464,15 @@ const getInputDom = (isEditing, hasEditingError) => {
5440
5464
  onBlur: HandleInputBlur,
5441
5465
  onClick: HandleInputClick,
5442
5466
  onInput: HandleEditingInput,
5443
- spellcheck: 'false'
5467
+ spellcheck: 'false',
5468
+ type: Input
5444
5469
  }];
5445
5470
  };
5446
5471
 
5447
5472
  const label = {
5448
- type: Div,
5473
+ childCount: 1,
5449
5474
  className: Label,
5450
- childCount: 1
5475
+ type: Div
5451
5476
  };
5452
5477
  const getLabelDom = (isEditing, name, isDimmed) => {
5453
5478
  if (isEditing) {
@@ -5455,9 +5480,9 @@ const getLabelDom = (isEditing, name, isDimmed) => {
5455
5480
  }
5456
5481
  if (isDimmed) {
5457
5482
  return [{
5458
- type: Div,
5483
+ childCount: 1,
5459
5484
  className: mergeClassNames(Label, LabelCut),
5460
- childCount: 1
5485
+ type: Div
5461
5486
  }, text(name)];
5462
5487
  }
5463
5488
  return [label, text(name)];
@@ -5472,31 +5497,31 @@ const getExplorerItemVirtualDom = item => {
5472
5497
  hasEditingError,
5473
5498
  icon,
5474
5499
  id,
5500
+ index,
5501
+ isCut,
5475
5502
  isEditing,
5503
+ isIgnored,
5476
5504
  name,
5477
5505
  path,
5478
- setSize,
5479
5506
  posInSet,
5480
- isCut,
5481
- isIgnored,
5482
- index
5507
+ setSize
5483
5508
  } = item;
5484
5509
  const chevronDom = getChevronVirtualDom(chevron);
5485
5510
  return [{
5486
- type: Div,
5487
- role: TreeItem,
5488
- className,
5489
- draggable: true,
5490
- title: path,
5511
+ ariaDescription: '',
5512
+ ariaExpanded,
5513
+ ariaLabel: name,
5514
+ ariaLevel: depth,
5491
5515
  ariaPosInSet: posInSet,
5492
5516
  ariaSetSize: setSize,
5493
- ariaLevel: depth,
5494
5517
  childCount: 2 + chevronDom.length,
5495
- ariaLabel: name,
5496
- ariaExpanded,
5497
- ariaDescription: '',
5518
+ className,
5519
+ 'data-index': index,
5520
+ draggable: true,
5498
5521
  id,
5499
- 'data-index': index
5522
+ role: TreeItem,
5523
+ title: path,
5524
+ type: Div
5500
5525
  }, ...chevronDom, getFileIconVirtualDom(icon), ...getInputDom(isEditing, hasEditingError), ...getLabelDom(isEditing, name, isCut || isIgnored)];
5501
5526
  };
5502
5527
 
@@ -5514,13 +5539,10 @@ const getClassName = (focused, focusedIndex, dropTarget) => {
5514
5539
  };
5515
5540
  const getListItemsVirtualDom = (visibleItems, focusedIndex, focused, dropTargets) => {
5516
5541
  const dom = [{
5517
- type: Div,
5518
- className: getClassName(focused, focusedIndex, dropTargets),
5519
- tabIndex: 0,
5520
- role: Tree,
5542
+ ariaActiveDescendant: getActiveDescendant(focusedIndex),
5521
5543
  ariaLabel: filesExplorer(),
5522
5544
  childCount: visibleItems.length,
5523
- ariaActiveDescendant: getActiveDescendant(focusedIndex),
5545
+ className: getClassName(focused, focusedIndex, dropTargets),
5524
5546
  onBlur: HandleListBlur,
5525
5547
  onClick: HandleClick,
5526
5548
  onContextMenu: HandleContextMenu,
@@ -5530,7 +5552,10 @@ const getListItemsVirtualDom = (visibleItems, focusedIndex, focused, dropTargets
5530
5552
  onDrop: HandleDrop,
5531
5553
  onFocus: HandleListFocus,
5532
5554
  onPointerDown: HandlePointerDown,
5533
- onWheel: HandleWheel
5555
+ onWheel: HandleWheel,
5556
+ role: Tree,
5557
+ tabIndex: 0,
5558
+ type: Div
5534
5559
  // onKeyDown: DomEventListenerFunctions.HandleListKeyDown,
5535
5560
  }, ...visibleItems.flatMap(getExplorerItemVirtualDom)];
5536
5561
  return dom;
@@ -5556,15 +5581,15 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
5556
5581
  const heightString = px(scrollBarHeight);
5557
5582
  const translateString = position(0, scrollBarTop);
5558
5583
  return [{
5559
- type: Div,
5584
+ childCount: 1,
5560
5585
  className: mergeClassNames(ScrollBar, ScrollBarSmall),
5561
- childCount: 1
5586
+ type: Div
5562
5587
  }, {
5563
- type: Div,
5564
- className: ScrollBarThumb,
5565
5588
  childCount: 0,
5589
+ className: ScrollBarThumb,
5566
5590
  height: heightString,
5567
- translate: translateString
5591
+ translate: translateString,
5592
+ type: Div
5568
5593
  }];
5569
5594
  };
5570
5595
 
@@ -5588,10 +5613,10 @@ const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused
5588
5613
  const errorDom = getErrorMessageDom(errorMessage);
5589
5614
  const childCount = getChildCount(scrollBarDom.length, errorDom.length);
5590
5615
  const parentNode = {
5591
- type: Div,
5592
5616
  childCount,
5593
5617
  className: mergeClassNames(Viewlet, Explorer$1),
5594
- role: None
5618
+ role: None,
5619
+ type: Div
5595
5620
  };
5596
5621
  const dom = [parentNode, ...getListItemsVirtualDom(visibleItems, focusedIndex, focused, dropTargets), ...scrollBarDom, ...errorDom];
5597
5622
  return dom;
@@ -5629,20 +5654,20 @@ const renderValue = (oldState, newState) => {
5629
5654
 
5630
5655
  const getRenderer = diffType => {
5631
5656
  switch (diffType) {
5632
- case RenderItems:
5633
- return renderItems;
5657
+ case RenderCss:
5658
+ return renderCss;
5659
+ case RenderDragData:
5660
+ return renderDragData;
5634
5661
  case RenderFocus:
5635
5662
  return renderFocus;
5636
5663
  case RenderFocusContext:
5637
5664
  return renderFocusContext;
5638
- case RenderValue:
5639
- return renderValue;
5665
+ case RenderItems:
5666
+ return renderItems;
5640
5667
  case RenderSelection:
5641
5668
  return renderEditingSelection;
5642
- case RenderDragData:
5643
- return renderDragData;
5644
- case RenderCss:
5645
- return renderCss;
5669
+ case RenderValue:
5670
+ return renderValue;
5646
5671
  default:
5647
5672
  throw new Error('unknown renderer');
5648
5673
  }
@@ -5662,8 +5687,8 @@ const applyRender = (oldState, newState, diffResult) => {
5662
5687
 
5663
5688
  const render2 = (uid, diffResult) => {
5664
5689
  const {
5665
- oldState,
5666
- newState
5690
+ newState,
5691
+ oldState
5667
5692
  } = get(uid);
5668
5693
  set(uid, newState, newState);
5669
5694
  const commands = applyRender(oldState, newState, diffResult);
@@ -5682,49 +5707,49 @@ const getActions = root => {
5682
5707
  return [];
5683
5708
  }
5684
5709
  return [{
5685
- type: Button,
5686
- id: newFile$1(),
5710
+ command: 'newFile',
5687
5711
  icon: NewFile,
5688
- command: 'newFile'
5712
+ id: newFile$1(),
5713
+ type: Button
5689
5714
  }, {
5690
- type: Button,
5691
- id: newFolder$1(),
5715
+ command: 'newFolder',
5692
5716
  icon: NewFolder,
5693
- command: 'newFolder'
5717
+ id: newFolder$1(),
5718
+ type: Button
5694
5719
  }, {
5695
- type: Button,
5696
- id: refresh$1(),
5720
+ command: 'refresh',
5697
5721
  icon: Refresh,
5698
- command: 'refresh'
5722
+ id: refresh$1(),
5723
+ type: Button
5699
5724
  }, {
5700
- type: Button,
5701
- id: collapseAll$1(),
5725
+ command: 'collapseAll',
5702
5726
  icon: CollapseAll,
5703
- command: 'collapseAll'
5727
+ id: collapseAll$1(),
5728
+ type: Button
5704
5729
  }];
5705
5730
  };
5706
5731
 
5707
5732
  const getIconVirtualDom = (icon, type = Div) => {
5708
5733
  return {
5709
- type,
5734
+ childCount: 0,
5710
5735
  className: `MaskIcon MaskIcon${icon}`,
5711
5736
  role: None,
5712
- childCount: 0
5737
+ type
5713
5738
  };
5714
5739
  };
5715
5740
 
5716
5741
  const getActionButtonVirtualDom = action => {
5717
5742
  const {
5718
- id,
5743
+ command,
5719
5744
  icon,
5720
- command
5745
+ id
5721
5746
  } = action;
5722
5747
  return [{
5723
- type: Button$1,
5748
+ childCount: 1,
5724
5749
  className: IconButton,
5725
- title: id,
5726
5750
  'data-command': command,
5727
- childCount: 1
5751
+ title: id,
5752
+ type: Button$1
5728
5753
  }, getIconVirtualDom(icon || '')];
5729
5754
  };
5730
5755
 
@@ -5739,10 +5764,10 @@ const getActionVirtualDom = action => {
5739
5764
 
5740
5765
  const getActionsVirtualDom = actions => {
5741
5766
  return [{
5742
- type: Div,
5767
+ childCount: actions.length,
5743
5768
  className: Actions,
5744
5769
  role: ToolBar,
5745
- childCount: actions.length
5770
+ type: Div
5746
5771
  }, ...actions.flatMap(getActionVirtualDom)];
5747
5772
  };
5748
5773
 
@@ -5803,10 +5828,10 @@ const renderEventListeners = () => {
5803
5828
  name: HandleDragLeave,
5804
5829
  params: ['handleDragLeave']
5805
5830
  }, {
5806
- name: HandleDragStart,
5807
- params: ['handleDragStart'],
5808
5831
  // @ts-ignore
5809
- dragEffect: 'copyMove'
5832
+ dragEffect: 'copyMove',
5833
+ name: HandleDragStart,
5834
+ params: ['handleDragStart']
5810
5835
  }];
5811
5836
  };
5812
5837
 
@@ -5838,18 +5863,18 @@ const getSavedWorkspacePath = savedState => {
5838
5863
  const restoreState = savedState => {
5839
5864
  if (!savedState) {
5840
5865
  return {
5841
- root: '',
5866
+ deltaY: 0,
5842
5867
  minLineY: 0,
5843
- deltaY: 0
5868
+ root: ''
5844
5869
  };
5845
5870
  }
5846
5871
  const root = getSavedWorkspacePath(savedState);
5847
5872
  const minLineY = getSavedMinLineY(savedState);
5848
5873
  const deltaY = getSavedDeltaY(savedState);
5849
5874
  return {
5850
- root,
5875
+ deltaY,
5851
5876
  minLineY,
5852
- deltaY
5877
+ root
5853
5878
  };
5854
5879
  };
5855
5880
 
@@ -5882,11 +5907,11 @@ const mergeVisibleWithHiddenItems = (visibleItems, hiddenItems) => {
5882
5907
  // TODO maybe just insert items into explorer and refresh whole explorer
5883
5908
  const revealItemHidden = async (state, uri) => {
5884
5909
  const {
5885
- root,
5886
- pathSeparator,
5887
5910
  items,
5911
+ maxLineY,
5888
5912
  minLineY,
5889
- maxLineY
5913
+ pathSeparator,
5914
+ root
5890
5915
  } = state;
5891
5916
  const pathParts = getPathParts(root, uri, pathSeparator);
5892
5917
  if (pathParts.length === 0) {
@@ -5902,34 +5927,34 @@ const revealItemHidden = async (state, uri) => {
5902
5927
  throw new Error(`File not found in explorer ${uri}`);
5903
5928
  }
5904
5929
  const {
5905
- newMinLineY,
5906
- newMaxLineY
5930
+ newMaxLineY,
5931
+ newMinLineY
5907
5932
  } = scrollInto(index, minLineY, maxLineY);
5908
5933
  return {
5909
5934
  ...state,
5910
- items: mergedDirents,
5911
5935
  focused: true,
5912
5936
  focusedIndex: index,
5913
- minLineY: newMinLineY,
5914
- maxLineY: newMaxLineY
5937
+ items: mergedDirents,
5938
+ maxLineY: newMaxLineY,
5939
+ minLineY: newMinLineY
5915
5940
  };
5916
5941
  };
5917
5942
 
5918
5943
  const revealItemVisible = (state, index) => {
5919
5944
  const {
5920
- minLineY,
5921
- maxLineY
5945
+ maxLineY,
5946
+ minLineY
5922
5947
  } = state;
5923
5948
  const {
5924
- newMinLineY,
5925
- newMaxLineY
5949
+ newMaxLineY,
5950
+ newMinLineY
5926
5951
  } = scrollInto(index, minLineY, maxLineY);
5927
5952
  return {
5928
5953
  ...state,
5929
5954
  focused: true,
5930
5955
  focusedIndex: index,
5931
- minLineY: newMinLineY,
5932
- maxLineY: newMaxLineY
5956
+ maxLineY: newMaxLineY,
5957
+ minLineY: newMinLineY
5933
5958
  };
5934
5959
  };
5935
5960
 
@@ -5952,19 +5977,19 @@ const isExpandedDirectory = dirent => {
5952
5977
 
5953
5978
  const saveState = state => {
5954
5979
  const {
5955
- items,
5956
- root,
5957
5980
  deltaY,
5981
+ items,
5982
+ maxLineY,
5958
5983
  minLineY,
5959
- maxLineY
5984
+ root
5960
5985
  } = state;
5961
5986
  const expandedPaths = items.filter(isExpandedDirectory).map(getPath);
5962
5987
  return {
5988
+ deltaY,
5963
5989
  expandedPaths,
5964
- root,
5965
- minLineY,
5966
5990
  maxLineY,
5967
- deltaY
5991
+ minLineY,
5992
+ root
5968
5993
  };
5969
5994
  };
5970
5995
 
@@ -5993,8 +6018,8 @@ const getLastSelectedIndex = items => {
5993
6018
  };
5994
6019
  const selectDown = state => {
5995
6020
  const {
5996
- items,
5997
- focusedIndex
6021
+ focusedIndex,
6022
+ items
5998
6023
  } = state;
5999
6024
  const lastSelectedIndex = getLastSelectedIndex(items);
6000
6025
  const targetIndex = lastSelectedIndex === -1 ? focusedIndex : lastSelectedIndex;
@@ -6007,8 +6032,8 @@ const selectDown = state => {
6007
6032
  }));
6008
6033
  return {
6009
6034
  ...state,
6010
- items: newItems,
6011
- focusedIndex: targetIndex + 1
6035
+ focusedIndex: targetIndex + 1,
6036
+ items: newItems
6012
6037
  };
6013
6038
  };
6014
6039
 
@@ -6028,8 +6053,8 @@ const setSelectedIndices = (state, indices) => {
6028
6053
 
6029
6054
  const selectUp = state => {
6030
6055
  const {
6031
- items,
6032
- focusedIndex
6056
+ focusedIndex,
6057
+ items
6033
6058
  } = state;
6034
6059
  const firstSelectedIndex = items.findIndex(item => item.selected);
6035
6060
  const targetIndex = firstSelectedIndex === -1 ? focusedIndex : firstSelectedIndex;
@@ -6074,11 +6099,10 @@ const getEditingIcon = async (editingType, value, direntType) => {
6074
6099
 
6075
6100
  const updateEditingValue = async (state, value, inputSource = User) => {
6076
6101
  const {
6077
- editingType,
6078
- items,
6079
6102
  editingIndex,
6080
- focusedIndex
6081
- } = state;
6103
+ editingType,
6104
+ focusedIndex,
6105
+ items} = state;
6082
6106
  const editingIcon = await getEditingIcon(editingType, value, items[editingIndex]?.type);
6083
6107
 
6084
6108
  // Get sibling file names for validation during file/folder creation
@@ -6089,9 +6113,9 @@ const updateEditingValue = async (state, value, inputSource = User) => {
6089
6113
  const editingErrorMessage = validateFileName2(value, siblingFileNames);
6090
6114
  return {
6091
6115
  ...state,
6092
- editingValue: value,
6116
+ editingErrorMessage,
6093
6117
  editingIcon,
6094
- editingErrorMessage
6118
+ editingValue: value
6095
6119
  };
6096
6120
  };
6097
6121
 
@@ -6102,6 +6126,10 @@ const commandMap = {
6102
6126
  'Explorer.collapseAll': wrapListItemCommand(collapseAll),
6103
6127
  'Explorer.copyPath': wrapListItemCommand(copyPath),
6104
6128
  'Explorer.copyRelativePath': wrapListItemCommand(copyRelativePath),
6129
+ 'Explorer.create': create,
6130
+ // not wrapped
6131
+ 'Explorer.create2': create2,
6132
+ 'Explorer.diff2': diff2,
6105
6133
  'Explorer.expandAll': wrapListItemCommand(expandAll),
6106
6134
  'Explorer.expandRecursively': wrapListItemCommand(expandRecursively),
6107
6135
  'Explorer.focus': wrapListItemCommand(focus),
@@ -6112,6 +6140,8 @@ const commandMap = {
6112
6140
  'Explorer.focusNone': wrapListItemCommand(focusNone),
6113
6141
  'Explorer.focusPrevious': wrapListItemCommand(focusPrevious),
6114
6142
  'Explorer.getCommandIds': getCommandIds,
6143
+ 'Explorer.getKeyBindings': getKeyBindings,
6144
+ 'Explorer.getMenuEntries': getMenuEntries,
6115
6145
  'Explorer.getMenuEntries2': wrapGetter(getMenuEntries2),
6116
6146
  'Explorer.getMouseActions': getMouseActions,
6117
6147
  'Explorer.handleArrowLeft': wrapListItemCommand(handleArrowLeft),
@@ -6144,6 +6174,7 @@ const commandMap = {
6144
6174
  'Explorer.handleWheel': wrapListItemCommand(handleWheel),
6145
6175
  'Explorer.handleWorkspaceChange': wrapListItemCommand(handleWorkspaceChange),
6146
6176
  'Explorer.handleWorkspaceRefresh': wrapListItemCommand(handleWorkspaceRefresh),
6177
+ 'Explorer.initialize': initialize,
6147
6178
  'Explorer.loadContent': wrapListItemCommand(loadContent),
6148
6179
  'Explorer.newFile': wrapListItemCommand(newFile),
6149
6180
  'Explorer.newFolder': wrapListItemCommand(newFolder),
@@ -6151,29 +6182,22 @@ const commandMap = {
6151
6182
  'Explorer.refresh': wrapListItemCommand(refresh),
6152
6183
  'Explorer.removeDirent': wrapListItemCommand(removeDirent),
6153
6184
  'Explorer.renameDirent': wrapListItemCommand(renameDirent),
6185
+ 'Explorer.render2': render2,
6186
+ 'Explorer.renderActions2': renderActions,
6187
+ 'Explorer.renderEventListeners': renderEventListeners,
6154
6188
  'Explorer.restoreState': restoreState,
6155
6189
  'Explorer.revealItem': wrapListItemCommand(revealItem),
6190
+ 'Explorer.saveState': wrapGetter(saveState),
6156
6191
  'Explorer.selectAll': wrapListItemCommand(selectAll),
6157
6192
  'Explorer.selectDown': wrapListItemCommand(selectDown),
6158
6193
  'Explorer.selectIndices': wrapListItemCommand(setSelectedIndices),
6159
6194
  'Explorer.selectUp': wrapListItemCommand(selectUp),
6160
6195
  'Explorer.setDeltaY': wrapListItemCommand(setDeltaY),
6161
6196
  'Explorer.setSelectedIndices': wrapListItemCommand(setSelectedIndices),
6197
+ 'Explorer.terminate': terminate,
6162
6198
  'Explorer.toggleIndividualSelection': wrapListItemCommand(toggleIndividualSelection),
6163
6199
  'Explorer.updateEditingValue': wrapListItemCommand(updateEditingValue),
6164
- 'Explorer.updateIcons': wrapListItemCommand(updateIcons),
6165
- // not wrapped
6166
- 'Explorer.create2': create2,
6167
- 'Explorer.diff2': diff2,
6168
- 'Explorer.getKeyBindings': getKeyBindings,
6169
- 'Explorer.getMenuEntries': getMenuEntries,
6170
- 'Explorer.render2': render2,
6171
- 'Explorer.renderActions2': renderActions,
6172
- 'Explorer.renderEventListeners': renderEventListeners,
6173
- 'Explorer.saveState': wrapGetter(saveState),
6174
- 'Explorer.terminate': terminate,
6175
- 'Explorer.initialize': initialize,
6176
- 'Explorer.create': create
6200
+ 'Explorer.updateIcons': wrapListItemCommand(updateIcons)
6177
6201
  };
6178
6202
 
6179
6203
  const listen = async () => {