@lvce-editor/iframe-worker 5.15.0 → 5.16.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 +23 -21
- package/package.json +1 -1
package/dist/iframeWorkerMain.js
CHANGED
|
@@ -486,7 +486,7 @@ const callbacks = Object.create(null);
|
|
|
486
486
|
const set$1 = (id, fn) => {
|
|
487
487
|
callbacks[id] = fn;
|
|
488
488
|
};
|
|
489
|
-
const get = id => {
|
|
489
|
+
const get$1 = id => {
|
|
490
490
|
return callbacks[id];
|
|
491
491
|
};
|
|
492
492
|
const remove = id => {
|
|
@@ -659,7 +659,7 @@ const warn = (...args) => {
|
|
|
659
659
|
console.warn(...args);
|
|
660
660
|
};
|
|
661
661
|
const resolve = (id, response) => {
|
|
662
|
-
const fn = get(id);
|
|
662
|
+
const fn = get$1(id);
|
|
663
663
|
if (!fn) {
|
|
664
664
|
console.log(response);
|
|
665
665
|
warn(`callback ${id} may already be disposed`);
|
|
@@ -1507,6 +1507,17 @@ const getProtocol = uri => {
|
|
|
1507
1507
|
return '';
|
|
1508
1508
|
};
|
|
1509
1509
|
|
|
1510
|
+
const rpcs = Object.create(null);
|
|
1511
|
+
const set = (id, rpc) => {
|
|
1512
|
+
rpcs[id] = rpc;
|
|
1513
|
+
};
|
|
1514
|
+
const get = id => {
|
|
1515
|
+
return rpcs[id];
|
|
1516
|
+
};
|
|
1517
|
+
const getAll = () => {
|
|
1518
|
+
return rpcs;
|
|
1519
|
+
};
|
|
1520
|
+
|
|
1510
1521
|
// TODO if webViewId is provided,
|
|
1511
1522
|
// 1. read file as blob
|
|
1512
1523
|
// 2. send blob to webview
|
|
@@ -1515,15 +1526,12 @@ const getProtocol = uri => {
|
|
|
1515
1526
|
// 5. provide objectUrl to extension
|
|
1516
1527
|
|
|
1517
1528
|
const getRemoteUrlForWebView = async options => {
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
// const [rpc, blob] = await Promise.all([CreateWebViewIpc.createWebViewIpc(webView), Rpc.invoke('FileSystem.getBlob', uri)])
|
|
1525
|
-
// const objectUrl = await rpc.invoke('createObjectUrl', blob)
|
|
1526
|
-
// return objectUrl
|
|
1529
|
+
const webView = get(options.id);
|
|
1530
|
+
const rpcPromise = createWebViewConnection(webView.webViewUid, webView.origin);
|
|
1531
|
+
const blobPromise = invoke('FileSystem.getBlob', options.uri);
|
|
1532
|
+
const [rpc, blob] = await Promise.all([rpcPromise, blobPromise]);
|
|
1533
|
+
const objectUrl = await rpc.invoke('createObjectUrl', blob);
|
|
1534
|
+
return objectUrl;
|
|
1527
1535
|
};
|
|
1528
1536
|
|
|
1529
1537
|
const getRemoteUrl = async options => {
|
|
@@ -1545,7 +1553,7 @@ const getRemoteUrl = async options => {
|
|
|
1545
1553
|
}
|
|
1546
1554
|
return `/remote/${uri}`;
|
|
1547
1555
|
}
|
|
1548
|
-
return getRemoteUrlForWebView();
|
|
1556
|
+
return getRemoteUrlForWebView(options);
|
|
1549
1557
|
};
|
|
1550
1558
|
|
|
1551
1559
|
const commandMap$1 = {
|
|
@@ -1570,14 +1578,6 @@ const getWebViewWorkerRpc = async rpcInfo => {
|
|
|
1570
1578
|
return rpc;
|
|
1571
1579
|
};
|
|
1572
1580
|
|
|
1573
|
-
const rpcs = Object.create(null);
|
|
1574
|
-
const set = (id, rpc) => {
|
|
1575
|
-
rpcs[id] = rpc;
|
|
1576
|
-
};
|
|
1577
|
-
const getAll = () => {
|
|
1578
|
-
return rpcs;
|
|
1579
|
-
};
|
|
1580
|
-
|
|
1581
1581
|
const createWebViewRpc = async (webView, savedState, uri, portId, webViewUid, origin) => {
|
|
1582
1582
|
if (!webView || !webView.rpc || typeof webView.rpc !== 'string') {
|
|
1583
1583
|
return;
|
|
@@ -1590,7 +1590,9 @@ const createWebViewRpc = async (webView, savedState, uri, portId, webViewUid, or
|
|
|
1590
1590
|
const webViewInfo = {
|
|
1591
1591
|
rpc,
|
|
1592
1592
|
webViewId: webView.id,
|
|
1593
|
-
portId: portId
|
|
1593
|
+
portId: portId,
|
|
1594
|
+
webViewUid,
|
|
1595
|
+
origin
|
|
1594
1596
|
};
|
|
1595
1597
|
set(portId, webViewInfo);
|
|
1596
1598
|
await rpc.invoke('LoadFile.loadFile', rpcInfo.url);
|