@lvce-editor/explorer-view 7.21.1 → 7.21.3
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 +574 -348
- package/package.json +1 -1
|
@@ -1,249 +1,3 @@
|
|
|
1
|
-
const toCommandId = key => {
|
|
2
|
-
const dotIndex = key.indexOf('.');
|
|
3
|
-
return key.slice(dotIndex + 1);
|
|
4
|
-
};
|
|
5
|
-
const create$a = () => {
|
|
6
|
-
const commandQueues = new Map();
|
|
7
|
-
const generations = Object.create(null);
|
|
8
|
-
const states = Object.create(null);
|
|
9
|
-
const commandMapRef = {};
|
|
10
|
-
const getGeneration = uid => generations[uid] || 0;
|
|
11
|
-
const isCurrentGeneration = (uid, generation) => {
|
|
12
|
-
return states[uid] !== undefined && getGeneration(uid) === generation;
|
|
13
|
-
};
|
|
14
|
-
const updateState = (uid, generation, fallbackState, updater) => {
|
|
15
|
-
if (!isCurrentGeneration(uid, generation)) {
|
|
16
|
-
return Promise.resolve(fallbackState);
|
|
17
|
-
}
|
|
18
|
-
const current = states[uid];
|
|
19
|
-
const updatedState = updater(current.newState);
|
|
20
|
-
if (updatedState !== current.newState) {
|
|
21
|
-
states[uid] = {
|
|
22
|
-
newState: updatedState,
|
|
23
|
-
oldState: current.oldState,
|
|
24
|
-
scheduledState: updatedState
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
return Promise.resolve(updatedState);
|
|
28
|
-
};
|
|
29
|
-
const createAsyncCommandContext = (uid, generation) => {
|
|
30
|
-
let latestState = states[uid].newState;
|
|
31
|
-
return {
|
|
32
|
-
getState: () => {
|
|
33
|
-
if (isCurrentGeneration(uid, generation)) {
|
|
34
|
-
latestState = states[uid].newState;
|
|
35
|
-
}
|
|
36
|
-
return latestState;
|
|
37
|
-
},
|
|
38
|
-
updateState: async updater => {
|
|
39
|
-
latestState = await updateState(uid, generation, latestState, updater);
|
|
40
|
-
return latestState;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
const enqueueCommand = async (uid, command) => {
|
|
45
|
-
const previous = commandQueues.get(uid) || Promise.resolve();
|
|
46
|
-
const run = async () => {
|
|
47
|
-
try {
|
|
48
|
-
await previous;
|
|
49
|
-
} catch {
|
|
50
|
-
// The previous caller receives its error; later commands must still run.
|
|
51
|
-
}
|
|
52
|
-
await command();
|
|
53
|
-
};
|
|
54
|
-
const current = run();
|
|
55
|
-
commandQueues.set(uid, current);
|
|
56
|
-
try {
|
|
57
|
-
await current;
|
|
58
|
-
} finally {
|
|
59
|
-
if (commandQueues.get(uid) === current) {
|
|
60
|
-
commandQueues.delete(uid);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
return {
|
|
65
|
-
clear() {
|
|
66
|
-
commandQueues.clear();
|
|
67
|
-
for (const key of Object.keys(states)) {
|
|
68
|
-
delete states[key];
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
diff(uid, modules, numbers) {
|
|
72
|
-
const {
|
|
73
|
-
oldState,
|
|
74
|
-
scheduledState
|
|
75
|
-
} = states[uid];
|
|
76
|
-
const diffResult = [];
|
|
77
|
-
for (let i = 0; i < modules.length; i++) {
|
|
78
|
-
const fn = modules[i];
|
|
79
|
-
if (!fn(oldState, scheduledState)) {
|
|
80
|
-
diffResult.push(numbers[i]);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return diffResult;
|
|
84
|
-
},
|
|
85
|
-
dispose(uid) {
|
|
86
|
-
commandQueues.delete(uid);
|
|
87
|
-
delete states[uid];
|
|
88
|
-
},
|
|
89
|
-
get(uid) {
|
|
90
|
-
return states[uid];
|
|
91
|
-
},
|
|
92
|
-
getCommandIds() {
|
|
93
|
-
const keys = Object.keys(commandMapRef);
|
|
94
|
-
const ids = keys.map(toCommandId);
|
|
95
|
-
return ids;
|
|
96
|
-
},
|
|
97
|
-
getKeys() {
|
|
98
|
-
return Object.keys(states).map(Number);
|
|
99
|
-
},
|
|
100
|
-
registerCommands(commandMap) {
|
|
101
|
-
Object.assign(commandMapRef, commandMap);
|
|
102
|
-
},
|
|
103
|
-
set(uid, oldState, newState, scheduledState) {
|
|
104
|
-
const current = states[uid];
|
|
105
|
-
if (!current || oldState === newState && newState !== current.newState) {
|
|
106
|
-
generations[uid] = getGeneration(uid) + 1;
|
|
107
|
-
}
|
|
108
|
-
states[uid] = {
|
|
109
|
-
newState,
|
|
110
|
-
oldState,
|
|
111
|
-
scheduledState: scheduledState ?? newState
|
|
112
|
-
};
|
|
113
|
-
},
|
|
114
|
-
wrapAsyncCommand(fn) {
|
|
115
|
-
const wrapped = async (uid, ...args) => {
|
|
116
|
-
const generation = getGeneration(uid);
|
|
117
|
-
const context = createAsyncCommandContext(uid, generation);
|
|
118
|
-
await fn(context, ...args);
|
|
119
|
-
};
|
|
120
|
-
return wrapped;
|
|
121
|
-
},
|
|
122
|
-
wrapCommand(fn) {
|
|
123
|
-
const wrapped = async (uid, ...args) => {
|
|
124
|
-
const generation = getGeneration(uid);
|
|
125
|
-
const {
|
|
126
|
-
newState,
|
|
127
|
-
oldState
|
|
128
|
-
} = states[uid];
|
|
129
|
-
const newerState = await fn(newState, ...args);
|
|
130
|
-
if (oldState === newerState || newState === newerState) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
if (!isCurrentGeneration(uid, generation)) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
const latestOld = states[uid];
|
|
137
|
-
const latestNew = {
|
|
138
|
-
...latestOld.newState,
|
|
139
|
-
...newerState
|
|
140
|
-
};
|
|
141
|
-
states[uid] = {
|
|
142
|
-
newState: latestNew,
|
|
143
|
-
oldState: latestOld.oldState,
|
|
144
|
-
scheduledState: latestNew
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
return wrapped;
|
|
148
|
-
},
|
|
149
|
-
wrapGetter(fn) {
|
|
150
|
-
const wrapped = (uid, ...args) => {
|
|
151
|
-
const {
|
|
152
|
-
newState
|
|
153
|
-
} = states[uid];
|
|
154
|
-
return fn(newState, ...args);
|
|
155
|
-
};
|
|
156
|
-
return wrapped;
|
|
157
|
-
},
|
|
158
|
-
wrapLoadContent(fn) {
|
|
159
|
-
const wrapped = async (uid, ...args) => {
|
|
160
|
-
const generation = getGeneration(uid);
|
|
161
|
-
const {
|
|
162
|
-
newState,
|
|
163
|
-
oldState
|
|
164
|
-
} = states[uid];
|
|
165
|
-
const result = await fn(newState, ...args);
|
|
166
|
-
const {
|
|
167
|
-
error,
|
|
168
|
-
state
|
|
169
|
-
} = result;
|
|
170
|
-
if (oldState === state || newState === state) {
|
|
171
|
-
return {
|
|
172
|
-
error
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
if (!isCurrentGeneration(uid, generation)) {
|
|
176
|
-
return {
|
|
177
|
-
error
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
const latestOld = states[uid];
|
|
181
|
-
const latestNew = {
|
|
182
|
-
...latestOld.newState,
|
|
183
|
-
...state
|
|
184
|
-
};
|
|
185
|
-
states[uid] = {
|
|
186
|
-
newState: latestNew,
|
|
187
|
-
oldState: latestOld.oldState,
|
|
188
|
-
scheduledState: latestNew
|
|
189
|
-
};
|
|
190
|
-
return {
|
|
191
|
-
error
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
return wrapped;
|
|
195
|
-
},
|
|
196
|
-
wrapSerialAsyncCommand(fn) {
|
|
197
|
-
const wrapped = async (uid, ...args) => {
|
|
198
|
-
await enqueueCommand(uid, async () => {
|
|
199
|
-
if (!states[uid]) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
const generation = getGeneration(uid);
|
|
203
|
-
const context = createAsyncCommandContext(uid, generation);
|
|
204
|
-
await fn(context, ...args);
|
|
205
|
-
});
|
|
206
|
-
};
|
|
207
|
-
return wrapped;
|
|
208
|
-
},
|
|
209
|
-
wrapSerialCommand(fn) {
|
|
210
|
-
const wrapped = async (uid, ...args) => {
|
|
211
|
-
await enqueueCommand(uid, async () => {
|
|
212
|
-
if (!states[uid]) {
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
const generation = getGeneration(uid);
|
|
216
|
-
const {
|
|
217
|
-
newState,
|
|
218
|
-
oldState
|
|
219
|
-
} = states[uid];
|
|
220
|
-
const newerState = await fn(newState, ...args);
|
|
221
|
-
if (oldState === newerState || newState === newerState) {
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
if (!isCurrentGeneration(uid, generation)) {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
const latestOld = states[uid];
|
|
228
|
-
const latestNew = {
|
|
229
|
-
...latestOld.newState,
|
|
230
|
-
...newerState
|
|
231
|
-
};
|
|
232
|
-
states[uid] = {
|
|
233
|
-
newState: latestNew,
|
|
234
|
-
oldState: latestOld.oldState,
|
|
235
|
-
scheduledState: latestNew
|
|
236
|
-
};
|
|
237
|
-
});
|
|
238
|
-
};
|
|
239
|
-
return wrapped;
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
};
|
|
243
|
-
const terminate = () => {
|
|
244
|
-
globalThis.close();
|
|
245
|
-
};
|
|
246
|
-
|
|
247
1
|
const normalizeLine = line => {
|
|
248
2
|
if (line.startsWith('Error: ')) {
|
|
249
3
|
return line.slice('Error: '.length);
|
|
@@ -300,12 +54,6 @@ class VError extends Error {
|
|
|
300
54
|
}
|
|
301
55
|
}
|
|
302
56
|
|
|
303
|
-
const CreateFolder$1 = 1;
|
|
304
|
-
const CreateFile$1 = 2;
|
|
305
|
-
const Copy$1 = 3;
|
|
306
|
-
const Rename$2 = 4;
|
|
307
|
-
const Remove = 5;
|
|
308
|
-
|
|
309
57
|
const isMessagePort = value => {
|
|
310
58
|
return value && value instanceof MessagePort;
|
|
311
59
|
};
|
|
@@ -997,7 +745,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
997
745
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
998
746
|
return create$1$1(id, errorProperty);
|
|
999
747
|
};
|
|
1000
|
-
const create$
|
|
748
|
+
const create$a = (message, result) => {
|
|
1001
749
|
return {
|
|
1002
750
|
id: message.id,
|
|
1003
751
|
jsonrpc: Two$1,
|
|
@@ -1006,7 +754,7 @@ const create$9 = (message, result) => {
|
|
|
1006
754
|
};
|
|
1007
755
|
const getSuccessResponse = (message, result) => {
|
|
1008
756
|
const resultProperty = result ?? null;
|
|
1009
|
-
return create$
|
|
757
|
+
return create$a(message, resultProperty);
|
|
1010
758
|
};
|
|
1011
759
|
const getErrorResponseSimple = (id, error) => {
|
|
1012
760
|
return {
|
|
@@ -1100,7 +848,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
1100
848
|
|
|
1101
849
|
const Two = '2.0';
|
|
1102
850
|
|
|
1103
|
-
const create$
|
|
851
|
+
const create$9 = (method, params) => {
|
|
1104
852
|
return {
|
|
1105
853
|
jsonrpc: Two,
|
|
1106
854
|
method,
|
|
@@ -1108,7 +856,7 @@ const create$8 = (method, params) => {
|
|
|
1108
856
|
};
|
|
1109
857
|
};
|
|
1110
858
|
|
|
1111
|
-
const create$
|
|
859
|
+
const create$8 = (id, method, params) => {
|
|
1112
860
|
const message = {
|
|
1113
861
|
id,
|
|
1114
862
|
jsonrpc: Two,
|
|
@@ -1119,12 +867,12 @@ const create$7 = (id, method, params) => {
|
|
|
1119
867
|
};
|
|
1120
868
|
|
|
1121
869
|
let id = 0;
|
|
1122
|
-
const create$
|
|
870
|
+
const create$7 = () => {
|
|
1123
871
|
return ++id;
|
|
1124
872
|
};
|
|
1125
873
|
|
|
1126
874
|
const registerPromise = map => {
|
|
1127
|
-
const id = create$
|
|
875
|
+
const id = create$7();
|
|
1128
876
|
const {
|
|
1129
877
|
promise,
|
|
1130
878
|
resolve
|
|
@@ -1141,7 +889,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
1141
889
|
id,
|
|
1142
890
|
promise
|
|
1143
891
|
} = registerPromise(callbacks);
|
|
1144
|
-
const message = create$
|
|
892
|
+
const message = create$8(id, method, params);
|
|
1145
893
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
1146
894
|
ipc.sendAndTransfer(message);
|
|
1147
895
|
} else {
|
|
@@ -1177,7 +925,7 @@ const createRpc = ipc => {
|
|
|
1177
925
|
* @deprecated
|
|
1178
926
|
*/
|
|
1179
927
|
send(method, ...params) {
|
|
1180
|
-
const message = create$
|
|
928
|
+
const message = create$9(method, params);
|
|
1181
929
|
ipc.send(message);
|
|
1182
930
|
}
|
|
1183
931
|
};
|
|
@@ -1245,7 +993,7 @@ const createSharedLazyRpc = factory => {
|
|
|
1245
993
|
};
|
|
1246
994
|
};
|
|
1247
995
|
|
|
1248
|
-
const create$
|
|
996
|
+
const create$6 = async ({
|
|
1249
997
|
commandMap,
|
|
1250
998
|
isMessagePortOpen = true,
|
|
1251
999
|
messagePort
|
|
@@ -1263,7 +1011,7 @@ const create$5 = async ({
|
|
|
1263
1011
|
return rpc;
|
|
1264
1012
|
};
|
|
1265
1013
|
|
|
1266
|
-
const create$
|
|
1014
|
+
const create$5 = async ({
|
|
1267
1015
|
commandMap,
|
|
1268
1016
|
isMessagePortOpen,
|
|
1269
1017
|
send
|
|
@@ -1273,20 +1021,20 @@ const create$4 = async ({
|
|
|
1273
1021
|
port2
|
|
1274
1022
|
} = new MessageChannel();
|
|
1275
1023
|
await send(port1);
|
|
1276
|
-
return create$
|
|
1024
|
+
return create$6({
|
|
1277
1025
|
commandMap,
|
|
1278
1026
|
isMessagePortOpen,
|
|
1279
1027
|
messagePort: port2
|
|
1280
1028
|
});
|
|
1281
1029
|
};
|
|
1282
1030
|
|
|
1283
|
-
const create$
|
|
1031
|
+
const create$4 = async ({
|
|
1284
1032
|
commandMap,
|
|
1285
1033
|
isMessagePortOpen,
|
|
1286
1034
|
send
|
|
1287
1035
|
}) => {
|
|
1288
1036
|
return createSharedLazyRpc(() => {
|
|
1289
|
-
return create$
|
|
1037
|
+
return create$5({
|
|
1290
1038
|
commandMap,
|
|
1291
1039
|
isMessagePortOpen,
|
|
1292
1040
|
send
|
|
@@ -1294,7 +1042,7 @@ const create$3 = async ({
|
|
|
1294
1042
|
});
|
|
1295
1043
|
};
|
|
1296
1044
|
|
|
1297
|
-
const create$
|
|
1045
|
+
const create$3 = async ({
|
|
1298
1046
|
commandMap
|
|
1299
1047
|
}) => {
|
|
1300
1048
|
// TODO create a commandMap per rpc instance
|
|
@@ -1326,7 +1074,7 @@ const createMockRpc = ({
|
|
|
1326
1074
|
};
|
|
1327
1075
|
|
|
1328
1076
|
const rpcs = Object.create(null);
|
|
1329
|
-
const set$
|
|
1077
|
+
const set$9 = (id, rpc) => {
|
|
1330
1078
|
rpcs[id] = rpc;
|
|
1331
1079
|
};
|
|
1332
1080
|
const get$1 = id => {
|
|
@@ -1337,7 +1085,7 @@ const remove$1 = id => {
|
|
|
1337
1085
|
};
|
|
1338
1086
|
|
|
1339
1087
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1340
|
-
const create$
|
|
1088
|
+
const create$2 = rpcId => {
|
|
1341
1089
|
return {
|
|
1342
1090
|
async dispose() {
|
|
1343
1091
|
const rpc = get$1(rpcId);
|
|
@@ -1359,7 +1107,7 @@ const create$1 = rpcId => {
|
|
|
1359
1107
|
const mockRpc = createMockRpc({
|
|
1360
1108
|
commandMap
|
|
1361
1109
|
});
|
|
1362
|
-
set$
|
|
1110
|
+
set$9(rpcId, mockRpc);
|
|
1363
1111
|
// @ts-ignore
|
|
1364
1112
|
mockRpc[Symbol.dispose] = () => {
|
|
1365
1113
|
remove$1(rpcId);
|
|
@@ -1368,7 +1116,7 @@ const create$1 = rpcId => {
|
|
|
1368
1116
|
return mockRpc;
|
|
1369
1117
|
},
|
|
1370
1118
|
set(rpc) {
|
|
1371
|
-
set$
|
|
1119
|
+
set$9(rpcId, rpc);
|
|
1372
1120
|
}
|
|
1373
1121
|
};
|
|
1374
1122
|
};
|
|
@@ -1546,7 +1294,6 @@ const Button$3 = 'event.button';
|
|
|
1546
1294
|
const ClientX = 'event.clientX';
|
|
1547
1295
|
const ClientY = 'event.clientY';
|
|
1548
1296
|
const CtrlKey = 'event.ctrlKey';
|
|
1549
|
-
const DataTransferFiles = 'event.dataTransfer.files';
|
|
1550
1297
|
const DataTransferFiles2 = 'event.dataTransfer.files2';
|
|
1551
1298
|
const DefaultPrevented = 'event.defaultPrevented';
|
|
1552
1299
|
const DeltaMode = 'event.deltaMode';
|
|
@@ -1570,7 +1317,6 @@ const DownArrow = 16;
|
|
|
1570
1317
|
const Delete$1 = 18;
|
|
1571
1318
|
const KeyA = 29;
|
|
1572
1319
|
const KeyC = 31;
|
|
1573
|
-
const KeyV = 50;
|
|
1574
1320
|
const KeyX = 52;
|
|
1575
1321
|
const F2 = 58;
|
|
1576
1322
|
const Star = 131;
|
|
@@ -1579,6 +1325,8 @@ const CtrlCmd = 1 << 11 >>> 0;
|
|
|
1579
1325
|
const Shift = 1 << 10 >>> 0;
|
|
1580
1326
|
const Alt = 1 << 9 >>> 0;
|
|
1581
1327
|
|
|
1328
|
+
const DialogWorker = 7014;
|
|
1329
|
+
const DragAndDropWorker = 3404;
|
|
1582
1330
|
const FileSystemWorker$1 = 209;
|
|
1583
1331
|
const IconThemeWorker = 7009;
|
|
1584
1332
|
const RendererWorker = 1;
|
|
@@ -1594,9 +1342,22 @@ const SetPatches = 'Viewlet.setPatches';
|
|
|
1594
1342
|
const FocusExplorer = 13;
|
|
1595
1343
|
const FocusExplorerEditBox = 14;
|
|
1596
1344
|
|
|
1345
|
+
const {
|
|
1346
|
+
invoke: invoke$5,
|
|
1347
|
+
set: set$8
|
|
1348
|
+
} = create$2(DialogWorker);
|
|
1349
|
+
|
|
1350
|
+
const {
|
|
1351
|
+
invoke: invoke$4,
|
|
1352
|
+
set: set$7
|
|
1353
|
+
} = create$2(DragAndDropWorker);
|
|
1354
|
+
const getDroppedItems$1 = async (itemIds, isElectron) => {
|
|
1355
|
+
return invoke$4('DragAndDrop.getDroppedItems', itemIds, isElectron);
|
|
1356
|
+
};
|
|
1357
|
+
|
|
1597
1358
|
const {
|
|
1598
1359
|
set: set$6
|
|
1599
|
-
} = create$
|
|
1360
|
+
} = create$2(FileSystemWorker$1);
|
|
1600
1361
|
|
|
1601
1362
|
const FileSystemWorker = {
|
|
1602
1363
|
__proto__: null,
|
|
@@ -1606,7 +1367,7 @@ const FileSystemWorker = {
|
|
|
1606
1367
|
const {
|
|
1607
1368
|
invoke: invoke$3,
|
|
1608
1369
|
set: set$5
|
|
1609
|
-
} = create$
|
|
1370
|
+
} = create$2(IconThemeWorker);
|
|
1610
1371
|
const getIcons = async iconRequests => {
|
|
1611
1372
|
// @ts-ignore
|
|
1612
1373
|
return invoke$3('IconTheme.getIcons', iconRequests);
|
|
@@ -1677,7 +1438,7 @@ const {
|
|
|
1677
1438
|
invoke: invoke$2,
|
|
1678
1439
|
invokeAndTransfer,
|
|
1679
1440
|
set: set$4
|
|
1680
|
-
} = create$
|
|
1441
|
+
} = create$2(RendererWorker);
|
|
1681
1442
|
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
1682
1443
|
number(uid);
|
|
1683
1444
|
number(menuId);
|
|
@@ -1685,9 +1446,13 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
|
1685
1446
|
number(y);
|
|
1686
1447
|
await invoke$2('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1687
1448
|
};
|
|
1688
|
-
const
|
|
1689
|
-
const
|
|
1690
|
-
|
|
1449
|
+
const sendMessagePortToDragAndDropWorker = async port => {
|
|
1450
|
+
const command = 'DragAndDrop.handleMessagePort';
|
|
1451
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDragAndDropWorker', port, command);
|
|
1452
|
+
};
|
|
1453
|
+
const sendMessagePortToDialogWorker = async port => {
|
|
1454
|
+
const command = 'HandleMessagePort.handleMessagePort';
|
|
1455
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
|
|
1691
1456
|
};
|
|
1692
1457
|
const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
|
|
1693
1458
|
const command = 'IconTheme.handleMessagePort';
|
|
@@ -1697,7 +1462,7 @@ const sendMessagePortToFileSystemWorker$1 = async (port, rpcId) => {
|
|
|
1697
1462
|
const command = 'FileSystem.handleMessagePort';
|
|
1698
1463
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
|
|
1699
1464
|
};
|
|
1700
|
-
const confirm = async (message, options) => {
|
|
1465
|
+
const confirm$1 = async (message, options) => {
|
|
1701
1466
|
const result = await invoke$2('ConfirmPrompt.prompt', message, options);
|
|
1702
1467
|
return result;
|
|
1703
1468
|
};
|
|
@@ -1708,18 +1473,270 @@ const sendMessagePortToSourceControlWorker = async port => {
|
|
|
1708
1473
|
const command = 'SourceControl.handleMessagePort';
|
|
1709
1474
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSourceControlWorker', port, command, 0);
|
|
1710
1475
|
};
|
|
1711
|
-
const openUri$1 = async (uri, focus, options) => {
|
|
1712
|
-
await invoke$2('Main.openUri', {
|
|
1713
|
-
...options,
|
|
1714
|
-
focus,
|
|
1715
|
-
uri
|
|
1716
|
-
});
|
|
1476
|
+
const openUri$1 = async (uri, focus, options) => {
|
|
1477
|
+
await invoke$2('Main.openUri', {
|
|
1478
|
+
...options,
|
|
1479
|
+
focus,
|
|
1480
|
+
uri
|
|
1481
|
+
});
|
|
1482
|
+
};
|
|
1483
|
+
|
|
1484
|
+
const {
|
|
1485
|
+
invoke: invoke$1,
|
|
1486
|
+
set: set$3
|
|
1487
|
+
} = create$2(SourceControlWorker);
|
|
1488
|
+
|
|
1489
|
+
const toCommandId = key => {
|
|
1490
|
+
const dotIndex = key.indexOf('.');
|
|
1491
|
+
return key.slice(dotIndex + 1);
|
|
1492
|
+
};
|
|
1493
|
+
const create$1 = () => {
|
|
1494
|
+
const commandQueues = new Map();
|
|
1495
|
+
const generations = Object.create(null);
|
|
1496
|
+
const states = Object.create(null);
|
|
1497
|
+
const commandMapRef = {};
|
|
1498
|
+
const getGeneration = uid => generations[uid] || 0;
|
|
1499
|
+
const isCurrentGeneration = (uid, generation) => {
|
|
1500
|
+
return states[uid] !== undefined && getGeneration(uid) === generation;
|
|
1501
|
+
};
|
|
1502
|
+
const updateState = (uid, generation, fallbackState, updater) => {
|
|
1503
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1504
|
+
return Promise.resolve(fallbackState);
|
|
1505
|
+
}
|
|
1506
|
+
const current = states[uid];
|
|
1507
|
+
const updatedState = updater(current.newState);
|
|
1508
|
+
if (updatedState !== current.newState) {
|
|
1509
|
+
states[uid] = {
|
|
1510
|
+
newState: updatedState,
|
|
1511
|
+
oldState: current.oldState,
|
|
1512
|
+
scheduledState: updatedState
|
|
1513
|
+
};
|
|
1514
|
+
}
|
|
1515
|
+
return Promise.resolve(updatedState);
|
|
1516
|
+
};
|
|
1517
|
+
const createAsyncCommandContext = (uid, generation) => {
|
|
1518
|
+
let latestState = states[uid].newState;
|
|
1519
|
+
return {
|
|
1520
|
+
getState: () => {
|
|
1521
|
+
if (isCurrentGeneration(uid, generation)) {
|
|
1522
|
+
latestState = states[uid].newState;
|
|
1523
|
+
}
|
|
1524
|
+
return latestState;
|
|
1525
|
+
},
|
|
1526
|
+
updateState: async updater => {
|
|
1527
|
+
latestState = await updateState(uid, generation, latestState, updater);
|
|
1528
|
+
return latestState;
|
|
1529
|
+
}
|
|
1530
|
+
};
|
|
1531
|
+
};
|
|
1532
|
+
const enqueueCommand = async (uid, command) => {
|
|
1533
|
+
const previous = commandQueues.get(uid) || Promise.resolve();
|
|
1534
|
+
const run = async () => {
|
|
1535
|
+
try {
|
|
1536
|
+
await previous;
|
|
1537
|
+
} catch {
|
|
1538
|
+
// The previous caller receives its error; later commands must still run.
|
|
1539
|
+
}
|
|
1540
|
+
await command();
|
|
1541
|
+
};
|
|
1542
|
+
const current = run();
|
|
1543
|
+
commandQueues.set(uid, current);
|
|
1544
|
+
try {
|
|
1545
|
+
await current;
|
|
1546
|
+
} finally {
|
|
1547
|
+
if (commandQueues.get(uid) === current) {
|
|
1548
|
+
commandQueues.delete(uid);
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
};
|
|
1552
|
+
return {
|
|
1553
|
+
clear() {
|
|
1554
|
+
commandQueues.clear();
|
|
1555
|
+
for (const key of Object.keys(states)) {
|
|
1556
|
+
delete states[key];
|
|
1557
|
+
}
|
|
1558
|
+
},
|
|
1559
|
+
diff(uid, modules, numbers) {
|
|
1560
|
+
const {
|
|
1561
|
+
oldState,
|
|
1562
|
+
scheduledState
|
|
1563
|
+
} = states[uid];
|
|
1564
|
+
const diffResult = [];
|
|
1565
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1566
|
+
const fn = modules[i];
|
|
1567
|
+
if (!fn(oldState, scheduledState)) {
|
|
1568
|
+
diffResult.push(numbers[i]);
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
return diffResult;
|
|
1572
|
+
},
|
|
1573
|
+
dispose(uid) {
|
|
1574
|
+
commandQueues.delete(uid);
|
|
1575
|
+
delete states[uid];
|
|
1576
|
+
},
|
|
1577
|
+
get(uid) {
|
|
1578
|
+
return states[uid];
|
|
1579
|
+
},
|
|
1580
|
+
getCommandIds() {
|
|
1581
|
+
const keys = Object.keys(commandMapRef);
|
|
1582
|
+
const ids = keys.map(toCommandId);
|
|
1583
|
+
return ids;
|
|
1584
|
+
},
|
|
1585
|
+
getKeys() {
|
|
1586
|
+
return Object.keys(states).map(Number);
|
|
1587
|
+
},
|
|
1588
|
+
registerCommands(commandMap) {
|
|
1589
|
+
Object.assign(commandMapRef, commandMap);
|
|
1590
|
+
},
|
|
1591
|
+
set(uid, oldState, newState, scheduledState) {
|
|
1592
|
+
const current = states[uid];
|
|
1593
|
+
if (!current || oldState === newState && newState !== current.newState) {
|
|
1594
|
+
generations[uid] = getGeneration(uid) + 1;
|
|
1595
|
+
}
|
|
1596
|
+
states[uid] = {
|
|
1597
|
+
newState,
|
|
1598
|
+
oldState,
|
|
1599
|
+
scheduledState: scheduledState ?? newState
|
|
1600
|
+
};
|
|
1601
|
+
},
|
|
1602
|
+
wrapAsyncCommand(fn) {
|
|
1603
|
+
const wrapped = async (uid, ...args) => {
|
|
1604
|
+
const generation = getGeneration(uid);
|
|
1605
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
1606
|
+
await fn(context, ...args);
|
|
1607
|
+
};
|
|
1608
|
+
return wrapped;
|
|
1609
|
+
},
|
|
1610
|
+
wrapCommand(fn) {
|
|
1611
|
+
const wrapped = async (uid, ...args) => {
|
|
1612
|
+
const generation = getGeneration(uid);
|
|
1613
|
+
const {
|
|
1614
|
+
newState,
|
|
1615
|
+
oldState
|
|
1616
|
+
} = states[uid];
|
|
1617
|
+
const newerState = await fn(newState, ...args);
|
|
1618
|
+
if (oldState === newerState || newState === newerState) {
|
|
1619
|
+
return;
|
|
1620
|
+
}
|
|
1621
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1622
|
+
return;
|
|
1623
|
+
}
|
|
1624
|
+
const latestOld = states[uid];
|
|
1625
|
+
const latestNew = {
|
|
1626
|
+
...latestOld.newState,
|
|
1627
|
+
...newerState
|
|
1628
|
+
};
|
|
1629
|
+
states[uid] = {
|
|
1630
|
+
newState: latestNew,
|
|
1631
|
+
oldState: latestOld.oldState,
|
|
1632
|
+
scheduledState: latestNew
|
|
1633
|
+
};
|
|
1634
|
+
};
|
|
1635
|
+
return wrapped;
|
|
1636
|
+
},
|
|
1637
|
+
wrapGetter(fn) {
|
|
1638
|
+
const wrapped = (uid, ...args) => {
|
|
1639
|
+
const {
|
|
1640
|
+
newState
|
|
1641
|
+
} = states[uid];
|
|
1642
|
+
return fn(newState, ...args);
|
|
1643
|
+
};
|
|
1644
|
+
return wrapped;
|
|
1645
|
+
},
|
|
1646
|
+
wrapLoadContent(fn) {
|
|
1647
|
+
const wrapped = async (uid, ...args) => {
|
|
1648
|
+
const generation = getGeneration(uid);
|
|
1649
|
+
const {
|
|
1650
|
+
newState,
|
|
1651
|
+
oldState
|
|
1652
|
+
} = states[uid];
|
|
1653
|
+
const result = await fn(newState, ...args);
|
|
1654
|
+
const {
|
|
1655
|
+
error,
|
|
1656
|
+
state
|
|
1657
|
+
} = result;
|
|
1658
|
+
if (oldState === state || newState === state) {
|
|
1659
|
+
return {
|
|
1660
|
+
error
|
|
1661
|
+
};
|
|
1662
|
+
}
|
|
1663
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1664
|
+
return {
|
|
1665
|
+
error
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
const latestOld = states[uid];
|
|
1669
|
+
const latestNew = {
|
|
1670
|
+
...latestOld.newState,
|
|
1671
|
+
...state
|
|
1672
|
+
};
|
|
1673
|
+
states[uid] = {
|
|
1674
|
+
newState: latestNew,
|
|
1675
|
+
oldState: latestOld.oldState,
|
|
1676
|
+
scheduledState: latestNew
|
|
1677
|
+
};
|
|
1678
|
+
return {
|
|
1679
|
+
error
|
|
1680
|
+
};
|
|
1681
|
+
};
|
|
1682
|
+
return wrapped;
|
|
1683
|
+
},
|
|
1684
|
+
wrapSerialAsyncCommand(fn) {
|
|
1685
|
+
const wrapped = async (uid, ...args) => {
|
|
1686
|
+
await enqueueCommand(uid, async () => {
|
|
1687
|
+
if (!states[uid]) {
|
|
1688
|
+
return;
|
|
1689
|
+
}
|
|
1690
|
+
const generation = getGeneration(uid);
|
|
1691
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
1692
|
+
await fn(context, ...args);
|
|
1693
|
+
});
|
|
1694
|
+
};
|
|
1695
|
+
return wrapped;
|
|
1696
|
+
},
|
|
1697
|
+
wrapSerialCommand(fn) {
|
|
1698
|
+
const wrapped = async (uid, ...args) => {
|
|
1699
|
+
await enqueueCommand(uid, async () => {
|
|
1700
|
+
if (!states[uid]) {
|
|
1701
|
+
return;
|
|
1702
|
+
}
|
|
1703
|
+
const generation = getGeneration(uid);
|
|
1704
|
+
const {
|
|
1705
|
+
newState,
|
|
1706
|
+
oldState
|
|
1707
|
+
} = states[uid];
|
|
1708
|
+
const newerState = await fn(newState, ...args);
|
|
1709
|
+
if (oldState === newerState || newState === newerState) {
|
|
1710
|
+
return;
|
|
1711
|
+
}
|
|
1712
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1713
|
+
return;
|
|
1714
|
+
}
|
|
1715
|
+
const latestOld = states[uid];
|
|
1716
|
+
const latestNew = {
|
|
1717
|
+
...latestOld.newState,
|
|
1718
|
+
...newerState
|
|
1719
|
+
};
|
|
1720
|
+
states[uid] = {
|
|
1721
|
+
newState: latestNew,
|
|
1722
|
+
oldState: latestOld.oldState,
|
|
1723
|
+
scheduledState: latestNew
|
|
1724
|
+
};
|
|
1725
|
+
});
|
|
1726
|
+
};
|
|
1727
|
+
return wrapped;
|
|
1728
|
+
}
|
|
1729
|
+
};
|
|
1730
|
+
};
|
|
1731
|
+
const terminate = () => {
|
|
1732
|
+
globalThis.close();
|
|
1717
1733
|
};
|
|
1718
1734
|
|
|
1719
|
-
const
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1735
|
+
const CreateFolder$1 = 1;
|
|
1736
|
+
const CreateFile$1 = 2;
|
|
1737
|
+
const Copy$1 = 3;
|
|
1738
|
+
const Rename$2 = 4;
|
|
1739
|
+
const Remove = 5;
|
|
1723
1740
|
|
|
1724
1741
|
// TODO use direct connection
|
|
1725
1742
|
const invoke = async (method, ...params) => {
|
|
@@ -1818,7 +1835,7 @@ const dirname = (pathSeparator, path) => {
|
|
|
1818
1835
|
const dirname2 = path => {
|
|
1819
1836
|
return dirname('/', path);
|
|
1820
1837
|
};
|
|
1821
|
-
const join = (pathSeparator, ...parts) => {
|
|
1838
|
+
const join$1 = (pathSeparator, ...parts) => {
|
|
1822
1839
|
return parts.join(pathSeparator);
|
|
1823
1840
|
};
|
|
1824
1841
|
const getBaseName = (pathSeparator, path) => {
|
|
@@ -1862,11 +1879,12 @@ const createTree = (items, root) => {
|
|
|
1862
1879
|
return tree;
|
|
1863
1880
|
};
|
|
1864
1881
|
|
|
1865
|
-
const None$
|
|
1882
|
+
const None$6 = 0;
|
|
1866
1883
|
const CreateFile = 1;
|
|
1867
1884
|
const CreateFolder = 2;
|
|
1868
1885
|
const Rename$1 = 3;
|
|
1869
1886
|
|
|
1887
|
+
const None$5 = 0;
|
|
1870
1888
|
const List = 1;
|
|
1871
1889
|
const Input$1 = 2;
|
|
1872
1890
|
|
|
@@ -2319,6 +2337,7 @@ const i18nString = (key, placeholders = emptyObject) => {
|
|
|
2319
2337
|
};
|
|
2320
2338
|
|
|
2321
2339
|
const CollapseAllFoldersInExplorer = 'Collapse All Folders in Explorer';
|
|
2340
|
+
const CannotMoveFolderIntoSubfolderOfItself = 'Cannot move folder {PH1} into a subfolder of itself';
|
|
2322
2341
|
const Copy = 'Copy';
|
|
2323
2342
|
const CopyPath = 'Copy Path';
|
|
2324
2343
|
const CopyRelativePath = 'Copy Relative Path';
|
|
@@ -2422,6 +2441,11 @@ const fileOrFolderAlreadyExists = name => {
|
|
|
2422
2441
|
PH1: name
|
|
2423
2442
|
});
|
|
2424
2443
|
};
|
|
2444
|
+
const cannotMoveFolderIntoSubfolderOfItself = folderName => {
|
|
2445
|
+
return i18nString(CannotMoveFolderIntoSubfolderOfItself, {
|
|
2446
|
+
PH1: folderName
|
|
2447
|
+
});
|
|
2448
|
+
};
|
|
2425
2449
|
const theNameIsNotValid = () => {
|
|
2426
2450
|
return i18nString(TheNameIsNotValid);
|
|
2427
2451
|
};
|
|
@@ -2498,7 +2522,7 @@ const acceptCreate = async (state, newDirentType) => {
|
|
|
2498
2522
|
return {
|
|
2499
2523
|
...state,
|
|
2500
2524
|
editingIndex: -1,
|
|
2501
|
-
editingType: None$
|
|
2525
|
+
editingType: None$6,
|
|
2502
2526
|
focus: List,
|
|
2503
2527
|
focusedIndex: newFocusedIndex,
|
|
2504
2528
|
items: dirents
|
|
@@ -2548,7 +2572,7 @@ const cancelEditRename = (state, keepFocus) => {
|
|
|
2548
2572
|
editingIndex: -1,
|
|
2549
2573
|
editingSelectionEnd: 0,
|
|
2550
2574
|
editingSelectionStart: 0,
|
|
2551
|
-
editingType: None$
|
|
2575
|
+
editingType: None$6,
|
|
2552
2576
|
editingValue: '',
|
|
2553
2577
|
focus: List,
|
|
2554
2578
|
focused: keepFocus,
|
|
@@ -2667,7 +2691,7 @@ const acceptRename = async state => {
|
|
|
2667
2691
|
editingIndex: -1,
|
|
2668
2692
|
editingSelectionEnd: 0,
|
|
2669
2693
|
editingSelectionStart: 0,
|
|
2670
|
-
editingType: None$
|
|
2694
|
+
editingType: None$6,
|
|
2671
2695
|
editingValue: '',
|
|
2672
2696
|
focus: List,
|
|
2673
2697
|
focused: true,
|
|
@@ -2722,7 +2746,7 @@ const cancelEditCreate = async (state, keepFocus) => {
|
|
|
2722
2746
|
...state,
|
|
2723
2747
|
editingErrorMessage: '',
|
|
2724
2748
|
editingIndex: -1,
|
|
2725
|
-
editingType: None$
|
|
2749
|
+
editingType: None$6,
|
|
2726
2750
|
editingValue: '',
|
|
2727
2751
|
focus: List,
|
|
2728
2752
|
focused: keepFocus,
|
|
@@ -2867,6 +2891,30 @@ const copyRelativePath = async state => {
|
|
|
2867
2891
|
return state;
|
|
2868
2892
|
};
|
|
2869
2893
|
|
|
2894
|
+
const missingDialogWorkerRelay = 'Command "SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker" not found';
|
|
2895
|
+
const state = {
|
|
2896
|
+
isTest: false
|
|
2897
|
+
};
|
|
2898
|
+
const setIsTest = value => {
|
|
2899
|
+
state.isTest = value;
|
|
2900
|
+
};
|
|
2901
|
+
const confirm = async message => {
|
|
2902
|
+
const {
|
|
2903
|
+
isTest
|
|
2904
|
+
} = state;
|
|
2905
|
+
if (isTest) {
|
|
2906
|
+
return confirm$1(message);
|
|
2907
|
+
}
|
|
2908
|
+
try {
|
|
2909
|
+
return await invoke$5('ConfirmPrompt.prompt', message, undefined);
|
|
2910
|
+
} catch (error) {
|
|
2911
|
+
if (!String(error).includes(missingDialogWorkerRelay)) {
|
|
2912
|
+
throw error;
|
|
2913
|
+
}
|
|
2914
|
+
return confirm$1(message);
|
|
2915
|
+
}
|
|
2916
|
+
};
|
|
2917
|
+
|
|
2870
2918
|
const commandCompletions = new WeakMap();
|
|
2871
2919
|
const set$1 = (state, completion) => {
|
|
2872
2920
|
commandCompletions.set(state, completion);
|
|
@@ -2976,7 +3024,7 @@ const getFileIcons = async (dirents, fileIconCache) => {
|
|
|
2976
3024
|
};
|
|
2977
3025
|
};
|
|
2978
3026
|
|
|
2979
|
-
const directoryTypes$
|
|
3027
|
+
const directoryTypes$2 = new Set([DirectoryExpanded, DirectoryExpanding, EditingDirectoryExpanded]);
|
|
2980
3028
|
const getParentPath = (path, pathSeparator) => {
|
|
2981
3029
|
const index = path.lastIndexOf(pathSeparator);
|
|
2982
3030
|
if (index === -1) {
|
|
@@ -2987,7 +3035,7 @@ const getParentPath = (path, pathSeparator) => {
|
|
|
2987
3035
|
const getGitIgnoreCandidateDirs = (root, items, pathSeparator) => {
|
|
2988
3036
|
const dirs = new Set([root]);
|
|
2989
3037
|
for (const item of items) {
|
|
2990
|
-
if (directoryTypes$
|
|
3038
|
+
if (directoryTypes$2.has(item.type)) {
|
|
2991
3039
|
dirs.add(item.path);
|
|
2992
3040
|
}
|
|
2993
3041
|
const parent = getParentPath(item.path, pathSeparator);
|
|
@@ -3663,7 +3711,7 @@ const {
|
|
|
3663
3711
|
registerCommands,
|
|
3664
3712
|
set,
|
|
3665
3713
|
wrapGetter
|
|
3666
|
-
} = create$
|
|
3714
|
+
} = create$1();
|
|
3667
3715
|
const commandQueues = new Map();
|
|
3668
3716
|
const runQueuedCommand = async (previousCommand, command) => {
|
|
3669
3717
|
await previousCommand;
|
|
@@ -3791,7 +3839,8 @@ const ListItem = 22;
|
|
|
3791
3839
|
const Slash = '/';
|
|
3792
3840
|
|
|
3793
3841
|
// TODO parentUid might ot be needed
|
|
3794
|
-
const create = (id, uri, x, y, width, height, args, parentUid, platform = 0, assetDir = '') => {
|
|
3842
|
+
const create = (id, uri, x, y, width, height, args, parentUid, platform = 0, assetDir = '', isTest = false) => {
|
|
3843
|
+
setIsTest(isTest);
|
|
3795
3844
|
const state = {
|
|
3796
3845
|
assetDir,
|
|
3797
3846
|
chevronSpace: 22,
|
|
@@ -3809,7 +3858,7 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0, ass
|
|
|
3809
3858
|
editingSelectionEnd: 0,
|
|
3810
3859
|
editingSelectionStart: 0,
|
|
3811
3860
|
editingSessionId: 0,
|
|
3812
|
-
editingType: None$
|
|
3861
|
+
editingType: None$6,
|
|
3813
3862
|
editingValue: '',
|
|
3814
3863
|
errorCode: '',
|
|
3815
3864
|
errorMessage: '',
|
|
@@ -4226,10 +4275,6 @@ const getKeyBindings = () => {
|
|
|
4226
4275
|
command: 'Explorer.collapseAll',
|
|
4227
4276
|
key: CtrlCmd | LeftArrow,
|
|
4228
4277
|
when: FocusExplorer
|
|
4229
|
-
}, {
|
|
4230
|
-
command: 'Explorer.handlePaste',
|
|
4231
|
-
key: CtrlCmd | KeyV,
|
|
4232
|
-
when: FocusExplorer
|
|
4233
4278
|
}, {
|
|
4234
4279
|
command: 'Explorer.handleCopy',
|
|
4235
4280
|
key: CtrlCmd | KeyC,
|
|
@@ -4665,6 +4710,7 @@ const handleBlur = async state => {
|
|
|
4665
4710
|
});
|
|
4666
4711
|
return {
|
|
4667
4712
|
...state,
|
|
4713
|
+
focus: None$5,
|
|
4668
4714
|
focused: false,
|
|
4669
4715
|
items: newItems
|
|
4670
4716
|
};
|
|
@@ -5039,7 +5085,7 @@ const resetEditing = {
|
|
|
5039
5085
|
end: 0,
|
|
5040
5086
|
start: 0
|
|
5041
5087
|
},
|
|
5042
|
-
editingType: None$
|
|
5088
|
+
editingType: None$6,
|
|
5043
5089
|
editingValue: ''
|
|
5044
5090
|
};
|
|
5045
5091
|
|
|
@@ -5917,7 +5963,7 @@ const getFileOperationsElectron = async (root, paths, fileHandles, pathSeparator
|
|
|
5917
5963
|
const path = paths[i];
|
|
5918
5964
|
operations.push({
|
|
5919
5965
|
from: path,
|
|
5920
|
-
path: join(pathSeparator, root, name),
|
|
5966
|
+
path: join$1(pathSeparator, root, name),
|
|
5921
5967
|
type: Copy$1
|
|
5922
5968
|
});
|
|
5923
5969
|
}
|
|
@@ -5985,6 +6031,121 @@ const handleDrop$1 = async (state, fileHandles, files, paths) => {
|
|
|
5985
6031
|
};
|
|
5986
6032
|
};
|
|
5987
6033
|
|
|
6034
|
+
const directoryTypes$1 = [Directory, DirectoryExpanded, DirectoryExpanding];
|
|
6035
|
+
const isDirectory = item => {
|
|
6036
|
+
return directoryTypes$1.includes(item.type);
|
|
6037
|
+
};
|
|
6038
|
+
const isDescendant = (path, parentPath, pathSeparator) => {
|
|
6039
|
+
const prefix = parentPath.endsWith(pathSeparator) ? parentPath : `${parentPath}${pathSeparator}`;
|
|
6040
|
+
return path.startsWith(prefix);
|
|
6041
|
+
};
|
|
6042
|
+
const join = (parentPath, name, pathSeparator) => {
|
|
6043
|
+
if (parentPath.endsWith(pathSeparator)) {
|
|
6044
|
+
return `${parentPath}${name}`;
|
|
6045
|
+
}
|
|
6046
|
+
return `${parentPath}${pathSeparator}${name}`;
|
|
6047
|
+
};
|
|
6048
|
+
const getTargetFolder = (state, index) => {
|
|
6049
|
+
const {
|
|
6050
|
+
items,
|
|
6051
|
+
pathSeparator,
|
|
6052
|
+
root
|
|
6053
|
+
} = state;
|
|
6054
|
+
if (index === -1) {
|
|
6055
|
+
return root;
|
|
6056
|
+
}
|
|
6057
|
+
const item = items[index];
|
|
6058
|
+
if (!item) {
|
|
6059
|
+
throw new Error('Drop target does not exist');
|
|
6060
|
+
}
|
|
6061
|
+
if (isDirectory(item)) {
|
|
6062
|
+
return item.path;
|
|
6063
|
+
}
|
|
6064
|
+
if (item.type === File) {
|
|
6065
|
+
return dirname(pathSeparator, item.path);
|
|
6066
|
+
}
|
|
6067
|
+
throw new Error('Drop target is not a file or folder');
|
|
6068
|
+
};
|
|
6069
|
+
const getTopLevelSourcePaths = (sourcePaths, pathSeparator) => {
|
|
6070
|
+
const uniquePaths = [...new Set(sourcePaths)];
|
|
6071
|
+
return uniquePaths.filter(path => uniquePaths.every(otherPath => otherPath === path || !isDescendant(path, otherPath, pathSeparator)));
|
|
6072
|
+
};
|
|
6073
|
+
const getMoveOperations = (state, sourcePaths, targetFolder) => {
|
|
6074
|
+
const {
|
|
6075
|
+
items,
|
|
6076
|
+
pathSeparator
|
|
6077
|
+
} = state;
|
|
6078
|
+
const itemByPath = new Map(items.map(item => [item.path, item]));
|
|
6079
|
+
const existingPaths = new Set(itemByPath.keys());
|
|
6080
|
+
const destinationPaths = new Set();
|
|
6081
|
+
const operations = [];
|
|
6082
|
+
for (const sourcePath of getTopLevelSourcePaths(sourcePaths, pathSeparator)) {
|
|
6083
|
+
const sourceItem = itemByPath.get(sourcePath);
|
|
6084
|
+
if (!sourceItem) {
|
|
6085
|
+
throw new Error(`Dragged item no longer exists: ${sourcePath}`);
|
|
6086
|
+
}
|
|
6087
|
+
if (sourcePath === targetFolder) {
|
|
6088
|
+
continue;
|
|
6089
|
+
}
|
|
6090
|
+
if (isDirectory(sourceItem) && isDescendant(targetFolder, sourcePath, pathSeparator)) {
|
|
6091
|
+
throw new Error(cannotMoveFolderIntoSubfolderOfItself(sourceItem.name));
|
|
6092
|
+
}
|
|
6093
|
+
const destinationPath = join(targetFolder, sourceItem.name, pathSeparator);
|
|
6094
|
+
if (destinationPath === sourcePath) {
|
|
6095
|
+
continue;
|
|
6096
|
+
}
|
|
6097
|
+
if (destinationPaths.has(destinationPath) || existingPaths.has(destinationPath)) {
|
|
6098
|
+
throw new Error(fileOrFolderAlreadyExists(sourceItem.name));
|
|
6099
|
+
}
|
|
6100
|
+
destinationPaths.add(destinationPath);
|
|
6101
|
+
operations.push({
|
|
6102
|
+
from: sourcePath,
|
|
6103
|
+
path: destinationPath
|
|
6104
|
+
});
|
|
6105
|
+
}
|
|
6106
|
+
return operations;
|
|
6107
|
+
};
|
|
6108
|
+
const expandTargetFolder = (items, targetFolder) => {
|
|
6109
|
+
return items.map(item => {
|
|
6110
|
+
if (item.path === targetFolder && item.type === Directory) {
|
|
6111
|
+
return {
|
|
6112
|
+
...item,
|
|
6113
|
+
type: DirectoryExpanded
|
|
6114
|
+
};
|
|
6115
|
+
}
|
|
6116
|
+
return item;
|
|
6117
|
+
});
|
|
6118
|
+
};
|
|
6119
|
+
const handleInternalDrop = async (state, sourcePaths, index) => {
|
|
6120
|
+
const {
|
|
6121
|
+
isReadonly,
|
|
6122
|
+
items
|
|
6123
|
+
} = state;
|
|
6124
|
+
if (isReadonly) {
|
|
6125
|
+
return state;
|
|
6126
|
+
}
|
|
6127
|
+
const targetFolder = getTargetFolder(state, index);
|
|
6128
|
+
const operations = getMoveOperations(state, sourcePaths, targetFolder);
|
|
6129
|
+
if (operations.length === 0) {
|
|
6130
|
+
return {
|
|
6131
|
+
...state,
|
|
6132
|
+
dropTargets: []
|
|
6133
|
+
};
|
|
6134
|
+
}
|
|
6135
|
+
for (const operation of operations) {
|
|
6136
|
+
await rename$1(operation.from, operation.path);
|
|
6137
|
+
}
|
|
6138
|
+
const expandedItems = expandTargetFolder(items, targetFolder);
|
|
6139
|
+
const updated = await refresh({
|
|
6140
|
+
...state,
|
|
6141
|
+
items: expandedItems
|
|
6142
|
+
});
|
|
6143
|
+
return {
|
|
6144
|
+
...updated,
|
|
6145
|
+
dropTargets: []
|
|
6146
|
+
};
|
|
6147
|
+
};
|
|
6148
|
+
|
|
5988
6149
|
const Electron = 2;
|
|
5989
6150
|
|
|
5990
6151
|
const getModule = isElectron => {
|
|
@@ -5997,6 +6158,9 @@ const handleDropRoot = async (state, fileHandles, files, paths) => {
|
|
|
5997
6158
|
if (state.isReadonly && state.root !== '') {
|
|
5998
6159
|
return state;
|
|
5999
6160
|
}
|
|
6161
|
+
if (fileHandles.length === 0 && paths.length > 0) {
|
|
6162
|
+
return handleInternalDrop(state, paths, -1);
|
|
6163
|
+
}
|
|
6000
6164
|
const isElectron = state.platform === Electron;
|
|
6001
6165
|
const fn = getModule(isElectron);
|
|
6002
6166
|
return fn(state, fileHandles, files, paths);
|
|
@@ -6050,6 +6214,9 @@ const handleDropIndex = async (state, fileHandles, files, paths, index) => {
|
|
|
6050
6214
|
if (state.isReadonly) {
|
|
6051
6215
|
return state;
|
|
6052
6216
|
}
|
|
6217
|
+
if (fileHandles.length === 0 && paths.length > 0) {
|
|
6218
|
+
return handleInternalDrop(state, paths, index);
|
|
6219
|
+
}
|
|
6053
6220
|
const {
|
|
6054
6221
|
items
|
|
6055
6222
|
} = state;
|
|
@@ -6077,50 +6244,53 @@ const getDropHandler = index => {
|
|
|
6077
6244
|
}
|
|
6078
6245
|
};
|
|
6079
6246
|
|
|
6080
|
-
const
|
|
6081
|
-
|
|
6082
|
-
const files =
|
|
6083
|
-
|
|
6247
|
+
const getDroppedItems = async (itemIds, isElectron) => {
|
|
6248
|
+
const result = await getDroppedItems$1(itemIds, isElectron);
|
|
6249
|
+
const files = isElectron ? result.files : result.files.filter(file => file.handle);
|
|
6250
|
+
const fileHandles = files.map(file => file.handle || {
|
|
6251
|
+
kind: file.kind,
|
|
6252
|
+
name: file.name
|
|
6253
|
+
});
|
|
6254
|
+
const paths = files.map(file => file.path);
|
|
6255
|
+
return {
|
|
6256
|
+
fileHandles,
|
|
6257
|
+
paths,
|
|
6258
|
+
uris: result.uris
|
|
6259
|
+
};
|
|
6084
6260
|
};
|
|
6085
6261
|
|
|
6086
|
-
const
|
|
6087
|
-
if (
|
|
6262
|
+
const getInternalDragPaths = (items, uris) => {
|
|
6263
|
+
if (uris.length === 0) {
|
|
6088
6264
|
return [];
|
|
6089
6265
|
}
|
|
6090
|
-
const
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
}
|
|
6097
|
-
|
|
6098
|
-
const getFilepath = async file => {
|
|
6099
|
-
return getFilePathElectron(file);
|
|
6100
|
-
};
|
|
6101
|
-
const getFilePaths = async (files, platform) => {
|
|
6102
|
-
if (platform !== Electron) {
|
|
6103
|
-
return files.map(file => '');
|
|
6266
|
+
const pathByUri = new Map(items.map(item => [ensureUri(item.path), item.path]));
|
|
6267
|
+
const paths = [];
|
|
6268
|
+
for (const uri of uris) {
|
|
6269
|
+
const path = pathByUri.get(uri);
|
|
6270
|
+
if (path === undefined) {
|
|
6271
|
+
return [];
|
|
6272
|
+
}
|
|
6273
|
+
paths.push(path);
|
|
6104
6274
|
}
|
|
6105
|
-
const promises = files.map(getFilepath);
|
|
6106
|
-
const paths = await Promise.all(promises);
|
|
6107
6275
|
return paths;
|
|
6108
6276
|
};
|
|
6109
6277
|
|
|
6110
|
-
const handleDrop = async (state, x, y, fileIds
|
|
6278
|
+
const handleDrop = async (state, x, y, fileIds) => {
|
|
6111
6279
|
if (state.isReadonly && state.root !== '') {
|
|
6112
6280
|
return state;
|
|
6113
6281
|
}
|
|
6114
6282
|
try {
|
|
6283
|
+
const isElectron = state.platform === Electron;
|
|
6115
6284
|
const {
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
const
|
|
6285
|
+
fileHandles,
|
|
6286
|
+
paths,
|
|
6287
|
+
uris
|
|
6288
|
+
} = await getDroppedItems(fileIds, isElectron);
|
|
6289
|
+
const internalPaths = getInternalDragPaths(state.items, uris);
|
|
6290
|
+
const droppedPaths = internalPaths.length > 0 ? internalPaths : paths;
|
|
6121
6291
|
const index = getIndexFromPosition(state, x, y);
|
|
6122
6292
|
const fn = getDropHandler(index);
|
|
6123
|
-
const result = await fn(state, fileHandles,
|
|
6293
|
+
const result = await fn(state, fileHandles, [], droppedPaths, index);
|
|
6124
6294
|
return result;
|
|
6125
6295
|
} catch (error) {
|
|
6126
6296
|
throw new VError(error, 'Failed to drop files');
|
|
@@ -6501,6 +6671,42 @@ const handlePaste = async state => {
|
|
|
6501
6671
|
return handlePasteCopy(state, nativeFiles);
|
|
6502
6672
|
};
|
|
6503
6673
|
|
|
6674
|
+
const handleNativePaste = async (state, itemIds) => {
|
|
6675
|
+
const {
|
|
6676
|
+
focusedIndex,
|
|
6677
|
+
isReadonly,
|
|
6678
|
+
platform
|
|
6679
|
+
} = state;
|
|
6680
|
+
if (isReadonly) {
|
|
6681
|
+
return state;
|
|
6682
|
+
}
|
|
6683
|
+
if (itemIds.length === 0) {
|
|
6684
|
+
return handlePaste(state);
|
|
6685
|
+
}
|
|
6686
|
+
try {
|
|
6687
|
+
const isElectron = platform === Electron;
|
|
6688
|
+
const {
|
|
6689
|
+
fileHandles,
|
|
6690
|
+
paths
|
|
6691
|
+
} = await getDroppedItems(itemIds, isElectron);
|
|
6692
|
+
if (isElectron) {
|
|
6693
|
+
const nativePaths = paths.filter(Boolean);
|
|
6694
|
+
if (nativePaths.length === 0) {
|
|
6695
|
+
return handlePaste(state);
|
|
6696
|
+
}
|
|
6697
|
+
return handlePasteCopy(state, {
|
|
6698
|
+
files: nativePaths,
|
|
6699
|
+
source: 'gnomeCopiedFiles',
|
|
6700
|
+
type: 'copy'
|
|
6701
|
+
});
|
|
6702
|
+
}
|
|
6703
|
+
const handleDrop = getDropHandler(focusedIndex);
|
|
6704
|
+
return handleDrop(state, fileHandles, [], paths, focusedIndex);
|
|
6705
|
+
} catch (error) {
|
|
6706
|
+
throw new VError(error, 'Failed to paste native files');
|
|
6707
|
+
}
|
|
6708
|
+
};
|
|
6709
|
+
|
|
6504
6710
|
const handlePointerDown = (state, button, x, y) => {
|
|
6505
6711
|
const index = getIndexFromPosition(state, x, y);
|
|
6506
6712
|
if (button === LeftClick && index === -1) {
|
|
@@ -7004,14 +7210,8 @@ const getDragLabel = urls => {
|
|
|
7004
7210
|
return String(urls.length);
|
|
7005
7211
|
};
|
|
7006
7212
|
|
|
7007
|
-
const toUri = path => {
|
|
7008
|
-
if (path.startsWith('file://')) {
|
|
7009
|
-
return path;
|
|
7010
|
-
}
|
|
7011
|
-
return 'file://' + path;
|
|
7012
|
-
};
|
|
7013
7213
|
const getDragData = urls => {
|
|
7014
|
-
const data = urls.map(
|
|
7214
|
+
const data = urls.map(ensureUri).join('\n');
|
|
7015
7215
|
const dragData = [{
|
|
7016
7216
|
data,
|
|
7017
7217
|
type: 'text/uri-list'
|
|
@@ -7118,6 +7318,7 @@ const HandleInputClick = 9;
|
|
|
7118
7318
|
const HandleKeyDown = 21;
|
|
7119
7319
|
const HandleListBlur = 11;
|
|
7120
7320
|
const HandleListFocus = 12;
|
|
7321
|
+
const HandleNativePaste = 26;
|
|
7121
7322
|
const HandlePointerDown = 14;
|
|
7122
7323
|
const HandlePointerUp = 25;
|
|
7123
7324
|
const HandleScrollBarMove = 22;
|
|
@@ -7313,6 +7514,7 @@ const getListItemsVirtualDom = (visibleItems, focusedIndex, focused, dropTargets
|
|
|
7313
7514
|
onDragStart: HandleDragStart,
|
|
7314
7515
|
onDrop: HandleDrop,
|
|
7315
7516
|
onFocus: HandleListFocus,
|
|
7517
|
+
onPaste: HandleNativePaste,
|
|
7316
7518
|
onPointerDown: HandlePointerDown,
|
|
7317
7519
|
onPointerUp: HandlePointerUp,
|
|
7318
7520
|
onWheel: HandleWheel,
|
|
@@ -7679,7 +7881,11 @@ const renderEventListeners = () => {
|
|
|
7679
7881
|
preventDefault: true
|
|
7680
7882
|
}, {
|
|
7681
7883
|
name: HandleDrop,
|
|
7682
|
-
params: ['handleDrop', ClientX, ClientY, DataTransferFiles2
|
|
7884
|
+
params: ['handleDrop', ClientX, ClientY, DataTransferFiles2],
|
|
7885
|
+
preventDefault: true
|
|
7886
|
+
}, {
|
|
7887
|
+
name: HandleNativePaste,
|
|
7888
|
+
params: ['handleNativePaste', 'event.clipboardData.files2'],
|
|
7683
7889
|
preventDefault: true
|
|
7684
7890
|
}, {
|
|
7685
7891
|
name: HandleDragLeave,
|
|
@@ -8055,6 +8261,7 @@ const commandMap = {
|
|
|
8055
8261
|
'Explorer.handleInputClick': wrapListItemCommand(handleInputClick),
|
|
8056
8262
|
'Explorer.handleInputKeyDown': wrapListItemCommand(handleInputKeyDown),
|
|
8057
8263
|
'Explorer.handleKeyDown': wrapListItemCommand(handleKeyDown),
|
|
8264
|
+
'Explorer.handleNativePaste': wrapListItemCommand(handleNativePaste),
|
|
8058
8265
|
'Explorer.handlePaste': wrapListItemCommand(handlePaste),
|
|
8059
8266
|
'Explorer.handlePointerDown': wrapListItemCommand(handlePointerDown),
|
|
8060
8267
|
'Explorer.handlePointerUp': wrapListItemCommand(handlePointerUp),
|
|
@@ -8095,13 +8302,27 @@ const commandMap = {
|
|
|
8095
8302
|
'Explorer.updateIcons': wrapListItemCommand(updateIcons)
|
|
8096
8303
|
};
|
|
8097
8304
|
|
|
8305
|
+
const send$2 = async port => {
|
|
8306
|
+
await sendMessagePortToDragAndDropWorker(port);
|
|
8307
|
+
};
|
|
8308
|
+
const createDragAndDropWorkerRpc = async () => {
|
|
8309
|
+
return create$4({
|
|
8310
|
+
commandMap: {},
|
|
8311
|
+
send: send$2
|
|
8312
|
+
});
|
|
8313
|
+
};
|
|
8314
|
+
|
|
8315
|
+
const initializeDragAndDropWorker = async () => {
|
|
8316
|
+
set$7(await createDragAndDropWorkerRpc());
|
|
8317
|
+
};
|
|
8318
|
+
|
|
8098
8319
|
const sendMessagePortToFileSystemWorker = async port => {
|
|
8099
8320
|
await sendMessagePortToFileSystemWorker$1(port, 0);
|
|
8100
8321
|
};
|
|
8101
8322
|
|
|
8102
8323
|
const createFileSystemWorkerRpc = async () => {
|
|
8103
8324
|
try {
|
|
8104
|
-
const rpc = await create$
|
|
8325
|
+
const rpc = await create$4({
|
|
8105
8326
|
commandMap: {},
|
|
8106
8327
|
send: sendMessagePortToFileSystemWorker
|
|
8107
8328
|
});
|
|
@@ -8121,7 +8342,7 @@ const send$1 = port => {
|
|
|
8121
8342
|
};
|
|
8122
8343
|
const createIconThemeWorkerRpc = async () => {
|
|
8123
8344
|
try {
|
|
8124
|
-
const rpc = await create$
|
|
8345
|
+
const rpc = await create$4({
|
|
8125
8346
|
commandMap: {},
|
|
8126
8347
|
send: send$1
|
|
8127
8348
|
});
|
|
@@ -8137,7 +8358,7 @@ const initializeIconThemeWorker = async () => {
|
|
|
8137
8358
|
};
|
|
8138
8359
|
|
|
8139
8360
|
const initializeRendererWorker = async () => {
|
|
8140
|
-
const rpc = await create$
|
|
8361
|
+
const rpc = await create$3({
|
|
8141
8362
|
commandMap: commandMap
|
|
8142
8363
|
});
|
|
8143
8364
|
set$4(rpc);
|
|
@@ -8149,7 +8370,7 @@ const send = port => {
|
|
|
8149
8370
|
};
|
|
8150
8371
|
const createSourceControlWorkerRpc = async () => {
|
|
8151
8372
|
try {
|
|
8152
|
-
const rpc = await create$
|
|
8373
|
+
const rpc = await create$4({
|
|
8153
8374
|
commandMap: {},
|
|
8154
8375
|
send
|
|
8155
8376
|
});
|
|
@@ -8171,7 +8392,12 @@ const initializeSourceControlWorker = async () => {
|
|
|
8171
8392
|
|
|
8172
8393
|
const listen = async () => {
|
|
8173
8394
|
registerCommands(commandMap);
|
|
8174
|
-
await Promise.all([initializeRendererWorker(), initializeFileSystemWorker(), initializeIconThemeWorker(), initializeSourceControlWorker()]);
|
|
8395
|
+
await Promise.all([initializeRendererWorker(), initializeFileSystemWorker(), initializeIconThemeWorker(), initializeSourceControlWorker(), initializeDragAndDropWorker()]);
|
|
8396
|
+
const dialogRpc = await create$4({
|
|
8397
|
+
commandMap: {},
|
|
8398
|
+
send: sendMessagePortToDialogWorker
|
|
8399
|
+
});
|
|
8400
|
+
set$8(dialogRpc);
|
|
8175
8401
|
};
|
|
8176
8402
|
|
|
8177
8403
|
const main = async () => {
|