@lvce-editor/explorer-view 5.24.0 → 5.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1339,6 +1339,9 @@ const sendMessagePortToSourceControlWorker = async port => {
1339
1339
  const command = 'SourceControl.handleMessagePort';
1340
1340
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSourceControlWorker', port, command, 0);
1341
1341
  };
1342
+ const openUri$1 = async (uri, focus, options) => {
1343
+ await invoke$2('Main.openUri', uri, focus, options);
1344
+ };
1342
1345
 
1343
1346
  const {
1344
1347
  invoke: invoke$1,
@@ -1764,7 +1767,7 @@ const mergeTrees = (a, b) => {
1764
1767
  };
1765
1768
 
1766
1769
  const openUri = async (uri, focus) => {
1767
- await invoke$2(/* Main.openAbsolutePath */'Main.openUri', /* absolutePath */uri, /* focus */focus);
1770
+ await openUri$1(uri, /* focus */focus);
1768
1771
  };
1769
1772
 
1770
1773
  const refreshWorkspace = async () => {
@@ -2257,21 +2260,6 @@ const copyRelativePath = async state => {
2257
2260
  return state;
2258
2261
  };
2259
2262
 
2260
- // TODO optimize this function to return the minimum number
2261
- // of visible items needed, e.g. when not scrolled 5 items with
2262
- // 20px fill 100px but when scrolled 6 items are needed
2263
- const getNumberOfVisibleItems = (listHeight, itemHeight) => {
2264
- if (listHeight <= 0 || itemHeight <= 0) {
2265
- return 0;
2266
- }
2267
- return Math.ceil(listHeight / itemHeight) + 1;
2268
- };
2269
-
2270
- const getExplorerMaxLineY = (minLineY, height, itemHeight, direntsLength) => {
2271
- const maxLineY = minLineY + Math.min(getNumberOfVisibleItems(height, itemHeight), direntsLength);
2272
- return maxLineY;
2273
- };
2274
-
2275
2263
  const getIconsCached = (dirents, fileIconCache) => {
2276
2264
  return dirents.map(dirent => fileIconCache[dirent]);
2277
2265
  };
@@ -2356,6 +2344,21 @@ const getFileIcons = async (dirents, fileIconCache) => {
2356
2344
  };
2357
2345
  };
2358
2346
 
2347
+ // TODO optimize this function to return the minimum number
2348
+ // of visible items needed, e.g. when not scrolled 5 items with
2349
+ // 20px fill 100px but when scrolled 6 items are needed
2350
+ const getNumberOfVisibleItems = (listHeight, itemHeight) => {
2351
+ if (listHeight <= 0 || itemHeight <= 0) {
2352
+ return 0;
2353
+ }
2354
+ return Math.ceil(listHeight / itemHeight) + 1;
2355
+ };
2356
+
2357
+ const getExplorerMaxLineY = (minLineY, height, itemHeight, direntsLength) => {
2358
+ const maxLineY = minLineY + Math.min(getNumberOfVisibleItems(height, itemHeight), direntsLength);
2359
+ return maxLineY;
2360
+ };
2361
+
2359
2362
  const None$4 = 0;
2360
2363
  const Right = 1;
2361
2364
  const Down = 2;
@@ -4351,6 +4354,9 @@ const getNewDropTargets = (state, index) => {
4351
4354
  return dropTargetFull;
4352
4355
  }
4353
4356
  const item = items[index];
4357
+ if (!item) {
4358
+ return dropTargetFull;
4359
+ }
4354
4360
  if (!canBeDroppedInto(item)) {
4355
4361
  const startIndex = getParentStartIndex(items, index);
4356
4362
  const endIndex = getParentEndIndex(items, index);
@@ -5084,6 +5090,9 @@ const handleUpload = async (state, dirents) => {
5084
5090
  };
5085
5091
 
5086
5092
  const setDeltaY = async (state, deltaY) => {
5093
+ if (!Number.isFinite(deltaY)) {
5094
+ return state;
5095
+ }
5087
5096
  const {
5088
5097
  height,
5089
5098
  itemHeight,
@@ -5426,14 +5435,11 @@ const getEditingType = direntType => {
5426
5435
 
5427
5436
  const getNewDirentsForRename = (items, focusedIndex) => {
5428
5437
  const item = items[focusedIndex];
5429
- const newItems = [...items];
5430
5438
  const editingType = getEditingType(item.type);
5431
- // TODO avoid mutation
5432
- newItems[focusedIndex] = {
5439
+ return [...items.slice(0, focusedIndex), {
5433
5440
  ...item,
5434
5441
  type: editingType
5435
- };
5436
- return newItems;
5442
+ }, ...items.slice(focusedIndex + 1)];
5437
5443
  };
5438
5444
 
5439
5445
  const getRenameSelectionRange = name => {
@@ -5520,6 +5526,13 @@ const getUnique = items => {
5520
5526
  return seens;
5521
5527
  };
5522
5528
 
5529
+ const getIndent = item => item.indent;
5530
+ const getUniqueIndents = items => {
5531
+ const indents = items.map(getIndent);
5532
+ const uniqueIndents = getUnique(indents);
5533
+ return uniqueIndents;
5534
+ };
5535
+
5523
5536
  const renderCss = (oldState, newState) => {
5524
5537
  const {
5525
5538
  focusedIndex,
@@ -5531,8 +5544,7 @@ const renderCss = (oldState, newState) => {
5531
5544
  visibleExplorerItems,
5532
5545
  width
5533
5546
  } = newState;
5534
- const indents = visibleExplorerItems.map(item => item.indent);
5535
- const uniqueIndents = getUnique(indents);
5547
+ const uniqueIndents = getUniqueIndents(visibleExplorerItems);
5536
5548
  const indent = 8;
5537
5549
  const padding = 10;
5538
5550
  const fileIconWidth = 16;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "5.24.0",
3
+ "version": "5.26.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",