@lvce-editor/title-bar-worker 4.17.1 → 4.18.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.
@@ -3548,9 +3548,19 @@ const set = rpc => {
3548
3548
  state.connected = true;
3549
3549
  };
3550
3550
 
3551
- const handleMessagePort = async port => {
3551
+ const handleMessagePort = async (port, viewletCommandMap) => {
3552
+ const executeViewletCommand = async (uid, command, ...args) => {
3553
+ const fn = viewletCommandMap[`TitleBar.${command}`];
3554
+ if (typeof fn !== 'function') {
3555
+ throw new TypeError(`Viewlet command not found: ${command}`);
3556
+ }
3557
+ await fn(uid, ...args);
3558
+ await invoke$1('Viewlet.requestRender', uid);
3559
+ };
3552
3560
  const rpc = await create$5({
3553
- commandMap: {},
3561
+ commandMap: {
3562
+ 'Viewlet.executeViewletCommand': executeViewletCommand
3563
+ },
3554
3564
  messagePort: port
3555
3565
  });
3556
3566
  set(rpc);
@@ -4958,7 +4968,14 @@ const handleFocus = async state => {
4958
4968
  };
4959
4969
 
4960
4970
  const handleFocusOut = async state => {
4961
- return state;
4971
+ const closedState = closeMenu(state, /* keepFocus */false);
4972
+ if (!closedState.focused) {
4973
+ return closedState;
4974
+ }
4975
+ return {
4976
+ ...closedState,
4977
+ focused: false
4978
+ };
4962
4979
  };
4963
4980
 
4964
4981
  const openMenu = async (state, focus) => {
@@ -5445,6 +5462,7 @@ const wakeUp = sleepState => {
5445
5462
  set$1(sleepState.uid, sleepState, sleepState);
5446
5463
  };
5447
5464
 
5465
+ const handleDirectMessagePort = port => handleMessagePort(port, commandMap);
5448
5466
  const commandMap = {
5449
5467
  'TitleBar.closeMenu': wrapCommand(closeMenu),
5450
5468
  'TitleBar.create': create,
@@ -5485,7 +5503,7 @@ const commandMap = {
5485
5503
  'TitleBar.handleKeySpace': wrapCommand(handleKeySpace),
5486
5504
  'TitleBar.handleMenuClick': wrapCommand(handleMenuClick),
5487
5505
  'TitleBar.handleMenuMouseOver': wrapCommand(handleMenuMouseOver),
5488
- 'TitleBar.handleMessagePort': handleMessagePort,
5506
+ 'TitleBar.handleMessagePort': handleDirectMessagePort,
5489
5507
  'TitleBar.handleMouseOut': wrapCommand(handleMouseOut),
5490
5508
  'TitleBar.handleMouseOver': wrapCommand(handleMouseOver),
5491
5509
  'TitleBar.handlePointerOut': wrapCommand(handlePointerOut),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/title-bar-worker",
3
- "version": "4.17.1",
3
+ "version": "4.18.0",
4
4
  "description": "Title Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",