@lvce-editor/explorer-view 1.16.0 → 1.17.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.
- package/dist/explorerViewWorkerMain.js +95 -31
- package/package.json +1 -1
|
@@ -898,7 +898,7 @@ const compareDirent = (direntA, direntB) => {
|
|
|
898
898
|
return compareDirentType(direntA, direntB) || compareDirentName(direntA, direntB);
|
|
899
899
|
};
|
|
900
900
|
|
|
901
|
-
const getFileIcon
|
|
901
|
+
const getFileIcon = ({
|
|
902
902
|
name
|
|
903
903
|
}) => {
|
|
904
904
|
return '';
|
|
@@ -921,7 +921,7 @@ const computeExplorerRenamedDirent = (dirents, index, newName) => {
|
|
|
921
921
|
...oldDirent,
|
|
922
922
|
name: newName,
|
|
923
923
|
path: oldDirent.path.slice(0, -oldDirent.name.length) + newName,
|
|
924
|
-
icon: getFileIcon
|
|
924
|
+
icon: getFileIcon({
|
|
925
925
|
name: newName
|
|
926
926
|
})
|
|
927
927
|
};
|
|
@@ -1408,6 +1408,59 @@ const getExplorerMaxLineY = (minLineY, height, itemHeight, direntsLength) => {
|
|
|
1408
1408
|
return maxLineY;
|
|
1409
1409
|
};
|
|
1410
1410
|
|
|
1411
|
+
const getIconsCached = (dirents, fileIconCache) => {
|
|
1412
|
+
return dirents.map(dirent => fileIconCache[dirent.path]);
|
|
1413
|
+
};
|
|
1414
|
+
|
|
1415
|
+
const getMissingIconRequests = (dirents, fileIconCache) => {
|
|
1416
|
+
const missingRequests = [];
|
|
1417
|
+
for (const dirent of dirents) {
|
|
1418
|
+
if (!(dirent.path in fileIconCache)) {
|
|
1419
|
+
missingRequests.push({
|
|
1420
|
+
type: dirent.type,
|
|
1421
|
+
name: dirent.name,
|
|
1422
|
+
path: dirent.path
|
|
1423
|
+
});
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
return missingRequests;
|
|
1427
|
+
};
|
|
1428
|
+
|
|
1429
|
+
const requestFileIcons = async requests => {
|
|
1430
|
+
const promises = requests.map(request => request.type === File ? invoke('IconTheme.getFileIcon', {
|
|
1431
|
+
name: request.name
|
|
1432
|
+
}) : invoke('IconTheme.getFolderIcon', {
|
|
1433
|
+
name: request.name
|
|
1434
|
+
}));
|
|
1435
|
+
return Promise.all(promises);
|
|
1436
|
+
};
|
|
1437
|
+
|
|
1438
|
+
const updateIconCache = (iconCache, missingRequests, newIcons) => {
|
|
1439
|
+
if (missingRequests.length === 0) {
|
|
1440
|
+
return iconCache;
|
|
1441
|
+
}
|
|
1442
|
+
const newFileIconCache = {
|
|
1443
|
+
...iconCache
|
|
1444
|
+
};
|
|
1445
|
+
for (let i = 0; i < missingRequests.length; i++) {
|
|
1446
|
+
const request = missingRequests[i];
|
|
1447
|
+
const icon = newIcons[i];
|
|
1448
|
+
newFileIconCache[request.path] = icon;
|
|
1449
|
+
}
|
|
1450
|
+
return newFileIconCache;
|
|
1451
|
+
};
|
|
1452
|
+
|
|
1453
|
+
const getFileIcons = async (dirents, fileIconCache) => {
|
|
1454
|
+
const missingRequests = getMissingIconRequests(dirents, fileIconCache);
|
|
1455
|
+
const newIcons = await requestFileIcons(missingRequests);
|
|
1456
|
+
const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
|
|
1457
|
+
const icons = getIconsCached(dirents, newFileIconCache);
|
|
1458
|
+
return {
|
|
1459
|
+
icons,
|
|
1460
|
+
newFileIconCache
|
|
1461
|
+
};
|
|
1462
|
+
};
|
|
1463
|
+
|
|
1411
1464
|
const expandAll = async state => {
|
|
1412
1465
|
const {
|
|
1413
1466
|
items,
|
|
@@ -1445,9 +1498,16 @@ const expandAll = async state => {
|
|
|
1445
1498
|
}
|
|
1446
1499
|
}
|
|
1447
1500
|
const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, newDirents.length);
|
|
1501
|
+
const visible = newDirents.slice(minLineY, maxLineY);
|
|
1502
|
+
const {
|
|
1503
|
+
icons,
|
|
1504
|
+
newFileIconCache
|
|
1505
|
+
} = await getFileIcons(visible, state.fileIconCache);
|
|
1448
1506
|
return {
|
|
1449
1507
|
...state,
|
|
1450
1508
|
items: newDirents,
|
|
1509
|
+
icons,
|
|
1510
|
+
fileIconCache: newFileIconCache,
|
|
1451
1511
|
maxLineY
|
|
1452
1512
|
};
|
|
1453
1513
|
};
|
|
@@ -1747,13 +1807,17 @@ const TreeItem$1 = 'treeitem';
|
|
|
1747
1807
|
|
|
1748
1808
|
const Actions = 'Actions';
|
|
1749
1809
|
const Button$1 = 'Button';
|
|
1810
|
+
const ButtonNarrow = 'ButtonNarrow';
|
|
1750
1811
|
const ButtonPrimary = 'ButtonPrimary';
|
|
1812
|
+
const ButtonWide = 'ButtonWide';
|
|
1751
1813
|
const Chevron = 'Chevron';
|
|
1752
1814
|
const Explorer$1 = 'Explorer';
|
|
1753
1815
|
const FileIcon = 'FileIcon';
|
|
1754
1816
|
const IconButton = 'IconButton';
|
|
1755
1817
|
const InputBox = 'InputBox';
|
|
1756
1818
|
const Label = 'Label';
|
|
1819
|
+
const MaskIconChevronDown = 'MaskIconChevronDown';
|
|
1820
|
+
const MaskIconChevronRight = 'MaskIconChevronRight';
|
|
1757
1821
|
const TreeItem = 'TreeItem';
|
|
1758
1822
|
const TreeItemActive = 'TreeItemActive';
|
|
1759
1823
|
const Viewlet = 'Viewlet';
|
|
@@ -1778,13 +1842,13 @@ const P = 50;
|
|
|
1778
1842
|
|
|
1779
1843
|
const chevronDownVirtualDom = {
|
|
1780
1844
|
type: Div,
|
|
1781
|
-
className: `${Chevron} MaskIconChevronDown`,
|
|
1845
|
+
className: `${Chevron} ${MaskIconChevronDown}`,
|
|
1782
1846
|
childCount: 0
|
|
1783
1847
|
};
|
|
1784
1848
|
|
|
1785
1849
|
const chevronRightVirtualDom = {
|
|
1786
1850
|
type: Div,
|
|
1787
|
-
className: `${Chevron} MaskIconChevronRight`,
|
|
1851
|
+
className: `${Chevron} ${MaskIconChevronRight}`,
|
|
1788
1852
|
childCount: 0
|
|
1789
1853
|
};
|
|
1790
1854
|
|
|
@@ -1887,7 +1951,7 @@ const getExplorerWelcomeVirtualDom = isWide => {
|
|
|
1887
1951
|
childCount: 1
|
|
1888
1952
|
}, text(youHaveNotYetOpenedAFolder()), {
|
|
1889
1953
|
type: Button,
|
|
1890
|
-
className: mergeClassNames(Button$1, ButtonPrimary, isWide ?
|
|
1954
|
+
className: mergeClassNames(Button$1, ButtonPrimary, isWide ? ButtonWide : ButtonNarrow),
|
|
1891
1955
|
childCount: 1,
|
|
1892
1956
|
onClick: handleClickOpenFolder$1
|
|
1893
1957
|
}, text(openFolder$1())];
|
|
@@ -2239,22 +2303,6 @@ const handleBlur = state => {
|
|
|
2239
2303
|
};
|
|
2240
2304
|
};
|
|
2241
2305
|
|
|
2242
|
-
const getFileIcon = dirent => {
|
|
2243
|
-
if (dirent.type === File) {
|
|
2244
|
-
return invoke('IconTheme.getFileIcon', {
|
|
2245
|
-
name: dirent.name
|
|
2246
|
-
});
|
|
2247
|
-
}
|
|
2248
|
-
return invoke('IconTheme.getFolderIcon', {
|
|
2249
|
-
name: dirent.name
|
|
2250
|
-
});
|
|
2251
|
-
};
|
|
2252
|
-
const getFileIcons = async dirents => {
|
|
2253
|
-
const promises = dirents.map(getFileIcon);
|
|
2254
|
-
const icons = await Promise.all(promises);
|
|
2255
|
-
return icons;
|
|
2256
|
-
};
|
|
2257
|
-
|
|
2258
2306
|
const handleClickDirectory = async (state, dirent, index, keepFocus) => {
|
|
2259
2307
|
dirent.type = DirectoryExpanding;
|
|
2260
2308
|
// TODO handle error
|
|
@@ -2281,11 +2329,15 @@ const handleClickDirectory = async (state, dirent, index, keepFocus) => {
|
|
|
2281
2329
|
// TODO when focused index has changed while expanding, don't update it
|
|
2282
2330
|
const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, newDirents.length);
|
|
2283
2331
|
const parts = newDirents.slice(minLineY, maxLineY);
|
|
2284
|
-
const
|
|
2332
|
+
const {
|
|
2333
|
+
icons,
|
|
2334
|
+
newFileIconCache
|
|
2335
|
+
} = await getFileIcons(parts, state.fileIconCache);
|
|
2285
2336
|
return {
|
|
2286
2337
|
...state,
|
|
2287
2338
|
items: newDirents,
|
|
2288
2339
|
icons,
|
|
2340
|
+
fileIconCache: newFileIconCache,
|
|
2289
2341
|
focusedIndex: newIndex,
|
|
2290
2342
|
focused: keepFocus,
|
|
2291
2343
|
maxLineY
|
|
@@ -2312,11 +2364,15 @@ const handleClickDirectoryExpanded$1 = async (state, dirent, index, keepFocus) =
|
|
|
2312
2364
|
const newMinLineY = newMaxLineY - visibleItems;
|
|
2313
2365
|
const deltaY = newMinLineY * itemHeight;
|
|
2314
2366
|
const parts = newDirents.slice(minLineY, maxLineY);
|
|
2315
|
-
const
|
|
2367
|
+
const {
|
|
2368
|
+
icons,
|
|
2369
|
+
newFileIconCache
|
|
2370
|
+
} = await getFileIcons(parts, state.fileIconCache);
|
|
2316
2371
|
return {
|
|
2317
2372
|
...state,
|
|
2318
2373
|
items: newDirents,
|
|
2319
2374
|
icons,
|
|
2375
|
+
fileIconCache: newFileIconCache,
|
|
2320
2376
|
focusedIndex: index,
|
|
2321
2377
|
focused: keepFocus,
|
|
2322
2378
|
minLineY: newMinLineY,
|
|
@@ -2325,11 +2381,15 @@ const handleClickDirectoryExpanded$1 = async (state, dirent, index, keepFocus) =
|
|
|
2325
2381
|
};
|
|
2326
2382
|
}
|
|
2327
2383
|
const parts = newDirents.slice(state.minLineY, state.maxLineY);
|
|
2328
|
-
const
|
|
2384
|
+
const {
|
|
2385
|
+
icons,
|
|
2386
|
+
newFileIconCache
|
|
2387
|
+
} = await getFileIcons(parts, state.fileIconCache);
|
|
2329
2388
|
return {
|
|
2330
2389
|
...state,
|
|
2331
2390
|
items: newDirents,
|
|
2332
2391
|
icons,
|
|
2392
|
+
fileIconCache: newFileIconCache,
|
|
2333
2393
|
focusedIndex: index,
|
|
2334
2394
|
focused: keepFocus
|
|
2335
2395
|
};
|
|
@@ -3233,12 +3293,16 @@ const loadContent = async (state, savedState) => {
|
|
|
3233
3293
|
deltaY = savedState.deltaY;
|
|
3234
3294
|
}
|
|
3235
3295
|
const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, restoredDirents.length);
|
|
3236
|
-
const
|
|
3296
|
+
const {
|
|
3297
|
+
icons,
|
|
3298
|
+
newFileIconCache
|
|
3299
|
+
} = await getFileIcons(restoredDirents, Object.create(null));
|
|
3237
3300
|
return {
|
|
3238
3301
|
...state,
|
|
3239
3302
|
root,
|
|
3240
3303
|
items: restoredDirents,
|
|
3241
3304
|
icons,
|
|
3305
|
+
fileIconCache: newFileIconCache,
|
|
3242
3306
|
minLineY,
|
|
3243
3307
|
deltaY,
|
|
3244
3308
|
maxLineY,
|
|
@@ -3369,15 +3433,15 @@ const removeDirent = async state => {
|
|
|
3369
3433
|
indexToFocus = Math.max(state.focusedIndex - 1, 0);
|
|
3370
3434
|
}
|
|
3371
3435
|
const visible = newDirents.slice(state.minLineY, state.maxLineY);
|
|
3372
|
-
const
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
});
|
|
3436
|
+
const {
|
|
3437
|
+
icons,
|
|
3438
|
+
newFileIconCache
|
|
3439
|
+
} = await getFileIcons(visible, state.fileIconCache);
|
|
3376
3440
|
return {
|
|
3377
3441
|
...state,
|
|
3378
3442
|
items: newDirents,
|
|
3379
|
-
// @ts-ignore
|
|
3380
3443
|
icons,
|
|
3444
|
+
fileIconCache: newFileIconCache,
|
|
3381
3445
|
focusedIndex: indexToFocus
|
|
3382
3446
|
};
|
|
3383
3447
|
};
|
|
@@ -3797,7 +3861,7 @@ const setDeltaY = (state, deltaY) => {
|
|
|
3797
3861
|
};
|
|
3798
3862
|
|
|
3799
3863
|
const updateEditingValue = (state, value) => {
|
|
3800
|
-
const editingIcon = getFileIcon
|
|
3864
|
+
const editingIcon = getFileIcon({
|
|
3801
3865
|
name: value
|
|
3802
3866
|
});
|
|
3803
3867
|
return {
|