@lvce-editor/explorer-view 2.58.0 → 2.59.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.
@@ -60,49 +60,57 @@ class AssertionError extends Error {
60
60
  this.name = 'AssertionError';
61
61
  }
62
62
  }
63
+ const Object$1 = 1;
64
+ const Number$1 = 2;
65
+ const Array$1 = 3;
66
+ const String = 4;
67
+ const Boolean$1 = 5;
68
+ const Function = 6;
69
+ const Null = 7;
70
+ const Unknown$1 = 8;
63
71
  const getType = value => {
64
72
  switch (typeof value) {
65
73
  case 'number':
66
- return 'number';
74
+ return Number$1;
67
75
  case 'function':
68
- return 'function';
76
+ return Function;
69
77
  case 'string':
70
- return 'string';
78
+ return String;
71
79
  case 'object':
72
80
  if (value === null) {
73
- return 'null';
81
+ return Null;
74
82
  }
75
83
  if (Array.isArray(value)) {
76
- return 'array';
84
+ return Array$1;
77
85
  }
78
- return 'object';
86
+ return Object$1;
79
87
  case 'boolean':
80
- return 'boolean';
88
+ return Boolean$1;
81
89
  default:
82
- return 'unknown';
90
+ return Unknown$1;
83
91
  }
84
92
  };
85
93
  const object = value => {
86
94
  const type = getType(value);
87
- if (type !== 'object') {
95
+ if (type !== Object$1) {
88
96
  throw new AssertionError('expected value to be of type object');
89
97
  }
90
98
  };
91
99
  const number = value => {
92
100
  const type = getType(value);
93
- if (type !== 'number') {
101
+ if (type !== Number$1) {
94
102
  throw new AssertionError('expected value to be of type number');
95
103
  }
96
104
  };
97
105
  const array = value => {
98
106
  const type = getType(value);
99
- if (type !== 'array') {
107
+ if (type !== Array$1) {
100
108
  throw new AssertionError('expected value to be of type array');
101
109
  }
102
110
  };
103
111
  const string = value => {
104
112
  const type = getType(value);
105
- if (type !== 'string') {
113
+ if (type !== String) {
106
114
  throw new AssertionError('expected value to be of type string');
107
115
  }
108
116
  };
@@ -923,11 +931,11 @@ const create$2 = rpcId => {
923
931
  };
924
932
  const RendererWorker$1 = 1;
925
933
  const {
926
- invoke: invoke$3,
934
+ invoke: invoke$4,
927
935
  set: set$3} = create$2(RendererWorker$1);
928
936
  const RendererWorker = {
929
937
  __proto__: null,
930
- invoke: invoke$3,
938
+ invoke: invoke$4,
931
939
  set: set$3
932
940
  };
933
941
 
@@ -2383,7 +2391,7 @@ const focusPrevious = state => {
2383
2391
  }
2384
2392
  };
2385
2393
 
2386
- const commandIds = ['acceptEdit', 'cancelEdit', 'cancelTypeAhead', 'collapseAll', 'copyPath', 'copyRelativePath', 'dispose', 'expandAll', 'expandRecursively', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'handleCut', 'focusNext', 'focusNone', 'focusPrevious', 'getFocusedDirent', 'getMenuEntries2', 'getMouseActions', 'handleArrowLeft', 'handleArrowLeft', 'handleArrowRight', 'handleArrowRight', 'handleBlur', 'handleClick', 'handleClickAt', 'handleClickCurrent', 'handleClickCurrentButKeepFocus', 'handleClickOpenFolder', 'handleContextMenu', 'handleContextMenuKeyboard', 'handleCopy', 'handleDragLeave', 'handleDragOver', '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', 'selectUp', 'setDeltaY', 'setSelectedIndices', 'updateEditingValue', 'updateIcons'];
2394
+ const commandIds = ['acceptEdit', 'cancelEdit', 'cancelTypeAhead', 'collapseAll', 'copyPath', 'copyRelativePath', 'dispose', 'expandAll', 'expandRecursively', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'handleCut', 'selectIndices', 'focusNext', 'focusNone', 'focusPrevious', 'getFocusedDirent', 'getMenuEntries2', 'getMouseActions', 'handleArrowLeft', 'handleArrowLeft', 'handleArrowRight', 'handleArrowRight', 'handleBlur', 'handleClick', 'handleClickAt', 'handleClickCurrent', 'handleClickCurrentButKeepFocus', 'handleClickOpenFolder', 'handleContextMenu', 'handleContextMenuKeyboard', 'handleCopy', 'handleDragLeave', 'handleDragOver', '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', 'selectUp', 'setDeltaY', 'setSelectedIndices', 'updateEditingValue', 'updateIcons'];
2387
2395
 
2388
2396
  const getCommandIds = () => {
2389
2397
  return commandIds;
@@ -3177,17 +3185,24 @@ const handleCopy = async state => {
3177
3185
  };
3178
3186
  };
3179
3187
 
3188
+ const getSelectedItems = (items, focusedIndex) => {
3189
+ const dirent = items[focusedIndex];
3190
+ const selectedItems = items.filter(item => item.selected || item === dirent);
3191
+ return selectedItems;
3192
+ };
3193
+
3180
3194
  const handleCut = async state => {
3181
3195
  // TODO handle multiple files
3182
3196
  // TODO if not file is selected, what happens?
3183
- const dirent = getFocusedDirent$1(state);
3184
- if (!dirent) {
3185
- console.error('[ViewletExplorer/handleCut] no dirent selected');
3197
+ const {
3198
+ items,
3199
+ focusedIndex
3200
+ } = state;
3201
+ const dirents = getSelectedItems(items, focusedIndex);
3202
+ if (dirents.length === 0) {
3186
3203
  return state;
3187
3204
  }
3188
- const absolutePath = dirent.path;
3189
- // TODO handle cut error gracefully
3190
- const files = [absolutePath];
3205
+ const files = dirents.map(dirent => dirent.path);
3191
3206
  await writeNativeFiles('cut', files);
3192
3207
  return {
3193
3208
  ...state,
@@ -3960,13 +3975,15 @@ const handlePasteCut = async (state, nativeFiles) => {
3960
3975
  const adjustedState = adjustScrollAfterPaste(latestState, pastedFileIndex);
3961
3976
  return {
3962
3977
  ...adjustedState,
3963
- pasteShouldMove: false
3978
+ pasteShouldMove: false,
3979
+ cutItems: []
3964
3980
  };
3965
3981
  }
3966
3982
  }
3967
3983
  return {
3968
3984
  ...latestState,
3969
- pasteShouldMove: false
3985
+ pasteShouldMove: false,
3986
+ cutItems: []
3970
3987
  };
3971
3988
  };
3972
3989
 
@@ -4439,12 +4456,6 @@ const confirmDelete = async paths => {
4439
4456
  return result === true;
4440
4457
  };
4441
4458
 
4442
- const getSelectedItems = (items, focusedIndex) => {
4443
- const dirent = items[focusedIndex];
4444
- const selectedItems = items.filter(item => item.selected || item === dirent);
4445
- return selectedItems;
4446
- };
4447
-
4448
4459
  const removePaths = async paths => {
4449
4460
  for (const item of paths) {
4450
4461
  try {
@@ -5590,6 +5601,7 @@ const commandMap = {
5590
5601
  'Explorer.selectUp': wrapCommand(selectUp),
5591
5602
  'Explorer.setDeltaY': wrapCommand(setDeltaY),
5592
5603
  'Explorer.setSelectedIndices': wrapCommand(setSelectedIndices),
5604
+ 'Explorer.selectIndices': wrapCommand(setSelectedIndices),
5593
5605
  'Explorer.updateEditingValue': wrapCommand(updateEditingValue),
5594
5606
  'Explorer.updateIcons': wrapCommand(updateIcons),
5595
5607
  // not wrapped
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "2.58.0",
3
+ "version": "2.59.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",