@lvce-editor/iframe-worker 5.19.0 → 5.21.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 +80 -8
- package/package.json +1 -1
package/dist/iframeWorkerMain.js
CHANGED
|
@@ -1566,6 +1566,70 @@ const commandMap$1 = {
|
|
|
1566
1566
|
'WebView.readFile': readFile
|
|
1567
1567
|
};
|
|
1568
1568
|
|
|
1569
|
+
const getWebViewWorkerRpc2 = async rpcInfo => {
|
|
1570
|
+
const {
|
|
1571
|
+
port1,
|
|
1572
|
+
port2
|
|
1573
|
+
} = getPortTuple();
|
|
1574
|
+
const rpcPromise = MessagePortRpcParent.create({
|
|
1575
|
+
commandMap: commandMap$1,
|
|
1576
|
+
messagePort: port2,
|
|
1577
|
+
isMessagePortOpen: true
|
|
1578
|
+
});
|
|
1579
|
+
// TODO
|
|
1580
|
+
// 1. ask extension host worker to ask renderer worker to ask renderer process to create a worker with given url
|
|
1581
|
+
// 2. send the port through renderer worker to renderer process to the worker for a direct connection
|
|
1582
|
+
await invokeAndTransfer$2('WebView.createWebViewWorkerRpc2', rpcInfo, port1);
|
|
1583
|
+
const rpc = await rpcPromise;
|
|
1584
|
+
// TODO rpc module should start the port
|
|
1585
|
+
port2.start();
|
|
1586
|
+
return rpc;
|
|
1587
|
+
};
|
|
1588
|
+
|
|
1589
|
+
// TODO not part of this function but, for the webview webworker connection,
|
|
1590
|
+
// send two ports to the iframe
|
|
1591
|
+
// one port for builtin events like ctrl+shift+p keydown event for quickpick
|
|
1592
|
+
// second port for the webview webworker connection
|
|
1593
|
+
|
|
1594
|
+
// this creates in total
|
|
1595
|
+
// 1 iframe
|
|
1596
|
+
// 1 worker
|
|
1597
|
+
// 6 messageports
|
|
1598
|
+
|
|
1599
|
+
// one way to reduce the number of messageports could be to route the worker events
|
|
1600
|
+
// through the iframe worker. However that could introduce some overhead / latency
|
|
1601
|
+
// compared to direct connections
|
|
1602
|
+
|
|
1603
|
+
const createWebWorkerRpc2 = async (rpcInfo, webView, savedState, uri, portId, webViewUid, origin) => {
|
|
1604
|
+
const rpc = await getWebViewWorkerRpc2(rpcInfo);
|
|
1605
|
+
const webViewInfo = {
|
|
1606
|
+
rpc,
|
|
1607
|
+
webViewId: webView.id,
|
|
1608
|
+
portId: portId,
|
|
1609
|
+
webViewUid,
|
|
1610
|
+
origin
|
|
1611
|
+
};
|
|
1612
|
+
set(portId, webViewInfo);
|
|
1613
|
+
|
|
1614
|
+
// TODO this connection might not be needed
|
|
1615
|
+
await createWebViewConnection(webViewUid, origin);
|
|
1616
|
+
const {
|
|
1617
|
+
port1,
|
|
1618
|
+
port2
|
|
1619
|
+
} = getPortTuple();
|
|
1620
|
+
await createSecondaryWebViewConnection(webViewUid, origin, port1);
|
|
1621
|
+
await rpc.invokeAndTransfer('_WebView.setPort', portId, port2);
|
|
1622
|
+
await rpc.invoke('_WebView.create', {
|
|
1623
|
+
id: portId,
|
|
1624
|
+
savedState,
|
|
1625
|
+
webViewId: webView.id,
|
|
1626
|
+
uri
|
|
1627
|
+
});
|
|
1628
|
+
};
|
|
1629
|
+
|
|
1630
|
+
/**
|
|
1631
|
+
* @deprecated use getWebViewWorkerRpc2 instead
|
|
1632
|
+
*/
|
|
1569
1633
|
const getWebViewWorkerRpc = async rpcInfo => {
|
|
1570
1634
|
const {
|
|
1571
1635
|
port1,
|
|
@@ -1583,14 +1647,8 @@ const getWebViewWorkerRpc = async rpcInfo => {
|
|
|
1583
1647
|
return rpc;
|
|
1584
1648
|
};
|
|
1585
1649
|
|
|
1586
|
-
const createWebViewRpc = async (webView, savedState, uri, portId, webViewUid, origin) => {
|
|
1587
|
-
|
|
1588
|
-
return;
|
|
1589
|
-
}
|
|
1590
|
-
const rpcInfo = await invoke$3('WebView.getRpcInfo', webView.rpc);
|
|
1591
|
-
if (rpcInfo.type !== 'web-worker') {
|
|
1592
|
-
throw new Error(`only web worker rpc is supported for webviews`);
|
|
1593
|
-
}
|
|
1650
|
+
const createWebViewRpc$1 = async (rpcInfo, webView, savedState, uri, portId, webViewUid, origin) => {
|
|
1651
|
+
// deprecated below
|
|
1594
1652
|
const rpc = await getWebViewWorkerRpc(rpcInfo);
|
|
1595
1653
|
const webViewInfo = {
|
|
1596
1654
|
rpc,
|
|
@@ -1618,6 +1676,20 @@ const createWebViewRpc = async (webView, savedState, uri, portId, webViewUid, or
|
|
|
1618
1676
|
});
|
|
1619
1677
|
};
|
|
1620
1678
|
|
|
1679
|
+
const createWebViewRpc = async (webView, savedState, uri, portId, webViewUid, origin) => {
|
|
1680
|
+
if (!webView || !webView.rpc || typeof webView.rpc !== 'string') {
|
|
1681
|
+
return;
|
|
1682
|
+
}
|
|
1683
|
+
const rpcInfo = await invoke$3('WebView.getRpcInfo', webView.rpc);
|
|
1684
|
+
if (rpcInfo && rpcInfo.type === 'web-worker-2') {
|
|
1685
|
+
return createWebWorkerRpc2(rpcInfo, webView, savedState, uri, portId, webViewUid, origin);
|
|
1686
|
+
}
|
|
1687
|
+
if (rpcInfo.type !== 'web-worker') {
|
|
1688
|
+
throw new Error(`only web worker rpc is supported for webviews`);
|
|
1689
|
+
}
|
|
1690
|
+
return createWebViewRpc$1(rpcInfo, webView, savedState, uri, portId, webViewUid, origin);
|
|
1691
|
+
};
|
|
1692
|
+
|
|
1621
1693
|
const getPreviewServerId = () => {
|
|
1622
1694
|
// TODO
|
|
1623
1695
|
return 1;
|