@lvce-editor/iframe-worker 5.16.0 → 5.18.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 +37 -32
- package/package.json +7 -7
package/dist/iframeWorkerMain.js
CHANGED
|
@@ -483,10 +483,10 @@ const create$4 = (method, params) => {
|
|
|
483
483
|
};
|
|
484
484
|
};
|
|
485
485
|
const callbacks = Object.create(null);
|
|
486
|
-
const set$
|
|
486
|
+
const set$2 = (id, fn) => {
|
|
487
487
|
callbacks[id] = fn;
|
|
488
488
|
};
|
|
489
|
-
const get$
|
|
489
|
+
const get$2 = id => {
|
|
490
490
|
return callbacks[id];
|
|
491
491
|
};
|
|
492
492
|
const remove = id => {
|
|
@@ -502,7 +502,7 @@ const registerPromise = () => {
|
|
|
502
502
|
resolve,
|
|
503
503
|
promise
|
|
504
504
|
} = Promise.withResolvers();
|
|
505
|
-
set$
|
|
505
|
+
set$2(id, resolve);
|
|
506
506
|
return {
|
|
507
507
|
id,
|
|
508
508
|
promise
|
|
@@ -659,7 +659,7 @@ const warn = (...args) => {
|
|
|
659
659
|
console.warn(...args);
|
|
660
660
|
};
|
|
661
661
|
const resolve = (id, response) => {
|
|
662
|
-
const fn = get$
|
|
662
|
+
const fn = get$2(id);
|
|
663
663
|
if (!fn) {
|
|
664
664
|
console.log(response);
|
|
665
665
|
warn(`callback ${id} may already be disposed`);
|
|
@@ -967,20 +967,24 @@ const getAssetDir = () => {
|
|
|
967
967
|
};
|
|
968
968
|
const assetDir = getAssetDir();
|
|
969
969
|
|
|
970
|
-
const
|
|
971
|
-
|
|
970
|
+
const RendererWorker = 1;
|
|
971
|
+
|
|
972
|
+
const rpcs$1 = Object.create(null);
|
|
973
|
+
const set$1 = (id, rpc) => {
|
|
974
|
+
rpcs$1[id] = rpc;
|
|
975
|
+
};
|
|
976
|
+
const get$1 = id => {
|
|
977
|
+
return rpcs$1[id];
|
|
972
978
|
};
|
|
979
|
+
|
|
973
980
|
const invoke$4 = (method, ...params) => {
|
|
974
|
-
const rpc =
|
|
981
|
+
const rpc = get$1(RendererWorker);
|
|
975
982
|
return rpc.invoke(method, ...params);
|
|
976
983
|
};
|
|
977
984
|
const invokeAndTransfer$3 = (method, ...params) => {
|
|
978
|
-
const rpc =
|
|
985
|
+
const rpc = get$1(RendererWorker);
|
|
979
986
|
return rpc.invokeAndTransfer(method, ...params);
|
|
980
987
|
};
|
|
981
|
-
const setRpc = rpc => {
|
|
982
|
-
state$1.rpc = rpc;
|
|
983
|
-
};
|
|
984
988
|
|
|
985
989
|
const invoke$3 = async (method, ...params) => {
|
|
986
990
|
return invoke$4('WebView.compatExtensionHostWorkerInvoke', method, ...params);
|
|
@@ -1041,13 +1045,17 @@ const getWebViewHtml = (baseUrl, locationOrigin, elements, assetDir) => {
|
|
|
1041
1045
|
const middle = [];
|
|
1042
1046
|
middle.push('<meta charset="utf-8">');
|
|
1043
1047
|
for (const element of elements) {
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1048
|
+
switch (element.type) {
|
|
1049
|
+
case 'title':
|
|
1050
|
+
middle.push(`<title>${element.value}</title>`);
|
|
1051
|
+
break;
|
|
1052
|
+
case 'script':
|
|
1053
|
+
middle.push(`<script type="module" src="${locationOrigin}${assetDir}/js/preview-injected.js"></script>`);
|
|
1054
|
+
middle.push(`<script type="module" src="${locationOrigin}${baseUrl}/${element.path}"></script>`);
|
|
1055
|
+
break;
|
|
1056
|
+
case 'css':
|
|
1057
|
+
middle.push(`<link rel="stylesheet" href="${locationOrigin}${baseUrl}/${element.path}" />`);
|
|
1058
|
+
break;
|
|
1051
1059
|
}
|
|
1052
1060
|
}
|
|
1053
1061
|
const middleHtml = middle.join('\n ');
|
|
@@ -1309,6 +1317,7 @@ const invokeAndTransfer$1 = async (method, ...params) => {
|
|
|
1309
1317
|
|
|
1310
1318
|
const WebView = 'lvce-oss-webview';
|
|
1311
1319
|
|
|
1320
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
1312
1321
|
const setPort = async (uid, port, origin, portType) => {
|
|
1313
1322
|
await invokeAndTransfer$1('WebView.setPort', uid, port, origin, portType);
|
|
1314
1323
|
};
|
|
@@ -1356,17 +1365,13 @@ const register$2 = async (previewServerId, webViewPort, frameAncestors, webViewR
|
|
|
1356
1365
|
// TODO pass coop / coep configuration to server
|
|
1357
1366
|
await create(previewServerId, useNewWebViewHandler); // TODO move this up
|
|
1358
1367
|
await start(previewServerId, webViewPort); // TODO move this up
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
});
|
|
1367
|
-
} else {
|
|
1368
|
-
await setHandler(previewServerId, frameAncestors, webViewRoot, csp, iframeContent);
|
|
1369
|
-
}
|
|
1368
|
+
await (useNewWebViewHandler ? setInfo2({
|
|
1369
|
+
webViewRoot,
|
|
1370
|
+
webViewId,
|
|
1371
|
+
contentSecurityPolicy: csp,
|
|
1372
|
+
iframeContent,
|
|
1373
|
+
remotePathPrefix
|
|
1374
|
+
}) : setHandler(previewServerId, frameAncestors, webViewRoot, csp, iframeContent));
|
|
1370
1375
|
// TODO make this work in gitpod also
|
|
1371
1376
|
};
|
|
1372
1377
|
|
|
@@ -1380,7 +1385,6 @@ const getModule = platform => {
|
|
|
1380
1385
|
return register$2;
|
|
1381
1386
|
case Electron:
|
|
1382
1387
|
return register$3;
|
|
1383
|
-
case Web:
|
|
1384
1388
|
default:
|
|
1385
1389
|
return register$1;
|
|
1386
1390
|
}
|
|
@@ -1472,6 +1476,7 @@ const invokeAndTransfer = async (method, ...params) => {
|
|
|
1472
1476
|
return invokeAndTransfer$3('WebView.compatRendererWorkerInvokeAndTransfer', method, ...params);
|
|
1473
1477
|
};
|
|
1474
1478
|
|
|
1479
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
1475
1480
|
const createSecondaryWebViewConnection = async (uid, origin, port) => {
|
|
1476
1481
|
const portType = 'application';
|
|
1477
1482
|
await invokeAndTransfer('WebView.setPort', uid, port, origin, portType);
|
|
@@ -1734,7 +1739,7 @@ const saveState = async () => {
|
|
|
1734
1739
|
value: savedState
|
|
1735
1740
|
});
|
|
1736
1741
|
} catch (error) {
|
|
1737
|
-
console.
|
|
1742
|
+
console.error(error);
|
|
1738
1743
|
// TODO maybe log the error
|
|
1739
1744
|
// ignore
|
|
1740
1745
|
}
|
|
@@ -1752,7 +1757,7 @@ const listen = async () => {
|
|
|
1752
1757
|
const rpc = await WebWorkerRpcClient.create({
|
|
1753
1758
|
commandMap: commandMap
|
|
1754
1759
|
});
|
|
1755
|
-
|
|
1760
|
+
set$1(RendererWorker, rpc);
|
|
1756
1761
|
};
|
|
1757
1762
|
|
|
1758
1763
|
const main = async () => {
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/iframe-worker",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.18.0",
|
|
4
4
|
"description": "Web Worker to manage creation and lifecycle of iframes in Lvce Editor",
|
|
5
|
-
"
|
|
6
|
-
|
|
5
|
+
"keywords": [
|
|
6
|
+
"iframe"
|
|
7
|
+
],
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
9
10
|
"url": "git@github.com:lvce-editor/iframe-worker.git"
|
|
10
11
|
},
|
|
11
|
-
"
|
|
12
|
-
"iframe"
|
|
13
|
-
],
|
|
12
|
+
"license": "MIT",
|
|
14
13
|
"author": "Lvce Editor",
|
|
15
|
-
"
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "dist/iframeWorkerMain.js"
|
|
16
16
|
}
|