@lvce-editor/explorer-view 5.17.0 → 5.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.
- package/dist/explorerViewWorkerMain.js +52 -28
- package/package.json +1 -1
|
@@ -1120,7 +1120,6 @@ const readDirWithFileTypes$1 = async uri => {
|
|
|
1120
1120
|
return invoke$4('FileSystem.readDirWithFileTypes', uri);
|
|
1121
1121
|
};
|
|
1122
1122
|
const getPathSeparator$2 = async root => {
|
|
1123
|
-
// @ts-ignore
|
|
1124
1123
|
return invoke$4('FileSystem.getPathSeparator', root);
|
|
1125
1124
|
};
|
|
1126
1125
|
const getRealPath$1 = async path => {
|
|
@@ -1148,21 +1147,23 @@ const copy$2 = async (oldUri, newUri) => {
|
|
|
1148
1147
|
return invoke$4('FileSystem.copy', oldUri, newUri);
|
|
1149
1148
|
};
|
|
1150
1149
|
const exists = async uri => {
|
|
1151
|
-
// @ts-ignore
|
|
1152
1150
|
return invoke$4('FileSystem.exists', uri);
|
|
1153
1151
|
};
|
|
1154
1152
|
const getFolderSize = async uri => {
|
|
1155
|
-
// @ts-ignore
|
|
1156
1153
|
return invoke$4('FileSystem.getFolderSize', uri);
|
|
1157
1154
|
};
|
|
1158
1155
|
const readFileAsBlob = async uri => {
|
|
1159
|
-
// @ts-ignore
|
|
1160
1156
|
return invoke$4('FileSystem.readFileAsBlob', uri);
|
|
1161
1157
|
};
|
|
1162
1158
|
const appendFile = async (uri, text) => {
|
|
1163
|
-
// @ts-ignore
|
|
1164
1159
|
return invoke$4('FileSystem.appendFile', uri, text);
|
|
1165
1160
|
};
|
|
1161
|
+
const watchFile = async (watchId, uri, rpcId) => {
|
|
1162
|
+
await invoke$4('FileSystem.watchFile', watchId, uri, rpcId);
|
|
1163
|
+
};
|
|
1164
|
+
const unwatchFile = async watchId => {
|
|
1165
|
+
await invoke$4('FileSystem.unwatchFile', watchId);
|
|
1166
|
+
};
|
|
1166
1167
|
const registerMockRpc = commandMap => {
|
|
1167
1168
|
const mockRpc = createMockRpc({
|
|
1168
1169
|
commandMap
|
|
@@ -1192,6 +1193,8 @@ const FileSystemWorker = {
|
|
|
1192
1193
|
rename: rename$2,
|
|
1193
1194
|
set: set$5,
|
|
1194
1195
|
stat: stat$1,
|
|
1196
|
+
unwatchFile,
|
|
1197
|
+
watchFile,
|
|
1195
1198
|
writeFile: writeFile$1
|
|
1196
1199
|
};
|
|
1197
1200
|
|
|
@@ -1217,6 +1220,10 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
|
1217
1220
|
// @ts-ignore
|
|
1218
1221
|
await invoke$2('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1219
1222
|
};
|
|
1223
|
+
const getFileHandles$1 = async fileIds => {
|
|
1224
|
+
const files = await invoke$2('FileSystemHandle.getFileHandles', fileIds);
|
|
1225
|
+
return files;
|
|
1226
|
+
};
|
|
1220
1227
|
const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
|
|
1221
1228
|
const command = 'IconTheme.handleMessagePort';
|
|
1222
1229
|
// @ts-ignore
|
|
@@ -3545,21 +3552,25 @@ const getFittingIndex = (dirents, startIndex) => {
|
|
|
3545
3552
|
const newDirent = async (state, editingType) => {
|
|
3546
3553
|
// TODO do it like vscode, select position between folders and files
|
|
3547
3554
|
const {
|
|
3555
|
+
editingIndex,
|
|
3548
3556
|
focusedIndex,
|
|
3549
3557
|
items,
|
|
3550
3558
|
root
|
|
3551
3559
|
} = state;
|
|
3560
|
+
if (editingIndex !== -1) {
|
|
3561
|
+
return state;
|
|
3562
|
+
}
|
|
3552
3563
|
const index = getFittingIndex(items, focusedIndex);
|
|
3553
3564
|
const direntType = getNewDirentType(editingType);
|
|
3554
3565
|
const newDirents = await getNewDirentsForNewDirent(items, index, direntType, root);
|
|
3555
|
-
const
|
|
3566
|
+
const newEditingIndex = newDirents.findIndex(item => item.type === EditingFile || item.type === EditingFolder);
|
|
3556
3567
|
return {
|
|
3557
3568
|
...state,
|
|
3558
|
-
editingIndex,
|
|
3569
|
+
editingIndex: newEditingIndex,
|
|
3559
3570
|
editingType,
|
|
3560
3571
|
editingValue: '',
|
|
3561
3572
|
focus: Input$1,
|
|
3562
|
-
focusedIndex:
|
|
3573
|
+
focusedIndex: newEditingIndex,
|
|
3563
3574
|
items: newDirents
|
|
3564
3575
|
};
|
|
3565
3576
|
};
|
|
@@ -3934,17 +3945,16 @@ const handleContextMenuAtIndex = async (state, index, x, y) => {
|
|
|
3934
3945
|
return newState;
|
|
3935
3946
|
};
|
|
3936
3947
|
|
|
3937
|
-
const handleContextMenuKeyboard = async state => {
|
|
3948
|
+
const handleContextMenuKeyboard = async (state, index = state.focusedIndex) => {
|
|
3938
3949
|
const {
|
|
3939
|
-
focusedIndex,
|
|
3940
3950
|
itemHeight,
|
|
3941
3951
|
minLineY,
|
|
3942
3952
|
x,
|
|
3943
3953
|
y
|
|
3944
3954
|
} = state;
|
|
3945
3955
|
const menuX = x;
|
|
3946
|
-
const menuY = y + (
|
|
3947
|
-
return handleContextMenuAtIndex(state,
|
|
3956
|
+
const menuY = y + (index - minLineY + 1) * itemHeight;
|
|
3957
|
+
return handleContextMenuAtIndex(state, index, menuX, menuY);
|
|
3948
3958
|
};
|
|
3949
3959
|
|
|
3950
3960
|
const handleContextMenuMouseAt = async (state, x, y) => {
|
|
@@ -4013,6 +4023,14 @@ const handleCut = async state => {
|
|
|
4013
4023
|
};
|
|
4014
4024
|
};
|
|
4015
4025
|
|
|
4026
|
+
const handleDoubleClick = async (state, eventX, eventY) => {
|
|
4027
|
+
const index = getIndexFromPosition(state, eventX, eventY);
|
|
4028
|
+
if (index !== -1) {
|
|
4029
|
+
return state;
|
|
4030
|
+
}
|
|
4031
|
+
return newFile(state);
|
|
4032
|
+
};
|
|
4033
|
+
|
|
4016
4034
|
const handleDragEnd = state => {
|
|
4017
4035
|
return {
|
|
4018
4036
|
...state,
|
|
@@ -4128,7 +4146,8 @@ const isFileHandle = fileHandle => {
|
|
|
4128
4146
|
|
|
4129
4147
|
const createUploadTree = async (root, fileHandles) => {
|
|
4130
4148
|
const uploadTree = Object.create(null);
|
|
4131
|
-
|
|
4149
|
+
const normalized = fileHandles.filter(Boolean);
|
|
4150
|
+
for (const fileHandle of normalized) {
|
|
4132
4151
|
const {
|
|
4133
4152
|
name
|
|
4134
4153
|
} = fileHandle;
|
|
@@ -4295,14 +4314,7 @@ const handleDropIntoFolder = async (state, dirent, index, fileHandles, files, pa
|
|
|
4295
4314
|
items,
|
|
4296
4315
|
pathSeparator
|
|
4297
4316
|
} = state;
|
|
4298
|
-
|
|
4299
|
-
for (const file of fileHandles) {
|
|
4300
|
-
// TODO path basename
|
|
4301
|
-
const baseName = file.name;
|
|
4302
|
-
const to = dirent.path + pathSeparator + baseName;
|
|
4303
|
-
// @ts-ignore
|
|
4304
|
-
await copy$1(file, to);
|
|
4305
|
-
}
|
|
4317
|
+
await uploadFileSystemHandles(dirent.path, '/', fileHandles);
|
|
4306
4318
|
const childDirents = await getChildDirents(pathSeparator, dirent.path, dirent.depth);
|
|
4307
4319
|
const mergedDirents = getMergedDirents(items, index, dirent, childDirents);
|
|
4308
4320
|
// TODO update maxlineY
|
|
@@ -4357,7 +4369,7 @@ const getFileArray = fileList => {
|
|
|
4357
4369
|
};
|
|
4358
4370
|
|
|
4359
4371
|
const getFileHandles = async fileIds => {
|
|
4360
|
-
const files = await
|
|
4372
|
+
const files = await getFileHandles$1(fileIds);
|
|
4361
4373
|
return files;
|
|
4362
4374
|
};
|
|
4363
4375
|
|
|
@@ -4379,9 +4391,12 @@ const getFilePaths = async (files, platform) => {
|
|
|
4379
4391
|
|
|
4380
4392
|
const handleDrop = async (state, x, y, fileIds, fileList) => {
|
|
4381
4393
|
try {
|
|
4394
|
+
const {
|
|
4395
|
+
platform
|
|
4396
|
+
} = state;
|
|
4382
4397
|
const files = getFileArray(fileList);
|
|
4383
4398
|
const fileHandles = await getFileHandles(fileIds);
|
|
4384
|
-
const paths = await getFilePaths(files,
|
|
4399
|
+
const paths = await getFilePaths(files, platform);
|
|
4385
4400
|
const index = getIndexFromPosition(state, x, y);
|
|
4386
4401
|
const fn = getDropHandler(index);
|
|
4387
4402
|
const result = await fn(state, fileHandles, files, paths, index);
|
|
@@ -5342,20 +5357,22 @@ const getDragData = urls => {
|
|
|
5342
5357
|
data,
|
|
5343
5358
|
type: 'text/plain'
|
|
5344
5359
|
}];
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5360
|
+
return {
|
|
5361
|
+
items: dragData,
|
|
5362
|
+
label: getDragLabel(urls)
|
|
5363
|
+
};
|
|
5348
5364
|
};
|
|
5349
5365
|
|
|
5350
5366
|
const renderDragData = (oldState, newState) => {
|
|
5351
5367
|
const {
|
|
5352
5368
|
focusedIndex,
|
|
5353
|
-
items
|
|
5369
|
+
items,
|
|
5370
|
+
uid
|
|
5354
5371
|
} = newState;
|
|
5355
5372
|
const selected = items.filter((item, index) => item.selected || index === focusedIndex);
|
|
5356
5373
|
const urls = selected.map(item => item.path);
|
|
5357
5374
|
const dragData = getDragData(urls);
|
|
5358
|
-
return ['Viewlet.setDragData',
|
|
5375
|
+
return ['Viewlet.setDragData', uid, dragData];
|
|
5359
5376
|
};
|
|
5360
5377
|
|
|
5361
5378
|
const renderEditingSelection = (oldState, newState) => {
|
|
@@ -5431,6 +5448,7 @@ const HandleListBlur = 11;
|
|
|
5431
5448
|
const HandleListFocus = 12;
|
|
5432
5449
|
const HandlePointerDown = 14;
|
|
5433
5450
|
const HandleWheel = 15;
|
|
5451
|
+
const HandleDoubleClick = 16;
|
|
5434
5452
|
|
|
5435
5453
|
const getExplorerWelcomeVirtualDom = isWide => {
|
|
5436
5454
|
return [{
|
|
@@ -5588,6 +5606,7 @@ const getListItemsVirtualDom = (visibleItems, focusedIndex, focused, dropTargets
|
|
|
5588
5606
|
onBlur: HandleListBlur,
|
|
5589
5607
|
onClick: HandleClick,
|
|
5590
5608
|
onContextMenu: HandleContextMenu,
|
|
5609
|
+
onDblClick: HandleDoubleClick,
|
|
5591
5610
|
onDragEnd: HandleDragEnd,
|
|
5592
5611
|
onDragLeave: HandleDragLeave,
|
|
5593
5612
|
onDragOver: HandleDragOver,
|
|
@@ -5853,6 +5872,9 @@ const renderEventListeners = () => {
|
|
|
5853
5872
|
}, {
|
|
5854
5873
|
name: HandlePointerDown,
|
|
5855
5874
|
params: ['handlePointerDown', Button$3, ClientX, ClientY]
|
|
5875
|
+
}, {
|
|
5876
|
+
name: HandleDoubleClick,
|
|
5877
|
+
params: ['handleDoubleClick', ClientX, ClientY]
|
|
5856
5878
|
}, {
|
|
5857
5879
|
name: HandleEditingInput,
|
|
5858
5880
|
params: ['updateEditingValue', TargetValue]
|
|
@@ -6211,12 +6233,14 @@ const commandMap = {
|
|
|
6211
6233
|
'Explorer.handleContextMenuKeyboard': wrapListItemCommand(handleContextMenuKeyboard),
|
|
6212
6234
|
'Explorer.handleCopy': wrapListItemCommand(handleCopy),
|
|
6213
6235
|
'Explorer.handleCut': wrapListItemCommand(handleCut),
|
|
6236
|
+
'Explorer.handleDoubleClick': wrapListItemCommand(handleDoubleClick),
|
|
6214
6237
|
'Explorer.handleDragEnd': wrapListItemCommand(handleDragEnd),
|
|
6215
6238
|
'Explorer.handleDragLeave': wrapListItemCommand(handleDragLeave),
|
|
6216
6239
|
'Explorer.handleDragOver': wrapListItemCommand(handleDragOver),
|
|
6217
6240
|
'Explorer.handleDragOverIndex': wrapListItemCommand(handleDragOverIndex),
|
|
6218
6241
|
'Explorer.handleDragStart': wrapListItemCommand(handleDragStart),
|
|
6219
6242
|
'Explorer.handleDrop': wrapListItemCommand(handleDrop),
|
|
6243
|
+
'Explorer.handleDropIndex': wrapListItemCommand(handleDropIndex),
|
|
6220
6244
|
'Explorer.handleEscape': wrapListItemCommand(handleEscape),
|
|
6221
6245
|
'Explorer.handleFocus': wrapListItemCommand(handleFocus),
|
|
6222
6246
|
'Explorer.handleIconThemeChange': wrapListItemCommand(handleIconThemeChange),
|