@lvce-editor/activity-bar-worker 4.4.0 → 4.5.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.
@@ -1274,16 +1274,21 @@ const getKeyBindings = () => {
1274
1274
  };
1275
1275
 
1276
1276
  const getMenuEntriesAccount = state => {
1277
+ const signInLabel = state.userLoginState === 'logging in' ? 'Signing In...' : 'Sign In';
1278
+ const signOutLabel = state.userLoginState === 'logging out' ? 'Signing Out...' : 'Sign Out';
1279
+ if (state.userLoginState === 'logged in' || state.userLoginState === 'logging out') {
1280
+ return [{
1281
+ command: 'ActivityBar.handleClickSignOut',
1282
+ flags: None,
1283
+ id: 'signOut',
1284
+ label: signOutLabel
1285
+ }];
1286
+ }
1277
1287
  return [{
1278
- command: 'Account.signIn',
1288
+ command: 'ActivityBar.handleClickSignIn',
1279
1289
  flags: None,
1280
1290
  id: 'signIn',
1281
- label: 'Sign In'
1282
- }, {
1283
- command: 'Account.signOut',
1284
- flags: None,
1285
- id: 'signOut',
1286
- label: 'Sign Out'
1291
+ label: signInLabel
1287
1292
  }];
1288
1293
  };
1289
1294
 
@@ -1495,15 +1500,28 @@ const getMenuEntriesSettings = state => {
1495
1500
  return items;
1496
1501
  };
1497
1502
 
1498
- // Use a unique number for the Account menu ID
1499
- const ACCOUNT_MENU_ID$1 = 1000;
1503
+ const show2 = async (uid, menuId, x, y, args) => {
1504
+ await showContextMenu2(uid, menuId, x, y, args);
1505
+ };
1506
+
1507
+ const ACCOUNT_MENU_ID = 32_122;
1508
+ const handleClickAccount = async (state, eventX, eventY, viewletId) => {
1509
+ const {
1510
+ uid
1511
+ } = state;
1512
+ await show2(uid, ACCOUNT_MENU_ID, eventX, eventY, {
1513
+ menuId: ACCOUNT_MENU_ID
1514
+ });
1515
+ return state;
1516
+ };
1517
+
1500
1518
  const getMenuEntries = (state, options) => {
1501
1519
  const {
1502
1520
  menuId
1503
1521
  } = options;
1504
1522
  switch (menuId) {
1505
- case ACCOUNT_MENU_ID$1:
1506
- return getMenuEntriesAccount();
1523
+ case ACCOUNT_MENU_ID:
1524
+ return getMenuEntriesAccount(state);
1507
1525
  case ActivityBar$3:
1508
1526
  return getMenuEntriesActivityBar(state);
1509
1527
  case ActivityBarAdditionalViews:
@@ -1516,7 +1534,7 @@ const getMenuEntries = (state, options) => {
1516
1534
  };
1517
1535
 
1518
1536
  const getMenuEntryIds = () => {
1519
- return [ActivityBar$3, ActivityBarAdditionalViews, Settings$1];
1537
+ return [ActivityBar$3, ActivityBarAdditionalViews, Settings$1, ACCOUNT_MENU_ID];
1520
1538
  };
1521
1539
 
1522
1540
  const updateItemsWithBadgeCount = async items => {
@@ -1554,7 +1572,23 @@ const handleBlur = state => {
1554
1572
  };
1555
1573
  };
1556
1574
 
1557
- const getIndexFromPosition = (y, eventX, eventY, itemHeight, itemCount, height) => {
1575
+ const isBottomItem = item => {
1576
+ return item.id === 'Account' || item.id === 'Settings';
1577
+ };
1578
+ const getBottomItemCount = items => {
1579
+ if (typeof items === 'number') {
1580
+ return items > 1 ? 1 : 0;
1581
+ }
1582
+ return items.filter(isBottomItem).length;
1583
+ };
1584
+ const getItemCount = items => {
1585
+ if (typeof items === 'number') {
1586
+ return items;
1587
+ }
1588
+ return items.length;
1589
+ };
1590
+ const getIndexFromPosition = (y, eventX, eventY, itemHeight, items, height) => {
1591
+ const itemCount = getItemCount(items);
1558
1592
  if (itemCount === 0) {
1559
1593
  return -1;
1560
1594
  }
@@ -1567,38 +1601,22 @@ const getIndexFromPosition = (y, eventX, eventY, itemHeight, itemCount, height)
1567
1601
  }
1568
1602
  return index;
1569
1603
  }
1570
- // Settings is always at the bottom (last item) when there are multiple items
1571
- const settingsBottomY = y + height;
1572
- const settingsTopY = settingsBottomY - itemHeight;
1573
- // Check if click is in the Settings area (bottom)
1574
- if (eventY >= settingsTopY && eventY < settingsBottomY) {
1575
- return itemCount - 1;
1604
+ const bottomItemCount = getBottomItemCount(items);
1605
+ const bottomItemsHeight = bottomItemCount * itemHeight;
1606
+ const bottomItemsTopY = y + height - bottomItemsHeight;
1607
+ if (bottomItemCount > 0 && eventY >= bottomItemsTopY && eventY < y + height) {
1608
+ const relativeBottomY = eventY - bottomItemsTopY;
1609
+ return itemCount - bottomItemCount + Math.floor(relativeBottomY / itemHeight);
1576
1610
  }
1577
- // Otherwise, calculate index from top items
1611
+ const topItemCount = itemCount - bottomItemCount;
1578
1612
  const relativeY = eventY - y;
1579
1613
  const index = Math.floor(relativeY / itemHeight);
1580
- if (index < 0 || index >= itemCount - 1) {
1614
+ if (index < 0 || index >= topItemCount) {
1581
1615
  return -1;
1582
1616
  }
1583
1617
  return index;
1584
1618
  };
1585
1619
 
1586
- const show2 = async (uid, menuId, x, y, args) => {
1587
- await showContextMenu2(uid, menuId, x, y, args);
1588
- };
1589
-
1590
- // Use a unique number for the Account menu ID
1591
- const ACCOUNT_MENU_ID = 1000;
1592
- const handleClickAccount = async (state, eventX, eventY, viewletId) => {
1593
- const {
1594
- uid
1595
- } = state;
1596
- await show2(uid, ACCOUNT_MENU_ID, eventX, eventY, {
1597
- menuId: ACCOUNT_MENU_ID
1598
- });
1599
- return state;
1600
- };
1601
-
1602
1620
  const handleClickAdditionalViews = async (state, eventX, eventY, viewletId) => {
1603
1621
  const {
1604
1622
  uid
@@ -1680,10 +1698,18 @@ const handleClick = async (state, button, eventX, eventY) => {
1680
1698
  itemHeight,
1681
1699
  y
1682
1700
  } = state;
1683
- const index = getIndexFromPosition(y, eventX, eventY, itemHeight, filteredItems.length, height);
1701
+ const index = getIndexFromPosition(y, eventX, eventY, itemHeight, filteredItems, height);
1684
1702
  return handleClickIndex(state, button, index, eventX, eventY);
1685
1703
  };
1686
1704
 
1705
+ const handleClickSignIn = async state => {
1706
+ return state;
1707
+ };
1708
+
1709
+ const handleClickSignOut = async state => {
1710
+ return state;
1711
+ };
1712
+
1687
1713
  const handleContextMenu = async (state, button, eventX, eventY) => {
1688
1714
  const {
1689
1715
  uid
@@ -1750,6 +1776,15 @@ const handleResize = (state, dimensions) => {
1750
1776
  };
1751
1777
  };
1752
1778
 
1779
+ const getAccountEnabled = async defaultValue => {
1780
+ try {
1781
+ const value = await invoke('Preferences.get', 'activityBar.accountEnabled');
1782
+ return typeof value === 'boolean' ? value : defaultValue;
1783
+ } catch {
1784
+ return defaultValue;
1785
+ }
1786
+ };
1787
+
1753
1788
  const Explorer = 'Explorer';
1754
1789
  const Extensions = 'Extensions';
1755
1790
  const RunAndDebug = 'Run And Debug';
@@ -1760,6 +1795,7 @@ const getActivityBarItems = state => {
1760
1795
  const {
1761
1796
  accountEnabled
1762
1797
  } = state;
1798
+ const settingsFlags = Button | Enabled | (accountEnabled ? 0 : MarginTop);
1763
1799
  const items = [
1764
1800
  // Top
1765
1801
  {
@@ -1805,7 +1841,7 @@ const getActivityBarItems = state => {
1805
1841
  });
1806
1842
  }
1807
1843
  items.push({
1808
- flags: Button | Enabled | MarginTop,
1844
+ flags: settingsFlags,
1809
1845
  icon: SettingsGear,
1810
1846
  id: 'Settings',
1811
1847
  keyShortcuts: '',
@@ -1842,13 +1878,17 @@ const handleSettingsChanged = async state => {
1842
1878
  itemHeight,
1843
1879
  selectedIndex
1844
1880
  } = state;
1845
- const items = getActivityBarItems(state);
1881
+ const [accountEnabled, sidebarLocation] = await Promise.all([getAccountEnabled(state.accountEnabled), getSideBarPosition()]);
1882
+ const newState = {
1883
+ ...state,
1884
+ accountEnabled
1885
+ };
1886
+ const items = getActivityBarItems(newState);
1846
1887
  const itemsWithSelected = markSelected(items, selectedIndex);
1847
1888
  const filteredItems = getFilteredActivityBarItems(itemsWithSelected, height, itemHeight);
1848
1889
  const newItems = await updateItemsWithBadgeCount(filteredItems);
1849
- const sidebarLocation = await getSideBarPosition();
1850
1890
  return {
1851
- ...state,
1891
+ ...newState,
1852
1892
  activityBarItems: itemsWithSelected,
1853
1893
  filteredItems: newItems,
1854
1894
  sideBarLocation: sidebarLocation
@@ -1967,15 +2007,19 @@ const loadContent = async state => {
1967
2007
  height,
1968
2008
  itemHeight
1969
2009
  } = state;
1970
- const items = getActivityBarItems(state);
1971
- const [activeView, sideBarVisible, sidebarLocation] = await Promise.all([getActiveView(), getSideBarVisible(), getSideBarPosition()]);
2010
+ const [accountEnabled, activeView, sideBarVisible, sidebarLocation] = await Promise.all([getAccountEnabled(state.accountEnabled), getActiveView(), getSideBarVisible(), getSideBarPosition()]);
2011
+ const newState = {
2012
+ ...state,
2013
+ accountEnabled
2014
+ };
2015
+ const items = getActivityBarItems(newState);
1972
2016
  const index = items.findIndex(item => item.id === activeView);
1973
2017
  const selectedIndex = sideBarVisible ? index : -1;
1974
2018
  const itemsWithSelected = markSelected(items, selectedIndex);
1975
2019
  const filteredItems = getFilteredActivityBarItems(itemsWithSelected, height, itemHeight);
1976
2020
  const newItems = await updateItemsWithBadgeCount(filteredItems);
1977
2021
  return {
1978
- ...state,
2022
+ ...newState,
1979
2023
  activityBarItems: itemsWithSelected,
1980
2024
  currentViewletId: Explorer,
1981
2025
  filteredItems: newItems,
@@ -2331,6 +2375,10 @@ const HandleMouseDown = 4;
2331
2375
 
2332
2376
  const ActivityBar = 'ActivityBar';
2333
2377
 
2378
+ const getActivityBarItemHasPopup = item => {
2379
+ return item.id === 'Account' || item.id === 'Settings';
2380
+ };
2381
+
2334
2382
  const getAriaSelected = (isTab, isSelected) => {
2335
2383
  if (!isTab) {
2336
2384
  return undefined;
@@ -2379,10 +2427,12 @@ const getActivityBarItemInProgressDom = item => {
2379
2427
  const isFocused = flags & Focused;
2380
2428
  const role = isTab ? Tab$1 : Button$2;
2381
2429
  const ariaSelected = getAriaSelected(isTab, isSelected);
2430
+ const ariaHasPopup = getActivityBarItemHasPopup(item) || undefined;
2382
2431
  const marginTop = flags & MarginTop;
2383
2432
  let className = getClassName(isFocused, marginTop, isSelected);
2384
2433
  className += ' ' + ActivityBarItemNested;
2385
2434
  return [{
2435
+ ariaHasPopup,
2386
2436
  ariaLabel: '',
2387
2437
  ariaSelected,
2388
2438
  childCount: 2,
@@ -2414,10 +2464,12 @@ const getActivityBarItemWithBadgeDom = item => {
2414
2464
  const isFocused = flags & Focused;
2415
2465
  const role = isTab ? Tab$1 : Button$2;
2416
2466
  const ariaSelected = getAriaSelected(isTab, isSelected);
2467
+ const ariaHasPopup = getActivityBarItemHasPopup(item) || undefined;
2417
2468
  const marginTop = flags & MarginTop;
2418
2469
  let className = getClassName(isFocused, marginTop, isSelected);
2419
2470
  className += ' ' + ActivityBarItemNested;
2420
2471
  return [{
2472
+ ariaHasPopup,
2421
2473
  ariaLabel: '',
2422
2474
  ariaSelected,
2423
2475
  childCount: 2,
@@ -2453,6 +2505,7 @@ const getActivityBarItemVirtualDom = item => {
2453
2505
  icon,
2454
2506
  title
2455
2507
  } = item;
2508
+ const ariaHasPopup = getActivityBarItemHasPopup(item) || undefined;
2456
2509
  const isTab = flags & Tab;
2457
2510
  const isSelected = flags & Selected;
2458
2511
  const isFocused = flags & Focused;
@@ -2463,6 +2516,7 @@ const getActivityBarItemVirtualDom = item => {
2463
2516
  const className = getClassName(isFocused, marginTop, isSelected);
2464
2517
  if (isSelected) {
2465
2518
  return [{
2519
+ ariaHasPopup,
2466
2520
  ariaLabel: '',
2467
2521
  ariaSelected,
2468
2522
  childCount: 1,
@@ -2481,6 +2535,7 @@ const getActivityBarItemVirtualDom = item => {
2481
2535
  return getActivityBarItemWithBadgeDom(item);
2482
2536
  }
2483
2537
  return [{
2538
+ ariaHasPopup,
2484
2539
  ariaLabel: '',
2485
2540
  ariaSelected,
2486
2541
  childCount: 0,
@@ -2624,6 +2679,13 @@ const setAccountEnabled = (state, enabled) => {
2624
2679
  };
2625
2680
  };
2626
2681
 
2682
+ const setUserLoginState = (state, userLoginState) => {
2683
+ return {
2684
+ ...state,
2685
+ userLoginState
2686
+ };
2687
+ };
2688
+
2627
2689
  const toggleActivityBarItem = async (state, itemId) => {
2628
2690
  const {
2629
2691
  activityBarItems
@@ -2662,6 +2724,8 @@ const commandMap = {
2662
2724
  'ActivityBar.handleClick': wrapCommand(handleClick),
2663
2725
  'ActivityBar.handleClickIndex': wrapCommand(handleClickIndex),
2664
2726
  'ActivityBar.handleClickSettings': wrapCommand(handleClickSettings),
2727
+ 'ActivityBar.handleClickSignIn': wrapCommand(handleClickSignIn),
2728
+ 'ActivityBar.handleClickSignOut': wrapCommand(handleClickSignOut),
2665
2729
  'ActivityBar.handleContextMenu': wrapCommand(handleContextMenu),
2666
2730
  'ActivityBar.handleFocus': wrapCommand(handleFocus),
2667
2731
  'ActivityBar.handleSettingsChanged': wrapCommand(handleSettingsChanged),
@@ -2674,6 +2738,7 @@ const commandMap = {
2674
2738
  'ActivityBar.resize': wrapCommand(handleResize),
2675
2739
  'ActivityBar.saveState': wrapGetter(saveState),
2676
2740
  'ActivityBar.setAccountEnabled': wrapCommand(setAccountEnabled),
2741
+ 'ActivityBar.setUserLoginState': wrapCommand(setUserLoginState),
2677
2742
  'ActivityBar.terminate': terminate,
2678
2743
  'ActivityBar.toggleActivityBarItem': wrapCommand(toggleActivityBarItem)
2679
2744
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/activity-bar-worker",
3
- "version": "4.4.0",
3
+ "version": "4.5.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",