@lvce-editor/iframe-worker 2.3.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/iframeWorkerMain.js +27 -40
- package/package.json +1 -1
package/dist/iframeWorkerMain.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
const Two = '2.0';
|
|
2
|
+
const create$4 = (method, params) => {
|
|
3
|
+
return {
|
|
4
|
+
jsonrpc: Two,
|
|
5
|
+
method,
|
|
6
|
+
params
|
|
7
|
+
};
|
|
8
|
+
};
|
|
2
9
|
const state$2 = {
|
|
3
10
|
callbacks: Object.create(null)
|
|
4
11
|
};
|
|
@@ -230,7 +237,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
|
|
|
230
237
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
231
238
|
return create$1$2(message, errorProperty);
|
|
232
239
|
};
|
|
233
|
-
const create$
|
|
240
|
+
const create$5 = (message, result) => {
|
|
234
241
|
return {
|
|
235
242
|
jsonrpc: Two,
|
|
236
243
|
id: message.id,
|
|
@@ -239,7 +246,7 @@ const create$4 = (message, result) => {
|
|
|
239
246
|
};
|
|
240
247
|
const getSuccessResponse = (message, result) => {
|
|
241
248
|
const resultProperty = result ?? null;
|
|
242
|
-
return create$
|
|
249
|
+
return create$5(message, resultProperty);
|
|
243
250
|
};
|
|
244
251
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
245
252
|
try {
|
|
@@ -328,6 +335,10 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
|
328
335
|
const responseMessage = await promise;
|
|
329
336
|
return unwrapJsonRpcResult(responseMessage);
|
|
330
337
|
};
|
|
338
|
+
const send = (transport, method, ...params) => {
|
|
339
|
+
const message = create$4(method, params);
|
|
340
|
+
transport.send(message);
|
|
341
|
+
};
|
|
331
342
|
const invoke$4 = (ipc, method, ...params) => {
|
|
332
343
|
return invokeHelper(ipc, method, params, false);
|
|
333
344
|
};
|
|
@@ -735,6 +746,12 @@ const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
|
735
746
|
|
|
736
747
|
const createRpc = ipc => {
|
|
737
748
|
const rpc = {
|
|
749
|
+
/**
|
|
750
|
+
* @deprecated
|
|
751
|
+
*/
|
|
752
|
+
send(method, ...params) {
|
|
753
|
+
send(ipc, method, ...params);
|
|
754
|
+
},
|
|
738
755
|
invoke(method, ...params) {
|
|
739
756
|
return invoke$4(ipc, method, ...params);
|
|
740
757
|
},
|
|
@@ -1094,11 +1111,8 @@ const getPortTuple = () => {
|
|
|
1094
1111
|
};
|
|
1095
1112
|
};
|
|
1096
1113
|
|
|
1097
|
-
const getJson = async () => {};
|
|
1098
|
-
|
|
1099
1114
|
const getSavedState = async () => {
|
|
1100
|
-
|
|
1101
|
-
return value;
|
|
1115
|
+
return invoke$3('WebView.getSavedState');
|
|
1102
1116
|
};
|
|
1103
1117
|
|
|
1104
1118
|
const getSavedWebViewState = async id => {
|
|
@@ -1141,7 +1155,7 @@ const getWebViewFrameAncestors = (locationProtocol, locationHost) => {
|
|
|
1141
1155
|
return frameAncestors;
|
|
1142
1156
|
};
|
|
1143
1157
|
|
|
1144
|
-
const getWebViewOrigin = webViewPort => {
|
|
1158
|
+
const getWebViewOrigin = (webViewPort, platform) => {
|
|
1145
1159
|
// TODO don't hardcode protocol
|
|
1146
1160
|
let origin = '';
|
|
1147
1161
|
if (platform === Electron) {
|
|
@@ -1222,11 +1236,6 @@ const register$3 = async previewServerId => {
|
|
|
1222
1236
|
await create(previewServerId); // TODO move this up
|
|
1223
1237
|
};
|
|
1224
1238
|
|
|
1225
|
-
const WebViewProtocolElectron = {
|
|
1226
|
-
__proto__: null,
|
|
1227
|
-
register: register$3
|
|
1228
|
-
};
|
|
1229
|
-
|
|
1230
1239
|
const register$2 = async (previewServerId, webViewPort, frameAncestors, webViewRoot, csp, iframeContent) => {
|
|
1231
1240
|
// TODO apply something similar for electron
|
|
1232
1241
|
// TODO pass webview root, so that only these resources can be accessed
|
|
@@ -1238,34 +1247,24 @@ const register$2 = async (previewServerId, webViewPort, frameAncestors, webViewR
|
|
|
1238
1247
|
// TODO make this work in gitpod also
|
|
1239
1248
|
};
|
|
1240
1249
|
|
|
1241
|
-
const WebViewProtocolRemote = {
|
|
1242
|
-
__proto__: null,
|
|
1243
|
-
register: register$2
|
|
1244
|
-
};
|
|
1245
|
-
|
|
1246
1250
|
const register$1 = async () => {
|
|
1247
1251
|
// noop
|
|
1248
1252
|
};
|
|
1249
1253
|
|
|
1250
|
-
const WebViewProtocolWeb = {
|
|
1251
|
-
__proto__: null,
|
|
1252
|
-
register: register$1
|
|
1253
|
-
};
|
|
1254
|
-
|
|
1255
1254
|
const getModule = platform => {
|
|
1256
1255
|
switch (platform) {
|
|
1257
1256
|
case Remote:
|
|
1258
|
-
return
|
|
1257
|
+
return register$2;
|
|
1259
1258
|
case Electron:
|
|
1260
|
-
return
|
|
1259
|
+
return register$3;
|
|
1261
1260
|
case Web:
|
|
1262
1261
|
default:
|
|
1263
|
-
return
|
|
1262
|
+
return register$1;
|
|
1264
1263
|
}
|
|
1265
1264
|
};
|
|
1266
1265
|
const register = async (previewServerId, webViewPort, frameAncestors, webViewRoot, csp, iframeContent) => {
|
|
1267
|
-
const
|
|
1268
|
-
return
|
|
1266
|
+
const fn = getModule(platform);
|
|
1267
|
+
return fn(previewServerId, webViewPort, frameAncestors, webViewRoot, csp, iframeContent);
|
|
1269
1268
|
};
|
|
1270
1269
|
|
|
1271
1270
|
const create2 = async ({
|
|
@@ -1319,7 +1318,7 @@ const create2 = async ({
|
|
|
1319
1318
|
await register(previewServerId, webViewPort, frameAncestors, webViewRoot, csp, iframeContent);
|
|
1320
1319
|
await invoke$1('WebView.create', id, iframeSrc, sandbox, iframeCsp, credentialless);
|
|
1321
1320
|
await invoke$1('WebView.load', id);
|
|
1322
|
-
const origin = getWebViewOrigin(webViewPort);
|
|
1321
|
+
const origin = getWebViewOrigin(webViewPort, platform);
|
|
1323
1322
|
const portType = '';
|
|
1324
1323
|
await setPort(id, port1, origin, portType);
|
|
1325
1324
|
await invokeAndTransfer$1('ExtensionHostWebView.create', webViewId, port2, uri, id, origin);
|
|
@@ -1336,18 +1335,6 @@ const create2 = async ({
|
|
|
1336
1335
|
};
|
|
1337
1336
|
|
|
1338
1337
|
const commandMap = {
|
|
1339
|
-
// deprecated
|
|
1340
|
-
'Location.getHost': getHost,
|
|
1341
|
-
'Location.getOrigin': getOrigin,
|
|
1342
|
-
'Location.getProtocol': getProtocol,
|
|
1343
|
-
'WebView.getBaseUrl': getWebViewBaseUrl,
|
|
1344
|
-
'WebView.getFrameAncestors': getWebViewFrameAncestors,
|
|
1345
|
-
'WebView.getHtml': getWebViewHtml,
|
|
1346
|
-
'WebView.getIframeSrc': getIframeSrc,
|
|
1347
|
-
'WebView.getOrigin': getWebViewOrigin,
|
|
1348
|
-
'WebView.getSandbox': getIframeSandbox,
|
|
1349
|
-
'WebView.getWebViewCsp': getWebViewCsp,
|
|
1350
|
-
// new
|
|
1351
1338
|
'WebView.create2': create2
|
|
1352
1339
|
};
|
|
1353
1340
|
|