@lvce-editor/activity-bar-worker 7.11.0 → 7.13.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.
@@ -305,7 +305,7 @@ const isEqual$1 = (oldState, newState) => {
305
305
  };
306
306
 
307
307
  const isEqual = (oldState, newState) => {
308
- return oldState.activityBarItems === newState.activityBarItems && oldState.filteredItems === newState.filteredItems && oldState.focusedIndex === newState.focusedIndex && oldState.sideBarLocation === newState.sideBarLocation && oldState.sideBarVisible === newState.sideBarVisible && oldState.updateProgress === newState.updateProgress && oldState.updateState === newState.updateState;
308
+ return oldState.activityBarItems === newState.activityBarItems && oldState.filteredItems === newState.filteredItems && oldState.focused === newState.focused && oldState.focusedIndex === newState.focusedIndex && oldState.sideBarLocation === newState.sideBarLocation && oldState.sideBarVisible === newState.sideBarVisible && oldState.updateProgress === newState.updateProgress && oldState.updateState === newState.updateState;
309
309
  };
310
310
 
311
311
  const RenderItems = 4;
@@ -2406,19 +2406,24 @@ const handleClickIndex = async (state, button, index, x, y) => {
2406
2406
  return state;
2407
2407
  }
2408
2408
  const {
2409
- filteredItems
2409
+ filteredItems,
2410
+ focused
2410
2411
  } = state;
2412
+ const clickState = focused ? {
2413
+ ...state,
2414
+ focused: false
2415
+ } : state;
2411
2416
  const item = filteredItems[index];
2412
2417
  const viewletId = item.id;
2413
2418
  switch (viewletId) {
2414
2419
  case 'Account':
2415
- return handleClickAccount(state, x, y);
2420
+ return handleClickAccount(clickState, x, y);
2416
2421
  case 'Additional Views':
2417
- return handleClickAdditionalViews(state, x, y, viewletId);
2422
+ return handleClickAdditionalViews(clickState, x, y, viewletId);
2418
2423
  case 'Settings':
2419
- return handleClickSettings(state, x, y);
2424
+ return handleClickSettings(clickState, x, y);
2420
2425
  default:
2421
- return handleClickOther(state, viewletId);
2426
+ return handleClickOther(clickState, viewletId);
2422
2427
  }
2423
2428
  };
2424
2429
 
@@ -3132,17 +3137,14 @@ const diffTrees = (oldTree, newTree, patches, path) => {
3132
3137
  };
3133
3138
 
3134
3139
  const removeTrailingNavigationPatches = patches => {
3135
- // Find the last non-navigation patch
3136
- let lastNonNavigationIndex = -1;
3137
- for (let i = patches.length - 1; i >= 0; i--) {
3138
- const patch = patches[i];
3140
+ while (patches.length > 0) {
3141
+ const patch = patches.at(-1);
3139
3142
  if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
3140
- lastNonNavigationIndex = i;
3141
3143
  break;
3142
3144
  }
3145
+ patches.pop();
3143
3146
  }
3144
- // Return patches up to and including the last non-navigation patch
3145
- return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
3147
+ return patches;
3146
3148
  };
3147
3149
 
3148
3150
  const diffTree = (oldNodes, newNodes) => {
@@ -3189,20 +3191,21 @@ const getAriaSelected = (isTab, isSelected) => {
3189
3191
  return Boolean(isSelected);
3190
3192
  };
3191
3193
 
3194
+ const badgeVirtualDom = [{
3195
+ childCount: 1,
3196
+ className: ActivityBarItemBadge,
3197
+ type: Div
3198
+ }, {
3199
+ childCount: 1,
3200
+ className: BadgeContent,
3201
+ type: Div
3202
+ }, {
3203
+ childCount: 0,
3204
+ className: mergeClassNames(Icon, ActivityBarBadgeIcon, MaskIconProgress),
3205
+ type: Div
3206
+ }];
3192
3207
  const getBadgeVirtualDom = () => {
3193
- return [{
3194
- childCount: 1,
3195
- className: ActivityBarItemBadge,
3196
- type: Div
3197
- }, {
3198
- childCount: 1,
3199
- className: BadgeContent,
3200
- type: Div
3201
- }, {
3202
- childCount: 0,
3203
- className: mergeClassNames(Icon, ActivityBarBadgeIcon, MaskIconProgress),
3204
- type: Div
3205
- }];
3208
+ return badgeVirtualDom;
3206
3209
  };
3207
3210
 
3208
3211
  const getClassName = (isFocused, marginTop, isSelected) => {
@@ -3238,8 +3241,7 @@ const getActivityBarItemInProgressDom = item => {
3238
3241
  const ariaSelected = getAriaSelected(isTab, isSelected);
3239
3242
  const ariaHasPopup = getActivityBarItemHasPopup(item) || undefined;
3240
3243
  const marginTop = flags & MarginTop;
3241
- let className = getClassName(isFocused, marginTop, isSelected);
3242
- className += ' ' + ActivityBarItemNested;
3244
+ const className = mergeClassNames(getClassName(isFocused, marginTop, isSelected), ActivityBarItemNested);
3243
3245
  return [{
3244
3246
  ariaHasPopup,
3245
3247
  ariaSelected,
@@ -3274,8 +3276,7 @@ const getActivityBarItemWithBadgeDom = item => {
3274
3276
  const ariaSelected = getAriaSelected(isTab, isSelected);
3275
3277
  const ariaHasPopup = getActivityBarItemHasPopup(item) || undefined;
3276
3278
  const marginTop = flags & MarginTop;
3277
- let className = getClassName(isFocused, marginTop, isSelected);
3278
- className += ' ' + ActivityBarItemNested;
3279
+ const className = mergeClassNames(getClassName(isFocused, marginTop, isSelected), ActivityBarItemNested);
3279
3280
  return [{
3280
3281
  ariaHasPopup,
3281
3282
  ariaSelected,
@@ -3392,6 +3393,7 @@ const getVisibleActivityBarItems = (items, focusedIndex) => {
3392
3393
  const renderItems = (oldState, newState) => {
3393
3394
  const {
3394
3395
  filteredItems,
3396
+ focused,
3395
3397
  focusedIndex,
3396
3398
  initial,
3397
3399
  uid
@@ -3399,7 +3401,7 @@ const renderItems = (oldState, newState) => {
3399
3401
  if (initial) {
3400
3402
  return [SetDom2, uid, []];
3401
3403
  }
3402
- const visibleItems = getVisibleActivityBarItems(filteredItems, focusedIndex);
3404
+ const visibleItems = getVisibleActivityBarItems(filteredItems, focused ? focusedIndex : -1);
3403
3405
  const dom = getActivityBarVirtualDom(visibleItems);
3404
3406
  return [SetDom2, uid, dom];
3405
3407
  };
@@ -3472,6 +3474,69 @@ const renderEventListeners = () => {
3472
3474
  }];
3473
3475
  };
3474
3476
 
3477
+ const createDefaultState = () => ({
3478
+ accountEnabled: true,
3479
+ activityBarItems: [],
3480
+ currentViewletId: '',
3481
+ filteredItems: [],
3482
+ focus: 0,
3483
+ focused: false,
3484
+ focusedIndex: 0,
3485
+ height: 400,
3486
+ initial: true,
3487
+ itemHeight: 48,
3488
+ numberOfVisibleItems: 0,
3489
+ platform: 0,
3490
+ scrollBarHeight: 0,
3491
+ selectedIndex: -1,
3492
+ sideBarLocation: 0,
3493
+ sideBarVisible: false,
3494
+ uid: 0,
3495
+ updateProgress: 0,
3496
+ updateState: '',
3497
+ userLoginProvider: 'Lvce Editor',
3498
+ userLoginState: 'logged out',
3499
+ userName: '',
3500
+ width: 48,
3501
+ x: 0,
3502
+ y: 0
3503
+ });
3504
+
3505
+ const createResetState = state => {
3506
+ const {
3507
+ accountEnabled,
3508
+ height,
3509
+ itemHeight,
3510
+ platform,
3511
+ uid,
3512
+ userLoginProvider,
3513
+ userLoginState,
3514
+ userName,
3515
+ width,
3516
+ x,
3517
+ y
3518
+ } = state;
3519
+ return {
3520
+ ...createDefaultState(),
3521
+ accountEnabled,
3522
+ focusedIndex: -1,
3523
+ height,
3524
+ itemHeight,
3525
+ platform,
3526
+ uid,
3527
+ userLoginProvider,
3528
+ userLoginState,
3529
+ userName,
3530
+ width,
3531
+ x,
3532
+ y
3533
+ };
3534
+ };
3535
+ const reset = async state => {
3536
+ const resetState = createResetState(state);
3537
+ return loadContent(resetState);
3538
+ };
3539
+
3475
3540
  const saveState = state => {
3476
3541
  return {};
3477
3542
  };
@@ -3620,6 +3685,7 @@ const commandMap = {
3620
3685
  'ActivityBar.loadContent': wrapCommand(loadContent),
3621
3686
  'ActivityBar.render2': render2,
3622
3687
  'ActivityBar.renderEventListeners': renderEventListeners,
3688
+ 'ActivityBar.reset': wrapCommand(reset),
3623
3689
  'ActivityBar.resize': wrapCommand(handleResize),
3624
3690
  'ActivityBar.saveState': wrapGetter(saveState),
3625
3691
  'ActivityBar.selectCurrent': wrapCommand(selectCurrent),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/activity-bar-worker",
3
- "version": "7.11.0",
3
+ "version": "7.13.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",