@lvce-editor/explorer-view 7.28.0 → 7.30.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 +61 -22
- package/package.json +1 -1
|
@@ -1443,12 +1443,13 @@ const getIcons = async iconRequests => {
|
|
|
1443
1443
|
|
|
1444
1444
|
const {
|
|
1445
1445
|
invoke: invoke$4,
|
|
1446
|
+
invokeAndTransfer: invokeAndTransfer$2,
|
|
1446
1447
|
set: set$6
|
|
1447
1448
|
} = create$2(RendererProcess);
|
|
1448
1449
|
|
|
1449
1450
|
const {
|
|
1450
1451
|
invoke: invoke$3,
|
|
1451
|
-
invokeAndTransfer,
|
|
1452
|
+
invokeAndTransfer: invokeAndTransfer$1,
|
|
1452
1453
|
set: set$5
|
|
1453
1454
|
} = create$2(RendererWorker);
|
|
1454
1455
|
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
@@ -1458,21 +1459,17 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
|
1458
1459
|
number(y);
|
|
1459
1460
|
await invoke$3('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1460
1461
|
};
|
|
1461
|
-
const sendMessagePortToDragAndDropWorker = async port => {
|
|
1462
|
-
const command = 'DragAndDrop.handleMessagePort';
|
|
1463
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDragAndDropWorker', port, command);
|
|
1464
|
-
};
|
|
1465
1462
|
const sendMessagePortToDialogWorker = async port => {
|
|
1466
1463
|
const command = 'HandleMessagePort.handleMessagePort';
|
|
1467
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
|
|
1464
|
+
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
|
|
1468
1465
|
};
|
|
1469
1466
|
const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
|
|
1470
1467
|
const command = 'IconTheme.handleMessagePort';
|
|
1471
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
|
|
1468
|
+
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
|
|
1472
1469
|
};
|
|
1473
1470
|
const sendMessagePortToFileSystemWorker$1 = async (port, rpcId) => {
|
|
1474
1471
|
const command = 'FileSystem.handleMessagePort';
|
|
1475
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
|
|
1472
|
+
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
|
|
1476
1473
|
};
|
|
1477
1474
|
const confirm$1 = async (message, options) => {
|
|
1478
1475
|
const result = await invoke$3('ConfirmPrompt.prompt', message, options);
|
|
@@ -1483,7 +1480,7 @@ const writeClipBoardText = async text => {
|
|
|
1483
1480
|
};
|
|
1484
1481
|
const sendMessagePortToSourceControlWorker = async port => {
|
|
1485
1482
|
const command = 'SourceControl.handleMessagePort';
|
|
1486
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSourceControlWorker', port, command, 0);
|
|
1483
|
+
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToSourceControlWorker', port, command, 0);
|
|
1487
1484
|
};
|
|
1488
1485
|
const openUri$1 = async (uri, focus, options) => {
|
|
1489
1486
|
await invoke$3('Main.openUri', {
|
|
@@ -1506,7 +1503,8 @@ const create$1 = () => {
|
|
|
1506
1503
|
const commandQueues = new Map();
|
|
1507
1504
|
const generations = Object.create(null);
|
|
1508
1505
|
const states = Object.create(null);
|
|
1509
|
-
const commandMapRef =
|
|
1506
|
+
const commandMapRef = Object.create(null);
|
|
1507
|
+
const commandsById = Object.create(null);
|
|
1510
1508
|
const getGeneration = uid => generations[uid] || 0;
|
|
1511
1509
|
const isCurrentGeneration = (uid, generation) => {
|
|
1512
1510
|
return states[uid] !== undefined && getGeneration(uid) === generation;
|
|
@@ -1568,6 +1566,18 @@ const create$1 = () => {
|
|
|
1568
1566
|
delete states[key];
|
|
1569
1567
|
}
|
|
1570
1568
|
},
|
|
1569
|
+
createDirectEventCommandMap(requestRender) {
|
|
1570
|
+
return {
|
|
1571
|
+
async 'Viewlet.executeViewletCommand'(uid, command, ...args) {
|
|
1572
|
+
const fn = commandsById[command];
|
|
1573
|
+
if (!fn) {
|
|
1574
|
+
throw new Error(`Viewlet command not found: ${command}`);
|
|
1575
|
+
}
|
|
1576
|
+
await fn(uid, ...args);
|
|
1577
|
+
await requestRender(uid);
|
|
1578
|
+
}
|
|
1579
|
+
};
|
|
1580
|
+
},
|
|
1571
1581
|
diff(uid, modules, numbers) {
|
|
1572
1582
|
const {
|
|
1573
1583
|
oldState,
|
|
@@ -1599,6 +1609,9 @@ const create$1 = () => {
|
|
|
1599
1609
|
},
|
|
1600
1610
|
registerCommands(commandMap) {
|
|
1601
1611
|
Object.assign(commandMapRef, commandMap);
|
|
1612
|
+
for (const [key, fn] of Object.entries(commandMap)) {
|
|
1613
|
+
commandsById[toCommandId(key)] = fn;
|
|
1614
|
+
}
|
|
1602
1615
|
},
|
|
1603
1616
|
set(uid, oldState, newState, scheduledState) {
|
|
1604
1617
|
const current = states[uid];
|
|
@@ -2315,6 +2328,9 @@ const isConnected = () => {
|
|
|
2315
2328
|
const invoke = (method, ...params) => {
|
|
2316
2329
|
return invoke$4(method, ...params);
|
|
2317
2330
|
};
|
|
2331
|
+
const invokeAndTransfer = (method, ...params) => {
|
|
2332
|
+
return invokeAndTransfer$2(method, ...params);
|
|
2333
|
+
};
|
|
2318
2334
|
const requestPostRenderFocus = uid => {
|
|
2319
2335
|
postRenderFocusRequests.add(uid);
|
|
2320
2336
|
};
|
|
@@ -2637,10 +2653,15 @@ const cancelEditRename = (state, keepFocus) => {
|
|
|
2637
2653
|
};
|
|
2638
2654
|
};
|
|
2639
2655
|
|
|
2640
|
-
const getUpdatedChildren = (children,
|
|
2656
|
+
const getUpdatedChildren = (children, previousChildren, oldUri, newUri, renamedChildren) => {
|
|
2641
2657
|
const setSize = children.length;
|
|
2658
|
+
const previousTypes = new Map(previousChildren.map(child => [child.name, normalizeDirentType(child.type)]));
|
|
2659
|
+
const oldName = getBaseName('/', oldUri);
|
|
2642
2660
|
return children.toSorted(compareDirent).map((child, index) => {
|
|
2643
|
-
|
|
2661
|
+
const previousName = child.path === newUri ? oldName : child.name;
|
|
2662
|
+
const previousType = previousTypes.get(previousName);
|
|
2663
|
+
const wasExpanded = previousType === DirectoryExpanded || child.path === newUri && renamedChildren.length > 0;
|
|
2664
|
+
if (wasExpanded && child.type === Directory) {
|
|
2644
2665
|
return {
|
|
2645
2666
|
...child,
|
|
2646
2667
|
posInSet: index + 1,
|
|
@@ -2662,7 +2683,8 @@ const computeExplorerRenamedDirentUpdate = (root, parentPath, oldUri, children,
|
|
|
2662
2683
|
const relativeNewUri = newUri.slice(rootLength);
|
|
2663
2684
|
const update = Object.create(null);
|
|
2664
2685
|
const oldItems = tree[relativeOldPath] || [];
|
|
2665
|
-
|
|
2686
|
+
const previousChildren = tree[relativeDirname] || [];
|
|
2687
|
+
update[relativeDirname] = getUpdatedChildren(children, previousChildren, oldUri, newUri, oldItems);
|
|
2666
2688
|
update[relativeNewUri] = oldItems;
|
|
2667
2689
|
for (const [key, value] of Object.entries(tree)) {
|
|
2668
2690
|
if (!key.startsWith(`${relativeOldPath}/`)) {
|
|
@@ -2855,11 +2877,15 @@ const toCollapsedDirent = dirent => {
|
|
|
2855
2877
|
|
|
2856
2878
|
const collapseAll = async state => {
|
|
2857
2879
|
const {
|
|
2858
|
-
|
|
2880
|
+
editingIndex
|
|
2859
2881
|
} = state;
|
|
2882
|
+
const stateWithoutEdit = editingIndex === -1 ? state : await cancelEditInternal(state, true);
|
|
2883
|
+
const {
|
|
2884
|
+
items
|
|
2885
|
+
} = stateWithoutEdit;
|
|
2860
2886
|
const newDirents = items.filter(isTopLevel).map(toCollapsedDirent);
|
|
2861
2887
|
return {
|
|
2862
|
-
...
|
|
2888
|
+
...stateWithoutEdit,
|
|
2863
2889
|
expandedPaths: [],
|
|
2864
2890
|
focusedIndex: 0,
|
|
2865
2891
|
items: newDirents
|
|
@@ -4946,13 +4972,13 @@ const NewFolder$1 = 'NewFolder';
|
|
|
4946
4972
|
const OpenFolder = 'OpenFolder';
|
|
4947
4973
|
const Refresh$1 = 'Refresh';
|
|
4948
4974
|
|
|
4949
|
-
const isFolder = direntType => {
|
|
4975
|
+
const isFolder$1 = direntType => {
|
|
4950
4976
|
return [Directory, DirectoryExpanded, SymLinkFolder].includes(direntType);
|
|
4951
4977
|
};
|
|
4952
4978
|
const getFittingIndex = (dirents, startIndex) => {
|
|
4953
4979
|
for (let i = startIndex; i >= 0; i--) {
|
|
4954
4980
|
const dirent = dirents[i];
|
|
4955
|
-
if (dirent && isFolder(dirent.type)) {
|
|
4981
|
+
if (dirent && isFolder$1(dirent.type)) {
|
|
4956
4982
|
return i;
|
|
4957
4983
|
}
|
|
4958
4984
|
}
|
|
@@ -4995,7 +5021,14 @@ const getNewChildDirentsForNewDirent = async (items, depth, parentPath, direntTy
|
|
|
4995
5021
|
return allChildDirents;
|
|
4996
5022
|
};
|
|
4997
5023
|
|
|
4998
|
-
const
|
|
5024
|
+
const isFolder = type => {
|
|
5025
|
+
return [Directory, DirectoryExpanded, DirectoryExpanding, SymLinkFolder].includes(type);
|
|
5026
|
+
};
|
|
5027
|
+
const getTopLevelFileIndex = items => {
|
|
5028
|
+
const topLevelDepth = items[0]?.depth;
|
|
5029
|
+
return items.findIndex(item => item.depth === topLevelDepth && !isFolder(item.type));
|
|
5030
|
+
};
|
|
5031
|
+
const getNewDirentsForNewDirent = async (items, focusedIndex, type, root, excluded = [], insertAtFolderBoundary = false) => {
|
|
4999
5032
|
if (items.length === 0 || focusedIndex === -1) {
|
|
5000
5033
|
const newDirent = {
|
|
5001
5034
|
depth: 0,
|
|
@@ -5010,7 +5043,14 @@ const getNewDirentsForNewDirent = async (items, focusedIndex, type, root, exclud
|
|
|
5010
5043
|
if (type === EditingFolder) {
|
|
5011
5044
|
return [newDirent, ...items];
|
|
5012
5045
|
}
|
|
5013
|
-
|
|
5046
|
+
if (!insertAtFolderBoundary) {
|
|
5047
|
+
return [...items, newDirent];
|
|
5048
|
+
}
|
|
5049
|
+
const fileIndex = getTopLevelFileIndex(items);
|
|
5050
|
+
if (fileIndex === -1) {
|
|
5051
|
+
return [...items, newDirent];
|
|
5052
|
+
}
|
|
5053
|
+
return [...items.slice(0, fileIndex), newDirent, ...items.slice(fileIndex)];
|
|
5014
5054
|
}
|
|
5015
5055
|
const focusedItem = items[focusedIndex];
|
|
5016
5056
|
if (!focusedItem) {
|
|
@@ -5060,7 +5100,6 @@ const getNewDirentType = editingType => {
|
|
|
5060
5100
|
};
|
|
5061
5101
|
|
|
5062
5102
|
const newDirent = async (state, editingType, editingIcon = '') => {
|
|
5063
|
-
// TODO do it like vscode, select position between folders and files
|
|
5064
5103
|
const {
|
|
5065
5104
|
editingIndex,
|
|
5066
5105
|
editingSessionId,
|
|
@@ -5074,7 +5113,7 @@ const newDirent = async (state, editingType, editingIcon = '') => {
|
|
|
5074
5113
|
}
|
|
5075
5114
|
const index = getFittingIndex(items, focusedIndex);
|
|
5076
5115
|
const direntType = getNewDirentType(editingType);
|
|
5077
|
-
const newDirents = await getNewDirentsForNewDirent(items, index, direntType, root, excluded);
|
|
5116
|
+
const newDirents = await getNewDirentsForNewDirent(items, index, direntType, root, excluded, focusedIndex === -1);
|
|
5078
5117
|
const newEditingIndex = newDirents.findIndex(item => item.type === EditingFile || item.type === EditingFolder);
|
|
5079
5118
|
return {
|
|
5080
5119
|
...state,
|
|
@@ -8570,7 +8609,7 @@ const commandMap = {
|
|
|
8570
8609
|
};
|
|
8571
8610
|
|
|
8572
8611
|
const send$2 = async port => {
|
|
8573
|
-
await
|
|
8612
|
+
await invokeAndTransfer('DragAndDrop.handleMessagePort', port);
|
|
8574
8613
|
};
|
|
8575
8614
|
const createDragAndDropWorkerRpc = async () => {
|
|
8576
8615
|
return create$4({
|