@lvce-editor/panel-worker 2.12.1 → 2.13.1
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 +29 -19
- package/package.json +1 -1
package/dist/panelWorkerMain.js
CHANGED
|
@@ -1581,12 +1581,8 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1581
1581
|
set$1(uid, state, state);
|
|
1582
1582
|
};
|
|
1583
1583
|
|
|
1584
|
-
const isEqual$2 = (oldState, newState) => {
|
|
1585
|
-
return oldState.actionsUid === newState.actionsUid;
|
|
1586
|
-
};
|
|
1587
|
-
|
|
1588
1584
|
const isEqual$1 = (oldState, newState) => {
|
|
1589
|
-
return oldState.
|
|
1585
|
+
return oldState.actionsUid === newState.actionsUid;
|
|
1590
1586
|
};
|
|
1591
1587
|
|
|
1592
1588
|
const areBadgeCountsEqual = (oldBadgeCounts, newBadgeCounts) => {
|
|
@@ -1600,11 +1596,10 @@ const isEqual = (oldState, newState) => {
|
|
|
1600
1596
|
|
|
1601
1597
|
const RenderItems = 4;
|
|
1602
1598
|
const RenderIncremental = 11;
|
|
1603
|
-
const RenderChildUid = 12;
|
|
1604
1599
|
const RenderActionsUid = 13;
|
|
1605
1600
|
|
|
1606
|
-
const modules = [isEqual, isEqual$1
|
|
1607
|
-
const numbers = [RenderIncremental,
|
|
1601
|
+
const modules = [isEqual, isEqual$1];
|
|
1602
|
+
const numbers = [RenderIncremental, RenderActionsUid];
|
|
1608
1603
|
|
|
1609
1604
|
const diff = (oldState, newState) => {
|
|
1610
1605
|
const diffResult = [];
|
|
@@ -1626,6 +1621,10 @@ const diff2 = uid => {
|
|
|
1626
1621
|
return result;
|
|
1627
1622
|
};
|
|
1628
1623
|
|
|
1624
|
+
const getComponentState = uid => {
|
|
1625
|
+
return get(uid).newState;
|
|
1626
|
+
};
|
|
1627
|
+
|
|
1629
1628
|
const getCurrentViewletId = state => {
|
|
1630
1629
|
const {
|
|
1631
1630
|
currentViewletId
|
|
@@ -1829,6 +1828,9 @@ const openViewlet = async (state, id, focus = false, uri = '') => {
|
|
|
1829
1828
|
const actionsUid = getUid();
|
|
1830
1829
|
const index = views.indexOf(id);
|
|
1831
1830
|
await createViewlet(id, childUid, tabId, actionsUid, childDimensions, uri, focus);
|
|
1831
|
+
if (currentChildUid > 0) {
|
|
1832
|
+
await invoke$1('Viewlet.dispose', currentChildUid);
|
|
1833
|
+
}
|
|
1832
1834
|
return {
|
|
1833
1835
|
...state,
|
|
1834
1836
|
actionsUid,
|
|
@@ -1894,15 +1896,6 @@ const renderActionsUid = (oldState, newState) => {
|
|
|
1894
1896
|
return ['Viewlet.dispose', oldActionsUid];
|
|
1895
1897
|
};
|
|
1896
1898
|
|
|
1897
|
-
// TODO also need to dispose child when panel becomes hidden
|
|
1898
|
-
const renderChildUid = (oldState, newState) => {
|
|
1899
|
-
const oldChildUid = oldState.childUid;
|
|
1900
|
-
if (oldChildUid <= 0 || oldChildUid === newState.childUid) {
|
|
1901
|
-
return [];
|
|
1902
|
-
}
|
|
1903
|
-
return ['Viewlet.dispose', oldChildUid];
|
|
1904
|
-
};
|
|
1905
|
-
|
|
1906
1899
|
const mergeClassNames = (...classNames) => {
|
|
1907
1900
|
return classNames.filter(Boolean).join(' ');
|
|
1908
1901
|
};
|
|
@@ -2371,8 +2364,6 @@ const getRenderer = diffType => {
|
|
|
2371
2364
|
switch (diffType) {
|
|
2372
2365
|
case RenderActionsUid:
|
|
2373
2366
|
return renderActionsUid;
|
|
2374
|
-
case RenderChildUid:
|
|
2375
|
-
return renderChildUid;
|
|
2376
2367
|
case RenderIncremental:
|
|
2377
2368
|
return renderIncremental;
|
|
2378
2369
|
case RenderItems:
|
|
@@ -2475,11 +2466,29 @@ const selectName = async (state, name) => {
|
|
|
2475
2466
|
return selectIndex(state, index);
|
|
2476
2467
|
};
|
|
2477
2468
|
|
|
2469
|
+
const applyComponentState = (currentState, state) => {
|
|
2470
|
+
if (!state || typeof state !== 'object' || Array.isArray(state)) {
|
|
2471
|
+
throw new TypeError('Panel state must be an object');
|
|
2472
|
+
}
|
|
2473
|
+
const {
|
|
2474
|
+
uid
|
|
2475
|
+
} = state;
|
|
2476
|
+
const {
|
|
2477
|
+
uid: currentUid
|
|
2478
|
+
} = currentState;
|
|
2479
|
+
if (uid !== currentUid) {
|
|
2480
|
+
throw new Error(`Panel state uid must remain ${currentUid}`);
|
|
2481
|
+
}
|
|
2482
|
+
return state;
|
|
2483
|
+
};
|
|
2484
|
+
const setComponentState = wrapCommand(applyComponentState);
|
|
2485
|
+
|
|
2478
2486
|
const handleDirectMessagePort = (port, setAsRendererProcess = true) => handleMessagePort(port, commandMap, setAsRendererProcess);
|
|
2479
2487
|
const commandMap = {
|
|
2480
2488
|
'Panel.create': create,
|
|
2481
2489
|
'Panel.diff2': diff2,
|
|
2482
2490
|
'Panel.getCommandIds': getCommandIds,
|
|
2491
|
+
'Panel.getComponentState': getComponentState,
|
|
2483
2492
|
'Panel.getCurrentViewletId': wrapGetter(getCurrentViewletId),
|
|
2484
2493
|
'Panel.handleBlur': wrapCommand(handleBlur),
|
|
2485
2494
|
'Panel.handleClickClose': wrapCommand(handleClickClose),
|
|
@@ -2499,6 +2508,7 @@ const commandMap = {
|
|
|
2499
2508
|
'Panel.selectIndexRaw': wrapCommand(selectRaw),
|
|
2500
2509
|
'Panel.selectName': wrapCommand(selectName),
|
|
2501
2510
|
'Panel.setBadgeCount': wrapCommand(setBadgeCount),
|
|
2511
|
+
'Panel.setComponentState': setComponentState,
|
|
2502
2512
|
'Panel.terminate': terminate,
|
|
2503
2513
|
'Panel.toggleView': wrapCommand(toggleView)
|
|
2504
2514
|
};
|