@lvce-editor/title-bar-worker 4.13.1 → 4.14.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.
@@ -1134,6 +1134,7 @@ const create$2 = rpcId => {
1134
1134
  };
1135
1135
  };
1136
1136
 
1137
+ const Button$2 = 'button';
1137
1138
  const ContentInfo = 'contentinfo';
1138
1139
  const Menu$1 = 'menu';
1139
1140
  const MenuBar$1 = 'menubar';
@@ -1314,6 +1315,7 @@ const VirtualDomElements = {
1314
1315
  const Button = 'event.button';
1315
1316
  const ClientX = 'event.clientX';
1316
1317
  const ClientY = 'event.clientY';
1318
+ const Key = 'event.key';
1317
1319
  const TargetName = 'event.target.name';
1318
1320
 
1319
1321
  const Backspace$1 = 1;
@@ -1891,6 +1893,8 @@ const HandleMenuClick = 9;
1891
1893
  const HandleMenuMouseOver = 10;
1892
1894
  const HandleContextMenu = 11;
1893
1895
  const HandleTitleBarContextMenu = 12;
1896
+ const HandleCommandCenterClick = 13;
1897
+ const HandleCommandCenterKeyDown = 14;
1894
1898
 
1895
1899
  const emptyObject = {};
1896
1900
  const i18nString = (key, placeholders = emptyObject) => {
@@ -2023,6 +2027,9 @@ const menuBar = () => {
2023
2027
  const commandCenter = () => {
2024
2028
  return i18nString(CommandCenter);
2025
2029
  };
2030
+ const search = () => {
2031
+ return i18nString(Search);
2032
+ };
2026
2033
  const layoutControls = () => {
2027
2034
  return i18nString(LayoutControls);
2028
2035
  };
@@ -2142,7 +2149,7 @@ const create3 = (id, uri, x, y, width, height, platform, controlsOverlayEnabled,
2142
2149
  };
2143
2150
 
2144
2151
  const isEqual$3 = (oldState, newState) => {
2145
- return oldState.titleBarEntries === newState.titleBarEntries && oldState.titleBarMenuBarEnabled === newState.titleBarMenuBarEnabled && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen && oldState.title === newState.title && oldState.workspaceUri === newState.workspaceUri;
2152
+ return oldState.commandCenterEnabled === newState.commandCenterEnabled && oldState.titleBarEntries === newState.titleBarEntries && oldState.titleBarMenuBarEnabled === newState.titleBarMenuBarEnabled && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen && oldState.title === newState.title && oldState.workspaceUri === newState.workspaceUri;
2146
2153
  };
2147
2154
 
2148
2155
  const isEqual$2 = (oldState, newState) => {
@@ -3391,6 +3398,48 @@ const handleClick$1 = async (state, buttonName) => {
3391
3398
  return state;
3392
3399
  };
3393
3400
 
3401
+ const commandCenterItems = [{
3402
+ command: 'QuickPick.showFile',
3403
+ label: 'Go to File'
3404
+ }, {
3405
+ command: 'QuickPick.showCommands',
3406
+ label: 'Show and Run Commands'
3407
+ }, {
3408
+ args: ['Search'],
3409
+ command: 'Layout.openSideBarViewlet',
3410
+ label: 'Search for Text'
3411
+ }, {
3412
+ args: ['symbol'],
3413
+ command: 'QuickPick.show',
3414
+ label: 'Go to Symbol in Editor'
3415
+ }, {
3416
+ args: ['Run And Debug'],
3417
+ command: 'Layout.openSideBarViewlet',
3418
+ label: 'Start Debugging'
3419
+ }, {
3420
+ command: 'QuickPick.showCommands',
3421
+ label: 'Run Task'
3422
+ }, {
3423
+ command: 'QuickPick.showEverything',
3424
+ label: 'More'
3425
+ }];
3426
+ const handleCommandCenterClick = async state => {
3427
+ await invoke('QuickPick.show', 'custom', commandCenterItems, undefined, {
3428
+ executeItemCommand: true,
3429
+ mode: 'quickPick',
3430
+ placeholder: 'Search files by name (append : to go to line or @ to go to symbol)',
3431
+ waitUntil: 'visible'
3432
+ });
3433
+ return state;
3434
+ };
3435
+
3436
+ const handleCommandCenterKeyDown = async (state, key) => {
3437
+ if (key !== 'Enter' && key !== ' ' && key !== 'Space') {
3438
+ return state;
3439
+ }
3440
+ return handleCommandCenterClick(state);
3441
+ };
3442
+
3394
3443
  const show2 = async (uid, menuId, x, y, args) => {
3395
3444
  await showContextMenu2(uid, menuId, x, y, args);
3396
3445
  };
@@ -3436,6 +3485,21 @@ const getTotalWidth$1 = entries => {
3436
3485
  }
3437
3486
  return total;
3438
3487
  };
3488
+ const createOverflowEntry = (hiddenEntries, overflowIndex, focusedIndex, isMenuOpen) => {
3489
+ return {
3490
+ ariaLabel: moreDot(),
3491
+ hiddenEntries,
3492
+ icon: Ellipsis,
3493
+ id: OverflowMenuId,
3494
+ isFocused: overflowIndex === focusedIndex,
3495
+ isOpen: overflowIndex === focusedIndex && isMenuOpen,
3496
+ label: '...',
3497
+ width: MoreEntryWidth
3498
+ };
3499
+ };
3500
+ const isOverflowTitleBarEntry = entry => {
3501
+ return entry.id === OverflowMenuId;
3502
+ };
3439
3503
  const getVisibleTitleBarEntries = (entries, width, focusedIndex, isMenuOpen) => {
3440
3504
  array(entries);
3441
3505
  number(width);
@@ -3464,23 +3528,11 @@ const getVisibleTitleBarEntries = (entries, width, focusedIndex, isMenuOpen) =>
3464
3528
  }
3465
3529
  const hiddenEntries = entries.slice(visible.length);
3466
3530
  const overflowIndex = visible.length;
3467
- visible.push({
3468
- ariaLabel: moreDot(),
3469
- hiddenEntries,
3470
- icon: Ellipsis,
3471
- id: OverflowMenuId,
3472
- isFocused: overflowIndex === focusedIndex,
3473
- isOpen: overflowIndex === focusedIndex && isMenuOpen,
3474
- label: '...',
3475
- width: MoreEntryWidth
3476
- });
3531
+ visible.push(createOverflowEntry(hiddenEntries, overflowIndex, focusedIndex, isMenuOpen));
3477
3532
  }
3478
3533
  return visible;
3479
3534
  };
3480
3535
 
3481
- const hasOverflowEntry = entries => {
3482
- return entries.some(entry => entry?.id === OverflowMenuId);
3483
- };
3484
3536
  const getNavigableTitleBarEntries = state => {
3485
3537
  const {
3486
3538
  focusedIndex,
@@ -3488,9 +3540,6 @@ const getNavigableTitleBarEntries = state => {
3488
3540
  titleBarEntries,
3489
3541
  width
3490
3542
  } = state;
3491
- if (hasOverflowEntry(titleBarEntries)) {
3492
- return titleBarEntries;
3493
- }
3494
3543
  return getVisibleTitleBarEntries(titleBarEntries, width, focusedIndex, isMenuOpen);
3495
3544
  };
3496
3545
 
@@ -3643,14 +3692,28 @@ const openMenuAtIndex = async (state, index, shouldBeFocused) => {
3643
3692
  if (!titleBarEntry) {
3644
3693
  return state;
3645
3694
  }
3646
- const {
3647
- id
3648
- } = titleBarEntry;
3649
- const rawItems = id === OverflowMenuId ? getOverflowMenuItems(titleBarEntry.hiddenEntries || []) : await getMenuEntries2(state, {
3650
- menuId: id,
3651
- platform
3652
- });
3653
- const items = id === OverflowMenuId ? rawItems : await addMenuEntryKeyBindings(rawItems);
3695
+ let rawItems;
3696
+ let menuId;
3697
+ const isOverflow = isOverflowTitleBarEntry(titleBarEntry);
3698
+ if (isOverflow) {
3699
+ rawItems = getOverflowMenuItems(titleBarEntry.hiddenEntries);
3700
+ menuId = undefined;
3701
+ } else {
3702
+ if (titleBarEntry.id === undefined) {
3703
+ return {
3704
+ ...state,
3705
+ focusedIndex: index,
3706
+ isMenuOpen: true,
3707
+ menus: []
3708
+ };
3709
+ }
3710
+ rawItems = await getMenuEntries2(state, {
3711
+ menuId: titleBarEntry.id,
3712
+ platform
3713
+ });
3714
+ menuId = titleBarEntry.id;
3715
+ }
3716
+ const items = isOverflow ? rawItems : await addMenuEntryKeyBindings(rawItems);
3654
3717
  const relevantEntries = titleBarEntries.slice(0, index);
3655
3718
  const totalWidths = getTotalWidth(relevantEntries);
3656
3719
  const offset = totalWidths;
@@ -3664,7 +3727,7 @@ const openMenuAtIndex = async (state, index, shouldBeFocused) => {
3664
3727
  const menu = {
3665
3728
  focusedIndex: menuFocusedIndex,
3666
3729
  height,
3667
- id: id === OverflowMenuId ? undefined : id,
3730
+ id: menuId,
3668
3731
  items,
3669
3732
  level: 0,
3670
3733
  width,
@@ -3990,6 +4053,7 @@ const MenuItemSubMenuArrowRight = 'MenuItemSubMenuArrowRight';
3990
4053
  const TitleBar = 'TitleBar';
3991
4054
  const TitleBarButton = 'TitleBarButton';
3992
4055
  const TitleBarButtons = 'TitleBarButtons';
4056
+ const TitleBarCommandCenter = 'TitleBarCommandCenter';
3993
4057
  const TitleBarEntryActive = 'TitleBarEntryActive';
3994
4058
  const TitleBarIcon = 'TitleBarIcon';
3995
4059
  const TitleBarIconIcon = 'TitleBarIconIcon';
@@ -4277,6 +4341,24 @@ const renderMenus = (oldState, newState) => {
4277
4341
  return ['Viewlet.send', uid, /* method */SetMenus, /* changes */changes, uid];
4278
4342
  };
4279
4343
 
4344
+ const Focusable = 0;
4345
+
4346
+ const getCommandCenterVirtualDom = commandCenterEnabled => {
4347
+ if (!commandCenterEnabled) {
4348
+ return [];
4349
+ }
4350
+ return [{
4351
+ ariaLabel: commandCenter(),
4352
+ childCount: 1,
4353
+ className: TitleBarCommandCenter,
4354
+ onClick: HandleCommandCenterClick,
4355
+ onKeyDown: HandleCommandCenterKeyDown,
4356
+ role: Button$2,
4357
+ tabIndex: Focusable,
4358
+ type: Div
4359
+ }, text(search())];
4360
+ };
4361
+
4280
4362
  const getIcon = assetDir => {
4281
4363
  return `${assetDir}/icons/icon.svg`;
4282
4364
  };
@@ -4349,7 +4431,6 @@ const getActiveEntryLabelDom = isFocused => {
4349
4431
  return [activeEntryLabelNode];
4350
4432
  };
4351
4433
  const getItemVirtualDom = item => {
4352
- // @ts-ignore
4353
4434
  const {
4354
4435
  ariaLabel,
4355
4436
  isFocused,
@@ -4418,6 +4499,7 @@ const emptyTitleBarNode = {
4418
4499
  const getTitleBarVirtualDom = state => {
4419
4500
  const {
4420
4501
  assetDir,
4502
+ commandCenterEnabled,
4421
4503
  focusedIndex,
4422
4504
  isMenuOpen,
4423
4505
  platform,
@@ -4436,7 +4518,8 @@ const getTitleBarVirtualDom = state => {
4436
4518
  }
4437
4519
  const iconSrc = getIcon(assetDir);
4438
4520
  const visibleEntries = getVisibleTitleBarEntries(titleBarEntries, width, focusedIndex, isMenuOpen);
4439
- const childCount = Number(titleBarIconEnabled) + Number(titleBarMenuBarEnabled) + Number(titleBarTitleEnabled) + Number(titleBarButtonsEnabled);
4521
+ const titleEnabled = titleBarTitleEnabled && !commandCenterEnabled;
4522
+ const childCount = Number(titleBarIconEnabled) + Number(titleBarMenuBarEnabled) + Number(commandCenterEnabled) + Number(titleEnabled) + Number(titleBarButtonsEnabled);
4440
4523
  return [{
4441
4524
  ariaLabel: titleBar(),
4442
4525
  childCount,
@@ -4445,7 +4528,7 @@ const getTitleBarVirtualDom = state => {
4445
4528
  onContextMenu: HandleTitleBarContextMenu,
4446
4529
  role: ContentInfo,
4447
4530
  type: Div
4448
- }, ...getTitleBarIconVirtualDom(titleBarIconEnabled, iconSrc), ...getTitleBarMenuBarVirtualDom(titleBarMenuBarEnabled, visibleEntries, focusedIndex), ...getTitleVirtualDom(titleBarTitleEnabled, title), ...getTitleBarButtonsVirtualDom(titleBarButtonsEnabled, titleBarButtons)];
4531
+ }, ...getTitleBarIconVirtualDom(titleBarIconEnabled, iconSrc), ...getTitleBarMenuBarVirtualDom(titleBarMenuBarEnabled, visibleEntries, focusedIndex), ...getCommandCenterVirtualDom(commandCenterEnabled), ...getTitleVirtualDom(titleEnabled, title), ...getTitleBarButtonsVirtualDom(titleBarButtonsEnabled, titleBarButtons)];
4449
4532
  };
4450
4533
 
4451
4534
  const renderTitleBar = (oldState, newState) => {
@@ -4503,6 +4586,12 @@ const renderEventListeners = () => {
4503
4586
  }, {
4504
4587
  name: HandleClickToggleMaximize,
4505
4588
  params: ['handleClickToggleMaximize']
4589
+ }, {
4590
+ name: HandleCommandCenterClick,
4591
+ params: ['handleCommandCenterClick']
4592
+ }, {
4593
+ name: HandleCommandCenterKeyDown,
4594
+ params: ['handleCommandCenterKeyDown', Key]
4506
4595
  }, {
4507
4596
  name: HandleFocusIn,
4508
4597
  params: ['handleFocus']
@@ -5230,6 +5319,8 @@ const commandMap = {
5230
5319
  'TitleBar.handleClickClose': wrapCommand(handleClickClose),
5231
5320
  'TitleBar.handleClickMinimize': wrapCommand(handleClickMinimize),
5232
5321
  'TitleBar.handleClickToggleMaximize': wrapCommand(handleClickToggleMaximize),
5322
+ 'TitleBar.handleCommandCenterClick': wrapCommand(handleCommandCenterClick),
5323
+ 'TitleBar.handleCommandCenterKeyDown': wrapCommand(handleCommandCenterKeyDown),
5233
5324
  'TitleBar.handleContextMenu': wrapCommand(handleContextMenu),
5234
5325
  'TitleBar.handleElectronMenuClick': wrapCommand(handleElectronMenuClick),
5235
5326
  'TitleBar.handleFocus': wrapCommand(handleFocus),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/title-bar-worker",
3
- "version": "4.13.1",
3
+ "version": "4.14.1",
4
4
  "description": "Title Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",