@lvce-editor/iframe-worker 5.20.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.
@@ -1566,10 +1566,7 @@ const commandMap$1 = {
1566
1566
  'WebView.readFile': readFile
1567
1567
  };
1568
1568
 
1569
- /**
1570
- * @deprecated use getWebViewWorkerRpc2 instead
1571
- */
1572
- const getWebViewWorkerRpc = async rpcInfo => {
1569
+ const getWebViewWorkerRpc2 = async rpcInfo => {
1573
1570
  const {
1574
1571
  port1,
1575
1572
  port2
@@ -1579,15 +1576,32 @@ const getWebViewWorkerRpc = async rpcInfo => {
1579
1576
  messagePort: port2,
1580
1577
  isMessagePortOpen: true
1581
1578
  });
1582
- await invokeAndTransfer$2('WebView.createWebViewWorkerRpc', rpcInfo, port1);
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
1583
  const rpc = await rpcPromise;
1584
1584
  // TODO rpc module should start the port
1585
1585
  port2.start();
1586
1586
  return rpc;
1587
1587
  };
1588
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
+
1589
1603
  const createWebWorkerRpc2 = async (rpcInfo, webView, savedState, uri, portId, webViewUid, origin) => {
1590
- const rpc = await getWebViewWorkerRpc(rpcInfo);
1604
+ const rpc = await getWebViewWorkerRpc2(rpcInfo);
1591
1605
  const webViewInfo = {
1592
1606
  rpc,
1593
1607
  webViewId: webView.id,
@@ -1613,6 +1627,26 @@ const createWebWorkerRpc2 = async (rpcInfo, webView, savedState, uri, portId, we
1613
1627
  });
1614
1628
  };
1615
1629
 
1630
+ /**
1631
+ * @deprecated use getWebViewWorkerRpc2 instead
1632
+ */
1633
+ const getWebViewWorkerRpc = async rpcInfo => {
1634
+ const {
1635
+ port1,
1636
+ port2
1637
+ } = getPortTuple();
1638
+ const rpcPromise = MessagePortRpcParent.create({
1639
+ commandMap: commandMap$1,
1640
+ messagePort: port2,
1641
+ isMessagePortOpen: true
1642
+ });
1643
+ await invokeAndTransfer$2('WebView.createWebViewWorkerRpc', rpcInfo, port1);
1644
+ const rpc = await rpcPromise;
1645
+ // TODO rpc module should start the port
1646
+ port2.start();
1647
+ return rpc;
1648
+ };
1649
+
1616
1650
  const createWebViewRpc$1 = async (rpcInfo, webView, savedState, uri, portId, webViewUid, origin) => {
1617
1651
  // deprecated below
1618
1652
  const rpc = await getWebViewWorkerRpc(rpcInfo);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/iframe-worker",
3
- "version": "5.20.0",
3
+ "version": "5.21.0",
4
4
  "description": "Web Worker to manage creation and lifecycle of iframes in Lvce Editor",
5
5
  "keywords": [
6
6
  "iframe"