@lvce-editor/title-bar-worker 1.8.0 → 1.10.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 +59 -28
- package/package.json +1 -1
|
@@ -913,6 +913,34 @@ const diff = (oldState, newState) => {
|
|
|
913
913
|
return diffResult;
|
|
914
914
|
};
|
|
915
915
|
|
|
916
|
+
const create$1 = () => {
|
|
917
|
+
const states = Object.create(null);
|
|
918
|
+
return {
|
|
919
|
+
get(uid) {
|
|
920
|
+
return states[uid];
|
|
921
|
+
},
|
|
922
|
+
set(uid, oldState, newState) {
|
|
923
|
+
states[uid] = {
|
|
924
|
+
oldState,
|
|
925
|
+
newState
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
};
|
|
929
|
+
};
|
|
930
|
+
|
|
931
|
+
const {
|
|
932
|
+
get,
|
|
933
|
+
set
|
|
934
|
+
} = create$1();
|
|
935
|
+
|
|
936
|
+
const diff2 = uid => {
|
|
937
|
+
const {
|
|
938
|
+
oldState,
|
|
939
|
+
newState
|
|
940
|
+
} = get(uid);
|
|
941
|
+
return diff(oldState, newState);
|
|
942
|
+
};
|
|
943
|
+
|
|
916
944
|
const Menu$1 = 'menu';
|
|
917
945
|
const MenuBar = 'menubar';
|
|
918
946
|
const MenuItem$1 = 'menuitem';
|
|
@@ -997,7 +1025,8 @@ const getTitleBarMenuBarItemsVirtualDom = visibleItems => {
|
|
|
997
1025
|
return dom;
|
|
998
1026
|
};
|
|
999
1027
|
|
|
1000
|
-
const
|
|
1028
|
+
const activeId = 'TitleBarEntryActive';
|
|
1029
|
+
const getTitleBarMenuBarVirtualDom = (visibleItems, focusedIndex) => {
|
|
1001
1030
|
return [{
|
|
1002
1031
|
type: Div,
|
|
1003
1032
|
className: 'Viewlet TitleBarMenuBar',
|
|
@@ -1008,7 +1037,8 @@ const getTitleBarMenuBarVirtualDom = visibleItems => {
|
|
|
1008
1037
|
onFocusOut: HandleFocusOut,
|
|
1009
1038
|
onFocusIn: HandleFocusIn,
|
|
1010
1039
|
onPointerOver: HandlePointerOver,
|
|
1011
|
-
onPointerOut: HandlePointerOut
|
|
1040
|
+
onPointerOut: HandlePointerOut,
|
|
1041
|
+
ariaActivedescendant: focusedIndex === -1 ? '' : activeId
|
|
1012
1042
|
}, ...getTitleBarMenuBarItemsVirtualDom(visibleItems)];
|
|
1013
1043
|
};
|
|
1014
1044
|
|
|
@@ -1088,7 +1118,7 @@ const getVisibleTitleBarEntries = (entries, width, focusedIndex, isMenuOpen) =>
|
|
|
1088
1118
|
|
|
1089
1119
|
const renderEntries = (oldState, newState) => {
|
|
1090
1120
|
const visibleEntries = getVisibleTitleBarEntries(newState.titleBarEntries, newState.width, newState.focusedIndex, newState.isMenuOpen);
|
|
1091
|
-
const dom = getTitleBarMenuBarVirtualDom(visibleEntries);
|
|
1121
|
+
const dom = getTitleBarMenuBarVirtualDom(visibleEntries, newState.focusedIndex);
|
|
1092
1122
|
return ['Viewlet.setDom2', newState.uid, dom];
|
|
1093
1123
|
};
|
|
1094
1124
|
|
|
@@ -1628,26 +1658,6 @@ const applyRender = (oldState, newState, diffResult) => {
|
|
|
1628
1658
|
return commands;
|
|
1629
1659
|
};
|
|
1630
1660
|
|
|
1631
|
-
const create$1 = () => {
|
|
1632
|
-
const states = Object.create(null);
|
|
1633
|
-
return {
|
|
1634
|
-
get(uid) {
|
|
1635
|
-
return states[uid];
|
|
1636
|
-
},
|
|
1637
|
-
set(uid, oldState, newState) {
|
|
1638
|
-
states[uid] = {
|
|
1639
|
-
oldState,
|
|
1640
|
-
newState
|
|
1641
|
-
};
|
|
1642
|
-
}
|
|
1643
|
-
};
|
|
1644
|
-
};
|
|
1645
|
-
|
|
1646
|
-
const {
|
|
1647
|
-
get,
|
|
1648
|
-
set
|
|
1649
|
-
} = create$1();
|
|
1650
|
-
|
|
1651
1661
|
const doRender = async uid => {
|
|
1652
1662
|
const {
|
|
1653
1663
|
oldState,
|
|
@@ -2681,6 +2691,15 @@ const loadContent = async (state, titleBarEntries) => {
|
|
|
2681
2691
|
};
|
|
2682
2692
|
};
|
|
2683
2693
|
|
|
2694
|
+
const render2 = async (uid, diffResult) => {
|
|
2695
|
+
const {
|
|
2696
|
+
oldState,
|
|
2697
|
+
newState
|
|
2698
|
+
} = get(uid);
|
|
2699
|
+
const commands = applyRender(oldState, newState, diffResult);
|
|
2700
|
+
return commands;
|
|
2701
|
+
};
|
|
2702
|
+
|
|
2684
2703
|
const renderEventListeners = () => {
|
|
2685
2704
|
return [{
|
|
2686
2705
|
name: HandleClickMinimize,
|
|
@@ -2693,7 +2712,7 @@ const renderEventListeners = () => {
|
|
|
2693
2712
|
params: ['handleClickToggleMaximize']
|
|
2694
2713
|
}, {
|
|
2695
2714
|
name: HandleFocusIn,
|
|
2696
|
-
params: ['
|
|
2715
|
+
params: ['handleFocus']
|
|
2697
2716
|
}, {
|
|
2698
2717
|
name: HandleMenuClick,
|
|
2699
2718
|
params: ['handleMenuClick', 'event.clientX', 'event.clientY']
|
|
@@ -2702,7 +2721,7 @@ const renderEventListeners = () => {
|
|
|
2702
2721
|
params: ['handleMenuMouseOver', 'event.clientX', 'event.clientY']
|
|
2703
2722
|
}, {
|
|
2704
2723
|
name: HandleClick,
|
|
2705
|
-
params: ['
|
|
2724
|
+
params: ['handleClickAt', 'event.button', 'event.clientX', 'event.clientY']
|
|
2706
2725
|
}, {
|
|
2707
2726
|
name: HandlePointerOut,
|
|
2708
2727
|
params: ['handlePointerOut', 'event.clientX', 'event.clientY']
|
|
@@ -2834,6 +2853,14 @@ const handleClick = async (state, button, index) => {
|
|
|
2834
2853
|
return toggleIndex(state, index);
|
|
2835
2854
|
};
|
|
2836
2855
|
|
|
2856
|
+
const handleClickAt = async (state, button, x, y) => {
|
|
2857
|
+
const index = getTitleBarIndexFromPosition(state.titleBarEntries, x - state.x);
|
|
2858
|
+
if (index === -1) {
|
|
2859
|
+
return state;
|
|
2860
|
+
}
|
|
2861
|
+
return handleClick(state, button, index);
|
|
2862
|
+
};
|
|
2863
|
+
|
|
2837
2864
|
// TODO remove this file and merge with whenExpressions
|
|
2838
2865
|
const TitleBarMenuBar = FocusTitleBarMenuBar;
|
|
2839
2866
|
|
|
@@ -3232,6 +3259,8 @@ const commandMap = {
|
|
|
3232
3259
|
'TitleBarMenuBar.closeMenu': closeMenu,
|
|
3233
3260
|
'TitleBarMenuBar.create': create,
|
|
3234
3261
|
'TitleBarMenuBar.focus': wrapCommand(focus),
|
|
3262
|
+
'TitleBarMenuBar.diff2': diff2,
|
|
3263
|
+
'TitleBarMenuBar.render2': render2,
|
|
3235
3264
|
'TitleBarMenuBar.focusFirst': wrapCommand(focusFirst),
|
|
3236
3265
|
'TitleBarMenuBar.focusIndex': wrapCommand(focusLast),
|
|
3237
3266
|
'TitleBarMenuBar.focusLast': wrapCommand(focusIndex),
|
|
@@ -3240,7 +3269,6 @@ const commandMap = {
|
|
|
3240
3269
|
'TitleBarMenuBar.getCommands': getCommandIds,
|
|
3241
3270
|
'TitleBarMenuBar.getKeyBindings': getKeyBindings,
|
|
3242
3271
|
'TitleBarMenuBar.getMenus': getMenus,
|
|
3243
|
-
'TitleBarMenuBar.diff': diff,
|
|
3244
3272
|
'TitleBarMenuBar.getVirtualDom': getTitleBarMenuBarVirtualDom,
|
|
3245
3273
|
'TitleBarMenuBar.handleClick': wrapCommand(handleClick),
|
|
3246
3274
|
'TitleBarMenuBar.handleFocus': wrapCommand(handleFocus),
|
|
@@ -3248,6 +3276,7 @@ const commandMap = {
|
|
|
3248
3276
|
'TitleBarMenuBar.handleKeyArrowLeft': wrapCommand(handleKeyArrowLeft),
|
|
3249
3277
|
'TitleBarMenuBar.handleKeyArrowRight': wrapCommand(handleKeyArrowRight),
|
|
3250
3278
|
'TitleBarMenuBar.handleKeyArrowUp': wrapCommand(handleKeyArrowUp),
|
|
3279
|
+
'TitleBarMenuBar.handleClickAt': wrapCommand(handleClickAt),
|
|
3251
3280
|
'TitleBarMenuBar.handlePointerOver': wrapCommand(handlePointerOver),
|
|
3252
3281
|
'TitleBarMenuBar.handleKeyEnd': wrapCommand(handleKeyEnd),
|
|
3253
3282
|
'TitleBarMenuBar.handleKeyEnter': wrapCommand(handleKeyEnter),
|
|
@@ -3260,11 +3289,13 @@ const commandMap = {
|
|
|
3260
3289
|
'TitleBarMenuBar.handleMouseOut': wrapCommand(handleMouseOut),
|
|
3261
3290
|
'TitleBarMenuBar.handleMouseOver': wrapCommand(handleMouseOver),
|
|
3262
3291
|
'TitleBarMenuBar.loadContent': wrapCommand(loadContent),
|
|
3263
|
-
'TitleBarMenuBar.render': doRender,
|
|
3264
3292
|
'TitleBarMenuBar.saveState': saveState,
|
|
3265
3293
|
'TitleBarMenuBar.terminate': terminate,
|
|
3266
3294
|
'TitleBarMenuBar.toggleIndex': wrapCommand(toggleIndex),
|
|
3267
|
-
'TitleBarMenuBar.toggleMenu': wrapCommand(toggleMenu)
|
|
3295
|
+
'TitleBarMenuBar.toggleMenu': wrapCommand(toggleMenu),
|
|
3296
|
+
// deprecated
|
|
3297
|
+
'TitleBarMenuBar.diff': diff,
|
|
3298
|
+
'TitleBarMenuBar.render': doRender
|
|
3268
3299
|
};
|
|
3269
3300
|
|
|
3270
3301
|
const listen = async () => {
|