@lvce-editor/explorer-view 3.7.0 → 3.9.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.
@@ -1025,6 +1025,22 @@ const WebWorkerRpcClient = {
1025
1025
  __proto__: null,
1026
1026
  create: create$4
1027
1027
  };
1028
+ const createMockRpc = ({
1029
+ commandMap
1030
+ }) => {
1031
+ const invocations = [];
1032
+ const invoke = (method, ...params) => {
1033
+ invocations.push([method, ...params]);
1034
+ const command = commandMap[method];
1035
+ return command(...params);
1036
+ };
1037
+ const mockRpc = {
1038
+ invoke,
1039
+ invokeAndTransfer: invoke,
1040
+ invocations
1041
+ };
1042
+ return mockRpc;
1043
+ };
1028
1044
 
1029
1045
  const CreateFolder$1 = 1;
1030
1046
  const CreateFile$1 = 2;
@@ -1059,6 +1075,9 @@ const DebugWorker = 55;
1059
1075
  const FileSystemWorker$1 = 209;
1060
1076
  const RendererWorker$1 = 1;
1061
1077
 
1078
+ const FocusExplorer = 13;
1079
+ const FocusExplorerEditBox = 14;
1080
+
1062
1081
  const rpcs = Object.create(null);
1063
1082
  const set$5 = (id, rpc) => {
1064
1083
  rpcs[id] = rpc;
@@ -1432,6 +1451,13 @@ const getLogsDir = async () => {
1432
1451
  // @ts-ignore
1433
1452
  return invoke$2('PlatformPaths.getLogsDir');
1434
1453
  };
1454
+ const registerMockRpc = commandMap => {
1455
+ const mockRpc = createMockRpc({
1456
+ commandMap
1457
+ });
1458
+ set$3(mockRpc);
1459
+ return mockRpc;
1460
+ };
1435
1461
 
1436
1462
  const RendererWorker = {
1437
1463
  __proto__: null,
@@ -1481,6 +1507,7 @@ const RendererWorker = {
1481
1507
  openUrl,
1482
1508
  openWidget,
1483
1509
  readFile,
1510
+ registerMockRpc,
1484
1511
  registerWebViewInterceptor,
1485
1512
  renderMarkdown,
1486
1513
  rerenderEditor,
@@ -2038,6 +2065,11 @@ const treeToArray = (map, root) => {
2038
2065
  return items;
2039
2066
  };
2040
2067
 
2068
+ const EmptyString = '';
2069
+ const Slash$1 = '/';
2070
+ const Dot = '.';
2071
+ const BackSlash = '\\';
2072
+
2041
2073
  const emptyObject = {};
2042
2074
  const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
2043
2075
  const i18nString = (key, placeholders = emptyObject) => {
@@ -2058,6 +2090,8 @@ const Cut = 'Cut';
2058
2090
  const Delete = 'Delete';
2059
2091
  const FileNameCannotStartWithSlash = 'A file or folder name cannot start with a slash.';
2060
2092
  const FileOrFolderNameMustBeProvider = 'A file or folder name must be provided.';
2093
+ const FileCannotStartWithDot = 'A file or folder name cannot start with a dot.';
2094
+ const FileCannotStartWithBackSlash = 'A file or folder name cannot start with a backslash.';
2061
2095
  const FilesExplorer = 'Files Explorer';
2062
2096
  const NewFile$1 = 'New File...';
2063
2097
  const NewFolder$1 = 'New Folder...';
@@ -2124,6 +2158,12 @@ const fileOrFolderNameMustBeProvided = () => {
2124
2158
  const fileCannotStartWithSlash = () => {
2125
2159
  return i18nString(FileNameCannotStartWithSlash);
2126
2160
  };
2161
+ const fileCannotStartWithDot = () => {
2162
+ return i18nString(FileCannotStartWithDot);
2163
+ };
2164
+ const fileCannotStartWithBackSlash = () => {
2165
+ return i18nString(FileCannotStartWithBackSlash);
2166
+ };
2127
2167
  const typeAFileName = () => {
2128
2168
  return i18nString(TypeAFileName);
2129
2169
  };
@@ -2133,9 +2173,15 @@ const validateFileName2 = name => {
2133
2173
  const editingErrorMessage = fileOrFolderNameMustBeProvided();
2134
2174
  return editingErrorMessage;
2135
2175
  }
2136
- if (name.startsWith('/')) {
2176
+ if (name.startsWith(Dot)) {
2177
+ return fileCannotStartWithDot();
2178
+ }
2179
+ if (name.startsWith(Slash$1)) {
2137
2180
  return fileCannotStartWithSlash();
2138
2181
  }
2182
+ if (name.startsWith(BackSlash)) {
2183
+ return fileCannotStartWithBackSlash();
2184
+ }
2139
2185
  return '';
2140
2186
  };
2141
2187
 
@@ -2321,12 +2367,17 @@ const isNormalItem = item => {
2321
2367
  return item.type !== EditingFile && item.type !== EditingFolder;
2322
2368
  };
2323
2369
 
2324
- const cancelEditCreate = (state, keepFocus) => {
2370
+ const cancelEditCreate = async (state, keepFocus) => {
2325
2371
  const {
2326
2372
  editingIndex,
2327
- items
2373
+ items,
2374
+ fileIconCache
2328
2375
  } = state;
2329
2376
  const filteredItems = items.filter(isNormalItem);
2377
+ const {
2378
+ icons,
2379
+ newFileIconCache
2380
+ } = await getFileIcons(filteredItems, fileIconCache);
2330
2381
  return {
2331
2382
  ...state,
2332
2383
  items: filteredItems,
@@ -2336,7 +2387,9 @@ const cancelEditCreate = (state, keepFocus) => {
2336
2387
  editingValue: '',
2337
2388
  editingErrorMessage: '',
2338
2389
  editingType: None$5,
2339
- focus: List
2390
+ focus: List,
2391
+ icons,
2392
+ fileIconCache: newFileIconCache
2340
2393
  };
2341
2394
  };
2342
2395
 
@@ -2378,7 +2431,7 @@ const cancelEditRename = (state, keepFocus) => {
2378
2431
  };
2379
2432
  };
2380
2433
 
2381
- const cancelEditInternal = (state, keepFocus) => {
2434
+ const cancelEditInternal = async (state, keepFocus) => {
2382
2435
  const {
2383
2436
  editingType
2384
2437
  } = state;
@@ -2388,7 +2441,7 @@ const cancelEditInternal = (state, keepFocus) => {
2388
2441
  return cancelEditCreate(state, keepFocus);
2389
2442
  };
2390
2443
 
2391
- const cancelEdit = state => {
2444
+ const cancelEdit = async state => {
2392
2445
  return cancelEditInternal(state, true);
2393
2446
  };
2394
2447
 
@@ -2563,7 +2616,9 @@ const create$1 = () => {
2563
2616
  const {
2564
2617
  get,
2565
2618
  set,
2566
- wrapCommand
2619
+ wrapCommand,
2620
+ registerCommands,
2621
+ getCommandIds
2567
2622
  } = create$1();
2568
2623
 
2569
2624
  const ListItem = 22;
@@ -2616,7 +2671,8 @@ const create2 = (uid, uri, x, y, width, height, args, parentUid, platform = 0) =
2616
2671
  pasteShouldMove: false,
2617
2672
  cutItems: [],
2618
2673
  isPointerDown: false,
2619
- pointerDownIndex: -1
2674
+ pointerDownIndex: -1,
2675
+ sourceControlIgnoredUris: []
2620
2676
  };
2621
2677
  set(uid, state, state);
2622
2678
  };
@@ -2667,40 +2723,36 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
2667
2723
  pasteShouldMove: false,
2668
2724
  cutItems: [],
2669
2725
  isPointerDown: false,
2670
- pointerDownIndex: -1
2726
+ pointerDownIndex: -1,
2727
+ sourceControlIgnoredUris: []
2671
2728
  };
2672
2729
  set(state.uid, state, state);
2673
2730
  return state;
2674
2731
  };
2675
2732
 
2676
- const RenderItems = 4;
2677
- const RenderFocus = 6;
2678
- const RenderFocusContext = 7;
2679
- const RenderValue = 8;
2680
- const RenderSelection = 9;
2681
- const RenderDragData = 10;
2682
-
2683
- const diffType$4 = RenderDragData;
2684
2733
  const isEqual$5 = (oldState, newState) => {
2685
2734
  return oldState.isPointerDown || !newState.isPointerDown;
2686
2735
  };
2687
2736
 
2688
- const diffType$3 = RenderFocus;
2689
2737
  const isEqual$4 = (oldState, newState) => {
2690
2738
  return oldState.focused === newState.focused && oldState.focus === newState.focus;
2691
2739
  };
2692
2740
 
2693
- const diffType$2 = RenderItems;
2694
2741
  const isEqual$3 = (oldState, newState) => {
2695
2742
  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;
2696
2743
  };
2697
2744
 
2698
- const diffType$1 = RenderSelection;
2699
2745
  const isEqual$2 = (oldState, newState) => {
2700
2746
  return oldState.editingSelectionStart === newState.editingSelectionStart && oldState.editingSelectionEnd === newState.editingSelectionEnd;
2701
2747
  };
2702
2748
 
2703
- const diffType = RenderValue;
2749
+ const RenderItems = 4;
2750
+ const RenderFocus = 6;
2751
+ const RenderFocusContext = 7;
2752
+ const RenderValue = 8;
2753
+ const RenderSelection = 9;
2754
+ const RenderDragData = 10;
2755
+
2704
2756
  const isEqual$1 = (oldState, newState) => {
2705
2757
  if (newState.focus !== Input$1) {
2706
2758
  return true;
@@ -2709,7 +2761,7 @@ const isEqual$1 = (oldState, newState) => {
2709
2761
  };
2710
2762
 
2711
2763
  const modules = [isEqual$3, isEqual$4, isEqual$4, isEqual$1, isEqual$2, isEqual$5];
2712
- const numbers = [diffType$2, diffType$3, RenderFocusContext, diffType, diffType$1, diffType$4];
2764
+ const numbers = [RenderItems, RenderFocus, RenderFocusContext, RenderValue, RenderSelection, RenderDragData];
2713
2765
 
2714
2766
  const diff = (oldState, newState) => {
2715
2767
  const diffResult = [];
@@ -3011,12 +3063,6 @@ const focusPrevious = state => {
3011
3063
  }
3012
3064
  };
3013
3065
 
3014
- const commandIds = ['acceptEdit', 'cancelEdit', 'cancelTypeAhead', 'collapseAll', 'copyPath', 'copyRelativePath', 'dispose', 'expandAll', 'expandRecursively', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusNone', 'focusPrevious', 'getFocusedDirent', 'getMenuEntries2', 'getMouseActions', 'handleArrowLeft', 'handleArrowLeft', 'handleArrowRight', 'handleArrowRight', 'handleBlur', 'handleClick', 'handleClickAt', 'handleClickCurrent', 'handleClickCurrentButKeepFocus', 'handleClickOpenFolder', 'handleContextMenu', 'handleContextMenuKeyboard', 'handleCopy', 'handleCut', 'handleDragLeave', 'handleDragOver', 'handleDragOverIndex', 'handleDragStart', 'handleDrop', 'handleFocus', 'handleIconThemeChange', 'handleInputBlur', 'handleInputClick', 'handleInputKeyDown', 'handleKeyDown', 'handleLanguagesChanged', 'handleMouseEnter', 'handleMouseLeave', 'handlePaste', 'handlePointerDown', 'handleUpload', 'handleWheel', 'handleWorkspaceChange', 'hotReload', 'newFile', 'newFolder', 'openContainingFolder', 'refresh', 'removeDirent', 'rename', 'renameDirent', 'renderEventListeners', 'revealItem', 'revealItem', 'scrollDown', 'scrollUp', 'selectAll', 'selectDown', 'selectIndices', 'selectUp', 'setDeltaY', 'setSelectedIndices', 'toggleIndividualSelection', 'updateEditingValue', 'updateIcons'];
3015
-
3016
- const getCommandIds = () => {
3017
- return commandIds;
3018
- };
3019
-
3020
3066
  const mergeClassNames = (...classNames) => {
3021
3067
  return classNames.filter(Boolean).join(' ');
3022
3068
  };
@@ -3036,9 +3082,6 @@ const text = data => {
3036
3082
  };
3037
3083
  };
3038
3084
 
3039
- const FocusExplorer = 13;
3040
- const FocusExplorerEditBox = 14;
3041
-
3042
3085
  const getKeyBindings = () => {
3043
3086
  return [{
3044
3087
  key: Shift | UpArrow,
@@ -3124,6 +3167,10 @@ const getKeyBindings = () => {
3124
3167
  key: Enter,
3125
3168
  command: 'Explorer.handleClickCurrent',
3126
3169
  when: FocusExplorer
3170
+ }, {
3171
+ key: Escape,
3172
+ command: 'Explorer.handleEscape',
3173
+ when: FocusExplorer
3127
3174
  }, {
3128
3175
  key: CtrlCmd | KeyA,
3129
3176
  command: 'Explorer.selectAll',
@@ -4305,6 +4352,13 @@ const handleDrop = async (state, x, y, fileIds, fileList) => {
4305
4352
  }
4306
4353
  };
4307
4354
 
4355
+ const handleEscape = async state => {
4356
+ return {
4357
+ ...state,
4358
+ cutItems: []
4359
+ };
4360
+ };
4361
+
4308
4362
  const handleFocus = async state => {
4309
4363
  await setFocus(FocusExplorer);
4310
4364
  return state;
@@ -4747,8 +4801,6 @@ const getSettings = async () => {
4747
4801
  };
4748
4802
  };
4749
4803
 
4750
- const EmptyString = '';
4751
-
4752
4804
  const getSavedChildDirents = (map, path, depth, excluded, pathSeparator) => {
4753
4805
  let children = map[path];
4754
4806
  if (!children) {
@@ -5292,10 +5344,10 @@ const renderFocus = (oldState, newState) => {
5292
5344
 
5293
5345
  const renderFocusContext = (oldState, newState) => {
5294
5346
  if (newState.focus === Input$1) {
5295
- return ['Viewlet.setFocusContext', FocusExplorerEditBox];
5347
+ return ['Viewlet.setFocusContext', newState.uid, FocusExplorerEditBox];
5296
5348
  }
5297
5349
  if (newState.focus === List) {
5298
- return ['Viewlet.setFocusContext', FocusExplorer];
5350
+ return ['Viewlet.setFocusContext', newState.uid, FocusExplorer];
5299
5351
  }
5300
5352
  return [];
5301
5353
  };
@@ -5467,8 +5519,8 @@ const label = {
5467
5519
  className: Label,
5468
5520
  childCount: 1
5469
5521
  };
5470
- const getLabelDom = (name, isCut) => {
5471
- if (isCut) {
5522
+ const getLabelDom = (name, isDimmed) => {
5523
+ if (isDimmed) {
5472
5524
  return [{
5473
5525
  type: Div,
5474
5526
  className: mergeClassNames(Label, LabelCut),
@@ -5478,11 +5530,11 @@ const getLabelDom = (name, isCut) => {
5478
5530
  return [label, text(name)];
5479
5531
  };
5480
5532
 
5481
- const getInputOrLabelDom = (isEditing, hasEditingError, name, isCut) => {
5533
+ const getInputOrLabelDom = (isEditing, hasEditingError, name, isCut, isIgnored) => {
5482
5534
  if (isEditing) {
5483
5535
  return getInputDom(hasEditingError);
5484
5536
  }
5485
- return getLabelDom(name, isCut);
5537
+ return getLabelDom(name, isCut || isIgnored);
5486
5538
  };
5487
5539
 
5488
5540
  const getExplorerItemVirtualDom = item => {
@@ -5501,6 +5553,7 @@ const getExplorerItemVirtualDom = item => {
5501
5553
  setSize,
5502
5554
  posInSet,
5503
5555
  isCut,
5556
+ isIgnored,
5504
5557
  index
5505
5558
  } = item;
5506
5559
  const chevronDom = getChevronVirtualDom(chevron);
@@ -5520,7 +5573,7 @@ const getExplorerItemVirtualDom = item => {
5520
5573
  ariaDescription: '',
5521
5574
  id,
5522
5575
  'data-index': index
5523
- }, ...chevronDom, getFileIconVirtualDom(icon), ...getInputOrLabelDom(isEditing, hasEditingError, name, isCut)];
5576
+ }, ...chevronDom, getFileIconVirtualDom(icon), ...getInputOrLabelDom(isEditing, hasEditingError, name, isCut, isIgnored)];
5524
5577
  };
5525
5578
 
5526
5579
  const getActiveDescendant = focusedIndex => {
@@ -5694,7 +5747,7 @@ const getEditingChevron = direntType => {
5694
5747
  return None$1;
5695
5748
  }
5696
5749
  };
5697
- const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems) => {
5750
+ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris = []) => {
5698
5751
  const visible = [];
5699
5752
  const indentFn = useChevrons ? getTreeItemIndentWithChevron : getTreeItemIndent;
5700
5753
  let iconIndex = 0;
@@ -5706,6 +5759,7 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
5706
5759
  const isSelected = item.selected;
5707
5760
  const isCut = cutItems.includes(item.path);
5708
5761
  const isDropping = dropTargets.includes(i);
5762
+ const isIgnored = sourceControlIgnoredUris.includes(item.path);
5709
5763
  const className = getTreeItemClassName(isSelected, isFocused, isDropping); // TODO compute classname in dom function
5710
5764
  const expanded = getExpandedType(item.type);
5711
5765
  const ariaExpanded = ariaExpandedValues[expanded];
@@ -5729,6 +5783,7 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
5729
5783
  id,
5730
5784
  className,
5731
5785
  isCut,
5786
+ isIgnored,
5732
5787
  index: i
5733
5788
  });
5734
5789
  }
@@ -5738,6 +5793,7 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
5738
5793
  const renderItems = (oldState, newState) => {
5739
5794
  const {
5740
5795
  cutItems,
5796
+ sourceControlIgnoredUris,
5741
5797
  deltaY,
5742
5798
  dropTargets,
5743
5799
  editingErrorMessage,
@@ -5757,7 +5813,7 @@ const renderItems = (oldState, newState) => {
5757
5813
  useChevrons,
5758
5814
  width
5759
5815
  } = newState;
5760
- const visibleDirents = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems);
5816
+ const visibleDirents = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
5761
5817
  const isWide = width > 450;
5762
5818
  const contentHeight = items.length * itemHeight;
5763
5819
  const depth = items[focusedIndex]?.depth || 0;
@@ -6280,6 +6336,7 @@ const commandMap = {
6280
6336
  'Explorer.getMouseActions': getMouseActions,
6281
6337
  'Explorer.handleArrowLeft': wrapCommand(handleArrowLeft),
6282
6338
  'Explorer.handleArrowRight': wrapCommand(handleArrowRight),
6339
+ 'Explorer.handleEscape': wrapCommand(handleEscape),
6283
6340
  'Explorer.handleBlur': wrapCommand(handleBlur),
6284
6341
  'Explorer.handleClick': wrapCommand(handleClick),
6285
6342
  'Explorer.handleClickAt': wrapCommand(handleClickAt),
@@ -6338,6 +6395,7 @@ const commandMap = {
6338
6395
  };
6339
6396
 
6340
6397
  const listen = async () => {
6398
+ registerCommands(commandMap);
6341
6399
  const rpc = await WebWorkerRpcClient.create({
6342
6400
  commandMap: commandMap
6343
6401
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "3.7.0",
3
+ "version": "3.9.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",