@lvce-editor/explorer-view 3.3.0 → 3.5.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 +216 -24
- package/package.json +1 -1
|
@@ -429,9 +429,103 @@ const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
|
429
429
|
listen: listen$6,
|
|
430
430
|
wrap: wrap$e
|
|
431
431
|
};
|
|
432
|
+
const addListener = (emitter, type, callback) => {
|
|
433
|
+
if ('addEventListener' in emitter) {
|
|
434
|
+
emitter.addEventListener(type, callback);
|
|
435
|
+
} else {
|
|
436
|
+
emitter.on(type, callback);
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
const removeListener = (emitter, type, callback) => {
|
|
440
|
+
if ('removeEventListener' in emitter) {
|
|
441
|
+
emitter.removeEventListener(type, callback);
|
|
442
|
+
} else {
|
|
443
|
+
emitter.off(type, callback);
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
447
|
+
const {
|
|
448
|
+
resolve,
|
|
449
|
+
promise
|
|
450
|
+
} = Promise.withResolvers();
|
|
451
|
+
const listenerMap = Object.create(null);
|
|
452
|
+
const cleanup = value => {
|
|
453
|
+
for (const event of Object.keys(eventMap)) {
|
|
454
|
+
removeListener(eventEmitter, event, listenerMap[event]);
|
|
455
|
+
}
|
|
456
|
+
resolve(value);
|
|
457
|
+
};
|
|
458
|
+
for (const [event, type] of Object.entries(eventMap)) {
|
|
459
|
+
const listener = event => {
|
|
460
|
+
cleanup({
|
|
461
|
+
type,
|
|
462
|
+
event
|
|
463
|
+
});
|
|
464
|
+
};
|
|
465
|
+
addListener(eventEmitter, event, listener);
|
|
466
|
+
listenerMap[event] = listener;
|
|
467
|
+
}
|
|
468
|
+
return promise;
|
|
469
|
+
};
|
|
470
|
+
const Message$1 = 3;
|
|
471
|
+
const create$5$1 = async ({
|
|
472
|
+
messagePort,
|
|
473
|
+
isMessagePortOpen
|
|
474
|
+
}) => {
|
|
475
|
+
if (!isMessagePort(messagePort)) {
|
|
476
|
+
throw new IpcError('port must be of type MessagePort');
|
|
477
|
+
}
|
|
478
|
+
if (isMessagePortOpen) {
|
|
479
|
+
return messagePort;
|
|
480
|
+
}
|
|
481
|
+
const eventPromise = getFirstEvent(messagePort, {
|
|
482
|
+
message: Message$1
|
|
483
|
+
});
|
|
484
|
+
messagePort.start();
|
|
485
|
+
const {
|
|
486
|
+
type,
|
|
487
|
+
event
|
|
488
|
+
} = await eventPromise;
|
|
489
|
+
if (type !== Message$1) {
|
|
490
|
+
throw new IpcError('Failed to wait for ipc message');
|
|
491
|
+
}
|
|
492
|
+
if (event.data !== readyMessage) {
|
|
493
|
+
throw new IpcError('unexpected first message');
|
|
494
|
+
}
|
|
495
|
+
return messagePort;
|
|
496
|
+
};
|
|
497
|
+
const signal$1 = messagePort => {
|
|
498
|
+
messagePort.start();
|
|
499
|
+
};
|
|
500
|
+
class IpcParentWithMessagePort extends Ipc {
|
|
501
|
+
getData = getData$2;
|
|
502
|
+
send(message) {
|
|
503
|
+
this._rawIpc.postMessage(message);
|
|
504
|
+
}
|
|
505
|
+
sendAndTransfer(message) {
|
|
506
|
+
const transfer = getTransferrables(message);
|
|
507
|
+
this._rawIpc.postMessage(message, transfer);
|
|
508
|
+
}
|
|
509
|
+
dispose() {
|
|
510
|
+
this._rawIpc.close();
|
|
511
|
+
}
|
|
512
|
+
onMessage(callback) {
|
|
513
|
+
this._rawIpc.addEventListener('message', callback);
|
|
514
|
+
}
|
|
515
|
+
onClose(callback) {}
|
|
516
|
+
}
|
|
517
|
+
const wrap$5 = messagePort => {
|
|
518
|
+
return new IpcParentWithMessagePort(messagePort);
|
|
519
|
+
};
|
|
520
|
+
const IpcParentWithMessagePort$1 = {
|
|
521
|
+
__proto__: null,
|
|
522
|
+
create: create$5$1,
|
|
523
|
+
signal: signal$1,
|
|
524
|
+
wrap: wrap$5
|
|
525
|
+
};
|
|
432
526
|
|
|
433
527
|
const Two = '2.0';
|
|
434
|
-
const create$4 = (method, params) => {
|
|
528
|
+
const create$4$1 = (method, params) => {
|
|
435
529
|
return {
|
|
436
530
|
jsonrpc: Two,
|
|
437
531
|
method,
|
|
@@ -439,7 +533,7 @@ const create$4 = (method, params) => {
|
|
|
439
533
|
};
|
|
440
534
|
};
|
|
441
535
|
const callbacks = Object.create(null);
|
|
442
|
-
const set$
|
|
536
|
+
const set$4 = (id, fn) => {
|
|
443
537
|
callbacks[id] = fn;
|
|
444
538
|
};
|
|
445
539
|
const get$2 = id => {
|
|
@@ -458,7 +552,7 @@ const registerPromise = () => {
|
|
|
458
552
|
resolve,
|
|
459
553
|
promise
|
|
460
554
|
} = Promise.withResolvers();
|
|
461
|
-
set$
|
|
555
|
+
set$4(id, resolve);
|
|
462
556
|
return {
|
|
463
557
|
id,
|
|
464
558
|
promise
|
|
@@ -685,7 +779,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
685
779
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
686
780
|
return create$1$1(id, errorProperty);
|
|
687
781
|
};
|
|
688
|
-
const create$
|
|
782
|
+
const create$6 = (message, result) => {
|
|
689
783
|
return {
|
|
690
784
|
jsonrpc: Two,
|
|
691
785
|
id: message.id,
|
|
@@ -694,7 +788,7 @@ const create$5 = (message, result) => {
|
|
|
694
788
|
};
|
|
695
789
|
const getSuccessResponse = (message, result) => {
|
|
696
790
|
const resultProperty = result ?? null;
|
|
697
|
-
return create$
|
|
791
|
+
return create$6(message, resultProperty);
|
|
698
792
|
};
|
|
699
793
|
const getErrorResponseSimple = (id, error) => {
|
|
700
794
|
return {
|
|
@@ -799,7 +893,7 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
|
799
893
|
return unwrapJsonRpcResult(responseMessage);
|
|
800
894
|
};
|
|
801
895
|
const send = (transport, method, ...params) => {
|
|
802
|
-
const message = create$4(method, params);
|
|
896
|
+
const message = create$4$1(method, params);
|
|
803
897
|
transport.send(message);
|
|
804
898
|
};
|
|
805
899
|
const invoke$2 = (ipc, method, ...params) => {
|
|
@@ -876,7 +970,41 @@ const listen$1 = async (module, options) => {
|
|
|
876
970
|
const ipc = module.wrap(rawIpc);
|
|
877
971
|
return ipc;
|
|
878
972
|
};
|
|
973
|
+
const create$5 = async ({
|
|
974
|
+
commandMap,
|
|
975
|
+
messagePort
|
|
976
|
+
}) => {
|
|
977
|
+
// TODO create a commandMap per rpc instance
|
|
978
|
+
register(commandMap);
|
|
979
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
980
|
+
messagePort,
|
|
981
|
+
isMessagePortOpen: true
|
|
982
|
+
});
|
|
983
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
984
|
+
handleIpc(ipc);
|
|
985
|
+
const rpc = createRpc(ipc);
|
|
986
|
+
messagePort.start();
|
|
987
|
+
return rpc;
|
|
988
|
+
};
|
|
879
989
|
const create$3 = async ({
|
|
990
|
+
commandMap,
|
|
991
|
+
send
|
|
992
|
+
}) => {
|
|
993
|
+
const {
|
|
994
|
+
port1,
|
|
995
|
+
port2
|
|
996
|
+
} = new MessageChannel();
|
|
997
|
+
await send(port1);
|
|
998
|
+
return create$5({
|
|
999
|
+
commandMap,
|
|
1000
|
+
messagePort: port2
|
|
1001
|
+
});
|
|
1002
|
+
};
|
|
1003
|
+
const TransferMessagePortRpcParent = {
|
|
1004
|
+
__proto__: null,
|
|
1005
|
+
create: create$3
|
|
1006
|
+
};
|
|
1007
|
+
const create$4 = async ({
|
|
880
1008
|
commandMap
|
|
881
1009
|
}) => {
|
|
882
1010
|
// TODO create a commandMap per rpc instance
|
|
@@ -888,7 +1016,7 @@ const create$3 = async ({
|
|
|
888
1016
|
};
|
|
889
1017
|
const WebWorkerRpcClient = {
|
|
890
1018
|
__proto__: null,
|
|
891
|
-
create: create$
|
|
1019
|
+
create: create$4
|
|
892
1020
|
};
|
|
893
1021
|
|
|
894
1022
|
const CreateFolder$1 = 1;
|
|
@@ -931,12 +1059,24 @@ const create$2 = rpcId => {
|
|
|
931
1059
|
};
|
|
932
1060
|
};
|
|
933
1061
|
const RendererWorker$1 = 1;
|
|
1062
|
+
const FileSystemWorker$1 = 209;
|
|
1063
|
+
const {
|
|
1064
|
+
set: set$7} = create$2(FileSystemWorker$1);
|
|
1065
|
+
const FileSystemWorker = {
|
|
1066
|
+
__proto__: null,
|
|
1067
|
+
set: set$7};
|
|
934
1068
|
const {
|
|
935
1069
|
invoke: invoke$3,
|
|
1070
|
+
invokeAndTransfer: invokeAndTransfer$3,
|
|
936
1071
|
set: set$3} = create$2(RendererWorker$1);
|
|
937
1072
|
const showContextMenu$1 = async (x, y, id, ...args) => {
|
|
938
1073
|
return invoke$3('ContextMenu.show', x, y, id, ...args);
|
|
939
1074
|
};
|
|
1075
|
+
const sendMessagePortToFileSystemWorker$2 = async (port, rpcId) => {
|
|
1076
|
+
const command = 'FileSystem.handleMessagePort';
|
|
1077
|
+
// @ts-ignore
|
|
1078
|
+
await invokeAndTransfer$3('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
|
|
1079
|
+
};
|
|
940
1080
|
const confirm$1 = async (message, options) => {
|
|
941
1081
|
// @ts-ignore
|
|
942
1082
|
const result = await invoke$3('Confirmprompt.prompt', message, options);
|
|
@@ -949,6 +1089,7 @@ const RendererWorker = {
|
|
|
949
1089
|
__proto__: null,
|
|
950
1090
|
confirm: confirm$1,
|
|
951
1091
|
invoke: invoke$3,
|
|
1092
|
+
sendMessagePortToFileSystemWorker: sendMessagePortToFileSystemWorker$2,
|
|
952
1093
|
set: set$3,
|
|
953
1094
|
showContextMenu: showContextMenu$1,
|
|
954
1095
|
writeClipBoardText: writeClipBoardText$1
|
|
@@ -956,16 +1097,20 @@ const RendererWorker = {
|
|
|
956
1097
|
|
|
957
1098
|
const {
|
|
958
1099
|
invoke: invoke$1,
|
|
959
|
-
set: set$
|
|
1100
|
+
set: set$2,
|
|
960
1101
|
writeClipBoardText,
|
|
961
1102
|
confirm,
|
|
962
|
-
showContextMenu
|
|
1103
|
+
showContextMenu,
|
|
1104
|
+
sendMessagePortToFileSystemWorker: sendMessagePortToFileSystemWorker$1
|
|
963
1105
|
} = RendererWorker;
|
|
964
1106
|
|
|
965
1107
|
// TODO use direct connection
|
|
966
1108
|
const invoke = async (method, ...params) => {
|
|
967
1109
|
return invoke$1(method, ...params);
|
|
968
1110
|
};
|
|
1111
|
+
const {
|
|
1112
|
+
set: set$1
|
|
1113
|
+
} = FileSystemWorker;
|
|
969
1114
|
|
|
970
1115
|
const remove = async dirent => {
|
|
971
1116
|
return invoke('FileSystem.remove', dirent);
|
|
@@ -1917,8 +2062,13 @@ const copyRelativePath = async state => {
|
|
|
1917
2062
|
return state;
|
|
1918
2063
|
};
|
|
1919
2064
|
|
|
2065
|
+
const toCommandId = key => {
|
|
2066
|
+
const dotIndex = key.indexOf('.');
|
|
2067
|
+
return key.slice(dotIndex + 1);
|
|
2068
|
+
};
|
|
1920
2069
|
const create$1 = () => {
|
|
1921
2070
|
const states = Object.create(null);
|
|
2071
|
+
const commandMapRef = {};
|
|
1922
2072
|
return {
|
|
1923
2073
|
get(uid) {
|
|
1924
2074
|
return states[uid];
|
|
@@ -1959,6 +2109,15 @@ const create$1 = () => {
|
|
|
1959
2109
|
};
|
|
1960
2110
|
return wrapped;
|
|
1961
2111
|
},
|
|
2112
|
+
wrapGetter(fn) {
|
|
2113
|
+
const wrapped = (uid, ...args) => {
|
|
2114
|
+
const {
|
|
2115
|
+
newState
|
|
2116
|
+
} = states[uid];
|
|
2117
|
+
return fn(newState, ...args);
|
|
2118
|
+
};
|
|
2119
|
+
return wrapped;
|
|
2120
|
+
},
|
|
1962
2121
|
diff(uid, modules, numbers) {
|
|
1963
2122
|
const {
|
|
1964
2123
|
oldState,
|
|
@@ -1972,6 +2131,14 @@ const create$1 = () => {
|
|
|
1972
2131
|
}
|
|
1973
2132
|
}
|
|
1974
2133
|
return diffResult;
|
|
2134
|
+
},
|
|
2135
|
+
getCommandIds() {
|
|
2136
|
+
const keys = Object.keys(commandMapRef);
|
|
2137
|
+
const ids = keys.map(toCommandId);
|
|
2138
|
+
return ids;
|
|
2139
|
+
},
|
|
2140
|
+
registerCommands(commandMap) {
|
|
2141
|
+
Object.assign(commandMapRef, commandMap);
|
|
1975
2142
|
}
|
|
1976
2143
|
};
|
|
1977
2144
|
};
|
|
@@ -2468,6 +2635,14 @@ const KeyCode = {
|
|
|
2468
2635
|
Star,
|
|
2469
2636
|
UpArrow
|
|
2470
2637
|
};
|
|
2638
|
+
const CtrlCmd = 1 << 11 >>> 0;
|
|
2639
|
+
const Shift = 1 << 10 >>> 0;
|
|
2640
|
+
const Alt = 1 << 9 >>> 0;
|
|
2641
|
+
const KeyModifier = {
|
|
2642
|
+
__proto__: null,
|
|
2643
|
+
Alt,
|
|
2644
|
+
CtrlCmd,
|
|
2645
|
+
Shift};
|
|
2471
2646
|
const mergeClassNames = (...classNames) => {
|
|
2472
2647
|
return classNames.filter(Boolean).join(' ');
|
|
2473
2648
|
};
|
|
@@ -2486,20 +2661,16 @@ const text = data => {
|
|
|
2486
2661
|
};
|
|
2487
2662
|
};
|
|
2488
2663
|
|
|
2489
|
-
const CtrlCmd = 1 << 11 >>> 0;
|
|
2490
|
-
const Shift = 1 << 10 >>> 0;
|
|
2491
|
-
const Alt = 1 << 9 >>> 0;
|
|
2492
|
-
|
|
2493
2664
|
const FocusExplorer = 13;
|
|
2494
2665
|
const FocusExplorerEditBox = 14;
|
|
2495
2666
|
|
|
2496
2667
|
const getKeyBindings = () => {
|
|
2497
2668
|
return [{
|
|
2498
|
-
key: Shift | KeyCode.UpArrow,
|
|
2669
|
+
key: KeyModifier.Shift | KeyCode.UpArrow,
|
|
2499
2670
|
command: 'Explorer.selectUp',
|
|
2500
2671
|
when: FocusExplorer
|
|
2501
2672
|
}, {
|
|
2502
|
-
key: Shift | KeyCode.DownArrow,
|
|
2673
|
+
key: KeyModifier.Shift | KeyCode.DownArrow,
|
|
2503
2674
|
command: 'Explorer.selectDown',
|
|
2504
2675
|
when: FocusExplorer
|
|
2505
2676
|
}, {
|
|
@@ -2527,27 +2698,27 @@ const getKeyBindings = () => {
|
|
|
2527
2698
|
command: 'Explorer.focusNext',
|
|
2528
2699
|
when: FocusExplorer
|
|
2529
2700
|
}, {
|
|
2530
|
-
key: CtrlCmd | KeyCode.Star,
|
|
2701
|
+
key: KeyModifier.CtrlCmd | KeyCode.Star,
|
|
2531
2702
|
command: 'Explorer.expandAll',
|
|
2532
2703
|
when: FocusExplorer
|
|
2533
2704
|
}, {
|
|
2534
|
-
key: Alt | KeyCode.RightArrow,
|
|
2705
|
+
key: KeyModifier.Alt | KeyCode.RightArrow,
|
|
2535
2706
|
command: 'Explorer.expandRecursively',
|
|
2536
2707
|
when: FocusExplorer
|
|
2537
2708
|
}, {
|
|
2538
|
-
key: CtrlCmd | KeyCode.LeftArrow,
|
|
2709
|
+
key: KeyModifier.CtrlCmd | KeyCode.LeftArrow,
|
|
2539
2710
|
command: 'Explorer.collapseAll',
|
|
2540
2711
|
when: FocusExplorer
|
|
2541
2712
|
}, {
|
|
2542
|
-
key: CtrlCmd | KeyCode.KeyV,
|
|
2713
|
+
key: KeyModifier.CtrlCmd | KeyCode.KeyV,
|
|
2543
2714
|
command: 'Explorer.handlePaste',
|
|
2544
2715
|
when: FocusExplorer
|
|
2545
2716
|
}, {
|
|
2546
|
-
key: CtrlCmd | KeyCode.KeyC,
|
|
2717
|
+
key: KeyModifier.CtrlCmd | KeyCode.KeyC,
|
|
2547
2718
|
command: 'Explorer.handleCopy',
|
|
2548
2719
|
when: FocusExplorer
|
|
2549
2720
|
}, {
|
|
2550
|
-
key: CtrlCmd | KeyCode.KeyX,
|
|
2721
|
+
key: KeyModifier.CtrlCmd | KeyCode.KeyX,
|
|
2551
2722
|
command: 'Explorer.handleCut',
|
|
2552
2723
|
when: FocusExplorer
|
|
2553
2724
|
}, {
|
|
@@ -2579,7 +2750,7 @@ const getKeyBindings = () => {
|
|
|
2579
2750
|
command: 'Explorer.handleClickCurrent',
|
|
2580
2751
|
when: FocusExplorer
|
|
2581
2752
|
}, {
|
|
2582
|
-
key: CtrlCmd | KeyCode.KeyA,
|
|
2753
|
+
key: KeyModifier.CtrlCmd | KeyCode.KeyA,
|
|
2583
2754
|
command: 'Explorer.selectAll',
|
|
2584
2755
|
when: FocusExplorer
|
|
2585
2756
|
}];
|
|
@@ -4369,8 +4540,29 @@ const handleWorkspaceChange = async state => {
|
|
|
4369
4540
|
return newState;
|
|
4370
4541
|
};
|
|
4371
4542
|
|
|
4543
|
+
const sendMessagePortToFileSystemWorker = async port => {
|
|
4544
|
+
await sendMessagePortToFileSystemWorker$1(port, 0);
|
|
4545
|
+
};
|
|
4546
|
+
|
|
4547
|
+
const createFileSystemWorkerRpc = async () => {
|
|
4548
|
+
try {
|
|
4549
|
+
const rpc = await TransferMessagePortRpcParent.create({
|
|
4550
|
+
commandMap: {},
|
|
4551
|
+
send: sendMessagePortToFileSystemWorker
|
|
4552
|
+
});
|
|
4553
|
+
return rpc;
|
|
4554
|
+
} catch (error) {
|
|
4555
|
+
throw new VError(error, `Failed to create file system worker rpc`);
|
|
4556
|
+
}
|
|
4557
|
+
};
|
|
4558
|
+
|
|
4559
|
+
const initializeFileSystemWorker = async () => {
|
|
4560
|
+
const rpc = await createFileSystemWorkerRpc();
|
|
4561
|
+
set$1(rpc);
|
|
4562
|
+
};
|
|
4563
|
+
|
|
4372
4564
|
const initialize = async () => {
|
|
4373
|
-
|
|
4565
|
+
await initializeFileSystemWorker();
|
|
4374
4566
|
};
|
|
4375
4567
|
|
|
4376
4568
|
const ExplorerEditBox = FocusExplorerEditBox;
|
|
@@ -5764,7 +5956,7 @@ const listen = async () => {
|
|
|
5764
5956
|
const rpc = await WebWorkerRpcClient.create({
|
|
5765
5957
|
commandMap: commandMap
|
|
5766
5958
|
});
|
|
5767
|
-
set$
|
|
5959
|
+
set$2(rpc);
|
|
5768
5960
|
};
|
|
5769
5961
|
|
|
5770
5962
|
const main = async () => {
|