@lvce-editor/title-bar-worker 4.23.0 → 4.24.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.
@@ -3376,6 +3376,33 @@ const getComponentState = uid => {
3376
3376
  return get(uid).newState;
3377
3377
  };
3378
3378
 
3379
+ const MaskIconCheck = 'MaskIconCheck';
3380
+ const MaskIcon = 'MaskIcon';
3381
+ const Menu = 'Menu';
3382
+ const MenuItem = 'MenuItem';
3383
+ const MenuItemCheckMark = 'MenuItemCheckMark';
3384
+ const MenuItemCheckmarkIcon = 'MenuItemCheckmarkIcon';
3385
+ const MenuItemDisabled = 'MenuItemDisabled';
3386
+ const MenuItemFocused = 'MenuItemFocused';
3387
+ const MenuItemKeyBinding = 'MenuItemKeyBinding';
3388
+ const MenuItemSeparator = 'MenuItemSeparator';
3389
+ const MenuItemSeparatorLine = 'MenuItemSeparatorLine';
3390
+ const MenuItemSubMenu = 'MenuItemSubMenu';
3391
+ const MenuItemSubMenuArrowRight = 'MenuItemSubMenuArrowRight';
3392
+ const TitleBar = 'TitleBar';
3393
+ const TitleBarButton = 'TitleBarButton';
3394
+ const TitleBarButtons = 'TitleBarButtons';
3395
+ const TitleBarCommandCenter = 'TitleBarCommandCenter';
3396
+ const TitleBarEntryActive = 'TitleBarEntryActive';
3397
+ const TitleBarIcon = 'TitleBarIcon';
3398
+ const TitleBarIconIcon = 'TitleBarIconIcon';
3399
+ const TitleBarMenuBar = 'TitleBarMenuBar';
3400
+ const TitleBarTopLevelEntry = 'TitleBarTopLevelEntry';
3401
+ const TitleBarTopLevelEntryLabel = 'TitleBarTopLevelEntryLabel';
3402
+ const Viewlet = 'Viewlet';
3403
+
3404
+ const Focusable = 0;
3405
+
3379
3406
  const mergeClassNames = (...classNames) => {
3380
3407
  return classNames.filter(Boolean).join(' ');
3381
3408
  };
@@ -3390,6 +3417,263 @@ const text = data => {
3390
3417
 
3391
3418
  new Set(Object.values(VirtualDomElements));
3392
3419
 
3420
+ const getCommandCenterVirtualDom = commandCenterEnabled => {
3421
+ if (!commandCenterEnabled) {
3422
+ return [];
3423
+ }
3424
+ return [{
3425
+ ariaLabel: commandCenter(),
3426
+ childCount: 1,
3427
+ className: TitleBarCommandCenter,
3428
+ onClick: HandleCommandCenterClick,
3429
+ onKeyDown: HandleCommandCenterKeyDown,
3430
+ role: Button$2,
3431
+ tabIndex: Focusable,
3432
+ type: Div
3433
+ }, text(search())];
3434
+ };
3435
+
3436
+ const getIcon = assetDir => {
3437
+ return `${assetDir}/icons/icon.svg`;
3438
+ };
3439
+
3440
+ const getIconVirtualDom = (icon, type = Div) => {
3441
+ return {
3442
+ childCount: 0,
3443
+ className: mergeClassNames(MaskIcon, `MaskIcon${icon}`),
3444
+ role: None$1,
3445
+ type
3446
+ };
3447
+ };
3448
+
3449
+ const createTitleBarButton = button => {
3450
+ const {
3451
+ icon,
3452
+ id,
3453
+ label,
3454
+ onClick
3455
+ } = button;
3456
+ const dom = [{
3457
+ ariaLabel: label,
3458
+ childCount: 1,
3459
+ className: mergeClassNames(TitleBarButton, `TitleBarButton${id}`),
3460
+ name: id,
3461
+ onClick,
3462
+ type: Button$1
3463
+ }, getIconVirtualDom(icon, I)];
3464
+ return dom;
3465
+ };
3466
+
3467
+ const getTitleBarButtonsVirtualDom = (buttonsEnabled, buttons) => {
3468
+ if (!buttonsEnabled) {
3469
+ return [];
3470
+ }
3471
+ return [{
3472
+ childCount: buttons.length,
3473
+ className: mergeClassNames(Viewlet, TitleBarButtons),
3474
+ type: Div
3475
+ }, ...buttons.flatMap(createTitleBarButton)];
3476
+ };
3477
+
3478
+ const parentNode$1 = {
3479
+ childCount: 1,
3480
+ className: mergeClassNames(Viewlet, TitleBarIcon),
3481
+ type: Div
3482
+ };
3483
+ const getTitleBarIconVirtualDom = (titleBarIconEnabled, iconSrc) => {
3484
+ if (!titleBarIconEnabled) {
3485
+ return [];
3486
+ }
3487
+ return [parentNode$1, {
3488
+ alt: '',
3489
+ childCount: 0,
3490
+ className: TitleBarIconIcon,
3491
+ src: iconSrc,
3492
+ type: Img
3493
+ }];
3494
+ };
3495
+
3496
+ const activeEntryLabelNode = {
3497
+ childCount: 1,
3498
+ className: TitleBarTopLevelEntryLabel,
3499
+ type: Div
3500
+ };
3501
+ const getActiveEntryLabelDom = isFocused => {
3502
+ if (!isFocused) {
3503
+ return [];
3504
+ }
3505
+ return [activeEntryLabelNode];
3506
+ };
3507
+ const getItemVirtualDom = item => {
3508
+ const {
3509
+ ariaLabel,
3510
+ isFocused,
3511
+ isOpen,
3512
+ keyboardShortCut,
3513
+ label
3514
+ } = item;
3515
+ const className = isFocused ? mergeClassNames(TitleBarTopLevelEntry, TitleBarEntryActive) : TitleBarTopLevelEntry;
3516
+ return [{
3517
+ ariaExpanded: isOpen,
3518
+ ariaHasPopup: true,
3519
+ ariaKeyShortcuts: keyboardShortCut,
3520
+ ariaLabel: ariaLabel || label,
3521
+ ariaOwns: isOpen ? 'Menu-0' : undefined,
3522
+ childCount: 1,
3523
+ className,
3524
+ id: isFocused ? 'TitleBarEntryActive' : undefined,
3525
+ name: label,
3526
+ // TODO have separate name attribute
3527
+ role: MenuItem$1,
3528
+ type: Button$1
3529
+ }, ...getActiveEntryLabelDom(isFocused), text(label)];
3530
+ };
3531
+ const getTitleBarMenuBarItemsVirtualDom = visibleItems => {
3532
+ const dom = visibleItems.flatMap(getItemVirtualDom);
3533
+ return dom;
3534
+ };
3535
+
3536
+ const activeId = 'TitleBarEntryActive';
3537
+ const getTitleBarMenuBarVirtualDom = (menuBarEnabled, visibleItems, focusedIndex) => {
3538
+ if (!menuBarEnabled) {
3539
+ return [];
3540
+ }
3541
+ return [{
3542
+ ariaActivedescendant: focusedIndex === -1 ? '' : activeId,
3543
+ childCount: visibleItems.length,
3544
+ className: mergeClassNames(Viewlet, TitleBarMenuBar),
3545
+ onContextMenu: HandleContextMenu,
3546
+ onFocusIn: HandleFocusIn,
3547
+ onFocusOut: HandleFocusOut,
3548
+ onMouseDown: HandleClick,
3549
+ onPointerOut: HandlePointerOut,
3550
+ onPointerOver: HandlePointerOver,
3551
+ role: MenuBar$1,
3552
+ tabIndex: 0,
3553
+ type: Div
3554
+ }, ...getTitleBarMenuBarItemsVirtualDom(visibleItems)];
3555
+ };
3556
+
3557
+ const parentNode = {
3558
+ childCount: 1,
3559
+ className: 'TitleBarTitle',
3560
+ type: Div
3561
+ };
3562
+ const getTitleVirtualDom = (titleBarTitleEnabled, title) => {
3563
+ if (!titleBarTitleEnabled) {
3564
+ return [];
3565
+ }
3566
+ return [parentNode, text(title)];
3567
+ };
3568
+
3569
+ const Ellipsis = 'Ellipsis';
3570
+
3571
+ const MoreEntryWidth = 38;
3572
+ const OverflowMenuId = 'title-bar-overflow';
3573
+ const getTotalWidth$1 = entries => {
3574
+ let total = 0;
3575
+ for (const entry of entries) {
3576
+ total += entry.width;
3577
+ }
3578
+ return total;
3579
+ };
3580
+ const createOverflowEntry = (hiddenEntries, overflowIndex, focusedIndex, isMenuOpen) => {
3581
+ return {
3582
+ ariaLabel: moreDot(),
3583
+ hiddenEntries,
3584
+ icon: Ellipsis,
3585
+ id: OverflowMenuId,
3586
+ isFocused: overflowIndex === focusedIndex,
3587
+ isOpen: overflowIndex === focusedIndex && isMenuOpen,
3588
+ label: '...',
3589
+ width: MoreEntryWidth
3590
+ };
3591
+ };
3592
+ const isOverflowTitleBarEntry = entry => {
3593
+ return entry.id === OverflowMenuId;
3594
+ };
3595
+ const getVisibleTitleBarEntries = (entries, width, focusedIndex, isMenuOpen) => {
3596
+ array(entries);
3597
+ number(width);
3598
+ let total = 0;
3599
+ const visible = [];
3600
+ for (let i = 0; i < entries.length; i++) {
3601
+ const entry = entries[i];
3602
+ const nextTotal = total + entry.width;
3603
+ if (nextTotal >= width) {
3604
+ break;
3605
+ }
3606
+ total = nextTotal;
3607
+ const visibleIndex = visible.length;
3608
+ const isOpen = visibleIndex === focusedIndex && isMenuOpen;
3609
+ const isFocused = visibleIndex === focusedIndex;
3610
+ visible.push({
3611
+ ...entry,
3612
+ isFocused,
3613
+ isOpen
3614
+ });
3615
+ }
3616
+ const hasOverflow = visible.length < entries.length;
3617
+ if (hasOverflow) {
3618
+ while (visible.length > 0 && getTotalWidth$1(visible) + MoreEntryWidth > width) {
3619
+ visible.pop();
3620
+ }
3621
+ const hiddenEntries = entries.slice(visible.length);
3622
+ const overflowIndex = visible.length;
3623
+ visible.push(createOverflowEntry(hiddenEntries, overflowIndex, focusedIndex, isMenuOpen));
3624
+ }
3625
+ return visible;
3626
+ };
3627
+
3628
+ const emptyTitleBarNode = {
3629
+ childCount: 0,
3630
+ type: Div
3631
+ };
3632
+ const getTitleBarVirtualDom = state => {
3633
+ const {
3634
+ assetDir,
3635
+ commandCenterEnabled,
3636
+ focusedIndex,
3637
+ isMenuOpen,
3638
+ platform,
3639
+ title,
3640
+ titleBarButtons,
3641
+ titleBarButtonsEnabled,
3642
+ titleBarEntries,
3643
+ titleBarIconEnabled,
3644
+ titleBarMenuBarEnabled,
3645
+ titleBarStyleCustom,
3646
+ titleBarTitleEnabled,
3647
+ width
3648
+ } = state;
3649
+ if (platform === Electron$1 && !titleBarStyleCustom) {
3650
+ return [emptyTitleBarNode];
3651
+ }
3652
+ const iconSrc = getIcon(assetDir);
3653
+ const visibleEntries = getVisibleTitleBarEntries(titleBarEntries, width, focusedIndex, isMenuOpen);
3654
+ const titleEnabled = titleBarTitleEnabled && !commandCenterEnabled;
3655
+ const childCount = Number(titleBarIconEnabled) + Number(titleBarMenuBarEnabled) + Number(commandCenterEnabled) + Number(titleEnabled) + Number(titleBarButtonsEnabled);
3656
+ return [{
3657
+ ariaLabel: titleBar(),
3658
+ childCount,
3659
+ className: mergeClassNames(Viewlet, TitleBar),
3660
+ id: 'TitleBar',
3661
+ onContextMenu: HandleTitleBarContextMenu,
3662
+ role: ContentInfo,
3663
+ type: Div
3664
+ }, ...getTitleBarIconVirtualDom(titleBarIconEnabled, iconSrc), ...getTitleBarMenuBarVirtualDom(titleBarMenuBarEnabled, visibleEntries, focusedIndex), ...getCommandCenterVirtualDom(commandCenterEnabled), ...getTitleVirtualDom(titleEnabled, title), ...getTitleBarButtonsVirtualDom(titleBarButtonsEnabled, titleBarButtons)];
3665
+ };
3666
+
3667
+ const renderTitleBar = (oldState, newState) => {
3668
+ const dom = getTitleBarVirtualDom(newState);
3669
+ return [SetDom2, newState.uid, dom];
3670
+ };
3671
+
3672
+ const getComponentDom = uid => {
3673
+ const state = getComponentState(uid);
3674
+ return renderTitleBar(state, state)[2];
3675
+ };
3676
+
3393
3677
  const getKeyBindings = () => {
3394
3678
  return [{
3395
3679
  command: 'TitleBar.handleKeyArrowDown',
@@ -3563,99 +3847,40 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
3563
3847
  const executeViewletCommand = async (uid, command, ...args) => {
3564
3848
  const fn = viewletCommandMap[`TitleBar.${command}`];
3565
3849
  if (typeof fn !== 'function') {
3566
- throw new TypeError(`Viewlet command not found: ${command}`);
3567
- }
3568
- const previous = commandQueues.get(uid);
3569
- const {
3570
- promise: next,
3571
- resolve
3572
- } = Promise.withResolvers();
3573
- commandQueues.set(uid, next);
3574
- if (previous) {
3575
- await previous;
3576
- }
3577
- try {
3578
- await fn(uid, ...args);
3579
- await invoke$1('Viewlet.requestRender', uid);
3580
- } finally {
3581
- resolve();
3582
- if (commandQueues.get(uid) === next) {
3583
- commandQueues.delete(uid);
3584
- }
3585
- }
3586
- };
3587
- const rpc = await create$5({
3588
- commandMap: {
3589
- 'Viewlet.executeViewletCommand': executeViewletCommand
3590
- },
3591
- messagePort: port
3592
- });
3593
- if (setAsRendererProcess) {
3594
- set(rpc);
3595
- }
3596
- };
3597
-
3598
- const getMenuOffset = (x, clientX, iconWidth) => {
3599
- return clientX - x - iconWidth;
3600
- };
3601
-
3602
- const Ellipsis = 'Ellipsis';
3603
-
3604
- const MoreEntryWidth = 38;
3605
- const OverflowMenuId = 'title-bar-overflow';
3606
- const getTotalWidth$1 = entries => {
3607
- let total = 0;
3608
- for (const entry of entries) {
3609
- total += entry.width;
3610
- }
3611
- return total;
3612
- };
3613
- const createOverflowEntry = (hiddenEntries, overflowIndex, focusedIndex, isMenuOpen) => {
3614
- return {
3615
- ariaLabel: moreDot(),
3616
- hiddenEntries,
3617
- icon: Ellipsis,
3618
- id: OverflowMenuId,
3619
- isFocused: overflowIndex === focusedIndex,
3620
- isOpen: overflowIndex === focusedIndex && isMenuOpen,
3621
- label: '...',
3622
- width: MoreEntryWidth
3623
- };
3624
- };
3625
- const isOverflowTitleBarEntry = entry => {
3626
- return entry.id === OverflowMenuId;
3627
- };
3628
- const getVisibleTitleBarEntries = (entries, width, focusedIndex, isMenuOpen) => {
3629
- array(entries);
3630
- number(width);
3631
- let total = 0;
3632
- const visible = [];
3633
- for (let i = 0; i < entries.length; i++) {
3634
- const entry = entries[i];
3635
- const nextTotal = total + entry.width;
3636
- if (nextTotal >= width) {
3637
- break;
3638
- }
3639
- total = nextTotal;
3640
- const visibleIndex = visible.length;
3641
- const isOpen = visibleIndex === focusedIndex && isMenuOpen;
3642
- const isFocused = visibleIndex === focusedIndex;
3643
- visible.push({
3644
- ...entry,
3645
- isFocused,
3646
- isOpen
3647
- });
3648
- }
3649
- const hasOverflow = visible.length < entries.length;
3650
- if (hasOverflow) {
3651
- while (visible.length > 0 && getTotalWidth$1(visible) + MoreEntryWidth > width) {
3652
- visible.pop();
3850
+ throw new TypeError(`Viewlet command not found: ${command}`);
3653
3851
  }
3654
- const hiddenEntries = entries.slice(visible.length);
3655
- const overflowIndex = visible.length;
3656
- visible.push(createOverflowEntry(hiddenEntries, overflowIndex, focusedIndex, isMenuOpen));
3852
+ const previous = commandQueues.get(uid);
3853
+ const {
3854
+ promise: next,
3855
+ resolve
3856
+ } = Promise.withResolvers();
3857
+ commandQueues.set(uid, next);
3858
+ if (previous) {
3859
+ await previous;
3860
+ }
3861
+ try {
3862
+ await fn(uid, ...args);
3863
+ await invoke$1('Viewlet.requestRender', uid);
3864
+ } finally {
3865
+ resolve();
3866
+ if (commandQueues.get(uid) === next) {
3867
+ commandQueues.delete(uid);
3868
+ }
3869
+ }
3870
+ };
3871
+ const rpc = await create$5({
3872
+ commandMap: {
3873
+ 'Viewlet.executeViewletCommand': executeViewletCommand
3874
+ },
3875
+ messagePort: port
3876
+ });
3877
+ if (setAsRendererProcess) {
3878
+ set(rpc);
3657
3879
  }
3658
- return visible;
3880
+ };
3881
+
3882
+ const getMenuOffset = (x, clientX, iconWidth) => {
3883
+ return clientX - x - iconWidth;
3659
3884
  };
3660
3885
 
3661
3886
  const getNavigableTitleBarEntries = state => {
@@ -4188,31 +4413,6 @@ const renderFocusedIndex = (oldState, newState) => {
4188
4413
  return [FocusSelector, newState.uid, '.ViewletTitleBarMenuBar'];
4189
4414
  };
4190
4415
 
4191
- const MaskIconCheck = 'MaskIconCheck';
4192
- const MaskIcon = 'MaskIcon';
4193
- const Menu = 'Menu';
4194
- const MenuItem = 'MenuItem';
4195
- const MenuItemCheckMark = 'MenuItemCheckMark';
4196
- const MenuItemCheckmarkIcon = 'MenuItemCheckmarkIcon';
4197
- const MenuItemDisabled = 'MenuItemDisabled';
4198
- const MenuItemFocused = 'MenuItemFocused';
4199
- const MenuItemKeyBinding = 'MenuItemKeyBinding';
4200
- const MenuItemSeparator = 'MenuItemSeparator';
4201
- const MenuItemSeparatorLine = 'MenuItemSeparatorLine';
4202
- const MenuItemSubMenu = 'MenuItemSubMenu';
4203
- const MenuItemSubMenuArrowRight = 'MenuItemSubMenuArrowRight';
4204
- const TitleBar = 'TitleBar';
4205
- const TitleBarButton = 'TitleBarButton';
4206
- const TitleBarButtons = 'TitleBarButtons';
4207
- const TitleBarCommandCenter = 'TitleBarCommandCenter';
4208
- const TitleBarEntryActive = 'TitleBarEntryActive';
4209
- const TitleBarIcon = 'TitleBarIcon';
4210
- const TitleBarIconIcon = 'TitleBarIconIcon';
4211
- const TitleBarMenuBar = 'TitleBarMenuBar';
4212
- const TitleBarTopLevelEntry = 'TitleBarTopLevelEntry';
4213
- const TitleBarTopLevelEntryLabel = 'TitleBarTopLevelEntryLabel';
4214
- const Viewlet = 'Viewlet';
4215
-
4216
4416
  const getKeyBindingString = (key, altKey, ctrlKey, shiftKey, metaKey) => {
4217
4417
  let string = '';
4218
4418
  if (ctrlKey) {
@@ -4494,201 +4694,6 @@ const renderMenus = (oldState, newState) => {
4494
4694
  return ['Viewlet.send', uid, /* method */SetMenus, /* changes */changes, uid];
4495
4695
  };
4496
4696
 
4497
- const Focusable = 0;
4498
-
4499
- const getCommandCenterVirtualDom = commandCenterEnabled => {
4500
- if (!commandCenterEnabled) {
4501
- return [];
4502
- }
4503
- return [{
4504
- ariaLabel: commandCenter(),
4505
- childCount: 1,
4506
- className: TitleBarCommandCenter,
4507
- onClick: HandleCommandCenterClick,
4508
- onKeyDown: HandleCommandCenterKeyDown,
4509
- role: Button$2,
4510
- tabIndex: Focusable,
4511
- type: Div
4512
- }, text(search())];
4513
- };
4514
-
4515
- const getIcon = assetDir => {
4516
- return `${assetDir}/icons/icon.svg`;
4517
- };
4518
-
4519
- const getIconVirtualDom = (icon, type = Div) => {
4520
- return {
4521
- childCount: 0,
4522
- className: mergeClassNames(MaskIcon, `MaskIcon${icon}`),
4523
- role: None$1,
4524
- type
4525
- };
4526
- };
4527
-
4528
- const createTitleBarButton = button => {
4529
- const {
4530
- icon,
4531
- id,
4532
- label,
4533
- onClick
4534
- } = button;
4535
- const dom = [{
4536
- ariaLabel: label,
4537
- childCount: 1,
4538
- className: mergeClassNames(TitleBarButton, `TitleBarButton${id}`),
4539
- name: id,
4540
- onClick,
4541
- type: Button$1
4542
- }, getIconVirtualDom(icon, I)];
4543
- return dom;
4544
- };
4545
-
4546
- const getTitleBarButtonsVirtualDom = (buttonsEnabled, buttons) => {
4547
- if (!buttonsEnabled) {
4548
- return [];
4549
- }
4550
- return [{
4551
- childCount: buttons.length,
4552
- className: mergeClassNames(Viewlet, TitleBarButtons),
4553
- type: Div
4554
- }, ...buttons.flatMap(createTitleBarButton)];
4555
- };
4556
-
4557
- const parentNode$1 = {
4558
- childCount: 1,
4559
- className: mergeClassNames(Viewlet, TitleBarIcon),
4560
- type: Div
4561
- };
4562
- const getTitleBarIconVirtualDom = (titleBarIconEnabled, iconSrc) => {
4563
- if (!titleBarIconEnabled) {
4564
- return [];
4565
- }
4566
- return [parentNode$1, {
4567
- alt: '',
4568
- childCount: 0,
4569
- className: TitleBarIconIcon,
4570
- src: iconSrc,
4571
- type: Img
4572
- }];
4573
- };
4574
-
4575
- const activeEntryLabelNode = {
4576
- childCount: 1,
4577
- className: TitleBarTopLevelEntryLabel,
4578
- type: Div
4579
- };
4580
- const getActiveEntryLabelDom = isFocused => {
4581
- if (!isFocused) {
4582
- return [];
4583
- }
4584
- return [activeEntryLabelNode];
4585
- };
4586
- const getItemVirtualDom = item => {
4587
- const {
4588
- ariaLabel,
4589
- isFocused,
4590
- isOpen,
4591
- keyboardShortCut,
4592
- label
4593
- } = item;
4594
- const className = isFocused ? mergeClassNames(TitleBarTopLevelEntry, TitleBarEntryActive) : TitleBarTopLevelEntry;
4595
- return [{
4596
- ariaExpanded: isOpen,
4597
- ariaHasPopup: true,
4598
- ariaKeyShortcuts: keyboardShortCut,
4599
- ariaLabel: ariaLabel || label,
4600
- ariaOwns: isOpen ? 'Menu-0' : undefined,
4601
- childCount: 1,
4602
- className,
4603
- id: isFocused ? 'TitleBarEntryActive' : undefined,
4604
- name: label,
4605
- // TODO have separate name attribute
4606
- role: MenuItem$1,
4607
- type: Button$1
4608
- }, ...getActiveEntryLabelDom(isFocused), text(label)];
4609
- };
4610
- const getTitleBarMenuBarItemsVirtualDom = visibleItems => {
4611
- const dom = visibleItems.flatMap(getItemVirtualDom);
4612
- return dom;
4613
- };
4614
-
4615
- const activeId = 'TitleBarEntryActive';
4616
- const getTitleBarMenuBarVirtualDom = (menuBarEnabled, visibleItems, focusedIndex) => {
4617
- if (!menuBarEnabled) {
4618
- return [];
4619
- }
4620
- return [{
4621
- ariaActivedescendant: focusedIndex === -1 ? '' : activeId,
4622
- childCount: visibleItems.length,
4623
- className: mergeClassNames(Viewlet, TitleBarMenuBar),
4624
- onContextMenu: HandleContextMenu,
4625
- onFocusIn: HandleFocusIn,
4626
- onFocusOut: HandleFocusOut,
4627
- onMouseDown: HandleClick,
4628
- onPointerOut: HandlePointerOut,
4629
- onPointerOver: HandlePointerOver,
4630
- role: MenuBar$1,
4631
- tabIndex: 0,
4632
- type: Div
4633
- }, ...getTitleBarMenuBarItemsVirtualDom(visibleItems)];
4634
- };
4635
-
4636
- const parentNode = {
4637
- childCount: 1,
4638
- className: 'TitleBarTitle',
4639
- type: Div
4640
- };
4641
- const getTitleVirtualDom = (titleBarTitleEnabled, title) => {
4642
- if (!titleBarTitleEnabled) {
4643
- return [];
4644
- }
4645
- return [parentNode, text(title)];
4646
- };
4647
-
4648
- const emptyTitleBarNode = {
4649
- childCount: 0,
4650
- type: Div
4651
- };
4652
- const getTitleBarVirtualDom = state => {
4653
- const {
4654
- assetDir,
4655
- commandCenterEnabled,
4656
- focusedIndex,
4657
- isMenuOpen,
4658
- platform,
4659
- title,
4660
- titleBarButtons,
4661
- titleBarButtonsEnabled,
4662
- titleBarEntries,
4663
- titleBarIconEnabled,
4664
- titleBarMenuBarEnabled,
4665
- titleBarStyleCustom,
4666
- titleBarTitleEnabled,
4667
- width
4668
- } = state;
4669
- if (platform === Electron$1 && !titleBarStyleCustom) {
4670
- return [emptyTitleBarNode];
4671
- }
4672
- const iconSrc = getIcon(assetDir);
4673
- const visibleEntries = getVisibleTitleBarEntries(titleBarEntries, width, focusedIndex, isMenuOpen);
4674
- const titleEnabled = titleBarTitleEnabled && !commandCenterEnabled;
4675
- const childCount = Number(titleBarIconEnabled) + Number(titleBarMenuBarEnabled) + Number(commandCenterEnabled) + Number(titleEnabled) + Number(titleBarButtonsEnabled);
4676
- return [{
4677
- ariaLabel: titleBar(),
4678
- childCount,
4679
- className: mergeClassNames(Viewlet, TitleBar),
4680
- id: 'TitleBar',
4681
- onContextMenu: HandleTitleBarContextMenu,
4682
- role: ContentInfo,
4683
- type: Div
4684
- }, ...getTitleBarIconVirtualDom(titleBarIconEnabled, iconSrc), ...getTitleBarMenuBarVirtualDom(titleBarMenuBarEnabled, visibleEntries, focusedIndex), ...getCommandCenterVirtualDom(commandCenterEnabled), ...getTitleVirtualDom(titleEnabled, title), ...getTitleBarButtonsVirtualDom(titleBarButtonsEnabled, titleBarButtons)];
4685
- };
4686
-
4687
- const renderTitleBar = (oldState, newState) => {
4688
- const dom = getTitleBarVirtualDom(newState);
4689
- return [SetDom2, newState.uid, dom];
4690
- };
4691
-
4692
4697
  const getRenderer3 = diffType => {
4693
4698
  switch (diffType) {
4694
4699
  case RenderEntries:
@@ -5543,6 +5548,7 @@ const commandMap = {
5543
5548
  'TitleBar.focusPrevious': wrapCommand(focusPrevious),
5544
5549
  'TitleBar.getCommandIds': getCommandIds,
5545
5550
  'TitleBar.getCommands': getCommandIds,
5551
+ 'TitleBar.getComponentDom': getComponentDom,
5546
5552
  'TitleBar.getComponentState': getComponentState,
5547
5553
  'TitleBar.getKeyBindings': getKeyBindings,
5548
5554
  'TitleBar.getMenuEntries2': wrapGetter(getMenuEntries2),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/title-bar-worker",
3
- "version": "4.23.0",
3
+ "version": "4.24.0",
4
4
  "description": "Title Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",