@lvce-editor/explorer-view 2.0.0 → 2.2.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.
@@ -1288,7 +1288,41 @@ const ListItem = 22;
1288
1288
  const Slash = '/';
1289
1289
 
1290
1290
  // TODO parentUid might ot be needed
1291
- const create = (id, uri, x, y, width, height, args, parentUid) => {
1291
+ const create2 = (uid, uri, x, y, width, height, args, parentUid, platform = 0) => {
1292
+ const state = {
1293
+ uid,
1294
+ parentUid,
1295
+ root: '',
1296
+ items: [],
1297
+ focusedIndex: -1,
1298
+ focused: false,
1299
+ hoverIndex: -1,
1300
+ x,
1301
+ y,
1302
+ width,
1303
+ height,
1304
+ deltaY: 0,
1305
+ minLineY: 0,
1306
+ maxLineY: 0,
1307
+ pathSeparator: Slash,
1308
+ version: 0,
1309
+ editingIndex: -1,
1310
+ itemHeight: ListItem,
1311
+ dropTargets: [],
1312
+ excluded: [],
1313
+ editingValue: '',
1314
+ editingType: None$5,
1315
+ editingIcon: '',
1316
+ fileIconCache: Object.create(null),
1317
+ useChevrons: false,
1318
+ icons: [],
1319
+ platform
1320
+ };
1321
+ set(uid, state, state);
1322
+ };
1323
+
1324
+ // TODO parentUid might ot be needed
1325
+ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) => {
1292
1326
  const state = {
1293
1327
  uid: id,
1294
1328
  parentUid,
@@ -1315,7 +1349,8 @@ const create = (id, uri, x, y, width, height, args, parentUid) => {
1315
1349
  editingIcon: '',
1316
1350
  fileIconCache: Object.create(null),
1317
1351
  useChevrons: false,
1318
- icons: []
1352
+ icons: [],
1353
+ platform
1319
1354
  };
1320
1355
  set(state.uid, state, state);
1321
1356
  return state;
@@ -1802,7 +1837,7 @@ const focusPrevious = state => {
1802
1837
  }
1803
1838
  };
1804
1839
 
1805
- const commandIds = ['acceptEdit', 'cancelEdit', 'collapseAll', 'copyPath', 'copyRelativePath', 'expandAll', 'expandRecursively', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusNone', 'focusPrevious', 'getFocusedDirent', 'handleArrowLeft', 'handleArrowLeft', 'handleArrowRight', 'handleArrowRight', 'handleBlur', 'handleClick', 'handleClickAt', 'handleClickCurrent', 'handleClickCurrentButKeepFocus', 'handleClickOpenFolder', 'handleContextMenu', 'handleCopy', 'handleDragOver', 'handleDrop', 'handleFocus', 'handleIconThemeChange', 'handleLanguagesChanged', 'handleMouseEnter', 'handleMouseLeave', 'handlePaste', 'handlePointerDown', 'handleUpload', 'handleWheel', 'handleWorkspaceChange', 'hotReload', 'newFile', 'newFolder', 'openContainingFolder', 'refresh', 'refresh', 'relealItem', 'removeDirent', 'rename', 'renameDirent', 'revealItem', 'scrollDown', 'scrollUp', 'setDeltaY', 'renderEventListeners', 'updateEditingValue', 'updateIcons'];
1840
+ const commandIds = ['acceptEdit', 'cancelEdit', 'collapseAll', 'copyPath', 'copyRelativePath', 'expandAll', 'expandRecursively', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusNone', 'focusPrevious', 'getFocusedDirent', 'handleArrowLeft', 'handleArrowLeft', 'handleArrowRight', 'handleArrowRight', 'handleBlur', 'handleClick', 'handleClickAt', 'handleClickCurrent', 'handleClickCurrentButKeepFocus', 'handleClickOpenFolder', 'handleContextMenu', 'handleCopy', 'handleDragOver', 'handleDrop', 'handleFocus', 'handleIconThemeChange', 'handleLanguagesChanged', 'handleMouseEnter', 'handleMouseLeave', 'handlePaste', 'handlePointerDown', 'handleUpload', 'handleWheel', 'handleWorkspaceChange', 'hotReload', 'newFile', 'newFolder', 'openContainingFolder', 'refresh', 'refresh', 'revealItem', 'removeDirent', 'rename', 'renameDirent', 'revealItem', 'scrollDown', 'scrollUp', 'setDeltaY', 'renderEventListeners', 'updateEditingValue', 'updateIcons'];
1806
1841
 
1807
1842
  const getCommandIds = () => {
1808
1843
  return commandIds;
@@ -2660,7 +2695,7 @@ const getModule = isElectron => {
2660
2695
  };
2661
2696
  const handleDropRoot = async (state, files) => {
2662
2697
  // @ts-ignore
2663
- const fn = await getModule(state.isElectron);
2698
+ const fn = getModule(state.isElectron);
2664
2699
  return fn(state, files);
2665
2700
  };
2666
2701
 
@@ -2806,6 +2841,7 @@ const mergeDirents = (oldDirents, newDirents) => {
2806
2841
 
2807
2842
  // TODO add lots of tests for this
2808
2843
  const updateRoot = async state1 => {
2844
+ // @ts-ignore
2809
2845
  if (state1.disposed) {
2810
2846
  return state1;
2811
2847
  }
@@ -3095,15 +3131,18 @@ const getExcluded = () => {
3095
3131
  }
3096
3132
  return excluded;
3097
3133
  };
3098
- const getSavedRoot$1 = (savedState, workspacePath) => {
3134
+ const getSavedRoot = (savedState, workspacePath) => {
3099
3135
  return workspacePath;
3100
3136
  };
3101
3137
  const loadContent = async (state, savedState) => {
3138
+ const {
3139
+ fileIconCache
3140
+ } = state;
3102
3141
  const {
3103
3142
  useChevrons
3104
3143
  } = await getSettings();
3105
3144
  const workspacePath = await getWorkspacePath();
3106
- const root = getSavedRoot$1(savedState, workspacePath);
3145
+ const root = getSavedRoot(savedState, workspacePath);
3107
3146
  // TODO path separator could be restored from saved state
3108
3147
  const pathSeparator = await getPathSeparator(root); // TODO only load path separator once
3109
3148
  const excluded = getExcluded();
@@ -3124,7 +3163,7 @@ const loadContent = async (state, savedState) => {
3124
3163
  const {
3125
3164
  icons,
3126
3165
  newFileIconCache
3127
- } = await getFileIcons(restoredDirents, Object.create(null));
3166
+ } = await getFileIcons(restoredDirents, fileIconCache);
3128
3167
  return {
3129
3168
  ...state,
3130
3169
  root,
@@ -3339,6 +3378,7 @@ const HandleListBlur = 'handleListBlur';
3339
3378
  const HandleListFocus = 'handleListFocus';
3340
3379
  const HandlePointerDown = 'handlePointerDown';
3341
3380
  const HandleWheel = 'handleWheel';
3381
+ const HandleDragOver = 'handleDragOver';
3342
3382
 
3343
3383
  const mergeClassNames = (...classNames) => {
3344
3384
  return classNames.filter(Boolean).join(' ');
@@ -3487,7 +3527,8 @@ const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused
3487
3527
  onContextMenu: HandleContextMenu,
3488
3528
  onPointerDown: HandlePointerDown,
3489
3529
  onWheel: HandleWheel,
3490
- onClick: HandleClick
3530
+ onClick: HandleClick,
3531
+ onDragOver: HandleDragOver
3491
3532
  }, ...visibleItems.flatMap(getExplorerItemVirtualDom)];
3492
3533
  return dom;
3493
3534
  };
@@ -3749,31 +3790,42 @@ const renderEventListeners = () => {
3749
3790
  name: HandleWheel,
3750
3791
  params: ['handleWheel', 'event.deltaMode', 'event.deltaY'],
3751
3792
  passive: true
3793
+ }, {
3794
+ name: HandleDragOver,
3795
+ params: ['handleDragOver', 'event.clientX', 'event.clientY']
3752
3796
  }];
3753
3797
  };
3754
3798
 
3755
- const getSavedRoot = (savedState, workspacePath) => {
3756
- return workspacePath;
3799
+ const getSavedMinLineY = savedState => {
3800
+ if (savedState && typeof savedState === 'object' && 'minLineY' in savedState && typeof savedState.minLineY === 'number') {
3801
+ return savedState.minLineY;
3802
+ }
3803
+ return 0;
3804
+ };
3805
+ const getSavedDeltaY = savedState => {
3806
+ if (savedState && typeof savedState === 'object' && 'deltaY' in savedState && typeof savedState.deltaY === 'number') {
3807
+ return savedState.deltaY;
3808
+ }
3809
+ return 0;
3810
+ };
3811
+ const getSavedWorkspacePath = savedState => {
3812
+ if (savedState && typeof savedState === 'object' && 'workspacePath' in savedState && typeof savedState.workspacePath === 'string') {
3813
+ return savedState.workspacePath;
3814
+ }
3815
+ return '';
3757
3816
  };
3758
-
3759
3817
  const restoreState = savedState => {
3760
3818
  if (!savedState) {
3761
3819
  return {
3820
+ root: '',
3762
3821
  minLineY: 0,
3763
3822
  deltaY: 0
3764
3823
  };
3765
3824
  }
3766
- const root = getSavedRoot(savedState, savedState.workspacePath || '');
3767
- let minLineY = 0;
3768
- if (savedState && typeof savedState.minLineY === 'number') {
3769
- minLineY = savedState.minLineY;
3770
- }
3771
- let deltaY = 0;
3772
- if (savedState && typeof savedState.deltaY === 'number') {
3773
- deltaY = savedState.deltaY;
3774
- }
3825
+ const root = getSavedWorkspacePath(savedState);
3826
+ const minLineY = getSavedMinLineY(savedState);
3827
+ const deltaY = getSavedDeltaY(savedState);
3775
3828
  return {
3776
- ...savedState,
3777
3829
  root,
3778
3830
  minLineY,
3779
3831
  deltaY
@@ -3866,8 +3918,8 @@ const getPathPartsToReveal = (root, pathParts, dirents) => {
3866
3918
  }
3867
3919
  return pathParts;
3868
3920
  };
3869
- const getPathPartChildren = pathPart => {
3870
- const children = getChildDirents(pathPart.pathSeparator, pathPart);
3921
+ const getPathPartChildren = async pathPart => {
3922
+ const children = await getChildDirents(pathPart.pathSeparator, pathPart);
3871
3923
  return children;
3872
3924
  };
3873
3925
  const mergeVisibleWithHiddenItems = (visibleItems, hiddenItems) => {
@@ -4097,13 +4149,13 @@ const commandMap = {
4097
4149
  'Explorer.openContainingFolder': wrapCommand(openContainingFolder),
4098
4150
  'Explorer.removeDirent': wrapCommand(removeDirent),
4099
4151
  'Explorer.renameDirent': wrapCommand(renameDirent),
4100
- 'Explorer.restoreState': wrapCommand(restoreState),
4152
+ 'Explorer.restoreState': restoreState,
4101
4153
  'Explorer.revealItem': wrapCommand(revealItem),
4102
4154
  'Explorer.setDeltaY': wrapCommand(setDeltaY),
4103
4155
  'Explorer.updateEditingValue': wrapCommand(updateEditingValue),
4104
4156
  'Explorer.updateIcons': wrapCommand(updateIcons),
4105
4157
  // not wrapped
4106
- 'Explorer.create': create,
4158
+ 'Explorer.create2': create2,
4107
4159
  'Explorer.diff2': diff2,
4108
4160
  'Explorer.getKeyBindings': getKeyBindings,
4109
4161
  'Explorer.getMenuEntries': getMenuEntries,
@@ -4111,7 +4163,9 @@ const commandMap = {
4111
4163
  'Explorer.renderActions2': renderActions,
4112
4164
  'Explorer.renderEventListeners': renderEventListeners,
4113
4165
  'Explorer.saveState': saveState,
4114
- 'Explorer.terminate': terminate
4166
+ 'Explorer.terminate': terminate,
4167
+ // deprecated
4168
+ 'Explorer.create': create
4115
4169
  };
4116
4170
 
4117
4171
  const listen = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",