@lvce-editor/explorer-view 5.20.0 → 5.21.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 +356 -69
- package/package.json +1 -1
|
@@ -6,42 +6,68 @@ const create$6 = () => {
|
|
|
6
6
|
const states = Object.create(null);
|
|
7
7
|
const commandMapRef = {};
|
|
8
8
|
return {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
clear() {
|
|
10
|
+
for (const key of Object.keys(states)) {
|
|
11
|
+
delete states[key];
|
|
12
|
+
}
|
|
11
13
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
14
|
+
diff(uid, modules, numbers) {
|
|
15
|
+
const {
|
|
16
|
+
newState,
|
|
17
|
+
oldState
|
|
18
|
+
} = states[uid];
|
|
19
|
+
const diffResult = [];
|
|
20
|
+
for (let i = 0; i < modules.length; i++) {
|
|
21
|
+
const fn = modules[i];
|
|
22
|
+
if (!fn(oldState, newState)) {
|
|
23
|
+
diffResult.push(numbers[i]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return diffResult;
|
|
17
27
|
},
|
|
18
28
|
dispose(uid) {
|
|
19
29
|
delete states[uid];
|
|
20
30
|
},
|
|
31
|
+
get(uid) {
|
|
32
|
+
return states[uid];
|
|
33
|
+
},
|
|
34
|
+
getCommandIds() {
|
|
35
|
+
const keys = Object.keys(commandMapRef);
|
|
36
|
+
const ids = keys.map(toCommandId);
|
|
37
|
+
return ids;
|
|
38
|
+
},
|
|
21
39
|
getKeys() {
|
|
22
40
|
return Object.keys(states).map(key => {
|
|
23
41
|
return Number.parseInt(key);
|
|
24
42
|
});
|
|
25
43
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
44
|
+
registerCommands(commandMap) {
|
|
45
|
+
Object.assign(commandMapRef, commandMap);
|
|
46
|
+
},
|
|
47
|
+
set(uid, oldState, newState) {
|
|
48
|
+
states[uid] = {
|
|
49
|
+
newState,
|
|
50
|
+
oldState
|
|
51
|
+
};
|
|
30
52
|
},
|
|
31
53
|
wrapCommand(fn) {
|
|
32
54
|
const wrapped = async (uid, ...args) => {
|
|
33
55
|
const {
|
|
34
|
-
|
|
35
|
-
|
|
56
|
+
newState,
|
|
57
|
+
oldState
|
|
36
58
|
} = states[uid];
|
|
37
59
|
const newerState = await fn(newState, ...args);
|
|
38
60
|
if (oldState === newerState || newState === newerState) {
|
|
39
61
|
return;
|
|
40
62
|
}
|
|
41
|
-
const
|
|
63
|
+
const latestOld = states[uid];
|
|
64
|
+
const latestNew = {
|
|
65
|
+
...latestOld.newState,
|
|
66
|
+
...newerState
|
|
67
|
+
};
|
|
42
68
|
states[uid] = {
|
|
43
|
-
|
|
44
|
-
|
|
69
|
+
newState: latestNew,
|
|
70
|
+
oldState: latestOld.oldState
|
|
45
71
|
};
|
|
46
72
|
};
|
|
47
73
|
return wrapped;
|
|
@@ -54,28 +80,6 @@ const create$6 = () => {
|
|
|
54
80
|
return fn(newState, ...args);
|
|
55
81
|
};
|
|
56
82
|
return wrapped;
|
|
57
|
-
},
|
|
58
|
-
diff(uid, modules, numbers) {
|
|
59
|
-
const {
|
|
60
|
-
oldState,
|
|
61
|
-
newState
|
|
62
|
-
} = states[uid];
|
|
63
|
-
const diffResult = [];
|
|
64
|
-
for (let i = 0; i < modules.length; i++) {
|
|
65
|
-
const fn = modules[i];
|
|
66
|
-
if (!fn(oldState, newState)) {
|
|
67
|
-
diffResult.push(numbers[i]);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return diffResult;
|
|
71
|
-
},
|
|
72
|
-
getCommandIds() {
|
|
73
|
-
const keys = Object.keys(commandMapRef);
|
|
74
|
-
const ids = keys.map(toCommandId);
|
|
75
|
-
return ids;
|
|
76
|
-
},
|
|
77
|
-
registerCommands(commandMap) {
|
|
78
|
-
Object.assign(commandMapRef, commandMap);
|
|
79
83
|
}
|
|
80
84
|
};
|
|
81
85
|
};
|
|
@@ -193,6 +197,7 @@ const FocusSelector = 'Viewlet.focusSelector';
|
|
|
193
197
|
const SetCss = 'Viewlet.setCss';
|
|
194
198
|
const SetDom2 = 'Viewlet.setDom2';
|
|
195
199
|
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
200
|
+
const SetPatches = 'Viewlet.setPatches';
|
|
196
201
|
|
|
197
202
|
const FocusExplorer = 13;
|
|
198
203
|
const FocusExplorerEditBox = 14;
|
|
@@ -611,7 +616,7 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
611
616
|
return promise;
|
|
612
617
|
};
|
|
613
618
|
const Message$1 = 3;
|
|
614
|
-
const create$5 = async ({
|
|
619
|
+
const create$5$1 = async ({
|
|
615
620
|
isMessagePortOpen,
|
|
616
621
|
messagePort
|
|
617
622
|
}) => {
|
|
@@ -662,7 +667,7 @@ const wrap$5 = messagePort => {
|
|
|
662
667
|
};
|
|
663
668
|
const IpcParentWithMessagePort$1 = {
|
|
664
669
|
__proto__: null,
|
|
665
|
-
create: create$5,
|
|
670
|
+
create: create$5$1,
|
|
666
671
|
signal: signal$1,
|
|
667
672
|
wrap: wrap$5
|
|
668
673
|
};
|
|
@@ -868,7 +873,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
868
873
|
}
|
|
869
874
|
};
|
|
870
875
|
};
|
|
871
|
-
const create$1$
|
|
876
|
+
const create$1$1 = (id, error) => {
|
|
872
877
|
return {
|
|
873
878
|
jsonrpc: Two$1,
|
|
874
879
|
id,
|
|
@@ -879,9 +884,9 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
879
884
|
const prettyError = preparePrettyError(error);
|
|
880
885
|
logError(error, prettyError);
|
|
881
886
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
882
|
-
return create$1$
|
|
887
|
+
return create$1$1(id, errorProperty);
|
|
883
888
|
};
|
|
884
|
-
const create$
|
|
889
|
+
const create$4 = (message, result) => {
|
|
885
890
|
return {
|
|
886
891
|
jsonrpc: Two$1,
|
|
887
892
|
id: message.id,
|
|
@@ -890,7 +895,7 @@ const create$3 = (message, result) => {
|
|
|
890
895
|
};
|
|
891
896
|
const getSuccessResponse = (message, result) => {
|
|
892
897
|
const resultProperty = result ?? null;
|
|
893
|
-
return create$
|
|
898
|
+
return create$4(message, resultProperty);
|
|
894
899
|
};
|
|
895
900
|
const getErrorResponseSimple = (id, error) => {
|
|
896
901
|
return {
|
|
@@ -1004,14 +1009,14 @@ const execute = (command, ...args) => {
|
|
|
1004
1009
|
};
|
|
1005
1010
|
|
|
1006
1011
|
const Two = '2.0';
|
|
1007
|
-
const create$
|
|
1012
|
+
const create$t = (method, params) => {
|
|
1008
1013
|
return {
|
|
1009
1014
|
jsonrpc: Two,
|
|
1010
1015
|
method,
|
|
1011
1016
|
params
|
|
1012
1017
|
};
|
|
1013
1018
|
};
|
|
1014
|
-
const create$
|
|
1019
|
+
const create$s = (id, method, params) => {
|
|
1015
1020
|
const message = {
|
|
1016
1021
|
id,
|
|
1017
1022
|
jsonrpc: Two,
|
|
@@ -1021,14 +1026,14 @@ const create$r = (id, method, params) => {
|
|
|
1021
1026
|
return message;
|
|
1022
1027
|
};
|
|
1023
1028
|
let id = 0;
|
|
1024
|
-
const create$
|
|
1029
|
+
const create$r = () => {
|
|
1025
1030
|
return ++id;
|
|
1026
1031
|
};
|
|
1027
1032
|
|
|
1028
1033
|
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
1029
1034
|
|
|
1030
1035
|
const registerPromise = map => {
|
|
1031
|
-
const id = create$
|
|
1036
|
+
const id = create$r();
|
|
1032
1037
|
const {
|
|
1033
1038
|
promise,
|
|
1034
1039
|
resolve
|
|
@@ -1046,7 +1051,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
1046
1051
|
id,
|
|
1047
1052
|
promise
|
|
1048
1053
|
} = registerPromise(callbacks);
|
|
1049
|
-
const message = create$
|
|
1054
|
+
const message = create$s(id, method, params);
|
|
1050
1055
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
1051
1056
|
ipc.sendAndTransfer(message);
|
|
1052
1057
|
} else {
|
|
@@ -1082,7 +1087,7 @@ const createRpc = ipc => {
|
|
|
1082
1087
|
* @deprecated
|
|
1083
1088
|
*/
|
|
1084
1089
|
send(method, ...params) {
|
|
1085
|
-
const message = create$
|
|
1090
|
+
const message = create$t(method, params);
|
|
1086
1091
|
ipc.send(message);
|
|
1087
1092
|
}
|
|
1088
1093
|
};
|
|
@@ -1148,13 +1153,13 @@ const createSharedLazyRpc = factory => {
|
|
|
1148
1153
|
}
|
|
1149
1154
|
};
|
|
1150
1155
|
};
|
|
1151
|
-
const create$
|
|
1156
|
+
const create$j = async ({
|
|
1152
1157
|
commandMap,
|
|
1153
1158
|
isMessagePortOpen,
|
|
1154
1159
|
send
|
|
1155
1160
|
}) => {
|
|
1156
1161
|
return createSharedLazyRpc(() => {
|
|
1157
|
-
return create$
|
|
1162
|
+
return create$3({
|
|
1158
1163
|
commandMap,
|
|
1159
1164
|
isMessagePortOpen,
|
|
1160
1165
|
send
|
|
@@ -1163,9 +1168,9 @@ const create$i = async ({
|
|
|
1163
1168
|
};
|
|
1164
1169
|
const LazyTransferMessagePortRpcParent = {
|
|
1165
1170
|
__proto__: null,
|
|
1166
|
-
create: create$
|
|
1171
|
+
create: create$j
|
|
1167
1172
|
};
|
|
1168
|
-
const create$
|
|
1173
|
+
const create$5 = async ({
|
|
1169
1174
|
commandMap,
|
|
1170
1175
|
isMessagePortOpen = true,
|
|
1171
1176
|
messagePort
|
|
@@ -1182,7 +1187,7 @@ const create$4 = async ({
|
|
|
1182
1187
|
messagePort.start();
|
|
1183
1188
|
return rpc;
|
|
1184
1189
|
};
|
|
1185
|
-
const create$
|
|
1190
|
+
const create$3 = async ({
|
|
1186
1191
|
commandMap,
|
|
1187
1192
|
isMessagePortOpen,
|
|
1188
1193
|
send
|
|
@@ -1192,13 +1197,13 @@ const create$2 = async ({
|
|
|
1192
1197
|
port2
|
|
1193
1198
|
} = new MessageChannel();
|
|
1194
1199
|
await send(port1);
|
|
1195
|
-
return create$
|
|
1200
|
+
return create$5({
|
|
1196
1201
|
commandMap,
|
|
1197
1202
|
isMessagePortOpen,
|
|
1198
1203
|
messagePort: port2
|
|
1199
1204
|
});
|
|
1200
1205
|
};
|
|
1201
|
-
const create$
|
|
1206
|
+
const create$2 = async ({
|
|
1202
1207
|
commandMap
|
|
1203
1208
|
}) => {
|
|
1204
1209
|
// TODO create a commandMap per rpc instance
|
|
@@ -1210,7 +1215,7 @@ const create$1$1 = async ({
|
|
|
1210
1215
|
};
|
|
1211
1216
|
const WebWorkerRpcClient = {
|
|
1212
1217
|
__proto__: null,
|
|
1213
|
-
create: create$
|
|
1218
|
+
create: create$2
|
|
1214
1219
|
};
|
|
1215
1220
|
const createMockRpc = ({
|
|
1216
1221
|
commandMap
|
|
@@ -1871,7 +1876,7 @@ const treeToArrayInternal = (map, root, items, path, depth) => {
|
|
|
1871
1876
|
}
|
|
1872
1877
|
};
|
|
1873
1878
|
|
|
1874
|
-
const treeToArray = (map, root) => {
|
|
1879
|
+
const treeToArray$1 = (map, root) => {
|
|
1875
1880
|
const items = [];
|
|
1876
1881
|
treeToArrayInternal(map, root, items, '', 1);
|
|
1877
1882
|
return items;
|
|
@@ -1914,7 +1919,7 @@ const RefreshExplorer = 'Refresh Explorer';
|
|
|
1914
1919
|
const Rename = 'Rename';
|
|
1915
1920
|
const TheNameIsNotValid = 'The name **{0}** is not valid as a file or folder name. Please choose a different name.';
|
|
1916
1921
|
const TypeAFileName = 'Type file name. Press Enter to confirm or Escape to cancel.'; // TODO use keybinding
|
|
1917
|
-
const YouHaveNotYetOpenedAFolder = 'You have not yet opened a folder';
|
|
1922
|
+
const YouHaveNotYetOpenedAFolder = 'You have not yet opened a folder.';
|
|
1918
1923
|
|
|
1919
1924
|
const newFile$1 = () => {
|
|
1920
1925
|
return i18nString(NewFile$2);
|
|
@@ -2046,7 +2051,7 @@ const acceptCreate = async (state, newDirentType) => {
|
|
|
2046
2051
|
const tree = createTree(items, root);
|
|
2047
2052
|
const childTree = createTree(children, root);
|
|
2048
2053
|
const merged = mergeTrees(tree, childTree);
|
|
2049
|
-
const newItems = treeToArray(merged, root);
|
|
2054
|
+
const newItems = treeToArray$1(merged, root);
|
|
2050
2055
|
const dirents = newItems;
|
|
2051
2056
|
const newFocusedIndex = getIndex(newItems, absolutePath);
|
|
2052
2057
|
await refreshWorkspace();
|
|
@@ -2136,7 +2141,7 @@ const acceptRename = async state => {
|
|
|
2136
2141
|
const tree = createTree(items, root);
|
|
2137
2142
|
const update = computeExplorerRenamedDirentUpdate(root, dirname, oldUri, children, tree, newUri);
|
|
2138
2143
|
const newTree = updateTree2(tree, update);
|
|
2139
|
-
const newDirents = treeToArray(newTree, root);
|
|
2144
|
+
const newDirents = treeToArray$1(newTree, root);
|
|
2140
2145
|
const newFocusedIndex = getIndex(newDirents, newUri);
|
|
2141
2146
|
return {
|
|
2142
2147
|
...state,
|
|
@@ -2308,7 +2313,6 @@ const writeText = async text => {
|
|
|
2308
2313
|
await writeClipBoardText(text);
|
|
2309
2314
|
};
|
|
2310
2315
|
const readNativeFiles = async () => {
|
|
2311
|
-
// @ts-ignore
|
|
2312
2316
|
return invoke$2('ClipBoard.readNativeFiles');
|
|
2313
2317
|
};
|
|
2314
2318
|
const writeNativeFiles = async (type, files) => {
|
|
@@ -2538,6 +2542,283 @@ const text = data => {
|
|
|
2538
2542
|
};
|
|
2539
2543
|
};
|
|
2540
2544
|
|
|
2545
|
+
const SetText = 1;
|
|
2546
|
+
const Replace = 2;
|
|
2547
|
+
const SetAttribute = 3;
|
|
2548
|
+
const RemoveAttribute = 4;
|
|
2549
|
+
const Add = 6;
|
|
2550
|
+
const NavigateChild = 7;
|
|
2551
|
+
const NavigateParent = 8;
|
|
2552
|
+
const RemoveChild = 9;
|
|
2553
|
+
const NavigateSibling = 10;
|
|
2554
|
+
|
|
2555
|
+
const isKey = key => {
|
|
2556
|
+
return key !== 'type' && key !== 'childCount';
|
|
2557
|
+
};
|
|
2558
|
+
|
|
2559
|
+
const getKeys = node => {
|
|
2560
|
+
const keys = Object.keys(node).filter(isKey);
|
|
2561
|
+
return keys;
|
|
2562
|
+
};
|
|
2563
|
+
|
|
2564
|
+
const arrayToTree = nodes => {
|
|
2565
|
+
const result = [];
|
|
2566
|
+
let i = 0;
|
|
2567
|
+
while (i < nodes.length) {
|
|
2568
|
+
const node = nodes[i];
|
|
2569
|
+
const {
|
|
2570
|
+
children,
|
|
2571
|
+
nodesConsumed
|
|
2572
|
+
} = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
|
|
2573
|
+
result.push({
|
|
2574
|
+
node,
|
|
2575
|
+
children
|
|
2576
|
+
});
|
|
2577
|
+
i += 1 + nodesConsumed;
|
|
2578
|
+
}
|
|
2579
|
+
return result;
|
|
2580
|
+
};
|
|
2581
|
+
const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
2582
|
+
if (childCount === 0) {
|
|
2583
|
+
return {
|
|
2584
|
+
children: [],
|
|
2585
|
+
nodesConsumed: 0
|
|
2586
|
+
};
|
|
2587
|
+
}
|
|
2588
|
+
const children = [];
|
|
2589
|
+
let i = startIndex;
|
|
2590
|
+
let remaining = childCount;
|
|
2591
|
+
let totalConsumed = 0;
|
|
2592
|
+
while (remaining > 0 && i < nodes.length) {
|
|
2593
|
+
const node = nodes[i];
|
|
2594
|
+
const nodeChildCount = node.childCount || 0;
|
|
2595
|
+
const {
|
|
2596
|
+
children: nodeChildren,
|
|
2597
|
+
nodesConsumed
|
|
2598
|
+
} = getChildrenWithCount(nodes, i + 1, nodeChildCount);
|
|
2599
|
+
children.push({
|
|
2600
|
+
node,
|
|
2601
|
+
children: nodeChildren
|
|
2602
|
+
});
|
|
2603
|
+
const nodeSize = 1 + nodesConsumed;
|
|
2604
|
+
i += nodeSize;
|
|
2605
|
+
totalConsumed += nodeSize;
|
|
2606
|
+
remaining--;
|
|
2607
|
+
}
|
|
2608
|
+
return {
|
|
2609
|
+
children,
|
|
2610
|
+
nodesConsumed: totalConsumed
|
|
2611
|
+
};
|
|
2612
|
+
};
|
|
2613
|
+
|
|
2614
|
+
const compareNodes = (oldNode, newNode) => {
|
|
2615
|
+
const patches = [];
|
|
2616
|
+
// Check if node type changed - return null to signal incompatible nodes
|
|
2617
|
+
// (caller should handle this with a Replace operation)
|
|
2618
|
+
if (oldNode.type !== newNode.type) {
|
|
2619
|
+
return null;
|
|
2620
|
+
}
|
|
2621
|
+
// Handle text nodes
|
|
2622
|
+
if (oldNode.type === Text && newNode.type === Text) {
|
|
2623
|
+
if (oldNode.text !== newNode.text) {
|
|
2624
|
+
patches.push({
|
|
2625
|
+
type: SetText,
|
|
2626
|
+
value: newNode.text
|
|
2627
|
+
});
|
|
2628
|
+
}
|
|
2629
|
+
return patches;
|
|
2630
|
+
}
|
|
2631
|
+
// Compare attributes
|
|
2632
|
+
const oldKeys = getKeys(oldNode);
|
|
2633
|
+
const newKeys = getKeys(newNode);
|
|
2634
|
+
// Check for attribute changes
|
|
2635
|
+
for (const key of newKeys) {
|
|
2636
|
+
if (oldNode[key] !== newNode[key]) {
|
|
2637
|
+
patches.push({
|
|
2638
|
+
type: SetAttribute,
|
|
2639
|
+
key,
|
|
2640
|
+
value: newNode[key]
|
|
2641
|
+
});
|
|
2642
|
+
}
|
|
2643
|
+
}
|
|
2644
|
+
// Check for removed attributes
|
|
2645
|
+
for (const key of oldKeys) {
|
|
2646
|
+
if (!(key in newNode)) {
|
|
2647
|
+
patches.push({
|
|
2648
|
+
type: RemoveAttribute,
|
|
2649
|
+
key
|
|
2650
|
+
});
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
return patches;
|
|
2654
|
+
};
|
|
2655
|
+
|
|
2656
|
+
const treeToArray = node => {
|
|
2657
|
+
const result = [node.node];
|
|
2658
|
+
for (const child of node.children) {
|
|
2659
|
+
result.push(...treeToArray(child));
|
|
2660
|
+
}
|
|
2661
|
+
return result;
|
|
2662
|
+
};
|
|
2663
|
+
|
|
2664
|
+
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
2665
|
+
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
2666
|
+
// Track where we are: -1 means at parent, >= 0 means at child index
|
|
2667
|
+
let currentChildIndex = -1;
|
|
2668
|
+
// Collect indices of children to remove (we'll add these patches at the end in reverse order)
|
|
2669
|
+
const indicesToRemove = [];
|
|
2670
|
+
for (let i = 0; i < maxLength; i++) {
|
|
2671
|
+
const oldNode = oldChildren[i];
|
|
2672
|
+
const newNode = newChildren[i];
|
|
2673
|
+
if (!oldNode && !newNode) {
|
|
2674
|
+
continue;
|
|
2675
|
+
}
|
|
2676
|
+
if (!oldNode) {
|
|
2677
|
+
// Add new node - we should be at the parent
|
|
2678
|
+
if (currentChildIndex >= 0) {
|
|
2679
|
+
// Navigate back to parent
|
|
2680
|
+
patches.push({
|
|
2681
|
+
type: NavigateParent
|
|
2682
|
+
});
|
|
2683
|
+
currentChildIndex = -1;
|
|
2684
|
+
}
|
|
2685
|
+
// Flatten the entire subtree so renderInternal can handle it
|
|
2686
|
+
const flatNodes = treeToArray(newNode);
|
|
2687
|
+
patches.push({
|
|
2688
|
+
type: Add,
|
|
2689
|
+
nodes: flatNodes
|
|
2690
|
+
});
|
|
2691
|
+
} else if (newNode) {
|
|
2692
|
+
// Compare nodes to see if we need any patches
|
|
2693
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2694
|
+
// If nodePatches is null, the node types are incompatible - need to replace
|
|
2695
|
+
if (nodePatches === null) {
|
|
2696
|
+
// Navigate to this child
|
|
2697
|
+
if (currentChildIndex === -1) {
|
|
2698
|
+
patches.push({
|
|
2699
|
+
type: NavigateChild,
|
|
2700
|
+
index: i
|
|
2701
|
+
});
|
|
2702
|
+
currentChildIndex = i;
|
|
2703
|
+
} else if (currentChildIndex !== i) {
|
|
2704
|
+
patches.push({
|
|
2705
|
+
type: NavigateSibling,
|
|
2706
|
+
index: i
|
|
2707
|
+
});
|
|
2708
|
+
currentChildIndex = i;
|
|
2709
|
+
}
|
|
2710
|
+
// Replace the entire subtree
|
|
2711
|
+
const flatNodes = treeToArray(newNode);
|
|
2712
|
+
patches.push({
|
|
2713
|
+
type: Replace,
|
|
2714
|
+
nodes: flatNodes
|
|
2715
|
+
});
|
|
2716
|
+
// After replace, we're at the new element (same position)
|
|
2717
|
+
continue;
|
|
2718
|
+
}
|
|
2719
|
+
// Check if we need to recurse into children
|
|
2720
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
2721
|
+
// Only navigate to this element if we need to do something
|
|
2722
|
+
if (nodePatches.length > 0 || hasChildrenToCompare) {
|
|
2723
|
+
// Navigate to this child if not already there
|
|
2724
|
+
if (currentChildIndex === -1) {
|
|
2725
|
+
patches.push({
|
|
2726
|
+
type: NavigateChild,
|
|
2727
|
+
index: i
|
|
2728
|
+
});
|
|
2729
|
+
currentChildIndex = i;
|
|
2730
|
+
} else if (currentChildIndex !== i) {
|
|
2731
|
+
patches.push({
|
|
2732
|
+
type: NavigateSibling,
|
|
2733
|
+
index: i
|
|
2734
|
+
});
|
|
2735
|
+
currentChildIndex = i;
|
|
2736
|
+
}
|
|
2737
|
+
// Apply node patches (these apply to the current element, not children)
|
|
2738
|
+
if (nodePatches.length > 0) {
|
|
2739
|
+
patches.push(...nodePatches);
|
|
2740
|
+
}
|
|
2741
|
+
// Compare children recursively
|
|
2742
|
+
if (hasChildrenToCompare) {
|
|
2743
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
} else {
|
|
2747
|
+
// Remove old node - collect the index for later removal
|
|
2748
|
+
indicesToRemove.push(i);
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
// Navigate back to parent if we ended at a child
|
|
2752
|
+
if (currentChildIndex >= 0) {
|
|
2753
|
+
patches.push({
|
|
2754
|
+
type: NavigateParent
|
|
2755
|
+
});
|
|
2756
|
+
currentChildIndex = -1;
|
|
2757
|
+
}
|
|
2758
|
+
// Add remove patches in reverse order (highest index first)
|
|
2759
|
+
// This ensures indices remain valid as we remove
|
|
2760
|
+
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
2761
|
+
patches.push({
|
|
2762
|
+
type: RemoveChild,
|
|
2763
|
+
index: indicesToRemove[j]
|
|
2764
|
+
});
|
|
2765
|
+
}
|
|
2766
|
+
};
|
|
2767
|
+
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
2768
|
+
// At the root level (path.length === 0), we're already AT the element
|
|
2769
|
+
// So we compare the root node directly, then compare its children
|
|
2770
|
+
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
2771
|
+
const oldNode = oldTree[0];
|
|
2772
|
+
const newNode = newTree[0];
|
|
2773
|
+
// Compare root nodes
|
|
2774
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2775
|
+
// If nodePatches is null, the root node types are incompatible - need to replace
|
|
2776
|
+
if (nodePatches === null) {
|
|
2777
|
+
const flatNodes = treeToArray(newNode);
|
|
2778
|
+
patches.push({
|
|
2779
|
+
type: Replace,
|
|
2780
|
+
nodes: flatNodes
|
|
2781
|
+
});
|
|
2782
|
+
return;
|
|
2783
|
+
}
|
|
2784
|
+
if (nodePatches.length > 0) {
|
|
2785
|
+
patches.push(...nodePatches);
|
|
2786
|
+
}
|
|
2787
|
+
// Compare children
|
|
2788
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
2789
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
2790
|
+
}
|
|
2791
|
+
} else {
|
|
2792
|
+
// Non-root level or multiple root elements - use the regular comparison
|
|
2793
|
+
diffChildren(oldTree, newTree, patches);
|
|
2794
|
+
}
|
|
2795
|
+
};
|
|
2796
|
+
|
|
2797
|
+
const removeTrailingNavigationPatches = patches => {
|
|
2798
|
+
// Find the last non-navigation patch
|
|
2799
|
+
let lastNonNavigationIndex = -1;
|
|
2800
|
+
for (let i = patches.length - 1; i >= 0; i--) {
|
|
2801
|
+
const patch = patches[i];
|
|
2802
|
+
if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
|
|
2803
|
+
lastNonNavigationIndex = i;
|
|
2804
|
+
break;
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
// Return patches up to and including the last non-navigation patch
|
|
2808
|
+
return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
|
|
2809
|
+
};
|
|
2810
|
+
|
|
2811
|
+
const diffTree = (oldNodes, newNodes) => {
|
|
2812
|
+
// Step 1: Convert flat arrays to tree structures
|
|
2813
|
+
const oldTree = arrayToTree(oldNodes);
|
|
2814
|
+
const newTree = arrayToTree(newNodes);
|
|
2815
|
+
// Step 3: Compare the trees
|
|
2816
|
+
const patches = [];
|
|
2817
|
+
diffTrees(oldTree, newTree, patches, []);
|
|
2818
|
+
// Remove trailing navigation patches since they serve no purpose
|
|
2819
|
+
return removeTrailingNavigationPatches(patches);
|
|
2820
|
+
};
|
|
2821
|
+
|
|
2541
2822
|
const getTreeItemClassName = (isSelected, isFocused, isDropping, useChevrons, indent, decoration) => {
|
|
2542
2823
|
let className = TreeItem$1;
|
|
2543
2824
|
className = mergeClassNames(className, `Indent-${indent}`);
|
|
@@ -2611,7 +2892,6 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
2611
2892
|
ariaExpanded,
|
|
2612
2893
|
chevron,
|
|
2613
2894
|
className,
|
|
2614
|
-
// @ts-ignore
|
|
2615
2895
|
decoration,
|
|
2616
2896
|
hasEditingError: isEditing && Boolean(editingErrorMessage),
|
|
2617
2897
|
icon,
|
|
@@ -2718,6 +2998,7 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0, ass
|
|
|
2718
2998
|
height,
|
|
2719
2999
|
hoverIndex: -1,
|
|
2720
3000
|
icons: [],
|
|
3001
|
+
initial: false,
|
|
2721
3002
|
inputSource: 0,
|
|
2722
3003
|
isPointerDown: false,
|
|
2723
3004
|
itemHeight: ListItem,
|
|
@@ -2782,6 +3063,7 @@ const RenderValue = 8;
|
|
|
2782
3063
|
const RenderSelection = 9;
|
|
2783
3064
|
const RenderDragData = 10;
|
|
2784
3065
|
const RenderCss = 11;
|
|
3066
|
+
const RenderIncremental = 12;
|
|
2785
3067
|
|
|
2786
3068
|
const isEqual$1 = (oldState, newState) => {
|
|
2787
3069
|
if (newState.focus !== Input$1) {
|
|
@@ -3963,7 +4245,6 @@ const handleClickCurrentButKeepFocus = state => {
|
|
|
3963
4245
|
};
|
|
3964
4246
|
|
|
3965
4247
|
const openFolder = async () => {
|
|
3966
|
-
// @ts-ignore
|
|
3967
4248
|
await invoke$2(`Dialog.openFolder`);
|
|
3968
4249
|
};
|
|
3969
4250
|
|
|
@@ -4566,8 +4847,6 @@ const handleKeyDown = (state, key) => {
|
|
|
4566
4847
|
if (timeout) {
|
|
4567
4848
|
clearTimeout(timeout);
|
|
4568
4849
|
}
|
|
4569
|
-
|
|
4570
|
-
// @ts-ignore
|
|
4571
4850
|
timeout = setTimeout(async () => {
|
|
4572
4851
|
await invoke$2('Explorer.cancelTypeAhead');
|
|
4573
4852
|
}, focusWordTimeout);
|
|
@@ -5060,7 +5339,6 @@ const getSavedRoot = (savedState, workspacePath) => {
|
|
|
5060
5339
|
return workspacePath;
|
|
5061
5340
|
};
|
|
5062
5341
|
const loadContent = async (state, savedState) => {
|
|
5063
|
-
// @ts-ignore
|
|
5064
5342
|
const {
|
|
5065
5343
|
assetDir,
|
|
5066
5344
|
platform
|
|
@@ -5092,6 +5370,7 @@ const loadContent = async (state, savedState) => {
|
|
|
5092
5370
|
decorations,
|
|
5093
5371
|
deltaY,
|
|
5094
5372
|
excluded,
|
|
5373
|
+
initial: true,
|
|
5095
5374
|
items: restoredDirents,
|
|
5096
5375
|
maxIndent: 10,
|
|
5097
5376
|
minLineY,
|
|
@@ -5148,7 +5427,6 @@ const openContainingFolder = async state => {
|
|
|
5148
5427
|
const confirmDelete = async paths => {
|
|
5149
5428
|
// TODO use i18n string
|
|
5150
5429
|
const message = paths.length === 1 ? `Are you sure you want to delete "${paths[0]}"?` : `Are you sure you want to delete ${paths.length} items?`;
|
|
5151
|
-
// @ts-ignore
|
|
5152
5430
|
const result = await confirm(message);
|
|
5153
5431
|
return result === true;
|
|
5154
5432
|
};
|
|
@@ -5694,6 +5972,13 @@ const renderItems = (oldState, newState) => {
|
|
|
5694
5972
|
return [SetDom2, dom];
|
|
5695
5973
|
};
|
|
5696
5974
|
|
|
5975
|
+
const renderIncremental = (oldState, newState) => {
|
|
5976
|
+
const oldDom = renderItems(oldState, oldState)[1];
|
|
5977
|
+
const newDom = renderItems(newState, newState)[1];
|
|
5978
|
+
const patches = diffTree(oldDom, newDom);
|
|
5979
|
+
return [SetPatches, newState.uid, patches];
|
|
5980
|
+
};
|
|
5981
|
+
|
|
5697
5982
|
const renderValue = (oldState, newState) => {
|
|
5698
5983
|
if (newState.inputSource === User) {
|
|
5699
5984
|
return [];
|
|
@@ -5714,6 +5999,8 @@ const getRenderer = diffType => {
|
|
|
5714
5999
|
return renderFocus;
|
|
5715
6000
|
case RenderFocusContext:
|
|
5716
6001
|
return renderFocusContext;
|
|
6002
|
+
case RenderIncremental:
|
|
6003
|
+
return renderIncremental;
|
|
5717
6004
|
case RenderItems:
|
|
5718
6005
|
return renderItems;
|
|
5719
6006
|
case RenderSelection:
|