@lvce-editor/activity-bar-worker 7.11.0 → 7.12.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.
@@ -3132,17 +3132,14 @@ const diffTrees = (oldTree, newTree, patches, path) => {
3132
3132
  };
3133
3133
 
3134
3134
  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];
3135
+ while (patches.length > 0) {
3136
+ const patch = patches.at(-1);
3139
3137
  if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
3140
- lastNonNavigationIndex = i;
3141
3138
  break;
3142
3139
  }
3140
+ patches.pop();
3143
3141
  }
3144
- // Return patches up to and including the last non-navigation patch
3145
- return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
3142
+ return patches;
3146
3143
  };
3147
3144
 
3148
3145
  const diffTree = (oldNodes, newNodes) => {
@@ -3189,20 +3186,21 @@ const getAriaSelected = (isTab, isSelected) => {
3189
3186
  return Boolean(isSelected);
3190
3187
  };
3191
3188
 
3189
+ const badgeVirtualDom = [{
3190
+ childCount: 1,
3191
+ className: ActivityBarItemBadge,
3192
+ type: Div
3193
+ }, {
3194
+ childCount: 1,
3195
+ className: BadgeContent,
3196
+ type: Div
3197
+ }, {
3198
+ childCount: 0,
3199
+ className: mergeClassNames(Icon, ActivityBarBadgeIcon, MaskIconProgress),
3200
+ type: Div
3201
+ }];
3192
3202
  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
- }];
3203
+ return badgeVirtualDom;
3206
3204
  };
3207
3205
 
3208
3206
  const getClassName = (isFocused, marginTop, isSelected) => {
@@ -3238,8 +3236,7 @@ const getActivityBarItemInProgressDom = item => {
3238
3236
  const ariaSelected = getAriaSelected(isTab, isSelected);
3239
3237
  const ariaHasPopup = getActivityBarItemHasPopup(item) || undefined;
3240
3238
  const marginTop = flags & MarginTop;
3241
- let className = getClassName(isFocused, marginTop, isSelected);
3242
- className += ' ' + ActivityBarItemNested;
3239
+ const className = mergeClassNames(getClassName(isFocused, marginTop, isSelected), ActivityBarItemNested);
3243
3240
  return [{
3244
3241
  ariaHasPopup,
3245
3242
  ariaSelected,
@@ -3274,8 +3271,7 @@ const getActivityBarItemWithBadgeDom = item => {
3274
3271
  const ariaSelected = getAriaSelected(isTab, isSelected);
3275
3272
  const ariaHasPopup = getActivityBarItemHasPopup(item) || undefined;
3276
3273
  const marginTop = flags & MarginTop;
3277
- let className = getClassName(isFocused, marginTop, isSelected);
3278
- className += ' ' + ActivityBarItemNested;
3274
+ const className = mergeClassNames(getClassName(isFocused, marginTop, isSelected), ActivityBarItemNested);
3279
3275
  return [{
3280
3276
  ariaHasPopup,
3281
3277
  ariaSelected,
@@ -3472,6 +3468,69 @@ const renderEventListeners = () => {
3472
3468
  }];
3473
3469
  };
3474
3470
 
3471
+ const createDefaultState = () => ({
3472
+ accountEnabled: true,
3473
+ activityBarItems: [],
3474
+ currentViewletId: '',
3475
+ filteredItems: [],
3476
+ focus: 0,
3477
+ focused: false,
3478
+ focusedIndex: 0,
3479
+ height: 400,
3480
+ initial: true,
3481
+ itemHeight: 48,
3482
+ numberOfVisibleItems: 0,
3483
+ platform: 0,
3484
+ scrollBarHeight: 0,
3485
+ selectedIndex: -1,
3486
+ sideBarLocation: 0,
3487
+ sideBarVisible: false,
3488
+ uid: 0,
3489
+ updateProgress: 0,
3490
+ updateState: '',
3491
+ userLoginProvider: 'Lvce Editor',
3492
+ userLoginState: 'logged out',
3493
+ userName: '',
3494
+ width: 48,
3495
+ x: 0,
3496
+ y: 0
3497
+ });
3498
+
3499
+ const createResetState = state => {
3500
+ const {
3501
+ accountEnabled,
3502
+ height,
3503
+ itemHeight,
3504
+ platform,
3505
+ uid,
3506
+ userLoginProvider,
3507
+ userLoginState,
3508
+ userName,
3509
+ width,
3510
+ x,
3511
+ y
3512
+ } = state;
3513
+ return {
3514
+ ...createDefaultState(),
3515
+ accountEnabled,
3516
+ focusedIndex: -1,
3517
+ height,
3518
+ itemHeight,
3519
+ platform,
3520
+ uid,
3521
+ userLoginProvider,
3522
+ userLoginState,
3523
+ userName,
3524
+ width,
3525
+ x,
3526
+ y
3527
+ };
3528
+ };
3529
+ const reset = async state => {
3530
+ const resetState = createResetState(state);
3531
+ return loadContent(resetState);
3532
+ };
3533
+
3475
3534
  const saveState = state => {
3476
3535
  return {};
3477
3536
  };
@@ -3620,6 +3679,7 @@ const commandMap = {
3620
3679
  'ActivityBar.loadContent': wrapCommand(loadContent),
3621
3680
  'ActivityBar.render2': render2,
3622
3681
  'ActivityBar.renderEventListeners': renderEventListeners,
3682
+ 'ActivityBar.reset': wrapCommand(reset),
3623
3683
  'ActivityBar.resize': wrapCommand(handleResize),
3624
3684
  'ActivityBar.saveState': wrapGetter(saveState),
3625
3685
  '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.12.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",