@lvce-editor/explorer-view 2.42.0 → 2.43.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 +74 -34
- package/package.json +1 -1
|
@@ -761,7 +761,7 @@ const send = (transport, method, ...params) => {
|
|
|
761
761
|
const message = create$4(method, params);
|
|
762
762
|
transport.send(message);
|
|
763
763
|
};
|
|
764
|
-
const invoke$
|
|
764
|
+
const invoke$3 = (ipc, method, ...params) => {
|
|
765
765
|
return invokeHelper(ipc, method, params, false);
|
|
766
766
|
};
|
|
767
767
|
const invokeAndTransfer = (ipc, method, ...params) => {
|
|
@@ -794,7 +794,7 @@ const createRpc = ipc => {
|
|
|
794
794
|
send(ipc, method, ...params);
|
|
795
795
|
},
|
|
796
796
|
invoke(method, ...params) {
|
|
797
|
-
return invoke$
|
|
797
|
+
return invoke$3(ipc, method, ...params);
|
|
798
798
|
},
|
|
799
799
|
invokeAndTransfer(method, ...params) {
|
|
800
800
|
return invokeAndTransfer(ipc, method, ...params);
|
|
@@ -891,10 +891,14 @@ const RendererWorker = {
|
|
|
891
891
|
};
|
|
892
892
|
|
|
893
893
|
const {
|
|
894
|
-
invoke,
|
|
894
|
+
invoke: invoke$1,
|
|
895
895
|
set: set$1
|
|
896
896
|
} = RendererWorker;
|
|
897
897
|
|
|
898
|
+
const invoke = async (method, ...params) => {
|
|
899
|
+
return invoke$1(method, ...params);
|
|
900
|
+
};
|
|
901
|
+
|
|
898
902
|
const remove = async dirent => {
|
|
899
903
|
return invoke('FileSystem.remove', dirent);
|
|
900
904
|
};
|
|
@@ -1077,7 +1081,7 @@ const requestFileIcons = async requests => {
|
|
|
1077
1081
|
return [];
|
|
1078
1082
|
}
|
|
1079
1083
|
const simpleRequests = requests.map(toSimpleIconRequest);
|
|
1080
|
-
const icons = await invoke('IconTheme.getIcons', simpleRequests);
|
|
1084
|
+
const icons = await invoke$1('IconTheme.getIcons', simpleRequests);
|
|
1081
1085
|
return icons;
|
|
1082
1086
|
};
|
|
1083
1087
|
|
|
@@ -1516,12 +1520,22 @@ const acceptCreateFolder = async state => {
|
|
|
1516
1520
|
return acceptCreate(state, Directory, mkdir);
|
|
1517
1521
|
};
|
|
1518
1522
|
|
|
1519
|
-
const computeExplorerRenamedDirentUpdate =
|
|
1520
|
-
const
|
|
1521
|
-
const relativeDirname = parentPath.slice(
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1523
|
+
const computeExplorerRenamedDirentUpdate = (root, parentPath, oldUri, children, tree, newUri) => {
|
|
1524
|
+
const rootLength = root.length;
|
|
1525
|
+
const relativeDirname = parentPath.slice(rootLength);
|
|
1526
|
+
const relativeOldPath = oldUri.slice(rootLength);
|
|
1527
|
+
const relativeNewUri = newUri.slice(rootLength);
|
|
1528
|
+
const update = Object.create(null);
|
|
1529
|
+
update[relativeDirname] = children;
|
|
1530
|
+
const oldItems = tree[relativeOldPath] || [];
|
|
1531
|
+
update[relativeNewUri] = oldItems;
|
|
1532
|
+
for (const [key, value] of Object.entries(tree)) {
|
|
1533
|
+
if (key.startsWith(`${relativeOldPath}/`)) {
|
|
1534
|
+
const newKey = `${relativeNewUri}` + key.slice(relativeOldPath.length);
|
|
1535
|
+
update[newKey] = value;
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
return update;
|
|
1525
1539
|
};
|
|
1526
1540
|
|
|
1527
1541
|
const createNewDirentsRename = async (renamedDirent, editingValue, pathSeparator) => {
|
|
@@ -1569,10 +1583,12 @@ const acceptRename = async state => {
|
|
|
1569
1583
|
if (!successful) {
|
|
1570
1584
|
return state;
|
|
1571
1585
|
}
|
|
1572
|
-
const
|
|
1586
|
+
const oldUri = renamedDirent.path;
|
|
1587
|
+
const dirname = dirname2(oldUri);
|
|
1573
1588
|
const newUri = join2(dirname, editingValue);
|
|
1574
|
-
const
|
|
1589
|
+
const children = await getChildDirents('/', dirname, renamedDirent.depth - 1, []);
|
|
1575
1590
|
const tree = createTree(items, root);
|
|
1591
|
+
const update = computeExplorerRenamedDirentUpdate(root, dirname, oldUri, children, tree, newUri);
|
|
1576
1592
|
const newTree = updateTree2(tree, update);
|
|
1577
1593
|
const newDirents = treeToArray(newTree, root);
|
|
1578
1594
|
const newFocusedIndex = getIndex(newDirents, newUri);
|
|
@@ -1707,14 +1723,27 @@ const toCollapsedDirent = dirent => {
|
|
|
1707
1723
|
return dirent;
|
|
1708
1724
|
};
|
|
1709
1725
|
|
|
1710
|
-
const collapseAll = state => {
|
|
1726
|
+
const collapseAll = async state => {
|
|
1711
1727
|
const {
|
|
1728
|
+
minLineY,
|
|
1729
|
+
height,
|
|
1730
|
+
itemHeight,
|
|
1731
|
+
fileIconCache,
|
|
1712
1732
|
items
|
|
1713
1733
|
} = state;
|
|
1714
1734
|
const newDirents = items.filter(isTopLevel).map(toCollapsedDirent);
|
|
1735
|
+
const dirents = newDirents;
|
|
1736
|
+
const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, dirents.length);
|
|
1737
|
+
const visible = dirents.slice(minLineY, maxLineY);
|
|
1738
|
+
const {
|
|
1739
|
+
icons,
|
|
1740
|
+
newFileIconCache
|
|
1741
|
+
} = await getFileIcons(visible, fileIconCache);
|
|
1715
1742
|
return {
|
|
1716
1743
|
...state,
|
|
1717
|
-
items: newDirents
|
|
1744
|
+
items: newDirents,
|
|
1745
|
+
icons,
|
|
1746
|
+
fileIconCache: newFileIconCache
|
|
1718
1747
|
};
|
|
1719
1748
|
};
|
|
1720
1749
|
|
|
@@ -1738,13 +1767,13 @@ const copyPath = async state => {
|
|
|
1738
1767
|
};
|
|
1739
1768
|
|
|
1740
1769
|
const writeText = async text => {
|
|
1741
|
-
await invoke('ClipBoard.writeText', /* text */text);
|
|
1770
|
+
await invoke$1('ClipBoard.writeText', /* text */text);
|
|
1742
1771
|
};
|
|
1743
1772
|
const readNativeFiles = async () => {
|
|
1744
|
-
return invoke('ClipBoard.readNativeFiles');
|
|
1773
|
+
return invoke$1('ClipBoard.readNativeFiles');
|
|
1745
1774
|
};
|
|
1746
1775
|
const writeNativeFiles = async (type, files) => {
|
|
1747
|
-
return invoke('ClipBoard.writeNativeFiles', type, files);
|
|
1776
|
+
return invoke$1('ClipBoard.writeNativeFiles', type, files);
|
|
1748
1777
|
};
|
|
1749
1778
|
|
|
1750
1779
|
const copyRelativePath = async state => {
|
|
@@ -2627,7 +2656,7 @@ const handleArrowRightDirectoryExpanded = (state, dirent) => {
|
|
|
2627
2656
|
};
|
|
2628
2657
|
|
|
2629
2658
|
const setFocus = key => {
|
|
2630
|
-
return invoke('Focus.setFocus', key);
|
|
2659
|
+
return invoke$1('Focus.setFocus', key);
|
|
2631
2660
|
};
|
|
2632
2661
|
|
|
2633
2662
|
const handleClickDirectory = async (state, dirent, index, keepFocus) => {
|
|
@@ -2676,7 +2705,7 @@ const handleClickDirectory = async (state, dirent, index, keepFocus) => {
|
|
|
2676
2705
|
};
|
|
2677
2706
|
|
|
2678
2707
|
const openUri = async (uri, focus) => {
|
|
2679
|
-
await invoke(/* Main.openAbsolutePath */'Main.openUri', /* absolutePath */uri, /* focus */focus);
|
|
2708
|
+
await invoke$1(/* Main.openAbsolutePath */'Main.openUri', /* absolutePath */uri, /* focus */focus);
|
|
2680
2709
|
};
|
|
2681
2710
|
|
|
2682
2711
|
const handleClickFile = async (state, dirent, index, keepFocus = false) => {
|
|
@@ -2937,7 +2966,7 @@ const handleClickOpenFolder = async state => {
|
|
|
2937
2966
|
};
|
|
2938
2967
|
|
|
2939
2968
|
const show = async (x, y, id, ...args) => {
|
|
2940
|
-
return invoke('ContextMenu.show', x, y, id, ...args);
|
|
2969
|
+
return invoke$1('ContextMenu.show', x, y, id, ...args);
|
|
2941
2970
|
};
|
|
2942
2971
|
|
|
2943
2972
|
const Explorer$1 = 4;
|
|
@@ -3086,8 +3115,12 @@ const getExpandedDirents = items => {
|
|
|
3086
3115
|
const getPathDirentsMap = async allPaths => {
|
|
3087
3116
|
const pathToDirents = Object.create(null);
|
|
3088
3117
|
await Promise.all(allPaths.map(async path => {
|
|
3089
|
-
|
|
3090
|
-
|
|
3118
|
+
try {
|
|
3119
|
+
const dirents = await readDirWithFileTypes(path);
|
|
3120
|
+
pathToDirents[path] = dirents;
|
|
3121
|
+
} catch {
|
|
3122
|
+
// ignore
|
|
3123
|
+
}
|
|
3091
3124
|
}));
|
|
3092
3125
|
return pathToDirents;
|
|
3093
3126
|
};
|
|
@@ -3443,12 +3476,12 @@ const getFileArray = fileList => {
|
|
|
3443
3476
|
};
|
|
3444
3477
|
|
|
3445
3478
|
const getFileHandles = async fileIds => {
|
|
3446
|
-
const files = await invoke('FileSystemHandle.getFileHandles', fileIds);
|
|
3479
|
+
const files = await invoke$1('FileSystemHandle.getFileHandles', fileIds);
|
|
3447
3480
|
return files;
|
|
3448
3481
|
};
|
|
3449
3482
|
|
|
3450
3483
|
const getFilePathElectron = async file => {
|
|
3451
|
-
return invoke('FileSystemHandle.getFilePathElectron', file);
|
|
3484
|
+
return invoke$1('FileSystemHandle.getFilePathElectron', file);
|
|
3452
3485
|
};
|
|
3453
3486
|
|
|
3454
3487
|
const getFilepath = async file => {
|
|
@@ -3575,7 +3608,7 @@ const handleKeyDown = (state, key) => {
|
|
|
3575
3608
|
// @ts-ignore
|
|
3576
3609
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
3577
3610
|
timeout = setTimeout(async () => {
|
|
3578
|
-
await invoke('Explorer.cancelTypeAhead');
|
|
3611
|
+
await invoke$1('Explorer.cancelTypeAhead');
|
|
3579
3612
|
}, focusWordTimeout);
|
|
3580
3613
|
if (matchingIndex === -1) {
|
|
3581
3614
|
return {
|
|
@@ -3770,11 +3803,11 @@ const handleWheel = (state, deltaMode, deltaY) => {
|
|
|
3770
3803
|
};
|
|
3771
3804
|
|
|
3772
3805
|
const getWorkspacePath = () => {
|
|
3773
|
-
return invoke('Workspace.getPath');
|
|
3806
|
+
return invoke$1('Workspace.getPath');
|
|
3774
3807
|
};
|
|
3775
3808
|
|
|
3776
3809
|
const getSettings = async () => {
|
|
3777
|
-
const useChevronsRaw = await invoke('Preferences.get', 'explorer.useChevrons');
|
|
3810
|
+
const useChevronsRaw = await invoke$1('Preferences.get', 'explorer.useChevrons');
|
|
3778
3811
|
const useChevrons = useChevronsRaw === false ? false : true;
|
|
3779
3812
|
return {
|
|
3780
3813
|
useChevrons
|
|
@@ -4095,7 +4128,7 @@ const getContainingFolder = (root, dirents, focusedIndex, pathSeparator) => {
|
|
|
4095
4128
|
};
|
|
4096
4129
|
|
|
4097
4130
|
const openNativeFolder = async path => {
|
|
4098
|
-
await invoke('OpenNativeFolder.openNativeFolder', /* path */path);
|
|
4131
|
+
await invoke$1('OpenNativeFolder.openNativeFolder', /* path */path);
|
|
4099
4132
|
};
|
|
4100
4133
|
|
|
4101
4134
|
const openContainingFolder = async state => {
|
|
@@ -4139,10 +4172,17 @@ const removeDirent = async state => {
|
|
|
4139
4172
|
return newState;
|
|
4140
4173
|
};
|
|
4141
4174
|
|
|
4175
|
+
const getEditingType = direntType => {
|
|
4176
|
+
if (direntType < DELTA_EDITING) {
|
|
4177
|
+
return direntType + DELTA_EDITING;
|
|
4178
|
+
}
|
|
4179
|
+
return direntType;
|
|
4180
|
+
};
|
|
4181
|
+
|
|
4142
4182
|
const getNewDirentsForRename = (items, focusedIndex) => {
|
|
4143
4183
|
const item = items[focusedIndex];
|
|
4144
4184
|
const newItems = [...items];
|
|
4145
|
-
const editingType = item.type
|
|
4185
|
+
const editingType = getEditingType(item.type);
|
|
4146
4186
|
// TODO avoid mutation
|
|
4147
4187
|
newItems[focusedIndex] = {
|
|
4148
4188
|
...item,
|
|
@@ -5144,24 +5184,24 @@ const terminate = () => {
|
|
|
5144
5184
|
|
|
5145
5185
|
const getEditingIcon = async (editingType, value, direntType) => {
|
|
5146
5186
|
if (editingType === CreateFile) {
|
|
5147
|
-
return invoke('IconTheme.getFileIcon', {
|
|
5187
|
+
return invoke$1('IconTheme.getFileIcon', {
|
|
5148
5188
|
name: value
|
|
5149
5189
|
});
|
|
5150
5190
|
}
|
|
5151
5191
|
if (editingType === Rename$1) {
|
|
5152
5192
|
if (direntType === File || direntType === EditingFile) {
|
|
5153
|
-
return invoke('IconTheme.getFileIcon', {
|
|
5193
|
+
return invoke$1('IconTheme.getFileIcon', {
|
|
5154
5194
|
name: value
|
|
5155
5195
|
});
|
|
5156
5196
|
}
|
|
5157
|
-
if (direntType === Directory || direntType === EditingFolder) {
|
|
5158
|
-
return invoke('IconTheme.getFolderIcon', {
|
|
5197
|
+
if (direntType === Directory || direntType === EditingFolder || direntType === EditingDirectoryExpanded) {
|
|
5198
|
+
return invoke$1('IconTheme.getFolderIcon', {
|
|
5159
5199
|
name: value
|
|
5160
5200
|
});
|
|
5161
5201
|
}
|
|
5162
5202
|
}
|
|
5163
5203
|
if (editingType === CreateFolder) {
|
|
5164
|
-
return invoke('IconTheme.getFolderIcon', {
|
|
5204
|
+
return invoke$1('IconTheme.getFolderIcon', {
|
|
5165
5205
|
name: value
|
|
5166
5206
|
});
|
|
5167
5207
|
}
|