@lvce-editor/iframe-worker 5.17.0 → 5.19.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.
@@ -711,7 +711,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
711
711
  const errorProperty = getErrorProperty(error, prettyError);
712
712
  return create$1$1(message, errorProperty);
713
713
  };
714
- const create$6 = (message, result) => {
714
+ const create$5 = (message, result) => {
715
715
  return {
716
716
  jsonrpc: Two,
717
717
  id: message.id,
@@ -720,7 +720,7 @@ const create$6 = (message, result) => {
720
720
  };
721
721
  const getSuccessResponse = (message, result) => {
722
722
  const resultProperty = result ?? null;
723
- return create$6(message, resultProperty);
723
+ return create$5(message, resultProperty);
724
724
  };
725
725
  const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
726
726
  try {
@@ -884,7 +884,7 @@ const listen$1 = async (module, options) => {
884
884
  const ipc = module.wrap(rawIpc);
885
885
  return ipc;
886
886
  };
887
- const create$5 = async ({
887
+ const create$6 = async ({
888
888
  commandMap,
889
889
  messagePort,
890
890
  isMessagePortOpen
@@ -902,7 +902,7 @@ const create$5 = async ({
902
902
  };
903
903
  const MessagePortRpcParent = {
904
904
  __proto__: null,
905
- create: create$5
905
+ create: create$6
906
906
  };
907
907
  const create$2 = async ({
908
908
  commandMap
@@ -1045,13 +1045,17 @@ const getWebViewHtml = (baseUrl, locationOrigin, elements, assetDir) => {
1045
1045
  const middle = [];
1046
1046
  middle.push('<meta charset="utf-8">');
1047
1047
  for (const element of elements) {
1048
- if (element.type === 'title') {
1049
- middle.push(`<title>${element.value}</title>`);
1050
- } else if (element.type === 'script') {
1051
- middle.push(`<script type="module" src="${locationOrigin}${assetDir}/js/preview-injected.js"></script>`);
1052
- middle.push(`<script type="module" src="${locationOrigin}${baseUrl}/${element.path}"></script>`);
1053
- } else if (element.type === 'css') {
1054
- middle.push(`<link rel="stylesheet" href="${locationOrigin}${baseUrl}/${element.path}" />`);
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;
1055
1059
  }
1056
1060
  }
1057
1061
  const middleHtml = middle.join('\n ');
@@ -1313,6 +1317,7 @@ const invokeAndTransfer$1 = async (method, ...params) => {
1313
1317
 
1314
1318
  const WebView = 'lvce-oss-webview';
1315
1319
 
1320
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
1316
1321
  const setPort = async (uid, port, origin, portType) => {
1317
1322
  await invokeAndTransfer$1('WebView.setPort', uid, port, origin, portType);
1318
1323
  };
@@ -1360,17 +1365,13 @@ const register$2 = async (previewServerId, webViewPort, frameAncestors, webViewR
1360
1365
  // TODO pass coop / coep configuration to server
1361
1366
  await create(previewServerId, useNewWebViewHandler); // TODO move this up
1362
1367
  await start(previewServerId, webViewPort); // TODO move this up
1363
- if (useNewWebViewHandler) {
1364
- await setInfo2({
1365
- webViewRoot,
1366
- webViewId,
1367
- contentSecurityPolicy: csp,
1368
- iframeContent,
1369
- remotePathPrefix
1370
- });
1371
- } else {
1372
- await setHandler(previewServerId, frameAncestors, webViewRoot, csp, iframeContent);
1373
- }
1368
+ await (useNewWebViewHandler ? setInfo2({
1369
+ webViewRoot,
1370
+ webViewId,
1371
+ contentSecurityPolicy: csp,
1372
+ iframeContent,
1373
+ remotePathPrefix
1374
+ }) : setHandler(previewServerId, frameAncestors, webViewRoot, csp, iframeContent));
1374
1375
  // TODO make this work in gitpod also
1375
1376
  };
1376
1377
 
@@ -1384,7 +1385,6 @@ const getModule = platform => {
1384
1385
  return register$2;
1385
1386
  case Electron:
1386
1387
  return register$3;
1387
- case Web:
1388
1388
  default:
1389
1389
  return register$1;
1390
1390
  }
@@ -1476,6 +1476,7 @@ const invokeAndTransfer = async (method, ...params) => {
1476
1476
  return invokeAndTransfer$3('WebView.compatRendererWorkerInvokeAndTransfer', method, ...params);
1477
1477
  };
1478
1478
 
1479
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
1479
1480
  const createSecondaryWebViewConnection = async (uid, origin, port) => {
1480
1481
  const portType = 'application';
1481
1482
  await invokeAndTransfer('WebView.setPort', uid, port, origin, portType);
@@ -1727,6 +1728,10 @@ const create3 = async ({
1727
1728
  };
1728
1729
  };
1729
1730
 
1731
+ const getSecret = async key => {
1732
+ return invoke('WebView.getSecret', key);
1733
+ };
1734
+
1730
1735
  const saveState = async () => {
1731
1736
  const all = getAll();
1732
1737
  const serialized = [];
@@ -1738,7 +1743,7 @@ const saveState = async () => {
1738
1743
  value: savedState
1739
1744
  });
1740
1745
  } catch (error) {
1741
- console.log(error);
1746
+ console.error(error);
1742
1747
  // TODO maybe log the error
1743
1748
  // ignore
1744
1749
  }
@@ -1749,7 +1754,8 @@ const saveState = async () => {
1749
1754
  const commandMap = {
1750
1755
  'WebView.create2': create2,
1751
1756
  'WebView.create3': create3,
1752
- 'WebView.saveState': saveState
1757
+ 'WebView.saveState': saveState,
1758
+ 'WebView.getSecret': getSecret
1753
1759
  };
1754
1760
 
1755
1761
  const listen = async () => {
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@lvce-editor/iframe-worker",
3
- "version": "5.17.0",
3
+ "version": "5.19.0",
4
4
  "description": "Web Worker to manage creation and lifecycle of iframes in Lvce Editor",
5
- "main": "dist/iframeWorkerMain.js",
6
- "type": "module",
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
- "keywords": [
12
- "iframe"
13
- ],
12
+ "license": "MIT",
14
13
  "author": "Lvce Editor",
15
- "license": "MIT"
14
+ "type": "module",
15
+ "main": "dist/iframeWorkerMain.js"
16
16
  }