@lvce-editor/iframe-worker 5.19.0 → 5.20.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 +46 -8
- package/package.json +1 -1
package/dist/iframeWorkerMain.js
CHANGED
|
@@ -1566,6 +1566,9 @@ const commandMap$1 = {
|
|
|
1566
1566
|
'WebView.readFile': readFile
|
|
1567
1567
|
};
|
|
1568
1568
|
|
|
1569
|
+
/**
|
|
1570
|
+
* @deprecated use getWebViewWorkerRpc2 instead
|
|
1571
|
+
*/
|
|
1569
1572
|
const getWebViewWorkerRpc = async rpcInfo => {
|
|
1570
1573
|
const {
|
|
1571
1574
|
port1,
|
|
@@ -1583,14 +1586,35 @@ const getWebViewWorkerRpc = async rpcInfo => {
|
|
|
1583
1586
|
return rpc;
|
|
1584
1587
|
};
|
|
1585
1588
|
|
|
1586
|
-
const
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1589
|
+
const createWebWorkerRpc2 = async (rpcInfo, webView, savedState, uri, portId, webViewUid, origin) => {
|
|
1590
|
+
const rpc = await getWebViewWorkerRpc(rpcInfo);
|
|
1591
|
+
const webViewInfo = {
|
|
1592
|
+
rpc,
|
|
1593
|
+
webViewId: webView.id,
|
|
1594
|
+
portId: portId,
|
|
1595
|
+
webViewUid,
|
|
1596
|
+
origin
|
|
1597
|
+
};
|
|
1598
|
+
set(portId, webViewInfo);
|
|
1599
|
+
|
|
1600
|
+
// TODO this connection might not be needed
|
|
1601
|
+
await createWebViewConnection(webViewUid, origin);
|
|
1602
|
+
const {
|
|
1603
|
+
port1,
|
|
1604
|
+
port2
|
|
1605
|
+
} = getPortTuple();
|
|
1606
|
+
await createSecondaryWebViewConnection(webViewUid, origin, port1);
|
|
1607
|
+
await rpc.invokeAndTransfer('_WebView.setPort', portId, port2);
|
|
1608
|
+
await rpc.invoke('_WebView.create', {
|
|
1609
|
+
id: portId,
|
|
1610
|
+
savedState,
|
|
1611
|
+
webViewId: webView.id,
|
|
1612
|
+
uri
|
|
1613
|
+
});
|
|
1614
|
+
};
|
|
1615
|
+
|
|
1616
|
+
const createWebViewRpc$1 = async (rpcInfo, webView, savedState, uri, portId, webViewUid, origin) => {
|
|
1617
|
+
// deprecated below
|
|
1594
1618
|
const rpc = await getWebViewWorkerRpc(rpcInfo);
|
|
1595
1619
|
const webViewInfo = {
|
|
1596
1620
|
rpc,
|
|
@@ -1618,6 +1642,20 @@ const createWebViewRpc = async (webView, savedState, uri, portId, webViewUid, or
|
|
|
1618
1642
|
});
|
|
1619
1643
|
};
|
|
1620
1644
|
|
|
1645
|
+
const createWebViewRpc = async (webView, savedState, uri, portId, webViewUid, origin) => {
|
|
1646
|
+
if (!webView || !webView.rpc || typeof webView.rpc !== 'string') {
|
|
1647
|
+
return;
|
|
1648
|
+
}
|
|
1649
|
+
const rpcInfo = await invoke$3('WebView.getRpcInfo', webView.rpc);
|
|
1650
|
+
if (rpcInfo && rpcInfo.type === 'web-worker-2') {
|
|
1651
|
+
return createWebWorkerRpc2(rpcInfo, webView, savedState, uri, portId, webViewUid, origin);
|
|
1652
|
+
}
|
|
1653
|
+
if (rpcInfo.type !== 'web-worker') {
|
|
1654
|
+
throw new Error(`only web worker rpc is supported for webviews`);
|
|
1655
|
+
}
|
|
1656
|
+
return createWebViewRpc$1(rpcInfo, webView, savedState, uri, portId, webViewUid, origin);
|
|
1657
|
+
};
|
|
1658
|
+
|
|
1621
1659
|
const getPreviewServerId = () => {
|
|
1622
1660
|
// TODO
|
|
1623
1661
|
return 1;
|