@lvce-editor/iframe-worker 5.13.0 → 5.14.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 +29 -2
- package/package.json +1 -1
package/dist/iframeWorkerMain.js
CHANGED
|
@@ -1198,6 +1198,9 @@ const getSavedWebViewState = async id => {
|
|
|
1198
1198
|
if (item && item.key && item.key === id && item.value && item.value.state) {
|
|
1199
1199
|
return item.value.state;
|
|
1200
1200
|
}
|
|
1201
|
+
if (item && item.key && item.key === id && item.value) {
|
|
1202
|
+
return item.value;
|
|
1203
|
+
}
|
|
1201
1204
|
}
|
|
1202
1205
|
return undefined;
|
|
1203
1206
|
};
|
|
@@ -1563,6 +1566,9 @@ const rpcs = Object.create(null);
|
|
|
1563
1566
|
const set = (id, rpc) => {
|
|
1564
1567
|
rpcs[id] = rpc;
|
|
1565
1568
|
};
|
|
1569
|
+
const getAll = () => {
|
|
1570
|
+
return rpcs;
|
|
1571
|
+
};
|
|
1566
1572
|
|
|
1567
1573
|
const createWebViewRpc = async (webView, savedState, uri, portId, webViewUid, origin) => {
|
|
1568
1574
|
if (!webView || !webView.rpc || typeof webView.rpc !== 'string') {
|
|
@@ -1575,7 +1581,8 @@ const createWebViewRpc = async (webView, savedState, uri, portId, webViewUid, or
|
|
|
1575
1581
|
const rpc = await getWebViewWorkerRpc(rpcInfo);
|
|
1576
1582
|
const webViewInfo = {
|
|
1577
1583
|
rpc,
|
|
1578
|
-
webViewId: webView.id
|
|
1584
|
+
webViewId: webView.id,
|
|
1585
|
+
portId: portId
|
|
1579
1586
|
};
|
|
1580
1587
|
set(portId, webViewInfo);
|
|
1581
1588
|
await rpc.invoke('LoadFile.loadFile', rpcInfo.url);
|
|
@@ -1706,9 +1713,29 @@ const create3 = async ({
|
|
|
1706
1713
|
};
|
|
1707
1714
|
};
|
|
1708
1715
|
|
|
1716
|
+
const saveState = async () => {
|
|
1717
|
+
const all = getAll();
|
|
1718
|
+
const serialized = [];
|
|
1719
|
+
for (const value of Object.values(all)) {
|
|
1720
|
+
try {
|
|
1721
|
+
const savedState = await value.rpc.invoke('WebView.saveState', value.portId);
|
|
1722
|
+
serialized.push({
|
|
1723
|
+
key: value.webViewId,
|
|
1724
|
+
value: savedState
|
|
1725
|
+
});
|
|
1726
|
+
} catch (error) {
|
|
1727
|
+
console.log(error);
|
|
1728
|
+
// TODO maybe log the error
|
|
1729
|
+
// ignore
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
return serialized;
|
|
1733
|
+
};
|
|
1734
|
+
|
|
1709
1735
|
const commandMap = {
|
|
1710
1736
|
'WebView.create2': create2,
|
|
1711
|
-
'WebView.create3': create3
|
|
1737
|
+
'WebView.create3': create3,
|
|
1738
|
+
'WebView.saveState': saveState
|
|
1712
1739
|
};
|
|
1713
1740
|
|
|
1714
1741
|
const listen = async () => {
|