@lvce-editor/explorer-view 7.21.0 → 7.21.2
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 +512 -427
- 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,73 +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
|
-
class AssertionError extends Error {
|
|
310
|
-
constructor(message) {
|
|
311
|
-
super(message);
|
|
312
|
-
this.name = 'AssertionError';
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
const Object$1 = 1;
|
|
316
|
-
const Number$1 = 2;
|
|
317
|
-
const Array$1 = 3;
|
|
318
|
-
const String$1 = 4;
|
|
319
|
-
const Boolean$1 = 5;
|
|
320
|
-
const Function = 6;
|
|
321
|
-
const Null = 7;
|
|
322
|
-
const Unknown$1 = 8;
|
|
323
|
-
const getType = value => {
|
|
324
|
-
switch (typeof value) {
|
|
325
|
-
case 'number':
|
|
326
|
-
return Number$1;
|
|
327
|
-
case 'function':
|
|
328
|
-
return Function;
|
|
329
|
-
case 'string':
|
|
330
|
-
return String$1;
|
|
331
|
-
case 'object':
|
|
332
|
-
if (value === null) {
|
|
333
|
-
return Null;
|
|
334
|
-
}
|
|
335
|
-
if (Array.isArray(value)) {
|
|
336
|
-
return Array$1;
|
|
337
|
-
}
|
|
338
|
-
return Object$1;
|
|
339
|
-
case 'boolean':
|
|
340
|
-
return Boolean$1;
|
|
341
|
-
default:
|
|
342
|
-
return Unknown$1;
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
|
-
const object = value => {
|
|
346
|
-
const type = getType(value);
|
|
347
|
-
if (type !== Object$1) {
|
|
348
|
-
throw new AssertionError('expected value to be of type object');
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
const number = value => {
|
|
352
|
-
const type = getType(value);
|
|
353
|
-
if (type !== Number$1) {
|
|
354
|
-
throw new AssertionError('expected value to be of type number');
|
|
355
|
-
}
|
|
356
|
-
};
|
|
357
|
-
const array = value => {
|
|
358
|
-
const type = getType(value);
|
|
359
|
-
if (type !== Array$1) {
|
|
360
|
-
throw new AssertionError('expected value to be of type array');
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
const string = value => {
|
|
364
|
-
const type = getType(value);
|
|
365
|
-
if (type !== String$1) {
|
|
366
|
-
throw new AssertionError('expected value to be of type string');
|
|
367
|
-
}
|
|
368
|
-
};
|
|
369
|
-
|
|
370
57
|
const isMessagePort = value => {
|
|
371
58
|
return value && value instanceof MessagePort;
|
|
372
59
|
};
|
|
@@ -1058,7 +745,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
1058
745
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
1059
746
|
return create$1$1(id, errorProperty);
|
|
1060
747
|
};
|
|
1061
|
-
const create$
|
|
748
|
+
const create$a = (message, result) => {
|
|
1062
749
|
return {
|
|
1063
750
|
id: message.id,
|
|
1064
751
|
jsonrpc: Two$1,
|
|
@@ -1067,7 +754,7 @@ const create$9 = (message, result) => {
|
|
|
1067
754
|
};
|
|
1068
755
|
const getSuccessResponse = (message, result) => {
|
|
1069
756
|
const resultProperty = result ?? null;
|
|
1070
|
-
return create$
|
|
757
|
+
return create$a(message, resultProperty);
|
|
1071
758
|
};
|
|
1072
759
|
const getErrorResponseSimple = (id, error) => {
|
|
1073
760
|
return {
|
|
@@ -1161,7 +848,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
1161
848
|
|
|
1162
849
|
const Two = '2.0';
|
|
1163
850
|
|
|
1164
|
-
const create$
|
|
851
|
+
const create$9 = (method, params) => {
|
|
1165
852
|
return {
|
|
1166
853
|
jsonrpc: Two,
|
|
1167
854
|
method,
|
|
@@ -1169,7 +856,7 @@ const create$8 = (method, params) => {
|
|
|
1169
856
|
};
|
|
1170
857
|
};
|
|
1171
858
|
|
|
1172
|
-
const create$
|
|
859
|
+
const create$8 = (id, method, params) => {
|
|
1173
860
|
const message = {
|
|
1174
861
|
id,
|
|
1175
862
|
jsonrpc: Two,
|
|
@@ -1180,12 +867,12 @@ const create$7 = (id, method, params) => {
|
|
|
1180
867
|
};
|
|
1181
868
|
|
|
1182
869
|
let id = 0;
|
|
1183
|
-
const create$
|
|
870
|
+
const create$7 = () => {
|
|
1184
871
|
return ++id;
|
|
1185
872
|
};
|
|
1186
873
|
|
|
1187
874
|
const registerPromise = map => {
|
|
1188
|
-
const id = create$
|
|
875
|
+
const id = create$7();
|
|
1189
876
|
const {
|
|
1190
877
|
promise,
|
|
1191
878
|
resolve
|
|
@@ -1202,7 +889,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
1202
889
|
id,
|
|
1203
890
|
promise
|
|
1204
891
|
} = registerPromise(callbacks);
|
|
1205
|
-
const message = create$
|
|
892
|
+
const message = create$8(id, method, params);
|
|
1206
893
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
1207
894
|
ipc.sendAndTransfer(message);
|
|
1208
895
|
} else {
|
|
@@ -1238,7 +925,7 @@ const createRpc = ipc => {
|
|
|
1238
925
|
* @deprecated
|
|
1239
926
|
*/
|
|
1240
927
|
send(method, ...params) {
|
|
1241
|
-
const message = create$
|
|
928
|
+
const message = create$9(method, params);
|
|
1242
929
|
ipc.send(message);
|
|
1243
930
|
}
|
|
1244
931
|
};
|
|
@@ -1278,7 +965,35 @@ const listen$1 = async (module, options) => {
|
|
|
1278
965
|
return ipc;
|
|
1279
966
|
};
|
|
1280
967
|
|
|
1281
|
-
const
|
|
968
|
+
const createSharedLazyRpc = factory => {
|
|
969
|
+
let rpcPromise;
|
|
970
|
+
const getOrCreate = () => {
|
|
971
|
+
if (!rpcPromise) {
|
|
972
|
+
rpcPromise = factory();
|
|
973
|
+
}
|
|
974
|
+
return rpcPromise;
|
|
975
|
+
};
|
|
976
|
+
return {
|
|
977
|
+
async dispose() {
|
|
978
|
+
const rpc = await getOrCreate();
|
|
979
|
+
await rpc.dispose();
|
|
980
|
+
},
|
|
981
|
+
async invoke(method, ...params) {
|
|
982
|
+
const rpc = await getOrCreate();
|
|
983
|
+
return rpc.invoke(method, ...params);
|
|
984
|
+
},
|
|
985
|
+
async invokeAndTransfer(method, ...params) {
|
|
986
|
+
const rpc = await getOrCreate();
|
|
987
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
988
|
+
},
|
|
989
|
+
async send(method, ...params) {
|
|
990
|
+
const rpc = await getOrCreate();
|
|
991
|
+
rpc.send(method, ...params);
|
|
992
|
+
}
|
|
993
|
+
};
|
|
994
|
+
};
|
|
995
|
+
|
|
996
|
+
const create$6 = async ({
|
|
1282
997
|
commandMap,
|
|
1283
998
|
isMessagePortOpen = true,
|
|
1284
999
|
messagePort
|
|
@@ -1296,7 +1011,7 @@ const create$5 = async ({
|
|
|
1296
1011
|
return rpc;
|
|
1297
1012
|
};
|
|
1298
1013
|
|
|
1299
|
-
const create$
|
|
1014
|
+
const create$5 = async ({
|
|
1300
1015
|
commandMap,
|
|
1301
1016
|
isMessagePortOpen,
|
|
1302
1017
|
send
|
|
@@ -1306,48 +1021,20 @@ const create$4 = async ({
|
|
|
1306
1021
|
port2
|
|
1307
1022
|
} = new MessageChannel();
|
|
1308
1023
|
await send(port1);
|
|
1309
|
-
return create$
|
|
1024
|
+
return create$6({
|
|
1310
1025
|
commandMap,
|
|
1311
1026
|
isMessagePortOpen,
|
|
1312
1027
|
messagePort: port2
|
|
1313
1028
|
});
|
|
1314
1029
|
};
|
|
1315
1030
|
|
|
1316
|
-
const
|
|
1317
|
-
let rpcPromise;
|
|
1318
|
-
const getOrCreate = () => {
|
|
1319
|
-
if (!rpcPromise) {
|
|
1320
|
-
rpcPromise = factory();
|
|
1321
|
-
}
|
|
1322
|
-
return rpcPromise;
|
|
1323
|
-
};
|
|
1324
|
-
return {
|
|
1325
|
-
async dispose() {
|
|
1326
|
-
const rpc = await getOrCreate();
|
|
1327
|
-
await rpc.dispose();
|
|
1328
|
-
},
|
|
1329
|
-
async invoke(method, ...params) {
|
|
1330
|
-
const rpc = await getOrCreate();
|
|
1331
|
-
return rpc.invoke(method, ...params);
|
|
1332
|
-
},
|
|
1333
|
-
async invokeAndTransfer(method, ...params) {
|
|
1334
|
-
const rpc = await getOrCreate();
|
|
1335
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
1336
|
-
},
|
|
1337
|
-
async send(method, ...params) {
|
|
1338
|
-
const rpc = await getOrCreate();
|
|
1339
|
-
rpc.send(method, ...params);
|
|
1340
|
-
}
|
|
1341
|
-
};
|
|
1342
|
-
};
|
|
1343
|
-
|
|
1344
|
-
const create$3 = async ({
|
|
1031
|
+
const create$4 = async ({
|
|
1345
1032
|
commandMap,
|
|
1346
1033
|
isMessagePortOpen,
|
|
1347
1034
|
send
|
|
1348
1035
|
}) => {
|
|
1349
1036
|
return createSharedLazyRpc(() => {
|
|
1350
|
-
return create$
|
|
1037
|
+
return create$5({
|
|
1351
1038
|
commandMap,
|
|
1352
1039
|
isMessagePortOpen,
|
|
1353
1040
|
send
|
|
@@ -1355,7 +1042,7 @@ const create$3 = async ({
|
|
|
1355
1042
|
});
|
|
1356
1043
|
};
|
|
1357
1044
|
|
|
1358
|
-
const create$
|
|
1045
|
+
const create$3 = async ({
|
|
1359
1046
|
commandMap
|
|
1360
1047
|
}) => {
|
|
1361
1048
|
// TODO create a commandMap per rpc instance
|
|
@@ -1387,7 +1074,7 @@ const createMockRpc = ({
|
|
|
1387
1074
|
};
|
|
1388
1075
|
|
|
1389
1076
|
const rpcs = Object.create(null);
|
|
1390
|
-
const set$
|
|
1077
|
+
const set$9 = (id, rpc) => {
|
|
1391
1078
|
rpcs[id] = rpc;
|
|
1392
1079
|
};
|
|
1393
1080
|
const get$1 = id => {
|
|
@@ -1398,7 +1085,7 @@ const remove$1 = id => {
|
|
|
1398
1085
|
};
|
|
1399
1086
|
|
|
1400
1087
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1401
|
-
const create$
|
|
1088
|
+
const create$2 = rpcId => {
|
|
1402
1089
|
return {
|
|
1403
1090
|
async dispose() {
|
|
1404
1091
|
const rpc = get$1(rpcId);
|
|
@@ -1420,7 +1107,7 @@ const create$1 = rpcId => {
|
|
|
1420
1107
|
const mockRpc = createMockRpc({
|
|
1421
1108
|
commandMap
|
|
1422
1109
|
});
|
|
1423
|
-
set$
|
|
1110
|
+
set$9(rpcId, mockRpc);
|
|
1424
1111
|
// @ts-ignore
|
|
1425
1112
|
mockRpc[Symbol.dispose] = () => {
|
|
1426
1113
|
remove$1(rpcId);
|
|
@@ -1429,7 +1116,7 @@ const create$1 = rpcId => {
|
|
|
1429
1116
|
return mockRpc;
|
|
1430
1117
|
},
|
|
1431
1118
|
set(rpc) {
|
|
1432
|
-
set$
|
|
1119
|
+
set$9(rpcId, rpc);
|
|
1433
1120
|
}
|
|
1434
1121
|
};
|
|
1435
1122
|
};
|
|
@@ -1607,7 +1294,6 @@ const Button$3 = 'event.button';
|
|
|
1607
1294
|
const ClientX = 'event.clientX';
|
|
1608
1295
|
const ClientY = 'event.clientY';
|
|
1609
1296
|
const CtrlKey = 'event.ctrlKey';
|
|
1610
|
-
const DataTransferFiles = 'event.dataTransfer.files';
|
|
1611
1297
|
const DataTransferFiles2 = 'event.dataTransfer.files2';
|
|
1612
1298
|
const DefaultPrevented = 'event.defaultPrevented';
|
|
1613
1299
|
const DeltaMode = 'event.deltaMode';
|
|
@@ -1640,6 +1326,8 @@ const CtrlCmd = 1 << 11 >>> 0;
|
|
|
1640
1326
|
const Shift = 1 << 10 >>> 0;
|
|
1641
1327
|
const Alt = 1 << 9 >>> 0;
|
|
1642
1328
|
|
|
1329
|
+
const DialogWorker = 7014;
|
|
1330
|
+
const DragAndDropWorker = 3404;
|
|
1643
1331
|
const FileSystemWorker$1 = 209;
|
|
1644
1332
|
const IconThemeWorker = 7009;
|
|
1645
1333
|
const RendererWorker = 1;
|
|
@@ -1655,9 +1343,22 @@ const SetPatches = 'Viewlet.setPatches';
|
|
|
1655
1343
|
const FocusExplorer = 13;
|
|
1656
1344
|
const FocusExplorerEditBox = 14;
|
|
1657
1345
|
|
|
1346
|
+
const {
|
|
1347
|
+
invoke: invoke$5,
|
|
1348
|
+
set: set$8
|
|
1349
|
+
} = create$2(DialogWorker);
|
|
1350
|
+
|
|
1351
|
+
const {
|
|
1352
|
+
invoke: invoke$4,
|
|
1353
|
+
set: set$7
|
|
1354
|
+
} = create$2(DragAndDropWorker);
|
|
1355
|
+
const getDroppedItems$1 = async (itemIds, isElectron) => {
|
|
1356
|
+
return invoke$4('DragAndDrop.getDroppedItems', itemIds, isElectron);
|
|
1357
|
+
};
|
|
1358
|
+
|
|
1658
1359
|
const {
|
|
1659
1360
|
set: set$6
|
|
1660
|
-
} = create$
|
|
1361
|
+
} = create$2(FileSystemWorker$1);
|
|
1661
1362
|
|
|
1662
1363
|
const FileSystemWorker = {
|
|
1663
1364
|
__proto__: null,
|
|
@@ -1667,17 +1368,78 @@ const FileSystemWorker = {
|
|
|
1667
1368
|
const {
|
|
1668
1369
|
invoke: invoke$3,
|
|
1669
1370
|
set: set$5
|
|
1670
|
-
} = create$
|
|
1371
|
+
} = create$2(IconThemeWorker);
|
|
1671
1372
|
const getIcons = async iconRequests => {
|
|
1672
1373
|
// @ts-ignore
|
|
1673
1374
|
return invoke$3('IconTheme.getIcons', iconRequests);
|
|
1674
1375
|
};
|
|
1675
1376
|
|
|
1377
|
+
class AssertionError extends Error {
|
|
1378
|
+
constructor(message) {
|
|
1379
|
+
super(message);
|
|
1380
|
+
this.name = 'AssertionError';
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
const Object$1 = 1;
|
|
1384
|
+
const Number$1 = 2;
|
|
1385
|
+
const Array$1 = 3;
|
|
1386
|
+
const String$1 = 4;
|
|
1387
|
+
const Boolean$1 = 5;
|
|
1388
|
+
const Function = 6;
|
|
1389
|
+
const Null = 7;
|
|
1390
|
+
const Unknown$1 = 8;
|
|
1391
|
+
const getType = value => {
|
|
1392
|
+
switch (typeof value) {
|
|
1393
|
+
case 'number':
|
|
1394
|
+
return Number$1;
|
|
1395
|
+
case 'function':
|
|
1396
|
+
return Function;
|
|
1397
|
+
case 'string':
|
|
1398
|
+
return String$1;
|
|
1399
|
+
case 'object':
|
|
1400
|
+
if (value === null) {
|
|
1401
|
+
return Null;
|
|
1402
|
+
}
|
|
1403
|
+
if (Array.isArray(value)) {
|
|
1404
|
+
return Array$1;
|
|
1405
|
+
}
|
|
1406
|
+
return Object$1;
|
|
1407
|
+
case 'boolean':
|
|
1408
|
+
return Boolean$1;
|
|
1409
|
+
default:
|
|
1410
|
+
return Unknown$1;
|
|
1411
|
+
}
|
|
1412
|
+
};
|
|
1413
|
+
const object = value => {
|
|
1414
|
+
const type = getType(value);
|
|
1415
|
+
if (type !== Object$1) {
|
|
1416
|
+
throw new AssertionError('expected value to be of type object');
|
|
1417
|
+
}
|
|
1418
|
+
};
|
|
1419
|
+
const number = value => {
|
|
1420
|
+
const type = getType(value);
|
|
1421
|
+
if (type !== Number$1) {
|
|
1422
|
+
throw new AssertionError('expected value to be of type number');
|
|
1423
|
+
}
|
|
1424
|
+
};
|
|
1425
|
+
const array = value => {
|
|
1426
|
+
const type = getType(value);
|
|
1427
|
+
if (type !== Array$1) {
|
|
1428
|
+
throw new AssertionError('expected value to be of type array');
|
|
1429
|
+
}
|
|
1430
|
+
};
|
|
1431
|
+
const string = value => {
|
|
1432
|
+
const type = getType(value);
|
|
1433
|
+
if (type !== String$1) {
|
|
1434
|
+
throw new AssertionError('expected value to be of type string');
|
|
1435
|
+
}
|
|
1436
|
+
};
|
|
1437
|
+
|
|
1676
1438
|
const {
|
|
1677
1439
|
invoke: invoke$2,
|
|
1678
1440
|
invokeAndTransfer,
|
|
1679
1441
|
set: set$4
|
|
1680
|
-
} = create$
|
|
1442
|
+
} = create$2(RendererWorker);
|
|
1681
1443
|
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
1682
1444
|
number(uid);
|
|
1683
1445
|
number(menuId);
|
|
@@ -1685,9 +1447,13 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
|
1685
1447
|
number(y);
|
|
1686
1448
|
await invoke$2('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1687
1449
|
};
|
|
1688
|
-
const
|
|
1689
|
-
const
|
|
1690
|
-
|
|
1450
|
+
const sendMessagePortToDragAndDropWorker = async port => {
|
|
1451
|
+
const command = 'DragAndDrop.handleMessagePort';
|
|
1452
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDragAndDropWorker', port, command);
|
|
1453
|
+
};
|
|
1454
|
+
const sendMessagePortToDialogWorker = async port => {
|
|
1455
|
+
const command = 'HandleMessagePort.handleMessagePort';
|
|
1456
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
|
|
1691
1457
|
};
|
|
1692
1458
|
const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
|
|
1693
1459
|
const command = 'IconTheme.handleMessagePort';
|
|
@@ -1697,7 +1463,7 @@ const sendMessagePortToFileSystemWorker$1 = async (port, rpcId) => {
|
|
|
1697
1463
|
const command = 'FileSystem.handleMessagePort';
|
|
1698
1464
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
|
|
1699
1465
|
};
|
|
1700
|
-
const confirm = async (message, options) => {
|
|
1466
|
+
const confirm$1 = async (message, options) => {
|
|
1701
1467
|
const result = await invoke$2('ConfirmPrompt.prompt', message, options);
|
|
1702
1468
|
return result;
|
|
1703
1469
|
};
|
|
@@ -1708,14 +1474,270 @@ const sendMessagePortToSourceControlWorker = async port => {
|
|
|
1708
1474
|
const command = 'SourceControl.handleMessagePort';
|
|
1709
1475
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSourceControlWorker', port, command, 0);
|
|
1710
1476
|
};
|
|
1711
|
-
const openUri$1 = async (uri, focus, options) => {
|
|
1712
|
-
await invoke$2('Main.openUri',
|
|
1477
|
+
const openUri$1 = async (uri, focus, options) => {
|
|
1478
|
+
await invoke$2('Main.openUri', {
|
|
1479
|
+
...options,
|
|
1480
|
+
focus,
|
|
1481
|
+
uri
|
|
1482
|
+
});
|
|
1483
|
+
};
|
|
1484
|
+
|
|
1485
|
+
const {
|
|
1486
|
+
invoke: invoke$1,
|
|
1487
|
+
set: set$3
|
|
1488
|
+
} = create$2(SourceControlWorker);
|
|
1489
|
+
|
|
1490
|
+
const toCommandId = key => {
|
|
1491
|
+
const dotIndex = key.indexOf('.');
|
|
1492
|
+
return key.slice(dotIndex + 1);
|
|
1493
|
+
};
|
|
1494
|
+
const create$1 = () => {
|
|
1495
|
+
const commandQueues = new Map();
|
|
1496
|
+
const generations = Object.create(null);
|
|
1497
|
+
const states = Object.create(null);
|
|
1498
|
+
const commandMapRef = {};
|
|
1499
|
+
const getGeneration = uid => generations[uid] || 0;
|
|
1500
|
+
const isCurrentGeneration = (uid, generation) => {
|
|
1501
|
+
return states[uid] !== undefined && getGeneration(uid) === generation;
|
|
1502
|
+
};
|
|
1503
|
+
const updateState = (uid, generation, fallbackState, updater) => {
|
|
1504
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1505
|
+
return Promise.resolve(fallbackState);
|
|
1506
|
+
}
|
|
1507
|
+
const current = states[uid];
|
|
1508
|
+
const updatedState = updater(current.newState);
|
|
1509
|
+
if (updatedState !== current.newState) {
|
|
1510
|
+
states[uid] = {
|
|
1511
|
+
newState: updatedState,
|
|
1512
|
+
oldState: current.oldState,
|
|
1513
|
+
scheduledState: updatedState
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
return Promise.resolve(updatedState);
|
|
1517
|
+
};
|
|
1518
|
+
const createAsyncCommandContext = (uid, generation) => {
|
|
1519
|
+
let latestState = states[uid].newState;
|
|
1520
|
+
return {
|
|
1521
|
+
getState: () => {
|
|
1522
|
+
if (isCurrentGeneration(uid, generation)) {
|
|
1523
|
+
latestState = states[uid].newState;
|
|
1524
|
+
}
|
|
1525
|
+
return latestState;
|
|
1526
|
+
},
|
|
1527
|
+
updateState: async updater => {
|
|
1528
|
+
latestState = await updateState(uid, generation, latestState, updater);
|
|
1529
|
+
return latestState;
|
|
1530
|
+
}
|
|
1531
|
+
};
|
|
1532
|
+
};
|
|
1533
|
+
const enqueueCommand = async (uid, command) => {
|
|
1534
|
+
const previous = commandQueues.get(uid) || Promise.resolve();
|
|
1535
|
+
const run = async () => {
|
|
1536
|
+
try {
|
|
1537
|
+
await previous;
|
|
1538
|
+
} catch {
|
|
1539
|
+
// The previous caller receives its error; later commands must still run.
|
|
1540
|
+
}
|
|
1541
|
+
await command();
|
|
1542
|
+
};
|
|
1543
|
+
const current = run();
|
|
1544
|
+
commandQueues.set(uid, current);
|
|
1545
|
+
try {
|
|
1546
|
+
await current;
|
|
1547
|
+
} finally {
|
|
1548
|
+
if (commandQueues.get(uid) === current) {
|
|
1549
|
+
commandQueues.delete(uid);
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
};
|
|
1553
|
+
return {
|
|
1554
|
+
clear() {
|
|
1555
|
+
commandQueues.clear();
|
|
1556
|
+
for (const key of Object.keys(states)) {
|
|
1557
|
+
delete states[key];
|
|
1558
|
+
}
|
|
1559
|
+
},
|
|
1560
|
+
diff(uid, modules, numbers) {
|
|
1561
|
+
const {
|
|
1562
|
+
oldState,
|
|
1563
|
+
scheduledState
|
|
1564
|
+
} = states[uid];
|
|
1565
|
+
const diffResult = [];
|
|
1566
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1567
|
+
const fn = modules[i];
|
|
1568
|
+
if (!fn(oldState, scheduledState)) {
|
|
1569
|
+
diffResult.push(numbers[i]);
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
return diffResult;
|
|
1573
|
+
},
|
|
1574
|
+
dispose(uid) {
|
|
1575
|
+
commandQueues.delete(uid);
|
|
1576
|
+
delete states[uid];
|
|
1577
|
+
},
|
|
1578
|
+
get(uid) {
|
|
1579
|
+
return states[uid];
|
|
1580
|
+
},
|
|
1581
|
+
getCommandIds() {
|
|
1582
|
+
const keys = Object.keys(commandMapRef);
|
|
1583
|
+
const ids = keys.map(toCommandId);
|
|
1584
|
+
return ids;
|
|
1585
|
+
},
|
|
1586
|
+
getKeys() {
|
|
1587
|
+
return Object.keys(states).map(Number);
|
|
1588
|
+
},
|
|
1589
|
+
registerCommands(commandMap) {
|
|
1590
|
+
Object.assign(commandMapRef, commandMap);
|
|
1591
|
+
},
|
|
1592
|
+
set(uid, oldState, newState, scheduledState) {
|
|
1593
|
+
const current = states[uid];
|
|
1594
|
+
if (!current || oldState === newState && newState !== current.newState) {
|
|
1595
|
+
generations[uid] = getGeneration(uid) + 1;
|
|
1596
|
+
}
|
|
1597
|
+
states[uid] = {
|
|
1598
|
+
newState,
|
|
1599
|
+
oldState,
|
|
1600
|
+
scheduledState: scheduledState ?? newState
|
|
1601
|
+
};
|
|
1602
|
+
},
|
|
1603
|
+
wrapAsyncCommand(fn) {
|
|
1604
|
+
const wrapped = async (uid, ...args) => {
|
|
1605
|
+
const generation = getGeneration(uid);
|
|
1606
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
1607
|
+
await fn(context, ...args);
|
|
1608
|
+
};
|
|
1609
|
+
return wrapped;
|
|
1610
|
+
},
|
|
1611
|
+
wrapCommand(fn) {
|
|
1612
|
+
const wrapped = async (uid, ...args) => {
|
|
1613
|
+
const generation = getGeneration(uid);
|
|
1614
|
+
const {
|
|
1615
|
+
newState,
|
|
1616
|
+
oldState
|
|
1617
|
+
} = states[uid];
|
|
1618
|
+
const newerState = await fn(newState, ...args);
|
|
1619
|
+
if (oldState === newerState || newState === newerState) {
|
|
1620
|
+
return;
|
|
1621
|
+
}
|
|
1622
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1623
|
+
return;
|
|
1624
|
+
}
|
|
1625
|
+
const latestOld = states[uid];
|
|
1626
|
+
const latestNew = {
|
|
1627
|
+
...latestOld.newState,
|
|
1628
|
+
...newerState
|
|
1629
|
+
};
|
|
1630
|
+
states[uid] = {
|
|
1631
|
+
newState: latestNew,
|
|
1632
|
+
oldState: latestOld.oldState,
|
|
1633
|
+
scheduledState: latestNew
|
|
1634
|
+
};
|
|
1635
|
+
};
|
|
1636
|
+
return wrapped;
|
|
1637
|
+
},
|
|
1638
|
+
wrapGetter(fn) {
|
|
1639
|
+
const wrapped = (uid, ...args) => {
|
|
1640
|
+
const {
|
|
1641
|
+
newState
|
|
1642
|
+
} = states[uid];
|
|
1643
|
+
return fn(newState, ...args);
|
|
1644
|
+
};
|
|
1645
|
+
return wrapped;
|
|
1646
|
+
},
|
|
1647
|
+
wrapLoadContent(fn) {
|
|
1648
|
+
const wrapped = async (uid, ...args) => {
|
|
1649
|
+
const generation = getGeneration(uid);
|
|
1650
|
+
const {
|
|
1651
|
+
newState,
|
|
1652
|
+
oldState
|
|
1653
|
+
} = states[uid];
|
|
1654
|
+
const result = await fn(newState, ...args);
|
|
1655
|
+
const {
|
|
1656
|
+
error,
|
|
1657
|
+
state
|
|
1658
|
+
} = result;
|
|
1659
|
+
if (oldState === state || newState === state) {
|
|
1660
|
+
return {
|
|
1661
|
+
error
|
|
1662
|
+
};
|
|
1663
|
+
}
|
|
1664
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1665
|
+
return {
|
|
1666
|
+
error
|
|
1667
|
+
};
|
|
1668
|
+
}
|
|
1669
|
+
const latestOld = states[uid];
|
|
1670
|
+
const latestNew = {
|
|
1671
|
+
...latestOld.newState,
|
|
1672
|
+
...state
|
|
1673
|
+
};
|
|
1674
|
+
states[uid] = {
|
|
1675
|
+
newState: latestNew,
|
|
1676
|
+
oldState: latestOld.oldState,
|
|
1677
|
+
scheduledState: latestNew
|
|
1678
|
+
};
|
|
1679
|
+
return {
|
|
1680
|
+
error
|
|
1681
|
+
};
|
|
1682
|
+
};
|
|
1683
|
+
return wrapped;
|
|
1684
|
+
},
|
|
1685
|
+
wrapSerialAsyncCommand(fn) {
|
|
1686
|
+
const wrapped = async (uid, ...args) => {
|
|
1687
|
+
await enqueueCommand(uid, async () => {
|
|
1688
|
+
if (!states[uid]) {
|
|
1689
|
+
return;
|
|
1690
|
+
}
|
|
1691
|
+
const generation = getGeneration(uid);
|
|
1692
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
1693
|
+
await fn(context, ...args);
|
|
1694
|
+
});
|
|
1695
|
+
};
|
|
1696
|
+
return wrapped;
|
|
1697
|
+
},
|
|
1698
|
+
wrapSerialCommand(fn) {
|
|
1699
|
+
const wrapped = async (uid, ...args) => {
|
|
1700
|
+
await enqueueCommand(uid, async () => {
|
|
1701
|
+
if (!states[uid]) {
|
|
1702
|
+
return;
|
|
1703
|
+
}
|
|
1704
|
+
const generation = getGeneration(uid);
|
|
1705
|
+
const {
|
|
1706
|
+
newState,
|
|
1707
|
+
oldState
|
|
1708
|
+
} = states[uid];
|
|
1709
|
+
const newerState = await fn(newState, ...args);
|
|
1710
|
+
if (oldState === newerState || newState === newerState) {
|
|
1711
|
+
return;
|
|
1712
|
+
}
|
|
1713
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1714
|
+
return;
|
|
1715
|
+
}
|
|
1716
|
+
const latestOld = states[uid];
|
|
1717
|
+
const latestNew = {
|
|
1718
|
+
...latestOld.newState,
|
|
1719
|
+
...newerState
|
|
1720
|
+
};
|
|
1721
|
+
states[uid] = {
|
|
1722
|
+
newState: latestNew,
|
|
1723
|
+
oldState: latestOld.oldState,
|
|
1724
|
+
scheduledState: latestNew
|
|
1725
|
+
};
|
|
1726
|
+
});
|
|
1727
|
+
};
|
|
1728
|
+
return wrapped;
|
|
1729
|
+
}
|
|
1730
|
+
};
|
|
1731
|
+
};
|
|
1732
|
+
const terminate = () => {
|
|
1733
|
+
globalThis.close();
|
|
1713
1734
|
};
|
|
1714
1735
|
|
|
1715
|
-
const
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1736
|
+
const CreateFolder$1 = 1;
|
|
1737
|
+
const CreateFile$1 = 2;
|
|
1738
|
+
const Copy$1 = 3;
|
|
1739
|
+
const Rename$2 = 4;
|
|
1740
|
+
const Remove = 5;
|
|
1719
1741
|
|
|
1720
1742
|
// TODO use direct connection
|
|
1721
1743
|
const invoke = async (method, ...params) => {
|
|
@@ -1858,11 +1880,12 @@ const createTree = (items, root) => {
|
|
|
1858
1880
|
return tree;
|
|
1859
1881
|
};
|
|
1860
1882
|
|
|
1861
|
-
const None$
|
|
1883
|
+
const None$6 = 0;
|
|
1862
1884
|
const CreateFile = 1;
|
|
1863
1885
|
const CreateFolder = 2;
|
|
1864
1886
|
const Rename$1 = 3;
|
|
1865
1887
|
|
|
1888
|
+
const None$5 = 0;
|
|
1866
1889
|
const List = 1;
|
|
1867
1890
|
const Input$1 = 2;
|
|
1868
1891
|
|
|
@@ -2494,7 +2517,7 @@ const acceptCreate = async (state, newDirentType) => {
|
|
|
2494
2517
|
return {
|
|
2495
2518
|
...state,
|
|
2496
2519
|
editingIndex: -1,
|
|
2497
|
-
editingType: None$
|
|
2520
|
+
editingType: None$6,
|
|
2498
2521
|
focus: List,
|
|
2499
2522
|
focusedIndex: newFocusedIndex,
|
|
2500
2523
|
items: dirents
|
|
@@ -2544,7 +2567,7 @@ const cancelEditRename = (state, keepFocus) => {
|
|
|
2544
2567
|
editingIndex: -1,
|
|
2545
2568
|
editingSelectionEnd: 0,
|
|
2546
2569
|
editingSelectionStart: 0,
|
|
2547
|
-
editingType: None$
|
|
2570
|
+
editingType: None$6,
|
|
2548
2571
|
editingValue: '',
|
|
2549
2572
|
focus: List,
|
|
2550
2573
|
focused: keepFocus,
|
|
@@ -2663,7 +2686,7 @@ const acceptRename = async state => {
|
|
|
2663
2686
|
editingIndex: -1,
|
|
2664
2687
|
editingSelectionEnd: 0,
|
|
2665
2688
|
editingSelectionStart: 0,
|
|
2666
|
-
editingType: None$
|
|
2689
|
+
editingType: None$6,
|
|
2667
2690
|
editingValue: '',
|
|
2668
2691
|
focus: List,
|
|
2669
2692
|
focused: true,
|
|
@@ -2718,7 +2741,7 @@ const cancelEditCreate = async (state, keepFocus) => {
|
|
|
2718
2741
|
...state,
|
|
2719
2742
|
editingErrorMessage: '',
|
|
2720
2743
|
editingIndex: -1,
|
|
2721
|
-
editingType: None$
|
|
2744
|
+
editingType: None$6,
|
|
2722
2745
|
editingValue: '',
|
|
2723
2746
|
focus: List,
|
|
2724
2747
|
focused: keepFocus,
|
|
@@ -2863,6 +2886,30 @@ const copyRelativePath = async state => {
|
|
|
2863
2886
|
return state;
|
|
2864
2887
|
};
|
|
2865
2888
|
|
|
2889
|
+
const missingDialogWorkerRelay = 'Command "SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker" not found';
|
|
2890
|
+
const state = {
|
|
2891
|
+
isTest: false
|
|
2892
|
+
};
|
|
2893
|
+
const setIsTest = value => {
|
|
2894
|
+
state.isTest = value;
|
|
2895
|
+
};
|
|
2896
|
+
const confirm = async message => {
|
|
2897
|
+
const {
|
|
2898
|
+
isTest
|
|
2899
|
+
} = state;
|
|
2900
|
+
if (isTest) {
|
|
2901
|
+
return confirm$1(message);
|
|
2902
|
+
}
|
|
2903
|
+
try {
|
|
2904
|
+
return await invoke$5('ConfirmPrompt.prompt', message, undefined);
|
|
2905
|
+
} catch (error) {
|
|
2906
|
+
if (!String(error).includes(missingDialogWorkerRelay)) {
|
|
2907
|
+
throw error;
|
|
2908
|
+
}
|
|
2909
|
+
return confirm$1(message);
|
|
2910
|
+
}
|
|
2911
|
+
};
|
|
2912
|
+
|
|
2866
2913
|
const commandCompletions = new WeakMap();
|
|
2867
2914
|
const set$1 = (state, completion) => {
|
|
2868
2915
|
commandCompletions.set(state, completion);
|
|
@@ -3659,7 +3706,7 @@ const {
|
|
|
3659
3706
|
registerCommands,
|
|
3660
3707
|
set,
|
|
3661
3708
|
wrapGetter
|
|
3662
|
-
} = create$
|
|
3709
|
+
} = create$1();
|
|
3663
3710
|
const commandQueues = new Map();
|
|
3664
3711
|
const runQueuedCommand = async (previousCommand, command) => {
|
|
3665
3712
|
await previousCommand;
|
|
@@ -3787,7 +3834,8 @@ const ListItem = 22;
|
|
|
3787
3834
|
const Slash = '/';
|
|
3788
3835
|
|
|
3789
3836
|
// TODO parentUid might ot be needed
|
|
3790
|
-
const create = (id, uri, x, y, width, height, args, parentUid, platform = 0, assetDir = '') => {
|
|
3837
|
+
const create = (id, uri, x, y, width, height, args, parentUid, platform = 0, assetDir = '', isTest = false) => {
|
|
3838
|
+
setIsTest(isTest);
|
|
3791
3839
|
const state = {
|
|
3792
3840
|
assetDir,
|
|
3793
3841
|
chevronSpace: 22,
|
|
@@ -3805,7 +3853,7 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0, ass
|
|
|
3805
3853
|
editingSelectionEnd: 0,
|
|
3806
3854
|
editingSelectionStart: 0,
|
|
3807
3855
|
editingSessionId: 0,
|
|
3808
|
-
editingType: None$
|
|
3856
|
+
editingType: None$6,
|
|
3809
3857
|
editingValue: '',
|
|
3810
3858
|
errorCode: '',
|
|
3811
3859
|
errorMessage: '',
|
|
@@ -3873,7 +3921,7 @@ const isEqual$6 = (oldState, newState) => {
|
|
|
3873
3921
|
};
|
|
3874
3922
|
|
|
3875
3923
|
const isEqual$5 = (oldState, newState) => {
|
|
3876
|
-
return oldState.isPointerDown
|
|
3924
|
+
return oldState.isPointerDown === newState.isPointerDown && oldState.pointerDownIndex === newState.pointerDownIndex;
|
|
3877
3925
|
};
|
|
3878
3926
|
|
|
3879
3927
|
const isEqual$4 = (oldState, newState) => {
|
|
@@ -4661,6 +4709,7 @@ const handleBlur = async state => {
|
|
|
4661
4709
|
});
|
|
4662
4710
|
return {
|
|
4663
4711
|
...state,
|
|
4712
|
+
focus: None$5,
|
|
4664
4713
|
focused: false,
|
|
4665
4714
|
items: newItems
|
|
4666
4715
|
};
|
|
@@ -5035,7 +5084,7 @@ const resetEditing = {
|
|
|
5035
5084
|
end: 0,
|
|
5036
5085
|
start: 0
|
|
5037
5086
|
},
|
|
5038
|
-
editingType: None$
|
|
5087
|
+
editingType: None$6,
|
|
5039
5088
|
editingValue: ''
|
|
5040
5089
|
};
|
|
5041
5090
|
|
|
@@ -5338,7 +5387,9 @@ const handleDoubleClick = async (state, eventX, eventY) => {
|
|
|
5338
5387
|
const handleDragEnd = state => {
|
|
5339
5388
|
return {
|
|
5340
5389
|
...state,
|
|
5341
|
-
dropTargets: []
|
|
5390
|
+
dropTargets: [],
|
|
5391
|
+
isPointerDown: false,
|
|
5392
|
+
pointerDownIndex: -1
|
|
5342
5393
|
};
|
|
5343
5394
|
};
|
|
5344
5395
|
|
|
@@ -6071,50 +6122,33 @@ const getDropHandler = index => {
|
|
|
6071
6122
|
}
|
|
6072
6123
|
};
|
|
6073
6124
|
|
|
6074
|
-
const
|
|
6075
|
-
|
|
6076
|
-
const files =
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
};
|
|
6087
|
-
|
|
6088
|
-
const getFilePathElectron = async file => {
|
|
6089
|
-
return invoke$2('FileSystemHandle.getFilePathElectron', file);
|
|
6090
|
-
};
|
|
6091
|
-
|
|
6092
|
-
const getFilepath = async file => {
|
|
6093
|
-
return getFilePathElectron(file);
|
|
6094
|
-
};
|
|
6095
|
-
const getFilePaths = async (files, platform) => {
|
|
6096
|
-
if (platform !== Electron) {
|
|
6097
|
-
return files.map(file => '');
|
|
6098
|
-
}
|
|
6099
|
-
const promises = files.map(getFilepath);
|
|
6100
|
-
const paths = await Promise.all(promises);
|
|
6101
|
-
return paths;
|
|
6125
|
+
const getDroppedItems = async (itemIds, isElectron) => {
|
|
6126
|
+
const result = await getDroppedItems$1(itemIds, isElectron);
|
|
6127
|
+
const files = isElectron ? result.files : result.files.filter(file => file.handle);
|
|
6128
|
+
const fileHandles = files.map(file => file.handle || {
|
|
6129
|
+
kind: file.kind,
|
|
6130
|
+
name: file.name
|
|
6131
|
+
});
|
|
6132
|
+
const paths = files.map(file => file.path);
|
|
6133
|
+
return {
|
|
6134
|
+
fileHandles,
|
|
6135
|
+
paths
|
|
6136
|
+
};
|
|
6102
6137
|
};
|
|
6103
6138
|
|
|
6104
|
-
const handleDrop = async (state, x, y, fileIds
|
|
6139
|
+
const handleDrop = async (state, x, y, fileIds) => {
|
|
6105
6140
|
if (state.isReadonly && state.root !== '') {
|
|
6106
6141
|
return state;
|
|
6107
6142
|
}
|
|
6108
6143
|
try {
|
|
6144
|
+
const isElectron = state.platform === Electron;
|
|
6109
6145
|
const {
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
const fileHandles = await getFileHandles(fileIds);
|
|
6114
|
-
const paths = await getFilePaths(files, platform);
|
|
6146
|
+
fileHandles,
|
|
6147
|
+
paths
|
|
6148
|
+
} = await getDroppedItems(fileIds, isElectron);
|
|
6115
6149
|
const index = getIndexFromPosition(state, x, y);
|
|
6116
6150
|
const fn = getDropHandler(index);
|
|
6117
|
-
const result = await fn(state, fileHandles,
|
|
6151
|
+
const result = await fn(state, fileHandles, [], paths, index);
|
|
6118
6152
|
return result;
|
|
6119
6153
|
} catch (error) {
|
|
6120
6154
|
throw new VError(error, 'Failed to drop files');
|
|
@@ -6505,9 +6539,31 @@ const handlePointerDown = (state, button, x, y) => {
|
|
|
6505
6539
|
focusedIndex: -1
|
|
6506
6540
|
};
|
|
6507
6541
|
}
|
|
6542
|
+
if (button === LeftClick) {
|
|
6543
|
+
return {
|
|
6544
|
+
...state,
|
|
6545
|
+
isPointerDown: true,
|
|
6546
|
+
pointerDownIndex: index
|
|
6547
|
+
};
|
|
6548
|
+
}
|
|
6508
6549
|
return state;
|
|
6509
6550
|
};
|
|
6510
6551
|
|
|
6552
|
+
const handlePointerUp = state => {
|
|
6553
|
+
const {
|
|
6554
|
+
isPointerDown,
|
|
6555
|
+
pointerDownIndex
|
|
6556
|
+
} = state;
|
|
6557
|
+
if (!isPointerDown && pointerDownIndex === -1) {
|
|
6558
|
+
return state;
|
|
6559
|
+
}
|
|
6560
|
+
return {
|
|
6561
|
+
...state,
|
|
6562
|
+
isPointerDown: false,
|
|
6563
|
+
pointerDownIndex: -1
|
|
6564
|
+
};
|
|
6565
|
+
};
|
|
6566
|
+
|
|
6511
6567
|
const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
6512
6568
|
if (size >= contentSize) {
|
|
6513
6569
|
return 0;
|
|
@@ -6999,11 +7055,15 @@ const getDragData = urls => {
|
|
|
6999
7055
|
|
|
7000
7056
|
const renderDragData = (oldState, newState) => {
|
|
7001
7057
|
const {
|
|
7002
|
-
|
|
7058
|
+
isPointerDown,
|
|
7003
7059
|
items,
|
|
7060
|
+
pointerDownIndex,
|
|
7004
7061
|
uid
|
|
7005
7062
|
} = newState;
|
|
7006
|
-
|
|
7063
|
+
if (!isPointerDown) {
|
|
7064
|
+
return [];
|
|
7065
|
+
}
|
|
7066
|
+
const selected = items.filter((item, index) => item.selected || index === pointerDownIndex);
|
|
7007
7067
|
const urls = selected.map(item => item.path);
|
|
7008
7068
|
const dragData = getDragData(urls);
|
|
7009
7069
|
return ['Viewlet.setDragData', uid, dragData];
|
|
@@ -7087,6 +7147,7 @@ const HandleKeyDown = 21;
|
|
|
7087
7147
|
const HandleListBlur = 11;
|
|
7088
7148
|
const HandleListFocus = 12;
|
|
7089
7149
|
const HandlePointerDown = 14;
|
|
7150
|
+
const HandlePointerUp = 25;
|
|
7090
7151
|
const HandleScrollBarMove = 22;
|
|
7091
7152
|
const HandleScrollBarPointerCaptureLost = 23;
|
|
7092
7153
|
const HandleScrollBarPointerDown = 24;
|
|
@@ -7281,6 +7342,7 @@ const getListItemsVirtualDom = (visibleItems, focusedIndex, focused, dropTargets
|
|
|
7281
7342
|
onDrop: HandleDrop,
|
|
7282
7343
|
onFocus: HandleListFocus,
|
|
7283
7344
|
onPointerDown: HandlePointerDown,
|
|
7345
|
+
onPointerUp: HandlePointerUp,
|
|
7284
7346
|
onWheel: HandleWheel,
|
|
7285
7347
|
role: Tree,
|
|
7286
7348
|
tabIndex: Focusable,
|
|
@@ -7607,6 +7669,9 @@ const renderEventListeners = () => {
|
|
|
7607
7669
|
}, {
|
|
7608
7670
|
name: HandlePointerDown,
|
|
7609
7671
|
params: ['handlePointerDown', Button$3, ClientX, ClientY]
|
|
7672
|
+
}, {
|
|
7673
|
+
name: HandlePointerUp,
|
|
7674
|
+
params: ['handlePointerUp']
|
|
7610
7675
|
}, {
|
|
7611
7676
|
name: HandleScrollBarPointerDown,
|
|
7612
7677
|
params: ['handleScrollBarClick', ClientY],
|
|
@@ -7642,7 +7707,7 @@ const renderEventListeners = () => {
|
|
|
7642
7707
|
preventDefault: true
|
|
7643
7708
|
}, {
|
|
7644
7709
|
name: HandleDrop,
|
|
7645
|
-
params: ['handleDrop', ClientX, ClientY, DataTransferFiles2
|
|
7710
|
+
params: ['handleDrop', ClientX, ClientY, DataTransferFiles2],
|
|
7646
7711
|
preventDefault: true
|
|
7647
7712
|
}, {
|
|
7648
7713
|
name: HandleDragLeave,
|
|
@@ -8020,6 +8085,7 @@ const commandMap = {
|
|
|
8020
8085
|
'Explorer.handleKeyDown': wrapListItemCommand(handleKeyDown),
|
|
8021
8086
|
'Explorer.handlePaste': wrapListItemCommand(handlePaste),
|
|
8022
8087
|
'Explorer.handlePointerDown': wrapListItemCommand(handlePointerDown),
|
|
8088
|
+
'Explorer.handlePointerUp': wrapListItemCommand(handlePointerUp),
|
|
8023
8089
|
'Explorer.handleResize': wrapListItemCommand(handleResize),
|
|
8024
8090
|
'Explorer.handleScrollBarCaptureLost': wrapListItemCommand(handleScrollBarCaptureLost),
|
|
8025
8091
|
'Explorer.handleScrollBarClick': wrapListItemCommand(handleScrollBarClick),
|
|
@@ -8057,13 +8123,27 @@ const commandMap = {
|
|
|
8057
8123
|
'Explorer.updateIcons': wrapListItemCommand(updateIcons)
|
|
8058
8124
|
};
|
|
8059
8125
|
|
|
8126
|
+
const send$2 = async port => {
|
|
8127
|
+
await sendMessagePortToDragAndDropWorker(port);
|
|
8128
|
+
};
|
|
8129
|
+
const createDragAndDropWorkerRpc = async () => {
|
|
8130
|
+
return create$4({
|
|
8131
|
+
commandMap: {},
|
|
8132
|
+
send: send$2
|
|
8133
|
+
});
|
|
8134
|
+
};
|
|
8135
|
+
|
|
8136
|
+
const initializeDragAndDropWorker = async () => {
|
|
8137
|
+
set$7(await createDragAndDropWorkerRpc());
|
|
8138
|
+
};
|
|
8139
|
+
|
|
8060
8140
|
const sendMessagePortToFileSystemWorker = async port => {
|
|
8061
8141
|
await sendMessagePortToFileSystemWorker$1(port, 0);
|
|
8062
8142
|
};
|
|
8063
8143
|
|
|
8064
8144
|
const createFileSystemWorkerRpc = async () => {
|
|
8065
8145
|
try {
|
|
8066
|
-
const rpc = await create$
|
|
8146
|
+
const rpc = await create$4({
|
|
8067
8147
|
commandMap: {},
|
|
8068
8148
|
send: sendMessagePortToFileSystemWorker
|
|
8069
8149
|
});
|
|
@@ -8083,7 +8163,7 @@ const send$1 = port => {
|
|
|
8083
8163
|
};
|
|
8084
8164
|
const createIconThemeWorkerRpc = async () => {
|
|
8085
8165
|
try {
|
|
8086
|
-
const rpc = await create$
|
|
8166
|
+
const rpc = await create$4({
|
|
8087
8167
|
commandMap: {},
|
|
8088
8168
|
send: send$1
|
|
8089
8169
|
});
|
|
@@ -8099,7 +8179,7 @@ const initializeIconThemeWorker = async () => {
|
|
|
8099
8179
|
};
|
|
8100
8180
|
|
|
8101
8181
|
const initializeRendererWorker = async () => {
|
|
8102
|
-
const rpc = await create$
|
|
8182
|
+
const rpc = await create$3({
|
|
8103
8183
|
commandMap: commandMap
|
|
8104
8184
|
});
|
|
8105
8185
|
set$4(rpc);
|
|
@@ -8111,7 +8191,7 @@ const send = port => {
|
|
|
8111
8191
|
};
|
|
8112
8192
|
const createSourceControlWorkerRpc = async () => {
|
|
8113
8193
|
try {
|
|
8114
|
-
const rpc = await create$
|
|
8194
|
+
const rpc = await create$4({
|
|
8115
8195
|
commandMap: {},
|
|
8116
8196
|
send
|
|
8117
8197
|
});
|
|
@@ -8133,7 +8213,12 @@ const initializeSourceControlWorker = async () => {
|
|
|
8133
8213
|
|
|
8134
8214
|
const listen = async () => {
|
|
8135
8215
|
registerCommands(commandMap);
|
|
8136
|
-
await Promise.all([initializeRendererWorker(), initializeFileSystemWorker(), initializeIconThemeWorker(), initializeSourceControlWorker()]);
|
|
8216
|
+
await Promise.all([initializeRendererWorker(), initializeFileSystemWorker(), initializeIconThemeWorker(), initializeSourceControlWorker(), initializeDragAndDropWorker()]);
|
|
8217
|
+
const dialogRpc = await create$4({
|
|
8218
|
+
commandMap: {},
|
|
8219
|
+
send: sendMessagePortToDialogWorker
|
|
8220
|
+
});
|
|
8221
|
+
set$8(dialogRpc);
|
|
8137
8222
|
};
|
|
8138
8223
|
|
|
8139
8224
|
const main = async () => {
|