@lvce-editor/explorer-view 5.15.0 → 5.16.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 +115 -113
- package/package.json +1 -1
|
@@ -468,7 +468,7 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
468
468
|
return promise;
|
|
469
469
|
};
|
|
470
470
|
const Message$1 = 3;
|
|
471
|
-
const create$5
|
|
471
|
+
const create$5 = async ({
|
|
472
472
|
isMessagePortOpen,
|
|
473
473
|
messagePort
|
|
474
474
|
}) => {
|
|
@@ -519,61 +519,19 @@ const wrap$5 = messagePort => {
|
|
|
519
519
|
};
|
|
520
520
|
const IpcParentWithMessagePort$1 = {
|
|
521
521
|
__proto__: null,
|
|
522
|
-
create: create$5
|
|
522
|
+
create: create$5,
|
|
523
523
|
signal: signal$1,
|
|
524
524
|
wrap: wrap$5
|
|
525
525
|
};
|
|
526
526
|
|
|
527
|
-
const Two = '2.0';
|
|
528
|
-
const create$4$1 = (method, params) => {
|
|
529
|
-
return {
|
|
530
|
-
jsonrpc: Two,
|
|
531
|
-
method,
|
|
532
|
-
params
|
|
533
|
-
};
|
|
534
|
-
};
|
|
527
|
+
const Two$1 = '2.0';
|
|
535
528
|
const callbacks = Object.create(null);
|
|
536
|
-
const set$7 = (id, fn) => {
|
|
537
|
-
callbacks[id] = fn;
|
|
538
|
-
};
|
|
539
529
|
const get$2 = id => {
|
|
540
530
|
return callbacks[id];
|
|
541
531
|
};
|
|
542
532
|
const remove$2 = id => {
|
|
543
533
|
delete callbacks[id];
|
|
544
534
|
};
|
|
545
|
-
let id = 0;
|
|
546
|
-
const create$3$1 = () => {
|
|
547
|
-
return ++id;
|
|
548
|
-
};
|
|
549
|
-
const registerPromise = () => {
|
|
550
|
-
const id = create$3$1();
|
|
551
|
-
const {
|
|
552
|
-
resolve,
|
|
553
|
-
promise
|
|
554
|
-
} = Promise.withResolvers();
|
|
555
|
-
set$7(id, resolve);
|
|
556
|
-
return {
|
|
557
|
-
id,
|
|
558
|
-
promise
|
|
559
|
-
};
|
|
560
|
-
};
|
|
561
|
-
const create$2$1 = (method, params) => {
|
|
562
|
-
const {
|
|
563
|
-
id,
|
|
564
|
-
promise
|
|
565
|
-
} = registerPromise();
|
|
566
|
-
const message = {
|
|
567
|
-
jsonrpc: Two,
|
|
568
|
-
method,
|
|
569
|
-
params,
|
|
570
|
-
id
|
|
571
|
-
};
|
|
572
|
-
return {
|
|
573
|
-
message,
|
|
574
|
-
promise
|
|
575
|
-
};
|
|
576
|
-
};
|
|
577
535
|
class JsonRpcError extends Error {
|
|
578
536
|
constructor(message) {
|
|
579
537
|
super(message);
|
|
@@ -767,9 +725,9 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
767
725
|
}
|
|
768
726
|
};
|
|
769
727
|
};
|
|
770
|
-
const create$1$
|
|
728
|
+
const create$1$2 = (id, error) => {
|
|
771
729
|
return {
|
|
772
|
-
jsonrpc: Two,
|
|
730
|
+
jsonrpc: Two$1,
|
|
773
731
|
id,
|
|
774
732
|
error
|
|
775
733
|
};
|
|
@@ -778,22 +736,22 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
778
736
|
const prettyError = preparePrettyError(error);
|
|
779
737
|
logError(error, prettyError);
|
|
780
738
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
781
|
-
return create$1$
|
|
739
|
+
return create$1$2(id, errorProperty);
|
|
782
740
|
};
|
|
783
|
-
const create$
|
|
741
|
+
const create$3 = (message, result) => {
|
|
784
742
|
return {
|
|
785
|
-
jsonrpc: Two,
|
|
743
|
+
jsonrpc: Two$1,
|
|
786
744
|
id: message.id,
|
|
787
745
|
result: result ?? null
|
|
788
746
|
};
|
|
789
747
|
};
|
|
790
748
|
const getSuccessResponse = (message, result) => {
|
|
791
749
|
const resultProperty = result ?? null;
|
|
792
|
-
return create$
|
|
750
|
+
return create$3(message, resultProperty);
|
|
793
751
|
};
|
|
794
752
|
const getErrorResponseSimple = (id, error) => {
|
|
795
753
|
return {
|
|
796
|
-
jsonrpc: Two,
|
|
754
|
+
jsonrpc: Two$1,
|
|
797
755
|
id,
|
|
798
756
|
error: {
|
|
799
757
|
code: Custom,
|
|
@@ -880,29 +838,6 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
880
838
|
}
|
|
881
839
|
throw new JsonRpcError('unexpected message');
|
|
882
840
|
};
|
|
883
|
-
const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
884
|
-
const {
|
|
885
|
-
message,
|
|
886
|
-
promise
|
|
887
|
-
} = create$2$1(method, params);
|
|
888
|
-
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
889
|
-
ipc.sendAndTransfer(message);
|
|
890
|
-
} else {
|
|
891
|
-
ipc.send(message);
|
|
892
|
-
}
|
|
893
|
-
const responseMessage = await promise;
|
|
894
|
-
return unwrapJsonRpcResult(responseMessage);
|
|
895
|
-
};
|
|
896
|
-
const send$2 = (transport, method, ...params) => {
|
|
897
|
-
const message = create$4$1(method, params);
|
|
898
|
-
transport.send(message);
|
|
899
|
-
};
|
|
900
|
-
const invoke$5 = (ipc, method, ...params) => {
|
|
901
|
-
return invokeHelper(ipc, method, params, false);
|
|
902
|
-
};
|
|
903
|
-
const invokeAndTransfer$2 = (ipc, method, ...params) => {
|
|
904
|
-
return invokeHelper(ipc, method, params, true);
|
|
905
|
-
};
|
|
906
841
|
|
|
907
842
|
class CommandNotFoundError extends Error {
|
|
908
843
|
constructor(command) {
|
|
@@ -925,24 +860,87 @@ const execute = (command, ...args) => {
|
|
|
925
860
|
return fn(...args);
|
|
926
861
|
};
|
|
927
862
|
|
|
863
|
+
const Two = '2.0';
|
|
864
|
+
const create$o = (method, params) => {
|
|
865
|
+
return {
|
|
866
|
+
jsonrpc: Two,
|
|
867
|
+
method,
|
|
868
|
+
params
|
|
869
|
+
};
|
|
870
|
+
};
|
|
871
|
+
const create$n = (id, method, params) => {
|
|
872
|
+
const message = {
|
|
873
|
+
id,
|
|
874
|
+
jsonrpc: Two,
|
|
875
|
+
method,
|
|
876
|
+
params
|
|
877
|
+
};
|
|
878
|
+
return message;
|
|
879
|
+
};
|
|
880
|
+
let id = 0;
|
|
881
|
+
const create$m = () => {
|
|
882
|
+
return ++id;
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
886
|
+
|
|
887
|
+
const registerPromise = map => {
|
|
888
|
+
const id = create$m();
|
|
889
|
+
const {
|
|
890
|
+
promise,
|
|
891
|
+
resolve
|
|
892
|
+
} = Promise.withResolvers();
|
|
893
|
+
map[id] = resolve;
|
|
894
|
+
return {
|
|
895
|
+
id,
|
|
896
|
+
promise
|
|
897
|
+
};
|
|
898
|
+
};
|
|
899
|
+
|
|
900
|
+
// @ts-ignore
|
|
901
|
+
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
902
|
+
const {
|
|
903
|
+
id,
|
|
904
|
+
promise
|
|
905
|
+
} = registerPromise(callbacks);
|
|
906
|
+
const message = create$n(id, method, params);
|
|
907
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
908
|
+
ipc.sendAndTransfer(message);
|
|
909
|
+
} else {
|
|
910
|
+
ipc.send(message);
|
|
911
|
+
}
|
|
912
|
+
const responseMessage = await promise;
|
|
913
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
914
|
+
};
|
|
928
915
|
const createRpc = ipc => {
|
|
916
|
+
const callbacks = Object.create(null);
|
|
917
|
+
ipc._resolve = (id, response) => {
|
|
918
|
+
const fn = callbacks[id];
|
|
919
|
+
if (!fn) {
|
|
920
|
+
console.warn(`callback ${id} may already be disposed`);
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
fn(response);
|
|
924
|
+
delete callbacks[id];
|
|
925
|
+
};
|
|
929
926
|
const rpc = {
|
|
927
|
+
async dispose() {
|
|
928
|
+
await ipc?.dispose();
|
|
929
|
+
},
|
|
930
|
+
invoke(method, ...params) {
|
|
931
|
+
return invokeHelper(callbacks, ipc, method, params, false);
|
|
932
|
+
},
|
|
933
|
+
invokeAndTransfer(method, ...params) {
|
|
934
|
+
return invokeHelper(callbacks, ipc, method, params, true);
|
|
935
|
+
},
|
|
930
936
|
// @ts-ignore
|
|
931
937
|
ipc,
|
|
932
938
|
/**
|
|
933
939
|
* @deprecated
|
|
934
940
|
*/
|
|
935
941
|
send(method, ...params) {
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
invoke(method, ...params) {
|
|
939
|
-
return invoke$5(ipc, method, ...params);
|
|
940
|
-
},
|
|
941
|
-
invokeAndTransfer(method, ...params) {
|
|
942
|
-
return invokeAndTransfer$2(ipc, method, ...params);
|
|
943
|
-
},
|
|
944
|
-
async dispose() {
|
|
945
|
-
await ipc?.dispose();
|
|
942
|
+
const message = create$o(method, params);
|
|
943
|
+
ipc.send(message);
|
|
946
944
|
}
|
|
947
945
|
};
|
|
948
946
|
return rpc;
|
|
@@ -959,7 +957,7 @@ const logError = () => {
|
|
|
959
957
|
const handleMessage = event => {
|
|
960
958
|
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
961
959
|
const actualExecute = event?.target?.execute || execute;
|
|
962
|
-
return handleJsonRpcMessage(event.target, event.data, actualExecute,
|
|
960
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
963
961
|
};
|
|
964
962
|
const handleIpc = ipc => {
|
|
965
963
|
if ('addEventListener' in ipc) {
|
|
@@ -977,15 +975,16 @@ const listen$1 = async (module, options) => {
|
|
|
977
975
|
const ipc = module.wrap(rawIpc);
|
|
978
976
|
return ipc;
|
|
979
977
|
};
|
|
980
|
-
const create$
|
|
978
|
+
const create$6 = async ({
|
|
981
979
|
commandMap,
|
|
980
|
+
isMessagePortOpen = true,
|
|
982
981
|
messagePort
|
|
983
982
|
}) => {
|
|
984
983
|
// TODO create a commandMap per rpc instance
|
|
985
984
|
register(commandMap);
|
|
986
985
|
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
987
|
-
|
|
988
|
-
|
|
986
|
+
isMessagePortOpen,
|
|
987
|
+
messagePort
|
|
989
988
|
});
|
|
990
989
|
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
991
990
|
handleIpc(ipc);
|
|
@@ -993,8 +992,9 @@ const create$5 = async ({
|
|
|
993
992
|
messagePort.start();
|
|
994
993
|
return rpc;
|
|
995
994
|
};
|
|
996
|
-
const create$
|
|
995
|
+
const create$4 = async ({
|
|
997
996
|
commandMap,
|
|
997
|
+
isMessagePortOpen,
|
|
998
998
|
send
|
|
999
999
|
}) => {
|
|
1000
1000
|
const {
|
|
@@ -1002,16 +1002,17 @@ const create$3 = async ({
|
|
|
1002
1002
|
port2
|
|
1003
1003
|
} = new MessageChannel();
|
|
1004
1004
|
await send(port1);
|
|
1005
|
-
return create$
|
|
1005
|
+
return create$6({
|
|
1006
1006
|
commandMap,
|
|
1007
|
+
isMessagePortOpen,
|
|
1007
1008
|
messagePort: port2
|
|
1008
1009
|
});
|
|
1009
1010
|
};
|
|
1010
1011
|
const TransferMessagePortRpcParent = {
|
|
1011
1012
|
__proto__: null,
|
|
1012
|
-
create: create$
|
|
1013
|
+
create: create$4
|
|
1013
1014
|
};
|
|
1014
|
-
const create$
|
|
1015
|
+
const create$1$1 = async ({
|
|
1015
1016
|
commandMap
|
|
1016
1017
|
}) => {
|
|
1017
1018
|
// TODO create a commandMap per rpc instance
|
|
@@ -1023,26 +1024,7 @@ const create$4 = async ({
|
|
|
1023
1024
|
};
|
|
1024
1025
|
const WebWorkerRpcClient = {
|
|
1025
1026
|
__proto__: null,
|
|
1026
|
-
create: create$
|
|
1027
|
-
};
|
|
1028
|
-
const createMockRpc = ({
|
|
1029
|
-
commandMap
|
|
1030
|
-
}) => {
|
|
1031
|
-
const invocations = [];
|
|
1032
|
-
const invoke = (method, ...params) => {
|
|
1033
|
-
invocations.push([method, ...params]);
|
|
1034
|
-
const command = commandMap[method];
|
|
1035
|
-
if (!command) {
|
|
1036
|
-
throw new Error(`command ${method} not found`);
|
|
1037
|
-
}
|
|
1038
|
-
return command(...params);
|
|
1039
|
-
};
|
|
1040
|
-
const mockRpc = {
|
|
1041
|
-
invoke,
|
|
1042
|
-
invokeAndTransfer: invoke,
|
|
1043
|
-
invocations
|
|
1044
|
-
};
|
|
1045
|
-
return mockRpc;
|
|
1027
|
+
create: create$1$1
|
|
1046
1028
|
};
|
|
1047
1029
|
|
|
1048
1030
|
const Button$3 = 'event.button';
|
|
@@ -1106,6 +1088,26 @@ const create$2 = rpcId => {
|
|
|
1106
1088
|
};
|
|
1107
1089
|
};
|
|
1108
1090
|
|
|
1091
|
+
const createMockRpc = ({
|
|
1092
|
+
commandMap
|
|
1093
|
+
}) => {
|
|
1094
|
+
const invocations = [];
|
|
1095
|
+
const invoke = (method, ...params) => {
|
|
1096
|
+
invocations.push([method, ...params]);
|
|
1097
|
+
const command = commandMap[method];
|
|
1098
|
+
if (!command) {
|
|
1099
|
+
throw new Error(`command ${method} not found`);
|
|
1100
|
+
}
|
|
1101
|
+
return command(...params);
|
|
1102
|
+
};
|
|
1103
|
+
const mockRpc = {
|
|
1104
|
+
invoke,
|
|
1105
|
+
invokeAndTransfer: invoke,
|
|
1106
|
+
invocations
|
|
1107
|
+
};
|
|
1108
|
+
return mockRpc;
|
|
1109
|
+
};
|
|
1110
|
+
|
|
1109
1111
|
const {
|
|
1110
1112
|
dispose,
|
|
1111
1113
|
invoke: invoke$4,
|