@lvce-editor/menu-worker 2.2.0 → 3.1.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.
@@ -1377,6 +1377,9 @@ const searchFileHtml = async uri => {
1377
1377
  const getFilePathElectron = async file => {
1378
1378
  return invoke$2('FileSystemHandle.getFilePathElectron', file);
1379
1379
  };
1380
+ /**
1381
+ * @deprecated
1382
+ */
1380
1383
  const showContextMenu = async (x, y, id, ...args) => {
1381
1384
  return invoke$2('ContextMenu.show', x, y, id, ...args);
1382
1385
  };
@@ -2936,10 +2939,7 @@ const focusIndex = async (menu, index) => {
2936
2939
  }
2937
2940
  const oldFocusedIndex = menu.focusedIndex;
2938
2941
  menu.focusedIndex = index;
2939
- return {
2940
- commands: [/* Menu.focusIndex */'Menu.focusIndex', /* level */menu.level, /* oldFocusedIndex */oldFocusedIndex, /* newFocusedIndex */index],
2941
- menus: getAll()
2942
- };
2942
+ await invoke$3('Menu.focusIndex', /* level */menu.level, /* oldFocusedIndex */oldFocusedIndex, /* newFocusedIndex */index);
2943
2943
  };
2944
2944
 
2945
2945
  const getCurrentMenu = () => {
@@ -3120,17 +3120,18 @@ const handleContextMenu = state => {
3120
3120
  const hideSubMenus = async level => {
3121
3121
  if (level < getCount()) {
3122
3122
  set$1(getAll().slice(0, level + 1));
3123
- return {
3124
- commands: [/* Menu.hideSubMenu */'Menu.hideSubMenu', /* level */level + 1],
3125
- menus: getAll()
3126
- };
3123
+ await invoke$3('Menu.hideSubMenu', /* level */level + 1);
3127
3124
  }
3128
3125
  };
3129
3126
 
3130
- /* eslint-disable @typescript-eslint/no-implied-eval */
3131
3127
  const MENU_DELAY_TRIANGLE = 300;
3132
- const resolveAfterTimeout = fn => {
3133
- setTimeout(fn, MENU_DELAY_TRIANGLE);
3128
+ const resolveAfterTimeout = async () => {
3129
+ const {
3130
+ resolve,
3131
+ promise
3132
+ } = Promise.withResolvers();
3133
+ setTimeout(resolve, MENU_DELAY_TRIANGLE);
3134
+ await promise;
3134
3135
  };
3135
3136
 
3136
3137
  const showSubMenuAtEnter = async (level, index, enterX, enterY) => {
@@ -3153,10 +3154,7 @@ const showSubMenuAtEnter = async (level, index, enterX, enterY) => {
3153
3154
  const height = getMenuHeight(subMenuItems);
3154
3155
  const visible = getVisible(subMenu.items, -1, false, subMenu.level);
3155
3156
  const dom = getMenuVirtualDom(visible).slice(1);
3156
- return {
3157
- commands: [/* Menu.showMenu */'Menu.showMenu', /* x */subMenu.x, /* y */subMenu.y, /* width */width, /* height */height, /* items */subMenu.items, /* level */subMenu.level, /* parentIndex */index, /* dom */dom],
3158
- menus: getAll()
3159
- };
3157
+ await invoke$3(/* Menu.showMenu */'Menu.showMenu', /* x */subMenu.x, /* y */subMenu.y, /* width */width, /* height */height, /* items */subMenu.items, /* level */subMenu.level, /* parentIndex */index, /* dom */dom);
3160
3158
  };
3161
3159
  const showSubMenu = async (level, index) => {
3162
3160
  return showSubMenuAtEnter(level, index, -1, -1);
@@ -3176,7 +3174,7 @@ const handleMouseEnter = async (level, index, enterX, enterY, enterTimeStamp) =>
3176
3174
  const subMenuEnterX = subMenu.enterX;
3177
3175
  // TODO should check for triangle position here
3178
3176
  if (enterX >= subMenuEnterX) {
3179
- await new Promise(resolveAfterTimeout);
3177
+ await resolveAfterTimeout();
3180
3178
  if (getLatestTimestamp() !== enterTimeStamp) {
3181
3179
  return;
3182
3180
  }
@@ -3185,7 +3183,7 @@ const handleMouseEnter = async (level, index, enterX, enterY, enterTimeStamp) =>
3185
3183
  const item = menu.items[index];
3186
3184
  await focusIndex(menu, index);
3187
3185
  switch (item.flags) {
3188
- case /* SubMenu */4:
3186
+ case SubMenu:
3189
3187
  await showSubMenuAtEnter(menu.level, index, enterX, enterY);
3190
3188
  break;
3191
3189
  default:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/menu-worker",
3
- "version": "2.2.0",
3
+ "version": "3.1.0",
4
4
  "description": "Menu Worker",
5
5
  "repository": {
6
6
  "type": "git",