@lvce-editor/explorer-view 2.57.0 → 2.58.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.
@@ -1995,7 +1995,8 @@ const create2 = (uid, uri, x, y, width, height, args, parentUid, platform = 0) =
1995
1995
  scrollBarActive: false,
1996
1996
  scrollBarHeight: 0,
1997
1997
  confirmPaste: false,
1998
- pasteShouldMove: false
1998
+ pasteShouldMove: false,
1999
+ cutItems: []
1999
2000
  };
2000
2001
  set(uid, state, state);
2001
2002
  };
@@ -2043,7 +2044,8 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
2043
2044
  scrollBarActive: false,
2044
2045
  scrollBarHeight: 0,
2045
2046
  confirmPaste: false,
2046
- pasteShouldMove: false
2047
+ pasteShouldMove: false,
2048
+ cutItems: []
2047
2049
  };
2048
2050
  set(state.uid, state, state);
2049
2051
  return state;
@@ -2062,7 +2064,7 @@ const isEqual$4 = (oldState, newState) => {
2062
2064
 
2063
2065
  const diffType$2 = RenderItems;
2064
2066
  const isEqual$3 = (oldState, newState) => {
2065
- 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;
2067
+ 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;
2066
2068
  };
2067
2069
 
2068
2070
  const diffType$1 = RenderSelection;
@@ -2400,8 +2402,45 @@ const Delete = 18;
2400
2402
  const KeyA = 29;
2401
2403
  const KeyC = 31;
2402
2404
  const KeyV = 50;
2405
+ const KeyX = 52;
2403
2406
  const F2 = 58;
2404
2407
  const Star = 131;
2408
+ const KeyCode = {
2409
+ __proto__: null,
2410
+ Delete,
2411
+ DownArrow,
2412
+ End,
2413
+ Enter,
2414
+ Escape,
2415
+ F2,
2416
+ Home,
2417
+ KeyA,
2418
+ KeyC,
2419
+ KeyV,
2420
+ KeyX,
2421
+ LeftArrow,
2422
+ RightArrow,
2423
+ Space,
2424
+ Star,
2425
+ UpArrow
2426
+ };
2427
+ const mergeClassNames = (...classNames) => {
2428
+ return classNames.filter(Boolean).join(' ');
2429
+ };
2430
+ const px = value => {
2431
+ return `${value}px`;
2432
+ };
2433
+ const position = (x, y) => {
2434
+ return `${x}px ${y}px`;
2435
+ };
2436
+ const Text = 12;
2437
+ const text = data => {
2438
+ return {
2439
+ type: Text,
2440
+ text: data,
2441
+ childCount: 0
2442
+ };
2443
+ };
2405
2444
 
2406
2445
  const CtrlCmd = 1 << 11 >>> 0;
2407
2446
  const Shift = 1 << 10 >>> 0;
@@ -2412,87 +2451,91 @@ const FocusExplorerEditBox = 14;
2412
2451
 
2413
2452
  const getKeyBindings = () => {
2414
2453
  return [{
2415
- key: Shift | UpArrow,
2454
+ key: Shift | KeyCode.UpArrow,
2416
2455
  command: 'Explorer.selectUp',
2417
2456
  when: FocusExplorer
2418
2457
  }, {
2419
- key: Shift | DownArrow,
2458
+ key: Shift | KeyCode.DownArrow,
2420
2459
  command: 'Explorer.selectDown',
2421
2460
  when: FocusExplorer
2422
2461
  }, {
2423
- key: RightArrow,
2462
+ key: KeyCode.RightArrow,
2424
2463
  command: 'Explorer.handleArrowRight',
2425
2464
  when: FocusExplorer
2426
2465
  }, {
2427
- key: LeftArrow,
2466
+ key: KeyCode.LeftArrow,
2428
2467
  command: 'Explorer.handleArrowLeft',
2429
2468
  when: FocusExplorer
2430
2469
  }, {
2431
- key: Home,
2470
+ key: KeyCode.Home,
2432
2471
  command: 'Explorer.focusFirst',
2433
2472
  when: FocusExplorer
2434
2473
  }, {
2435
- key: End,
2474
+ key: KeyCode.End,
2436
2475
  command: 'Explorer.focusLast',
2437
2476
  when: FocusExplorer
2438
2477
  }, {
2439
- key: UpArrow,
2478
+ key: KeyCode.UpArrow,
2440
2479
  command: 'Explorer.focusPrevious',
2441
2480
  when: FocusExplorer
2442
2481
  }, {
2443
- key: DownArrow,
2482
+ key: KeyCode.DownArrow,
2444
2483
  command: 'Explorer.focusNext',
2445
2484
  when: FocusExplorer
2446
2485
  }, {
2447
- key: CtrlCmd | Star,
2486
+ key: CtrlCmd | KeyCode.Star,
2448
2487
  command: 'Explorer.expandAll',
2449
2488
  when: FocusExplorer
2450
2489
  }, {
2451
- key: Alt | RightArrow,
2490
+ key: Alt | KeyCode.RightArrow,
2452
2491
  command: 'Explorer.expandRecursively',
2453
2492
  when: FocusExplorer
2454
2493
  }, {
2455
- key: CtrlCmd | LeftArrow,
2494
+ key: CtrlCmd | KeyCode.LeftArrow,
2456
2495
  command: 'Explorer.collapseAll',
2457
2496
  when: FocusExplorer
2458
2497
  }, {
2459
- key: CtrlCmd | KeyV,
2498
+ key: CtrlCmd | KeyCode.KeyV,
2460
2499
  command: 'Explorer.handlePaste',
2461
2500
  when: FocusExplorer
2462
2501
  }, {
2463
- key: CtrlCmd | KeyC,
2502
+ key: CtrlCmd | KeyCode.KeyC,
2464
2503
  command: 'Explorer.handleCopy',
2465
2504
  when: FocusExplorer
2466
2505
  }, {
2467
- key: F2,
2506
+ key: CtrlCmd | KeyCode.KeyX,
2507
+ command: 'Explorer.handleCut',
2508
+ when: FocusExplorer
2509
+ }, {
2510
+ key: KeyCode.F2,
2468
2511
  command: 'Explorer.renameDirent',
2469
2512
  when: FocusExplorer
2470
2513
  }, {
2471
- key: Escape,
2514
+ key: KeyCode.Escape,
2472
2515
  command: 'Explorer.cancelEdit',
2473
2516
  when: FocusExplorerEditBox
2474
2517
  }, {
2475
- key: Enter,
2518
+ key: KeyCode.Enter,
2476
2519
  command: 'Explorer.acceptEdit',
2477
2520
  when: FocusExplorerEditBox
2478
2521
  }, {
2479
- key: Delete,
2522
+ key: KeyCode.Delete,
2480
2523
  command: 'Explorer.removeDirent',
2481
2524
  when: FocusExplorer
2482
2525
  }, {
2483
- key: Escape,
2526
+ key: KeyCode.Escape,
2484
2527
  command: 'Explorer.focusNone',
2485
2528
  when: FocusExplorer
2486
2529
  }, {
2487
- key: Space,
2530
+ key: KeyCode.Space,
2488
2531
  command: 'Explorer.handleClickCurrentButKeepFocus',
2489
2532
  when: FocusExplorer
2490
2533
  }, {
2491
- key: Enter,
2534
+ key: KeyCode.Enter,
2492
2535
  command: 'Explorer.handleClickCurrent',
2493
2536
  when: FocusExplorer
2494
2537
  }, {
2495
- key: CtrlCmd | KeyA,
2538
+ key: CtrlCmd | KeyCode.KeyA,
2496
2539
  command: 'Explorer.selectAll',
2497
2540
  when: FocusExplorer
2498
2541
  }];
@@ -3148,7 +3191,8 @@ const handleCut = async state => {
3148
3191
  await writeNativeFiles('cut', files);
3149
3192
  return {
3150
3193
  ...state,
3151
- pasteShouldMove: true
3194
+ pasteShouldMove: true,
3195
+ cutItems: files
3152
3196
  };
3153
3197
  };
3154
3198
 
@@ -4556,22 +4600,34 @@ const ToolBar = 'toolbar';
4556
4600
  const Tree = 'tree';
4557
4601
  const TreeItem$1 = 'treeitem';
4558
4602
 
4603
+ // 0 = 'Button'
4604
+ // 1 = 'IconButton'
4605
+ // 2 = 'Button IconButton'
4606
+ // it could make dom diffing faster, since for classname,
4607
+ // once at start, send all classnames to renderer process
4608
+ // only numbers are compared. it could also make rendering faster,
4609
+ // representing the concatenated strings for example
4610
+ // since less data is transferred to renderer process
4611
+ // then, components uses numeric classname
4612
+ // TODO add option to make classnames numeric
4613
+ // when a component uses multiple classnames, it is a new number
4559
4614
  const Actions = 'Actions';
4560
4615
  const Button$2 = 'Button';
4561
4616
  const ButtonNarrow = 'ButtonNarrow';
4562
4617
  const ButtonPrimary = 'ButtonPrimary';
4563
4618
  const ButtonWide = 'ButtonWide';
4564
4619
  const Chevron = 'Chevron';
4565
- const ExplorerErrorMessage = 'ExplorerErrorMessage';
4566
4620
  const Empty = '';
4567
4621
  const Explorer = 'Explorer';
4568
4622
  const ExplorerDropTarget = 'DropTarget';
4623
+ const ExplorerErrorMessage = 'ExplorerErrorMessage';
4569
4624
  const ExplorerInputBox = 'ExplorerInputBox';
4570
4625
  const FileIcon = 'FileIcon';
4571
4626
  const FocusOutline = 'FocusOutline';
4572
4627
  const IconButton = 'IconButton';
4573
4628
  const InputValidationError = 'InputValidationError';
4574
4629
  const Label = 'Label';
4630
+ const LabelCut = 'LabelCut';
4575
4631
  const ListItems = 'ListItems';
4576
4632
  const MaskIconChevronDown = 'MaskIconChevronDown';
4577
4633
  const MaskIconChevronRight = 'MaskIconChevronRight';
@@ -4584,36 +4640,6 @@ const Viewlet = 'Viewlet';
4584
4640
  const Welcome = 'Welcome';
4585
4641
  const WelcomeMessage = 'WelcomeMessage';
4586
4642
 
4587
- // TODO add option to make classnames numeric
4588
- // once at start, send all classnames to renderer process
4589
- // then, components uses numeric classname
4590
- // when a component uses multiple classnames, it is a new number
4591
- // representing the concatenated strings for example
4592
- // 0 = 'Button'
4593
- // 1 = 'IconButton'
4594
- // 2 = 'Button IconButton'
4595
- // it could make dom diffing faster, since for classname,
4596
- // only numbers are compared. it could also make rendering faster,
4597
- // since less data is transferred to renderer process
4598
-
4599
- const mergeClassNames = (...classNames) => {
4600
- return classNames.filter(Boolean).join(' ');
4601
- };
4602
- const px = value => {
4603
- return `${value}px`;
4604
- };
4605
- const position = (x, y) => {
4606
- return `${x}px ${y}px`;
4607
- };
4608
- const Text = 12;
4609
- const text = data => {
4610
- return {
4611
- type: Text,
4612
- text: data,
4613
- childCount: 0
4614
- };
4615
- };
4616
-
4617
4643
  const Button$1 = 1;
4618
4644
  const Div = 4;
4619
4645
  const Input = 6;
@@ -4726,15 +4752,22 @@ const label = {
4726
4752
  className: Label,
4727
4753
  childCount: 1
4728
4754
  };
4729
- const getLabelDom = name => {
4755
+ const getLabelDom = (name, isCut) => {
4756
+ if (isCut) {
4757
+ return [{
4758
+ type: Div,
4759
+ className: mergeClassNames(Label, LabelCut),
4760
+ childCount: 1
4761
+ }, text(name)];
4762
+ }
4730
4763
  return [label, text(name)];
4731
4764
  };
4732
4765
 
4733
- const getInputOrLabelDom = (isEditing, hasEditingError, name) => {
4766
+ const getInputOrLabelDom = (isEditing, hasEditingError, name, isCut) => {
4734
4767
  if (isEditing) {
4735
4768
  return getInputDom(hasEditingError);
4736
4769
  }
4737
- return getLabelDom(name);
4770
+ return getLabelDom(name, isCut);
4738
4771
  };
4739
4772
 
4740
4773
  const getExplorerItemVirtualDom = item => {
@@ -4751,7 +4784,8 @@ const getExplorerItemVirtualDom = item => {
4751
4784
  name,
4752
4785
  path,
4753
4786
  setSize,
4754
- posInSet
4787
+ posInSet,
4788
+ isCut
4755
4789
  } = item;
4756
4790
  const chevronDom = getChevronVirtualDom(chevron);
4757
4791
  return [{
@@ -4769,7 +4803,7 @@ const getExplorerItemVirtualDom = item => {
4769
4803
  ariaExpanded,
4770
4804
  ariaDescription: '',
4771
4805
  id
4772
- }, ...chevronDom, getFileIconVirtualDom(icon), ...getInputOrLabelDom(isEditing, hasEditingError, name)];
4806
+ }, ...chevronDom, getFileIconVirtualDom(icon), ...getInputOrLabelDom(isEditing, hasEditingError, name, isCut)];
4773
4807
  };
4774
4808
 
4775
4809
  const getActiveDescendant = focusedIndex => {
@@ -4943,7 +4977,7 @@ const getEditingChevron = direntType => {
4943
4977
  return None$1;
4944
4978
  }
4945
4979
  };
4946
- const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon) => {
4980
+ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems) => {
4947
4981
  const visible = [];
4948
4982
  const indentFn = useChevrons ? getTreeItemIndentWithChevron : getTreeItemIndent;
4949
4983
  let iconIndex = 0;
@@ -4953,7 +4987,8 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
4953
4987
  const isFocused = i === focusedIndex;
4954
4988
  const id = isFocused ? 'TreeItemActive' : undefined;
4955
4989
  const isSelected = item.selected;
4956
- const className = getTreeItemClassName(isSelected, isFocused);
4990
+ const isCut = cutItems.includes(item.path);
4991
+ const className = getTreeItemClassName(isSelected, isFocused); // TODO compute classname in dom function
4957
4992
  const expanded = getExpandedType(item.type);
4958
4993
  const ariaExpanded = ariaExpandedValues[expanded];
4959
4994
  const isEditing = i === editingIndex;
@@ -4974,17 +5009,39 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
4974
5009
  ariaExpanded,
4975
5010
  chevron,
4976
5011
  id,
4977
- className
5012
+ className,
5013
+ isCut
4978
5014
  });
4979
5015
  }
4980
5016
  return visible;
4981
5017
  };
4982
5018
 
4983
5019
  const renderItems = (oldState, newState) => {
4984
- const visibleDirents = getVisibleExplorerItems(newState.items, newState.minLineY, newState.maxLineY, newState.focusedIndex, newState.editingIndex, newState.editingType, newState.editingValue, newState.editingErrorMessage, newState.icons, newState.useChevrons, newState.dropTargets, newState.editingIcon);
4985
- const isWide = newState.width > 450;
4986
- const contentHeight = newState.items.length * newState.itemHeight;
4987
- const depth = newState.items[newState.focusedIndex]?.depth || 0;
5020
+ const {
5021
+ items,
5022
+ minLineY,
5023
+ maxLineY,
5024
+ focusedIndex,
5025
+ editingIndex,
5026
+ editingType,
5027
+ editingValue,
5028
+ editingErrorMessage,
5029
+ icons,
5030
+ useChevrons,
5031
+ dropTargets,
5032
+ editingIcon,
5033
+ itemHeight,
5034
+ width,
5035
+ root,
5036
+ deltaY,
5037
+ focused,
5038
+ height,
5039
+ cutItems
5040
+ } = newState;
5041
+ const visibleDirents = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems);
5042
+ const isWide = width > 450;
5043
+ const contentHeight = items.length * itemHeight;
5044
+ const depth = items[focusedIndex]?.depth || 0;
4988
5045
  const indent = 8;
4989
5046
  const padding = 10;
4990
5047
  const fileIconWidth = 16;
@@ -4993,8 +5050,8 @@ const renderItems = (oldState, newState) => {
4993
5050
  const {
4994
5051
  top,
4995
5052
  left
4996
- } = getErrorMessagePosition(newState.itemHeight, newState.focusedIndex, newState.minLineY, depth, indent, fileIconWidth, padding + defaultPaddingLeft + chevronSpace);
4997
- const dom = getExplorerVirtualDom(visibleDirents, newState.focusedIndex, newState.root, isWide, newState.focused, newState.dropTargets, newState.height, contentHeight, newState.deltaY, newState.editingErrorMessage, top, left);
5053
+ } = getErrorMessagePosition(itemHeight, focusedIndex, minLineY, depth, indent, fileIconWidth, padding + defaultPaddingLeft + chevronSpace);
5054
+ const dom = getExplorerVirtualDom(visibleDirents, focusedIndex, root, isWide, focused, dropTargets, height, contentHeight, deltaY, editingErrorMessage, top, left);
4998
5055
  return ['Viewlet.setDom2', dom];
4999
5056
  };
5000
5057
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "2.57.0",
3
+ "version": "2.58.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",