@lvce-editor/explorer-view 3.16.0 → 3.18.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.
@@ -1045,6 +1045,90 @@ const createMockRpc = ({
1045
1045
  return mockRpc;
1046
1046
  };
1047
1047
 
1048
+ const toCommandId = key => {
1049
+ const dotIndex = key.indexOf('.');
1050
+ return key.slice(dotIndex + 1);
1051
+ };
1052
+ const create$2 = () => {
1053
+ const states = Object.create(null);
1054
+ const commandMapRef = {};
1055
+ return {
1056
+ get(uid) {
1057
+ return states[uid];
1058
+ },
1059
+ set(uid, oldState, newState) {
1060
+ states[uid] = {
1061
+ oldState,
1062
+ newState
1063
+ };
1064
+ },
1065
+ dispose(uid) {
1066
+ delete states[uid];
1067
+ },
1068
+ getKeys() {
1069
+ return Object.keys(states).map(key => {
1070
+ return Number.parseInt(key);
1071
+ });
1072
+ },
1073
+ clear() {
1074
+ for (const key of Object.keys(states)) {
1075
+ delete states[key];
1076
+ }
1077
+ },
1078
+ wrapCommand(fn) {
1079
+ const wrapped = async (uid, ...args) => {
1080
+ const {
1081
+ newState
1082
+ } = states[uid];
1083
+ const newerState = await fn(newState, ...args);
1084
+ if (newState === newerState) {
1085
+ return;
1086
+ }
1087
+ const latest = states[uid];
1088
+ states[uid] = {
1089
+ oldState: latest.oldState,
1090
+ newState: newerState
1091
+ };
1092
+ };
1093
+ return wrapped;
1094
+ },
1095
+ wrapGetter(fn) {
1096
+ const wrapped = (uid, ...args) => {
1097
+ const {
1098
+ newState
1099
+ } = states[uid];
1100
+ return fn(newState, ...args);
1101
+ };
1102
+ return wrapped;
1103
+ },
1104
+ diff(uid, modules, numbers) {
1105
+ const {
1106
+ oldState,
1107
+ newState
1108
+ } = states[uid];
1109
+ const diffResult = [];
1110
+ for (let i = 0; i < modules.length; i++) {
1111
+ const fn = modules[i];
1112
+ if (!fn(oldState, newState)) {
1113
+ diffResult.push(numbers[i]);
1114
+ }
1115
+ }
1116
+ return diffResult;
1117
+ },
1118
+ getCommandIds() {
1119
+ const keys = Object.keys(commandMapRef);
1120
+ const ids = keys.map(toCommandId);
1121
+ return ids;
1122
+ },
1123
+ registerCommands(commandMap) {
1124
+ Object.assign(commandMapRef, commandMap);
1125
+ }
1126
+ };
1127
+ };
1128
+ const terminate = () => {
1129
+ globalThis.close();
1130
+ };
1131
+
1048
1132
  const CreateFolder$1 = 1;
1049
1133
  const CreateFile$1 = 2;
1050
1134
  const Copy$1 = 3;
@@ -1053,6 +1137,14 @@ const Remove = 5;
1053
1137
 
1054
1138
  const Text = 12;
1055
1139
 
1140
+ const Button$3 = 'event.button';
1141
+ const ClientX = 'event.clientX';
1142
+ const ClientY = 'event.clientY';
1143
+ const CtrlKey = 'event.ctrlKey';
1144
+ const DeltaMode = 'event.deltaMode';
1145
+ const DeltaY = 'event.deltaY';
1146
+ const TargetValue = 'event.target.value';
1147
+
1056
1148
  const Enter = 3;
1057
1149
  const Escape = 8;
1058
1150
  const Space = 9;
@@ -1078,6 +1170,11 @@ const DebugWorker = 55;
1078
1170
  const FileSystemWorker$1 = 209;
1079
1171
  const RendererWorker$1 = 1;
1080
1172
 
1173
+ const FocusElementByName = 'Viewlet.focusElementByName';
1174
+ const FocusSelector = 'Viewlet.focusSelector';
1175
+ const SetCss = 'Viewlet.setCss';
1176
+ const SetFocusContext = 'Viewlet.setFocusContext';
1177
+
1081
1178
  const FocusExplorer = 13;
1082
1179
  const FocusExplorerEditBox = 14;
1083
1180
 
@@ -1089,7 +1186,7 @@ const get$1 = id => {
1089
1186
  return rpcs[id];
1090
1187
  };
1091
1188
 
1092
- const create$2 = rpcId => {
1189
+ const create$1 = rpcId => {
1093
1190
  return {
1094
1191
  // @ts-ignore
1095
1192
  invoke(method, ...params) {
@@ -1118,7 +1215,7 @@ const {
1118
1215
  invokeAndTransfer: invokeAndTransfer$1,
1119
1216
  set: set$4,
1120
1217
  dispose: dispose$1
1121
- } = create$2(FileSystemWorker$1);
1218
+ } = create$1(FileSystemWorker$1);
1122
1219
  const remove$1 = async dirent => {
1123
1220
  return invoke$3('FileSystem.remove', dirent);
1124
1221
  };
@@ -1198,7 +1295,7 @@ const {
1198
1295
  invokeAndTransfer,
1199
1296
  set: set$3,
1200
1297
  dispose
1201
- } = create$2(RendererWorker$1);
1298
+ } = create$1(RendererWorker$1);
1202
1299
  const searchFileHtml = async uri => {
1203
1300
  return invoke$2('ExtensionHost.searchFileWithHtml', uri);
1204
1301
  };
@@ -2544,87 +2641,6 @@ const copyRelativePath = async state => {
2544
2641
  return state;
2545
2642
  };
2546
2643
 
2547
- const toCommandId = key => {
2548
- const dotIndex = key.indexOf('.');
2549
- return key.slice(dotIndex + 1);
2550
- };
2551
- const create$1 = () => {
2552
- const states = Object.create(null);
2553
- const commandMapRef = {};
2554
- return {
2555
- get(uid) {
2556
- return states[uid];
2557
- },
2558
- set(uid, oldState, newState) {
2559
- states[uid] = {
2560
- oldState,
2561
- newState
2562
- };
2563
- },
2564
- dispose(uid) {
2565
- delete states[uid];
2566
- },
2567
- getKeys() {
2568
- return Object.keys(states).map(key => {
2569
- return Number.parseInt(key);
2570
- });
2571
- },
2572
- clear() {
2573
- for (const key of Object.keys(states)) {
2574
- delete states[key];
2575
- }
2576
- },
2577
- wrapCommand(fn) {
2578
- const wrapped = async (uid, ...args) => {
2579
- const {
2580
- newState
2581
- } = states[uid];
2582
- const newerState = await fn(newState, ...args);
2583
- if (newState === newerState) {
2584
- return;
2585
- }
2586
- const latest = states[uid];
2587
- states[uid] = {
2588
- oldState: latest.oldState,
2589
- newState: newerState
2590
- };
2591
- };
2592
- return wrapped;
2593
- },
2594
- wrapGetter(fn) {
2595
- const wrapped = (uid, ...args) => {
2596
- const {
2597
- newState
2598
- } = states[uid];
2599
- return fn(newState, ...args);
2600
- };
2601
- return wrapped;
2602
- },
2603
- diff(uid, modules, numbers) {
2604
- const {
2605
- oldState,
2606
- newState
2607
- } = states[uid];
2608
- const diffResult = [];
2609
- for (let i = 0; i < modules.length; i++) {
2610
- const fn = modules[i];
2611
- if (!fn(oldState, newState)) {
2612
- diffResult.push(numbers[i]);
2613
- }
2614
- }
2615
- return diffResult;
2616
- },
2617
- getCommandIds() {
2618
- const keys = Object.keys(commandMapRef);
2619
- const ids = keys.map(toCommandId);
2620
- return ids;
2621
- },
2622
- registerCommands(commandMap) {
2623
- Object.assign(commandMapRef, commandMap);
2624
- }
2625
- };
2626
- };
2627
-
2628
2644
  const {
2629
2645
  get,
2630
2646
  set,
@@ -2632,7 +2648,7 @@ const {
2632
2648
  registerCommands,
2633
2649
  getCommandIds,
2634
2650
  wrapGetter
2635
- } = create$1();
2651
+ } = create$2();
2636
2652
 
2637
2653
  const ListItem = 22;
2638
2654
 
@@ -2685,7 +2701,8 @@ const create2 = (uid, uri, x, y, width, height, args, parentUid, platform = 0) =
2685
2701
  cutItems: [],
2686
2702
  isPointerDown: false,
2687
2703
  pointerDownIndex: -1,
2688
- sourceControlIgnoredUris: []
2704
+ sourceControlIgnoredUris: [],
2705
+ maxIndent: 0
2689
2706
  };
2690
2707
  set(uid, state, state);
2691
2708
  };
@@ -2737,12 +2754,17 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
2737
2754
  cutItems: [],
2738
2755
  isPointerDown: false,
2739
2756
  pointerDownIndex: -1,
2740
- sourceControlIgnoredUris: []
2757
+ sourceControlIgnoredUris: [],
2758
+ maxIndent: 0
2741
2759
  };
2742
2760
  set(state.uid, state, state);
2743
2761
  return state;
2744
2762
  };
2745
2763
 
2764
+ const isEqual$6 = (oldState, newState) => {
2765
+ return oldState.scrollBarHeight === newState.scrollBarHeight && oldState.scrollBarActive === newState.scrollBarActive;
2766
+ };
2767
+
2746
2768
  const isEqual$5 = (oldState, newState) => {
2747
2769
  return oldState.isPointerDown || !newState.isPointerDown;
2748
2770
  };
@@ -2765,6 +2787,7 @@ const RenderFocusContext = 7;
2765
2787
  const RenderValue = 8;
2766
2788
  const RenderSelection = 9;
2767
2789
  const RenderDragData = 10;
2790
+ const RenderCss = 11;
2768
2791
 
2769
2792
  const isEqual$1 = (oldState, newState) => {
2770
2793
  if (newState.focus !== Input$1) {
@@ -2773,8 +2796,8 @@ const isEqual$1 = (oldState, newState) => {
2773
2796
  return oldState.focus === Input$1 && newState.focus === Input$1 && oldState.editingValue === newState.editingValue;
2774
2797
  };
2775
2798
 
2776
- const modules = [isEqual$3, isEqual$4, isEqual$4, isEqual$1, isEqual$2, isEqual$5];
2777
- const numbers = [RenderItems, RenderFocus, RenderFocusContext, RenderValue, RenderSelection, RenderDragData];
2799
+ const modules = [isEqual$3, isEqual$4, isEqual$4, isEqual$1, isEqual$2, isEqual$5, isEqual$6];
2800
+ const numbers = [RenderItems, RenderFocus, RenderFocusContext, RenderValue, RenderSelection, RenderDragData, RenderCss];
2778
2801
 
2779
2802
  const diff = (oldState, newState) => {
2780
2803
  const diffResult = [];
@@ -4978,7 +5001,8 @@ const loadContent = async (state, savedState) => {
4978
5001
  pathSeparator,
4979
5002
  excluded,
4980
5003
  useChevrons,
4981
- confirmDelete
5004
+ confirmDelete,
5005
+ maxIndent: 10
4982
5006
  };
4983
5007
  };
4984
5008
 
@@ -5292,6 +5316,30 @@ const renameDirent = state => {
5292
5316
  };
5293
5317
  };
5294
5318
 
5319
+ const defaultIndent$1 = 1;
5320
+ const getTreeItemIndent = depth => {
5321
+ return `${depth * defaultIndent$1}rem`;
5322
+ };
5323
+
5324
+ const renderCss = (oldState, newState) => {
5325
+ const {
5326
+ scrollBarHeight,
5327
+ uid,
5328
+ maxIndent
5329
+ } = newState;
5330
+ const rules = [`.Explorer {
5331
+ --ScrollBarThumbHeight: ${scrollBarHeight}px;
5332
+ `];
5333
+ for (let i = 0; i < maxIndent; i++) {
5334
+ const indent = getTreeItemIndent(i);
5335
+ rules.push(`.Indent-${i} {
5336
+ padding-left: ${indent}px;
5337
+ }`);
5338
+ }
5339
+ const css = rules.join('\n');
5340
+ return [SetCss, uid, css];
5341
+ };
5342
+
5295
5343
  const getDragLabel = urls => {
5296
5344
  if (urls.length === 1) {
5297
5345
  return getBaseName('/', urls[0]);
@@ -5347,10 +5395,10 @@ const renderFocus = (oldState, newState) => {
5347
5395
  return [];
5348
5396
  }
5349
5397
  if (newState.focus === Input$1) {
5350
- return ['Viewlet.focusElementByName', ExplorerInput];
5398
+ return [FocusElementByName, ExplorerInput];
5351
5399
  }
5352
5400
  if (newState.focus === List) {
5353
- return ['Viewlet.focusSelector', '.ListItems'];
5401
+ return [FocusSelector, '.ListItems'];
5354
5402
  }
5355
5403
  // TODO
5356
5404
  // 1. when focused, focus the outer list element
@@ -5360,10 +5408,10 @@ const renderFocus = (oldState, newState) => {
5360
5408
 
5361
5409
  const renderFocusContext = (oldState, newState) => {
5362
5410
  if (newState.focus === Input$1) {
5363
- return ['Viewlet.setFocusContext', newState.uid, FocusExplorerEditBox];
5411
+ return [SetFocusContext, newState.uid, FocusExplorerEditBox];
5364
5412
  }
5365
5413
  if (newState.focus === List) {
5366
- return ['Viewlet.setFocusContext', newState.uid, FocusExplorer];
5414
+ return [SetFocusContext, newState.uid, FocusExplorer];
5367
5415
  }
5368
5416
  return [];
5369
5417
  };
@@ -5513,7 +5561,10 @@ const getInputClassName = hasEditingError => {
5513
5561
  return ExplorerInputBox;
5514
5562
  };
5515
5563
 
5516
- const getInputDom = hasEditingError => {
5564
+ const getInputDom = (isEditing, hasEditingError) => {
5565
+ if (!isEditing) {
5566
+ return [];
5567
+ }
5517
5568
  const ariaLabel = typeAFileName();
5518
5569
  return [{
5519
5570
  type: Input,
@@ -5536,7 +5587,10 @@ const label = {
5536
5587
  className: Label,
5537
5588
  childCount: 1
5538
5589
  };
5539
- const getLabelDom = (name, isDimmed) => {
5590
+ const getLabelDom = (isEditing, name, isDimmed) => {
5591
+ if (isEditing) {
5592
+ return [];
5593
+ }
5540
5594
  if (isDimmed) {
5541
5595
  return [{
5542
5596
  type: Div,
@@ -5547,13 +5601,6 @@ const getLabelDom = (name, isDimmed) => {
5547
5601
  return [label, text(name)];
5548
5602
  };
5549
5603
 
5550
- const getInputOrLabelDom = (isEditing, hasEditingError, name, isCut, isIgnored) => {
5551
- if (isEditing) {
5552
- return getInputDom(hasEditingError);
5553
- }
5554
- return getLabelDom(name, isCut || isIgnored);
5555
- };
5556
-
5557
5604
  const getExplorerItemVirtualDom = item => {
5558
5605
  const {
5559
5606
  ariaExpanded,
@@ -5590,7 +5637,7 @@ const getExplorerItemVirtualDom = item => {
5590
5637
  ariaDescription: '',
5591
5638
  id,
5592
5639
  'data-index': index
5593
- }, ...chevronDom, getFileIconVirtualDom(icon), ...getInputOrLabelDom(isEditing, hasEditingError, name, isCut, isIgnored)];
5640
+ }, ...chevronDom, getFileIconVirtualDom(icon), ...getInputDom(isEditing, hasEditingError), ...getLabelDom(isEditing, name, isCut || isIgnored)];
5594
5641
  };
5595
5642
 
5596
5643
  const getActiveDescendant = focusedIndex => {
@@ -5725,8 +5772,9 @@ const getExpandedType = type => {
5725
5772
  }
5726
5773
  };
5727
5774
 
5728
- const getTreeItemClassName = (isSelected, isFocused, isDropping) => {
5775
+ const getTreeItemClassName = (isSelected, isFocused, isDropping, useChevrons, depth) => {
5729
5776
  let className = TreeItem;
5777
+ className = mergeClassNames(className, `Indent-${depth}`);
5730
5778
  if (isSelected || isFocused) {
5731
5779
  className = mergeClassNames(className, TreeItemActive);
5732
5780
  }
@@ -5736,11 +5784,6 @@ const getTreeItemClassName = (isSelected, isFocused, isDropping) => {
5736
5784
  return className;
5737
5785
  };
5738
5786
 
5739
- const defaultIndent$1 = 1;
5740
- const getTreeItemIndent = depth => {
5741
- return `${depth * defaultIndent$1}rem`;
5742
- };
5743
-
5744
5787
  // TODO make all of these variable configurable
5745
5788
  const defaultPaddingLeft = 4;
5746
5789
  const defaultIndent = 8;
@@ -5777,7 +5820,7 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
5777
5820
  const isCut = cutItems.includes(item.path);
5778
5821
  const isDropping = dropTargets.includes(i);
5779
5822
  const isIgnored = sourceControlIgnoredUris.includes(item.path);
5780
- const className = getTreeItemClassName(isSelected, isFocused, isDropping); // TODO compute classname in dom function
5823
+ const className = getTreeItemClassName(isSelected, isFocused, isDropping, useChevrons, item.depth); // TODO compute classname in dom function
5781
5824
  const expanded = getExpandedType(item.type);
5782
5825
  const ariaExpanded = ariaExpandedValues[expanded];
5783
5826
  const isEditing = i === editingIndex;
@@ -5871,6 +5914,8 @@ const getRenderer = diffType => {
5871
5914
  return renderEditingSelection;
5872
5915
  case RenderDragData:
5873
5916
  return renderDragData;
5917
+ case RenderCss:
5918
+ return renderCss;
5874
5919
  default:
5875
5920
  throw new Error('unknown renderer');
5876
5921
  }
@@ -6006,7 +6051,7 @@ const renderEventListeners = () => {
6006
6051
  params: ['handleBlur']
6007
6052
  }, {
6008
6053
  name: HandleClick,
6009
- params: ['handleClickAt', 'event.defaultPrevented', 'event.button', 'event.ctrlKey', 'event.shiftKey', 'event.clientX', 'event.clientY'],
6054
+ params: ['handleClickAt', 'event.defaultPrevented', Button$3, CtrlKey, 'event.shiftKey', ClientX, ClientY],
6010
6055
  preventDefault: true
6011
6056
  }, {
6012
6057
  name: HandleInputClick,
@@ -6018,26 +6063,26 @@ const renderEventListeners = () => {
6018
6063
  preventDefault: true
6019
6064
  }, {
6020
6065
  name: HandlePointerDown,
6021
- params: ['handlePointerDown', 'event.button', 'event.clientX', 'event.clientY']
6066
+ params: ['handlePointerDown', Button$3, ClientX, ClientY]
6022
6067
  // preventDefault: true,
6023
6068
  }, {
6024
6069
  name: HandleEditingInput,
6025
- params: ['updateEditingValue', 'event.target.value']
6070
+ params: ['updateEditingValue', TargetValue]
6026
6071
  }, {
6027
6072
  name: HandleContextMenu,
6028
- params: ['handleContextMenu', 'event.button', 'event.clientX', 'event.clientY'],
6073
+ params: ['handleContextMenu', Button$3, ClientX, ClientY],
6029
6074
  preventDefault: true
6030
6075
  }, {
6031
6076
  name: HandleWheel,
6032
- params: ['handleWheel', 'event.deltaMode', 'event.deltaY'],
6077
+ params: ['handleWheel', DeltaMode, DeltaY],
6033
6078
  passive: true
6034
6079
  }, {
6035
6080
  name: HandleDragOver,
6036
- params: ['handleDragOver', 'event.clientX', 'event.clientY'],
6081
+ params: ['handleDragOver', ClientX, ClientY],
6037
6082
  preventDefault: true
6038
6083
  }, {
6039
6084
  name: HandleDrop,
6040
- params: ['handleDrop', 'event.clientX', 'event.clientY', 'event.dataTransfer.files2', 'event.dataTransfer.files'],
6085
+ params: ['handleDrop', ClientX, ClientY, 'event.dataTransfer.files2', 'event.dataTransfer.files'],
6041
6086
  preventDefault: true
6042
6087
  }, {
6043
6088
  name: HandleDragLeave,
@@ -6279,10 +6324,6 @@ const selectUp = state => {
6279
6324
  };
6280
6325
  };
6281
6326
 
6282
- const terminate = () => {
6283
- globalThis.close();
6284
- };
6285
-
6286
6327
  const getEditingIcon = async (editingType, value, direntType) => {
6287
6328
  if (editingType === CreateFile) {
6288
6329
  return invoke$1('IconTheme.getFileIcon', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "3.16.0",
3
+ "version": "3.18.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",