@lvce-editor/explorer-view 2.39.0 → 2.40.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 +97 -153
- package/package.json +1 -1
|
@@ -441,11 +441,11 @@ const remove$1 = id => {
|
|
|
441
441
|
delete callbacks[id];
|
|
442
442
|
};
|
|
443
443
|
let id = 0;
|
|
444
|
-
const create$3 = () => {
|
|
444
|
+
const create$3$1 = () => {
|
|
445
445
|
return ++id;
|
|
446
446
|
};
|
|
447
447
|
const registerPromise = () => {
|
|
448
|
-
const id = create$3();
|
|
448
|
+
const id = create$3$1();
|
|
449
449
|
const {
|
|
450
450
|
resolve,
|
|
451
451
|
promise
|
|
@@ -835,7 +835,7 @@ const listen$1 = async (module, options) => {
|
|
|
835
835
|
const ipc = module.wrap(rawIpc);
|
|
836
836
|
return ipc;
|
|
837
837
|
};
|
|
838
|
-
const create$
|
|
838
|
+
const create$3 = async ({
|
|
839
839
|
commandMap
|
|
840
840
|
}) => {
|
|
841
841
|
// TODO create a commandMap per rpc instance
|
|
@@ -847,25 +847,43 @@ const create$2 = async ({
|
|
|
847
847
|
};
|
|
848
848
|
const WebWorkerRpcClient = {
|
|
849
849
|
__proto__: null,
|
|
850
|
-
create: create$
|
|
850
|
+
create: create$3
|
|
851
851
|
};
|
|
852
852
|
|
|
853
853
|
const rpcs = Object.create(null);
|
|
854
|
-
const set$
|
|
854
|
+
const set$7 = (id, rpc) => {
|
|
855
855
|
rpcs[id] = rpc;
|
|
856
856
|
};
|
|
857
857
|
const get$1 = id => {
|
|
858
858
|
return rpcs[id];
|
|
859
859
|
};
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
return
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
860
|
+
|
|
861
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
862
|
+
|
|
863
|
+
const create$2 = rpcId => {
|
|
864
|
+
return {
|
|
865
|
+
// @ts-ignore
|
|
866
|
+
invoke(method, ...params) {
|
|
867
|
+
const rpc = get$1(rpcId);
|
|
868
|
+
// @ts-ignore
|
|
869
|
+
return rpc.invoke(method, ...params);
|
|
870
|
+
},
|
|
871
|
+
// @ts-ignore
|
|
872
|
+
invokeAndTransfer(method, ...params) {
|
|
873
|
+
const rpc = get$1(rpcId);
|
|
874
|
+
// @ts-ignore
|
|
875
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
876
|
+
},
|
|
877
|
+
set(rpc) {
|
|
878
|
+
set$7(rpcId, rpc);
|
|
879
|
+
}
|
|
880
|
+
};
|
|
868
881
|
};
|
|
882
|
+
const RendererWorker$1 = 1;
|
|
883
|
+
const {
|
|
884
|
+
invoke: invoke$2,
|
|
885
|
+
set: set$2
|
|
886
|
+
} = create$2(RendererWorker$1);
|
|
869
887
|
const RendererWorker = {
|
|
870
888
|
__proto__: null,
|
|
871
889
|
invoke: invoke$2,
|
|
@@ -1291,13 +1309,13 @@ const sortExplorerItems = rawDirents => {
|
|
|
1291
1309
|
};
|
|
1292
1310
|
|
|
1293
1311
|
// TODO figure out whether this uses too much memory (name,path -> redundant, depth could be computed on demand)
|
|
1294
|
-
const toDisplayDirent = (
|
|
1295
|
-
const path = join2(
|
|
1312
|
+
const toDisplayDirent = (parentPath, parentDepth, rawDirent, index, length) => {
|
|
1313
|
+
const path = join2(parentPath, rawDirent.name);
|
|
1296
1314
|
return {
|
|
1297
1315
|
name: rawDirent.name,
|
|
1298
1316
|
posInSet: index + 1,
|
|
1299
1317
|
setSize: length,
|
|
1300
|
-
depth:
|
|
1318
|
+
depth: parentDepth + 1,
|
|
1301
1319
|
type: rawDirent.type,
|
|
1302
1320
|
path,
|
|
1303
1321
|
// TODO storing absolute path might be too costly, could also store relative path here
|
|
@@ -1306,7 +1324,7 @@ const toDisplayDirent = (parentDirent, rawDirent, index, length) => {
|
|
|
1306
1324
|
};
|
|
1307
1325
|
};
|
|
1308
1326
|
|
|
1309
|
-
const toDisplayDirents = (pathSeparator, rawDirents,
|
|
1327
|
+
const toDisplayDirents = (pathSeparator, rawDirents, parentDirentPath, parentDirentDepth, excluded) => {
|
|
1310
1328
|
rawDirents = sortExplorerItems(rawDirents);
|
|
1311
1329
|
const result = [];
|
|
1312
1330
|
const visibleItems = rawDirents.filter(item => {
|
|
@@ -1318,7 +1336,7 @@ const toDisplayDirents = (pathSeparator, rawDirents, parentDirent, excluded) =>
|
|
|
1318
1336
|
const count = visibleItems.length;
|
|
1319
1337
|
for (let i = 0; i < visibleItems.length; i++) {
|
|
1320
1338
|
const rawDirent = visibleItems[i];
|
|
1321
|
-
result.push(toDisplayDirent(
|
|
1339
|
+
result.push(toDisplayDirent(parentDirentPath, parentDirentDepth, rawDirent, i, count));
|
|
1322
1340
|
}
|
|
1323
1341
|
return result;
|
|
1324
1342
|
};
|
|
@@ -1331,18 +1349,16 @@ const getChildDirentsRaw = async uri => {
|
|
|
1331
1349
|
}
|
|
1332
1350
|
return rawDirents;
|
|
1333
1351
|
};
|
|
1334
|
-
const getChildDirents = async (pathSeparator,
|
|
1352
|
+
const getChildDirents = async (pathSeparator, parentDirentPath, parentDirentDepth, excluded = []) => {
|
|
1335
1353
|
string(pathSeparator);
|
|
1336
|
-
object(parentDirent);
|
|
1337
1354
|
// TODO use event/actor based code instead, this is impossible to cancel right now
|
|
1338
1355
|
// also cancel updating when opening new folder
|
|
1339
1356
|
// const dispose = state => state.pendingRequests.forEach(cancelRequest)
|
|
1340
1357
|
// TODO should use FileSystem directly in this case because it is globally available anyway
|
|
1341
1358
|
// and more typesafe than Command.execute
|
|
1342
1359
|
// and more performant
|
|
1343
|
-
const
|
|
1344
|
-
const
|
|
1345
|
-
const displayDirents = toDisplayDirents(pathSeparator, rawDirents, parentDirent, excluded);
|
|
1360
|
+
const rawDirents = await getChildDirentsRaw(parentDirentPath);
|
|
1361
|
+
const displayDirents = toDisplayDirents(pathSeparator, rawDirents, parentDirentPath, parentDirentDepth, excluded);
|
|
1346
1362
|
return displayDirents;
|
|
1347
1363
|
};
|
|
1348
1364
|
|
|
@@ -1374,7 +1390,7 @@ const orderDirents = dirents => {
|
|
|
1374
1390
|
};
|
|
1375
1391
|
|
|
1376
1392
|
const getPathPartChildren = async pathPart => {
|
|
1377
|
-
const children = await getChildDirents(pathPart.pathSeparator, pathPart);
|
|
1393
|
+
const children = await getChildDirents(pathPart.pathSeparator, pathPart.path, pathPart.depth);
|
|
1378
1394
|
return children;
|
|
1379
1395
|
};
|
|
1380
1396
|
const getPathPartsChildren = async pathparts => {
|
|
@@ -1484,98 +1500,11 @@ const acceptCreateFolder = async state => {
|
|
|
1484
1500
|
return acceptCreate(state, Directory, mkdir);
|
|
1485
1501
|
};
|
|
1486
1502
|
|
|
1487
|
-
|
|
1488
|
-
const
|
|
1489
|
-
|
|
1490
|
-
let innerEndIndex = index + 1;
|
|
1491
|
-
let insertIndex = -1;
|
|
1492
|
-
let posInSet = -1;
|
|
1493
|
-
const oldDirent = dirents[index];
|
|
1494
|
-
const newDirent = {
|
|
1495
|
-
...oldDirent,
|
|
1496
|
-
name: newName,
|
|
1497
|
-
path: oldDirent.path.slice(0, -oldDirent.name.length) + newName,
|
|
1498
|
-
icon: ''
|
|
1499
|
-
};
|
|
1500
|
-
const {
|
|
1501
|
-
depth
|
|
1502
|
-
} = newDirent;
|
|
1503
|
-
// TODO
|
|
1504
|
-
for (; startIndex >= 0; startIndex--) {
|
|
1505
|
-
const dirent = dirents[startIndex];
|
|
1506
|
-
if (dirent.depth > depth) {
|
|
1507
|
-
continue;
|
|
1508
|
-
}
|
|
1509
|
-
if (dirent.depth < depth) {
|
|
1510
|
-
break;
|
|
1511
|
-
}
|
|
1512
|
-
if (compareDirent(dirent, newDirent) === 1) {
|
|
1513
|
-
insertIndex = startIndex;
|
|
1514
|
-
posInSet = dirent.posInSet;
|
|
1515
|
-
// dirent.posInSet++
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
startIndex++;
|
|
1519
|
-
for (; innerEndIndex < dirents.length; innerEndIndex++) {
|
|
1520
|
-
const dirent = dirents[innerEndIndex];
|
|
1521
|
-
if (dirent.depth <= depth) {
|
|
1522
|
-
break;
|
|
1523
|
-
}
|
|
1524
|
-
dirent.path = newDirent.path + dirent.path.slice(oldDirent.path.length);
|
|
1525
|
-
}
|
|
1526
|
-
innerEndIndex--;
|
|
1527
|
-
let endIndex = innerEndIndex + 1;
|
|
1528
|
-
for (; endIndex < dirents.length; endIndex++) {
|
|
1529
|
-
const dirent = dirents[endIndex];
|
|
1530
|
-
if (dirent.depth > depth) {
|
|
1531
|
-
continue;
|
|
1532
|
-
}
|
|
1533
|
-
if (dirent.depth < depth) {
|
|
1534
|
-
break;
|
|
1535
|
-
}
|
|
1536
|
-
if (insertIndex === -1 && compareDirent(dirent, newDirent) === -1) {
|
|
1537
|
-
for (; endIndex < dirents.length; endIndex++) {
|
|
1538
|
-
}
|
|
1539
|
-
insertIndex = endIndex;
|
|
1540
|
-
posInSet = dirent.posInSet + 1;
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
endIndex--;
|
|
1544
|
-
for (let j = startIndex; j < index; j++) {
|
|
1545
|
-
const dirent = dirents[j];
|
|
1546
|
-
if (dirent.depth === depth) {
|
|
1547
|
-
dirent.posInSet++;
|
|
1548
|
-
}
|
|
1549
|
-
}
|
|
1550
|
-
for (let j = index; j < endIndex; j++) {
|
|
1551
|
-
const dirent = dirents[j];
|
|
1552
|
-
if (dirent.depth === depth) {
|
|
1553
|
-
dirent.posInSet--;
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
// for (let j = startIndex; j < index; j++) {
|
|
1558
|
-
// const dirent = dirents[j]
|
|
1559
|
-
// dirent.posInSet++
|
|
1560
|
-
// }
|
|
1561
|
-
|
|
1562
|
-
if (insertIndex === -1) {
|
|
1563
|
-
insertIndex = index;
|
|
1564
|
-
return {
|
|
1565
|
-
focusedIndex: index,
|
|
1566
|
-
newDirents: [...dirents.slice(0, index), newDirent, ...dirents.slice(index + 1)]
|
|
1567
|
-
};
|
|
1568
|
-
}
|
|
1569
|
-
newDirent.posInSet = posInSet;
|
|
1570
|
-
const newDirents = [...dirents];
|
|
1571
|
-
if (index < insertIndex) {
|
|
1572
|
-
insertIndex--;
|
|
1573
|
-
}
|
|
1574
|
-
newDirents.splice(index, 1);
|
|
1575
|
-
newDirents.splice(insertIndex, 0, newDirent);
|
|
1503
|
+
const computeExplorerRenamedDirentUpdate = async (root, parentPath, parentDepth) => {
|
|
1504
|
+
const children = await getChildDirents('/', parentPath, parentDepth, []);
|
|
1505
|
+
const relativeDirname = parentPath.slice(root.length);
|
|
1576
1506
|
return {
|
|
1577
|
-
|
|
1578
|
-
focusedIndex: insertIndex
|
|
1507
|
+
[relativeDirname]: children
|
|
1579
1508
|
};
|
|
1580
1509
|
};
|
|
1581
1510
|
|
|
@@ -1593,30 +1522,65 @@ const createNewDirentsRename = async (renamedDirent, editingValue, pathSeparator
|
|
|
1593
1522
|
return true;
|
|
1594
1523
|
};
|
|
1595
1524
|
|
|
1525
|
+
const getIndex = (dirents, uri) => {
|
|
1526
|
+
for (let i = 0; i < dirents.length; i++) {
|
|
1527
|
+
const dirent = dirents[i];
|
|
1528
|
+
if (dirent.path === uri) {
|
|
1529
|
+
return i;
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
return -1;
|
|
1533
|
+
};
|
|
1534
|
+
|
|
1535
|
+
const updateTree2 = (tree, update) => {
|
|
1536
|
+
const updatedTree = {
|
|
1537
|
+
...tree,
|
|
1538
|
+
...update
|
|
1539
|
+
};
|
|
1540
|
+
return updatedTree;
|
|
1541
|
+
};
|
|
1542
|
+
|
|
1596
1543
|
const acceptRename = async state => {
|
|
1597
1544
|
const {
|
|
1598
1545
|
editingIndex,
|
|
1599
1546
|
editingValue,
|
|
1600
|
-
items
|
|
1547
|
+
items,
|
|
1548
|
+
root,
|
|
1549
|
+
minLineY,
|
|
1550
|
+
height,
|
|
1551
|
+
itemHeight,
|
|
1552
|
+
fileIconCache
|
|
1553
|
+
} = state;
|
|
1601
1554
|
const renamedDirent = items[editingIndex];
|
|
1602
1555
|
const successful = await createNewDirentsRename(renamedDirent, editingValue);
|
|
1603
1556
|
if (!successful) {
|
|
1604
1557
|
return state;
|
|
1605
1558
|
}
|
|
1559
|
+
const dirname = dirname2(renamedDirent.path);
|
|
1560
|
+
const newUri = join2(dirname, editingValue);
|
|
1561
|
+
const update = await computeExplorerRenamedDirentUpdate(root, dirname, renamedDirent.depth - 1);
|
|
1562
|
+
const tree = createTree(items, root);
|
|
1563
|
+
const newTree = updateTree2(tree, update);
|
|
1564
|
+
const newDirents = treeToArray(newTree, root);
|
|
1565
|
+
const newFocusedIndex = getIndex(newDirents, newUri);
|
|
1566
|
+
const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, newDirents.length);
|
|
1567
|
+
const visible = newDirents.slice(minLineY, maxLineY);
|
|
1606
1568
|
const {
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
} =
|
|
1569
|
+
icons,
|
|
1570
|
+
newFileIconCache
|
|
1571
|
+
} = await getFileIcons(visible, fileIconCache);
|
|
1610
1572
|
return {
|
|
1611
1573
|
...state,
|
|
1612
1574
|
editingIndex: -1,
|
|
1613
1575
|
editingValue: '',
|
|
1614
1576
|
editingType: None$5,
|
|
1615
1577
|
editingIcon: '',
|
|
1616
|
-
focusedIndex,
|
|
1578
|
+
focusedIndex: newFocusedIndex,
|
|
1617
1579
|
focused: true,
|
|
1618
1580
|
focus: List,
|
|
1619
|
-
items: newDirents
|
|
1581
|
+
items: newDirents,
|
|
1582
|
+
icons,
|
|
1583
|
+
fileIconCache: newFileIconCache
|
|
1620
1584
|
};
|
|
1621
1585
|
};
|
|
1622
1586
|
|
|
@@ -2019,7 +1983,7 @@ const expandAll = async state => {
|
|
|
2019
1983
|
dirent.type = DirectoryExpanding;
|
|
2020
1984
|
// TODO handle error
|
|
2021
1985
|
// TODO race condition
|
|
2022
|
-
const childDirents = await getChildDirents(pathSeparator, dirent);
|
|
1986
|
+
const childDirents = await getChildDirents(pathSeparator, dirent.path, dirent.depth);
|
|
2023
1987
|
const newIndex = newDirents.indexOf(dirent);
|
|
2024
1988
|
if (newIndex === -1) {
|
|
2025
1989
|
continue;
|
|
@@ -2064,7 +2028,7 @@ const getChildDirentsRecursively = async (dirent, pathSeparator) => {
|
|
|
2064
2028
|
case Directory:
|
|
2065
2029
|
case DirectoryExpanding:
|
|
2066
2030
|
case DirectoryExpanded:
|
|
2067
|
-
const childDirents = await getChildDirents(pathSeparator, dirent);
|
|
2031
|
+
const childDirents = await getChildDirents(pathSeparator, dirent.path, dirent.depth);
|
|
2068
2032
|
const all = [makeExpanded(dirent)];
|
|
2069
2033
|
for (const childDirent of childDirents) {
|
|
2070
2034
|
const childAll = await getChildDirentsRecursively(childDirent, pathSeparator);
|
|
@@ -2657,7 +2621,7 @@ const handleClickDirectory = async (state, dirent, index, keepFocus) => {
|
|
|
2657
2621
|
// @ts-ignore
|
|
2658
2622
|
dirent.type = DirectoryExpanding;
|
|
2659
2623
|
// TODO handle error
|
|
2660
|
-
const dirents = await getChildDirents(state.pathSeparator, dirent);
|
|
2624
|
+
const dirents = await getChildDirents(state.pathSeparator, dirent.path, dirent.depth);
|
|
2661
2625
|
const state2 = state;
|
|
2662
2626
|
if (!state2) {
|
|
2663
2627
|
return state;
|
|
@@ -2919,7 +2883,10 @@ const handleRangeSelection = (state, startIndex, endIndex) => {
|
|
|
2919
2883
|
};
|
|
2920
2884
|
|
|
2921
2885
|
const handleClickAtRangeSelection = async (state, index) => {
|
|
2922
|
-
const
|
|
2886
|
+
const {
|
|
2887
|
+
items
|
|
2888
|
+
} = state;
|
|
2889
|
+
const firstSelectedIndex = items.findIndex(item => item.selected);
|
|
2923
2890
|
if (firstSelectedIndex === -1) {
|
|
2924
2891
|
return handleRangeSelection(state, index, index);
|
|
2925
2892
|
}
|
|
@@ -2929,10 +2896,7 @@ const handleClickAtRangeSelection = async (state, index) => {
|
|
|
2929
2896
|
};
|
|
2930
2897
|
|
|
2931
2898
|
const handleClickAt = async (state, defaultPrevented, button, ctrlKey, shiftKey, x, y) => {
|
|
2932
|
-
if (defaultPrevented) {
|
|
2933
|
-
return state;
|
|
2934
|
-
}
|
|
2935
|
-
if (button !== LeftClick) {
|
|
2899
|
+
if (defaultPrevented || button !== LeftClick) {
|
|
2936
2900
|
return state;
|
|
2937
2901
|
}
|
|
2938
2902
|
const index = getIndexFromPosition(state, x, y);
|
|
@@ -3294,10 +3258,7 @@ const mergeDirents$2 = (oldDirents, newDirents) => {
|
|
|
3294
3258
|
return newDirents;
|
|
3295
3259
|
};
|
|
3296
3260
|
const getMergedDirents$2 = async (root, pathSeparator, dirents) => {
|
|
3297
|
-
const childDirents = await getChildDirents(pathSeparator,
|
|
3298
|
-
path: root,
|
|
3299
|
-
depth: 0
|
|
3300
|
-
});
|
|
3261
|
+
const childDirents = await getChildDirents(pathSeparator, root, 0);
|
|
3301
3262
|
const mergedDirents = mergeDirents$2(dirents, childDirents);
|
|
3302
3263
|
return mergedDirents;
|
|
3303
3264
|
};
|
|
@@ -3351,10 +3312,7 @@ const mergeDirents$1 = (oldDirents, newDirents) => {
|
|
|
3351
3312
|
return newDirents;
|
|
3352
3313
|
};
|
|
3353
3314
|
const getMergedDirents$1 = async (root, pathSeparator, dirents) => {
|
|
3354
|
-
const childDirents = await getChildDirents(pathSeparator,
|
|
3355
|
-
path: root,
|
|
3356
|
-
depth: 0
|
|
3357
|
-
});
|
|
3315
|
+
const childDirents = await getChildDirents(pathSeparator, root, 0);
|
|
3358
3316
|
const mergedDirents = mergeDirents$1(dirents, childDirents);
|
|
3359
3317
|
return mergedDirents;
|
|
3360
3318
|
};
|
|
@@ -3417,7 +3375,7 @@ const handleDropIntoFolder = async (state, dirent, index, fileHandles, files, pa
|
|
|
3417
3375
|
// @ts-ignore
|
|
3418
3376
|
await copy$1(file, to);
|
|
3419
3377
|
}
|
|
3420
|
-
const childDirents = await getChildDirents(pathSeparator, dirent);
|
|
3378
|
+
const childDirents = await getChildDirents(pathSeparator, dirent.path, dirent.depth);
|
|
3421
3379
|
const mergedDirents = getMergedDirents(items, index, dirent, childDirents);
|
|
3422
3380
|
// TODO update maxlineY
|
|
3423
3381
|
return {
|
|
@@ -3623,11 +3581,7 @@ const getTopLevelDirents = (root, pathSeparator, excluded) => {
|
|
|
3623
3581
|
if (!root) {
|
|
3624
3582
|
return [];
|
|
3625
3583
|
}
|
|
3626
|
-
return getChildDirents(pathSeparator,
|
|
3627
|
-
depth: 0,
|
|
3628
|
-
path: root,
|
|
3629
|
-
type: Directory
|
|
3630
|
-
}, excluded);
|
|
3584
|
+
return getChildDirents(pathSeparator, root, 0, excluded);
|
|
3631
3585
|
};
|
|
3632
3586
|
|
|
3633
3587
|
const mergeDirents = (oldDirents, newDirents) => {
|
|
@@ -4933,16 +4887,6 @@ const restoreState = savedState => {
|
|
|
4933
4887
|
};
|
|
4934
4888
|
};
|
|
4935
4889
|
|
|
4936
|
-
const getIndex = (dirents, uri) => {
|
|
4937
|
-
for (let i = 0; i < dirents.length; i++) {
|
|
4938
|
-
const dirent = dirents[i];
|
|
4939
|
-
if (dirent.path === uri) {
|
|
4940
|
-
return i;
|
|
4941
|
-
}
|
|
4942
|
-
}
|
|
4943
|
-
return -1;
|
|
4944
|
-
};
|
|
4945
|
-
|
|
4946
4890
|
const getPathPartsToReveal = (root, pathParts, dirents) => {
|
|
4947
4891
|
for (let i = 0; i < pathParts.length; i++) {
|
|
4948
4892
|
const pathPart = pathParts[i];
|