@lvce-editor/preview-sandbox-worker 4.4.0 → 4.6.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/previewSandBoxWorkerMain.js +91 -17
- package/package.json +1 -1
|
@@ -741,7 +741,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
741
741
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
742
742
|
return create$1$1(id, errorProperty);
|
|
743
743
|
};
|
|
744
|
-
const create$
|
|
744
|
+
const create$8 = (message, result) => {
|
|
745
745
|
return {
|
|
746
746
|
id: message.id,
|
|
747
747
|
jsonrpc: Two$1,
|
|
@@ -750,7 +750,7 @@ const create$6 = (message, result) => {
|
|
|
750
750
|
};
|
|
751
751
|
const getSuccessResponse = (message, result) => {
|
|
752
752
|
const resultProperty = result ?? null;
|
|
753
|
-
return create$
|
|
753
|
+
return create$8(message, resultProperty);
|
|
754
754
|
};
|
|
755
755
|
const getErrorResponseSimple = (id, error) => {
|
|
756
756
|
return {
|
|
@@ -844,7 +844,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
844
844
|
|
|
845
845
|
const Two = '2.0';
|
|
846
846
|
|
|
847
|
-
const create$
|
|
847
|
+
const create$7 = (method, params) => {
|
|
848
848
|
return {
|
|
849
849
|
jsonrpc: Two,
|
|
850
850
|
method,
|
|
@@ -852,7 +852,7 @@ const create$5 = (method, params) => {
|
|
|
852
852
|
};
|
|
853
853
|
};
|
|
854
854
|
|
|
855
|
-
const create$
|
|
855
|
+
const create$6 = (id, method, params) => {
|
|
856
856
|
const message = {
|
|
857
857
|
id,
|
|
858
858
|
jsonrpc: Two,
|
|
@@ -863,12 +863,12 @@ const create$4 = (id, method, params) => {
|
|
|
863
863
|
};
|
|
864
864
|
|
|
865
865
|
let id$1 = 0;
|
|
866
|
-
const create$
|
|
866
|
+
const create$5 = () => {
|
|
867
867
|
return ++id$1;
|
|
868
868
|
};
|
|
869
869
|
|
|
870
870
|
const registerPromise = map => {
|
|
871
|
-
const id = create$
|
|
871
|
+
const id = create$5();
|
|
872
872
|
const {
|
|
873
873
|
promise,
|
|
874
874
|
resolve
|
|
@@ -885,7 +885,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
885
885
|
id,
|
|
886
886
|
promise
|
|
887
887
|
} = registerPromise(callbacks);
|
|
888
|
-
const message = create$
|
|
888
|
+
const message = create$6(id, method, params);
|
|
889
889
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
890
890
|
ipc.sendAndTransfer(message);
|
|
891
891
|
} else {
|
|
@@ -921,7 +921,7 @@ const createRpc = ipc => {
|
|
|
921
921
|
* @deprecated
|
|
922
922
|
*/
|
|
923
923
|
send(method, ...params) {
|
|
924
|
-
const message = create$
|
|
924
|
+
const message = create$7(method, params);
|
|
925
925
|
ipc.send(message);
|
|
926
926
|
}
|
|
927
927
|
};
|
|
@@ -961,7 +961,7 @@ const listen$1 = async (module, options) => {
|
|
|
961
961
|
return ipc;
|
|
962
962
|
};
|
|
963
963
|
|
|
964
|
-
const create$
|
|
964
|
+
const create$4 = async ({
|
|
965
965
|
commandMap,
|
|
966
966
|
isMessagePortOpen = true,
|
|
967
967
|
messagePort
|
|
@@ -979,6 +979,65 @@ const create$2 = async ({
|
|
|
979
979
|
return rpc;
|
|
980
980
|
};
|
|
981
981
|
|
|
982
|
+
const create$3 = async ({
|
|
983
|
+
commandMap,
|
|
984
|
+
isMessagePortOpen,
|
|
985
|
+
send
|
|
986
|
+
}) => {
|
|
987
|
+
const {
|
|
988
|
+
port1,
|
|
989
|
+
port2
|
|
990
|
+
} = new MessageChannel();
|
|
991
|
+
await send(port1);
|
|
992
|
+
return create$4({
|
|
993
|
+
commandMap,
|
|
994
|
+
isMessagePortOpen,
|
|
995
|
+
messagePort: port2
|
|
996
|
+
});
|
|
997
|
+
};
|
|
998
|
+
|
|
999
|
+
const createSharedLazyRpc = factory => {
|
|
1000
|
+
let rpcPromise;
|
|
1001
|
+
const getOrCreate = () => {
|
|
1002
|
+
if (!rpcPromise) {
|
|
1003
|
+
rpcPromise = factory();
|
|
1004
|
+
}
|
|
1005
|
+
return rpcPromise;
|
|
1006
|
+
};
|
|
1007
|
+
return {
|
|
1008
|
+
async dispose() {
|
|
1009
|
+
const rpc = await getOrCreate();
|
|
1010
|
+
await rpc.dispose();
|
|
1011
|
+
},
|
|
1012
|
+
async invoke(method, ...params) {
|
|
1013
|
+
const rpc = await getOrCreate();
|
|
1014
|
+
return rpc.invoke(method, ...params);
|
|
1015
|
+
},
|
|
1016
|
+
async invokeAndTransfer(method, ...params) {
|
|
1017
|
+
const rpc = await getOrCreate();
|
|
1018
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1019
|
+
},
|
|
1020
|
+
async send(method, ...params) {
|
|
1021
|
+
const rpc = await getOrCreate();
|
|
1022
|
+
rpc.send(method, ...params);
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
};
|
|
1026
|
+
|
|
1027
|
+
const create$2 = async ({
|
|
1028
|
+
commandMap,
|
|
1029
|
+
isMessagePortOpen,
|
|
1030
|
+
send
|
|
1031
|
+
}) => {
|
|
1032
|
+
return createSharedLazyRpc(() => {
|
|
1033
|
+
return create$3({
|
|
1034
|
+
commandMap,
|
|
1035
|
+
isMessagePortOpen,
|
|
1036
|
+
send
|
|
1037
|
+
});
|
|
1038
|
+
});
|
|
1039
|
+
};
|
|
1040
|
+
|
|
982
1041
|
const create$1 = async ({
|
|
983
1042
|
commandMap
|
|
984
1043
|
}) => {
|
|
@@ -1011,7 +1070,7 @@ const createMockRpc = ({
|
|
|
1011
1070
|
};
|
|
1012
1071
|
|
|
1013
1072
|
const rpcs = Object.create(null);
|
|
1014
|
-
const set$
|
|
1073
|
+
const set$5 = (id, rpc) => {
|
|
1015
1074
|
rpcs[id] = rpc;
|
|
1016
1075
|
};
|
|
1017
1076
|
const get$1 = id => {
|
|
@@ -1044,7 +1103,7 @@ const create = rpcId => {
|
|
|
1044
1103
|
const mockRpc = createMockRpc({
|
|
1045
1104
|
commandMap
|
|
1046
1105
|
});
|
|
1047
|
-
set$
|
|
1106
|
+
set$5(rpcId, mockRpc);
|
|
1048
1107
|
// @ts-ignore
|
|
1049
1108
|
mockRpc[Symbol.dispose] = () => {
|
|
1050
1109
|
remove(rpcId);
|
|
@@ -1053,7 +1112,7 @@ const create = rpcId => {
|
|
|
1053
1112
|
return mockRpc;
|
|
1054
1113
|
},
|
|
1055
1114
|
set(rpc) {
|
|
1056
|
-
set$
|
|
1115
|
+
set$5(rpcId, rpc);
|
|
1057
1116
|
}
|
|
1058
1117
|
};
|
|
1059
1118
|
};
|
|
@@ -1113,17 +1172,27 @@ const Html = 73;
|
|
|
1113
1172
|
const Canvas$1 = 77;
|
|
1114
1173
|
const Reference = 100;
|
|
1115
1174
|
|
|
1175
|
+
const DialogWorker = 7014;
|
|
1116
1176
|
const RendererWorker = 1;
|
|
1117
1177
|
|
|
1118
1178
|
const {
|
|
1119
1179
|
invoke: invoke$1,
|
|
1180
|
+
set: set$4
|
|
1181
|
+
} = create(DialogWorker);
|
|
1182
|
+
|
|
1183
|
+
const {
|
|
1184
|
+
invoke,
|
|
1120
1185
|
set: set$3
|
|
1121
1186
|
} = create(3211);
|
|
1122
1187
|
|
|
1123
1188
|
const {
|
|
1124
|
-
|
|
1189
|
+
invokeAndTransfer,
|
|
1125
1190
|
set: set$2
|
|
1126
1191
|
} = create(RendererWorker);
|
|
1192
|
+
const sendMessagePortToDialogWorker = async port => {
|
|
1193
|
+
const command = 'HandleMessagePort.handleMessagePort';
|
|
1194
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
|
|
1195
|
+
};
|
|
1127
1196
|
|
|
1128
1197
|
const terminate = () => {
|
|
1129
1198
|
globalThis.close();
|
|
@@ -1214,7 +1283,7 @@ const getOffscreenCanvas = async (uid, width, height) => {
|
|
|
1214
1283
|
id,
|
|
1215
1284
|
promise
|
|
1216
1285
|
} = registerCallback();
|
|
1217
|
-
await invoke
|
|
1286
|
+
await invoke('Preview.createOffscreenCanvas', uid, id, width, height);
|
|
1218
1287
|
const [offscreenCanvas, canvasId] = await promise;
|
|
1219
1288
|
return {
|
|
1220
1289
|
canvasId,
|
|
@@ -1895,7 +1964,7 @@ const handleKeyup = (uid, hdId, key, code) => {
|
|
|
1895
1964
|
};
|
|
1896
1965
|
|
|
1897
1966
|
const handleMessagePort = async port => {
|
|
1898
|
-
const rpc = await create$
|
|
1967
|
+
const rpc = await create$4({
|
|
1899
1968
|
commandMap: {},
|
|
1900
1969
|
messagePort: port
|
|
1901
1970
|
});
|
|
@@ -89876,7 +89945,7 @@ const getErrorCodeFrame = (scriptContent, error, contextLines = 2) => {
|
|
|
89876
89945
|
};
|
|
89877
89946
|
|
|
89878
89947
|
const alert = message => {
|
|
89879
|
-
void invoke('ConfirmPrompt.prompt', message);
|
|
89948
|
+
void invoke$1('ConfirmPrompt.prompt', message);
|
|
89880
89949
|
};
|
|
89881
89950
|
|
|
89882
89951
|
const createLocalStorage = () => {
|
|
@@ -90124,7 +90193,7 @@ const handleMutations = async uid => {
|
|
|
90124
90193
|
});
|
|
90125
90194
|
getParsedNodesChildNodeCount(serialized.dom);
|
|
90126
90195
|
try {
|
|
90127
|
-
await invoke
|
|
90196
|
+
await invoke('Preview.handleMutation', uid);
|
|
90128
90197
|
} catch (error) {
|
|
90129
90198
|
console.error(error);
|
|
90130
90199
|
// ignore
|
|
@@ -90471,6 +90540,11 @@ const listen = async () => {
|
|
|
90471
90540
|
commandMap: commandMap
|
|
90472
90541
|
});
|
|
90473
90542
|
set$2(rpc);
|
|
90543
|
+
const dialogRpc = await create$2({
|
|
90544
|
+
commandMap: {},
|
|
90545
|
+
send: sendMessagePortToDialogWorker
|
|
90546
|
+
});
|
|
90547
|
+
set$4(dialogRpc);
|
|
90474
90548
|
};
|
|
90475
90549
|
|
|
90476
90550
|
const main = async () => {
|