@lvce-editor/title-bar-worker 1.7.0 → 1.8.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 -210
- package/package.json +1 -1
|
@@ -901,7 +901,7 @@ const DiffMenus = {
|
|
|
901
901
|
isEqual
|
|
902
902
|
};
|
|
903
903
|
|
|
904
|
-
const modules = [
|
|
904
|
+
const modules = [DiffEntries, DiffFocusedIndex, DiffMenus];
|
|
905
905
|
|
|
906
906
|
const diff = (oldState, newState) => {
|
|
907
907
|
const diffResult = [];
|
|
@@ -920,6 +920,17 @@ const MenuItemCheckBox = 'menuitemcheckbox';
|
|
|
920
920
|
const None$1 = 'none';
|
|
921
921
|
const Separator$1 = 'separator';
|
|
922
922
|
|
|
923
|
+
const HandleClick = 'handleClick';
|
|
924
|
+
const HandleClickMinimize = 'handleClickMinimize';
|
|
925
|
+
const HandleClickToggleClose = 'handleClickToggleClose';
|
|
926
|
+
const HandleClickToggleMaximize = 'handleClickToggleMaximize';
|
|
927
|
+
const HandleFocusIn = 'handleFocusIn';
|
|
928
|
+
const HandleFocusOut = 'handleFocusOut';
|
|
929
|
+
const HandlePointerOut = 'handlePointerOut';
|
|
930
|
+
const HandlePointerOver = 'handlePointerOver';
|
|
931
|
+
const HandleMenuClick = 'handleMenuClick';
|
|
932
|
+
const HandleMenuMouseOver = 'handleMenuMouseOver';
|
|
933
|
+
|
|
923
934
|
const Menu = 'Menu';
|
|
924
935
|
const MenuItem = 'MenuItem';
|
|
925
936
|
const MenuItemFocused = 'MenuItemFocused';
|
|
@@ -931,6 +942,163 @@ const TitleBarEntryActive = 'TitleBarEntryActive';
|
|
|
931
942
|
const TitleBarTopLevelEntry = 'TitleBarTopLevelEntry';
|
|
932
943
|
const TitleBarTopLevelEntryLabel = 'TitleBarTopLevelEntryLabel';
|
|
933
944
|
|
|
945
|
+
const Button = 1;
|
|
946
|
+
const Div = 4;
|
|
947
|
+
const Text = 12;
|
|
948
|
+
const I = 16;
|
|
949
|
+
const Img = 17;
|
|
950
|
+
const Span = 8;
|
|
951
|
+
|
|
952
|
+
const text = data => {
|
|
953
|
+
return {
|
|
954
|
+
type: Text,
|
|
955
|
+
text: data,
|
|
956
|
+
childCount: 0
|
|
957
|
+
};
|
|
958
|
+
};
|
|
959
|
+
|
|
960
|
+
const getItemVirtualDom = item => {
|
|
961
|
+
// @ts-ignore
|
|
962
|
+
const {
|
|
963
|
+
keyboardShortCut,
|
|
964
|
+
label,
|
|
965
|
+
isOpen,
|
|
966
|
+
isFocused
|
|
967
|
+
} = item;
|
|
968
|
+
const dom = [];
|
|
969
|
+
dom.push({
|
|
970
|
+
type: Div,
|
|
971
|
+
className: TitleBarTopLevelEntry,
|
|
972
|
+
ariaHasPopup: true,
|
|
973
|
+
ariaExpanded: isOpen,
|
|
974
|
+
role: MenuItem$1,
|
|
975
|
+
childCount: 1,
|
|
976
|
+
ariaKeyShortcuts: keyboardShortCut
|
|
977
|
+
});
|
|
978
|
+
if (isOpen) {
|
|
979
|
+
// @ts-ignore
|
|
980
|
+
dom[0].ariaOwns = 'Menu-0';
|
|
981
|
+
}
|
|
982
|
+
if (isFocused) {
|
|
983
|
+
dom[0].className += ' ' + TitleBarEntryActive;
|
|
984
|
+
// @ts-ignore
|
|
985
|
+
dom[0].id = 'TitleBarEntryActive';
|
|
986
|
+
dom.push({
|
|
987
|
+
type: Div,
|
|
988
|
+
className: TitleBarTopLevelEntryLabel,
|
|
989
|
+
childCount: 1
|
|
990
|
+
});
|
|
991
|
+
}
|
|
992
|
+
dom.push(text(label));
|
|
993
|
+
return dom;
|
|
994
|
+
};
|
|
995
|
+
const getTitleBarMenuBarItemsVirtualDom = visibleItems => {
|
|
996
|
+
const dom = visibleItems.flatMap(getItemVirtualDom);
|
|
997
|
+
return dom;
|
|
998
|
+
};
|
|
999
|
+
|
|
1000
|
+
const getTitleBarMenuBarVirtualDom = visibleItems => {
|
|
1001
|
+
return [{
|
|
1002
|
+
type: Div,
|
|
1003
|
+
className: 'Viewlet TitleBarMenuBar',
|
|
1004
|
+
role: MenuBar,
|
|
1005
|
+
tabIndex: 0,
|
|
1006
|
+
childCount: visibleItems.length,
|
|
1007
|
+
onMouseDown: HandleClick,
|
|
1008
|
+
onFocusOut: HandleFocusOut,
|
|
1009
|
+
onFocusIn: HandleFocusIn,
|
|
1010
|
+
onPointerOver: HandlePointerOver,
|
|
1011
|
+
onPointerOut: HandlePointerOut
|
|
1012
|
+
}, ...getTitleBarMenuBarItemsVirtualDom(visibleItems)];
|
|
1013
|
+
};
|
|
1014
|
+
|
|
1015
|
+
const Ellipsis = 'Ellipsis';
|
|
1016
|
+
|
|
1017
|
+
const emptyObject = {};
|
|
1018
|
+
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1019
|
+
const i18nString = (key, placeholders = emptyObject) => {
|
|
1020
|
+
if (placeholders === emptyObject) {
|
|
1021
|
+
return key;
|
|
1022
|
+
}
|
|
1023
|
+
const replacer = (match, rest) => {
|
|
1024
|
+
return placeholders[rest];
|
|
1025
|
+
};
|
|
1026
|
+
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1027
|
+
};
|
|
1028
|
+
|
|
1029
|
+
const About = 'About';
|
|
1030
|
+
const CheckForUpdates = 'Check For Updates';
|
|
1031
|
+
const ClearRecentlyOpened = 'Clear Recently Opened';
|
|
1032
|
+
const Edit$1 = 'Edit';
|
|
1033
|
+
const File$1 = 'File';
|
|
1034
|
+
const Go$1 = 'Go';
|
|
1035
|
+
const Help$1 = 'Help';
|
|
1036
|
+
const MoreDot = 'More ...';
|
|
1037
|
+
const OpenProcessExplorer = 'Open Process Explorer';
|
|
1038
|
+
const Run$1 = 'Run';
|
|
1039
|
+
const Selection$1 = 'Selection';
|
|
1040
|
+
const Terminal$1 = 'Terminal';
|
|
1041
|
+
const ToggleDeveloperTools = 'Toggle Developer Tools';
|
|
1042
|
+
const View$1 = 'View';
|
|
1043
|
+
|
|
1044
|
+
const moreDot = () => {
|
|
1045
|
+
return i18nString(MoreDot);
|
|
1046
|
+
};
|
|
1047
|
+
const clearRecentlyOpened = () => {
|
|
1048
|
+
return i18nString(ClearRecentlyOpened);
|
|
1049
|
+
};
|
|
1050
|
+
|
|
1051
|
+
const getVisibleTitleBarEntries = (entries, width, focusedIndex, isMenuOpen) => {
|
|
1052
|
+
array(entries);
|
|
1053
|
+
number(width);
|
|
1054
|
+
let total = 0;
|
|
1055
|
+
const visible = [];
|
|
1056
|
+
for (let i = 0; i < entries.length; i++) {
|
|
1057
|
+
const entry = entries[i];
|
|
1058
|
+
total += entry.width;
|
|
1059
|
+
if (total >= width) {
|
|
1060
|
+
break;
|
|
1061
|
+
}
|
|
1062
|
+
const isOpen = i === focusedIndex && isMenuOpen;
|
|
1063
|
+
const isFocused = i === focusedIndex;
|
|
1064
|
+
visible.push({
|
|
1065
|
+
...entry,
|
|
1066
|
+
isOpen,
|
|
1067
|
+
isFocused
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
const hasOverflow = visible.length < entries.length;
|
|
1071
|
+
if (hasOverflow) {
|
|
1072
|
+
const padding = 8;
|
|
1073
|
+
const moreIconWidth = 22;
|
|
1074
|
+
const totalPadding = padding * 2;
|
|
1075
|
+
const hasStillOverflow = total + moreIconWidth + totalPadding > width;
|
|
1076
|
+
if (hasStillOverflow) {
|
|
1077
|
+
visible.pop();
|
|
1078
|
+
}
|
|
1079
|
+
visible.push({
|
|
1080
|
+
ariaLabel: moreDot(),
|
|
1081
|
+
icon: Ellipsis,
|
|
1082
|
+
label: '',
|
|
1083
|
+
width: moreIconWidth + totalPadding
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
return visible;
|
|
1087
|
+
};
|
|
1088
|
+
|
|
1089
|
+
const renderEntries = (oldState, newState) => {
|
|
1090
|
+
const visibleEntries = getVisibleTitleBarEntries(newState.titleBarEntries, newState.width, newState.focusedIndex, newState.isMenuOpen);
|
|
1091
|
+
const dom = getTitleBarMenuBarVirtualDom(visibleEntries);
|
|
1092
|
+
return ['Viewlet.setDom2', newState.uid, dom];
|
|
1093
|
+
};
|
|
1094
|
+
|
|
1095
|
+
const SetFocusedIndex = 'setFocusedIndex';
|
|
1096
|
+
const SetMenus = 'setMenus';
|
|
1097
|
+
|
|
1098
|
+
const renderFocusedIndex = (oldState, newState) => {
|
|
1099
|
+
return ['Viewlet.send', newState.uid, /* method */SetFocusedIndex, /* oldFocusedIndex */oldState.focusedIndex, /* newfocusedIndex */newState.focusedIndex, /* oldIsMenuOpen */oldState.isMenuOpen, /* newIsMenuOpen */newState.isMenuOpen];
|
|
1100
|
+
};
|
|
1101
|
+
|
|
934
1102
|
const getKeyBindingString = (key, altKey, ctrlKey, shiftKey, metaKey) => {
|
|
935
1103
|
let string = '';
|
|
936
1104
|
if (ctrlKey) {
|
|
@@ -1234,21 +1402,6 @@ const parseKey = rawKey => {
|
|
|
1234
1402
|
};
|
|
1235
1403
|
};
|
|
1236
1404
|
|
|
1237
|
-
const Button = 1;
|
|
1238
|
-
const Div = 4;
|
|
1239
|
-
const Text = 12;
|
|
1240
|
-
const I = 16;
|
|
1241
|
-
const Img = 17;
|
|
1242
|
-
const Span = 8;
|
|
1243
|
-
|
|
1244
|
-
const text = data => {
|
|
1245
|
-
return {
|
|
1246
|
-
type: Text,
|
|
1247
|
-
text: data,
|
|
1248
|
-
childCount: 0
|
|
1249
|
-
};
|
|
1250
|
-
};
|
|
1251
|
-
|
|
1252
1405
|
const separator = {
|
|
1253
1406
|
type: Div,
|
|
1254
1407
|
className: MenuItemSeparator,
|
|
@@ -1402,72 +1555,6 @@ const getMenuVirtualDom = menuItems => {
|
|
|
1402
1555
|
return dom;
|
|
1403
1556
|
};
|
|
1404
1557
|
|
|
1405
|
-
const HandleClick = 'handleClick';
|
|
1406
|
-
const HandleClickMinimize = 'handleClickMinimize';
|
|
1407
|
-
const HandleClickToggleClose = 'handleClickToggleClose';
|
|
1408
|
-
const HandleClickToggleMaximize = 'handleClickToggleMaximize';
|
|
1409
|
-
const HandleFocusIn = 'handleFocusIn';
|
|
1410
|
-
const HandleFocusOut = 'handleFocusOut';
|
|
1411
|
-
const HandlePointerOut = 'handlePointerOut';
|
|
1412
|
-
const HandlePointerOver = 'handlePointerOver';
|
|
1413
|
-
const HandleMenuClick = 'handleMenuClick';
|
|
1414
|
-
const HandleMenuMouseOver = 'handleMenuMouseOver';
|
|
1415
|
-
|
|
1416
|
-
const getItemVirtualDom = item => {
|
|
1417
|
-
// @ts-ignore
|
|
1418
|
-
const {
|
|
1419
|
-
keyboardShortCut,
|
|
1420
|
-
label,
|
|
1421
|
-
isOpen,
|
|
1422
|
-
isFocused
|
|
1423
|
-
} = item;
|
|
1424
|
-
const dom = [];
|
|
1425
|
-
dom.push({
|
|
1426
|
-
type: Div,
|
|
1427
|
-
className: TitleBarTopLevelEntry,
|
|
1428
|
-
ariaHasPopup: true,
|
|
1429
|
-
ariaExpanded: isOpen,
|
|
1430
|
-
role: MenuItem$1,
|
|
1431
|
-
childCount: 1,
|
|
1432
|
-
ariaKeyShortcuts: keyboardShortCut
|
|
1433
|
-
});
|
|
1434
|
-
if (isOpen) {
|
|
1435
|
-
// @ts-ignore
|
|
1436
|
-
dom[0].ariaOwns = 'Menu-0';
|
|
1437
|
-
}
|
|
1438
|
-
if (isFocused) {
|
|
1439
|
-
dom[0].className += ' ' + TitleBarEntryActive;
|
|
1440
|
-
// @ts-ignore
|
|
1441
|
-
dom[0].id = 'TitleBarEntryActive';
|
|
1442
|
-
dom.push({
|
|
1443
|
-
type: Div,
|
|
1444
|
-
className: TitleBarTopLevelEntryLabel,
|
|
1445
|
-
childCount: 1
|
|
1446
|
-
});
|
|
1447
|
-
}
|
|
1448
|
-
dom.push(text(label));
|
|
1449
|
-
return dom;
|
|
1450
|
-
};
|
|
1451
|
-
const getTitleBarMenuBarItemsVirtualDom = visibleItems => {
|
|
1452
|
-
const dom = visibleItems.flatMap(getItemVirtualDom);
|
|
1453
|
-
return dom;
|
|
1454
|
-
};
|
|
1455
|
-
|
|
1456
|
-
const getTitleBarMenuBarVirtualDom = visibleItems => {
|
|
1457
|
-
return [{
|
|
1458
|
-
type: Div,
|
|
1459
|
-
className: 'Viewlet TitleBarMenuBar',
|
|
1460
|
-
role: MenuBar,
|
|
1461
|
-
tabIndex: 0,
|
|
1462
|
-
childCount: visibleItems.length,
|
|
1463
|
-
onMouseDown: HandleClick,
|
|
1464
|
-
onFocusOut: HandleFocusOut,
|
|
1465
|
-
onFocusIn: HandleFocusIn,
|
|
1466
|
-
onPointerOver: HandlePointerOver,
|
|
1467
|
-
onPointerOut: HandlePointerOut
|
|
1468
|
-
}, ...getTitleBarMenuBarItemsVirtualDom(visibleItems)];
|
|
1469
|
-
};
|
|
1470
|
-
|
|
1471
1558
|
const getVisible = (items, focusedIndex, expanded, level) => {
|
|
1472
1559
|
const visibleItems = [];
|
|
1473
1560
|
const {
|
|
@@ -1491,134 +1578,55 @@ const getVisible = (items, focusedIndex, expanded, level) => {
|
|
|
1491
1578
|
return visibleItems;
|
|
1492
1579
|
};
|
|
1493
1580
|
|
|
1494
|
-
const
|
|
1495
|
-
|
|
1496
|
-
const
|
|
1497
|
-
const
|
|
1498
|
-
const
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
const About = 'About';
|
|
1509
|
-
const CheckForUpdates = 'Check For Updates';
|
|
1510
|
-
const ClearRecentlyOpened = 'Clear Recently Opened';
|
|
1511
|
-
const Edit$1 = 'Edit';
|
|
1512
|
-
const File$1 = 'File';
|
|
1513
|
-
const Go$1 = 'Go';
|
|
1514
|
-
const Help$1 = 'Help';
|
|
1515
|
-
const MoreDot = 'More ...';
|
|
1516
|
-
const OpenProcessExplorer = 'Open Process Explorer';
|
|
1517
|
-
const Run$1 = 'Run';
|
|
1518
|
-
const Selection$1 = 'Selection';
|
|
1519
|
-
const Terminal$1 = 'Terminal';
|
|
1520
|
-
const ToggleDeveloperTools = 'Toggle Developer Tools';
|
|
1521
|
-
const View$1 = 'View';
|
|
1522
|
-
|
|
1523
|
-
const moreDot = () => {
|
|
1524
|
-
return i18nString(MoreDot);
|
|
1525
|
-
};
|
|
1526
|
-
const clearRecentlyOpened = () => {
|
|
1527
|
-
return i18nString(ClearRecentlyOpened);
|
|
1528
|
-
};
|
|
1529
|
-
|
|
1530
|
-
const getVisibleTitleBarEntries = (entries, width, focusedIndex, isMenuOpen) => {
|
|
1531
|
-
array(entries);
|
|
1532
|
-
number(width);
|
|
1533
|
-
let total = 0;
|
|
1534
|
-
const visible = [];
|
|
1535
|
-
for (let i = 0; i < entries.length; i++) {
|
|
1536
|
-
const entry = entries[i];
|
|
1537
|
-
total += entry.width;
|
|
1538
|
-
if (total >= width) {
|
|
1539
|
-
break;
|
|
1581
|
+
const renderMEnus = (oldState, newState) => {
|
|
1582
|
+
const oldMenus = oldState.menus;
|
|
1583
|
+
const newMenus = newState.menus;
|
|
1584
|
+
const oldLength = oldMenus.length;
|
|
1585
|
+
const newLength = newMenus.length;
|
|
1586
|
+
const commonLength = Math.min(oldLength, newLength);
|
|
1587
|
+
const changes = [];
|
|
1588
|
+
for (let i = 0; i < commonLength; i++) {
|
|
1589
|
+
const oldMenu = oldMenus[i];
|
|
1590
|
+
const newMenu = newMenus[i];
|
|
1591
|
+
if (oldMenu !== newMenu) {
|
|
1592
|
+
const visible = getVisible(newMenu.items, newMenu.focusedIndex, newMenu.expanded, newMenu.level);
|
|
1593
|
+
const dom = getMenuVirtualDom(visible).slice(1);
|
|
1594
|
+
changes.push([/* method */'updateMenu', newMenu, /* newLength */newLength, dom]);
|
|
1540
1595
|
}
|
|
1541
|
-
const isOpen = i === focusedIndex && isMenuOpen;
|
|
1542
|
-
const isFocused = i === focusedIndex;
|
|
1543
|
-
visible.push({
|
|
1544
|
-
...entry,
|
|
1545
|
-
isOpen,
|
|
1546
|
-
isFocused
|
|
1547
|
-
});
|
|
1548
1596
|
}
|
|
1549
|
-
const
|
|
1550
|
-
if (
|
|
1551
|
-
const
|
|
1552
|
-
const
|
|
1553
|
-
const
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1597
|
+
const difference = newLength - oldLength;
|
|
1598
|
+
if (difference > 0) {
|
|
1599
|
+
const newMenu = newMenus.at(-1);
|
|
1600
|
+
const visible = getVisible(newMenu.items, newMenu.focusedIndex, newMenu.expanded, newMenu.level);
|
|
1601
|
+
const dom = getMenuVirtualDom(visible).slice(1);
|
|
1602
|
+
changes.push(['addMenu', newMenu, dom]);
|
|
1603
|
+
} else if (difference < 0) {
|
|
1604
|
+
changes.push(['closeMenus', newLength]);
|
|
1605
|
+
}
|
|
1606
|
+
return ['Viewlet.send', newState.uid, /* method */SetMenus, /* changes */changes, newState.uid];
|
|
1607
|
+
};
|
|
1608
|
+
|
|
1609
|
+
const getRenderer = diffType => {
|
|
1610
|
+
switch (diffType) {
|
|
1611
|
+
case RenderEntries:
|
|
1612
|
+
return renderEntries;
|
|
1613
|
+
case RenderFocusedIndex:
|
|
1614
|
+
return renderFocusedIndex;
|
|
1615
|
+
case RenderMenus:
|
|
1616
|
+
return renderMEnus;
|
|
1617
|
+
default:
|
|
1618
|
+
throw new Error('unknown renderer');
|
|
1564
1619
|
}
|
|
1565
|
-
return visible;
|
|
1566
1620
|
};
|
|
1567
1621
|
|
|
1568
|
-
const
|
|
1569
|
-
const
|
|
1570
|
-
|
|
1571
|
-
const
|
|
1572
|
-
|
|
1573
|
-
return oldState.titleBarEntries === newState.titleBarEntries && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen;
|
|
1574
|
-
},
|
|
1575
|
-
apply(oldState, newState) {
|
|
1576
|
-
const visibleEntries = getVisibleTitleBarEntries(newState.titleBarEntries, newState.width, newState.focusedIndex, newState.isMenuOpen);
|
|
1577
|
-
const dom = getTitleBarMenuBarVirtualDom(visibleEntries);
|
|
1578
|
-
return ['Viewlet.setDom2', newState.uid, dom];
|
|
1579
|
-
}
|
|
1580
|
-
};
|
|
1581
|
-
const renderFocusedIndex = {
|
|
1582
|
-
isEqual(oldState, newState) {
|
|
1583
|
-
return oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen;
|
|
1584
|
-
},
|
|
1585
|
-
apply(oldState, newState) {
|
|
1586
|
-
return ['Viewlet.send', newState.uid, /* method */SetFocusedIndex, /* oldFocusedIndex */oldState.focusedIndex, /* newfocusedIndex */newState.focusedIndex, /* oldIsMenuOpen */oldState.isMenuOpen, /* newIsMenuOpen */newState.isMenuOpen];
|
|
1587
|
-
}
|
|
1588
|
-
};
|
|
1589
|
-
const renderMenus = {
|
|
1590
|
-
isEqual(oldState, newState) {
|
|
1591
|
-
return oldState.menus === newState.menus;
|
|
1592
|
-
},
|
|
1593
|
-
apply(oldState, newState) {
|
|
1594
|
-
const oldMenus = oldState.menus;
|
|
1595
|
-
const newMenus = newState.menus;
|
|
1596
|
-
const oldLength = oldMenus.length;
|
|
1597
|
-
const newLength = newMenus.length;
|
|
1598
|
-
const commonLength = Math.min(oldLength, newLength);
|
|
1599
|
-
const changes = [];
|
|
1600
|
-
for (let i = 0; i < commonLength; i++) {
|
|
1601
|
-
const oldMenu = oldMenus[i];
|
|
1602
|
-
const newMenu = newMenus[i];
|
|
1603
|
-
if (oldMenu !== newMenu) {
|
|
1604
|
-
const visible = getVisible(newMenu.items, newMenu.focusedIndex, newMenu.expanded, newMenu.level);
|
|
1605
|
-
const dom = getMenuVirtualDom(visible).slice(1);
|
|
1606
|
-
changes.push([/* method */'updateMenu', newMenu, /* newLength */newLength, dom]);
|
|
1607
|
-
}
|
|
1608
|
-
}
|
|
1609
|
-
const difference = newLength - oldLength;
|
|
1610
|
-
if (difference > 0) {
|
|
1611
|
-
const newMenu = newMenus.at(-1);
|
|
1612
|
-
const visible = getVisible(newMenu.items, newMenu.focusedIndex, newMenu.expanded, newMenu.level);
|
|
1613
|
-
const dom = getMenuVirtualDom(visible).slice(1);
|
|
1614
|
-
changes.push(['addMenu', newMenu, dom]);
|
|
1615
|
-
} else if (difference < 0) {
|
|
1616
|
-
changes.push(['closeMenus', newLength]);
|
|
1617
|
-
}
|
|
1618
|
-
return ['Viewlet.send', newState.uid, /* method */SetMenus, /* changes */changes, newState.uid];
|
|
1622
|
+
const applyRender = (oldState, newState, diffResult) => {
|
|
1623
|
+
const commands = [];
|
|
1624
|
+
for (const item of diffResult) {
|
|
1625
|
+
const fn = getRenderer(item);
|
|
1626
|
+
commands.push(fn(oldState, newState));
|
|
1619
1627
|
}
|
|
1628
|
+
return commands;
|
|
1620
1629
|
};
|
|
1621
|
-
const render = [renderTitleBarEntries, renderFocusedIndex, renderMenus];
|
|
1622
1630
|
|
|
1623
1631
|
const create$1 = () => {
|
|
1624
1632
|
const states = Object.create(null);
|
|
@@ -1645,12 +1653,8 @@ const doRender = async uid => {
|
|
|
1645
1653
|
oldState,
|
|
1646
1654
|
newState
|
|
1647
1655
|
} = get(uid);
|
|
1648
|
-
const
|
|
1649
|
-
|
|
1650
|
-
if (!item.isEqual(oldState, newState)) {
|
|
1651
|
-
commands.push(item.apply(oldState, newState));
|
|
1652
|
-
}
|
|
1653
|
-
}
|
|
1656
|
+
const diffResult = diff(oldState, newState);
|
|
1657
|
+
const commands = applyRender(oldState, newState, diffResult);
|
|
1654
1658
|
return commands;
|
|
1655
1659
|
};
|
|
1656
1660
|
|
|
@@ -2712,7 +2716,9 @@ const renderEventListeners = () => {
|
|
|
2712
2716
|
};
|
|
2713
2717
|
|
|
2714
2718
|
const saveState = uid => {
|
|
2715
|
-
return {
|
|
2719
|
+
return {
|
|
2720
|
+
x: 1
|
|
2721
|
+
};
|
|
2716
2722
|
};
|
|
2717
2723
|
|
|
2718
2724
|
const terminate = () => {
|