@lvce-editor/explorer-view 5.16.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 +81 -58
- package/package.json +1 -1
|
@@ -861,14 +861,14 @@ const execute = (command, ...args) => {
|
|
|
861
861
|
};
|
|
862
862
|
|
|
863
863
|
const Two = '2.0';
|
|
864
|
-
const create$
|
|
864
|
+
const create$s = (method, params) => {
|
|
865
865
|
return {
|
|
866
866
|
jsonrpc: Two,
|
|
867
867
|
method,
|
|
868
868
|
params
|
|
869
869
|
};
|
|
870
870
|
};
|
|
871
|
-
const create$
|
|
871
|
+
const create$r = (id, method, params) => {
|
|
872
872
|
const message = {
|
|
873
873
|
id,
|
|
874
874
|
jsonrpc: Two,
|
|
@@ -878,14 +878,14 @@ const create$n = (id, method, params) => {
|
|
|
878
878
|
return message;
|
|
879
879
|
};
|
|
880
880
|
let id = 0;
|
|
881
|
-
const create$
|
|
881
|
+
const create$q = () => {
|
|
882
882
|
return ++id;
|
|
883
883
|
};
|
|
884
884
|
|
|
885
885
|
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
886
886
|
|
|
887
887
|
const registerPromise = map => {
|
|
888
|
-
const id = create$
|
|
888
|
+
const id = create$q();
|
|
889
889
|
const {
|
|
890
890
|
promise,
|
|
891
891
|
resolve
|
|
@@ -903,7 +903,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
903
903
|
id,
|
|
904
904
|
promise
|
|
905
905
|
} = registerPromise(callbacks);
|
|
906
|
-
const message = create$
|
|
906
|
+
const message = create$r(id, method, params);
|
|
907
907
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
908
908
|
ipc.sendAndTransfer(message);
|
|
909
909
|
} else {
|
|
@@ -939,7 +939,7 @@ const createRpc = ipc => {
|
|
|
939
939
|
* @deprecated
|
|
940
940
|
*/
|
|
941
941
|
send(method, ...params) {
|
|
942
|
-
const message = create$
|
|
942
|
+
const message = create$s(method, params);
|
|
943
943
|
ipc.send(message);
|
|
944
944
|
}
|
|
945
945
|
};
|
|
@@ -975,7 +975,7 @@ const listen$1 = async (module, options) => {
|
|
|
975
975
|
const ipc = module.wrap(rawIpc);
|
|
976
976
|
return ipc;
|
|
977
977
|
};
|
|
978
|
-
const create$
|
|
978
|
+
const create$4 = async ({
|
|
979
979
|
commandMap,
|
|
980
980
|
isMessagePortOpen = true,
|
|
981
981
|
messagePort
|
|
@@ -992,7 +992,7 @@ const create$6 = async ({
|
|
|
992
992
|
messagePort.start();
|
|
993
993
|
return rpc;
|
|
994
994
|
};
|
|
995
|
-
const create$
|
|
995
|
+
const create$2$1 = async ({
|
|
996
996
|
commandMap,
|
|
997
997
|
isMessagePortOpen,
|
|
998
998
|
send
|
|
@@ -1002,7 +1002,7 @@ const create$4 = async ({
|
|
|
1002
1002
|
port2
|
|
1003
1003
|
} = new MessageChannel();
|
|
1004
1004
|
await send(port1);
|
|
1005
|
-
return create$
|
|
1005
|
+
return create$4({
|
|
1006
1006
|
commandMap,
|
|
1007
1007
|
isMessagePortOpen,
|
|
1008
1008
|
messagePort: port2
|
|
@@ -1010,7 +1010,7 @@ const create$4 = async ({
|
|
|
1010
1010
|
};
|
|
1011
1011
|
const TransferMessagePortRpcParent = {
|
|
1012
1012
|
__proto__: null,
|
|
1013
|
-
create: create$
|
|
1013
|
+
create: create$2$1
|
|
1014
1014
|
};
|
|
1015
1015
|
const create$1$1 = async ({
|
|
1016
1016
|
commandMap
|
|
@@ -1026,6 +1026,25 @@ const WebWorkerRpcClient = {
|
|
|
1026
1026
|
__proto__: null,
|
|
1027
1027
|
create: create$1$1
|
|
1028
1028
|
};
|
|
1029
|
+
const createMockRpc = ({
|
|
1030
|
+
commandMap
|
|
1031
|
+
}) => {
|
|
1032
|
+
const invocations = [];
|
|
1033
|
+
const invoke = (method, ...params) => {
|
|
1034
|
+
invocations.push([method, ...params]);
|
|
1035
|
+
const command = commandMap[method];
|
|
1036
|
+
if (!command) {
|
|
1037
|
+
throw new Error(`command ${method} not found`);
|
|
1038
|
+
}
|
|
1039
|
+
return command(...params);
|
|
1040
|
+
};
|
|
1041
|
+
const mockRpc = {
|
|
1042
|
+
invocations,
|
|
1043
|
+
invoke,
|
|
1044
|
+
invokeAndTransfer: invoke
|
|
1045
|
+
};
|
|
1046
|
+
return mockRpc;
|
|
1047
|
+
};
|
|
1029
1048
|
|
|
1030
1049
|
const Button$3 = 'event.button';
|
|
1031
1050
|
const ClientX = 'event.clientX';
|
|
@@ -1088,26 +1107,6 @@ const create$2 = rpcId => {
|
|
|
1088
1107
|
};
|
|
1089
1108
|
};
|
|
1090
1109
|
|
|
1091
|
-
const createMockRpc = ({
|
|
1092
|
-
commandMap
|
|
1093
|
-
}) => {
|
|
1094
|
-
const invocations = [];
|
|
1095
|
-
const invoke = (method, ...params) => {
|
|
1096
|
-
invocations.push([method, ...params]);
|
|
1097
|
-
const command = commandMap[method];
|
|
1098
|
-
if (!command) {
|
|
1099
|
-
throw new Error(`command ${method} not found`);
|
|
1100
|
-
}
|
|
1101
|
-
return command(...params);
|
|
1102
|
-
};
|
|
1103
|
-
const mockRpc = {
|
|
1104
|
-
invoke,
|
|
1105
|
-
invokeAndTransfer: invoke,
|
|
1106
|
-
invocations
|
|
1107
|
-
};
|
|
1108
|
-
return mockRpc;
|
|
1109
|
-
};
|
|
1110
|
-
|
|
1111
1110
|
const {
|
|
1112
1111
|
dispose,
|
|
1113
1112
|
invoke: invoke$4,
|
|
@@ -1121,7 +1120,6 @@ const readDirWithFileTypes$1 = async uri => {
|
|
|
1121
1120
|
return invoke$4('FileSystem.readDirWithFileTypes', uri);
|
|
1122
1121
|
};
|
|
1123
1122
|
const getPathSeparator$2 = async root => {
|
|
1124
|
-
// @ts-ignore
|
|
1125
1123
|
return invoke$4('FileSystem.getPathSeparator', root);
|
|
1126
1124
|
};
|
|
1127
1125
|
const getRealPath$1 = async path => {
|
|
@@ -1149,21 +1147,23 @@ const copy$2 = async (oldUri, newUri) => {
|
|
|
1149
1147
|
return invoke$4('FileSystem.copy', oldUri, newUri);
|
|
1150
1148
|
};
|
|
1151
1149
|
const exists = async uri => {
|
|
1152
|
-
// @ts-ignore
|
|
1153
1150
|
return invoke$4('FileSystem.exists', uri);
|
|
1154
1151
|
};
|
|
1155
1152
|
const getFolderSize = async uri => {
|
|
1156
|
-
// @ts-ignore
|
|
1157
1153
|
return invoke$4('FileSystem.getFolderSize', uri);
|
|
1158
1154
|
};
|
|
1159
1155
|
const readFileAsBlob = async uri => {
|
|
1160
|
-
// @ts-ignore
|
|
1161
1156
|
return invoke$4('FileSystem.readFileAsBlob', uri);
|
|
1162
1157
|
};
|
|
1163
1158
|
const appendFile = async (uri, text) => {
|
|
1164
|
-
// @ts-ignore
|
|
1165
1159
|
return invoke$4('FileSystem.appendFile', uri, text);
|
|
1166
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
|
+
};
|
|
1167
1167
|
const registerMockRpc = commandMap => {
|
|
1168
1168
|
const mockRpc = createMockRpc({
|
|
1169
1169
|
commandMap
|
|
@@ -1193,6 +1193,8 @@ const FileSystemWorker = {
|
|
|
1193
1193
|
rename: rename$2,
|
|
1194
1194
|
set: set$5,
|
|
1195
1195
|
stat: stat$1,
|
|
1196
|
+
unwatchFile,
|
|
1197
|
+
watchFile,
|
|
1196
1198
|
writeFile: writeFile$1
|
|
1197
1199
|
};
|
|
1198
1200
|
|
|
@@ -1218,6 +1220,10 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
|
1218
1220
|
// @ts-ignore
|
|
1219
1221
|
await invoke$2('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1220
1222
|
};
|
|
1223
|
+
const getFileHandles$1 = async fileIds => {
|
|
1224
|
+
const files = await invoke$2('FileSystemHandle.getFileHandles', fileIds);
|
|
1225
|
+
return files;
|
|
1226
|
+
};
|
|
1221
1227
|
const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
|
|
1222
1228
|
const command = 'IconTheme.handleMessagePort';
|
|
1223
1229
|
// @ts-ignore
|
|
@@ -3546,21 +3552,25 @@ const getFittingIndex = (dirents, startIndex) => {
|
|
|
3546
3552
|
const newDirent = async (state, editingType) => {
|
|
3547
3553
|
// TODO do it like vscode, select position between folders and files
|
|
3548
3554
|
const {
|
|
3555
|
+
editingIndex,
|
|
3549
3556
|
focusedIndex,
|
|
3550
3557
|
items,
|
|
3551
3558
|
root
|
|
3552
3559
|
} = state;
|
|
3560
|
+
if (editingIndex !== -1) {
|
|
3561
|
+
return state;
|
|
3562
|
+
}
|
|
3553
3563
|
const index = getFittingIndex(items, focusedIndex);
|
|
3554
3564
|
const direntType = getNewDirentType(editingType);
|
|
3555
3565
|
const newDirents = await getNewDirentsForNewDirent(items, index, direntType, root);
|
|
3556
|
-
const
|
|
3566
|
+
const newEditingIndex = newDirents.findIndex(item => item.type === EditingFile || item.type === EditingFolder);
|
|
3557
3567
|
return {
|
|
3558
3568
|
...state,
|
|
3559
|
-
editingIndex,
|
|
3569
|
+
editingIndex: newEditingIndex,
|
|
3560
3570
|
editingType,
|
|
3561
3571
|
editingValue: '',
|
|
3562
3572
|
focus: Input$1,
|
|
3563
|
-
focusedIndex:
|
|
3573
|
+
focusedIndex: newEditingIndex,
|
|
3564
3574
|
items: newDirents
|
|
3565
3575
|
};
|
|
3566
3576
|
};
|
|
@@ -3935,17 +3945,16 @@ const handleContextMenuAtIndex = async (state, index, x, y) => {
|
|
|
3935
3945
|
return newState;
|
|
3936
3946
|
};
|
|
3937
3947
|
|
|
3938
|
-
const handleContextMenuKeyboard = async state => {
|
|
3948
|
+
const handleContextMenuKeyboard = async (state, index = state.focusedIndex) => {
|
|
3939
3949
|
const {
|
|
3940
|
-
focusedIndex,
|
|
3941
3950
|
itemHeight,
|
|
3942
3951
|
minLineY,
|
|
3943
3952
|
x,
|
|
3944
3953
|
y
|
|
3945
3954
|
} = state;
|
|
3946
3955
|
const menuX = x;
|
|
3947
|
-
const menuY = y + (
|
|
3948
|
-
return handleContextMenuAtIndex(state,
|
|
3956
|
+
const menuY = y + (index - minLineY + 1) * itemHeight;
|
|
3957
|
+
return handleContextMenuAtIndex(state, index, menuX, menuY);
|
|
3949
3958
|
};
|
|
3950
3959
|
|
|
3951
3960
|
const handleContextMenuMouseAt = async (state, x, y) => {
|
|
@@ -4014,6 +4023,14 @@ const handleCut = async state => {
|
|
|
4014
4023
|
};
|
|
4015
4024
|
};
|
|
4016
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
|
+
|
|
4017
4034
|
const handleDragEnd = state => {
|
|
4018
4035
|
return {
|
|
4019
4036
|
...state,
|
|
@@ -4129,7 +4146,8 @@ const isFileHandle = fileHandle => {
|
|
|
4129
4146
|
|
|
4130
4147
|
const createUploadTree = async (root, fileHandles) => {
|
|
4131
4148
|
const uploadTree = Object.create(null);
|
|
4132
|
-
|
|
4149
|
+
const normalized = fileHandles.filter(Boolean);
|
|
4150
|
+
for (const fileHandle of normalized) {
|
|
4133
4151
|
const {
|
|
4134
4152
|
name
|
|
4135
4153
|
} = fileHandle;
|
|
@@ -4296,14 +4314,7 @@ const handleDropIntoFolder = async (state, dirent, index, fileHandles, files, pa
|
|
|
4296
4314
|
items,
|
|
4297
4315
|
pathSeparator
|
|
4298
4316
|
} = state;
|
|
4299
|
-
|
|
4300
|
-
for (const file of fileHandles) {
|
|
4301
|
-
// TODO path basename
|
|
4302
|
-
const baseName = file.name;
|
|
4303
|
-
const to = dirent.path + pathSeparator + baseName;
|
|
4304
|
-
// @ts-ignore
|
|
4305
|
-
await copy$1(file, to);
|
|
4306
|
-
}
|
|
4317
|
+
await uploadFileSystemHandles(dirent.path, '/', fileHandles);
|
|
4307
4318
|
const childDirents = await getChildDirents(pathSeparator, dirent.path, dirent.depth);
|
|
4308
4319
|
const mergedDirents = getMergedDirents(items, index, dirent, childDirents);
|
|
4309
4320
|
// TODO update maxlineY
|
|
@@ -4358,7 +4369,7 @@ const getFileArray = fileList => {
|
|
|
4358
4369
|
};
|
|
4359
4370
|
|
|
4360
4371
|
const getFileHandles = async fileIds => {
|
|
4361
|
-
const files = await
|
|
4372
|
+
const files = await getFileHandles$1(fileIds);
|
|
4362
4373
|
return files;
|
|
4363
4374
|
};
|
|
4364
4375
|
|
|
@@ -4380,9 +4391,12 @@ const getFilePaths = async (files, platform) => {
|
|
|
4380
4391
|
|
|
4381
4392
|
const handleDrop = async (state, x, y, fileIds, fileList) => {
|
|
4382
4393
|
try {
|
|
4394
|
+
const {
|
|
4395
|
+
platform
|
|
4396
|
+
} = state;
|
|
4383
4397
|
const files = getFileArray(fileList);
|
|
4384
4398
|
const fileHandles = await getFileHandles(fileIds);
|
|
4385
|
-
const paths = await getFilePaths(files,
|
|
4399
|
+
const paths = await getFilePaths(files, platform);
|
|
4386
4400
|
const index = getIndexFromPosition(state, x, y);
|
|
4387
4401
|
const fn = getDropHandler(index);
|
|
4388
4402
|
const result = await fn(state, fileHandles, files, paths, index);
|
|
@@ -5343,20 +5357,22 @@ const getDragData = urls => {
|
|
|
5343
5357
|
data,
|
|
5344
5358
|
type: 'text/plain'
|
|
5345
5359
|
}];
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5360
|
+
return {
|
|
5361
|
+
items: dragData,
|
|
5362
|
+
label: getDragLabel(urls)
|
|
5363
|
+
};
|
|
5349
5364
|
};
|
|
5350
5365
|
|
|
5351
5366
|
const renderDragData = (oldState, newState) => {
|
|
5352
5367
|
const {
|
|
5353
5368
|
focusedIndex,
|
|
5354
|
-
items
|
|
5369
|
+
items,
|
|
5370
|
+
uid
|
|
5355
5371
|
} = newState;
|
|
5356
5372
|
const selected = items.filter((item, index) => item.selected || index === focusedIndex);
|
|
5357
5373
|
const urls = selected.map(item => item.path);
|
|
5358
5374
|
const dragData = getDragData(urls);
|
|
5359
|
-
return ['Viewlet.setDragData',
|
|
5375
|
+
return ['Viewlet.setDragData', uid, dragData];
|
|
5360
5376
|
};
|
|
5361
5377
|
|
|
5362
5378
|
const renderEditingSelection = (oldState, newState) => {
|
|
@@ -5432,6 +5448,7 @@ const HandleListBlur = 11;
|
|
|
5432
5448
|
const HandleListFocus = 12;
|
|
5433
5449
|
const HandlePointerDown = 14;
|
|
5434
5450
|
const HandleWheel = 15;
|
|
5451
|
+
const HandleDoubleClick = 16;
|
|
5435
5452
|
|
|
5436
5453
|
const getExplorerWelcomeVirtualDom = isWide => {
|
|
5437
5454
|
return [{
|
|
@@ -5589,6 +5606,7 @@ const getListItemsVirtualDom = (visibleItems, focusedIndex, focused, dropTargets
|
|
|
5589
5606
|
onBlur: HandleListBlur,
|
|
5590
5607
|
onClick: HandleClick,
|
|
5591
5608
|
onContextMenu: HandleContextMenu,
|
|
5609
|
+
onDblClick: HandleDoubleClick,
|
|
5592
5610
|
onDragEnd: HandleDragEnd,
|
|
5593
5611
|
onDragLeave: HandleDragLeave,
|
|
5594
5612
|
onDragOver: HandleDragOver,
|
|
@@ -5854,6 +5872,9 @@ const renderEventListeners = () => {
|
|
|
5854
5872
|
}, {
|
|
5855
5873
|
name: HandlePointerDown,
|
|
5856
5874
|
params: ['handlePointerDown', Button$3, ClientX, ClientY]
|
|
5875
|
+
}, {
|
|
5876
|
+
name: HandleDoubleClick,
|
|
5877
|
+
params: ['handleDoubleClick', ClientX, ClientY]
|
|
5857
5878
|
}, {
|
|
5858
5879
|
name: HandleEditingInput,
|
|
5859
5880
|
params: ['updateEditingValue', TargetValue]
|
|
@@ -6212,12 +6233,14 @@ const commandMap = {
|
|
|
6212
6233
|
'Explorer.handleContextMenuKeyboard': wrapListItemCommand(handleContextMenuKeyboard),
|
|
6213
6234
|
'Explorer.handleCopy': wrapListItemCommand(handleCopy),
|
|
6214
6235
|
'Explorer.handleCut': wrapListItemCommand(handleCut),
|
|
6236
|
+
'Explorer.handleDoubleClick': wrapListItemCommand(handleDoubleClick),
|
|
6215
6237
|
'Explorer.handleDragEnd': wrapListItemCommand(handleDragEnd),
|
|
6216
6238
|
'Explorer.handleDragLeave': wrapListItemCommand(handleDragLeave),
|
|
6217
6239
|
'Explorer.handleDragOver': wrapListItemCommand(handleDragOver),
|
|
6218
6240
|
'Explorer.handleDragOverIndex': wrapListItemCommand(handleDragOverIndex),
|
|
6219
6241
|
'Explorer.handleDragStart': wrapListItemCommand(handleDragStart),
|
|
6220
6242
|
'Explorer.handleDrop': wrapListItemCommand(handleDrop),
|
|
6243
|
+
'Explorer.handleDropIndex': wrapListItemCommand(handleDropIndex),
|
|
6221
6244
|
'Explorer.handleEscape': wrapListItemCommand(handleEscape),
|
|
6222
6245
|
'Explorer.handleFocus': wrapListItemCommand(handleFocus),
|
|
6223
6246
|
'Explorer.handleIconThemeChange': wrapListItemCommand(handleIconThemeChange),
|