@lvce-editor/panel-worker 2.13.0 → 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 +23 -0
- package/package.json +1 -1
package/dist/panelWorkerMain.js
CHANGED
|
@@ -1621,6 +1621,10 @@ const diff2 = uid => {
|
|
|
1621
1621
|
return result;
|
|
1622
1622
|
};
|
|
1623
1623
|
|
|
1624
|
+
const getComponentState = uid => {
|
|
1625
|
+
return get(uid).newState;
|
|
1626
|
+
};
|
|
1627
|
+
|
|
1624
1628
|
const getCurrentViewletId = state => {
|
|
1625
1629
|
const {
|
|
1626
1630
|
currentViewletId
|
|
@@ -2462,11 +2466,29 @@ const selectName = async (state, name) => {
|
|
|
2462
2466
|
return selectIndex(state, index);
|
|
2463
2467
|
};
|
|
2464
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
|
+
|
|
2465
2486
|
const handleDirectMessagePort = (port, setAsRendererProcess = true) => handleMessagePort(port, commandMap, setAsRendererProcess);
|
|
2466
2487
|
const commandMap = {
|
|
2467
2488
|
'Panel.create': create,
|
|
2468
2489
|
'Panel.diff2': diff2,
|
|
2469
2490
|
'Panel.getCommandIds': getCommandIds,
|
|
2491
|
+
'Panel.getComponentState': getComponentState,
|
|
2470
2492
|
'Panel.getCurrentViewletId': wrapGetter(getCurrentViewletId),
|
|
2471
2493
|
'Panel.handleBlur': wrapCommand(handleBlur),
|
|
2472
2494
|
'Panel.handleClickClose': wrapCommand(handleClickClose),
|
|
@@ -2486,6 +2508,7 @@ const commandMap = {
|
|
|
2486
2508
|
'Panel.selectIndexRaw': wrapCommand(selectRaw),
|
|
2487
2509
|
'Panel.selectName': wrapCommand(selectName),
|
|
2488
2510
|
'Panel.setBadgeCount': wrapCommand(setBadgeCount),
|
|
2511
|
+
'Panel.setComponentState': setComponentState,
|
|
2489
2512
|
'Panel.terminate': terminate,
|
|
2490
2513
|
'Panel.toggleView': wrapCommand(toggleView)
|
|
2491
2514
|
};
|