@lvce-editor/title-bar-worker 4.14.0 → 4.15.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.
@@ -54,61 +54,6 @@ class VError extends Error {
54
54
  }
55
55
  }
56
56
 
57
- class AssertionError extends Error {
58
- constructor(message) {
59
- super(message);
60
- this.name = 'AssertionError';
61
- }
62
- }
63
- const Object$1 = 1;
64
- const Number$1 = 2;
65
- const Array$1 = 3;
66
- const String$1 = 4;
67
- const Boolean$1 = 5;
68
- const Function = 6;
69
- const Null = 7;
70
- const Unknown$1 = 8;
71
- const getType = value => {
72
- switch (typeof value) {
73
- case 'number':
74
- return Number$1;
75
- case 'function':
76
- return Function;
77
- case 'string':
78
- return String$1;
79
- case 'object':
80
- if (value === null) {
81
- return Null;
82
- }
83
- if (Array.isArray(value)) {
84
- return Array$1;
85
- }
86
- return Object$1;
87
- case 'boolean':
88
- return Boolean$1;
89
- default:
90
- return Unknown$1;
91
- }
92
- };
93
- const object = value => {
94
- const type = getType(value);
95
- if (type !== Object$1) {
96
- throw new AssertionError('expected value to be of type object');
97
- }
98
- };
99
- const number = value => {
100
- const type = getType(value);
101
- if (type !== Number$1) {
102
- throw new AssertionError('expected value to be of type number');
103
- }
104
- };
105
- const array = value => {
106
- const type = getType(value);
107
- if (type !== Array$1) {
108
- throw new AssertionError('expected value to be of type array');
109
- }
110
- };
111
-
112
57
  const isMessagePort = value => {
113
58
  return value && value instanceof MessagePort;
114
59
  };
@@ -1383,7 +1328,7 @@ const Backslash$2 = 91;
1383
1328
  const Star$1 = 131;
1384
1329
  const Plus$1 = 132;
1385
1330
 
1386
- const Unknown = 'Unknown';
1331
+ const Unknown$1 = 'Unknown';
1387
1332
  const Backspace = 'Backspace';
1388
1333
  const Tab = 'Tab';
1389
1334
  const Enter = 'Enter';
@@ -1516,7 +1461,7 @@ const keyCodeStringMap = {
1516
1461
  [UpArrow$1]: UpArrow
1517
1462
  };
1518
1463
  const getKeyCodeString = keyCode => {
1519
- return keyCodeStringMap[keyCode] || Unknown;
1464
+ return keyCodeStringMap[keyCode] || Unknown$1;
1520
1465
  };
1521
1466
 
1522
1467
  const CtrlCmd = 1 << 11 >>> 0;
@@ -1558,6 +1503,61 @@ const SetFocusContext = 'Viewlet.setFocusContext';
1558
1503
 
1559
1504
  const FocusTitleBarMenuBar = 26;
1560
1505
 
1506
+ class AssertionError extends Error {
1507
+ constructor(message) {
1508
+ super(message);
1509
+ this.name = 'AssertionError';
1510
+ }
1511
+ }
1512
+ const Object$1 = 1;
1513
+ const Number$1 = 2;
1514
+ const Array$1 = 3;
1515
+ const String$1 = 4;
1516
+ const Boolean$1 = 5;
1517
+ const Function = 6;
1518
+ const Null = 7;
1519
+ const Unknown = 8;
1520
+ const getType = value => {
1521
+ switch (typeof value) {
1522
+ case 'number':
1523
+ return Number$1;
1524
+ case 'function':
1525
+ return Function;
1526
+ case 'string':
1527
+ return String$1;
1528
+ case 'object':
1529
+ if (value === null) {
1530
+ return Null;
1531
+ }
1532
+ if (Array.isArray(value)) {
1533
+ return Array$1;
1534
+ }
1535
+ return Object$1;
1536
+ case 'boolean':
1537
+ return Boolean$1;
1538
+ default:
1539
+ return Unknown;
1540
+ }
1541
+ };
1542
+ const object = value => {
1543
+ const type = getType(value);
1544
+ if (type !== Object$1) {
1545
+ throw new AssertionError('expected value to be of type object');
1546
+ }
1547
+ };
1548
+ const number = value => {
1549
+ const type = getType(value);
1550
+ if (type !== Number$1) {
1551
+ throw new AssertionError('expected value to be of type number');
1552
+ }
1553
+ };
1554
+ const array = value => {
1555
+ const type = getType(value);
1556
+ if (type !== Array$1) {
1557
+ throw new AssertionError('expected value to be of type array');
1558
+ }
1559
+ };
1560
+
1561
1561
  const {
1562
1562
  invoke,
1563
1563
  invokeAndTransfer,
@@ -3031,48 +3031,55 @@ const getMenuEntries$1 = () => {
3031
3031
  id: 'editorLayout',
3032
3032
  label: i18nString(EditorLayout)
3033
3033
  }, menuEntrySeparator, {
3034
- command: 'Explorer.focus',
3034
+ args: ['Explorer'],
3035
+ command: 'Layout.openSideBarViewlet',
3035
3036
  flags: None,
3036
3037
  id: 'explorer',
3037
3038
  label: i18nString(Explorer)
3038
3039
  }, {
3039
- command: 'Search.focus',
3040
+ args: ['Search'],
3041
+ command: 'Layout.openSideBarViewlet',
3040
3042
  flags: None,
3041
3043
  id: 'search',
3042
3044
  label: i18nString(Search)
3043
3045
  }, {
3044
- command: 'SourceControl.focus',
3046
+ args: ['Source Control'],
3047
+ command: 'Layout.openSideBarViewlet',
3045
3048
  flags: None,
3046
3049
  id: 'sourceControl',
3047
3050
  label: i18nString(SourceControl)
3048
3051
  }, {
3049
- command: 'Run.focus',
3052
+ args: ['Run And Debug'],
3053
+ command: 'Layout.openSideBarViewlet',
3050
3054
  flags: None,
3051
3055
  id: 'run',
3052
3056
  label: i18nString(Run$1)
3053
3057
  }, {
3054
- command: 'Extensions.focus',
3058
+ args: ['Extensions'],
3059
+ command: 'Layout.openSideBarViewlet',
3055
3060
  flags: None,
3056
3061
  id: 'extensions',
3057
3062
  label: i18nString(Extensions)
3058
3063
  }, menuEntrySeparator, {
3059
- command: 'Chat.focus',
3064
+ command: 'Layout.openChat',
3060
3065
  flags: None,
3061
3066
  id: 'chat',
3062
3067
  label: i18nString(Chat)
3063
3068
  }, menuEntrySeparator, {
3064
- command: 'Problems.toggle',
3069
+ args: ['Problems'],
3070
+ command: 'Layout.showPanel',
3065
3071
  flags: None,
3066
3072
  id: 'problems',
3067
3073
  label: i18nString(Problems)
3068
3074
  }, {
3069
- command: 'Output.toggle',
3075
+ args: ['Output'],
3076
+ command: 'Layout.showPanel',
3070
3077
  flags: None,
3071
3078
  id: 'output',
3072
3079
  label: i18nString(Output)
3073
3080
  }, {
3074
- args: ['Terminal'],
3075
- command: 'Layout.togglePanel',
3081
+ args: ['Terminals'],
3082
+ command: 'Layout.showPanel',
3076
3083
  flags: None,
3077
3084
  id: 'terminal',
3078
3085
  label: i18nString(Terminal$1)
@@ -3399,29 +3406,33 @@ const handleClick$1 = async (state, buttonName) => {
3399
3406
  };
3400
3407
 
3401
3408
  const commandCenterItems = [{
3402
- label: 'Go to File',
3403
- value: 'file'
3409
+ command: 'QuickPick.showFile',
3410
+ label: 'Go to File'
3404
3411
  }, {
3405
- label: 'Show and Run Commands',
3406
- value: 'commands'
3412
+ command: 'QuickPick.showCommands',
3413
+ label: 'Show and Run Commands'
3407
3414
  }, {
3408
- label: 'Search for Text',
3409
- value: 'search'
3415
+ args: ['Search'],
3416
+ command: 'Layout.openSideBarViewlet',
3417
+ label: 'Search for Text'
3410
3418
  }, {
3411
- label: 'Go to Symbol in Editor',
3412
- value: 'symbol'
3419
+ args: ['symbol'],
3420
+ command: 'QuickPick.show',
3421
+ label: 'Go to Symbol in Editor'
3413
3422
  }, {
3414
- label: 'Start Debugging',
3415
- value: 'debug'
3423
+ args: ['Run And Debug'],
3424
+ command: 'Layout.openSideBarViewlet',
3425
+ label: 'Start Debugging'
3416
3426
  }, {
3417
- label: 'Run Task',
3418
- value: 'task'
3427
+ command: 'QuickPick.showCommands',
3428
+ label: 'Run Task'
3419
3429
  }, {
3420
- label: 'More',
3421
- value: 'more'
3430
+ command: 'QuickPick.showEverything',
3431
+ label: 'More'
3422
3432
  }];
3423
3433
  const handleCommandCenterClick = async state => {
3424
- await invoke('QuickPick.showCustom', commandCenterItems, {
3434
+ await invoke('QuickPick.show', 'custom', commandCenterItems, undefined, {
3435
+ executeItemCommand: true,
3425
3436
  mode: 'quickPick',
3426
3437
  placeholder: 'Search files by name (append : to go to line or @ to go to symbol)',
3427
3438
  waitUntil: 'visible'
@@ -3481,6 +3492,21 @@ const getTotalWidth$1 = entries => {
3481
3492
  }
3482
3493
  return total;
3483
3494
  };
3495
+ const createOverflowEntry = (hiddenEntries, overflowIndex, focusedIndex, isMenuOpen) => {
3496
+ return {
3497
+ ariaLabel: moreDot(),
3498
+ hiddenEntries,
3499
+ icon: Ellipsis,
3500
+ id: OverflowMenuId,
3501
+ isFocused: overflowIndex === focusedIndex,
3502
+ isOpen: overflowIndex === focusedIndex && isMenuOpen,
3503
+ label: '...',
3504
+ width: MoreEntryWidth
3505
+ };
3506
+ };
3507
+ const isOverflowTitleBarEntry = entry => {
3508
+ return entry.id === OverflowMenuId;
3509
+ };
3484
3510
  const getVisibleTitleBarEntries = (entries, width, focusedIndex, isMenuOpen) => {
3485
3511
  array(entries);
3486
3512
  number(width);
@@ -3509,23 +3535,11 @@ const getVisibleTitleBarEntries = (entries, width, focusedIndex, isMenuOpen) =>
3509
3535
  }
3510
3536
  const hiddenEntries = entries.slice(visible.length);
3511
3537
  const overflowIndex = visible.length;
3512
- visible.push({
3513
- ariaLabel: moreDot(),
3514
- hiddenEntries,
3515
- icon: Ellipsis,
3516
- id: OverflowMenuId,
3517
- isFocused: overflowIndex === focusedIndex,
3518
- isOpen: overflowIndex === focusedIndex && isMenuOpen,
3519
- label: '...',
3520
- width: MoreEntryWidth
3521
- });
3538
+ visible.push(createOverflowEntry(hiddenEntries, overflowIndex, focusedIndex, isMenuOpen));
3522
3539
  }
3523
3540
  return visible;
3524
3541
  };
3525
3542
 
3526
- const hasOverflowEntry = entries => {
3527
- return entries.some(entry => entry?.id === OverflowMenuId);
3528
- };
3529
3543
  const getNavigableTitleBarEntries = state => {
3530
3544
  const {
3531
3545
  focusedIndex,
@@ -3533,9 +3547,6 @@ const getNavigableTitleBarEntries = state => {
3533
3547
  titleBarEntries,
3534
3548
  width
3535
3549
  } = state;
3536
- if (hasOverflowEntry(titleBarEntries)) {
3537
- return titleBarEntries;
3538
- }
3539
3550
  return getVisibleTitleBarEntries(titleBarEntries, width, focusedIndex, isMenuOpen);
3540
3551
  };
3541
3552
 
@@ -3688,14 +3699,28 @@ const openMenuAtIndex = async (state, index, shouldBeFocused) => {
3688
3699
  if (!titleBarEntry) {
3689
3700
  return state;
3690
3701
  }
3691
- const {
3692
- id
3693
- } = titleBarEntry;
3694
- const rawItems = id === OverflowMenuId ? getOverflowMenuItems(titleBarEntry.hiddenEntries || []) : await getMenuEntries2(state, {
3695
- menuId: id,
3696
- platform
3697
- });
3698
- const items = id === OverflowMenuId ? rawItems : await addMenuEntryKeyBindings(rawItems);
3702
+ let rawItems;
3703
+ let menuId;
3704
+ const isOverflow = isOverflowTitleBarEntry(titleBarEntry);
3705
+ if (isOverflow) {
3706
+ rawItems = getOverflowMenuItems(titleBarEntry.hiddenEntries);
3707
+ menuId = undefined;
3708
+ } else {
3709
+ if (titleBarEntry.id === undefined) {
3710
+ return {
3711
+ ...state,
3712
+ focusedIndex: index,
3713
+ isMenuOpen: true,
3714
+ menus: []
3715
+ };
3716
+ }
3717
+ rawItems = await getMenuEntries2(state, {
3718
+ menuId: titleBarEntry.id,
3719
+ platform
3720
+ });
3721
+ menuId = titleBarEntry.id;
3722
+ }
3723
+ const items = isOverflow ? rawItems : await addMenuEntryKeyBindings(rawItems);
3699
3724
  const relevantEntries = titleBarEntries.slice(0, index);
3700
3725
  const totalWidths = getTotalWidth(relevantEntries);
3701
3726
  const offset = totalWidths;
@@ -3709,7 +3734,7 @@ const openMenuAtIndex = async (state, index, shouldBeFocused) => {
3709
3734
  const menu = {
3710
3735
  focusedIndex: menuFocusedIndex,
3711
3736
  height,
3712
- id: id === OverflowMenuId ? undefined : id,
3737
+ id: menuId,
3713
3738
  items,
3714
3739
  level: 0,
3715
3740
  width,
@@ -4413,7 +4438,6 @@ const getActiveEntryLabelDom = isFocused => {
4413
4438
  return [activeEntryLabelNode];
4414
4439
  };
4415
4440
  const getItemVirtualDom = item => {
4416
- // @ts-ignore
4417
4441
  const {
4418
4442
  ariaLabel,
4419
4443
  isFocused,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/title-bar-worker",
3
- "version": "4.14.0",
3
+ "version": "4.15.0",
4
4
  "description": "Title Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",