@lvce-editor/activity-bar-worker 7.9.2 → 7.9.4

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.
@@ -249,7 +249,7 @@ const {
249
249
  get: get$2,
250
250
  getCommandIds,
251
251
  registerCommands,
252
- set: set$4,
252
+ set: set$3,
253
253
  wrapCommand,
254
254
  wrapGetter
255
255
  } = create$a();
@@ -283,7 +283,7 @@ const create$9 = (id, uri, x, y, width, height, args, parentUid, platform = 0) =
283
283
  x,
284
284
  y
285
285
  };
286
- set$4(id, state, state);
286
+ set$3(id, state, state);
287
287
  return state;
288
288
  };
289
289
 
@@ -620,8 +620,12 @@ const getKeyBindings = () => {
620
620
 
621
621
  const ACCOUNT_SUBMENU_ID = 32_123;
622
622
  const getAccountLabel = state => {
623
- const name = state.userName || 'Account';
624
- const provider = state.userLoginProvider || 'GitHub';
623
+ const {
624
+ userLoginProvider,
625
+ userName
626
+ } = state;
627
+ const name = userName || 'Account';
628
+ const provider = userLoginProvider || 'GitHub';
625
629
  return `${name} (${provider})`;
626
630
  };
627
631
  const getMenuEntriesAccountLoggedIn = state => {
@@ -823,8 +827,11 @@ const getNumberOfVisibleItems = state => {
823
827
  return numberOfVisibleItemsTop;
824
828
  };
825
829
  const getHiddenItems = state => {
830
+ const {
831
+ activityBarItems
832
+ } = state;
826
833
  const numberOfVisibleItems = getNumberOfVisibleItems(state);
827
- const items = state.activityBarItems.filter(item => item.flags & Enabled);
834
+ const items = activityBarItems.filter(item => item.flags & Enabled);
828
835
  if (numberOfVisibleItems >= items.length) {
829
836
  return [];
830
837
  }
@@ -1986,7 +1993,7 @@ const createMockRpc = ({
1986
1993
  };
1987
1994
 
1988
1995
  const rpcs = Object.create(null);
1989
- const set$3 = (id, rpc) => {
1996
+ const set$2 = (id, rpc) => {
1990
1997
  rpcs[id] = rpc;
1991
1998
  };
1992
1999
  const get = id => {
@@ -2019,7 +2026,7 @@ const create = rpcId => {
2019
2026
  const mockRpc = createMockRpc({
2020
2027
  commandMap
2021
2028
  });
2022
- set$3(rpcId, mockRpc);
2029
+ set$2(rpcId, mockRpc);
2023
2030
  // @ts-ignore
2024
2031
  mockRpc[Symbol.dispose] = () => {
2025
2032
  remove(rpcId);
@@ -2028,15 +2035,11 @@ const create = rpcId => {
2028
2035
  return mockRpc;
2029
2036
  },
2030
2037
  set(rpc) {
2031
- set$3(rpcId, rpc);
2038
+ set$2(rpcId, rpc);
2032
2039
  }
2033
2040
  };
2034
2041
  };
2035
2042
 
2036
- const {
2037
- set: set$2
2038
- } = create(6010);
2039
-
2040
2043
  const {
2041
2044
  invoke: invoke$1,
2042
2045
  set: set$1
@@ -2054,10 +2057,6 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
2054
2057
  number(y);
2055
2058
  await invoke('ContextMenu.show2', uid, menuId, x, y, args);
2056
2059
  };
2057
- const sendMessagePortToAuthWorker = async (port, rpcId) => {
2058
- const command = 'HandleMessagePort.handleMessagePort';
2059
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToAuthWorker', port, command, rpcId);
2060
- };
2061
2060
  const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
2062
2061
  const command = 'Extensions.handleMessagePort';
2063
2062
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
@@ -2073,6 +2072,11 @@ const handleClickAccount = async (state, eventX, eventY, viewletId) => {
2073
2072
  sideBarLocation,
2074
2073
  uid
2075
2074
  } = state;
2075
+ try {
2076
+ await invoke('Layout.refreshAuthState');
2077
+ } catch {
2078
+ // Keep the account menu available when auth is unavailable.
2079
+ }
2076
2080
  await show2(uid, ACCOUNT_MENU_ID, eventX, eventY, {
2077
2081
  menuId: ACCOUNT_MENU_ID,
2078
2082
  openSubMenuToLeft: sideBarLocation === Right
@@ -2122,8 +2126,11 @@ const updateItemsWithBadgeCount = async items => {
2122
2126
  };
2123
2127
 
2124
2128
  const updateStateItems = (state, activityBarItems) => {
2129
+ const {
2130
+ filteredItems: currentFilteredItems
2131
+ } = state;
2125
2132
  const itemById = new Map(activityBarItems.map(item => [item.id, item]));
2126
- const filteredItems = state.filteredItems.map(item => itemById.get(item.id) || item);
2133
+ const filteredItems = currentFilteredItems.map(item => itemById.get(item.id) || item);
2127
2134
  return {
2128
2135
  ...state,
2129
2136
  activityBarItems,
@@ -2131,7 +2138,10 @@ const updateStateItems = (state, activityBarItems) => {
2131
2138
  };
2132
2139
  };
2133
2140
  const applyBadgeCountChanges = (state, badgeCounts) => {
2134
- const activityBarItems = state.activityBarItems.map(item => {
2141
+ const {
2142
+ activityBarItems: currentActivityBarItems
2143
+ } = state;
2144
+ const activityBarItems = currentActivityBarItems.map(item => {
2135
2145
  if (!Object.hasOwn(badgeCounts, item.id)) {
2136
2146
  return item;
2137
2147
  }
@@ -2147,8 +2157,11 @@ const handleBadgeCountChange = async (state, badgeCounts) => {
2147
2157
  if (badgeCounts) {
2148
2158
  return applyBadgeCountChanges(state, badgeCounts);
2149
2159
  }
2150
- const newActivityBarItems = await updateItemsWithBadgeCount(state.activityBarItems);
2151
- if (newActivityBarItems === state.activityBarItems) {
2160
+ const {
2161
+ activityBarItems
2162
+ } = state;
2163
+ const newActivityBarItems = await updateItemsWithBadgeCount(activityBarItems);
2164
+ if (newActivityBarItems === activityBarItems) {
2152
2165
  return state;
2153
2166
  }
2154
2167
  return updateStateItems(state, newActivityBarItems);
@@ -2254,24 +2267,6 @@ const getFilteredActivityBarItems = (items, height, itemHeight) => {
2254
2267
  return [...enabledItems.slice(0, numberOfVisibleItems - 2), showMoreItem, enabledItems.at(-1)];
2255
2268
  };
2256
2269
 
2257
- const setFlag = (item, flag, enabled) => {
2258
- return {
2259
- ...item,
2260
- flags: enabled ? item.flags | flag : item.flags & ~flag
2261
- };
2262
- };
2263
-
2264
- const markSelected = (items, selectedIndex) => {
2265
- return items.map((item, index) => {
2266
- const isSelected = index === selectedIndex;
2267
- return setFlag(item, Selected, isSelected);
2268
- });
2269
- };
2270
-
2271
- const toggle = async id => {
2272
- await invoke('Layout.toggleSideBarView', id);
2273
- };
2274
-
2275
2270
  const getSideBarChange = (sideBarVisible, currentViewletId, viewletId) => {
2276
2271
  if (sideBarVisible) {
2277
2272
  if (currentViewletId === viewletId) {
@@ -2290,6 +2285,25 @@ const getSideBarChange = (sideBarVisible, currentViewletId, viewletId) => {
2290
2285
  viewletId
2291
2286
  };
2292
2287
  };
2288
+
2289
+ const setFlag = (item, flag, enabled) => {
2290
+ return {
2291
+ ...item,
2292
+ flags: enabled ? item.flags | flag : item.flags & ~flag
2293
+ };
2294
+ };
2295
+
2296
+ const markSelected = (items, selectedIndex) => {
2297
+ return items.map((item, index) => {
2298
+ const isSelected = index === selectedIndex;
2299
+ return setFlag(item, Selected, isSelected);
2300
+ });
2301
+ };
2302
+
2303
+ const toggle = async id => {
2304
+ await invoke('Layout.toggleSideBarView', id);
2305
+ };
2306
+
2293
2307
  const handleClickOther = async (state, viewletId) => {
2294
2308
  const {
2295
2309
  activityBarItems,
@@ -2362,7 +2376,10 @@ const getIndexFromTarget = (state, targetName) => {
2362
2376
  if (!targetName) {
2363
2377
  return -1;
2364
2378
  }
2365
- return state.filteredItems.findIndex(item => item.id === targetName);
2379
+ const {
2380
+ filteredItems
2381
+ } = state;
2382
+ return filteredItems.findIndex(item => item.id === targetName);
2366
2383
  };
2367
2384
  const handleClick = async (state, button, eventX, eventY, targetName = '') => {
2368
2385
  const {
@@ -2524,9 +2541,10 @@ const handleExtensionsChanged = async state => {
2524
2541
  const {
2525
2542
  height,
2526
2543
  itemHeight,
2544
+ platform,
2527
2545
  selectedIndex
2528
2546
  } = state;
2529
- const contributedViews = await getContributedViews(state.platform);
2547
+ const contributedViews = await getContributedViews(platform);
2530
2548
  const items = getActivityBarItems(state, contributedViews);
2531
2549
  const itemsWithSelected = markSelected(items, selectedIndex);
2532
2550
  const activityBarItems = await updateItemsWithBadgeCount(itemsWithSelected);
@@ -2586,11 +2604,13 @@ const getSideBarPosition = async () => {
2586
2604
 
2587
2605
  const handleSettingsChanged = async state => {
2588
2606
  const {
2607
+ accountEnabled: currentAccountEnabled,
2589
2608
  height,
2590
2609
  itemHeight,
2610
+ platform,
2591
2611
  selectedIndex
2592
2612
  } = state;
2593
- const [accountEnabled, contributedViews, sidebarLocation] = await Promise.all([getAccountEnabled(state.accountEnabled), getContributedViews(state.platform), getSideBarPosition()]);
2613
+ const [accountEnabled, contributedViews, sidebarLocation] = await Promise.all([getAccountEnabled(currentAccountEnabled), getContributedViews(platform), getSideBarPosition()]);
2594
2614
  const newState = {
2595
2615
  ...state,
2596
2616
  accountEnabled
@@ -2620,12 +2640,14 @@ const clearItem = item => {
2620
2640
  const withoutSelected = setFlag(item, Selected, false);
2621
2641
  return setFlag(withoutSelected, Focused, false);
2622
2642
  };
2623
- const handleSideBarStateChange = async (state, id = state.currentViewletId, sideBarVisibleOverride) => {
2643
+ const handleSideBarStateChange = async (state, id, sideBarVisibleOverride) => {
2624
2644
  const {
2625
2645
  activityBarItems,
2646
+ currentViewletId,
2626
2647
  height,
2627
2648
  itemHeight
2628
2649
  } = state;
2650
+ const resolvedId = id === undefined ? currentViewletId : id;
2629
2651
  const sideBarVisible = typeof sideBarVisibleOverride === 'boolean' ? sideBarVisibleOverride : await getSideBarVisible();
2630
2652
  if (!sideBarVisible) {
2631
2653
  const itemsCleared = activityBarItems.map(clearItem);
@@ -2639,13 +2661,13 @@ const handleSideBarStateChange = async (state, id = state.currentViewletId, side
2639
2661
  sideBarVisible: false
2640
2662
  };
2641
2663
  }
2642
- const selectedIndex = findIndex(activityBarItems, id);
2664
+ const selectedIndex = findIndex(activityBarItems, resolvedId);
2643
2665
  const newActivityBarItems = markSelected(activityBarItems, selectedIndex);
2644
2666
  const filteredItems = getFilteredActivityBarItems(newActivityBarItems, height, itemHeight);
2645
2667
  return {
2646
2668
  ...state,
2647
2669
  activityBarItems: newActivityBarItems,
2648
- currentViewletId: id,
2670
+ currentViewletId: resolvedId,
2649
2671
  filteredItems,
2650
2672
  selectedIndex,
2651
2673
  sideBarVisible
@@ -2690,40 +2712,6 @@ const handleUpdateStateChange = async (state, config) => {
2690
2712
  };
2691
2713
  };
2692
2714
 
2693
- const providerKeys = ['userLoginProvider', 'loginProvider', 'authProvider', 'provider'];
2694
- const getUserLoginProvider = userInfo => {
2695
- if (!userInfo || typeof userInfo !== 'object') {
2696
- return 'GitHub';
2697
- }
2698
- const record = userInfo;
2699
- for (const key of providerKeys) {
2700
- if (typeof record[key] === 'string' && record[key]) {
2701
- return record[key];
2702
- }
2703
- }
2704
- return 'GitHub';
2705
- };
2706
-
2707
- const getUserName = userInfo => {
2708
- if (!userInfo || typeof userInfo !== 'object') {
2709
- return '';
2710
- }
2711
- if (!('userName' in userInfo) || typeof userInfo.userName !== 'string') {
2712
- return '';
2713
- }
2714
- return userInfo.userName;
2715
- };
2716
-
2717
- const getUserState = userInfo => {
2718
- if (!userInfo || typeof userInfo !== 'object') {
2719
- return undefined;
2720
- }
2721
- if (!('userState' in userInfo)) {
2722
- return undefined;
2723
- }
2724
- return userInfo.userState;
2725
- };
2726
-
2727
2715
  const getActiveView = async () => {
2728
2716
  try {
2729
2717
  const activeView = await invoke('Layout.getActiveSideBarView');
@@ -2733,39 +2721,17 @@ const getActiveView = async () => {
2733
2721
  }
2734
2722
  };
2735
2723
 
2736
- const getUserInfo = async () => {
2737
- try {
2738
- return await invoke('Layout.getUserInfo');
2739
- } catch {
2740
- return undefined;
2741
- }
2742
- };
2743
-
2744
2724
  const loadPreferences = async (accountEnabled, platform) => {
2745
- const [accountEnabledNew, activeView, contributedViews, sidebarLocation, sideBarVisible, userInfo] = await Promise.all([getAccountEnabled(accountEnabled), getActiveView(), getContributedViews(platform), getSideBarPosition(), getSideBarVisible(), getUserInfo()]);
2725
+ const [accountEnabledNew, activeView, contributedViews, sidebarLocation, sideBarVisible] = await Promise.all([getAccountEnabled(accountEnabled), getActiveView(), getContributedViews(platform), getSideBarPosition(), getSideBarVisible()]);
2746
2726
  return {
2747
2727
  accountEnabled: accountEnabledNew,
2748
2728
  activeView,
2749
2729
  contributedViews,
2750
2730
  sidebarLocation,
2751
- sideBarVisible,
2752
- userInfo
2731
+ sideBarVisible
2753
2732
  };
2754
2733
  };
2755
2734
 
2756
- const toUserLoginState = userState => {
2757
- switch (userState) {
2758
- case 'loggedIn':
2759
- return 'logged in';
2760
- case 'loggingIn':
2761
- return 'logging in';
2762
- case 'loggingOut':
2763
- return 'logging out';
2764
- default:
2765
- return 'logged out';
2766
- }
2767
- };
2768
-
2769
2735
  const loadContent = async state => {
2770
2736
  const {
2771
2737
  accountEnabled,
@@ -2778,15 +2744,11 @@ const loadContent = async state => {
2778
2744
  activeView,
2779
2745
  contributedViews,
2780
2746
  sidebarLocation,
2781
- sideBarVisible,
2782
- userInfo
2747
+ sideBarVisible
2783
2748
  } = await loadPreferences(accountEnabled, platform);
2784
2749
  const newState = {
2785
2750
  ...state,
2786
- accountEnabled: accountEnabledNew,
2787
- userLoginProvider: getUserLoginProvider(userInfo),
2788
- userLoginState: toUserLoginState(getUserState(userInfo)),
2789
- userName: getUserName(userInfo)
2751
+ accountEnabled: accountEnabledNew
2790
2752
  };
2791
2753
  const items = getActivityBarItems(newState, contributedViews);
2792
2754
  const index = items.findIndex(item => item.id === activeView);
@@ -3215,7 +3177,6 @@ const getActivityBarItemInProgressDom = item => {
3215
3177
  className += ' ' + ActivityBarItemNested;
3216
3178
  return [{
3217
3179
  ariaHasPopup,
3218
- ariaLabel: '',
3219
3180
  ariaSelected,
3220
3181
  childCount: 2,
3221
3182
  className,
@@ -3252,7 +3213,6 @@ const getActivityBarItemWithBadgeDom = item => {
3252
3213
  className += ' ' + ActivityBarItemNested;
3253
3214
  return [{
3254
3215
  ariaHasPopup,
3255
- ariaLabel: '',
3256
3216
  ariaSelected,
3257
3217
  childCount: 2,
3258
3218
  className,
@@ -3303,7 +3263,6 @@ const getActivityBarItemVirtualDom = item => {
3303
3263
  if (isSelected && !badgeText) {
3304
3264
  return [{
3305
3265
  ariaHasPopup,
3306
- ariaLabel: '',
3307
3266
  ariaSelected,
3308
3267
  childCount: 1,
3309
3268
  className,
@@ -3326,7 +3285,6 @@ const getActivityBarItemVirtualDom = item => {
3326
3285
  }
3327
3286
  return [{
3328
3287
  ariaHasPopup,
3329
- ariaLabel: '',
3330
3288
  ariaSelected,
3331
3289
  childCount: 0,
3332
3290
  className: mergeClassNames(className, getIconClass(item, 'Icon')),
@@ -3342,6 +3300,8 @@ const getVirtualDom = visibleItems => {
3342
3300
  return dom;
3343
3301
  };
3344
3302
 
3303
+ const Focusable = 0;
3304
+
3345
3305
  const className = mergeClassNames(Viewlet, ActivityBar$1);
3346
3306
  const getActivityBarVirtualDom = visibleItems => {
3347
3307
  return [{
@@ -3355,7 +3315,7 @@ const getActivityBarVirtualDom = visibleItems => {
3355
3315
  onFocus: HandleFocus,
3356
3316
  onMouseDown: HandleMouseDown,
3357
3317
  role: ToolBar,
3358
- tabIndex: 0,
3318
+ tabIndex: Focusable,
3359
3319
  type: Div
3360
3320
  }, ...getVirtualDom(visibleItems)];
3361
3321
  };
@@ -3417,7 +3377,7 @@ const render2 = (uid, diffResult) => {
3417
3377
  newState,
3418
3378
  oldState
3419
3379
  } = get$2(uid);
3420
- set$4(uid, newState, newState);
3380
+ set$3(uid, newState, newState);
3421
3381
  const commands = applyRender(oldState, newState, diffResult);
3422
3382
  return commands;
3423
3383
  };
@@ -3465,6 +3425,30 @@ const setAccountEnabled = (state, enabled) => {
3465
3425
  };
3466
3426
  };
3467
3427
 
3428
+ const providerKeys = ['userLoginProvider', 'loginProvider', 'authProvider', 'provider'];
3429
+ const getUserLoginProvider = userInfo => {
3430
+ if (!userInfo || typeof userInfo !== 'object') {
3431
+ return 'GitHub';
3432
+ }
3433
+ const record = userInfo;
3434
+ for (const key of providerKeys) {
3435
+ if (typeof record[key] === 'string' && record[key]) {
3436
+ return record[key];
3437
+ }
3438
+ }
3439
+ return 'GitHub';
3440
+ };
3441
+
3442
+ const getUserName = userInfo => {
3443
+ if (!userInfo || typeof userInfo !== 'object') {
3444
+ return '';
3445
+ }
3446
+ if (!('userName' in userInfo) || typeof userInfo.userName !== 'string') {
3447
+ return '';
3448
+ }
3449
+ return userInfo.userName;
3450
+ };
3451
+
3468
3452
  const setUserLoginState = (state, userLoginState, userInfo) => {
3469
3453
  return {
3470
3454
  ...state,
@@ -3538,18 +3522,6 @@ const commandMap = {
3538
3522
  'ActivityBar.toggleActivityBarItem': wrapCommand(toggleActivityBarItem)
3539
3523
  };
3540
3524
 
3541
- const send$1 = async port => {
3542
- // @ts-ignore
3543
- await sendMessagePortToAuthWorker(port);
3544
- };
3545
- const initializeAuthWorker = async () => {
3546
- const rpc = await create$2({
3547
- commandMap: {},
3548
- send: send$1
3549
- });
3550
- set$2(rpc);
3551
- };
3552
-
3553
3525
  const send = async port => {
3554
3526
  await sendMessagePortToExtensionManagementWorker(port, 0);
3555
3527
  };
@@ -3570,7 +3542,7 @@ const initializeRendererWorker = async () => {
3570
3542
 
3571
3543
  const listen = async () => {
3572
3544
  registerCommands(commandMap);
3573
- await Promise.all([initializeRendererWorker(), initializeAuthWorker(), initializeExtensionManagementWorker()]);
3545
+ await Promise.all([initializeRendererWorker(), initializeExtensionManagementWorker()]);
3574
3546
  };
3575
3547
 
3576
3548
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/activity-bar-worker",
3
- "version": "7.9.2",
3
+ "version": "7.9.4",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",