@lvce-editor/opener-worker 1.1.0 → 1.3.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/openerWorkerMain.js +68 -17
- package/package.json +1 -1
package/dist/openerWorkerMain.js
CHANGED
|
@@ -677,7 +677,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
677
677
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
678
678
|
return create$1(id, errorProperty);
|
|
679
679
|
};
|
|
680
|
-
const create$
|
|
680
|
+
const create$6 = (message, result) => {
|
|
681
681
|
return {
|
|
682
682
|
jsonrpc: Two$1,
|
|
683
683
|
id: message.id,
|
|
@@ -686,7 +686,7 @@ const create$3 = (message, result) => {
|
|
|
686
686
|
};
|
|
687
687
|
const getSuccessResponse = (message, result) => {
|
|
688
688
|
const resultProperty = result ?? null;
|
|
689
|
-
return create$
|
|
689
|
+
return create$6(message, resultProperty);
|
|
690
690
|
};
|
|
691
691
|
const getErrorResponseSimple = (id, error) => {
|
|
692
692
|
return {
|
|
@@ -944,6 +944,26 @@ const PlainMessagePortRpcParent = {
|
|
|
944
944
|
__proto__: null,
|
|
945
945
|
create: create$4
|
|
946
946
|
};
|
|
947
|
+
const create$3 = async ({
|
|
948
|
+
commandMap,
|
|
949
|
+
isMessagePortOpen,
|
|
950
|
+
send
|
|
951
|
+
}) => {
|
|
952
|
+
const {
|
|
953
|
+
port1,
|
|
954
|
+
port2
|
|
955
|
+
} = new MessageChannel();
|
|
956
|
+
await send(port1);
|
|
957
|
+
return create$5({
|
|
958
|
+
commandMap,
|
|
959
|
+
isMessagePortOpen,
|
|
960
|
+
messagePort: port2
|
|
961
|
+
});
|
|
962
|
+
};
|
|
963
|
+
const TransferMessagePortRpcParent = {
|
|
964
|
+
__proto__: null,
|
|
965
|
+
create: create$3
|
|
966
|
+
};
|
|
947
967
|
const create$2 = async ({
|
|
948
968
|
commandMap
|
|
949
969
|
}) => {
|
|
@@ -981,9 +1001,10 @@ const createMockRpc = ({
|
|
|
981
1001
|
const Electron = 2;
|
|
982
1002
|
|
|
983
1003
|
const RendererWorker = 1;
|
|
1004
|
+
const SharedProcess = 1492;
|
|
984
1005
|
|
|
985
1006
|
const rpcs = Object.create(null);
|
|
986
|
-
const set$
|
|
1007
|
+
const set$3 = (id, rpc) => {
|
|
987
1008
|
rpcs[id] = rpc;
|
|
988
1009
|
};
|
|
989
1010
|
const get$1 = id => {
|
|
@@ -1016,7 +1037,7 @@ const create = rpcId => {
|
|
|
1016
1037
|
const mockRpc = createMockRpc({
|
|
1017
1038
|
commandMap
|
|
1018
1039
|
});
|
|
1019
|
-
set$
|
|
1040
|
+
set$3(rpcId, mockRpc);
|
|
1020
1041
|
// @ts-ignore
|
|
1021
1042
|
mockRpc[Symbol.dispose] = () => {
|
|
1022
1043
|
remove(rpcId);
|
|
@@ -1025,15 +1046,26 @@ const create = rpcId => {
|
|
|
1025
1046
|
return mockRpc;
|
|
1026
1047
|
},
|
|
1027
1048
|
set(rpc) {
|
|
1028
|
-
set$
|
|
1049
|
+
set$3(rpcId, rpc);
|
|
1029
1050
|
}
|
|
1030
1051
|
};
|
|
1031
1052
|
};
|
|
1032
1053
|
|
|
1054
|
+
const {
|
|
1055
|
+
invoke: invoke$2,
|
|
1056
|
+
invokeAndTransfer,
|
|
1057
|
+
set: set$2
|
|
1058
|
+
} = create(RendererWorker);
|
|
1059
|
+
const sendMessagePortToSharedProcess = async port => {
|
|
1060
|
+
const command = 'HandleElectronMessagePort.handleElectronMessagePort';
|
|
1061
|
+
// @ts-ignore
|
|
1062
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSharedProcess', port, command, 0);
|
|
1063
|
+
};
|
|
1064
|
+
|
|
1033
1065
|
const {
|
|
1034
1066
|
invoke: invoke$1,
|
|
1035
1067
|
set: set$1
|
|
1036
|
-
} = create(
|
|
1068
|
+
} = create(SharedProcess);
|
|
1037
1069
|
|
|
1038
1070
|
const handleMessagePort = async (port, rpcId) => {
|
|
1039
1071
|
const rpc = await PlainMessagePortRpcParent.create({
|
|
@@ -1041,12 +1073,12 @@ const handleMessagePort = async (port, rpcId) => {
|
|
|
1041
1073
|
messagePort: port
|
|
1042
1074
|
});
|
|
1043
1075
|
if (rpcId) {
|
|
1044
|
-
set$
|
|
1076
|
+
set$3(rpcId, rpc);
|
|
1045
1077
|
}
|
|
1046
1078
|
};
|
|
1047
1079
|
|
|
1048
1080
|
const openNew = async url => {
|
|
1049
|
-
|
|
1081
|
+
await invoke$1('OpenExternal.openExternal', url);
|
|
1050
1082
|
};
|
|
1051
1083
|
|
|
1052
1084
|
let enabled = false;
|
|
@@ -1081,29 +1113,27 @@ const OpenExternal = {
|
|
|
1081
1113
|
openExternal: openExternal$1
|
|
1082
1114
|
};
|
|
1083
1115
|
|
|
1084
|
-
const platform = 0;
|
|
1085
|
-
|
|
1086
1116
|
const openUrlWeb = async url => {
|
|
1087
1117
|
try {
|
|
1088
1118
|
// TODO make platform argument required
|
|
1089
|
-
await invoke$
|
|
1119
|
+
await invoke$2('Open.openUrl', url);
|
|
1090
1120
|
} catch (error) {
|
|
1091
1121
|
throw new VError(error, `Failed to open url ${url}`);
|
|
1092
1122
|
}
|
|
1093
1123
|
};
|
|
1094
1124
|
const openUrlElectron = async url => {
|
|
1095
|
-
await openNew();
|
|
1125
|
+
await openNew(url);
|
|
1096
1126
|
};
|
|
1097
1127
|
|
|
1098
1128
|
// TODO add required platform argument
|
|
1099
|
-
const openUrl = async url => {
|
|
1129
|
+
const openUrl = async (url, platform) => {
|
|
1100
1130
|
if (get()) {
|
|
1101
1131
|
writeUrl(url);
|
|
1102
1132
|
return;
|
|
1103
1133
|
}
|
|
1104
1134
|
switch (platform) {
|
|
1105
1135
|
case Electron:
|
|
1106
|
-
return openUrlElectron();
|
|
1136
|
+
return openUrlElectron(url);
|
|
1107
1137
|
default:
|
|
1108
1138
|
return openUrlWeb(url);
|
|
1109
1139
|
}
|
|
@@ -1119,19 +1149,40 @@ const enable = () => {
|
|
|
1119
1149
|
return set(true);
|
|
1120
1150
|
};
|
|
1121
1151
|
|
|
1152
|
+
const showSaveDialog = (title, properties) => {
|
|
1153
|
+
return invoke$1('ElectronDialog.showSaveDialog', title, properties);
|
|
1154
|
+
};
|
|
1155
|
+
|
|
1122
1156
|
const commandMap = {
|
|
1123
1157
|
'HandleMessagePort.handleMessagePort': handleMessagePort,
|
|
1124
1158
|
'Open.enableMemoryOpener': enable,
|
|
1125
1159
|
'Open.openExternal': openExternal,
|
|
1126
1160
|
'Open.openUrl': openUrl,
|
|
1127
|
-
'Open.readOpenedUrl': readOpenedMemory
|
|
1161
|
+
'Open.readOpenedUrl': readOpenedMemory,
|
|
1162
|
+
'Open.showSaveDialog': showSaveDialog
|
|
1128
1163
|
};
|
|
1129
1164
|
|
|
1130
|
-
const
|
|
1165
|
+
const send = async port => {
|
|
1166
|
+
await sendMessagePortToSharedProcess(port);
|
|
1167
|
+
};
|
|
1168
|
+
const initializeMainProcess = async () => {
|
|
1169
|
+
const rpc = await TransferMessagePortRpcParent.create({
|
|
1170
|
+
commandMap: commandMap,
|
|
1171
|
+
send
|
|
1172
|
+
});
|
|
1173
|
+
set$1(rpc);
|
|
1174
|
+
};
|
|
1175
|
+
|
|
1176
|
+
const initializeRendererWorker = async () => {
|
|
1131
1177
|
const rpc = await WebWorkerRpcClient.create({
|
|
1132
1178
|
commandMap: commandMap
|
|
1133
1179
|
});
|
|
1134
|
-
set$
|
|
1180
|
+
set$2(rpc);
|
|
1181
|
+
};
|
|
1182
|
+
|
|
1183
|
+
const listen = async () => {
|
|
1184
|
+
await initializeRendererWorker();
|
|
1185
|
+
await initializeMainProcess();
|
|
1135
1186
|
};
|
|
1136
1187
|
|
|
1137
1188
|
const main = async () => {
|