@lvce-editor/iframe-worker 5.21.0 → 5.22.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.
@@ -1094,6 +1094,9 @@ const getIframeSrcRemote = (webViews, webViewPort, webViewId, locationProtocol,
1094
1094
  if (!webViewUri) {
1095
1095
  return undefined;
1096
1096
  }
1097
+ if (!webView) {
1098
+ return undefined;
1099
+ }
1097
1100
  let iframeSrc = webViewUri;
1098
1101
  let webViewRoot = webViewUri;
1099
1102
 
@@ -1469,6 +1472,15 @@ const create2 = async ({
1469
1472
  };
1470
1473
  };
1471
1474
 
1475
+ const createAndLoadWebView = async (id, iframeSrc, sandbox, iframeCsp, credentialless, permissionPolicyString, frameTitle) => {
1476
+ await invoke$2('WebView.create', id, iframeSrc, sandbox, iframeCsp, credentialless, permissionPolicyString, frameTitle);
1477
+
1478
+ // TODO maybe iframe waitForLoad is not needed. since it cannot be used detect errors anyway
1479
+ // and causes flash of unstyled content, maybe a better way would be to just send the
1480
+ // port and wait for the first port message
1481
+ await invoke$2('WebView.load', id);
1482
+ };
1483
+
1472
1484
  const invoke = async (method, ...params) => {
1473
1485
  return invoke$4('WebView.compatRendererWorkerInvoke', method, ...params);
1474
1486
  };
@@ -1684,6 +1696,7 @@ const createWebViewRpc = async (webView, savedState, uri, portId, webViewUid, or
1684
1696
  if (rpcInfo && rpcInfo.type === 'web-worker-2') {
1685
1697
  return createWebWorkerRpc2(rpcInfo, webView, savedState, uri, portId, webViewUid, origin);
1686
1698
  }
1699
+ // legacy
1687
1700
  if (rpcInfo.type !== 'web-worker') {
1688
1701
  throw new Error(`only web worker rpc is supported for webviews`);
1689
1702
  }
@@ -1744,8 +1757,6 @@ const create3 = async ({
1744
1757
  return undefined;
1745
1758
  }
1746
1759
  const webView = getWebView(webViews, webViewId);
1747
-
1748
- // TODO move all of this to iframe worker
1749
1760
  const {
1750
1761
  iframeSrc,
1751
1762
  webViewRoot,
@@ -1769,12 +1780,7 @@ const create3 = async ({
1769
1780
  const portId = create$1();
1770
1781
  const remotePathPrefix = '/remote';
1771
1782
  await register(previewServerId, webViewPort, frameAncestors, webViewRoot, csp, iframeContent, platform, webViewId, remotePathPrefix, useNewWebViewHandler);
1772
- await invoke$2('WebView.create', id, iframeSrc, sandbox, iframeCsp, credentialless, permissionPolicyString, frameTitle);
1773
-
1774
- // TODO maybe iframe waitForLoad is not needed. since it cannot be used detect errors anyway
1775
- // and causes flash of unstyled content, maybe a better way would be to just send the
1776
- // port and wait for the first port message
1777
- await invoke$2('WebView.load', id);
1783
+ await createAndLoadWebView(id, iframeSrc, sandbox, iframeCsp, credentialless, permissionPolicyString, frameTitle);
1778
1784
  const origin = getWebViewOrigin(webViewPort, platform, webViewScheme, webViewId);
1779
1785
  const hasOldRpc = !webView || !webView.rpc || typeof webView.rpc !== 'string';
1780
1786
  if (hasOldRpc) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/iframe-worker",
3
- "version": "5.21.0",
3
+ "version": "5.22.0",
4
4
  "description": "Web Worker to manage creation and lifecycle of iframes in Lvce Editor",
5
5
  "keywords": [
6
6
  "iframe"