@lvce-editor/activity-bar-worker 7.25.0 → 7.27.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.
@@ -2174,6 +2174,10 @@ const getActiveViewIds = items => {
2174
2174
  return items.filter(item => item.flags & Selected).map(item => item.id);
2175
2175
  };
2176
2176
 
2177
+ const Default = 0;
2178
+ const Preview = 1;
2179
+ const SideBar = 2;
2180
+
2177
2181
  const Account = 'Account';
2178
2182
  const DebugAlt2 = 'DebugAlt2';
2179
2183
  const Extensions$1 = 'Extensions';
@@ -2194,10 +2198,17 @@ const getFilteredActivityBarItems = (items, height, itemHeight) => {
2194
2198
  return enabledItems;
2195
2199
  }
2196
2200
  const showMoreItem = {
2201
+ badgeIcon: '',
2202
+ badgeText: '',
2203
+ customIconClass: '',
2204
+ customIconUrl: '',
2205
+ enabled: false,
2197
2206
  flags: Button,
2207
+ hasPopup: false,
2198
2208
  icon: Ellipsis,
2199
2209
  id: 'Additional Views',
2200
2210
  keyShortcuts: '',
2211
+ preferredLocation: Default,
2201
2212
  title: additionalViews()
2202
2213
  };
2203
2214
  return [...enabledItems.slice(0, numberOfVisibleItems - 2), showMoreItem, enabledItems.at(-1)];
@@ -2410,7 +2421,7 @@ const handleClickOther = async (state, viewletId) => {
2410
2421
  const selectedItem = activityBarItems.find(item => item.id === viewletId);
2411
2422
  const sideBarChange = getSideBarChange(sideBarVisible, currentViewletId, viewletId);
2412
2423
  await toggle(viewletId);
2413
- if (selectedItem?.preferredLocation === 'preview') {
2424
+ if (selectedItem?.preferredLocation === Preview) {
2414
2425
  const isActive = activeViewIds.includes(viewletId);
2415
2426
  const newActiveViewIds = isActive ? activeViewIds.filter(id => id !== viewletId) : [...activeViewIds, viewletId];
2416
2427
  const newActivityBarItems = markActiveViews(activityBarItems, newActiveViewIds);
@@ -2576,27 +2587,24 @@ const Search = 'Search';
2576
2587
  const SourceControl = 'Source Control';
2577
2588
 
2578
2589
  const toActivityBarItem = view => {
2590
+ const defaultLocation = view.preferredLocation === 'sideBar' ? SideBar : Default;
2579
2591
  const icon = view.icon || Extensions$1;
2580
- const customIconUrl = isCustomIconUrl(icon) ? icon : undefined;
2581
- const customIconClass = customIconUrl ? getCustomIconClass(view.id, customIconUrl) : undefined;
2582
- const item = {
2592
+ const customIconUrl = isCustomIconUrl(icon) ? icon : '';
2593
+ const customIconClass = customIconUrl ? getCustomIconClass(view.id, customIconUrl) : '';
2594
+ return {
2595
+ badgeIcon: '',
2596
+ badgeText: '',
2597
+ customIconClass,
2598
+ customIconUrl,
2599
+ enabled: false,
2583
2600
  flags: Tab | Enabled,
2601
+ hasPopup: false,
2584
2602
  icon,
2585
2603
  id: view.id,
2586
2604
  keyShortcuts: '',
2587
- ...(view.preferredLocation === 'preview' && {
2588
- preferredLocation: 'preview'
2589
- }),
2605
+ preferredLocation: view.preferredLocation === 'preview' ? Preview : defaultLocation,
2590
2606
  title: view.title || view.id
2591
2607
  };
2592
- if (customIconClass && customIconUrl) {
2593
- return {
2594
- ...item,
2595
- customIconClass,
2596
- customIconUrl
2597
- };
2598
- }
2599
- return item;
2600
2608
  };
2601
2609
  const getActivityBarItems = (state, contributedViews = []) => {
2602
2610
  const {
@@ -2608,58 +2616,114 @@ const getActivityBarItems = (state, contributedViews = []) => {
2608
2616
  const items = [
2609
2617
  // Top
2610
2618
  {
2619
+ badgeIcon: '',
2620
+ badgeText: '',
2621
+ customIconClass: '',
2622
+ customIconUrl: '',
2623
+ enabled: false,
2611
2624
  flags: Tab | Enabled,
2625
+ hasPopup: false,
2612
2626
  icon: Files,
2613
2627
  id: Explorer,
2614
2628
  keyShortcuts: 'Control+Shift+E',
2629
+ preferredLocation: Default,
2615
2630
  title: explorer()
2616
2631
  }, {
2632
+ badgeIcon: '',
2633
+ badgeText: '',
2634
+ customIconClass: '',
2635
+ customIconUrl: '',
2636
+ enabled: false,
2617
2637
  flags: Tab | Enabled,
2638
+ hasPopup: false,
2618
2639
  icon: Search$1,
2619
2640
  id: Search,
2620
2641
  keyShortcuts: 'Control+Shift+F',
2642
+ preferredLocation: Default,
2621
2643
  title: search()
2622
2644
  }, {
2645
+ badgeIcon: '',
2646
+ badgeText: '',
2647
+ customIconClass: '',
2648
+ customIconUrl: '',
2649
+ enabled: false,
2623
2650
  flags: Tab | Enabled,
2651
+ hasPopup: false,
2624
2652
  icon: SourceControl$1,
2625
2653
  id: SourceControl,
2626
2654
  keyShortcuts: 'Control+Shift+G',
2655
+ preferredLocation: Default,
2627
2656
  title: sourceControl()
2628
2657
  }, {
2658
+ badgeIcon: '',
2659
+ badgeText: '',
2660
+ customIconClass: '',
2661
+ customIconUrl: '',
2662
+ enabled: false,
2629
2663
  flags: Tab | Enabled,
2664
+ hasPopup: false,
2630
2665
  icon: DebugAlt2,
2631
2666
  id: RunAndDebug,
2632
2667
  keyShortcuts: 'Control+Shift+D',
2668
+ preferredLocation: Default,
2633
2669
  title: runAndDebug()
2634
2670
  }, {
2671
+ badgeIcon: '',
2672
+ badgeText: '',
2673
+ customIconClass: '',
2674
+ customIconUrl: '',
2675
+ enabled: false,
2635
2676
  flags: Tab | Enabled,
2677
+ hasPopup: false,
2636
2678
  icon: Extensions$1,
2637
2679
  id: Extensions,
2638
2680
  keyShortcuts: 'Control+Shift+X',
2681
+ preferredLocation: Default,
2639
2682
  title: extensions()
2640
2683
  }, {
2684
+ badgeIcon: '',
2685
+ badgeText: '',
2686
+ customIconClass: '',
2687
+ customIconUrl: '',
2688
+ enabled: false,
2641
2689
  flags: Tab | (referencesEnabled ? Enabled : 0),
2690
+ hasPopup: false,
2642
2691
  icon: References$1,
2643
2692
  id: References,
2644
2693
  keyShortcuts: '',
2694
+ preferredLocation: Default,
2645
2695
  title: references()
2646
2696
  }, ...contributedViews.map(toActivityBarItem)
2647
2697
  // Bottom
2648
2698
  ];
2649
2699
  if (accountEnabled) {
2650
2700
  items.push({
2701
+ badgeIcon: '',
2702
+ badgeText: '',
2703
+ customIconClass: '',
2704
+ customIconUrl: '',
2705
+ enabled: false,
2651
2706
  flags: Button | Enabled | MarginTop,
2707
+ hasPopup: true,
2652
2708
  icon: Account,
2653
2709
  id: 'Account',
2654
2710
  keyShortcuts: '',
2711
+ preferredLocation: Default,
2655
2712
  title: account()
2656
2713
  });
2657
2714
  }
2658
2715
  items.push({
2716
+ badgeIcon: '',
2717
+ badgeText: '',
2718
+ customIconClass: '',
2719
+ customIconUrl: '',
2720
+ enabled: false,
2659
2721
  flags: settingsFlags,
2722
+ hasPopup: true,
2660
2723
  icon: SettingsGear,
2661
2724
  id: 'Settings',
2662
2725
  keyShortcuts: '',
2726
+ preferredLocation: Default,
2663
2727
  title: settings()
2664
2728
  });
2665
2729
  return items;
@@ -2977,28 +3041,39 @@ const loadContent = async state => {
2977
3041
  };
2978
3042
  };
2979
3043
 
2980
- const escapeCssUrl = url => {
2981
- return url.replaceAll('\\', '\\\\').replaceAll('"', '\\"').replaceAll('\n', '\\a ').replaceAll('\r', '\\d ').replaceAll('\f', '\\c ');
2982
- };
2983
-
2984
- const getCustomIconCss = items => {
3044
+ const getCustomIconItems = items => {
2985
3045
  const seen = new Set();
2986
- let css = '';
2987
- for (const item of items) {
3046
+ return items.filter(item => {
2988
3047
  const {
2989
3048
  customIconClass,
2990
3049
  customIconUrl
2991
3050
  } = item;
2992
3051
  if (!customIconClass || !customIconUrl || seen.has(customIconClass)) {
2993
- continue;
3052
+ return false;
2994
3053
  }
2995
3054
  seen.add(customIconClass);
2996
- css += `.${customIconClass} {
3055
+ return true;
3056
+ });
3057
+ };
3058
+
3059
+ const escapeCssUrl = url => {
3060
+ return url.replaceAll('\\', '\\\\').replaceAll('"', '\\"').replaceAll('\n', '\\a ').replaceAll('\r', '\\d ').replaceAll('\f', '\\c ');
3061
+ };
3062
+
3063
+ const getCustomIconRule = item => {
3064
+ const {
3065
+ customIconClass,
3066
+ customIconUrl
3067
+ } = item;
3068
+ return `.${customIconClass} {
2997
3069
  mask-image: url("${escapeCssUrl(customIconUrl)}");
2998
- }
2999
- `;
3000
- }
3001
- return css;
3070
+ }`;
3071
+ };
3072
+
3073
+ const getCustomIconCss = items => {
3074
+ const customIconItems = getCustomIconItems(items);
3075
+ const cssRules = customIconItems.map(getCustomIconRule);
3076
+ return cssRules.join('\n');
3002
3077
  };
3003
3078
 
3004
3079
  const getCss = (itemHeight, items = []) => {
@@ -3327,7 +3402,7 @@ const HandleFocus = 3;
3327
3402
  const HandleMouseDown = 4;
3328
3403
 
3329
3404
  const getActivityBarItemHasPopup = item => {
3330
- return item.id === 'Account' || item.id === 'Settings';
3405
+ return item.hasPopup;
3331
3406
  };
3332
3407
 
3333
3408
  const getAriaSelected = (isTab, isSelected) => {
@@ -4,7 +4,7 @@
4
4
  "description": "Show the account item in the activity bar",
5
5
  "heading": "Account",
6
6
  "id": "activityBar.accountEnabled",
7
- "type": 3,
7
+ "type": "boolean",
8
8
  "value": true
9
9
  }
10
10
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/activity-bar-worker",
3
- "version": "7.25.0",
3
+ "version": "7.27.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",