@lvce-editor/explorer-view 1.10.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/explorerViewWorkerMain.js +217 -163
- package/package.json +1 -1
|
@@ -107,27 +107,6 @@ const string = value => {
|
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
-
const walkValue = (value, transferrables, isTransferrable) => {
|
|
111
|
-
if (!value) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
if (isTransferrable(value)) {
|
|
115
|
-
transferrables.push(value);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (Array.isArray(value)) {
|
|
119
|
-
for (const item of value) {
|
|
120
|
-
walkValue(item, transferrables, isTransferrable);
|
|
121
|
-
}
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
if (typeof value === 'object') {
|
|
125
|
-
for (const property of Object.values(value)) {
|
|
126
|
-
walkValue(property, transferrables, isTransferrable);
|
|
127
|
-
}
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
110
|
const isMessagePort = value => {
|
|
132
111
|
return value && value instanceof MessagePort;
|
|
133
112
|
};
|
|
@@ -152,6 +131,27 @@ const isTransferrable = value => {
|
|
|
152
131
|
}
|
|
153
132
|
return false;
|
|
154
133
|
};
|
|
134
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
135
|
+
if (!value) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (isTransferrable(value)) {
|
|
139
|
+
transferrables.push(value);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (Array.isArray(value)) {
|
|
143
|
+
for (const item of value) {
|
|
144
|
+
walkValue(item, transferrables, isTransferrable);
|
|
145
|
+
}
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (typeof value === 'object') {
|
|
149
|
+
for (const property of Object.values(value)) {
|
|
150
|
+
walkValue(property, transferrables, isTransferrable);
|
|
151
|
+
}
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
155
|
const getTransferrables = value => {
|
|
156
156
|
const transferrables = [];
|
|
157
157
|
walkValue(value, transferrables, isTransferrable);
|
|
@@ -184,30 +184,35 @@ const NewLine$1 = '\n';
|
|
|
184
184
|
const joinLines$1 = lines => {
|
|
185
185
|
return lines.join(NewLine$1);
|
|
186
186
|
};
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
187
|
+
const RE_AT = /^\s+at/;
|
|
188
|
+
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
189
|
+
const isNormalStackLine = line => {
|
|
190
|
+
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
192
191
|
};
|
|
193
|
-
const
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
192
|
+
const getDetails = lines => {
|
|
193
|
+
const index = lines.findIndex(isNormalStackLine);
|
|
194
|
+
if (index === -1) {
|
|
195
|
+
return {
|
|
196
|
+
actualMessage: joinLines$1(lines),
|
|
197
|
+
rest: []
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
let lastIndex = index - 1;
|
|
201
|
+
while (++lastIndex < lines.length) {
|
|
202
|
+
if (!isNormalStackLine(lines[lastIndex])) {
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
197
206
|
return {
|
|
198
|
-
|
|
199
|
-
|
|
207
|
+
actualMessage: lines[index - 1],
|
|
208
|
+
rest: lines.slice(index, lastIndex)
|
|
200
209
|
};
|
|
201
210
|
};
|
|
202
|
-
const
|
|
203
|
-
|
|
211
|
+
const splitLines$1 = lines => {
|
|
212
|
+
return lines.split(NewLine$1);
|
|
213
|
+
};
|
|
204
214
|
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
205
215
|
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
206
|
-
const RE_AT = /^\s+at/;
|
|
207
|
-
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
208
|
-
const isUnhelpfulNativeModuleError = stderr => {
|
|
209
|
-
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
210
|
-
};
|
|
211
216
|
const isMessageCodeBlockStartIndex = line => {
|
|
212
217
|
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
213
218
|
};
|
|
@@ -222,51 +227,46 @@ const getMessageCodeBlock = stderr => {
|
|
|
222
227
|
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
223
228
|
return relevantMessage;
|
|
224
229
|
};
|
|
225
|
-
const
|
|
226
|
-
|
|
230
|
+
const isModuleNotFoundMessage = line => {
|
|
231
|
+
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
232
|
+
};
|
|
233
|
+
const getModuleNotFoundError = stderr => {
|
|
234
|
+
const lines = splitLines$1(stderr);
|
|
235
|
+
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
236
|
+
const message = lines[messageIndex];
|
|
227
237
|
return {
|
|
228
|
-
message
|
|
229
|
-
code:
|
|
238
|
+
message,
|
|
239
|
+
code: ERR_MODULE_NOT_FOUND
|
|
230
240
|
};
|
|
231
241
|
};
|
|
232
|
-
const
|
|
242
|
+
const isModuleNotFoundError = stderr => {
|
|
233
243
|
if (!stderr) {
|
|
234
244
|
return false;
|
|
235
245
|
}
|
|
236
|
-
return stderr.includes('
|
|
237
|
-
};
|
|
238
|
-
const getModuleSyntaxError = () => {
|
|
239
|
-
return {
|
|
240
|
-
message: `ES Modules are not supported in electron`,
|
|
241
|
-
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
|
|
242
|
-
};
|
|
246
|
+
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
243
247
|
};
|
|
244
|
-
const
|
|
248
|
+
const isModulesSyntaxError = stderr => {
|
|
245
249
|
if (!stderr) {
|
|
246
250
|
return false;
|
|
247
251
|
}
|
|
248
|
-
return stderr.includes('
|
|
252
|
+
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
249
253
|
};
|
|
250
|
-
const
|
|
251
|
-
|
|
254
|
+
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
255
|
+
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
256
|
+
const isUnhelpfulNativeModuleError = stderr => {
|
|
257
|
+
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
252
258
|
};
|
|
253
|
-
const
|
|
254
|
-
const
|
|
255
|
-
if (index === -1) {
|
|
256
|
-
return {
|
|
257
|
-
actualMessage: joinLines$1(lines),
|
|
258
|
-
rest: []
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
let lastIndex = index - 1;
|
|
262
|
-
while (++lastIndex < lines.length) {
|
|
263
|
-
if (!isNormalStackLine(lines[lastIndex])) {
|
|
264
|
-
break;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
259
|
+
const getNativeModuleErrorMessage = stderr => {
|
|
260
|
+
const message = getMessageCodeBlock(stderr);
|
|
267
261
|
return {
|
|
268
|
-
|
|
269
|
-
|
|
262
|
+
message: `Incompatible native node module: ${message}`,
|
|
263
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
const getModuleSyntaxError = () => {
|
|
267
|
+
return {
|
|
268
|
+
message: `ES Modules are not supported in electron`,
|
|
269
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
|
|
270
270
|
};
|
|
271
271
|
};
|
|
272
272
|
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
@@ -285,7 +285,7 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
285
285
|
rest
|
|
286
286
|
} = getDetails(lines);
|
|
287
287
|
return {
|
|
288
|
-
message:
|
|
288
|
+
message: actualMessage,
|
|
289
289
|
code: '',
|
|
290
290
|
stack: rest
|
|
291
291
|
};
|
|
@@ -320,14 +320,14 @@ const readyMessage = 'ready';
|
|
|
320
320
|
const getData$2 = event => {
|
|
321
321
|
return event.data;
|
|
322
322
|
};
|
|
323
|
-
const listen$
|
|
323
|
+
const listen$7 = () => {
|
|
324
324
|
// @ts-ignore
|
|
325
325
|
if (typeof WorkerGlobalScope === 'undefined') {
|
|
326
326
|
throw new TypeError('module is not in web worker scope');
|
|
327
327
|
}
|
|
328
328
|
return globalThis;
|
|
329
329
|
};
|
|
330
|
-
const signal$
|
|
330
|
+
const signal$8 = global => {
|
|
331
331
|
global.postMessage(readyMessage);
|
|
332
332
|
};
|
|
333
333
|
class IpcChildWithModuleWorker extends Ipc {
|
|
@@ -353,7 +353,7 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
353
353
|
this._rawIpc.addEventListener('message', callback);
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
|
-
const wrap$
|
|
356
|
+
const wrap$f = global => {
|
|
357
357
|
return new IpcChildWithModuleWorker(global);
|
|
358
358
|
};
|
|
359
359
|
const withResolvers = () => {
|
|
@@ -362,6 +362,7 @@ const withResolvers = () => {
|
|
|
362
362
|
_resolve = resolve;
|
|
363
363
|
});
|
|
364
364
|
return {
|
|
365
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
365
366
|
resolve: _resolve,
|
|
366
367
|
promise
|
|
367
368
|
};
|
|
@@ -378,10 +379,10 @@ const waitForFirstMessage = async port => {
|
|
|
378
379
|
// @ts-ignore
|
|
379
380
|
return event.data;
|
|
380
381
|
};
|
|
381
|
-
const listen$
|
|
382
|
-
const parentIpcRaw = listen$
|
|
383
|
-
signal$
|
|
384
|
-
const parentIpc = wrap$
|
|
382
|
+
const listen$6 = async () => {
|
|
383
|
+
const parentIpcRaw = listen$7();
|
|
384
|
+
signal$8(parentIpcRaw);
|
|
385
|
+
const parentIpc = wrap$f(parentIpcRaw);
|
|
385
386
|
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
386
387
|
if (firstMessage.method !== 'initialize') {
|
|
387
388
|
throw new IpcError('unexpected first message');
|
|
@@ -400,9 +401,6 @@ const listen$5 = async () => {
|
|
|
400
401
|
return globalThis;
|
|
401
402
|
};
|
|
402
403
|
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
403
|
-
constructor(port) {
|
|
404
|
-
super(port);
|
|
405
|
-
}
|
|
406
404
|
getData(event) {
|
|
407
405
|
return getData$2(event);
|
|
408
406
|
}
|
|
@@ -426,13 +424,13 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
|
426
424
|
this._rawIpc.start();
|
|
427
425
|
}
|
|
428
426
|
}
|
|
429
|
-
const wrap$
|
|
427
|
+
const wrap$e = port => {
|
|
430
428
|
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
431
429
|
};
|
|
432
430
|
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
433
431
|
__proto__: null,
|
|
434
|
-
listen: listen$
|
|
435
|
-
wrap: wrap$
|
|
432
|
+
listen: listen$6,
|
|
433
|
+
wrap: wrap$e
|
|
436
434
|
};
|
|
437
435
|
|
|
438
436
|
const Two = '2.0';
|
|
@@ -457,9 +455,6 @@ let id = 0;
|
|
|
457
455
|
const create$3 = () => {
|
|
458
456
|
return ++id;
|
|
459
457
|
};
|
|
460
|
-
const warn = (...args) => {
|
|
461
|
-
console.warn(...args);
|
|
462
|
-
};
|
|
463
458
|
const registerPromise = () => {
|
|
464
459
|
const id = create$3();
|
|
465
460
|
const {
|
|
@@ -472,16 +467,6 @@ const registerPromise = () => {
|
|
|
472
467
|
promise
|
|
473
468
|
};
|
|
474
469
|
};
|
|
475
|
-
const resolve = (id, response) => {
|
|
476
|
-
const fn = get(id);
|
|
477
|
-
if (!fn) {
|
|
478
|
-
console.log(response);
|
|
479
|
-
warn(`callback ${id} may already be disposed`);
|
|
480
|
-
return;
|
|
481
|
-
}
|
|
482
|
-
fn(response);
|
|
483
|
-
remove$1(id);
|
|
484
|
-
};
|
|
485
470
|
const create$2 = (method, params) => {
|
|
486
471
|
const {
|
|
487
472
|
id,
|
|
@@ -629,6 +614,19 @@ const unwrapJsonRpcResult = responseMessage => {
|
|
|
629
614
|
}
|
|
630
615
|
throw new JsonRpcError('unexpected response message');
|
|
631
616
|
};
|
|
617
|
+
const warn = (...args) => {
|
|
618
|
+
console.warn(...args);
|
|
619
|
+
};
|
|
620
|
+
const resolve = (id, response) => {
|
|
621
|
+
const fn = get(id);
|
|
622
|
+
if (!fn) {
|
|
623
|
+
console.log(response);
|
|
624
|
+
warn(`callback ${id} may already be disposed`);
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
fn(response);
|
|
628
|
+
remove$1(id);
|
|
629
|
+
};
|
|
632
630
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
633
631
|
const getErrorType = prettyError => {
|
|
634
632
|
if (prettyError && prettyError.type) {
|
|
@@ -798,6 +796,8 @@ const execute = (command, ...args) => {
|
|
|
798
796
|
|
|
799
797
|
const createRpc = ipc => {
|
|
800
798
|
const rpc = {
|
|
799
|
+
// @ts-ignore
|
|
800
|
+
ipc,
|
|
801
801
|
/**
|
|
802
802
|
* @deprecated
|
|
803
803
|
*/
|
|
@@ -824,7 +824,8 @@ const logError = () => {
|
|
|
824
824
|
};
|
|
825
825
|
const handleMessage = event => {
|
|
826
826
|
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
827
|
-
|
|
827
|
+
const actualExecute = event?.target?.execute || execute;
|
|
828
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
828
829
|
};
|
|
829
830
|
const handleIpc = ipc => {
|
|
830
831
|
if ('addEventListener' in ipc) {
|
|
@@ -2167,23 +2168,24 @@ const getMenuEntries = state => {
|
|
|
2167
2168
|
}
|
|
2168
2169
|
};
|
|
2169
2170
|
|
|
2170
|
-
const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue) => {
|
|
2171
|
+
const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, icons) => {
|
|
2171
2172
|
const visible = [];
|
|
2173
|
+
let iconIndex = 0;
|
|
2172
2174
|
for (let i = minLineY; i < Math.min(maxLineY, items.length); i++) {
|
|
2173
2175
|
const item = items[i];
|
|
2176
|
+
const icon = icons[iconIndex++];
|
|
2174
2177
|
if (i === editingIndex) {
|
|
2175
2178
|
visible.push({
|
|
2176
2179
|
...item,
|
|
2177
2180
|
isFocused: i === focusedIndex,
|
|
2178
2181
|
isEditing: true,
|
|
2179
|
-
icon
|
|
2180
|
-
name: editingValue
|
|
2181
|
-
})
|
|
2182
|
+
icon
|
|
2182
2183
|
});
|
|
2183
2184
|
} else {
|
|
2184
2185
|
visible.push({
|
|
2185
2186
|
...item,
|
|
2186
|
-
isFocused: i === focusedIndex
|
|
2187
|
+
isFocused: i === focusedIndex,
|
|
2188
|
+
icon
|
|
2187
2189
|
});
|
|
2188
2190
|
}
|
|
2189
2191
|
}
|
|
@@ -2677,6 +2679,65 @@ const handleCopy = async state => {
|
|
|
2677
2679
|
return state;
|
|
2678
2680
|
};
|
|
2679
2681
|
|
|
2682
|
+
const canBeDroppedInto = dirent => {
|
|
2683
|
+
if (!dirent) {
|
|
2684
|
+
return false;
|
|
2685
|
+
}
|
|
2686
|
+
switch (dirent.type) {
|
|
2687
|
+
case Directory:
|
|
2688
|
+
case DirectoryExpanded:
|
|
2689
|
+
case DirectoryExpanding:
|
|
2690
|
+
return true;
|
|
2691
|
+
default:
|
|
2692
|
+
return false;
|
|
2693
|
+
}
|
|
2694
|
+
};
|
|
2695
|
+
|
|
2696
|
+
const getNewDropTargets = (state, x, y) => {
|
|
2697
|
+
const {
|
|
2698
|
+
items
|
|
2699
|
+
} = state;
|
|
2700
|
+
const index = getIndexFromPosition(state, x, y);
|
|
2701
|
+
if (index === -1) {
|
|
2702
|
+
return [-1];
|
|
2703
|
+
}
|
|
2704
|
+
const item = items[index];
|
|
2705
|
+
if (!canBeDroppedInto(item)) {
|
|
2706
|
+
return [];
|
|
2707
|
+
}
|
|
2708
|
+
const newDropTargets = [index];
|
|
2709
|
+
return newDropTargets;
|
|
2710
|
+
};
|
|
2711
|
+
|
|
2712
|
+
const isEqual = (a, b) => {
|
|
2713
|
+
if (a.length !== b.length) {
|
|
2714
|
+
return false;
|
|
2715
|
+
}
|
|
2716
|
+
const length = a.length;
|
|
2717
|
+
for (let i = 0; i < length; i++) {
|
|
2718
|
+
if (a[i] !== b[i]) {
|
|
2719
|
+
return false;
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
return true;
|
|
2723
|
+
};
|
|
2724
|
+
|
|
2725
|
+
const handleDragOver = (state, x, y) => {
|
|
2726
|
+
number(x);
|
|
2727
|
+
number(y);
|
|
2728
|
+
const {
|
|
2729
|
+
dropTargets
|
|
2730
|
+
} = state;
|
|
2731
|
+
const newDropTargets = getNewDropTargets(state, x, y);
|
|
2732
|
+
if (isEqual(dropTargets, newDropTargets)) {
|
|
2733
|
+
return state;
|
|
2734
|
+
}
|
|
2735
|
+
return {
|
|
2736
|
+
...state,
|
|
2737
|
+
dropTargets: newDropTargets
|
|
2738
|
+
};
|
|
2739
|
+
};
|
|
2740
|
+
|
|
2680
2741
|
const getFilePathElectron = async file => {
|
|
2681
2742
|
return invoke('GetFilePathElectron.getFilePathElectron', file);
|
|
2682
2743
|
};
|
|
@@ -3293,65 +3354,6 @@ const removeDirent = async state => {
|
|
|
3293
3354
|
};
|
|
3294
3355
|
};
|
|
3295
3356
|
|
|
3296
|
-
const canBeDroppedInto = dirent => {
|
|
3297
|
-
if (!dirent) {
|
|
3298
|
-
return false;
|
|
3299
|
-
}
|
|
3300
|
-
switch (dirent.type) {
|
|
3301
|
-
case Directory:
|
|
3302
|
-
case DirectoryExpanded:
|
|
3303
|
-
case DirectoryExpanding:
|
|
3304
|
-
return true;
|
|
3305
|
-
default:
|
|
3306
|
-
return false;
|
|
3307
|
-
}
|
|
3308
|
-
};
|
|
3309
|
-
|
|
3310
|
-
const getNewDropTargets = (state, x, y) => {
|
|
3311
|
-
const {
|
|
3312
|
-
items
|
|
3313
|
-
} = state;
|
|
3314
|
-
const index = getIndexFromPosition(state, x, y);
|
|
3315
|
-
if (index === -1) {
|
|
3316
|
-
return [-1];
|
|
3317
|
-
}
|
|
3318
|
-
const item = items[index];
|
|
3319
|
-
if (!canBeDroppedInto(item)) {
|
|
3320
|
-
return [];
|
|
3321
|
-
}
|
|
3322
|
-
const newDropTargets = [index];
|
|
3323
|
-
return newDropTargets;
|
|
3324
|
-
};
|
|
3325
|
-
|
|
3326
|
-
const isEqual = (a, b) => {
|
|
3327
|
-
if (a.length !== b.length) {
|
|
3328
|
-
return false;
|
|
3329
|
-
}
|
|
3330
|
-
const length = a.length;
|
|
3331
|
-
for (let i = 0; i < length; i++) {
|
|
3332
|
-
if (a[i] !== b[i]) {
|
|
3333
|
-
return false;
|
|
3334
|
-
}
|
|
3335
|
-
}
|
|
3336
|
-
return true;
|
|
3337
|
-
};
|
|
3338
|
-
|
|
3339
|
-
const handleDragOver = (state, x, y) => {
|
|
3340
|
-
number(x);
|
|
3341
|
-
number(y);
|
|
3342
|
-
const {
|
|
3343
|
-
dropTargets
|
|
3344
|
-
} = state;
|
|
3345
|
-
const newDropTargets = getNewDropTargets(state, x, y);
|
|
3346
|
-
if (isEqual(dropTargets, newDropTargets)) {
|
|
3347
|
-
return state;
|
|
3348
|
-
}
|
|
3349
|
-
return {
|
|
3350
|
-
...state,
|
|
3351
|
-
dropTargets: newDropTargets
|
|
3352
|
-
};
|
|
3353
|
-
};
|
|
3354
|
-
|
|
3355
3357
|
const renameDirent = state => {
|
|
3356
3358
|
const {
|
|
3357
3359
|
focusedIndex,
|
|
@@ -3367,6 +3369,57 @@ const renameDirent = state => {
|
|
|
3367
3369
|
};
|
|
3368
3370
|
};
|
|
3369
3371
|
|
|
3372
|
+
const renderItems = {
|
|
3373
|
+
isEqual(oldState, newState) {
|
|
3374
|
+
return JSON.stringify(oldState.items) === JSON.stringify(newState.items) && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex && oldState.editingIndex === newState.editingIndex && oldState.editingType === newState.editingType && oldState.editingValue === newState.editingValue && oldState.width === newState.width;
|
|
3375
|
+
},
|
|
3376
|
+
apply(oldState, newState) {
|
|
3377
|
+
const visibleDirents = getVisibleExplorerItems(newState.items, newState.minLineY, newState.maxLineY, newState.focusedIndex, newState.editingIndex, newState.editingType, newState.editingValue, newState.icons);
|
|
3378
|
+
const isWide = newState.width > 450;
|
|
3379
|
+
const dom = getExplorerVirtualDom(visibleDirents, newState.focusedIndex, newState.root, isWide);
|
|
3380
|
+
return ['Viewlet.setDom2', dom];
|
|
3381
|
+
}
|
|
3382
|
+
};
|
|
3383
|
+
|
|
3384
|
+
// const renderFocusedIndex = {
|
|
3385
|
+
// isEqual(oldState:any, newState:any) {
|
|
3386
|
+
// return oldState.focusedIndex === newState.focusedIndex && oldState.focused === newState.focused && oldState.minLineY === newState.minLineY
|
|
3387
|
+
// },
|
|
3388
|
+
// apply(oldState:any, newState:any) {
|
|
3389
|
+
// const oldFocusedIndex = oldState.focusedIndex - oldState.minLineY
|
|
3390
|
+
// const newFocusedIndex = newState.focusedIndex - newState.minLineY
|
|
3391
|
+
// return [/* method */ 'setFocusedIndex', /* oldindex */ oldFocusedIndex, /* newIndex */ newFocusedIndex, /* focused */ newState.focused]
|
|
3392
|
+
// },
|
|
3393
|
+
// }
|
|
3394
|
+
|
|
3395
|
+
// const renderDropTargets = {
|
|
3396
|
+
// isEqual(oldState:any, newState:any) {
|
|
3397
|
+
// return oldState.dropTargets === newState.dropTargets
|
|
3398
|
+
// },
|
|
3399
|
+
// apply(oldState:any, newState:any) {
|
|
3400
|
+
// return [/* method */ 'setDropTargets', /* oldDropTargets */ oldState.dropTargets, /* newDropTargets */ newState.dropTargets]
|
|
3401
|
+
// },
|
|
3402
|
+
// }
|
|
3403
|
+
|
|
3404
|
+
const renderEditingIndex = {
|
|
3405
|
+
isEqual(oldState, newState) {
|
|
3406
|
+
return oldState.editingIndex === newState.editingIndex && oldState.editingType === newState.editingType;
|
|
3407
|
+
},
|
|
3408
|
+
apply(oldState, newState) {
|
|
3409
|
+
return ['focusInput', 'ExplorerInput'];
|
|
3410
|
+
}
|
|
3411
|
+
};
|
|
3412
|
+
const render = [renderItems, renderEditingIndex];
|
|
3413
|
+
const doRender = (oldState, newState) => {
|
|
3414
|
+
const commands = [];
|
|
3415
|
+
for (const fn of render) {
|
|
3416
|
+
if (!fn.isEqual(oldState, newState)) {
|
|
3417
|
+
commands.push(fn.apply(oldState, newState));
|
|
3418
|
+
}
|
|
3419
|
+
}
|
|
3420
|
+
return commands;
|
|
3421
|
+
};
|
|
3422
|
+
|
|
3370
3423
|
const getIconVirtualDom = (icon, type = Div) => {
|
|
3371
3424
|
return {
|
|
3372
3425
|
type,
|
|
@@ -3767,6 +3820,7 @@ const commandMap = {
|
|
|
3767
3820
|
'Explorer.openContainingFolder': openContainingFolder,
|
|
3768
3821
|
'Explorer.removeDirent': removeDirent,
|
|
3769
3822
|
'Explorer.renameDirent': renameDirent,
|
|
3823
|
+
'Explorer.render': doRender,
|
|
3770
3824
|
'Explorer.renderActions': renderActions,
|
|
3771
3825
|
'Explorer.restoreState': restoreState,
|
|
3772
3826
|
'Explorer.revealItem': revealItem,
|