@lvce-editor/title-bar-worker 2.0.0 → 2.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.
- package/dist/titleBarWorkerMain.js +216 -139
- package/package.json +1 -1
|
@@ -876,41 +876,25 @@ const isEqual$2 = (oldState, newState) => {
|
|
|
876
876
|
return oldState.titleBarEntries === newState.titleBarEntries && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen;
|
|
877
877
|
};
|
|
878
878
|
|
|
879
|
-
const DiffEntries = {
|
|
880
|
-
__proto__: null,
|
|
881
|
-
diffType: diffType$2,
|
|
882
|
-
isEqual: isEqual$2
|
|
883
|
-
};
|
|
884
|
-
|
|
885
879
|
const diffType$1 = RenderFocusedIndex;
|
|
886
880
|
const isEqual$1 = (oldState, newState) => {
|
|
887
881
|
return oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen;
|
|
888
882
|
};
|
|
889
883
|
|
|
890
|
-
const DiffFocusedIndex = {
|
|
891
|
-
__proto__: null,
|
|
892
|
-
diffType: diffType$1,
|
|
893
|
-
isEqual: isEqual$1
|
|
894
|
-
};
|
|
895
|
-
|
|
896
884
|
const diffType = RenderMenus;
|
|
897
885
|
const isEqual = (oldState, newState) => {
|
|
898
886
|
return oldState.menus === newState.menus;
|
|
899
887
|
};
|
|
900
888
|
|
|
901
|
-
const
|
|
902
|
-
|
|
903
|
-
diffType,
|
|
904
|
-
isEqual
|
|
905
|
-
};
|
|
906
|
-
|
|
907
|
-
const modules = [DiffEntries, DiffFocusedIndex, DiffMenus];
|
|
889
|
+
const modules = [isEqual$2, isEqual$1, isEqual];
|
|
890
|
+
const numbers = [diffType$2, diffType$1, diffType];
|
|
908
891
|
|
|
909
892
|
const diff = (oldState, newState) => {
|
|
910
893
|
const diffResult = [];
|
|
911
|
-
for (
|
|
912
|
-
|
|
913
|
-
|
|
894
|
+
for (let i = 0; i < modules.length; i++) {
|
|
895
|
+
const fn = modules[i];
|
|
896
|
+
if (!fn(oldState, newState)) {
|
|
897
|
+
diffResult.push(numbers[i]);
|
|
914
898
|
}
|
|
915
899
|
}
|
|
916
900
|
return diffResult;
|
|
@@ -944,7 +928,7 @@ const diff2 = uid => {
|
|
|
944
928
|
return diff(oldState, newState);
|
|
945
929
|
};
|
|
946
930
|
|
|
947
|
-
const commandsIds = ['closeMenu', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusPrevious', 'handleClick', 'handleFocus', 'handleKeyArrowDown', 'handleKeyArrowLeft', 'handleKeyArrowRight', 'handleKeyArrowUp', 'handleKeyEnd', 'handleKeyEnter', 'handleKeyEscape', 'handleKeyHome', 'handleKeySpace', 'handleMenuClick', 'handleMenuMouseOver', 'handleMouseOut', 'handleMouseOver', 'handlePointerOver', 'handlePointerOut', 'toggleIndex', 'toggleMenu'];
|
|
931
|
+
const commandsIds = ['closeMenu', 'handleClickAt', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusPrevious', 'handleClick', 'handleFocus', 'handleFocusOut', 'handleKeyArrowDown', 'handleKeyArrowLeft', 'handleKeyArrowRight', 'handleKeyArrowUp', 'handleKeyEnd', 'handleKeyEnter', 'handleKeyEscape', 'handleKeyHome', 'handleKeySpace', 'handleMenuClick', 'handleMenuMouseOver', 'handleMouseOut', 'handleMouseOver', 'handlePointerOver', 'handlePointerOut', 'toggleIndex', 'toggleMenu'];
|
|
948
932
|
|
|
949
933
|
const getCommandIds = () => {
|
|
950
934
|
return commandsIds;
|
|
@@ -1151,12 +1135,12 @@ const getMenuEntries$d = () => {
|
|
|
1151
1135
|
id: 'undo',
|
|
1152
1136
|
label: undo(),
|
|
1153
1137
|
flags: Disabled,
|
|
1154
|
-
command: /* TODO
|
|
1138
|
+
command: /* TODO */'-1'
|
|
1155
1139
|
}, {
|
|
1156
1140
|
id: 'redo',
|
|
1157
1141
|
label: redo(),
|
|
1158
1142
|
flags: Disabled,
|
|
1159
|
-
command: /* TODO
|
|
1143
|
+
command: /* TODO */'-1'
|
|
1160
1144
|
}, menuEntrySeparator, {
|
|
1161
1145
|
id: 'cut',
|
|
1162
1146
|
label: cut(),
|
|
@@ -1231,6 +1215,7 @@ const exit = () => {
|
|
|
1231
1215
|
|
|
1232
1216
|
const Web = 1;
|
|
1233
1217
|
const Electron = 2;
|
|
1218
|
+
const Remote = 3;
|
|
1234
1219
|
|
|
1235
1220
|
const id$8 = File$1;
|
|
1236
1221
|
const getMenuEntries$c = platform => {
|
|
@@ -1238,7 +1223,7 @@ const getMenuEntries$c = platform => {
|
|
|
1238
1223
|
id: 'newFile',
|
|
1239
1224
|
label: newFile(),
|
|
1240
1225
|
flags: None$1,
|
|
1241
|
-
command: -1
|
|
1226
|
+
command: '-1'
|
|
1242
1227
|
}, {
|
|
1243
1228
|
id: 'newWindow',
|
|
1244
1229
|
label: newWindow(),
|
|
@@ -1301,10 +1286,13 @@ const MenuEntriesGo = {
|
|
|
1301
1286
|
const About = 'About';
|
|
1302
1287
|
const CheckForUpdates = 'Check For Updates';
|
|
1303
1288
|
const ClearRecentlyOpened = 'Clear Recently Opened';
|
|
1289
|
+
const Close = 'Close';
|
|
1304
1290
|
const Edit = 'Edit';
|
|
1305
1291
|
const File = 'File';
|
|
1306
1292
|
const Go = 'Go';
|
|
1307
1293
|
const Help = 'Help';
|
|
1294
|
+
const Maximize = 'Maximize';
|
|
1295
|
+
const Minimize = 'Minimize';
|
|
1308
1296
|
const MoreDot = 'More ...';
|
|
1309
1297
|
const OpenProcessExplorer = 'Open Process Explorer';
|
|
1310
1298
|
const Run = 'Run';
|
|
@@ -1544,6 +1532,15 @@ const terminal = () => {
|
|
|
1544
1532
|
const help = () => {
|
|
1545
1533
|
return i18nString(Help);
|
|
1546
1534
|
};
|
|
1535
|
+
const minimize$1 = () => {
|
|
1536
|
+
return i18nString(Minimize);
|
|
1537
|
+
};
|
|
1538
|
+
const maximize$1 = () => {
|
|
1539
|
+
return i18nString(Maximize);
|
|
1540
|
+
};
|
|
1541
|
+
const close$1 = () => {
|
|
1542
|
+
return i18nString(Close);
|
|
1543
|
+
};
|
|
1547
1544
|
|
|
1548
1545
|
const getMenuEntries$5 = () => {
|
|
1549
1546
|
return [{
|
|
@@ -1656,6 +1653,50 @@ const getMenuEntries$1 = (id, platform) => {
|
|
|
1656
1653
|
return menu.getMenuEntries(platform);
|
|
1657
1654
|
};
|
|
1658
1655
|
|
|
1656
|
+
const getTitleBarButtonsWeb = () => {
|
|
1657
|
+
return [];
|
|
1658
|
+
};
|
|
1659
|
+
const getTitleBarButtonsRemote = () => {
|
|
1660
|
+
return [];
|
|
1661
|
+
};
|
|
1662
|
+
const getTitleBarButtonsElectron = (controlsOverlayEnabled, titleBarStyleCustom) => {
|
|
1663
|
+
if (controlsOverlayEnabled) {
|
|
1664
|
+
return [];
|
|
1665
|
+
}
|
|
1666
|
+
if (titleBarStyleCustom) {
|
|
1667
|
+
// TODO don't render title bar buttons on windows when electron window controls overlay is enabled
|
|
1668
|
+
return [{
|
|
1669
|
+
label: minimize$1(),
|
|
1670
|
+
icon: 'Minimize',
|
|
1671
|
+
id: 'Minimize',
|
|
1672
|
+
onClick: 'handleClickMinimize'
|
|
1673
|
+
}, {
|
|
1674
|
+
label: maximize$1(),
|
|
1675
|
+
icon: 'Maximize',
|
|
1676
|
+
id: 'ToggleMaximize',
|
|
1677
|
+
onClick: 'handleClickToggleMaximize'
|
|
1678
|
+
}, {
|
|
1679
|
+
label: close$1(),
|
|
1680
|
+
icon: 'ChromeClose',
|
|
1681
|
+
id: 'Close',
|
|
1682
|
+
onClick: 'handleClickClose'
|
|
1683
|
+
}];
|
|
1684
|
+
}
|
|
1685
|
+
return [];
|
|
1686
|
+
};
|
|
1687
|
+
const getTitleBarButtons = (platform, controlsOverlayEnabled, titleBarStyleCustom) => {
|
|
1688
|
+
switch (platform) {
|
|
1689
|
+
case Electron:
|
|
1690
|
+
return getTitleBarButtonsElectron(controlsOverlayEnabled, titleBarStyleCustom);
|
|
1691
|
+
case Web:
|
|
1692
|
+
return getTitleBarButtonsWeb();
|
|
1693
|
+
case Remote:
|
|
1694
|
+
return getTitleBarButtonsRemote();
|
|
1695
|
+
default:
|
|
1696
|
+
return [];
|
|
1697
|
+
}
|
|
1698
|
+
};
|
|
1699
|
+
|
|
1659
1700
|
const MaskIconCheck = 'MaskIconCheck';
|
|
1660
1701
|
const Menu$1 = 'Menu';
|
|
1661
1702
|
const MenuItem$1 = 'MenuItem';
|
|
@@ -1685,7 +1726,6 @@ const Separator = 'separator';
|
|
|
1685
1726
|
|
|
1686
1727
|
const Button = 1;
|
|
1687
1728
|
const Div = 4;
|
|
1688
|
-
const Text = 12;
|
|
1689
1729
|
const I = 16;
|
|
1690
1730
|
const Img = 17;
|
|
1691
1731
|
const Span = 8;
|
|
@@ -1719,6 +1759,14 @@ const createTitleBarButton = button => {
|
|
|
1719
1759
|
const mergeClassNames = (...classNames) => {
|
|
1720
1760
|
return classNames.filter(Boolean).join(' ');
|
|
1721
1761
|
};
|
|
1762
|
+
const Text = 12;
|
|
1763
|
+
const text = data => {
|
|
1764
|
+
return {
|
|
1765
|
+
type: Text,
|
|
1766
|
+
text: data,
|
|
1767
|
+
childCount: 0
|
|
1768
|
+
};
|
|
1769
|
+
};
|
|
1722
1770
|
|
|
1723
1771
|
const getTitleBarButtonsVirtualDom = buttons => {
|
|
1724
1772
|
const dom = [{
|
|
@@ -1754,14 +1802,6 @@ const HandlePointerOver = 'handlePointerOver';
|
|
|
1754
1802
|
const HandleMenuClick = 'handleMenuClick';
|
|
1755
1803
|
const HandleMenuMouseOver = 'handleMenuMouseOver';
|
|
1756
1804
|
|
|
1757
|
-
const text = data => {
|
|
1758
|
-
return {
|
|
1759
|
-
type: Text,
|
|
1760
|
-
text: data,
|
|
1761
|
-
childCount: 0
|
|
1762
|
-
};
|
|
1763
|
-
};
|
|
1764
|
-
|
|
1765
1805
|
const getItemVirtualDom = item => {
|
|
1766
1806
|
// @ts-ignore
|
|
1767
1807
|
const {
|
|
@@ -1823,18 +1863,29 @@ const getTitleVirtualDom = title => {
|
|
|
1823
1863
|
return [text(title)];
|
|
1824
1864
|
};
|
|
1825
1865
|
|
|
1826
|
-
const
|
|
1866
|
+
const maximize = async () => {
|
|
1867
|
+
await invoke('ElectronWindow.unmaximize');
|
|
1868
|
+
};
|
|
1869
|
+
const minimize = async () => {
|
|
1870
|
+
await invoke('ElectronWindow.minimize');
|
|
1871
|
+
};
|
|
1872
|
+
const close = async () => {
|
|
1827
1873
|
await invoke('ElectronWindow.close');
|
|
1874
|
+
};
|
|
1875
|
+
|
|
1876
|
+
const handleClickClose = async state => {
|
|
1877
|
+
await close();
|
|
1828
1878
|
return state;
|
|
1829
1879
|
};
|
|
1830
1880
|
|
|
1831
1881
|
const handleClickMinimize = async state => {
|
|
1832
|
-
await
|
|
1882
|
+
await minimize();
|
|
1833
1883
|
return state;
|
|
1834
1884
|
};
|
|
1835
1885
|
|
|
1836
1886
|
const handleClickToggleMaximize = async state => {
|
|
1837
|
-
|
|
1887
|
+
const fn = maximize;
|
|
1888
|
+
await fn();
|
|
1838
1889
|
return state;
|
|
1839
1890
|
};
|
|
1840
1891
|
|
|
@@ -2101,6 +2152,15 @@ const getFontString = (fontWeight, fontSize, fontFamily) => {
|
|
|
2101
2152
|
return `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
2102
2153
|
};
|
|
2103
2154
|
|
|
2155
|
+
const createTextMeasureContext = () => {
|
|
2156
|
+
const canvas = new OffscreenCanvas(0, 0);
|
|
2157
|
+
const ctx = canvas.getContext('2d');
|
|
2158
|
+
if (!ctx) {
|
|
2159
|
+
throw new Error('Failed to get canvas context 2d');
|
|
2160
|
+
}
|
|
2161
|
+
return ctx;
|
|
2162
|
+
};
|
|
2163
|
+
|
|
2104
2164
|
const state = {
|
|
2105
2165
|
ctx: undefined
|
|
2106
2166
|
};
|
|
@@ -2112,16 +2172,8 @@ const getOrCreate = createCtx => {
|
|
|
2112
2172
|
return state.ctx;
|
|
2113
2173
|
};
|
|
2114
2174
|
|
|
2115
|
-
const createCtx = () => {
|
|
2116
|
-
const canvas = new OffscreenCanvas(0, 0);
|
|
2117
|
-
const ctx = /** @type {OffscreenCanvasRenderingContext2D} */canvas.getContext('2d');
|
|
2118
|
-
if (!ctx) {
|
|
2119
|
-
throw new Error('Failed to get canvas context 2d');
|
|
2120
|
-
}
|
|
2121
|
-
return ctx;
|
|
2122
|
-
};
|
|
2123
2175
|
const getContext = () => {
|
|
2124
|
-
const ctx = getOrCreate(
|
|
2176
|
+
const ctx = getOrCreate(createTextMeasureContext);
|
|
2125
2177
|
return ctx;
|
|
2126
2178
|
};
|
|
2127
2179
|
|
|
@@ -2145,7 +2197,6 @@ const measureTextWidth = (text, fontWeight, fontSize, fontFamily, letterSpacing,
|
|
|
2145
2197
|
const letterSpacingString = getLetterSpacingString(letterSpacing);
|
|
2146
2198
|
const fontString = getFontString(fontWeight, fontSize, fontFamily);
|
|
2147
2199
|
const ctx = getContext();
|
|
2148
|
-
// @ts-ignore
|
|
2149
2200
|
ctx.letterSpacing = letterSpacingString;
|
|
2150
2201
|
ctx.font = fontString;
|
|
2151
2202
|
const metrics = ctx.measureText(text);
|
|
@@ -2242,6 +2293,25 @@ const renderFocusedIndex = (oldState, newState) => {
|
|
|
2242
2293
|
return ['Viewlet.focusSelector', '.ViewletTitleBarMenuBar'];
|
|
2243
2294
|
};
|
|
2244
2295
|
|
|
2296
|
+
const checkboxChecked = {
|
|
2297
|
+
type: Div,
|
|
2298
|
+
className: mergeClassNames(MenuItem$1, MenuItemCheckMark),
|
|
2299
|
+
role: MenuItemCheckBox,
|
|
2300
|
+
ariaChecked: true,
|
|
2301
|
+
tabIndex: -1,
|
|
2302
|
+
childCount: 2
|
|
2303
|
+
};
|
|
2304
|
+
const checkMark = {
|
|
2305
|
+
type: Div,
|
|
2306
|
+
className: mergeClassNames(MenuItemCheckmarkIcon, MaskIconCheck)
|
|
2307
|
+
};
|
|
2308
|
+
const getMenuItemCheckedDom = menuItem => {
|
|
2309
|
+
const {
|
|
2310
|
+
label
|
|
2311
|
+
} = menuItem;
|
|
2312
|
+
return [checkboxChecked, checkMark, text(label)];
|
|
2313
|
+
};
|
|
2314
|
+
|
|
2245
2315
|
const getKeyBindingString = (key, altKey, ctrlKey, shiftKey, metaKey) => {
|
|
2246
2316
|
let string = '';
|
|
2247
2317
|
if (ctrlKey) {
|
|
@@ -2471,70 +2541,6 @@ const parseKey = rawKey => {
|
|
|
2471
2541
|
};
|
|
2472
2542
|
};
|
|
2473
2543
|
|
|
2474
|
-
const separator = {
|
|
2475
|
-
type: Div,
|
|
2476
|
-
className: MenuItemSeparator,
|
|
2477
|
-
role: Separator,
|
|
2478
|
-
childCount: 1
|
|
2479
|
-
};
|
|
2480
|
-
const separatorLine = {
|
|
2481
|
-
type: Div,
|
|
2482
|
-
className: MenuItemSeparatorLine,
|
|
2483
|
-
childCount: 0
|
|
2484
|
-
};
|
|
2485
|
-
const checkboxUnchecked = {
|
|
2486
|
-
type: Div,
|
|
2487
|
-
className: MenuItem$1,
|
|
2488
|
-
role: MenuItemCheckBox,
|
|
2489
|
-
ariaChecked: false,
|
|
2490
|
-
tabIndex: -1,
|
|
2491
|
-
childCount: 1
|
|
2492
|
-
};
|
|
2493
|
-
const checkboxChecked = {
|
|
2494
|
-
type: Div,
|
|
2495
|
-
className: mergeClassNames(MenuItem$1, MenuItemCheckMark),
|
|
2496
|
-
role: MenuItemCheckBox,
|
|
2497
|
-
ariaChecked: true,
|
|
2498
|
-
tabIndex: -1,
|
|
2499
|
-
childCount: 2
|
|
2500
|
-
};
|
|
2501
|
-
const disabled = {
|
|
2502
|
-
type: Div,
|
|
2503
|
-
className: MenuItem$1,
|
|
2504
|
-
role: MenuItem,
|
|
2505
|
-
tabIndex: -1,
|
|
2506
|
-
disabled: true,
|
|
2507
|
-
childCount: 1
|
|
2508
|
-
};
|
|
2509
|
-
const arrowRight = {
|
|
2510
|
-
type: Div,
|
|
2511
|
-
className: MenuItemSubMenuArrowRight,
|
|
2512
|
-
childCount: 0
|
|
2513
|
-
};
|
|
2514
|
-
const getMenuItemSeparatorDom = menuItem => {
|
|
2515
|
-
return [separator, separatorLine];
|
|
2516
|
-
};
|
|
2517
|
-
const getMenuItemCheckedDom = menuItem => {
|
|
2518
|
-
const {
|
|
2519
|
-
label
|
|
2520
|
-
} = menuItem;
|
|
2521
|
-
return [checkboxChecked, {
|
|
2522
|
-
type: Div,
|
|
2523
|
-
className: mergeClassNames(MenuItemCheckmarkIcon, MaskIconCheck)
|
|
2524
|
-
}, text(label)];
|
|
2525
|
-
};
|
|
2526
|
-
const getMenuItemUncheckedDom = menuItem => {
|
|
2527
|
-
const {
|
|
2528
|
-
label
|
|
2529
|
-
} = menuItem;
|
|
2530
|
-
return [checkboxUnchecked, text(label)];
|
|
2531
|
-
};
|
|
2532
|
-
const getMenuItemDisabledDom = menuItem => {
|
|
2533
|
-
const {
|
|
2534
|
-
label
|
|
2535
|
-
} = menuItem;
|
|
2536
|
-
return [disabled, text(label)];
|
|
2537
|
-
};
|
|
2538
2544
|
const getMenuItemDefaultDom = menuItem => {
|
|
2539
2545
|
const {
|
|
2540
2546
|
label,
|
|
@@ -2565,6 +2571,46 @@ const getMenuItemDefaultDom = menuItem => {
|
|
|
2565
2571
|
}
|
|
2566
2572
|
return dom;
|
|
2567
2573
|
};
|
|
2574
|
+
|
|
2575
|
+
const disabled = {
|
|
2576
|
+
type: Div,
|
|
2577
|
+
className: MenuItem$1,
|
|
2578
|
+
role: MenuItem,
|
|
2579
|
+
tabIndex: -1,
|
|
2580
|
+
disabled: true,
|
|
2581
|
+
childCount: 1
|
|
2582
|
+
};
|
|
2583
|
+
const getMenuItemDisabledDom = menuItem => {
|
|
2584
|
+
const {
|
|
2585
|
+
label
|
|
2586
|
+
} = menuItem;
|
|
2587
|
+
return [disabled, text(label)];
|
|
2588
|
+
};
|
|
2589
|
+
|
|
2590
|
+
const getMenuItemsNoopDom = () => {
|
|
2591
|
+
return [];
|
|
2592
|
+
};
|
|
2593
|
+
|
|
2594
|
+
const separator = {
|
|
2595
|
+
type: Div,
|
|
2596
|
+
className: MenuItemSeparator,
|
|
2597
|
+
role: Separator,
|
|
2598
|
+
childCount: 1
|
|
2599
|
+
};
|
|
2600
|
+
const separatorLine = {
|
|
2601
|
+
type: Div,
|
|
2602
|
+
className: MenuItemSeparatorLine,
|
|
2603
|
+
childCount: 0
|
|
2604
|
+
};
|
|
2605
|
+
const getMenuItemSeparatorDom = menuItem => {
|
|
2606
|
+
return [separator, separatorLine];
|
|
2607
|
+
};
|
|
2608
|
+
|
|
2609
|
+
const arrowRight = {
|
|
2610
|
+
type: Div,
|
|
2611
|
+
className: MenuItemSubMenuArrowRight,
|
|
2612
|
+
childCount: 0
|
|
2613
|
+
};
|
|
2568
2614
|
const getMenuItemSubMenuDom = menuItem => {
|
|
2569
2615
|
const {
|
|
2570
2616
|
label,
|
|
@@ -2588,48 +2634,65 @@ const getMenuItemSubMenuDom = menuItem => {
|
|
|
2588
2634
|
childCount: 2
|
|
2589
2635
|
}, text(label), arrowRight];
|
|
2590
2636
|
};
|
|
2591
|
-
|
|
2637
|
+
|
|
2638
|
+
const checkboxUnchecked = {
|
|
2639
|
+
type: Div,
|
|
2640
|
+
className: MenuItem$1,
|
|
2641
|
+
role: MenuItemCheckBox,
|
|
2642
|
+
ariaChecked: false,
|
|
2643
|
+
tabIndex: -1,
|
|
2644
|
+
childCount: 1
|
|
2645
|
+
};
|
|
2646
|
+
const getMenuItemUncheckedDom = menuItem => {
|
|
2592
2647
|
const {
|
|
2593
|
-
|
|
2648
|
+
label
|
|
2594
2649
|
} = menuItem;
|
|
2650
|
+
return [checkboxUnchecked, text(label)];
|
|
2651
|
+
};
|
|
2652
|
+
|
|
2653
|
+
const getMenuItemRenderer = flags => {
|
|
2595
2654
|
switch (flags) {
|
|
2596
2655
|
case None$1:
|
|
2597
2656
|
case RestoreFocus:
|
|
2598
2657
|
case Ignore:
|
|
2599
|
-
return getMenuItemDefaultDom
|
|
2658
|
+
return getMenuItemDefaultDom;
|
|
2600
2659
|
case Separator$1:
|
|
2601
|
-
return getMenuItemSeparatorDom
|
|
2660
|
+
return getMenuItemSeparatorDom;
|
|
2602
2661
|
case Checked:
|
|
2603
|
-
return getMenuItemCheckedDom
|
|
2662
|
+
return getMenuItemCheckedDom;
|
|
2604
2663
|
case Unchecked:
|
|
2605
|
-
return getMenuItemUncheckedDom
|
|
2664
|
+
return getMenuItemUncheckedDom;
|
|
2606
2665
|
case Disabled:
|
|
2607
|
-
return getMenuItemDisabledDom
|
|
2666
|
+
return getMenuItemDisabledDom;
|
|
2608
2667
|
case SubMenu:
|
|
2609
|
-
return getMenuItemSubMenuDom
|
|
2668
|
+
return getMenuItemSubMenuDom;
|
|
2610
2669
|
default:
|
|
2611
|
-
return
|
|
2670
|
+
return getMenuItemsNoopDom;
|
|
2612
2671
|
}
|
|
2613
2672
|
};
|
|
2673
|
+
|
|
2674
|
+
const getMenuItemVirtualDom = menuItem => {
|
|
2675
|
+
const {
|
|
2676
|
+
flags
|
|
2677
|
+
} = menuItem;
|
|
2678
|
+
const fn = getMenuItemRenderer(flags);
|
|
2679
|
+
return fn(menuItem);
|
|
2680
|
+
};
|
|
2681
|
+
|
|
2614
2682
|
const getMenuVirtualDom = menuItems => {
|
|
2615
|
-
const dom = [
|
|
2616
|
-
dom.push({
|
|
2683
|
+
const dom = [{
|
|
2617
2684
|
type: Div,
|
|
2618
2685
|
className: Menu$1,
|
|
2619
2686
|
role: Menu,
|
|
2620
2687
|
tabIndex: -1,
|
|
2621
2688
|
childCount: menuItems.length
|
|
2622
|
-
});
|
|
2623
|
-
dom.push(...menuItems.flatMap(getMenuItemVirtualDom));
|
|
2689
|
+
}, ...menuItems.flatMap(getMenuItemVirtualDom)];
|
|
2624
2690
|
return dom;
|
|
2625
2691
|
};
|
|
2626
2692
|
|
|
2627
2693
|
const getVisible = (items, focusedIndex, expanded, level) => {
|
|
2628
2694
|
const visibleItems = [];
|
|
2629
|
-
|
|
2630
|
-
length
|
|
2631
|
-
} = items;
|
|
2632
|
-
for (let i = 0; i < length; i++) {
|
|
2695
|
+
for (let i = 0; i < items.length; i++) {
|
|
2633
2696
|
const item = items[i];
|
|
2634
2697
|
const {
|
|
2635
2698
|
flags,
|
|
@@ -2649,7 +2712,7 @@ const getVisible = (items, focusedIndex, expanded, level) => {
|
|
|
2649
2712
|
|
|
2650
2713
|
const SetMenus = 'setMenus';
|
|
2651
2714
|
|
|
2652
|
-
const
|
|
2715
|
+
const renderMenus = (oldState, newState) => {
|
|
2653
2716
|
const oldMenus = oldState.menus;
|
|
2654
2717
|
const newMenus = newState.menus;
|
|
2655
2718
|
const oldLength = oldMenus.length;
|
|
@@ -2684,7 +2747,7 @@ const getRenderer = diffType => {
|
|
|
2684
2747
|
case RenderFocusedIndex:
|
|
2685
2748
|
return renderFocusedIndex;
|
|
2686
2749
|
case RenderMenus:
|
|
2687
|
-
return
|
|
2750
|
+
return renderMenus;
|
|
2688
2751
|
default:
|
|
2689
2752
|
throw new Error('unknown renderer');
|
|
2690
2753
|
}
|
|
@@ -2694,7 +2757,10 @@ const applyRender = (oldState, newState, diffResult) => {
|
|
|
2694
2757
|
const commands = [];
|
|
2695
2758
|
for (const item of diffResult) {
|
|
2696
2759
|
const fn = getRenderer(item);
|
|
2697
|
-
|
|
2760
|
+
const result = fn(oldState, newState);
|
|
2761
|
+
if (result.length > 0) {
|
|
2762
|
+
commands.push(result);
|
|
2763
|
+
}
|
|
2698
2764
|
}
|
|
2699
2765
|
return commands;
|
|
2700
2766
|
};
|
|
@@ -2704,6 +2770,7 @@ const render2 = async (uid, diffResult) => {
|
|
|
2704
2770
|
oldState,
|
|
2705
2771
|
newState
|
|
2706
2772
|
} = get(uid);
|
|
2773
|
+
set(uid, newState, newState);
|
|
2707
2774
|
const commands = applyRender(oldState, newState, diffResult);
|
|
2708
2775
|
return commands;
|
|
2709
2776
|
};
|
|
@@ -2869,11 +2936,19 @@ const handleClickAt = async (state, button, x, y) => {
|
|
|
2869
2936
|
return handleClick(state, button, index);
|
|
2870
2937
|
};
|
|
2871
2938
|
|
|
2939
|
+
const setFocus = async focusKey => {
|
|
2940
|
+
await invoke('Focus.setFocus', focusKey);
|
|
2941
|
+
};
|
|
2942
|
+
|
|
2872
2943
|
// TODO remove this file and merge with whenExpressions
|
|
2873
2944
|
const TitleBarMenuBar = FocusTitleBarMenuBar;
|
|
2874
2945
|
|
|
2875
2946
|
const handleFocus = async state => {
|
|
2876
|
-
await
|
|
2947
|
+
await setFocus(TitleBarMenuBar);
|
|
2948
|
+
return state;
|
|
2949
|
+
};
|
|
2950
|
+
|
|
2951
|
+
const handleFocusOut = async state => {
|
|
2877
2952
|
return state;
|
|
2878
2953
|
};
|
|
2879
2954
|
|
|
@@ -3261,18 +3336,17 @@ const wrapCommand = fn => {
|
|
|
3261
3336
|
|
|
3262
3337
|
const commandMap = {
|
|
3263
3338
|
'TitleBar.getButtonsVirtualDom': getTitleBarButtonsVirtualDom,
|
|
3264
|
-
'TitleBar.handleContextMenu': handleContextMenu,
|
|
3265
3339
|
'TitleBar.getIconVirtualDom': getTitleBarIconVirtualDom,
|
|
3266
3340
|
'TitleBar.getMenuEntries': getMenuEntries$1,
|
|
3267
3341
|
'TitleBar.getMenuIds': getMenuIds,
|
|
3268
3342
|
'TitleBar.getTitleVirtualDom': getTitleVirtualDom,
|
|
3269
3343
|
'TitleBar.handleButtonsClick': handleClick$1,
|
|
3344
|
+
'TitleBar.handleContextMenu': handleContextMenu,
|
|
3270
3345
|
'TitleBar.renderEventListeners': renderEventListeners,
|
|
3271
3346
|
'TitleBarMenuBar.closeMenu': closeMenu,
|
|
3272
3347
|
'TitleBarMenuBar.create': create,
|
|
3273
|
-
'TitleBarMenuBar.focus': wrapCommand(focus),
|
|
3274
3348
|
'TitleBarMenuBar.diff2': diff2,
|
|
3275
|
-
'TitleBarMenuBar.
|
|
3349
|
+
'TitleBarMenuBar.focus': wrapCommand(focus),
|
|
3276
3350
|
'TitleBarMenuBar.focusFirst': wrapCommand(focusFirst),
|
|
3277
3351
|
'TitleBarMenuBar.focusIndex': wrapCommand(focusLast),
|
|
3278
3352
|
'TitleBarMenuBar.focusLast': wrapCommand(focusIndex),
|
|
@@ -3283,16 +3357,16 @@ const commandMap = {
|
|
|
3283
3357
|
'TitleBarMenuBar.getMenus': getMenus,
|
|
3284
3358
|
'TitleBarMenuBar.getVirtualDom': getTitleBarMenuBarVirtualDom,
|
|
3285
3359
|
'TitleBarMenuBar.handleClick': wrapCommand(handleClick),
|
|
3360
|
+
'TitleBarMenuBar.getTitleBarButtons': getTitleBarButtons,
|
|
3361
|
+
'TitleBarMenuBar.handleClickAt': wrapCommand(handleClickAt),
|
|
3286
3362
|
'TitleBarMenuBar.handleFocus': wrapCommand(handleFocus),
|
|
3363
|
+
'TitleBarMenuBar.handleFocusOut': wrapCommand(handleFocusOut),
|
|
3287
3364
|
'TitleBarMenuBar.handleKeyArrowDown': wrapCommand(handleKeyArrowDown),
|
|
3288
3365
|
'TitleBarMenuBar.handleKeyArrowLeft': wrapCommand(handleKeyArrowLeft),
|
|
3289
3366
|
'TitleBarMenuBar.handleKeyArrowRight': wrapCommand(handleKeyArrowRight),
|
|
3290
3367
|
'TitleBarMenuBar.handleKeyArrowUp': wrapCommand(handleKeyArrowUp),
|
|
3291
|
-
'TitleBarMenuBar.handleClickAt': wrapCommand(handleClickAt),
|
|
3292
|
-
'TitleBarMenuBar.handlePointerOver': wrapCommand(handlePointerOver),
|
|
3293
3368
|
'TitleBarMenuBar.handleKeyEnd': wrapCommand(handleKeyEnd),
|
|
3294
3369
|
'TitleBarMenuBar.handleKeyEnter': wrapCommand(handleKeyEnter),
|
|
3295
|
-
'TitleBarMenuBar.handlePointerOut': wrapCommand(handlePointerOut),
|
|
3296
3370
|
'TitleBarMenuBar.handleKeyEscape': wrapCommand(handleKeyEscape),
|
|
3297
3371
|
'TitleBarMenuBar.handleKeyHome': wrapCommand(handleKeyHome),
|
|
3298
3372
|
'TitleBarMenuBar.handleKeySpace': wrapCommand(handleKeySpace),
|
|
@@ -3300,7 +3374,10 @@ const commandMap = {
|
|
|
3300
3374
|
'TitleBarMenuBar.handleMenuMouseOver': wrapCommand(handleMenuMouseOver),
|
|
3301
3375
|
'TitleBarMenuBar.handleMouseOut': wrapCommand(handleMouseOut),
|
|
3302
3376
|
'TitleBarMenuBar.handleMouseOver': wrapCommand(handleMouseOver),
|
|
3377
|
+
'TitleBarMenuBar.handlePointerOut': wrapCommand(handlePointerOut),
|
|
3378
|
+
'TitleBarMenuBar.handlePointerOver': wrapCommand(handlePointerOver),
|
|
3303
3379
|
'TitleBarMenuBar.loadContent': wrapCommand(loadContent),
|
|
3380
|
+
'TitleBarMenuBar.render2': render2,
|
|
3304
3381
|
'TitleBarMenuBar.saveState': saveState,
|
|
3305
3382
|
'TitleBarMenuBar.terminate': terminate,
|
|
3306
3383
|
'TitleBarMenuBar.toggleIndex': wrapCommand(toggleIndex),
|