@lvce-editor/explorer-view 2.60.0 → 2.62.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.
@@ -931,17 +931,34 @@ const create$2 = rpcId => {
931
931
  };
932
932
  const RendererWorker$1 = 1;
933
933
  const {
934
- invoke: invoke$4,
934
+ invoke: invoke$3,
935
935
  set: set$3} = create$2(RendererWorker$1);
936
+ const showContextMenu$1 = async (x, y, id, ...args) => {
937
+ return invoke$3('ContextMenu.show', x, y, id, ...args);
938
+ };
939
+ const confirm$1 = async (message, options) => {
940
+ // @ts-ignore
941
+ const result = await invoke$3('Confirmprompt.prompt', message, options);
942
+ return result;
943
+ };
944
+ const writeClipBoardText$1 = async text => {
945
+ await invoke$3('ClipBoard.writeText', /* text */text);
946
+ };
936
947
  const RendererWorker = {
937
948
  __proto__: null,
938
- invoke: invoke$4,
939
- set: set$3
949
+ confirm: confirm$1,
950
+ invoke: invoke$3,
951
+ set: set$3,
952
+ showContextMenu: showContextMenu$1,
953
+ writeClipBoardText: writeClipBoardText$1
940
954
  };
941
955
 
942
956
  const {
943
957
  invoke: invoke$1,
944
- set: set$1
958
+ set: set$1,
959
+ writeClipBoardText,
960
+ confirm,
961
+ showContextMenu
945
962
  } = RendererWorker;
946
963
 
947
964
  // TODO use direct connection
@@ -1870,7 +1887,7 @@ const copyPath = async state => {
1870
1887
  };
1871
1888
 
1872
1889
  const writeText = async text => {
1873
- await invoke$1('ClipBoard.writeText', /* text */text);
1890
+ await writeClipBoardText(text);
1874
1891
  };
1875
1892
  const readNativeFiles = async () => {
1876
1893
  // @ts-ignore
@@ -2004,7 +2021,8 @@ const create2 = (uid, uri, x, y, width, height, args, parentUid, platform = 0) =
2004
2021
  scrollBarHeight: 0,
2005
2022
  confirmPaste: false,
2006
2023
  pasteShouldMove: false,
2007
- cutItems: []
2024
+ cutItems: [],
2025
+ isPointerDown: false
2008
2026
  };
2009
2027
  set(uid, state, state);
2010
2028
  };
@@ -2053,7 +2071,8 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
2053
2071
  scrollBarHeight: 0,
2054
2072
  confirmPaste: false,
2055
2073
  pasteShouldMove: false,
2056
- cutItems: []
2074
+ cutItems: [],
2075
+ isPointerDown: false
2057
2076
  };
2058
2077
  set(state.uid, state, state);
2059
2078
  return state;
@@ -2064,6 +2083,7 @@ const RenderFocus = 6;
2064
2083
  const RenderFocusContext = 7;
2065
2084
  const RenderValue = 8;
2066
2085
  const RenderSelection = 9;
2086
+ const RenderDragData = 10;
2067
2087
 
2068
2088
  const diffType$3 = RenderFocus;
2069
2089
  const isEqual$4 = (oldState, newState) => {
@@ -2391,7 +2411,7 @@ const focusPrevious = state => {
2391
2411
  }
2392
2412
  };
2393
2413
 
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'];
2414
+ 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', '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'];
2395
2415
 
2396
2416
  const getCommandIds = () => {
2397
2417
  return commandIds;
@@ -3090,14 +3110,44 @@ const handleClickAtRangeSelection = async (state, index) => {
3090
3110
  return handleRangeSelection(state, min, max);
3091
3111
  };
3092
3112
 
3113
+ const toggleIndividualSelection = async (state, index) => {
3114
+ const {
3115
+ items
3116
+ } = state;
3117
+
3118
+ // If index is out of range, do nothing
3119
+ if (index < 0 || index >= items.length) {
3120
+ return state;
3121
+ }
3122
+ const newItems = items.map((item, i) => ({
3123
+ ...item,
3124
+ selected: i === index ? !item.selected : item.selected
3125
+ }));
3126
+ return {
3127
+ ...state,
3128
+ items: newItems
3129
+ };
3130
+ };
3131
+
3093
3132
  const handleClickAt = async (state, defaultPrevented, button, ctrlKey, shiftKey, x, y) => {
3094
3133
  if (defaultPrevented || button !== LeftClick) {
3095
3134
  return state;
3096
3135
  }
3097
3136
  const index = getIndexFromPosition(state, x, y);
3137
+ if (index === -1) {
3138
+ return {
3139
+ ...state,
3140
+ focused: true,
3141
+ focusedIndex: -1
3142
+ // TODO mark all items as not selected
3143
+ };
3144
+ }
3098
3145
  if (shiftKey) {
3099
3146
  return handleClickAtRangeSelection(state, index);
3100
3147
  }
3148
+ if (ctrlKey) {
3149
+ return toggleIndividualSelection(state, index);
3150
+ }
3101
3151
  return handleClick(state, index);
3102
3152
  };
3103
3153
 
@@ -3119,7 +3169,7 @@ const handleClickOpenFolder = async state => {
3119
3169
  };
3120
3170
 
3121
3171
  const show = async (x, y, id, ...args) => {
3122
- return invoke$1('ContextMenu.show', x, y, id, ...args);
3172
+ return showContextMenu(x, y, id, ...args);
3123
3173
  };
3124
3174
 
3125
3175
  const Explorer$1 = 4;
@@ -3213,14 +3263,6 @@ const handleCut = async state => {
3213
3263
 
3214
3264
  const handleDragLeave = state => {
3215
3265
  return state;
3216
- // const { dropTargets } = state
3217
- // if (dropTargets.length === 0) {
3218
- // return state
3219
- // }
3220
- // return {
3221
- // ...state,
3222
- // dropTargets: [],
3223
- // }
3224
3266
  };
3225
3267
 
3226
3268
  const canBeDroppedInto = dirent => {
@@ -3286,6 +3328,10 @@ const handleDragOver = (state, x, y) => {
3286
3328
  };
3287
3329
  };
3288
3330
 
3331
+ const handleDragStart = state => {
3332
+ return state;
3333
+ };
3334
+
3289
3335
  const isExpanded = item => {
3290
3336
  return item.type === DirectoryExpanded || item.type === DirectoryExpanding;
3291
3337
  };
@@ -4284,6 +4330,10 @@ const handleWorkspaceChange = async state => {
4284
4330
  return newState;
4285
4331
  };
4286
4332
 
4333
+ const initialize = async () => {
4334
+ // TODO create file system worker connection
4335
+ };
4336
+
4287
4337
  const ExplorerEditBox = FocusExplorerEditBox;
4288
4338
 
4289
4339
  const getNewChildDirentsForNewDirent = async (items, depth, parentPath, direntType) => {
@@ -4452,7 +4502,7 @@ const confirmDelete = async paths => {
4452
4502
  // TODO use i18n string
4453
4503
  const message = paths.length === 1 ? `Are you sure you want to delete "${paths[0]}"?` : `Are you sure you want to delete ${paths.length} items?`;
4454
4504
  // @ts-ignore
4455
- const result = await invoke$1('Confirmprompt.prompt', message);
4505
+ const result = await confirm(message);
4456
4506
  return result === true;
4457
4507
  };
4458
4508
 
@@ -4560,6 +4610,15 @@ const renameDirent = state => {
4560
4610
  };
4561
4611
  };
4562
4612
 
4613
+ const renderDragData = (oldState, newState) => {
4614
+ // TODO send selected urls
4615
+ const dragData = [{
4616
+ type: 'text/plain',
4617
+ data: 'https://example.com'
4618
+ }];
4619
+ return ['Viewlet.setDragData', newState.uid, dragData];
4620
+ };
4621
+
4563
4622
  const ExplorerInput = 'ExplorerInput';
4564
4623
 
4565
4624
  const renderEditingSelection = (oldState, newState) => {
@@ -4670,19 +4729,20 @@ const getErrorMessageDom = (errorMessage, errorMessageLeft, errorMessageTop) =>
4670
4729
  }, text(errorMessage)];
4671
4730
  };
4672
4731
 
4673
- const HandleClick = 'handleClick';
4674
- const HandleClickOpenFolder = 'handleClickOpenFolder';
4675
- const HandleContextMenu = 'handleContextMenu';
4676
- const HandleDragLeave = 'handleDragLeave';
4677
- const HandleDragOver = 'handleDragOver';
4678
- const HandleDrop = 'handleDrop';
4679
- const HandleEditingInput = 'handleEditingInput';
4680
- const HandleInputBlur = 'handleInputBlur';
4681
- const HandleInputClick = 'handleInputClick';
4682
- const HandleListBlur = 'handleListBlur';
4683
- const HandleListFocus = 'handleListFocus';
4684
- const HandlePointerDown = 'handlePointerDown';
4685
- const HandleWheel = 'handleWheel';
4732
+ const HandleClick = 1;
4733
+ const HandleClickOpenFolder = 2;
4734
+ const HandleContextMenu = 3;
4735
+ const HandleDragLeave = 4;
4736
+ const HandleDragOver = 5;
4737
+ const HandleDrop = 6;
4738
+ const HandleEditingInput = 7;
4739
+ const HandleInputBlur = 8;
4740
+ const HandleInputClick = 9;
4741
+ const HandleListBlur = 11;
4742
+ const HandleListFocus = 12;
4743
+ const HandlePointerDown = 14;
4744
+ const HandleWheel = 15;
4745
+ const HandleDragStart = 17;
4686
4746
 
4687
4747
  const getExplorerWelcomeVirtualDom = isWide => {
4688
4748
  return [{
@@ -4796,7 +4856,8 @@ const getExplorerItemVirtualDom = item => {
4796
4856
  path,
4797
4857
  setSize,
4798
4858
  posInSet,
4799
- isCut
4859
+ isCut,
4860
+ index
4800
4861
  } = item;
4801
4862
  const chevronDom = getChevronVirtualDom(chevron);
4802
4863
  return [{
@@ -4813,7 +4874,8 @@ const getExplorerItemVirtualDom = item => {
4813
4874
  ariaLabel: name,
4814
4875
  ariaExpanded,
4815
4876
  ariaDescription: '',
4816
- id
4877
+ id,
4878
+ 'data-index': index
4817
4879
  }, ...chevronDom, getFileIconVirtualDom(icon), ...getInputOrLabelDom(isEditing, hasEditingError, name, isCut)];
4818
4880
  };
4819
4881
 
@@ -5021,7 +5083,8 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
5021
5083
  chevron,
5022
5084
  id,
5023
5085
  className,
5024
- isCut
5086
+ isCut,
5087
+ index: i
5025
5088
  });
5026
5089
  }
5027
5090
  return visible;
@@ -5088,6 +5151,8 @@ const getRenderer = diffType => {
5088
5151
  return renderValue;
5089
5152
  case RenderSelection:
5090
5153
  return renderEditingSelection;
5154
+ case RenderDragData:
5155
+ return renderDragData;
5091
5156
  default:
5092
5157
  throw new Error('unknown renderer');
5093
5158
  }
@@ -5259,6 +5324,13 @@ const renderEventListeners = () => {
5259
5324
  }, {
5260
5325
  name: HandleDragLeave,
5261
5326
  params: ['handleDragLeave']
5327
+ }, {
5328
+ name: HandleDragStart,
5329
+ params: ['handleDragStart'],
5330
+ // @ts-ignore
5331
+ dragInfo: {
5332
+ 'text/uri': 'abc'
5333
+ }
5262
5334
  }];
5263
5335
  };
5264
5336
 
@@ -5555,6 +5627,7 @@ const commandMap = {
5555
5627
  'Explorer.focusFirst': wrapCommand(focusFirst),
5556
5628
  'Explorer.focusIndex': wrapCommand(focusIndex),
5557
5629
  'Explorer.focusLast': wrapCommand(focusLast),
5630
+ 'Explorer.handleDragStart': wrapCommand(handleDragStart),
5558
5631
  'Explorer.focusNext': wrapCommand(focusNext),
5559
5632
  'Explorer.focusNone': wrapCommand(focusNone),
5560
5633
  'Explorer.focusPrevious': wrapCommand(focusPrevious),
@@ -5598,10 +5671,11 @@ const commandMap = {
5598
5671
  'Explorer.revealItem': wrapCommand(revealItem),
5599
5672
  'Explorer.selectAll': wrapCommand(selectAll),
5600
5673
  'Explorer.selectDown': wrapCommand(selectDown),
5674
+ 'Explorer.selectIndices': wrapCommand(setSelectedIndices),
5601
5675
  'Explorer.selectUp': wrapCommand(selectUp),
5602
5676
  'Explorer.setDeltaY': wrapCommand(setDeltaY),
5603
5677
  'Explorer.setSelectedIndices': wrapCommand(setSelectedIndices),
5604
- 'Explorer.selectIndices': wrapCommand(setSelectedIndices),
5678
+ 'Explorer.toggleIndividualSelection': wrapCommand(toggleIndividualSelection),
5605
5679
  'Explorer.updateEditingValue': wrapCommand(updateEditingValue),
5606
5680
  'Explorer.updateIcons': wrapCommand(updateIcons),
5607
5681
  // not wrapped
@@ -5614,6 +5688,7 @@ const commandMap = {
5614
5688
  'Explorer.renderEventListeners': renderEventListeners,
5615
5689
  'Explorer.saveState': saveState,
5616
5690
  'Explorer.terminate': terminate,
5691
+ 'Explorer.initialize': initialize,
5617
5692
  // deprecated
5618
5693
  'Explorer.create': create
5619
5694
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "2.60.0",
3
+ "version": "2.62.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",