@lvce-editor/explorer-view 3.3.0 → 3.4.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 +199 -11
- 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
|
};
|
|
@@ -4369,8 +4536,29 @@ const handleWorkspaceChange = async state => {
|
|
|
4369
4536
|
return newState;
|
|
4370
4537
|
};
|
|
4371
4538
|
|
|
4539
|
+
const sendMessagePortToFileSystemWorker = async port => {
|
|
4540
|
+
await sendMessagePortToFileSystemWorker$1(port, 0);
|
|
4541
|
+
};
|
|
4542
|
+
|
|
4543
|
+
const createFileSystemWorkerRpc = async () => {
|
|
4544
|
+
try {
|
|
4545
|
+
const rpc = await TransferMessagePortRpcParent.create({
|
|
4546
|
+
commandMap: {},
|
|
4547
|
+
send: sendMessagePortToFileSystemWorker
|
|
4548
|
+
});
|
|
4549
|
+
return rpc;
|
|
4550
|
+
} catch (error) {
|
|
4551
|
+
throw new VError(error, `Failed to create file system worker rpc`);
|
|
4552
|
+
}
|
|
4553
|
+
};
|
|
4554
|
+
|
|
4555
|
+
const initializeFileSystemWorker = async () => {
|
|
4556
|
+
const rpc = await createFileSystemWorkerRpc();
|
|
4557
|
+
set$1(rpc);
|
|
4558
|
+
};
|
|
4559
|
+
|
|
4372
4560
|
const initialize = async () => {
|
|
4373
|
-
|
|
4561
|
+
await initializeFileSystemWorker();
|
|
4374
4562
|
};
|
|
4375
4563
|
|
|
4376
4564
|
const ExplorerEditBox = FocusExplorerEditBox;
|
|
@@ -5764,7 +5952,7 @@ const listen = async () => {
|
|
|
5764
5952
|
const rpc = await WebWorkerRpcClient.create({
|
|
5765
5953
|
commandMap: commandMap
|
|
5766
5954
|
});
|
|
5767
|
-
set$
|
|
5955
|
+
set$2(rpc);
|
|
5768
5956
|
};
|
|
5769
5957
|
|
|
5770
5958
|
const main = async () => {
|