@lvce-editor/explorer-view 2.5.0 → 2.6.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.
- package/dist/explorerViewWorkerMain.js +82 -31
- package/package.json +1 -1
|
@@ -1845,7 +1845,7 @@ const focusPrevious = state => {
|
|
|
1845
1845
|
}
|
|
1846
1846
|
};
|
|
1847
1847
|
|
|
1848
|
-
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', '
|
|
1848
|
+
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', 'handleDragLeave', 'handleDragOver', 'handleDrop', 'handleFocus', 'handleIconThemeChange', 'handleLanguagesChanged', 'handleMouseEnter', 'handleMouseLeave', 'handlePaste', 'handlePointerDown', 'handleUpload', 'handleWheel', 'handleWorkspaceChange', 'hotReload', 'newFile', 'newFolder', 'openContainingFolder', 'refresh', 'refresh', 'removeDirent', 'rename', 'renameDirent', 'renderEventListeners', 'revealItem', 'revealItem', 'scrollDown', 'scrollUp', 'setDeltaY', 'updateEditingValue', 'updateIcons'];
|
|
1849
1849
|
|
|
1850
1850
|
const getCommandIds = () => {
|
|
1851
1851
|
return commandIds;
|
|
@@ -2561,6 +2561,19 @@ const handleCopy = async state => {
|
|
|
2561
2561
|
return state;
|
|
2562
2562
|
};
|
|
2563
2563
|
|
|
2564
|
+
const handleDragLeave = state => {
|
|
2565
|
+
const {
|
|
2566
|
+
dropTargets
|
|
2567
|
+
} = state;
|
|
2568
|
+
if (dropTargets.length === 0) {
|
|
2569
|
+
return state;
|
|
2570
|
+
}
|
|
2571
|
+
return {
|
|
2572
|
+
...state,
|
|
2573
|
+
dropTargets: []
|
|
2574
|
+
};
|
|
2575
|
+
};
|
|
2576
|
+
|
|
2564
2577
|
const canBeDroppedInto = dirent => {
|
|
2565
2578
|
if (!dirent) {
|
|
2566
2579
|
return false;
|
|
@@ -2658,6 +2671,9 @@ const applyOperation = operation => {
|
|
|
2658
2671
|
if (operation.type === 'createFolder') {
|
|
2659
2672
|
return mkdir(operation.path);
|
|
2660
2673
|
}
|
|
2674
|
+
if (operation.type === 'copy') {
|
|
2675
|
+
return copy$1(operation.from || '', operation.path);
|
|
2676
|
+
}
|
|
2661
2677
|
return writeFile(operation.path, operation.text);
|
|
2662
2678
|
};
|
|
2663
2679
|
const applyFileOperations = async operations => {
|
|
@@ -2753,16 +2769,19 @@ const getMergedDirents$2 = async (root, pathSeparator, dirents) => {
|
|
|
2753
2769
|
const mergedDirents = mergeDirents$1(dirents, childDirents);
|
|
2754
2770
|
return mergedDirents;
|
|
2755
2771
|
};
|
|
2756
|
-
const handleDrop$2 = async (state, files) => {
|
|
2772
|
+
const handleDrop$2 = async (state, fileHandles, files) => {
|
|
2757
2773
|
const {
|
|
2758
2774
|
root,
|
|
2759
2775
|
pathSeparator,
|
|
2760
2776
|
items
|
|
2761
2777
|
} = state;
|
|
2762
|
-
const handled = await uploadFileSystemHandles(root, pathSeparator,
|
|
2778
|
+
const handled = await uploadFileSystemHandles(root, pathSeparator, fileHandles);
|
|
2763
2779
|
if (handled) {
|
|
2764
2780
|
const updated = await refresh(state);
|
|
2765
|
-
return
|
|
2781
|
+
return {
|
|
2782
|
+
...updated,
|
|
2783
|
+
dropTargets: []
|
|
2784
|
+
};
|
|
2766
2785
|
}
|
|
2767
2786
|
const mergedDirents = await getMergedDirents$2(root, pathSeparator, items);
|
|
2768
2787
|
return {
|
|
@@ -2772,22 +2791,44 @@ const handleDrop$2 = async (state, files) => {
|
|
|
2772
2791
|
};
|
|
2773
2792
|
};
|
|
2774
2793
|
|
|
2794
|
+
const getFileOperationsElectron = async (root, paths, fileHandles) => {
|
|
2795
|
+
const operations = [];
|
|
2796
|
+
for (let i = 0; i < paths.length; i++) {
|
|
2797
|
+
const fileHandle = fileHandles[i];
|
|
2798
|
+
const name = fileHandle.name;
|
|
2799
|
+
const path = paths[i];
|
|
2800
|
+
operations.push({
|
|
2801
|
+
type: 'copy',
|
|
2802
|
+
path: `${root}/${name}`,
|
|
2803
|
+
text: '',
|
|
2804
|
+
from: path
|
|
2805
|
+
});
|
|
2806
|
+
}
|
|
2807
|
+
return operations;
|
|
2808
|
+
};
|
|
2809
|
+
|
|
2775
2810
|
const getFilePathElectron = async file => {
|
|
2776
|
-
return invoke('
|
|
2811
|
+
return invoke('FileSystemHandle.getFilePathElectron', file);
|
|
2777
2812
|
};
|
|
2778
2813
|
|
|
2779
|
-
const
|
|
2780
|
-
return
|
|
2814
|
+
const getFilepath = async file => {
|
|
2815
|
+
return getFilePathElectron(file);
|
|
2816
|
+
};
|
|
2817
|
+
const getFilePaths = async files => {
|
|
2818
|
+
const promises = files.map(getFilepath);
|
|
2819
|
+
const paths = await Promise.all(promises);
|
|
2820
|
+
return paths;
|
|
2781
2821
|
};
|
|
2782
2822
|
|
|
2783
2823
|
// TODO copy files in parallel
|
|
2784
|
-
const copyFilesElectron = async (root, pathSeparator, files) => {
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2824
|
+
const copyFilesElectron = async (root, pathSeparator, fileHandles, files) => {
|
|
2825
|
+
const paths = await getFilePaths(files);
|
|
2826
|
+
const operations = await getFileOperationsElectron(root, paths, fileHandles);
|
|
2827
|
+
await applyFileOperations(operations);
|
|
2828
|
+
};
|
|
2829
|
+
|
|
2830
|
+
const mergeDirents = (oldDirents, newDirents) => {
|
|
2831
|
+
return newDirents;
|
|
2791
2832
|
};
|
|
2792
2833
|
const getMergedDirents$1 = async (root, pathSeparator, dirents) => {
|
|
2793
2834
|
const childDirents = await getChildDirents(pathSeparator, {
|
|
@@ -2797,13 +2838,13 @@ const getMergedDirents$1 = async (root, pathSeparator, dirents) => {
|
|
|
2797
2838
|
const mergedDirents = mergeDirents(dirents, childDirents);
|
|
2798
2839
|
return mergedDirents;
|
|
2799
2840
|
};
|
|
2800
|
-
const handleDrop$1 = async (state, files) => {
|
|
2841
|
+
const handleDrop$1 = async (state, fileHandles, files) => {
|
|
2801
2842
|
const {
|
|
2802
2843
|
root,
|
|
2803
2844
|
pathSeparator,
|
|
2804
2845
|
items
|
|
2805
2846
|
} = state;
|
|
2806
|
-
await copyFilesElectron(root, pathSeparator, files);
|
|
2847
|
+
await copyFilesElectron(root, pathSeparator, fileHandles, files);
|
|
2807
2848
|
const mergedDirents = await getMergedDirents$1(root, pathSeparator, items);
|
|
2808
2849
|
return {
|
|
2809
2850
|
...state,
|
|
@@ -2812,16 +2853,18 @@ const handleDrop$1 = async (state, files) => {
|
|
|
2812
2853
|
};
|
|
2813
2854
|
};
|
|
2814
2855
|
|
|
2856
|
+
const Electron = 2;
|
|
2857
|
+
|
|
2815
2858
|
const getModule = isElectron => {
|
|
2816
2859
|
if (isElectron) {
|
|
2817
2860
|
return handleDrop$1;
|
|
2818
2861
|
}
|
|
2819
2862
|
return handleDrop$2;
|
|
2820
2863
|
};
|
|
2821
|
-
const handleDropRoot = async (state, files) => {
|
|
2822
|
-
|
|
2823
|
-
const fn = getModule(
|
|
2824
|
-
return fn(state, files);
|
|
2864
|
+
const handleDropRoot = async (state, fileHandles, files) => {
|
|
2865
|
+
const isElectron = state.platform === Electron;
|
|
2866
|
+
const fn = getModule(isElectron);
|
|
2867
|
+
return fn(state, fileHandles, files);
|
|
2825
2868
|
};
|
|
2826
2869
|
|
|
2827
2870
|
const getEndIndex = (items, index, dirent) => {
|
|
@@ -2841,13 +2884,13 @@ const getMergedDirents = (items, index, dirent, childDirents) => {
|
|
|
2841
2884
|
}, ...childDirents, ...items.slice(endIndex)];
|
|
2842
2885
|
return mergedDirents;
|
|
2843
2886
|
};
|
|
2844
|
-
const handleDropIntoFolder = async (state, dirent, index, files) => {
|
|
2887
|
+
const handleDropIntoFolder = async (state, dirent, index, fileHandles, files) => {
|
|
2845
2888
|
const {
|
|
2846
2889
|
pathSeparator,
|
|
2847
2890
|
items
|
|
2848
2891
|
} = state;
|
|
2849
2892
|
// @ts-ignore
|
|
2850
|
-
for (const file of
|
|
2893
|
+
for (const file of fileHandles) {
|
|
2851
2894
|
// TODO path basename
|
|
2852
2895
|
const baseName = file.name;
|
|
2853
2896
|
const to = dirent.path + pathSeparator + baseName;
|
|
@@ -2863,18 +2906,18 @@ const handleDropIntoFolder = async (state, dirent, index, files) => {
|
|
|
2863
2906
|
dropTargets: []
|
|
2864
2907
|
};
|
|
2865
2908
|
};
|
|
2866
|
-
const handleDropIntoFile = (state, dirent, index, files) => {
|
|
2909
|
+
const handleDropIntoFile = (state, dirent, index, fileHandles, files) => {
|
|
2867
2910
|
const {
|
|
2868
2911
|
items
|
|
2869
2912
|
} = state;
|
|
2870
2913
|
const parentIndex = getParentStartIndex(items, index);
|
|
2871
2914
|
if (parentIndex === -1) {
|
|
2872
|
-
return handleDropRoot(state, files);
|
|
2915
|
+
return handleDropRoot(state, fileHandles, files);
|
|
2873
2916
|
}
|
|
2874
2917
|
// @ts-ignore
|
|
2875
2918
|
return handleDropIndex(parentIndex);
|
|
2876
2919
|
};
|
|
2877
|
-
const handleDropIndex = async (state, files, index) => {
|
|
2920
|
+
const handleDropIndex = async (state, fileHandles, files, index) => {
|
|
2878
2921
|
const {
|
|
2879
2922
|
items
|
|
2880
2923
|
} = state;
|
|
@@ -2885,9 +2928,9 @@ const handleDropIndex = async (state, files, index) => {
|
|
|
2885
2928
|
switch (dirent.type) {
|
|
2886
2929
|
case Directory:
|
|
2887
2930
|
case DirectoryExpanded:
|
|
2888
|
-
return handleDropIntoFolder(state, dirent, index,
|
|
2931
|
+
return handleDropIntoFolder(state, dirent, index, fileHandles);
|
|
2889
2932
|
case File:
|
|
2890
|
-
return handleDropIntoFile(state, dirent, index, files);
|
|
2933
|
+
return handleDropIntoFile(state, dirent, index, fileHandles, files);
|
|
2891
2934
|
default:
|
|
2892
2935
|
return state;
|
|
2893
2936
|
}
|
|
@@ -2907,12 +2950,14 @@ const getFileHandles = async fileIds => {
|
|
|
2907
2950
|
return files;
|
|
2908
2951
|
};
|
|
2909
2952
|
|
|
2910
|
-
const handleDrop = async (state, x, y, fileIds) => {
|
|
2953
|
+
const handleDrop = async (state, x, y, fileIds, fileList) => {
|
|
2911
2954
|
try {
|
|
2912
|
-
|
|
2955
|
+
// @ts-ignore
|
|
2956
|
+
const files = [...fileList];
|
|
2957
|
+
const fileHandles = await getFileHandles(fileIds);
|
|
2913
2958
|
const index = getIndexFromPosition(state, x, y);
|
|
2914
2959
|
const fn = getDropHandler(index);
|
|
2915
|
-
const result = await fn(state, files, index);
|
|
2960
|
+
const result = await fn(state, fileHandles, files, index);
|
|
2916
2961
|
return result;
|
|
2917
2962
|
} catch (error) {
|
|
2918
2963
|
throw new VError(error, 'Failed to drop files');
|
|
@@ -3502,6 +3547,7 @@ const HandlePointerDown = 'handlePointerDown';
|
|
|
3502
3547
|
const HandleWheel = 'handleWheel';
|
|
3503
3548
|
const HandleDragOver = 'handleDragOver';
|
|
3504
3549
|
const HandleDrop = 'handleDrop';
|
|
3550
|
+
const HandleDragLeave = 'handleDragLeave';
|
|
3505
3551
|
|
|
3506
3552
|
const mergeClassNames = (...classNames) => {
|
|
3507
3553
|
return classNames.filter(Boolean).join(' ');
|
|
@@ -3653,6 +3699,7 @@ const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused
|
|
|
3653
3699
|
onBlur: HandleListBlur,
|
|
3654
3700
|
onClick: HandleClick,
|
|
3655
3701
|
onContextMenu: HandleContextMenu,
|
|
3702
|
+
onDragLeave: HandleDragLeave,
|
|
3656
3703
|
onDragOver: HandleDragOver,
|
|
3657
3704
|
onDrop: HandleDrop,
|
|
3658
3705
|
onFocus: HandleListFocus,
|
|
@@ -3925,8 +3972,11 @@ const renderEventListeners = () => {
|
|
|
3925
3972
|
preventDefault: true
|
|
3926
3973
|
}, {
|
|
3927
3974
|
name: HandleDrop,
|
|
3928
|
-
params: ['handleDrop', 'event.clientX', 'event.clientY', 'event.dataTransfer.files2'],
|
|
3975
|
+
params: ['handleDrop', 'event.clientX', 'event.clientY', 'event.dataTransfer.files2', 'event.dataTransfer.files'],
|
|
3929
3976
|
preventDefault: true
|
|
3977
|
+
}, {
|
|
3978
|
+
name: HandleDragLeave,
|
|
3979
|
+
params: ['handleDragLeave']
|
|
3930
3980
|
}];
|
|
3931
3981
|
};
|
|
3932
3982
|
|
|
@@ -4268,6 +4318,7 @@ const commandMap = {
|
|
|
4268
4318
|
'Explorer.handleClickOpenFolder': wrapCommand(handleClickOpenFolder),
|
|
4269
4319
|
'Explorer.handleContextMenu': wrapCommand(handleContextMenu),
|
|
4270
4320
|
'Explorer.handleCopy': wrapCommand(handleCopy),
|
|
4321
|
+
'Explorer.handleDragLeave': wrapCommand(handleDragLeave),
|
|
4271
4322
|
'Explorer.handleDragOver': wrapCommand(handleDragOver),
|
|
4272
4323
|
'Explorer.handleDrop': wrapCommand(handleDrop),
|
|
4273
4324
|
'Explorer.handleFocus': wrapCommand(handleFocus),
|