@lvce-editor/title-bar-worker 4.22.1 → 4.23.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.
@@ -3372,6 +3372,10 @@ const hydrate = async state => {
3372
3372
  };
3373
3373
  };
3374
3374
 
3375
+ const getComponentState = uid => {
3376
+ return get(uid).newState;
3377
+ };
3378
+
3375
3379
  const mergeClassNames = (...classNames) => {
3376
3380
  return classNames.filter(Boolean).join(' ');
3377
3381
  };
@@ -4802,6 +4806,23 @@ const saveState = state => {
4802
4806
  };
4803
4807
  };
4804
4808
 
4809
+ const applyComponentState = (currentState, state) => {
4810
+ if (!state || typeof state !== 'object' || Array.isArray(state)) {
4811
+ throw new TypeError('Title Bar state must be an object');
4812
+ }
4813
+ const {
4814
+ uid
4815
+ } = state;
4816
+ const {
4817
+ uid: currentUid
4818
+ } = currentState;
4819
+ if (uid !== currentUid) {
4820
+ throw new Error(`Title Bar state uid must remain ${currentUid}`);
4821
+ }
4822
+ return state;
4823
+ };
4824
+ const setComponentState = wrapCommand(applyComponentState);
4825
+
4805
4826
  const setPlatform = (state, platform) => {
4806
4827
  return {
4807
4828
  ...state,
@@ -5522,6 +5543,7 @@ const commandMap = {
5522
5543
  'TitleBar.focusPrevious': wrapCommand(focusPrevious),
5523
5544
  'TitleBar.getCommandIds': getCommandIds,
5524
5545
  'TitleBar.getCommands': getCommandIds,
5546
+ 'TitleBar.getComponentState': getComponentState,
5525
5547
  'TitleBar.getKeyBindings': getKeyBindings,
5526
5548
  'TitleBar.getMenuEntries2': wrapGetter(getMenuEntries2),
5527
5549
  'TitleBar.getMenuIds': getMenuIds,
@@ -5563,6 +5585,7 @@ const commandMap = {
5563
5585
  'TitleBar.renderEventListeners': renderEventListeners,
5564
5586
  'TitleBar.resize': wrapCommand(resize),
5565
5587
  'TitleBar.saveState': wrapGetter(saveState),
5588
+ 'TitleBar.setComponentState': setComponentState,
5566
5589
  'TitleBar.setPlatform': wrapCommand(setPlatform),
5567
5590
  'TitleBar.setTitleTemplate': wrapCommand(setTitleTemplate),
5568
5591
  'TitleBar.setWidth': wrapCommand(setWidth),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/title-bar-worker",
3
- "version": "4.22.1",
3
+ "version": "4.23.0",
4
4
  "description": "Title Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",