@lvce-editor/explorer-view 2.14.0 → 2.16.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.
@@ -1452,6 +1452,10 @@ const getFocusedDirent$1 = state => {
1452
1452
  };
1453
1453
 
1454
1454
  const copyPath = async state => {
1455
+ const dirent = getFocusedDirent$1(state);
1456
+ if (!dirent) {
1457
+ return state;
1458
+ }
1455
1459
  // await Command.execute(RendererWorkerCommandType.ClipBoardWriteText, /* text */ path)
1456
1460
  return state;
1457
1461
  };
@@ -1468,6 +1472,9 @@ const writeNativeFiles = async (type, files) => {
1468
1472
 
1469
1473
  const copyRelativePath = async state => {
1470
1474
  const dirent = getFocusedDirent$1(state);
1475
+ if (!dirent) {
1476
+ return state;
1477
+ }
1471
1478
  const relativePath = dirent.path.slice(1);
1472
1479
  // TODO handle error
1473
1480
  await writeText(relativePath);
@@ -1565,49 +1572,27 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
1565
1572
  };
1566
1573
 
1567
1574
  const RenderItems = 4;
1568
- const RenderEditingIndex = 5;
1569
1575
  const RenderFocus = 6;
1570
1576
 
1571
- const diffType$2 = RenderEditingIndex;
1572
- const isEqual$3 = (oldState, newState) => {
1573
- return oldState.editingIndex === newState.editingIndex && oldState.editingType === newState.editingType;
1574
- };
1575
-
1576
- const DiffEditingIndex = {
1577
- __proto__: null,
1578
- diffType: diffType$2,
1579
- isEqual: isEqual$3
1580
- };
1581
-
1582
1577
  const diffType$1 = RenderFocus;
1583
1578
  const isEqual$2 = (oldState, newState) => {
1584
1579
  return oldState.focused === newState.focused && oldState.focus === newState.focus;
1585
1580
  };
1586
1581
 
1587
- const DiffFocus = {
1588
- __proto__: null,
1589
- diffType: diffType$1,
1590
- isEqual: isEqual$2
1591
- };
1592
-
1593
1582
  const diffType = RenderItems;
1594
1583
  const isEqual$1 = (oldState, newState) => {
1595
1584
  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;
1596
1585
  };
1597
1586
 
1598
- const DiffItems = {
1599
- __proto__: null,
1600
- diffType,
1601
- isEqual: isEqual$1
1602
- };
1603
-
1604
- const modules = [DiffItems, DiffEditingIndex, DiffFocus];
1587
+ const modules = [isEqual$1, isEqual$2];
1588
+ const numbers = [diffType, diffType$1];
1605
1589
 
1606
1590
  const diff = (oldState, newState) => {
1607
1591
  const diffResult = [];
1608
- for (const module of modules) {
1609
- if (!module.isEqual(oldState, newState)) {
1610
- diffResult.push(module.diffType);
1592
+ for (let i = 0; i < modules.length; i++) {
1593
+ const fn = modules[i];
1594
+ if (!fn(oldState, newState)) {
1595
+ diffResult.push(numbers[i]);
1611
1596
  }
1612
1597
  }
1613
1598
  return diffResult;
@@ -3203,7 +3188,8 @@ const handlePointerDown = (state, button, x, y) => {
3203
3188
  return {
3204
3189
  ...state,
3205
3190
  focused: true,
3206
- focusedIndex: -1
3191
+ focusedIndex: -1,
3192
+ focus: List
3207
3193
  };
3208
3194
  }
3209
3195
  return state;
@@ -3517,6 +3503,9 @@ const removeDirent = async state => {
3517
3503
  return state;
3518
3504
  }
3519
3505
  const dirent = getFocusedDirent$1(state);
3506
+ if (!dirent) {
3507
+ return state;
3508
+ }
3520
3509
  const absolutePath = dirent.path;
3521
3510
  try {
3522
3511
  // TODO handle error
@@ -3589,16 +3578,20 @@ const renameDirent = state => {
3589
3578
  };
3590
3579
  };
3591
3580
 
3592
- const renderEditingIndex = (oldState, newState) => {
3593
- return ['focusInput', 'ExplorerInput'];
3594
- };
3595
-
3596
3581
  const ExplorerInput = 'ExplorerInput';
3597
3582
 
3583
+ const User = 1;
3584
+
3598
3585
  const renderFocus = (oldState, newState) => {
3586
+ if (newState.inputSource === User) {
3587
+ return [];
3588
+ }
3599
3589
  if (newState.focus === Input$1) {
3600
3590
  return ['Viewlet.focusElementByName', ExplorerInput];
3601
3591
  }
3592
+ if (newState.focus === List) {
3593
+ return ['Viewlet.focusSelector', '.ListItems'];
3594
+ }
3602
3595
  // TODO
3603
3596
  // 1. when focused, focus the outer list element
3604
3597
  // 2. when focused, set focus context in renderer worker
@@ -3621,6 +3614,7 @@ const Explorer = 'Explorer';
3621
3614
  const ExplorerDropTarget = 'DropTarget';
3622
3615
  const FileIcon = 'FileIcon';
3623
3616
  const FocusOutline = 'FocusOutline';
3617
+ const ListItems = 'ListItems';
3624
3618
  const IconButton = 'IconButton';
3625
3619
  const InputBox = 'InputBox';
3626
3620
  const InputValidationError = 'InputValidationError';
@@ -3798,14 +3792,20 @@ const getActiveDescendant = focusedIndex => {
3798
3792
  const getClassName = (focused, focusedIndex, dropTarget) => {
3799
3793
  const extraClass1 = focused && focusedIndex === -1 ? FocusOutline : Empty;
3800
3794
  const extraClass2 = dropTarget === dropTargetFull ? ExplorerDropTarget : Empty;
3801
- const className = mergeClassNames(Viewlet, Explorer, extraClass1, extraClass2);
3795
+ const className = mergeClassNames(ListItems, extraClass1, extraClass2);
3802
3796
  return className;
3803
3797
  };
3798
+ const parentNode = {
3799
+ type: Div,
3800
+ childCount: 1,
3801
+ className: mergeClassNames(Viewlet, Explorer),
3802
+ role: 'none'
3803
+ };
3804
3804
  const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused, dropTargets) => {
3805
3805
  if (!root) {
3806
3806
  return getExplorerWelcomeVirtualDom(isWide);
3807
3807
  }
3808
- const dom = [{
3808
+ const dom = [parentNode, {
3809
3809
  type: Div,
3810
3810
  className: getClassName(focused, focusedIndex, dropTargets),
3811
3811
  tabIndex: 0,
@@ -3893,6 +3893,8 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
3893
3893
  const className = isFocused ? mergeClassNames(TreeItem, TreeItemActive) : TreeItem;
3894
3894
  const expanded = getExpandedType(item.type);
3895
3895
  const ariaExpanded = ariaExpandedValues[expanded];
3896
+
3897
+ // @ts-ignore
3896
3898
  visible.push({
3897
3899
  ...item,
3898
3900
  isEditing: i === editingIndex,
@@ -3934,8 +3936,6 @@ const renderItems = (oldState, newState) => {
3934
3936
 
3935
3937
  const getRenderer = diffType => {
3936
3938
  switch (diffType) {
3937
- case RenderEditingIndex:
3938
- return renderEditingIndex;
3939
3939
  case RenderItems:
3940
3940
  return renderItems;
3941
3941
  case RenderFocus:
@@ -4161,6 +4161,18 @@ const getPathParts = (root, uri, pathSeparator) => {
4161
4161
  return parts;
4162
4162
  };
4163
4163
 
4164
+ const getPathPartsToReveal = (root, pathParts, dirents) => {
4165
+ for (let i = 0; i < pathParts.length; i++) {
4166
+ const pathPart = pathParts[i];
4167
+ const index = getIndex(dirents, pathPart.path);
4168
+ if (index === -1) {
4169
+ continue;
4170
+ }
4171
+ return pathParts.slice(i);
4172
+ }
4173
+ return pathParts;
4174
+ };
4175
+
4164
4176
  const isTopLevel = dirent => {
4165
4177
  return dirent.depth === 1;
4166
4178
  };
@@ -4209,17 +4221,6 @@ const scrollInto = (index, minLineY, maxLineY) => {
4209
4221
  };
4210
4222
  };
4211
4223
 
4212
- const getPathPartsToReveal = (root, pathParts, dirents) => {
4213
- for (let i = 0; i < pathParts.length; i++) {
4214
- const pathPart = pathParts[i];
4215
- const index = getIndex(dirents, pathPart.uri);
4216
- if (index === -1) {
4217
- continue;
4218
- }
4219
- return pathParts.slice(i);
4220
- }
4221
- return pathParts;
4222
- };
4223
4224
  const getPathPartChildren = async pathPart => {
4224
4225
  const children = await getChildDirents(pathPart.pathSeparator, pathPart);
4225
4226
  return children;
@@ -4387,8 +4388,6 @@ const terminate = () => {
4387
4388
  globalThis.close();
4388
4389
  };
4389
4390
 
4390
- const User = 1;
4391
-
4392
4391
  const updateEditingValue = (state, value, inputSource = User) => {
4393
4392
  const editingIcon = '';
4394
4393
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "2.14.0",
3
+ "version": "2.16.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",