@lvce-editor/extension-management-worker 3.0.0 → 3.1.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/extensionManagementWorkerMain.js +163 -161
- package/package.json +1 -1
|
@@ -540,7 +540,7 @@ const waitForWebSocketToBeOpen = webSocket => {
|
|
|
540
540
|
open: Open
|
|
541
541
|
});
|
|
542
542
|
};
|
|
543
|
-
const create$
|
|
543
|
+
const create$c = async ({
|
|
544
544
|
webSocket
|
|
545
545
|
}) => {
|
|
546
546
|
const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
|
|
@@ -577,13 +577,34 @@ const wrap = webSocket => {
|
|
|
577
577
|
};
|
|
578
578
|
const IpcParentWithWebSocket$1 = {
|
|
579
579
|
__proto__: null,
|
|
580
|
-
create: create$
|
|
580
|
+
create: create$c,
|
|
581
581
|
wrap
|
|
582
582
|
};
|
|
583
583
|
|
|
584
|
+
class CommandNotFoundError extends Error {
|
|
585
|
+
constructor(command) {
|
|
586
|
+
super(`Command not found ${command}`);
|
|
587
|
+
this.name = 'CommandNotFoundError';
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
const commands = Object.create(null);
|
|
591
|
+
const register = commandMap => {
|
|
592
|
+
Object.assign(commands, commandMap);
|
|
593
|
+
};
|
|
594
|
+
const getCommand = key => {
|
|
595
|
+
return commands[key];
|
|
596
|
+
};
|
|
597
|
+
const execute = (command, ...args) => {
|
|
598
|
+
const fn = getCommand(command);
|
|
599
|
+
if (!fn) {
|
|
600
|
+
throw new CommandNotFoundError(command);
|
|
601
|
+
}
|
|
602
|
+
return fn(...args);
|
|
603
|
+
};
|
|
604
|
+
|
|
584
605
|
const Two$1 = '2.0';
|
|
585
606
|
const callbacks = Object.create(null);
|
|
586
|
-
const get$
|
|
607
|
+
const get$6 = id => {
|
|
587
608
|
return callbacks[id];
|
|
588
609
|
};
|
|
589
610
|
const remove$1 = id => {
|
|
@@ -605,12 +626,12 @@ const getErrorConstructor = (message, type) => {
|
|
|
605
626
|
switch (type) {
|
|
606
627
|
case DomException:
|
|
607
628
|
return DOMException;
|
|
608
|
-
case TypeError$1:
|
|
609
|
-
return TypeError;
|
|
610
|
-
case SyntaxError$1:
|
|
611
|
-
return SyntaxError;
|
|
612
629
|
case ReferenceError$1:
|
|
613
630
|
return ReferenceError;
|
|
631
|
+
case SyntaxError$1:
|
|
632
|
+
return SyntaxError;
|
|
633
|
+
case TypeError$1:
|
|
634
|
+
return TypeError;
|
|
614
635
|
default:
|
|
615
636
|
return Error;
|
|
616
637
|
}
|
|
@@ -732,7 +753,7 @@ const warn$1 = (...args) => {
|
|
|
732
753
|
console.warn(...args);
|
|
733
754
|
};
|
|
734
755
|
const resolve = (id, response) => {
|
|
735
|
-
const fn = get$
|
|
756
|
+
const fn = get$6(id);
|
|
736
757
|
if (!fn) {
|
|
737
758
|
console.log(response);
|
|
738
759
|
warn$1(`callback ${id} may already be disposed`);
|
|
@@ -766,27 +787,27 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
766
787
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
767
788
|
return {
|
|
768
789
|
code: MethodNotFound,
|
|
769
|
-
|
|
770
|
-
|
|
790
|
+
data: error.stack,
|
|
791
|
+
message: error.message
|
|
771
792
|
};
|
|
772
793
|
}
|
|
773
794
|
return {
|
|
774
795
|
code: Custom,
|
|
775
|
-
message: prettyError.message,
|
|
776
796
|
data: {
|
|
777
|
-
stack: getStack(prettyError),
|
|
778
|
-
codeFrame: prettyError.codeFrame,
|
|
779
|
-
type: getErrorType(prettyError),
|
|
780
797
|
code: prettyError.code,
|
|
781
|
-
|
|
782
|
-
|
|
798
|
+
codeFrame: prettyError.codeFrame,
|
|
799
|
+
name: prettyError.name,
|
|
800
|
+
stack: getStack(prettyError),
|
|
801
|
+
type: getErrorType(prettyError)
|
|
802
|
+
},
|
|
803
|
+
message: prettyError.message
|
|
783
804
|
};
|
|
784
805
|
};
|
|
785
806
|
const create$1$1 = (id, error) => {
|
|
786
807
|
return {
|
|
787
|
-
|
|
808
|
+
error,
|
|
788
809
|
id,
|
|
789
|
-
|
|
810
|
+
jsonrpc: Two$1
|
|
790
811
|
};
|
|
791
812
|
};
|
|
792
813
|
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
@@ -795,27 +816,27 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
795
816
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
796
817
|
return create$1$1(id, errorProperty);
|
|
797
818
|
};
|
|
798
|
-
const create$
|
|
819
|
+
const create$b = (message, result) => {
|
|
799
820
|
return {
|
|
800
|
-
jsonrpc: Two$1,
|
|
801
821
|
id: message.id,
|
|
822
|
+
jsonrpc: Two$1,
|
|
802
823
|
result: result ?? null
|
|
803
824
|
};
|
|
804
825
|
};
|
|
805
826
|
const getSuccessResponse = (message, result) => {
|
|
806
827
|
const resultProperty = result ?? null;
|
|
807
|
-
return create$
|
|
828
|
+
return create$b(message, resultProperty);
|
|
808
829
|
};
|
|
809
830
|
const getErrorResponseSimple = (id, error) => {
|
|
810
831
|
return {
|
|
811
|
-
jsonrpc: Two$1,
|
|
812
|
-
id,
|
|
813
832
|
error: {
|
|
814
833
|
code: Custom,
|
|
834
|
+
data: error,
|
|
815
835
|
// @ts-ignore
|
|
816
|
-
message: error.message
|
|
817
|
-
|
|
818
|
-
|
|
836
|
+
message: error.message
|
|
837
|
+
},
|
|
838
|
+
id,
|
|
839
|
+
jsonrpc: Two$1
|
|
819
840
|
};
|
|
820
841
|
};
|
|
821
842
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
@@ -845,35 +866,35 @@ const normalizeParams = args => {
|
|
|
845
866
|
if (args.length === 1) {
|
|
846
867
|
const options = args[0];
|
|
847
868
|
return {
|
|
869
|
+
execute: options.execute,
|
|
848
870
|
ipc: options.ipc,
|
|
871
|
+
logError: options.logError || defaultLogError,
|
|
849
872
|
message: options.message,
|
|
850
|
-
execute: options.execute,
|
|
851
|
-
resolve: options.resolve || defaultResolve,
|
|
852
873
|
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
853
|
-
|
|
854
|
-
|
|
874
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
875
|
+
resolve: options.resolve || defaultResolve
|
|
855
876
|
};
|
|
856
877
|
}
|
|
857
878
|
return {
|
|
879
|
+
execute: args[2],
|
|
858
880
|
ipc: args[0],
|
|
881
|
+
logError: args[5],
|
|
859
882
|
message: args[1],
|
|
860
|
-
execute: args[2],
|
|
861
|
-
resolve: args[3],
|
|
862
883
|
preparePrettyError: args[4],
|
|
863
|
-
|
|
864
|
-
|
|
884
|
+
requiresSocket: args[6],
|
|
885
|
+
resolve: args[3]
|
|
865
886
|
};
|
|
866
887
|
};
|
|
867
888
|
const handleJsonRpcMessage = async (...args) => {
|
|
868
889
|
const options = normalizeParams(args);
|
|
869
890
|
const {
|
|
870
|
-
message,
|
|
871
|
-
ipc,
|
|
872
891
|
execute,
|
|
873
|
-
|
|
874
|
-
preparePrettyError,
|
|
892
|
+
ipc,
|
|
875
893
|
logError,
|
|
876
|
-
|
|
894
|
+
message,
|
|
895
|
+
preparePrettyError,
|
|
896
|
+
requiresSocket,
|
|
897
|
+
resolve
|
|
877
898
|
} = options;
|
|
878
899
|
if ('id' in message) {
|
|
879
900
|
if ('method' in message) {
|
|
@@ -896,36 +917,17 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
896
917
|
throw new JsonRpcError('unexpected message');
|
|
897
918
|
};
|
|
898
919
|
|
|
899
|
-
class CommandNotFoundError extends Error {
|
|
900
|
-
constructor(command) {
|
|
901
|
-
super(`Command not found ${command}`);
|
|
902
|
-
this.name = 'CommandNotFoundError';
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
const commands = Object.create(null);
|
|
906
|
-
const register = commandMap => {
|
|
907
|
-
Object.assign(commands, commandMap);
|
|
908
|
-
};
|
|
909
|
-
const getCommand = key => {
|
|
910
|
-
return commands[key];
|
|
911
|
-
};
|
|
912
|
-
const execute = (command, ...args) => {
|
|
913
|
-
const fn = getCommand(command);
|
|
914
|
-
if (!fn) {
|
|
915
|
-
throw new CommandNotFoundError(command);
|
|
916
|
-
}
|
|
917
|
-
return fn(...args);
|
|
918
|
-
};
|
|
919
|
-
|
|
920
920
|
const Two = '2.0';
|
|
921
|
-
|
|
921
|
+
|
|
922
|
+
const create$a = (method, params) => {
|
|
922
923
|
return {
|
|
923
924
|
jsonrpc: Two,
|
|
924
925
|
method,
|
|
925
926
|
params
|
|
926
927
|
};
|
|
927
928
|
};
|
|
928
|
-
|
|
929
|
+
|
|
930
|
+
const create$9 = (id, method, params) => {
|
|
929
931
|
const message = {
|
|
930
932
|
id,
|
|
931
933
|
jsonrpc: Two,
|
|
@@ -934,15 +936,14 @@ const create$s = (id, method, params) => {
|
|
|
934
936
|
};
|
|
935
937
|
return message;
|
|
936
938
|
};
|
|
939
|
+
|
|
937
940
|
let id$1 = 0;
|
|
938
|
-
const create$
|
|
941
|
+
const create$8 = () => {
|
|
939
942
|
return ++id$1;
|
|
940
943
|
};
|
|
941
944
|
|
|
942
|
-
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
943
|
-
|
|
944
945
|
const registerPromise = map => {
|
|
945
|
-
const id = create$
|
|
946
|
+
const id = create$8();
|
|
946
947
|
const {
|
|
947
948
|
promise,
|
|
948
949
|
resolve
|
|
@@ -954,13 +955,12 @@ const registerPromise = map => {
|
|
|
954
955
|
};
|
|
955
956
|
};
|
|
956
957
|
|
|
957
|
-
// @ts-ignore
|
|
958
958
|
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
959
959
|
const {
|
|
960
960
|
id,
|
|
961
961
|
promise
|
|
962
962
|
} = registerPromise(callbacks);
|
|
963
|
-
const message = create$
|
|
963
|
+
const message = create$9(id, method, params);
|
|
964
964
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
965
965
|
ipc.sendAndTransfer(message);
|
|
966
966
|
} else {
|
|
@@ -996,12 +996,13 @@ const createRpc = ipc => {
|
|
|
996
996
|
* @deprecated
|
|
997
997
|
*/
|
|
998
998
|
send(method, ...params) {
|
|
999
|
-
const message = create$
|
|
999
|
+
const message = create$a(method, params);
|
|
1000
1000
|
ipc.send(message);
|
|
1001
1001
|
}
|
|
1002
1002
|
};
|
|
1003
1003
|
return rpc;
|
|
1004
1004
|
};
|
|
1005
|
+
|
|
1005
1006
|
const requiresSocket = () => {
|
|
1006
1007
|
return false;
|
|
1007
1008
|
};
|
|
@@ -1016,6 +1017,7 @@ const handleMessage = event => {
|
|
|
1016
1017
|
const actualExecute = event?.target?.execute || execute;
|
|
1017
1018
|
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
1018
1019
|
};
|
|
1020
|
+
|
|
1019
1021
|
const handleIpc = ipc => {
|
|
1020
1022
|
if ('addEventListener' in ipc) {
|
|
1021
1023
|
ipc.addEventListener('message', handleMessage);
|
|
@@ -1024,6 +1026,7 @@ const handleIpc = ipc => {
|
|
|
1024
1026
|
ipc.on('message', handleMessage);
|
|
1025
1027
|
}
|
|
1026
1028
|
};
|
|
1029
|
+
|
|
1027
1030
|
const listen$1 = async (module, options) => {
|
|
1028
1031
|
const rawIpc = await module.listen(options);
|
|
1029
1032
|
if (module.signal) {
|
|
@@ -1032,23 +1035,63 @@ const listen$1 = async (module, options) => {
|
|
|
1032
1035
|
const ipc = module.wrap(rawIpc);
|
|
1033
1036
|
return ipc;
|
|
1034
1037
|
};
|
|
1038
|
+
|
|
1039
|
+
const create$7 = async ({
|
|
1040
|
+
commandMap,
|
|
1041
|
+
isMessagePortOpen = true,
|
|
1042
|
+
messagePort
|
|
1043
|
+
}) => {
|
|
1044
|
+
// TODO create a commandMap per rpc instance
|
|
1045
|
+
register(commandMap);
|
|
1046
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
1047
|
+
isMessagePortOpen,
|
|
1048
|
+
messagePort
|
|
1049
|
+
});
|
|
1050
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
1051
|
+
handleIpc(ipc);
|
|
1052
|
+
const rpc = createRpc(ipc);
|
|
1053
|
+
messagePort.start();
|
|
1054
|
+
return rpc;
|
|
1055
|
+
};
|
|
1056
|
+
|
|
1057
|
+
const create$6 = async ({
|
|
1058
|
+
commandMap,
|
|
1059
|
+
isMessagePortOpen,
|
|
1060
|
+
send
|
|
1061
|
+
}) => {
|
|
1062
|
+
const {
|
|
1063
|
+
port1,
|
|
1064
|
+
port2
|
|
1065
|
+
} = new MessageChannel();
|
|
1066
|
+
await send(port1);
|
|
1067
|
+
return create$7({
|
|
1068
|
+
commandMap,
|
|
1069
|
+
isMessagePortOpen,
|
|
1070
|
+
messagePort: port2
|
|
1071
|
+
});
|
|
1072
|
+
};
|
|
1073
|
+
|
|
1035
1074
|
const Https = 'https:';
|
|
1036
1075
|
const Ws = 'ws:';
|
|
1037
1076
|
const Wss = 'wss:';
|
|
1077
|
+
|
|
1038
1078
|
const getWebSocketProtocol = locationProtocol => {
|
|
1039
1079
|
return locationProtocol === Https ? Wss : Ws;
|
|
1040
1080
|
};
|
|
1081
|
+
|
|
1041
1082
|
const getWebSocketUrl = (type, host, locationProtocol) => {
|
|
1042
1083
|
const wsProtocol = getWebSocketProtocol(locationProtocol);
|
|
1043
1084
|
return `${wsProtocol}//${host}/websocket/${type}`;
|
|
1044
1085
|
};
|
|
1086
|
+
|
|
1045
1087
|
const getHost = () => {
|
|
1046
1088
|
return location.host;
|
|
1047
1089
|
};
|
|
1048
1090
|
const getProtocol = () => {
|
|
1049
1091
|
return location.protocol;
|
|
1050
1092
|
};
|
|
1051
|
-
|
|
1093
|
+
|
|
1094
|
+
const create$5 = async ({
|
|
1052
1095
|
commandMap,
|
|
1053
1096
|
webSocket
|
|
1054
1097
|
}) => {
|
|
@@ -1062,7 +1105,8 @@ const create$i = async ({
|
|
|
1062
1105
|
const rpc = createRpc(ipc);
|
|
1063
1106
|
return rpc;
|
|
1064
1107
|
};
|
|
1065
|
-
|
|
1108
|
+
|
|
1109
|
+
const create$4 = async ({
|
|
1066
1110
|
commandMap,
|
|
1067
1111
|
type
|
|
1068
1112
|
}) => {
|
|
@@ -1070,17 +1114,14 @@ const create$h = async ({
|
|
|
1070
1114
|
const protocol = getProtocol();
|
|
1071
1115
|
const wsUrl = getWebSocketUrl(type, host, protocol);
|
|
1072
1116
|
const webSocket = new WebSocket(wsUrl);
|
|
1073
|
-
const rpc = await create$
|
|
1117
|
+
const rpc = await create$5({
|
|
1074
1118
|
commandMap,
|
|
1075
1119
|
webSocket
|
|
1076
1120
|
});
|
|
1077
1121
|
return rpc;
|
|
1078
1122
|
};
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
create: create$h
|
|
1082
|
-
};
|
|
1083
|
-
const create$e = async ({
|
|
1123
|
+
|
|
1124
|
+
const create$3 = async ({
|
|
1084
1125
|
commandMap,
|
|
1085
1126
|
isMessagePortOpen,
|
|
1086
1127
|
messagePort
|
|
@@ -1096,51 +1137,7 @@ const create$e = async ({
|
|
|
1096
1137
|
const rpc = createRpc(ipc);
|
|
1097
1138
|
return rpc;
|
|
1098
1139
|
};
|
|
1099
|
-
|
|
1100
|
-
__proto__: null,
|
|
1101
|
-
create: create$e
|
|
1102
|
-
};
|
|
1103
|
-
const create$5 = async ({
|
|
1104
|
-
commandMap,
|
|
1105
|
-
isMessagePortOpen = true,
|
|
1106
|
-
messagePort
|
|
1107
|
-
}) => {
|
|
1108
|
-
// TODO create a commandMap per rpc instance
|
|
1109
|
-
register(commandMap);
|
|
1110
|
-
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
1111
|
-
isMessagePortOpen,
|
|
1112
|
-
messagePort
|
|
1113
|
-
});
|
|
1114
|
-
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
1115
|
-
handleIpc(ipc);
|
|
1116
|
-
const rpc = createRpc(ipc);
|
|
1117
|
-
messagePort.start();
|
|
1118
|
-
return rpc;
|
|
1119
|
-
};
|
|
1120
|
-
const PlainMessagePortRpc = {
|
|
1121
|
-
__proto__: null,
|
|
1122
|
-
create: create$5
|
|
1123
|
-
};
|
|
1124
|
-
const create$3 = async ({
|
|
1125
|
-
commandMap,
|
|
1126
|
-
isMessagePortOpen,
|
|
1127
|
-
send
|
|
1128
|
-
}) => {
|
|
1129
|
-
const {
|
|
1130
|
-
port1,
|
|
1131
|
-
port2
|
|
1132
|
-
} = new MessageChannel();
|
|
1133
|
-
await send(port1);
|
|
1134
|
-
return create$5({
|
|
1135
|
-
commandMap,
|
|
1136
|
-
isMessagePortOpen,
|
|
1137
|
-
messagePort: port2
|
|
1138
|
-
});
|
|
1139
|
-
};
|
|
1140
|
-
const TransferMessagePortRpcParent = {
|
|
1141
|
-
__proto__: null,
|
|
1142
|
-
create: create$3
|
|
1143
|
-
};
|
|
1140
|
+
|
|
1144
1141
|
const create$2 = async ({
|
|
1145
1142
|
commandMap
|
|
1146
1143
|
}) => {
|
|
@@ -1151,10 +1148,7 @@ const create$2 = async ({
|
|
|
1151
1148
|
const rpc = createRpc(ipc);
|
|
1152
1149
|
return rpc;
|
|
1153
1150
|
};
|
|
1154
|
-
|
|
1155
|
-
__proto__: null,
|
|
1156
|
-
create: create$2
|
|
1157
|
-
};
|
|
1151
|
+
|
|
1158
1152
|
const createMockRpc = ({
|
|
1159
1153
|
commandMap
|
|
1160
1154
|
}) => {
|
|
@@ -1175,21 +1169,11 @@ const createMockRpc = ({
|
|
|
1175
1169
|
return mockRpc;
|
|
1176
1170
|
};
|
|
1177
1171
|
|
|
1178
|
-
const Web = 1;
|
|
1179
|
-
const Electron = 2;
|
|
1180
|
-
const Remote = 3;
|
|
1181
|
-
const Test = 4;
|
|
1182
|
-
|
|
1183
|
-
const ExtensionHostWorker = 44;
|
|
1184
|
-
const FileSystemWorker = 209;
|
|
1185
|
-
const RendererWorker = 1;
|
|
1186
|
-
const SharedProcess = 1492;
|
|
1187
|
-
|
|
1188
1172
|
const rpcs$1 = Object.create(null);
|
|
1189
1173
|
const set$7 = (id, rpc) => {
|
|
1190
1174
|
rpcs$1[id] = rpc;
|
|
1191
1175
|
};
|
|
1192
|
-
const get$
|
|
1176
|
+
const get$5 = id => {
|
|
1193
1177
|
return rpcs$1[id];
|
|
1194
1178
|
};
|
|
1195
1179
|
const remove = id => {
|
|
@@ -1200,18 +1184,18 @@ const remove = id => {
|
|
|
1200
1184
|
const create$1 = rpcId => {
|
|
1201
1185
|
return {
|
|
1202
1186
|
async dispose() {
|
|
1203
|
-
const rpc = get$
|
|
1187
|
+
const rpc = get$5(rpcId);
|
|
1204
1188
|
await rpc.dispose();
|
|
1205
1189
|
},
|
|
1206
1190
|
// @ts-ignore
|
|
1207
1191
|
invoke(method, ...params) {
|
|
1208
|
-
const rpc = get$
|
|
1192
|
+
const rpc = get$5(rpcId);
|
|
1209
1193
|
// @ts-ignore
|
|
1210
1194
|
return rpc.invoke(method, ...params);
|
|
1211
1195
|
},
|
|
1212
1196
|
// @ts-ignore
|
|
1213
1197
|
invokeAndTransfer(method, ...params) {
|
|
1214
|
-
const rpc = get$
|
|
1198
|
+
const rpc = get$5(rpcId);
|
|
1215
1199
|
// @ts-ignore
|
|
1216
1200
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1217
1201
|
},
|
|
@@ -1233,6 +1217,16 @@ const create$1 = rpcId => {
|
|
|
1233
1217
|
};
|
|
1234
1218
|
};
|
|
1235
1219
|
|
|
1220
|
+
const Web = 1;
|
|
1221
|
+
const Electron = 2;
|
|
1222
|
+
const Remote = 3;
|
|
1223
|
+
const Test = 4;
|
|
1224
|
+
|
|
1225
|
+
const ExtensionHostWorker = 44;
|
|
1226
|
+
const FileSystemWorker = 209;
|
|
1227
|
+
const RendererWorker = 1;
|
|
1228
|
+
const SharedProcess = 1492;
|
|
1229
|
+
|
|
1236
1230
|
const {
|
|
1237
1231
|
invoke: invoke$4,
|
|
1238
1232
|
set: set$6
|
|
@@ -1259,7 +1253,6 @@ const {
|
|
|
1259
1253
|
} = create$1(RendererWorker);
|
|
1260
1254
|
const sendMessagePortToFileSystemWorker = async (port, rpcId) => {
|
|
1261
1255
|
const command = 'FileSystem.handleMessagePort';
|
|
1262
|
-
// @ts-ignore
|
|
1263
1256
|
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
|
|
1264
1257
|
};
|
|
1265
1258
|
const sendMessagePortToExtensionHostWorker = async (port, rpcId = 0) => {
|
|
@@ -1268,7 +1261,6 @@ const sendMessagePortToExtensionHostWorker = async (port, rpcId = 0) => {
|
|
|
1268
1261
|
};
|
|
1269
1262
|
const sendMessagePortToSharedProcess = async port => {
|
|
1270
1263
|
const command = 'HandleElectronMessagePort.handleElectronMessagePort';
|
|
1271
|
-
// @ts-ignore
|
|
1272
1264
|
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToSharedProcess', port, command, 0);
|
|
1273
1265
|
};
|
|
1274
1266
|
|
|
@@ -1323,7 +1315,7 @@ const states = Object.create(null);
|
|
|
1323
1315
|
const set$2 = status => {
|
|
1324
1316
|
states[status.id] = status;
|
|
1325
1317
|
};
|
|
1326
|
-
const get$
|
|
1318
|
+
const get$4 = extensionId => {
|
|
1327
1319
|
return states[extensionId];
|
|
1328
1320
|
};
|
|
1329
1321
|
const update$1 = (id, update) => {
|
|
@@ -1404,7 +1396,9 @@ const activateExtension2 = async (extensionId, extension, absolutePath) => {
|
|
|
1404
1396
|
const id = getExtensionId(extension);
|
|
1405
1397
|
if (isImportError(error)) {
|
|
1406
1398
|
const actualErrorMessage = await tryToGetActualImportErrorMessage(absolutePath, error);
|
|
1407
|
-
throw new Error(`Failed to activate extension ${id}: ${actualErrorMessage}
|
|
1399
|
+
throw new Error(`Failed to activate extension ${id}: ${actualErrorMessage}`, {
|
|
1400
|
+
cause: error
|
|
1401
|
+
});
|
|
1408
1402
|
}
|
|
1409
1403
|
update$1(extensionId, {
|
|
1410
1404
|
status: Error$1 // TODO maybe store error also in runtime status state
|
|
@@ -1419,7 +1413,7 @@ const rpcs = Object.create(null);
|
|
|
1419
1413
|
const add = (id, rpc) => {
|
|
1420
1414
|
rpcs[id] = rpc;
|
|
1421
1415
|
};
|
|
1422
|
-
const get$
|
|
1416
|
+
const get$3 = id => {
|
|
1423
1417
|
return rpcs[id];
|
|
1424
1418
|
};
|
|
1425
1419
|
|
|
@@ -1487,7 +1481,9 @@ const importExtension = async (extensionId, absolutePath, activationEvent) => {
|
|
|
1487
1481
|
});
|
|
1488
1482
|
if (isImportError(error)) {
|
|
1489
1483
|
const actualErrorMessage = await tryToGetActualImportErrorMessage(absolutePath, error);
|
|
1490
|
-
throw new Error(actualErrorMessage
|
|
1484
|
+
throw new Error(actualErrorMessage, {
|
|
1485
|
+
cause: error
|
|
1486
|
+
});
|
|
1491
1487
|
}
|
|
1492
1488
|
throw error;
|
|
1493
1489
|
}
|
|
@@ -1514,6 +1510,12 @@ const activateExtension3 = async (extension, absolutePath, activationEvent, plat
|
|
|
1514
1510
|
const state$1 = {
|
|
1515
1511
|
webExtensions: []
|
|
1516
1512
|
};
|
|
1513
|
+
const push = extension => {
|
|
1514
|
+
state$1.webExtensions.push(extension);
|
|
1515
|
+
};
|
|
1516
|
+
const get$2 = () => {
|
|
1517
|
+
return state$1.webExtensions;
|
|
1518
|
+
};
|
|
1517
1519
|
|
|
1518
1520
|
const cache = Object.create(null);
|
|
1519
1521
|
const id = 1;
|
|
@@ -1557,7 +1559,7 @@ const addWebExtension = async path => {
|
|
|
1557
1559
|
const manifestPath = getWebManifestPath(path);
|
|
1558
1560
|
const manifest = await getWebExtensionManifest(path, manifestPath);
|
|
1559
1561
|
// TODO avoid mutation if possible
|
|
1560
|
-
|
|
1562
|
+
push(manifest);
|
|
1561
1563
|
clear();
|
|
1562
1564
|
return manifest;
|
|
1563
1565
|
};
|
|
@@ -1580,7 +1582,7 @@ const createWebViewWorkerRpc2 = async (rpcInfo, port) => {
|
|
|
1580
1582
|
// the two message ports
|
|
1581
1583
|
|
|
1582
1584
|
// TODO have a way so that the worker already includes the webview api and the extension
|
|
1583
|
-
// host
|
|
1585
|
+
// host sub-worker doesn't need to import the other file
|
|
1584
1586
|
await invokeAndTransfer('IpcParent.create', {
|
|
1585
1587
|
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
|
|
1586
1588
|
name: rpcInfo.name,
|
|
@@ -1610,7 +1612,7 @@ const createWebViewWorkerRpc = async (rpcInfo, port) => {
|
|
|
1610
1612
|
// the two message ports
|
|
1611
1613
|
|
|
1612
1614
|
// TODO have a way so that the worker already includes the webview api and the extension
|
|
1613
|
-
// host
|
|
1615
|
+
// host sub-worker doesn't need to import the other file
|
|
1614
1616
|
await invokeAndTransfer$1('IpcParent.create', {
|
|
1615
1617
|
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
|
|
1616
1618
|
name: rpcInfo.name,
|
|
@@ -1936,7 +1938,7 @@ const getColorThemeUri = (extensions, colorThemeId) => {
|
|
|
1936
1938
|
};
|
|
1937
1939
|
|
|
1938
1940
|
const getDynamicWebExtensions = () => {
|
|
1939
|
-
return
|
|
1941
|
+
return get$2();
|
|
1940
1942
|
};
|
|
1941
1943
|
|
|
1942
1944
|
const getWebExtensionsUrl = assetDir => {
|
|
@@ -2061,7 +2063,7 @@ const createWebViewIpc = async webView => {
|
|
|
2061
2063
|
port1,
|
|
2062
2064
|
port2
|
|
2063
2065
|
} = getPortTuple();
|
|
2064
|
-
const rpcPromise =
|
|
2066
|
+
const rpcPromise = create$3({
|
|
2065
2067
|
commandMap: {},
|
|
2066
2068
|
isMessagePortOpen: false,
|
|
2067
2069
|
messagePort: port2
|
|
@@ -2082,8 +2084,8 @@ const getWebView = id => {
|
|
|
2082
2084
|
// TODO if webViewId is provided,
|
|
2083
2085
|
// 1. read file as blob
|
|
2084
2086
|
// 2. send blob to webview
|
|
2085
|
-
// 3. create
|
|
2086
|
-
// 4. send back
|
|
2087
|
+
// 3. create object URL in webview
|
|
2088
|
+
// 4. send back object URL to extension host worker
|
|
2087
2089
|
// 5. provide objectUrl to extension
|
|
2088
2090
|
|
|
2089
2091
|
const getRemoteUrlForWebView = async (uri, options = {}) => {
|
|
@@ -2098,7 +2100,7 @@ const getRemoteUrlForWebView = async (uri, options = {}) => {
|
|
|
2098
2100
|
};
|
|
2099
2101
|
|
|
2100
2102
|
const getRpcInfo = rpcId => {
|
|
2101
|
-
const info = get$
|
|
2103
|
+
const info = get$3(rpcId);
|
|
2102
2104
|
if (!info) {
|
|
2103
2105
|
throw new Error(`Rpc not found ${rpcId}`);
|
|
2104
2106
|
}
|
|
@@ -2117,20 +2119,20 @@ const emptyStatus = {
|
|
|
2117
2119
|
status: None
|
|
2118
2120
|
};
|
|
2119
2121
|
const getRuntimeStatus = extensionId => {
|
|
2120
|
-
return get$
|
|
2122
|
+
return get$4(extensionId) || emptyStatus;
|
|
2121
2123
|
};
|
|
2122
2124
|
|
|
2123
2125
|
const commandMapRef = {};
|
|
2124
2126
|
|
|
2125
2127
|
const handleMessagePort = async port => {
|
|
2126
|
-
await
|
|
2128
|
+
await create$7({
|
|
2127
2129
|
commandMap: commandMapRef,
|
|
2128
2130
|
messagePort: port
|
|
2129
2131
|
});
|
|
2130
2132
|
};
|
|
2131
2133
|
|
|
2132
2134
|
const initializeExtensionHostWorker = async () => {
|
|
2133
|
-
const rpc = await
|
|
2135
|
+
const rpc = await create$6({
|
|
2134
2136
|
commandMap: commandMapRef,
|
|
2135
2137
|
async send(port) {
|
|
2136
2138
|
await sendMessagePortToExtensionHostWorker(port, 0);
|
|
@@ -2140,7 +2142,7 @@ const initializeExtensionHostWorker = async () => {
|
|
|
2140
2142
|
};
|
|
2141
2143
|
|
|
2142
2144
|
const initializeFileSystemWorker = async () => {
|
|
2143
|
-
const rpc = await
|
|
2145
|
+
const rpc = await create$6({
|
|
2144
2146
|
commandMap: commandMapRef,
|
|
2145
2147
|
async send(port) {
|
|
2146
2148
|
await sendMessagePortToFileSystemWorker(port, 0);
|
|
@@ -2152,14 +2154,14 @@ const initializeFileSystemWorker = async () => {
|
|
|
2152
2154
|
const getRpc = async platform => {
|
|
2153
2155
|
// TODO create connection to shared process
|
|
2154
2156
|
if (platform === Remote) {
|
|
2155
|
-
const rpc = await
|
|
2157
|
+
const rpc = await create$4({
|
|
2156
2158
|
commandMap: commandMapRef,
|
|
2157
2159
|
type: 'shared-process'
|
|
2158
2160
|
});
|
|
2159
2161
|
return rpc;
|
|
2160
2162
|
}
|
|
2161
2163
|
if (platform === Electron) {
|
|
2162
|
-
const rpc =
|
|
2164
|
+
const rpc = create$6({
|
|
2163
2165
|
commandMap: commandMapRef,
|
|
2164
2166
|
async send(port) {
|
|
2165
2167
|
await sendMessagePortToSharedProcess(port);
|
|
@@ -2275,7 +2277,7 @@ const commandMap = {
|
|
|
2275
2277
|
|
|
2276
2278
|
const listen = async () => {
|
|
2277
2279
|
Object.assign(commandMapRef, commandMap);
|
|
2278
|
-
const rpc = await
|
|
2280
|
+
const rpc = await create$2({
|
|
2279
2281
|
commandMap: commandMap
|
|
2280
2282
|
});
|
|
2281
2283
|
set$4(rpc);
|