@lvce-editor/panel-worker 2.13.1 → 2.13.2
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/panelWorkerMain.js +39 -3
- package/package.json +1 -1
package/dist/panelWorkerMain.js
CHANGED
|
@@ -1791,6 +1791,21 @@ const getUid = () => {
|
|
|
1791
1791
|
return Math.random();
|
|
1792
1792
|
};
|
|
1793
1793
|
|
|
1794
|
+
const pending = new Map();
|
|
1795
|
+
const add = (uid, childUid) => {
|
|
1796
|
+
let children = pending.get(uid);
|
|
1797
|
+
if (!children) {
|
|
1798
|
+
children = new Set();
|
|
1799
|
+
pending.set(uid, children);
|
|
1800
|
+
}
|
|
1801
|
+
children.add(childUid);
|
|
1802
|
+
};
|
|
1803
|
+
const take = uid => {
|
|
1804
|
+
const children = pending.get(uid);
|
|
1805
|
+
pending.delete(uid);
|
|
1806
|
+
return children ? [...children] : [];
|
|
1807
|
+
};
|
|
1808
|
+
|
|
1794
1809
|
const command = 'SaveState.saveViewletStateWithStorageId';
|
|
1795
1810
|
const isCommandNotFoundError = error => {
|
|
1796
1811
|
if (!(error instanceof Error)) {
|
|
@@ -1816,6 +1831,7 @@ const openViewlet = async (state, id, focus = false, uri = '') => {
|
|
|
1816
1831
|
const {
|
|
1817
1832
|
childUid: currentChildUid,
|
|
1818
1833
|
currentViewletId,
|
|
1834
|
+
uid,
|
|
1819
1835
|
views
|
|
1820
1836
|
} = state;
|
|
1821
1837
|
if (!views.includes(id)) {
|
|
@@ -1829,7 +1845,7 @@ const openViewlet = async (state, id, focus = false, uri = '') => {
|
|
|
1829
1845
|
const index = views.indexOf(id);
|
|
1830
1846
|
await createViewlet(id, childUid, tabId, actionsUid, childDimensions, uri, focus);
|
|
1831
1847
|
if (currentChildUid > 0) {
|
|
1832
|
-
|
|
1848
|
+
add(uid, currentChildUid);
|
|
1833
1849
|
}
|
|
1834
1850
|
return {
|
|
1835
1851
|
...state,
|
|
@@ -2385,13 +2401,33 @@ const applyRender = (oldState, newState, diffResult) => {
|
|
|
2385
2401
|
return commands;
|
|
2386
2402
|
};
|
|
2387
2403
|
|
|
2388
|
-
const
|
|
2404
|
+
const hideViewlet = async uid => {
|
|
2405
|
+
try {
|
|
2406
|
+
const commands = await invoke$1('Viewlet.hide', uid);
|
|
2407
|
+
if (Array.isArray(commands)) {
|
|
2408
|
+
return commands;
|
|
2409
|
+
}
|
|
2410
|
+
} catch (error) {
|
|
2411
|
+
// Older renderers do not support deferred container disposal yet.
|
|
2412
|
+
if (!(error instanceof Error) || !error.message.includes('Viewlet.hide') || !error.message.toLowerCase().includes('not found')) {
|
|
2413
|
+
throw error;
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
const commands = await invoke$1('Viewlet.dispose', uid, true);
|
|
2417
|
+
return Array.isArray(commands) ? commands : [];
|
|
2418
|
+
};
|
|
2419
|
+
|
|
2420
|
+
const render2 = async (uid, diffResult) => {
|
|
2389
2421
|
const {
|
|
2390
2422
|
newState,
|
|
2391
2423
|
oldState
|
|
2392
2424
|
} = get(uid);
|
|
2393
2425
|
set$1(uid, newState, newState);
|
|
2394
|
-
const commands = applyRender(oldState, newState, diffResult);
|
|
2426
|
+
const commands = [...applyRender(oldState, newState, diffResult)];
|
|
2427
|
+
// Keep referenced DOM nodes until the parent patches have replaced them.
|
|
2428
|
+
for (const childUid of take(uid)) {
|
|
2429
|
+
commands.push(...(await hideViewlet(childUid)));
|
|
2430
|
+
}
|
|
2395
2431
|
if (!isConnected()) return commands;
|
|
2396
2432
|
return renderDirect(uid, commands);
|
|
2397
2433
|
};
|