@lvce-editor/explorer-view 3.18.0 → 3.19.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.
@@ -2641,6 +2641,183 @@ const copyRelativePath = async state => {
2641
2641
  return state;
2642
2642
  };
2643
2643
 
2644
+ const None$4 = 0;
2645
+ const Right = 1;
2646
+ const Down = 2;
2647
+
2648
+ const getChevronType = (type, useChevrons) => {
2649
+ if (!useChevrons) {
2650
+ return None$4;
2651
+ }
2652
+ switch (type) {
2653
+ case Directory:
2654
+ return Right;
2655
+ case DirectoryExpanded:
2656
+ case DirectoryExpanding:
2657
+ return Down;
2658
+ default:
2659
+ return None$4;
2660
+ }
2661
+ };
2662
+
2663
+ const None$3 = 0;
2664
+ const Expanded = 1;
2665
+ const Collapsed = 2;
2666
+
2667
+ const getExpandedType = type => {
2668
+ switch (type) {
2669
+ case Directory:
2670
+ return Collapsed;
2671
+ case DirectoryExpanding:
2672
+ case DirectoryExpanded:
2673
+ return Expanded;
2674
+ default:
2675
+ return None$3;
2676
+ }
2677
+ };
2678
+
2679
+ // 0 = 'Button'
2680
+ // 1 = 'IconButton'
2681
+ // 2 = 'Button IconButton'
2682
+ // it could make dom diffing faster, since for classname,
2683
+ // once at start, send all classnames to renderer process
2684
+ // only numbers are compared. it could also make rendering faster,
2685
+ // representing the concatenated strings for example
2686
+ // since less data is transferred to renderer process
2687
+ // then, components uses numeric classname
2688
+ // TODO add option to make classnames numeric
2689
+ // when a component uses multiple classnames, it is a new number
2690
+ const Actions = 'Actions';
2691
+ const Button$2 = 'Button';
2692
+ const ButtonNarrow = 'ButtonNarrow';
2693
+ const ButtonPrimary = 'ButtonPrimary';
2694
+ const ButtonWide = 'ButtonWide';
2695
+ const Chevron = 'Chevron';
2696
+ const Empty = '';
2697
+ const Explorer$1 = 'Explorer';
2698
+ const ExplorerDropTarget = 'DropTarget';
2699
+ const ExplorerErrorMessage = 'ExplorerErrorMessage';
2700
+ const ExplorerInputBox = 'ExplorerInputBox';
2701
+ const FileIcon = 'FileIcon';
2702
+ const FocusOutline = 'FocusOutline';
2703
+ const IconButton = 'IconButton';
2704
+ const InputValidationError = 'InputValidationError';
2705
+ const Label = 'Label';
2706
+ const LabelCut = 'LabelCut';
2707
+ const ListItems = 'ListItems';
2708
+ const MaskIconChevronDown = 'MaskIconChevronDown';
2709
+ const MaskIconChevronRight = 'MaskIconChevronRight';
2710
+ const ScrollBar = 'ScrollBar';
2711
+ const ScrollBarSmall = 'ScrollBarSmall';
2712
+ const ScrollBarThumb = 'ScrollBarThumb';
2713
+ const TreeItem$1 = 'TreeItem';
2714
+ const TreeItemActive = 'TreeItemActive';
2715
+ const Viewlet = 'Viewlet';
2716
+ const Welcome = 'Welcome';
2717
+ const WelcomeMessage = 'WelcomeMessage';
2718
+
2719
+ const mergeClassNames = (...classNames) => {
2720
+ return classNames.filter(Boolean).join(' ');
2721
+ };
2722
+
2723
+ const px = value => {
2724
+ return `${value}px`;
2725
+ };
2726
+ const position = (x, y) => {
2727
+ return `${x}px ${y}px`;
2728
+ };
2729
+
2730
+ const text = data => {
2731
+ return {
2732
+ type: Text,
2733
+ text: data,
2734
+ childCount: 0
2735
+ };
2736
+ };
2737
+
2738
+ const getTreeItemClassName = (isSelected, isFocused, isDropping, useChevrons, depth) => {
2739
+ let className = TreeItem$1;
2740
+ className = mergeClassNames(className, `Indent-${depth}`);
2741
+ if (isSelected || isFocused) {
2742
+ className = mergeClassNames(className, TreeItemActive);
2743
+ }
2744
+ if (isDropping) {
2745
+ className = mergeClassNames(className, 'DropTarget');
2746
+ }
2747
+ return className;
2748
+ };
2749
+
2750
+ const defaultIndent$1 = 1;
2751
+ const getTreeItemIndent = depth => {
2752
+ return `${depth * defaultIndent$1}rem`;
2753
+ };
2754
+
2755
+ // TODO make all of these variable configurable
2756
+ const defaultPaddingLeft = 4;
2757
+ const defaultIndent = 8;
2758
+
2759
+ // TODO make chevron size configurable
2760
+ const chevronSize = 22;
2761
+ const getTreeItemIndentWithChevron = (depth, chevron) => {
2762
+ // TODO use numeric value here, convert to string value in renderer process
2763
+ const extraSpace = chevron ? 0 : chevronSize;
2764
+ return `${depth * defaultIndent + extraSpace + defaultPaddingLeft}px`;
2765
+ };
2766
+
2767
+ const ariaExpandedValues = [undefined, 'true', 'false'];
2768
+ const getEditingChevron = direntType => {
2769
+ switch (direntType) {
2770
+ case EditingDirectoryExpanded:
2771
+ return Down;
2772
+ case EditingFolder:
2773
+ return Right;
2774
+ default:
2775
+ return None$4;
2776
+ }
2777
+ };
2778
+ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris = []) => {
2779
+ const visible = [];
2780
+ const indentFn = useChevrons ? getTreeItemIndentWithChevron : getTreeItemIndent;
2781
+ let iconIndex = 0;
2782
+ for (let i = minLineY; i < Math.min(maxLineY, items.length); i++) {
2783
+ const item = items[i];
2784
+ let chevron = getChevronType(item.type, useChevrons);
2785
+ const isFocused = i === focusedIndex;
2786
+ const id = isFocused ? 'TreeItemActive' : undefined;
2787
+ const isSelected = item.selected;
2788
+ const isCut = cutItems.includes(item.path);
2789
+ const isDropping = dropTargets.includes(i);
2790
+ const isIgnored = sourceControlIgnoredUris.includes(item.path);
2791
+ const className = getTreeItemClassName(isSelected, isFocused, isDropping, useChevrons, item.depth); // TODO compute classname in dom function
2792
+ const expanded = getExpandedType(item.type);
2793
+ const ariaExpanded = ariaExpandedValues[expanded];
2794
+ const isEditing = i === editingIndex;
2795
+ let icon = icons[iconIndex++];
2796
+ if (isEditing) {
2797
+ icon = editingIcon;
2798
+ chevron = getEditingChevron(item.type);
2799
+ }
2800
+ const indent = indentFn(item.depth, chevron);
2801
+ visible.push({
2802
+ ...item,
2803
+ posInSet: item.posInSet ?? i + 1,
2804
+ setSize: item.setSize ?? items.length,
2805
+ isEditing: isEditing,
2806
+ hasEditingError: isEditing && Boolean(editingErrorMessage),
2807
+ icon,
2808
+ indent,
2809
+ ariaExpanded,
2810
+ chevron,
2811
+ id,
2812
+ className,
2813
+ isCut,
2814
+ isIgnored,
2815
+ index: i
2816
+ });
2817
+ }
2818
+ return visible;
2819
+ };
2820
+
2644
2821
  const {
2645
2822
  get,
2646
2823
  set,
@@ -2702,7 +2879,10 @@ const create2 = (uid, uri, x, y, width, height, args, parentUid, platform = 0) =
2702
2879
  isPointerDown: false,
2703
2880
  pointerDownIndex: -1,
2704
2881
  sourceControlIgnoredUris: [],
2705
- maxIndent: 0
2882
+ maxIndent: 0,
2883
+ errorMessageLeft: 0,
2884
+ errorMessageTop: 0,
2885
+ visibleExplorerItems: []
2706
2886
  };
2707
2887
  set(uid, state, state);
2708
2888
  };
@@ -2755,14 +2935,17 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
2755
2935
  isPointerDown: false,
2756
2936
  pointerDownIndex: -1,
2757
2937
  sourceControlIgnoredUris: [],
2758
- maxIndent: 0
2938
+ maxIndent: 0,
2939
+ errorMessageLeft: 0,
2940
+ errorMessageTop: 0,
2941
+ visibleExplorerItems: []
2759
2942
  };
2760
2943
  set(state.uid, state, state);
2761
2944
  return state;
2762
2945
  };
2763
2946
 
2764
2947
  const isEqual$6 = (oldState, newState) => {
2765
- return oldState.scrollBarHeight === newState.scrollBarHeight && oldState.scrollBarActive === newState.scrollBarActive;
2948
+ return oldState.scrollBarHeight === newState.scrollBarHeight && oldState.scrollBarActive === newState.scrollBarActive && oldState.maxIndent === newState.maxIndent;
2766
2949
  };
2767
2950
 
2768
2951
  const isEqual$5 = (oldState, newState) => {
@@ -2774,7 +2957,7 @@ const isEqual$4 = (oldState, newState) => {
2774
2957
  };
2775
2958
 
2776
2959
  const isEqual$3 = (oldState, newState) => {
2777
- return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex && oldState.editingIndex === newState.editingIndex && oldState.editingType === newState.editingType && oldState.editingValue === newState.editingValue && oldState.editingErrorMessage === newState.editingErrorMessage && oldState.width === newState.width && oldState.focused === newState.focused && oldState.dropTargets === newState.dropTargets && oldState.icons === newState.icons && oldState.cutItems === newState.cutItems;
2960
+ return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex && oldState.editingIndex === newState.editingIndex && oldState.editingType === newState.editingType && oldState.editingValue === newState.editingValue && oldState.editingErrorMessage === newState.editingErrorMessage && oldState.width === newState.width && oldState.focused === newState.focused && oldState.dropTargets === newState.dropTargets && oldState.icons === newState.icons && oldState.cutItems === newState.cutItems && oldState.visibleExplorerItems === newState.visibleExplorerItems;
2778
2961
  };
2779
2962
 
2780
2963
  const isEqual$2 = (oldState, newState) => {
@@ -3099,25 +3282,6 @@ const focusPrevious = state => {
3099
3282
  }
3100
3283
  };
3101
3284
 
3102
- const mergeClassNames = (...classNames) => {
3103
- return classNames.filter(Boolean).join(' ');
3104
- };
3105
-
3106
- const px = value => {
3107
- return `${value}px`;
3108
- };
3109
- const position = (x, y) => {
3110
- return `${x}px ${y}px`;
3111
- };
3112
-
3113
- const text = data => {
3114
- return {
3115
- type: Text,
3116
- text: data,
3117
- childCount: 0
3118
- };
3119
- };
3120
-
3121
3285
  const getKeyBindings = () => {
3122
3286
  return [{
3123
3287
  key: Shift | UpArrow,
@@ -3215,7 +3379,7 @@ const getKeyBindings = () => {
3215
3379
  };
3216
3380
 
3217
3381
  const Separator = 1;
3218
- const None$4 = 0;
3382
+ const None$2 = 0;
3219
3383
  const RestoreFocus = 6;
3220
3384
 
3221
3385
  const menuEntrySeparator = {
@@ -3228,13 +3392,13 @@ const menuEntrySeparator = {
3228
3392
  const menuEntryNewFile = {
3229
3393
  id: 'newFile',
3230
3394
  label: newFile$1(),
3231
- flags: None$4,
3395
+ flags: None$2,
3232
3396
  command: 'Explorer.newFile'
3233
3397
  };
3234
3398
  const menuEntryNewFolder = {
3235
3399
  id: 'newFolder',
3236
3400
  label: newFolder$1(),
3237
- flags: None$4,
3401
+ flags: None$2,
3238
3402
  command: 'Explorer.newFolder'
3239
3403
  };
3240
3404
  const menuEntryOpenContainingFolder = {
@@ -3246,7 +3410,7 @@ const menuEntryOpenContainingFolder = {
3246
3410
  const menuEntryOpenInIntegratedTerminal = {
3247
3411
  id: 'openInIntegratedTerminal',
3248
3412
  label: openInIntegratedTerminal(),
3249
- flags: None$4,
3413
+ flags: None$2,
3250
3414
  command: /* TODO */'-1'
3251
3415
  };
3252
3416
  const menuEntryCut = {
@@ -3264,7 +3428,7 @@ const menuEntryCopy = {
3264
3428
  const menuEntryPaste = {
3265
3429
  id: 'paste',
3266
3430
  label: paste(),
3267
- flags: None$4,
3431
+ flags: None$2,
3268
3432
  command: 'Explorer.handlePaste'
3269
3433
  };
3270
3434
  const menuEntryCopyPath = {
@@ -3282,13 +3446,13 @@ const menuEntryCopyRelativePath = {
3282
3446
  const menuEntryRename = {
3283
3447
  id: 'rename',
3284
3448
  label: rename(),
3285
- flags: None$4,
3449
+ flags: None$2,
3286
3450
  command: 'Explorer.renameDirent'
3287
3451
  };
3288
3452
  const menuEntryDelete = {
3289
3453
  id: 'delete',
3290
3454
  label: deleteItem(),
3291
- flags: None$4,
3455
+ flags: None$2,
3292
3456
  command: 'Explorer.removeDirent'
3293
3457
  };
3294
3458
  const ALL_ENTRIES = [menuEntryNewFile, menuEntryNewFolder, menuEntryOpenContainingFolder, menuEntryOpenInIntegratedTerminal, menuEntrySeparator, menuEntryCut, menuEntryCopy, menuEntryPaste, menuEntrySeparator, menuEntryCopyPath, menuEntryCopyRelativePath, menuEntrySeparator, menuEntryRename, menuEntryDelete];
@@ -3387,16 +3551,27 @@ const handleClickDirectoryExpanded = async (state, dirent, index, keepFocus) =>
3387
3551
  minLineY,
3388
3552
  maxLineY,
3389
3553
  itemHeight,
3390
- fileIconCache
3554
+ fileIconCache,
3555
+ cutItems,
3556
+ sourceControlIgnoredUris,
3557
+ dropTargets,
3558
+ editingErrorMessage,
3559
+ editingIcon,
3560
+ editingIndex,
3561
+ editingType,
3562
+ editingValue,
3563
+ focusedIndex,
3564
+ useChevrons,
3565
+ items
3391
3566
  } = state;
3392
3567
  // @ts-ignore
3393
3568
  dirent.type = Directory;
3394
3569
  // @ts-ignore
3395
3570
  dirent.icon = '';
3396
- const endIndex = getParentEndIndex(state.items, index);
3571
+ const endIndex = getParentEndIndex(items, index);
3397
3572
  const removeCount = endIndex - index - 1;
3398
3573
  // TODO race conditions and side effects are everywhere
3399
- const newDirents = [...state.items];
3574
+ const newDirents = [...items];
3400
3575
  newDirents.splice(index + 1, removeCount);
3401
3576
  const newTotal = newDirents.length;
3402
3577
  if (newTotal < maxLineY) {
@@ -3409,30 +3584,34 @@ const handleClickDirectoryExpanded = async (state, dirent, index, keepFocus) =>
3409
3584
  icons,
3410
3585
  newFileIconCache
3411
3586
  } = await getFileIcons(parts, fileIconCache);
3587
+ const visibleExplorerItems = getVisibleExplorerItems(newDirents, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
3412
3588
  return {
3413
3589
  ...state,
3414
- items: newDirents,
3415
- icons,
3590
+ deltaY,
3416
3591
  fileIconCache: newFileIconCache,
3417
- focusedIndex: index,
3418
3592
  focused: keepFocus,
3419
- minLineY: newMinLineY,
3593
+ focusedIndex: index,
3594
+ icons,
3595
+ items: newDirents,
3420
3596
  maxLineY: newMaxLineY,
3421
- deltaY
3597
+ minLineY: newMinLineY,
3598
+ visibleExplorerItems
3422
3599
  };
3423
3600
  }
3424
- const parts = newDirents.slice(state.minLineY, state.maxLineY);
3601
+ const parts = newDirents.slice(minLineY, maxLineY);
3425
3602
  const {
3426
3603
  icons,
3427
3604
  newFileIconCache
3428
3605
  } = await getFileIcons(parts, fileIconCache);
3606
+ const visibleExplorerItems = getVisibleExplorerItems(newDirents, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
3429
3607
  return {
3430
3608
  ...state,
3431
- items: newDirents,
3432
- icons,
3433
3609
  fileIconCache: newFileIconCache,
3610
+ focused: keepFocus,
3434
3611
  focusedIndex: index,
3435
- focused: keepFocus
3612
+ icons,
3613
+ items: newDirents,
3614
+ visibleExplorerItems
3436
3615
  };
3437
3616
  };
3438
3617
 
@@ -3478,6 +3657,18 @@ const setFocus = key => {
3478
3657
  };
3479
3658
 
3480
3659
  const handleClickDirectory = async (state, dirent, index, keepFocus) => {
3660
+ const {
3661
+ cutItems,
3662
+ sourceControlIgnoredUris,
3663
+ dropTargets,
3664
+ editingErrorMessage,
3665
+ editingIcon,
3666
+ editingIndex,
3667
+ editingType,
3668
+ editingValue,
3669
+ focusedIndex,
3670
+ useChevrons
3671
+ } = state;
3481
3672
  // @ts-ignore
3482
3673
  dirent.type = DirectoryExpanding;
3483
3674
  // TODO handle error
@@ -3510,15 +3701,19 @@ const handleClickDirectory = async (state, dirent, index, keepFocus) => {
3510
3701
  icons,
3511
3702
  newFileIconCache
3512
3703
  } = await getFileIcons(parts, state.fileIconCache);
3704
+ const visibleExplorerItems = getVisibleExplorerItems(newDirents, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
3705
+
3706
+ // TODO use functional focus rendering
3513
3707
  await setFocus(FocusExplorer);
3514
3708
  return {
3515
3709
  ...state,
3516
- items: newDirents,
3517
- icons,
3518
3710
  fileIconCache: newFileIconCache,
3519
- focusedIndex: newIndex,
3520
3711
  focused: keepFocus,
3521
- maxLineY
3712
+ focusedIndex: newIndex,
3713
+ icons,
3714
+ items: newDirents,
3715
+ maxLineY,
3716
+ visibleExplorerItems
3522
3717
  };
3523
3718
  };
3524
3719
 
@@ -3828,7 +4023,7 @@ const show = async (x, y, id, ...args) => {
3828
4023
  return showContextMenu(x, y, id, ...args);
3829
4024
  };
3830
4025
 
3831
- const Explorer$1 = 4;
4026
+ const Explorer = 4;
3832
4027
 
3833
4028
  const handleContextMenuKeyboard = async state => {
3834
4029
  const {
@@ -3840,7 +4035,7 @@ const handleContextMenuKeyboard = async state => {
3840
4035
  } = state;
3841
4036
  const menuX = x;
3842
4037
  const menuY = y + (focusedIndex - minLineY + 1) * itemHeight;
3843
- await show(menuX, menuY, Explorer$1);
4038
+ await show(menuX, menuY, Explorer);
3844
4039
  return state;
3845
4040
  };
3846
4041
 
@@ -3854,7 +4049,7 @@ const handleContextMenuMouseAt = async (state, x, y) => {
3854
4049
  focused: false
3855
4050
  };
3856
4051
  set(state.uid, state, newState);
3857
- await show(x, y, Explorer$1);
4052
+ await show(x, y, Explorer);
3858
4053
  return state;
3859
4054
  };
3860
4055
 
@@ -4075,8 +4270,17 @@ const refresh = async state => {
4075
4270
  height,
4076
4271
  itemHeight,
4077
4272
  fileIconCache,
4273
+ cutItems,
4274
+ sourceControlIgnoredUris,
4275
+ dropTargets,
4276
+ editingErrorMessage,
4277
+ editingIcon,
4278
+ editingIndex,
4279
+ editingType,
4280
+ editingValue,
4281
+ focusedIndex,
4078
4282
  items,
4079
- focusedIndex
4283
+ useChevrons
4080
4284
  } = state;
4081
4285
  const expandedDirents = getExpandedDirents(items);
4082
4286
  const expandedPaths = getPaths(expandedDirents);
@@ -4094,13 +4298,15 @@ const refresh = async state => {
4094
4298
  if (focusedIndex >= newItems.length) {
4095
4299
  newFocusedIndex = newItems.length - 1;
4096
4300
  }
4301
+ const visibleExplorerItems = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
4097
4302
  return {
4098
4303
  ...state,
4099
- items: newItems,
4100
4304
  fileIconCache: newFileIconCache,
4305
+ focusedIndex: newFocusedIndex,
4101
4306
  icons,
4307
+ items: newItems,
4102
4308
  maxLineY,
4103
- focusedIndex: newFocusedIndex
4309
+ visibleExplorerItems
4104
4310
  };
4105
4311
  };
4106
4312
 
@@ -4720,7 +4926,7 @@ const handlePasteCut = async (state, nativeFiles) => {
4720
4926
  };
4721
4927
  };
4722
4928
 
4723
- const None$3 = 'none';
4929
+ const None$1 = 'none';
4724
4930
 
4725
4931
  const handlePaste = async state => {
4726
4932
  const nativeFiles = await readNativeFiles();
@@ -4741,7 +4947,7 @@ const handlePaste = async state => {
4741
4947
  // TODO handle error gracefully when copy fails
4742
4948
 
4743
4949
  // If no files to paste, return original state unchanged
4744
- if (nativeFiles.type === None$3) {
4950
+ if (nativeFiles.type === None$1) {
4745
4951
  return state;
4746
4952
  }
4747
4953
 
@@ -4788,7 +4994,17 @@ const handleUpload = async (state, dirents) => {
4788
4994
  const setDeltaY = async (state, deltaY) => {
4789
4995
  const {
4790
4996
  itemHeight,
4997
+ useChevrons,
4791
4998
  height,
4999
+ cutItems,
5000
+ sourceControlIgnoredUris,
5001
+ dropTargets,
5002
+ editingErrorMessage,
5003
+ editingIcon,
5004
+ editingIndex,
5005
+ editingType,
5006
+ editingValue,
5007
+ focusedIndex,
4792
5008
  items
4793
5009
  } = state;
4794
5010
  if (deltaY < 0) {
@@ -4806,13 +5022,15 @@ const setDeltaY = async (state, deltaY) => {
4806
5022
  icons,
4807
5023
  newFileIconCache
4808
5024
  } = await getFileIcons(visible, state.fileIconCache);
5025
+ const visibleExplorerItems = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
4809
5026
  return {
4810
5027
  ...state,
4811
5028
  deltaY,
4812
- minLineY,
4813
- maxLineY,
5029
+ fileIconCache: newFileIconCache,
4814
5030
  icons,
4815
- fileIconCache: newFileIconCache
5031
+ maxLineY,
5032
+ minLineY,
5033
+ visibleExplorerItems
4816
5034
  };
4817
5035
  };
4818
5036
 
@@ -4959,7 +5177,16 @@ const getSavedRoot = (savedState, workspacePath) => {
4959
5177
  };
4960
5178
  const loadContent = async (state, savedState) => {
4961
5179
  const {
4962
- fileIconCache
5180
+ fileIconCache,
5181
+ cutItems,
5182
+ sourceControlIgnoredUris,
5183
+ dropTargets,
5184
+ editingErrorMessage,
5185
+ editingIcon,
5186
+ editingIndex,
5187
+ editingType,
5188
+ editingValue,
5189
+ focusedIndex
4963
5190
  } = state;
4964
5191
  const {
4965
5192
  useChevrons,
@@ -4989,20 +5216,22 @@ const loadContent = async (state, savedState) => {
4989
5216
  icons,
4990
5217
  newFileIconCache
4991
5218
  } = await getFileIcons(visible, fileIconCache);
5219
+ const visibleExplorerItems = getVisibleExplorerItems(restoredDirents, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
4992
5220
  return {
4993
5221
  ...state,
4994
- root,
4995
- items: restoredDirents,
4996
- icons,
4997
- fileIconCache: newFileIconCache,
4998
- minLineY,
5222
+ confirmDelete,
4999
5223
  deltaY,
5224
+ excluded,
5225
+ fileIconCache: newFileIconCache,
5226
+ icons,
5227
+ items: restoredDirents,
5228
+ maxIndent: 10,
5000
5229
  maxLineY,
5230
+ minLineY,
5001
5231
  pathSeparator,
5002
- excluded,
5232
+ root,
5003
5233
  useChevrons,
5004
- confirmDelete,
5005
- maxIndent: 10
5234
+ visibleExplorerItems
5006
5235
  };
5007
5236
  };
5008
5237
 
@@ -5139,13 +5368,20 @@ const newDirent = async (state, editingType) => {
5139
5368
  await setFocus(ExplorerEditBox);
5140
5369
  // TODO do it like vscode, select position between folders and files
5141
5370
  const {
5142
- focusedIndex,
5143
- items,
5144
5371
  minLineY,
5145
5372
  height,
5146
5373
  itemHeight,
5374
+ root,
5147
5375
  fileIconCache,
5148
- root
5376
+ cutItems,
5377
+ sourceControlIgnoredUris,
5378
+ dropTargets,
5379
+ editingErrorMessage,
5380
+ editingIcon,
5381
+ editingValue,
5382
+ focusedIndex,
5383
+ items,
5384
+ useChevrons
5149
5385
  } = state;
5150
5386
  const index = getFittingIndex(items, focusedIndex);
5151
5387
  const direntType = getNewDirentType(editingType);
@@ -5157,17 +5393,19 @@ const newDirent = async (state, editingType) => {
5157
5393
  newFileIconCache
5158
5394
  } = await getFileIcons(visible, fileIconCache);
5159
5395
  const editingIndex = newDirents.findIndex(item => item.type === EditingFile || item.type === EditingFolder);
5396
+ const visibleExplorerItems = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
5160
5397
  return {
5161
5398
  ...state,
5162
- items: newDirents,
5163
5399
  editingIndex,
5164
5400
  editingType,
5165
5401
  editingValue: '',
5166
- focusedIndex: editingIndex,
5402
+ fileIconCache: newFileIconCache,
5167
5403
  focus: Input$1,
5404
+ focusedIndex: editingIndex,
5168
5405
  icons,
5169
- fileIconCache: newFileIconCache,
5170
- maxLineY
5406
+ items: newDirents,
5407
+ maxLineY,
5408
+ visibleExplorerItems
5171
5409
  };
5172
5410
  };
5173
5411
 
@@ -5316,11 +5554,6 @@ const renameDirent = state => {
5316
5554
  };
5317
5555
  };
5318
5556
 
5319
- const defaultIndent$1 = 1;
5320
- const getTreeItemIndent = depth => {
5321
- return `${depth * defaultIndent$1}rem`;
5322
- };
5323
-
5324
5557
  const renderCss = (oldState, newState) => {
5325
5558
  const {
5326
5559
  scrollBarHeight,
@@ -5333,7 +5566,7 @@ const renderCss = (oldState, newState) => {
5333
5566
  for (let i = 0; i < maxIndent; i++) {
5334
5567
  const indent = getTreeItemIndent(i);
5335
5568
  rules.push(`.Indent-${i} {
5336
- padding-left: ${indent}px;
5569
+ padding-left: ${indent};
5337
5570
  }`);
5338
5571
  }
5339
5572
  const css = rules.join('\n');
@@ -5425,50 +5658,10 @@ const getErrorMessagePosition = (itemHeight, focusedIndex, minLineY, depth, inde
5425
5658
  };
5426
5659
  };
5427
5660
 
5428
- const None$2 = 'none';
5661
+ const None = 'none';
5429
5662
  const ToolBar = 'toolbar';
5430
5663
  const Tree = 'tree';
5431
- const TreeItem$1 = 'treeitem';
5432
-
5433
- // 0 = 'Button'
5434
- // 1 = 'IconButton'
5435
- // 2 = 'Button IconButton'
5436
- // it could make dom diffing faster, since for classname,
5437
- // once at start, send all classnames to renderer process
5438
- // only numbers are compared. it could also make rendering faster,
5439
- // representing the concatenated strings for example
5440
- // since less data is transferred to renderer process
5441
- // then, components uses numeric classname
5442
- // TODO add option to make classnames numeric
5443
- // when a component uses multiple classnames, it is a new number
5444
- const Actions = 'Actions';
5445
- const Button$2 = 'Button';
5446
- const ButtonNarrow = 'ButtonNarrow';
5447
- const ButtonPrimary = 'ButtonPrimary';
5448
- const ButtonWide = 'ButtonWide';
5449
- const Chevron = 'Chevron';
5450
- const Empty = '';
5451
- const Explorer = 'Explorer';
5452
- const ExplorerDropTarget = 'DropTarget';
5453
- const ExplorerErrorMessage = 'ExplorerErrorMessage';
5454
- const ExplorerInputBox = 'ExplorerInputBox';
5455
- const FileIcon = 'FileIcon';
5456
- const FocusOutline = 'FocusOutline';
5457
- const IconButton = 'IconButton';
5458
- const InputValidationError = 'InputValidationError';
5459
- const Label = 'Label';
5460
- const LabelCut = 'LabelCut';
5461
- const ListItems = 'ListItems';
5462
- const MaskIconChevronDown = 'MaskIconChevronDown';
5463
- const MaskIconChevronRight = 'MaskIconChevronRight';
5464
- const ScrollBar = 'ScrollBar';
5465
- const ScrollBarSmall = 'ScrollBarSmall';
5466
- const ScrollBarThumb = 'ScrollBarThumb';
5467
- const TreeItem = 'TreeItem';
5468
- const TreeItemActive = 'TreeItemActive';
5469
- const Viewlet = 'Viewlet';
5470
- const Welcome = 'Welcome';
5471
- const WelcomeMessage = 'WelcomeMessage';
5664
+ const TreeItem = 'treeitem';
5472
5665
 
5473
5666
  const Button$1 = 1;
5474
5667
  const Div = 4;
@@ -5507,7 +5700,7 @@ const HandleDragStart = 17;
5507
5700
  const getExplorerWelcomeVirtualDom = isWide => {
5508
5701
  return [{
5509
5702
  type: Div,
5510
- className: mergeClassNames(Viewlet, Explorer),
5703
+ className: mergeClassNames(Viewlet, Explorer$1),
5511
5704
  tabIndex: 0,
5512
5705
  childCount: 1
5513
5706
  }, {
@@ -5549,7 +5742,7 @@ const getFileIconVirtualDom = icon => {
5549
5742
  type: Img,
5550
5743
  className: FileIcon,
5551
5744
  src: icon,
5552
- role: None$2,
5745
+ role: None,
5553
5746
  childCount: 0
5554
5747
  };
5555
5748
  };
@@ -5623,7 +5816,7 @@ const getExplorerItemVirtualDom = item => {
5623
5816
  const chevronDom = getChevronVirtualDom(chevron);
5624
5817
  return [{
5625
5818
  type: Div,
5626
- role: TreeItem$1,
5819
+ role: TreeItem,
5627
5820
  className,
5628
5821
  draggable: true,
5629
5822
  title: path,
@@ -5730,126 +5923,13 @@ const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused
5730
5923
  const parentNode = {
5731
5924
  type: Div,
5732
5925
  childCount,
5733
- className: mergeClassNames(Viewlet, Explorer),
5734
- role: None$2
5926
+ className: mergeClassNames(Viewlet, Explorer$1),
5927
+ role: None
5735
5928
  };
5736
5929
  const dom = [parentNode, ...getListItemsVirtualDom(visibleItems, focusedIndex, focused, dropTargets), ...scrollBarDom, ...errorDom];
5737
5930
  return dom;
5738
5931
  };
5739
5932
 
5740
- const None$1 = 0;
5741
- const Right = 1;
5742
- const Down = 2;
5743
-
5744
- const getChevronType = (type, useChevrons) => {
5745
- if (!useChevrons) {
5746
- return None$1;
5747
- }
5748
- switch (type) {
5749
- case Directory:
5750
- return Right;
5751
- case DirectoryExpanded:
5752
- case DirectoryExpanding:
5753
- return Down;
5754
- default:
5755
- return None$1;
5756
- }
5757
- };
5758
-
5759
- const None = 0;
5760
- const Expanded = 1;
5761
- const Collapsed = 2;
5762
-
5763
- const getExpandedType = type => {
5764
- switch (type) {
5765
- case Directory:
5766
- return Collapsed;
5767
- case DirectoryExpanding:
5768
- case DirectoryExpanded:
5769
- return Expanded;
5770
- default:
5771
- return None;
5772
- }
5773
- };
5774
-
5775
- const getTreeItemClassName = (isSelected, isFocused, isDropping, useChevrons, depth) => {
5776
- let className = TreeItem;
5777
- className = mergeClassNames(className, `Indent-${depth}`);
5778
- if (isSelected || isFocused) {
5779
- className = mergeClassNames(className, TreeItemActive);
5780
- }
5781
- if (isDropping) {
5782
- className = mergeClassNames(className, 'DropTarget');
5783
- }
5784
- return className;
5785
- };
5786
-
5787
- // TODO make all of these variable configurable
5788
- const defaultPaddingLeft = 4;
5789
- const defaultIndent = 8;
5790
-
5791
- // TODO make chevron size configurable
5792
- const chevronSize = 22;
5793
- const getTreeItemIndentWithChevron = (depth, chevron) => {
5794
- // TODO use numeric value here, convert to string value in renderer process
5795
- const extraSpace = chevron ? 0 : chevronSize;
5796
- return `${depth * defaultIndent + extraSpace + defaultPaddingLeft}px`;
5797
- };
5798
-
5799
- const ariaExpandedValues = [undefined, 'true', 'false'];
5800
- const getEditingChevron = direntType => {
5801
- switch (direntType) {
5802
- case EditingDirectoryExpanded:
5803
- return Down;
5804
- case EditingFolder:
5805
- return Right;
5806
- default:
5807
- return None$1;
5808
- }
5809
- };
5810
- const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris = []) => {
5811
- const visible = [];
5812
- const indentFn = useChevrons ? getTreeItemIndentWithChevron : getTreeItemIndent;
5813
- let iconIndex = 0;
5814
- for (let i = minLineY; i < Math.min(maxLineY, items.length); i++) {
5815
- const item = items[i];
5816
- let chevron = getChevronType(item.type, useChevrons);
5817
- const isFocused = i === focusedIndex;
5818
- const id = isFocused ? 'TreeItemActive' : undefined;
5819
- const isSelected = item.selected;
5820
- const isCut = cutItems.includes(item.path);
5821
- const isDropping = dropTargets.includes(i);
5822
- const isIgnored = sourceControlIgnoredUris.includes(item.path);
5823
- const className = getTreeItemClassName(isSelected, isFocused, isDropping, useChevrons, item.depth); // TODO compute classname in dom function
5824
- const expanded = getExpandedType(item.type);
5825
- const ariaExpanded = ariaExpandedValues[expanded];
5826
- const isEditing = i === editingIndex;
5827
- let icon = icons[iconIndex++];
5828
- if (isEditing) {
5829
- icon = editingIcon;
5830
- chevron = getEditingChevron(item.type);
5831
- }
5832
- const indent = indentFn(item.depth, chevron);
5833
- visible.push({
5834
- ...item,
5835
- posInSet: item.posInSet ?? i + 1,
5836
- setSize: item.setSize ?? items.length,
5837
- isEditing: isEditing,
5838
- hasEditingError: isEditing && Boolean(editingErrorMessage),
5839
- icon,
5840
- indent,
5841
- ariaExpanded,
5842
- chevron,
5843
- id,
5844
- className,
5845
- isCut,
5846
- isIgnored,
5847
- index: i
5848
- });
5849
- }
5850
- return visible;
5851
- };
5852
-
5853
5933
  const renderItems = (oldState, newState) => {
5854
5934
  const {
5855
5935
  cutItems,
@@ -5981,7 +6061,7 @@ const getIconVirtualDom = (icon, type = Div) => {
5981
6061
  return {
5982
6062
  type,
5983
6063
  className: `MaskIcon MaskIcon${icon}`,
5984
- role: None$2,
6064
+ role: None,
5985
6065
  childCount: 0
5986
6066
  };
5987
6067
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "3.18.0",
3
+ "version": "3.19.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",