@lvce-editor/activity-bar-worker 1.5.0 → 1.7.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/README.md +2 -2
- package/dist/activityBarWorkerMain.js +65 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Activity Bar Worker
|
|
2
2
|
|
|
3
|
-
Activity Bar
|
|
3
|
+
> WebWorker for the Activity Bar functionality in Lvce Editor.
|
|
@@ -963,9 +963,10 @@ const create$1 = (id, uri, x, y, width, height, args, parentUid, platform = 0) =
|
|
|
963
963
|
y: 0,
|
|
964
964
|
sideBarVisible: false,
|
|
965
965
|
activityBarItems: [],
|
|
966
|
-
selectedIndex: -1
|
|
966
|
+
selectedIndex: -1,
|
|
967
|
+
itemHeight: 48
|
|
967
968
|
};
|
|
968
|
-
set$3(
|
|
969
|
+
set$3(id, state, state);
|
|
969
970
|
return state;
|
|
970
971
|
};
|
|
971
972
|
|
|
@@ -1054,11 +1055,15 @@ const focusNone = state => {
|
|
|
1054
1055
|
return focusIndex(state, -1);
|
|
1055
1056
|
};
|
|
1056
1057
|
|
|
1057
|
-
const Button$
|
|
1058
|
+
const Button$2 = 'button';
|
|
1058
1059
|
const None = 'none';
|
|
1059
1060
|
const Tab$1 = 'tab';
|
|
1060
1061
|
const ToolBar = 'toolbar';
|
|
1061
1062
|
|
|
1063
|
+
const Button$1 = 'event.button';
|
|
1064
|
+
const ClientX = 'event.clientX';
|
|
1065
|
+
const ClientY = 'event.clientY';
|
|
1066
|
+
|
|
1062
1067
|
const Enter = 3;
|
|
1063
1068
|
const Space = 9;
|
|
1064
1069
|
const PageUp = 10;
|
|
@@ -1122,10 +1127,23 @@ const handleBlur = state => {
|
|
|
1122
1127
|
};
|
|
1123
1128
|
};
|
|
1124
1129
|
|
|
1130
|
+
const getIndexFromPosition = (eventX, eventY, itemHeight, itemCount) => {
|
|
1131
|
+
const index = Math.floor(eventY / itemHeight);
|
|
1132
|
+
if (index < 0 || index >= itemCount) {
|
|
1133
|
+
return -1;
|
|
1134
|
+
}
|
|
1135
|
+
return index;
|
|
1136
|
+
};
|
|
1137
|
+
|
|
1125
1138
|
const show = async (x, y, id, ...args) => {
|
|
1126
1139
|
// TODO
|
|
1127
1140
|
};
|
|
1128
1141
|
|
|
1142
|
+
const handleClickAdditionalViews = async (state, x, y, viewletId) => {
|
|
1143
|
+
await show();
|
|
1144
|
+
return state;
|
|
1145
|
+
};
|
|
1146
|
+
|
|
1129
1147
|
const rpcs = Object.create(null);
|
|
1130
1148
|
const set$2 = (id, rpc) => {
|
|
1131
1149
|
rpcs[id] = rpc;
|
|
@@ -1518,14 +1536,6 @@ const {
|
|
|
1518
1536
|
invoke
|
|
1519
1537
|
} = RendererWorker;
|
|
1520
1538
|
|
|
1521
|
-
const handleClickSettings = async (state, x, y, viewletId) => {
|
|
1522
|
-
await show();
|
|
1523
|
-
return state;
|
|
1524
|
-
};
|
|
1525
|
-
const handleClickAdditionalViews = async (state, x, y, viewletId) => {
|
|
1526
|
-
await show();
|
|
1527
|
-
return state;
|
|
1528
|
-
};
|
|
1529
1539
|
const handleClickOther = async (state, x, y, viewletId) => {
|
|
1530
1540
|
// TODO ask renderer worker asynchronously if sidebar is visible
|
|
1531
1541
|
|
|
@@ -1546,13 +1556,22 @@ const handleClickOther = async (state, x, y, viewletId) => {
|
|
|
1546
1556
|
}
|
|
1547
1557
|
return state;
|
|
1548
1558
|
};
|
|
1549
|
-
|
|
1559
|
+
|
|
1560
|
+
const handleClickSettings = async (state, x, y, viewletId) => {
|
|
1561
|
+
await show();
|
|
1562
|
+
return state;
|
|
1563
|
+
};
|
|
1564
|
+
|
|
1565
|
+
const handleClickIndex = async (state, button, index, x, y) => {
|
|
1550
1566
|
if (button !== LeftClick) {
|
|
1551
1567
|
return state;
|
|
1552
1568
|
}
|
|
1553
1569
|
const {
|
|
1554
1570
|
activityBarItems
|
|
1555
1571
|
} = state;
|
|
1572
|
+
if (index === -1) {
|
|
1573
|
+
return state;
|
|
1574
|
+
}
|
|
1556
1575
|
const item = activityBarItems[index];
|
|
1557
1576
|
const viewletId = item.id;
|
|
1558
1577
|
switch (viewletId) {
|
|
@@ -1565,6 +1584,20 @@ const handleClick = async (state, button, index, x, y) => {
|
|
|
1565
1584
|
}
|
|
1566
1585
|
};
|
|
1567
1586
|
|
|
1587
|
+
const handleClick = async (state, button, x, y) => {
|
|
1588
|
+
const {
|
|
1589
|
+
activityBarItems,
|
|
1590
|
+
itemHeight
|
|
1591
|
+
} = state;
|
|
1592
|
+
const index = getIndexFromPosition(x, y, itemHeight, activityBarItems.length);
|
|
1593
|
+
return handleClickIndex(state, button, index, x, y);
|
|
1594
|
+
};
|
|
1595
|
+
|
|
1596
|
+
const handleContextMenu = async (state, button, x, y) => {
|
|
1597
|
+
await show();
|
|
1598
|
+
return state;
|
|
1599
|
+
};
|
|
1600
|
+
|
|
1568
1601
|
const handleResize = state => {
|
|
1569
1602
|
return state;
|
|
1570
1603
|
};
|
|
@@ -1763,7 +1796,7 @@ const createActivityBarItem = item => {
|
|
|
1763
1796
|
const isSelected = flags & Selected;
|
|
1764
1797
|
const isFocused = flags & Focused;
|
|
1765
1798
|
const isProgress = flags & Progress;
|
|
1766
|
-
const role = isTab ? Tab$1 : Button$
|
|
1799
|
+
const role = isTab ? Tab$1 : Button$2;
|
|
1767
1800
|
const ariaSelected = getAriaSelected(isTab, isSelected);
|
|
1768
1801
|
const marginTop = flags & MarginTop;
|
|
1769
1802
|
let className = ActivityBarItem;
|
|
@@ -1832,11 +1865,12 @@ const getVirtualDom = visibleItems => {
|
|
|
1832
1865
|
return dom;
|
|
1833
1866
|
};
|
|
1834
1867
|
|
|
1868
|
+
const className = mergeClassNames(Viewlet, ActivityBar$1);
|
|
1835
1869
|
const getActivityBarVirtualDom = visibleItems => {
|
|
1836
1870
|
return [{
|
|
1837
1871
|
type: Div,
|
|
1838
1872
|
id: ActivityBar,
|
|
1839
|
-
className
|
|
1873
|
+
className,
|
|
1840
1874
|
role: ToolBar,
|
|
1841
1875
|
ariaRoleDescription: activityBar(),
|
|
1842
1876
|
ariaOrientation: Vertical,
|
|
@@ -1896,7 +1930,21 @@ const render2 = (uid, diffResult) => {
|
|
|
1896
1930
|
};
|
|
1897
1931
|
|
|
1898
1932
|
const renderEventListeners = () => {
|
|
1899
|
-
return [
|
|
1933
|
+
return [{
|
|
1934
|
+
name: HandleBlur,
|
|
1935
|
+
params: ['handleBlur']
|
|
1936
|
+
}, {
|
|
1937
|
+
name: HandleFocus,
|
|
1938
|
+
params: ['handleFocus']
|
|
1939
|
+
}, {
|
|
1940
|
+
name: HandleContextMenu,
|
|
1941
|
+
params: ['handleContextMenu', Button$1, ClientX, ClientY]
|
|
1942
|
+
}, {
|
|
1943
|
+
name: HandleMouseDown,
|
|
1944
|
+
params: ['handleClick', Button$1, ClientX, ClientY],
|
|
1945
|
+
preventDefault: true,
|
|
1946
|
+
stopPropagation: true
|
|
1947
|
+
}];
|
|
1900
1948
|
};
|
|
1901
1949
|
|
|
1902
1950
|
const saveState = state => {
|
|
@@ -1922,6 +1970,8 @@ const commandMap = {
|
|
|
1922
1970
|
'ActivityBar.handleBlur': wrapCommand(handleBlur),
|
|
1923
1971
|
'ActivityBar.handleResize': wrapCommand(handleResize),
|
|
1924
1972
|
'ActivityBar.handleClick': wrapCommand(handleClick),
|
|
1973
|
+
'ActivityBar.handleContextMenu': wrapCommand(handleContextMenu),
|
|
1974
|
+
'ActivityBar.handleClickIndex': wrapCommand(handleClickIndex),
|
|
1925
1975
|
'ActivityBar.handleSideBarViewletChange': wrapCommand(handleSideBarViewletChange),
|
|
1926
1976
|
'ActivityBar.loadContent': wrapCommand(loadContent),
|
|
1927
1977
|
'ActivityBar.render2': render2,
|