@lvce-editor/activity-bar-worker 7.4.0 → 7.6.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.
@@ -151,7 +151,9 @@ const create$9 = (id, uri, x, y, width, height, args, parentUid, platform = 0) =
151
151
  uid: id,
152
152
  updateProgress: 0,
153
153
  updateState: '',
154
+ userLoginProvider: 'GitHub',
154
155
  userLoginState: 'logged out',
156
+ userName: '',
155
157
  width,
156
158
  x,
157
159
  y
@@ -251,6 +253,7 @@ const Reference = 100;
251
253
  const Button$1 = 'event.button';
252
254
  const ClientX = 'event.clientX';
253
255
  const ClientY = 'event.clientY';
256
+ const TargetName = 'event.target.name';
254
257
 
255
258
  const Enter = 3;
256
259
  const Space = 9;
@@ -267,6 +270,7 @@ const ActivityBarAdditionalViews = 17;
267
270
 
268
271
  const Separator = 1;
269
272
  const None = 0;
273
+ const SubMenu = 4;
270
274
  const Checked = 2;
271
275
  const Unchecked = 3;
272
276
 
@@ -324,7 +328,24 @@ const getKeyBindings = () => {
324
328
  }];
325
329
  };
326
330
 
331
+ const ACCOUNT_SUBMENU_ID = 32_123;
332
+ const getAccountLabel = state => {
333
+ const name = state.userName || 'Account';
334
+ const provider = state.userLoginProvider || 'GitHub';
335
+ return `${name} (${provider})`;
336
+ };
327
337
  const getMenuEntriesAccountLoggedIn = state => {
338
+ return [{
339
+ args: [{
340
+ menuId: ACCOUNT_SUBMENU_ID
341
+ }],
342
+ command: '',
343
+ flags: SubMenu,
344
+ id: ACCOUNT_SUBMENU_ID,
345
+ label: getAccountLabel(state)
346
+ }];
347
+ };
348
+ const getMenuEntriesAccountSubMenu = state => {
328
349
  const {
329
350
  userLoginState
330
351
  } = state;
@@ -1768,6 +1789,8 @@ const getMenuEntries = (state, options) => {
1768
1789
  switch (menuId) {
1769
1790
  case ACCOUNT_MENU_ID:
1770
1791
  return getMenuEntriesAccount(state);
1792
+ case ACCOUNT_SUBMENU_ID:
1793
+ return getMenuEntriesAccountSubMenu(state);
1771
1794
  case ActivityBar$3:
1772
1795
  return getMenuEntriesActivityBar(state);
1773
1796
  case ActivityBarAdditionalViews:
@@ -1780,7 +1803,7 @@ const getMenuEntries = (state, options) => {
1780
1803
  };
1781
1804
 
1782
1805
  const getMenuEntryIds = () => {
1783
- return [ActivityBar$3, ActivityBarAdditionalViews, Settings$1, ACCOUNT_MENU_ID];
1806
+ return [ActivityBar$3, ActivityBarAdditionalViews, Settings$1, ACCOUNT_MENU_ID, ACCOUNT_SUBMENU_ID];
1784
1807
  };
1785
1808
 
1786
1809
  const updateItemsWithBadgeCount = async items => {
@@ -2015,14 +2038,21 @@ const handleClickIndex = async (state, button, index, x, y) => {
2015
2038
  }
2016
2039
  };
2017
2040
 
2018
- const handleClick = async (state, button, eventX, eventY) => {
2041
+ const getIndexFromTarget = (state, targetName) => {
2042
+ if (!targetName) {
2043
+ return -1;
2044
+ }
2045
+ return state.filteredItems.findIndex(item => item.id === targetName);
2046
+ };
2047
+ const handleClick = async (state, button, eventX, eventY, targetName = '') => {
2019
2048
  const {
2020
2049
  filteredItems,
2021
2050
  height,
2022
2051
  itemHeight,
2023
2052
  y
2024
2053
  } = state;
2025
- const index = getIndexFromPosition(y, eventX, eventY, itemHeight, filteredItems, height);
2054
+ const targetIndex = getIndexFromTarget(state, targetName);
2055
+ const index = targetIndex === -1 ? getIndexFromPosition(y, eventX, eventY, itemHeight, filteredItems, height) : targetIndex;
2026
2056
  return handleClickIndex(state, button, index, eventX, eventY);
2027
2057
  };
2028
2058
 
@@ -2336,6 +2366,30 @@ const handleUpdateStateChange = async (state, config) => {
2336
2366
  };
2337
2367
  };
2338
2368
 
2369
+ const providerKeys = ['userLoginProvider', 'loginProvider', 'authProvider', 'provider'];
2370
+ const getUserLoginProvider = userInfo => {
2371
+ if (!userInfo || typeof userInfo !== 'object') {
2372
+ return 'GitHub';
2373
+ }
2374
+ const record = userInfo;
2375
+ for (const key of providerKeys) {
2376
+ if (typeof record[key] === 'string' && record[key]) {
2377
+ return record[key];
2378
+ }
2379
+ }
2380
+ return 'GitHub';
2381
+ };
2382
+
2383
+ const getUserName = userInfo => {
2384
+ if (!userInfo || typeof userInfo !== 'object') {
2385
+ return '';
2386
+ }
2387
+ if (!('userName' in userInfo) || typeof userInfo.userName !== 'string') {
2388
+ return '';
2389
+ }
2390
+ return userInfo.userName;
2391
+ };
2392
+
2339
2393
  const getUserState = userInfo => {
2340
2394
  if (!userInfo || typeof userInfo !== 'object') {
2341
2395
  return undefined;
@@ -2406,7 +2460,9 @@ const loadContent = async state => {
2406
2460
  const newState = {
2407
2461
  ...state,
2408
2462
  accountEnabled: accountEnabledNew,
2409
- userLoginState: toUserLoginState(getUserState(userInfo))
2463
+ userLoginProvider: getUserLoginProvider(userInfo),
2464
+ userLoginState: toUserLoginState(getUserState(userInfo)),
2465
+ userName: getUserName(userInfo)
2410
2466
  };
2411
2467
  const items = getActivityBarItems(newState, contributedViews);
2412
2468
  const index = items.findIndex(item => item.id === activeView);
@@ -2852,6 +2908,7 @@ const getActivityBarItemWithBadgeDom = item => {
2852
2908
  const {
2853
2909
  badgeText,
2854
2910
  flags,
2911
+ id,
2855
2912
  title
2856
2913
  } = item;
2857
2914
  if (!badgeText) {
@@ -2873,17 +2930,20 @@ const getActivityBarItemWithBadgeDom = item => {
2873
2930
  ariaSelected,
2874
2931
  childCount: 2,
2875
2932
  className,
2933
+ name: id,
2876
2934
  role,
2877
2935
  title,
2878
2936
  type: Div
2879
2937
  }, {
2880
2938
  childCount: 0,
2881
2939
  className: mergeClassNames(Icon, getIconClass(item, 'MaskIcon')),
2940
+ name: id,
2882
2941
  role: None$1,
2883
2942
  type: Div
2884
2943
  }, {
2885
2944
  childCount: 1,
2886
2945
  className: ActivityBarItemBadge,
2946
+ name: id,
2887
2947
  type: Div
2888
2948
  }, text(badgeText)];
2889
2949
  };
@@ -2902,6 +2962,7 @@ const getActivityBarItemVirtualDom = item => {
2902
2962
  badgeText,
2903
2963
  flags,
2904
2964
  icon,
2965
+ id,
2905
2966
  title
2906
2967
  } = item;
2907
2968
  const ariaHasPopup = getActivityBarItemHasPopup(item) || undefined;
@@ -2920,10 +2981,14 @@ const getActivityBarItemVirtualDom = item => {
2920
2981
  ariaSelected,
2921
2982
  childCount: 1,
2922
2983
  className,
2984
+ name: id,
2923
2985
  role,
2924
2986
  title,
2925
2987
  type: Div
2926
- }, getIconVirtualDom(icon, Div, item.customIconClass)];
2988
+ }, {
2989
+ ...getIconVirtualDom(icon, Div, item.customIconClass),
2990
+ name: id
2991
+ }];
2927
2992
  }
2928
2993
 
2929
2994
  // TODO support progress on selected activity bar item
@@ -2939,6 +3004,7 @@ const getActivityBarItemVirtualDom = item => {
2939
3004
  ariaSelected,
2940
3005
  childCount: 0,
2941
3006
  className: mergeClassNames(className, getIconClass(item, 'Icon')),
3007
+ name: id,
2942
3008
  role,
2943
3009
  title,
2944
3010
  type: Div
@@ -3043,7 +3109,7 @@ const renderEventListeners = () => {
3043
3109
  preventDefault: true
3044
3110
  }, {
3045
3111
  name: HandleMouseDown,
3046
- params: ['handleClick', Button$1, ClientX, ClientY],
3112
+ params: ['handleClick', Button$1, ClientX, ClientY, TargetName],
3047
3113
  preventDefault: false,
3048
3114
  stopPropagation: false
3049
3115
  }];
@@ -3073,10 +3139,12 @@ const setAccountEnabled = (state, enabled) => {
3073
3139
  };
3074
3140
  };
3075
3141
 
3076
- const setUserLoginState = (state, userLoginState) => {
3142
+ const setUserLoginState = (state, userLoginState, userInfo) => {
3077
3143
  return {
3078
3144
  ...state,
3079
- userLoginState
3145
+ userLoginProvider: getUserLoginProvider(userInfo),
3146
+ userLoginState,
3147
+ userName: getUserName(userInfo)
3080
3148
  };
3081
3149
  };
3082
3150
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/activity-bar-worker",
3
- "version": "7.4.0",
3
+ "version": "7.6.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",