@lvce-editor/activity-bar-worker 7.9.2 → 7.9.3
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/dist/activityBarWorkerMain.js +67 -36
- package/package.json +1 -1
|
@@ -620,8 +620,12 @@ const getKeyBindings = () => {
|
|
|
620
620
|
|
|
621
621
|
const ACCOUNT_SUBMENU_ID = 32_123;
|
|
622
622
|
const getAccountLabel = state => {
|
|
623
|
-
const
|
|
624
|
-
|
|
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 =
|
|
834
|
+
const items = activityBarItems.filter(item => item.flags & Enabled);
|
|
828
835
|
if (numberOfVisibleItems >= items.length) {
|
|
829
836
|
return [];
|
|
830
837
|
}
|
|
@@ -2122,8 +2129,11 @@ const updateItemsWithBadgeCount = async items => {
|
|
|
2122
2129
|
};
|
|
2123
2130
|
|
|
2124
2131
|
const updateStateItems = (state, activityBarItems) => {
|
|
2132
|
+
const {
|
|
2133
|
+
filteredItems: currentFilteredItems
|
|
2134
|
+
} = state;
|
|
2125
2135
|
const itemById = new Map(activityBarItems.map(item => [item.id, item]));
|
|
2126
|
-
const filteredItems =
|
|
2136
|
+
const filteredItems = currentFilteredItems.map(item => itemById.get(item.id) || item);
|
|
2127
2137
|
return {
|
|
2128
2138
|
...state,
|
|
2129
2139
|
activityBarItems,
|
|
@@ -2131,7 +2141,10 @@ const updateStateItems = (state, activityBarItems) => {
|
|
|
2131
2141
|
};
|
|
2132
2142
|
};
|
|
2133
2143
|
const applyBadgeCountChanges = (state, badgeCounts) => {
|
|
2134
|
-
const
|
|
2144
|
+
const {
|
|
2145
|
+
activityBarItems: currentActivityBarItems
|
|
2146
|
+
} = state;
|
|
2147
|
+
const activityBarItems = currentActivityBarItems.map(item => {
|
|
2135
2148
|
if (!Object.hasOwn(badgeCounts, item.id)) {
|
|
2136
2149
|
return item;
|
|
2137
2150
|
}
|
|
@@ -2147,8 +2160,11 @@ const handleBadgeCountChange = async (state, badgeCounts) => {
|
|
|
2147
2160
|
if (badgeCounts) {
|
|
2148
2161
|
return applyBadgeCountChanges(state, badgeCounts);
|
|
2149
2162
|
}
|
|
2150
|
-
const
|
|
2151
|
-
|
|
2163
|
+
const {
|
|
2164
|
+
activityBarItems
|
|
2165
|
+
} = state;
|
|
2166
|
+
const newActivityBarItems = await updateItemsWithBadgeCount(activityBarItems);
|
|
2167
|
+
if (newActivityBarItems === activityBarItems) {
|
|
2152
2168
|
return state;
|
|
2153
2169
|
}
|
|
2154
2170
|
return updateStateItems(state, newActivityBarItems);
|
|
@@ -2254,24 +2270,6 @@ const getFilteredActivityBarItems = (items, height, itemHeight) => {
|
|
|
2254
2270
|
return [...enabledItems.slice(0, numberOfVisibleItems - 2), showMoreItem, enabledItems.at(-1)];
|
|
2255
2271
|
};
|
|
2256
2272
|
|
|
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
2273
|
const getSideBarChange = (sideBarVisible, currentViewletId, viewletId) => {
|
|
2276
2274
|
if (sideBarVisible) {
|
|
2277
2275
|
if (currentViewletId === viewletId) {
|
|
@@ -2290,6 +2288,25 @@ const getSideBarChange = (sideBarVisible, currentViewletId, viewletId) => {
|
|
|
2290
2288
|
viewletId
|
|
2291
2289
|
};
|
|
2292
2290
|
};
|
|
2291
|
+
|
|
2292
|
+
const setFlag = (item, flag, enabled) => {
|
|
2293
|
+
return {
|
|
2294
|
+
...item,
|
|
2295
|
+
flags: enabled ? item.flags | flag : item.flags & ~flag
|
|
2296
|
+
};
|
|
2297
|
+
};
|
|
2298
|
+
|
|
2299
|
+
const markSelected = (items, selectedIndex) => {
|
|
2300
|
+
return items.map((item, index) => {
|
|
2301
|
+
const isSelected = index === selectedIndex;
|
|
2302
|
+
return setFlag(item, Selected, isSelected);
|
|
2303
|
+
});
|
|
2304
|
+
};
|
|
2305
|
+
|
|
2306
|
+
const toggle = async id => {
|
|
2307
|
+
await invoke('Layout.toggleSideBarView', id);
|
|
2308
|
+
};
|
|
2309
|
+
|
|
2293
2310
|
const handleClickOther = async (state, viewletId) => {
|
|
2294
2311
|
const {
|
|
2295
2312
|
activityBarItems,
|
|
@@ -2362,7 +2379,10 @@ const getIndexFromTarget = (state, targetName) => {
|
|
|
2362
2379
|
if (!targetName) {
|
|
2363
2380
|
return -1;
|
|
2364
2381
|
}
|
|
2365
|
-
|
|
2382
|
+
const {
|
|
2383
|
+
filteredItems
|
|
2384
|
+
} = state;
|
|
2385
|
+
return filteredItems.findIndex(item => item.id === targetName);
|
|
2366
2386
|
};
|
|
2367
2387
|
const handleClick = async (state, button, eventX, eventY, targetName = '') => {
|
|
2368
2388
|
const {
|
|
@@ -2524,9 +2544,10 @@ const handleExtensionsChanged = async state => {
|
|
|
2524
2544
|
const {
|
|
2525
2545
|
height,
|
|
2526
2546
|
itemHeight,
|
|
2547
|
+
platform,
|
|
2527
2548
|
selectedIndex
|
|
2528
2549
|
} = state;
|
|
2529
|
-
const contributedViews = await getContributedViews(
|
|
2550
|
+
const contributedViews = await getContributedViews(platform);
|
|
2530
2551
|
const items = getActivityBarItems(state, contributedViews);
|
|
2531
2552
|
const itemsWithSelected = markSelected(items, selectedIndex);
|
|
2532
2553
|
const activityBarItems = await updateItemsWithBadgeCount(itemsWithSelected);
|
|
@@ -2586,11 +2607,13 @@ const getSideBarPosition = async () => {
|
|
|
2586
2607
|
|
|
2587
2608
|
const handleSettingsChanged = async state => {
|
|
2588
2609
|
const {
|
|
2610
|
+
accountEnabled: currentAccountEnabled,
|
|
2589
2611
|
height,
|
|
2590
2612
|
itemHeight,
|
|
2613
|
+
platform,
|
|
2591
2614
|
selectedIndex
|
|
2592
2615
|
} = state;
|
|
2593
|
-
const [accountEnabled, contributedViews, sidebarLocation] = await Promise.all([getAccountEnabled(
|
|
2616
|
+
const [accountEnabled, contributedViews, sidebarLocation] = await Promise.all([getAccountEnabled(currentAccountEnabled), getContributedViews(platform), getSideBarPosition()]);
|
|
2594
2617
|
const newState = {
|
|
2595
2618
|
...state,
|
|
2596
2619
|
accountEnabled
|
|
@@ -2620,12 +2643,14 @@ const clearItem = item => {
|
|
|
2620
2643
|
const withoutSelected = setFlag(item, Selected, false);
|
|
2621
2644
|
return setFlag(withoutSelected, Focused, false);
|
|
2622
2645
|
};
|
|
2623
|
-
const handleSideBarStateChange = async (state, id
|
|
2646
|
+
const handleSideBarStateChange = async (state, id, sideBarVisibleOverride) => {
|
|
2624
2647
|
const {
|
|
2625
2648
|
activityBarItems,
|
|
2649
|
+
currentViewletId,
|
|
2626
2650
|
height,
|
|
2627
2651
|
itemHeight
|
|
2628
2652
|
} = state;
|
|
2653
|
+
const resolvedId = id === undefined ? currentViewletId : id;
|
|
2629
2654
|
const sideBarVisible = typeof sideBarVisibleOverride === 'boolean' ? sideBarVisibleOverride : await getSideBarVisible();
|
|
2630
2655
|
if (!sideBarVisible) {
|
|
2631
2656
|
const itemsCleared = activityBarItems.map(clearItem);
|
|
@@ -2639,13 +2664,13 @@ const handleSideBarStateChange = async (state, id = state.currentViewletId, side
|
|
|
2639
2664
|
sideBarVisible: false
|
|
2640
2665
|
};
|
|
2641
2666
|
}
|
|
2642
|
-
const selectedIndex = findIndex(activityBarItems,
|
|
2667
|
+
const selectedIndex = findIndex(activityBarItems, resolvedId);
|
|
2643
2668
|
const newActivityBarItems = markSelected(activityBarItems, selectedIndex);
|
|
2644
2669
|
const filteredItems = getFilteredActivityBarItems(newActivityBarItems, height, itemHeight);
|
|
2645
2670
|
return {
|
|
2646
2671
|
...state,
|
|
2647
2672
|
activityBarItems: newActivityBarItems,
|
|
2648
|
-
currentViewletId:
|
|
2673
|
+
currentViewletId: resolvedId,
|
|
2649
2674
|
filteredItems,
|
|
2650
2675
|
selectedIndex,
|
|
2651
2676
|
sideBarVisible
|
|
@@ -3215,7 +3240,6 @@ const getActivityBarItemInProgressDom = item => {
|
|
|
3215
3240
|
className += ' ' + ActivityBarItemNested;
|
|
3216
3241
|
return [{
|
|
3217
3242
|
ariaHasPopup,
|
|
3218
|
-
ariaLabel: '',
|
|
3219
3243
|
ariaSelected,
|
|
3220
3244
|
childCount: 2,
|
|
3221
3245
|
className,
|
|
@@ -3252,7 +3276,6 @@ const getActivityBarItemWithBadgeDom = item => {
|
|
|
3252
3276
|
className += ' ' + ActivityBarItemNested;
|
|
3253
3277
|
return [{
|
|
3254
3278
|
ariaHasPopup,
|
|
3255
|
-
ariaLabel: '',
|
|
3256
3279
|
ariaSelected,
|
|
3257
3280
|
childCount: 2,
|
|
3258
3281
|
className,
|
|
@@ -3303,7 +3326,6 @@ const getActivityBarItemVirtualDom = item => {
|
|
|
3303
3326
|
if (isSelected && !badgeText) {
|
|
3304
3327
|
return [{
|
|
3305
3328
|
ariaHasPopup,
|
|
3306
|
-
ariaLabel: '',
|
|
3307
3329
|
ariaSelected,
|
|
3308
3330
|
childCount: 1,
|
|
3309
3331
|
className,
|
|
@@ -3326,7 +3348,6 @@ const getActivityBarItemVirtualDom = item => {
|
|
|
3326
3348
|
}
|
|
3327
3349
|
return [{
|
|
3328
3350
|
ariaHasPopup,
|
|
3329
|
-
ariaLabel: '',
|
|
3330
3351
|
ariaSelected,
|
|
3331
3352
|
childCount: 0,
|
|
3332
3353
|
className: mergeClassNames(className, getIconClass(item, 'Icon')),
|
|
@@ -3342,6 +3363,8 @@ const getVirtualDom = visibleItems => {
|
|
|
3342
3363
|
return dom;
|
|
3343
3364
|
};
|
|
3344
3365
|
|
|
3366
|
+
const Focusable = 0;
|
|
3367
|
+
|
|
3345
3368
|
const className = mergeClassNames(Viewlet, ActivityBar$1);
|
|
3346
3369
|
const getActivityBarVirtualDom = visibleItems => {
|
|
3347
3370
|
return [{
|
|
@@ -3355,7 +3378,7 @@ const getActivityBarVirtualDom = visibleItems => {
|
|
|
3355
3378
|
onFocus: HandleFocus,
|
|
3356
3379
|
onMouseDown: HandleMouseDown,
|
|
3357
3380
|
role: ToolBar,
|
|
3358
|
-
tabIndex:
|
|
3381
|
+
tabIndex: Focusable,
|
|
3359
3382
|
type: Div
|
|
3360
3383
|
}, ...getVirtualDom(visibleItems)];
|
|
3361
3384
|
};
|
|
@@ -3373,7 +3396,15 @@ const renderItems = (oldState, newState) => {
|
|
|
3373
3396
|
return [SetDom2, uid, dom];
|
|
3374
3397
|
};
|
|
3375
3398
|
|
|
3399
|
+
const hasSameItemIds = (oldState, newState) => {
|
|
3400
|
+
const oldItems = oldState.filteredItems;
|
|
3401
|
+
const newItems = newState.filteredItems;
|
|
3402
|
+
return oldItems.length === newItems.length && oldItems.every((item, index) => item.id === newItems[index].id);
|
|
3403
|
+
};
|
|
3376
3404
|
const renderIncremental = (oldState, newState) => {
|
|
3405
|
+
if (!hasSameItemIds(oldState, newState)) {
|
|
3406
|
+
return renderItems(oldState, newState);
|
|
3407
|
+
}
|
|
3377
3408
|
const oldDom = renderItems(oldState, oldState)[2];
|
|
3378
3409
|
const newDom = renderItems(newState, newState)[2];
|
|
3379
3410
|
const patches = diffTree(oldDom, newDom);
|