@lvce-editor/explorer-view 3.15.0 → 3.17.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 +126 -108
- package/package.json +1 -1
|
@@ -1045,6 +1045,90 @@ const createMockRpc = ({
|
|
|
1045
1045
|
return mockRpc;
|
|
1046
1046
|
};
|
|
1047
1047
|
|
|
1048
|
+
const toCommandId = key => {
|
|
1049
|
+
const dotIndex = key.indexOf('.');
|
|
1050
|
+
return key.slice(dotIndex + 1);
|
|
1051
|
+
};
|
|
1052
|
+
const create$2 = () => {
|
|
1053
|
+
const states = Object.create(null);
|
|
1054
|
+
const commandMapRef = {};
|
|
1055
|
+
return {
|
|
1056
|
+
get(uid) {
|
|
1057
|
+
return states[uid];
|
|
1058
|
+
},
|
|
1059
|
+
set(uid, oldState, newState) {
|
|
1060
|
+
states[uid] = {
|
|
1061
|
+
oldState,
|
|
1062
|
+
newState
|
|
1063
|
+
};
|
|
1064
|
+
},
|
|
1065
|
+
dispose(uid) {
|
|
1066
|
+
delete states[uid];
|
|
1067
|
+
},
|
|
1068
|
+
getKeys() {
|
|
1069
|
+
return Object.keys(states).map(key => {
|
|
1070
|
+
return Number.parseInt(key);
|
|
1071
|
+
});
|
|
1072
|
+
},
|
|
1073
|
+
clear() {
|
|
1074
|
+
for (const key of Object.keys(states)) {
|
|
1075
|
+
delete states[key];
|
|
1076
|
+
}
|
|
1077
|
+
},
|
|
1078
|
+
wrapCommand(fn) {
|
|
1079
|
+
const wrapped = async (uid, ...args) => {
|
|
1080
|
+
const {
|
|
1081
|
+
newState
|
|
1082
|
+
} = states[uid];
|
|
1083
|
+
const newerState = await fn(newState, ...args);
|
|
1084
|
+
if (newState === newerState) {
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1087
|
+
const latest = states[uid];
|
|
1088
|
+
states[uid] = {
|
|
1089
|
+
oldState: latest.oldState,
|
|
1090
|
+
newState: newerState
|
|
1091
|
+
};
|
|
1092
|
+
};
|
|
1093
|
+
return wrapped;
|
|
1094
|
+
},
|
|
1095
|
+
wrapGetter(fn) {
|
|
1096
|
+
const wrapped = (uid, ...args) => {
|
|
1097
|
+
const {
|
|
1098
|
+
newState
|
|
1099
|
+
} = states[uid];
|
|
1100
|
+
return fn(newState, ...args);
|
|
1101
|
+
};
|
|
1102
|
+
return wrapped;
|
|
1103
|
+
},
|
|
1104
|
+
diff(uid, modules, numbers) {
|
|
1105
|
+
const {
|
|
1106
|
+
oldState,
|
|
1107
|
+
newState
|
|
1108
|
+
} = states[uid];
|
|
1109
|
+
const diffResult = [];
|
|
1110
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1111
|
+
const fn = modules[i];
|
|
1112
|
+
if (!fn(oldState, newState)) {
|
|
1113
|
+
diffResult.push(numbers[i]);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
return diffResult;
|
|
1117
|
+
},
|
|
1118
|
+
getCommandIds() {
|
|
1119
|
+
const keys = Object.keys(commandMapRef);
|
|
1120
|
+
const ids = keys.map(toCommandId);
|
|
1121
|
+
return ids;
|
|
1122
|
+
},
|
|
1123
|
+
registerCommands(commandMap) {
|
|
1124
|
+
Object.assign(commandMapRef, commandMap);
|
|
1125
|
+
}
|
|
1126
|
+
};
|
|
1127
|
+
};
|
|
1128
|
+
const terminate = () => {
|
|
1129
|
+
globalThis.close();
|
|
1130
|
+
};
|
|
1131
|
+
|
|
1048
1132
|
const CreateFolder$1 = 1;
|
|
1049
1133
|
const CreateFile$1 = 2;
|
|
1050
1134
|
const Copy$1 = 3;
|
|
@@ -1053,6 +1137,14 @@ const Remove = 5;
|
|
|
1053
1137
|
|
|
1054
1138
|
const Text = 12;
|
|
1055
1139
|
|
|
1140
|
+
const TargetValue = 'event.target.value';
|
|
1141
|
+
const ClientX = 'event.clientX';
|
|
1142
|
+
const ClientY = 'event.clientY';
|
|
1143
|
+
const Button$3 = 'event.button';
|
|
1144
|
+
const DeltaMode = 'event.deltaMode';
|
|
1145
|
+
const DeltaY = 'event.deltaY';
|
|
1146
|
+
const CtrlKey = 'event.ctrlKey';
|
|
1147
|
+
|
|
1056
1148
|
const Enter = 3;
|
|
1057
1149
|
const Escape = 8;
|
|
1058
1150
|
const Space = 9;
|
|
@@ -1078,6 +1170,10 @@ const DebugWorker = 55;
|
|
|
1078
1170
|
const FileSystemWorker$1 = 209;
|
|
1079
1171
|
const RendererWorker$1 = 1;
|
|
1080
1172
|
|
|
1173
|
+
const FocusElementByName = 'Viewlet.focusElementByName';
|
|
1174
|
+
const FocusSelector = 'Viewlet.focusSelector';
|
|
1175
|
+
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
1176
|
+
|
|
1081
1177
|
const FocusExplorer = 13;
|
|
1082
1178
|
const FocusExplorerEditBox = 14;
|
|
1083
1179
|
|
|
@@ -1089,7 +1185,7 @@ const get$1 = id => {
|
|
|
1089
1185
|
return rpcs[id];
|
|
1090
1186
|
};
|
|
1091
1187
|
|
|
1092
|
-
const create$
|
|
1188
|
+
const create$1 = rpcId => {
|
|
1093
1189
|
return {
|
|
1094
1190
|
// @ts-ignore
|
|
1095
1191
|
invoke(method, ...params) {
|
|
@@ -1118,7 +1214,7 @@ const {
|
|
|
1118
1214
|
invokeAndTransfer: invokeAndTransfer$1,
|
|
1119
1215
|
set: set$4,
|
|
1120
1216
|
dispose: dispose$1
|
|
1121
|
-
} = create$
|
|
1217
|
+
} = create$1(FileSystemWorker$1);
|
|
1122
1218
|
const remove$1 = async dirent => {
|
|
1123
1219
|
return invoke$3('FileSystem.remove', dirent);
|
|
1124
1220
|
};
|
|
@@ -1198,7 +1294,7 @@ const {
|
|
|
1198
1294
|
invokeAndTransfer,
|
|
1199
1295
|
set: set$3,
|
|
1200
1296
|
dispose
|
|
1201
|
-
} = create$
|
|
1297
|
+
} = create$1(RendererWorker$1);
|
|
1202
1298
|
const searchFileHtml = async uri => {
|
|
1203
1299
|
return invoke$2('ExtensionHost.searchFileWithHtml', uri);
|
|
1204
1300
|
};
|
|
@@ -1649,6 +1745,9 @@ const dirname = (pathSeparator, path) => {
|
|
|
1649
1745
|
const dirname2 = path => {
|
|
1650
1746
|
return dirname('/', path);
|
|
1651
1747
|
};
|
|
1748
|
+
const join = (pathSeparator, ...parts) => {
|
|
1749
|
+
return parts.join(pathSeparator);
|
|
1750
|
+
};
|
|
1652
1751
|
const getBaseName = (pathSeparator, path) => {
|
|
1653
1752
|
return path.slice(path.lastIndexOf(pathSeparator) + 1);
|
|
1654
1753
|
};
|
|
@@ -2105,7 +2204,7 @@ const FilesExplorer = 'Files Explorer';
|
|
|
2105
2204
|
const NewFile$1 = 'New File...';
|
|
2106
2205
|
const NewFolder$1 = 'New Folder...';
|
|
2107
2206
|
const OpenContainingFolder = 'Open Containing Folder';
|
|
2108
|
-
const OpenFolder = 'Open folder';
|
|
2207
|
+
const OpenFolder$1 = 'Open folder';
|
|
2109
2208
|
const OpenInIntegratedTerminal = 'Open in integrated Terminal';
|
|
2110
2209
|
const Paste = 'Paste';
|
|
2111
2210
|
const RefreshExplorer = 'Refresh Explorer';
|
|
@@ -2159,7 +2258,7 @@ const youHaveNotYetOpenedAFolder = () => {
|
|
|
2159
2258
|
return i18nString(YouHaveNotYetOpenedAFolder);
|
|
2160
2259
|
};
|
|
2161
2260
|
const openFolder$1 = () => {
|
|
2162
|
-
return i18nString(OpenFolder);
|
|
2261
|
+
return i18nString(OpenFolder$1);
|
|
2163
2262
|
};
|
|
2164
2263
|
const fileOrFolderNameMustBeProvided = () => {
|
|
2165
2264
|
return i18nString(FileOrFolderNameMustBeProvider);
|
|
@@ -2541,87 +2640,6 @@ const copyRelativePath = async state => {
|
|
|
2541
2640
|
return state;
|
|
2542
2641
|
};
|
|
2543
2642
|
|
|
2544
|
-
const toCommandId = key => {
|
|
2545
|
-
const dotIndex = key.indexOf('.');
|
|
2546
|
-
return key.slice(dotIndex + 1);
|
|
2547
|
-
};
|
|
2548
|
-
const create$1 = () => {
|
|
2549
|
-
const states = Object.create(null);
|
|
2550
|
-
const commandMapRef = {};
|
|
2551
|
-
return {
|
|
2552
|
-
get(uid) {
|
|
2553
|
-
return states[uid];
|
|
2554
|
-
},
|
|
2555
|
-
set(uid, oldState, newState) {
|
|
2556
|
-
states[uid] = {
|
|
2557
|
-
oldState,
|
|
2558
|
-
newState
|
|
2559
|
-
};
|
|
2560
|
-
},
|
|
2561
|
-
dispose(uid) {
|
|
2562
|
-
delete states[uid];
|
|
2563
|
-
},
|
|
2564
|
-
getKeys() {
|
|
2565
|
-
return Object.keys(states).map(key => {
|
|
2566
|
-
return Number.parseInt(key);
|
|
2567
|
-
});
|
|
2568
|
-
},
|
|
2569
|
-
clear() {
|
|
2570
|
-
for (const key of Object.keys(states)) {
|
|
2571
|
-
delete states[key];
|
|
2572
|
-
}
|
|
2573
|
-
},
|
|
2574
|
-
wrapCommand(fn) {
|
|
2575
|
-
const wrapped = async (uid, ...args) => {
|
|
2576
|
-
const {
|
|
2577
|
-
newState
|
|
2578
|
-
} = states[uid];
|
|
2579
|
-
const newerState = await fn(newState, ...args);
|
|
2580
|
-
if (newState === newerState) {
|
|
2581
|
-
return;
|
|
2582
|
-
}
|
|
2583
|
-
const latest = states[uid];
|
|
2584
|
-
states[uid] = {
|
|
2585
|
-
oldState: latest.oldState,
|
|
2586
|
-
newState: newerState
|
|
2587
|
-
};
|
|
2588
|
-
};
|
|
2589
|
-
return wrapped;
|
|
2590
|
-
},
|
|
2591
|
-
wrapGetter(fn) {
|
|
2592
|
-
const wrapped = (uid, ...args) => {
|
|
2593
|
-
const {
|
|
2594
|
-
newState
|
|
2595
|
-
} = states[uid];
|
|
2596
|
-
return fn(newState, ...args);
|
|
2597
|
-
};
|
|
2598
|
-
return wrapped;
|
|
2599
|
-
},
|
|
2600
|
-
diff(uid, modules, numbers) {
|
|
2601
|
-
const {
|
|
2602
|
-
oldState,
|
|
2603
|
-
newState
|
|
2604
|
-
} = states[uid];
|
|
2605
|
-
const diffResult = [];
|
|
2606
|
-
for (let i = 0; i < modules.length; i++) {
|
|
2607
|
-
const fn = modules[i];
|
|
2608
|
-
if (!fn(oldState, newState)) {
|
|
2609
|
-
diffResult.push(numbers[i]);
|
|
2610
|
-
}
|
|
2611
|
-
}
|
|
2612
|
-
return diffResult;
|
|
2613
|
-
},
|
|
2614
|
-
getCommandIds() {
|
|
2615
|
-
const keys = Object.keys(commandMapRef);
|
|
2616
|
-
const ids = keys.map(toCommandId);
|
|
2617
|
-
return ids;
|
|
2618
|
-
},
|
|
2619
|
-
registerCommands(commandMap) {
|
|
2620
|
-
Object.assign(commandMapRef, commandMap);
|
|
2621
|
-
}
|
|
2622
|
-
};
|
|
2623
|
-
};
|
|
2624
|
-
|
|
2625
2643
|
const {
|
|
2626
2644
|
get,
|
|
2627
2645
|
set,
|
|
@@ -2629,7 +2647,7 @@ const {
|
|
|
2629
2647
|
registerCommands,
|
|
2630
2648
|
getCommandIds,
|
|
2631
2649
|
wrapGetter
|
|
2632
|
-
} = create$
|
|
2650
|
+
} = create$2();
|
|
2633
2651
|
|
|
2634
2652
|
const ListItem = 22;
|
|
2635
2653
|
|
|
@@ -3789,7 +3807,8 @@ const handleClickCurrentButKeepFocus = state => {
|
|
|
3789
3807
|
};
|
|
3790
3808
|
|
|
3791
3809
|
const openFolder = async () => {
|
|
3792
|
-
//
|
|
3810
|
+
// @ts-ignore
|
|
3811
|
+
await invoke$2(`Dialog.openFolder`);
|
|
3793
3812
|
};
|
|
3794
3813
|
|
|
3795
3814
|
const handleClickOpenFolder = async state => {
|
|
@@ -4184,7 +4203,7 @@ const handleDrop$2 = async (state, fileHandles, files) => {
|
|
|
4184
4203
|
};
|
|
4185
4204
|
};
|
|
4186
4205
|
|
|
4187
|
-
const getFileOperationsElectron = async (root, paths, fileHandles) => {
|
|
4206
|
+
const getFileOperationsElectron = async (root, paths, fileHandles, pathSeparator) => {
|
|
4188
4207
|
const operations = [];
|
|
4189
4208
|
for (let i = 0; i < paths.length; i++) {
|
|
4190
4209
|
const fileHandle = fileHandles[i];
|
|
@@ -4194,7 +4213,7 @@ const getFileOperationsElectron = async (root, paths, fileHandles) => {
|
|
|
4194
4213
|
const path = paths[i];
|
|
4195
4214
|
operations.push({
|
|
4196
4215
|
type: Copy$1,
|
|
4197
|
-
path:
|
|
4216
|
+
path: join(pathSeparator, root, name),
|
|
4198
4217
|
from: path
|
|
4199
4218
|
});
|
|
4200
4219
|
}
|
|
@@ -4202,8 +4221,9 @@ const getFileOperationsElectron = async (root, paths, fileHandles) => {
|
|
|
4202
4221
|
};
|
|
4203
4222
|
|
|
4204
4223
|
// TODO copy files in parallel
|
|
4205
|
-
const copyFilesElectron = async (root,
|
|
4206
|
-
const
|
|
4224
|
+
const copyFilesElectron = async (root, fileHandles, files, paths) => {
|
|
4225
|
+
const pathSeparator = await getPathSeparator$1(root);
|
|
4226
|
+
const operations = await getFileOperationsElectron(root, paths, fileHandles, pathSeparator);
|
|
4207
4227
|
await applyFileOperations(operations);
|
|
4208
4228
|
};
|
|
4209
4229
|
|
|
@@ -4221,7 +4241,7 @@ const handleDrop$1 = async (state, fileHandles, files, paths) => {
|
|
|
4221
4241
|
pathSeparator,
|
|
4222
4242
|
items
|
|
4223
4243
|
} = state;
|
|
4224
|
-
await copyFilesElectron(root,
|
|
4244
|
+
await copyFilesElectron(root, fileHandles, files, paths);
|
|
4225
4245
|
const mergedDirents = await getMergedDirents$1(root, pathSeparator, items);
|
|
4226
4246
|
return {
|
|
4227
4247
|
...state,
|
|
@@ -5326,6 +5346,7 @@ const renderDragData = (oldState, newState) => {
|
|
|
5326
5346
|
};
|
|
5327
5347
|
|
|
5328
5348
|
const ExplorerInput = 'ExplorerInput';
|
|
5349
|
+
const OpenFolder = 'OpenFolder';
|
|
5329
5350
|
|
|
5330
5351
|
const renderEditingSelection = (oldState, newState) => {
|
|
5331
5352
|
const {
|
|
@@ -5341,10 +5362,10 @@ const renderFocus = (oldState, newState) => {
|
|
|
5341
5362
|
return [];
|
|
5342
5363
|
}
|
|
5343
5364
|
if (newState.focus === Input$1) {
|
|
5344
|
-
return [
|
|
5365
|
+
return [FocusElementByName, ExplorerInput];
|
|
5345
5366
|
}
|
|
5346
5367
|
if (newState.focus === List) {
|
|
5347
|
-
return [
|
|
5368
|
+
return [FocusSelector, '.ListItems'];
|
|
5348
5369
|
}
|
|
5349
5370
|
// TODO
|
|
5350
5371
|
// 1. when focused, focus the outer list element
|
|
@@ -5354,10 +5375,10 @@ const renderFocus = (oldState, newState) => {
|
|
|
5354
5375
|
|
|
5355
5376
|
const renderFocusContext = (oldState, newState) => {
|
|
5356
5377
|
if (newState.focus === Input$1) {
|
|
5357
|
-
return [
|
|
5378
|
+
return [SetFocusContext, newState.uid, FocusExplorerEditBox];
|
|
5358
5379
|
}
|
|
5359
5380
|
if (newState.focus === List) {
|
|
5360
|
-
return [
|
|
5381
|
+
return [SetFocusContext, newState.uid, FocusExplorer];
|
|
5361
5382
|
}
|
|
5362
5383
|
return [];
|
|
5363
5384
|
};
|
|
@@ -5467,6 +5488,7 @@ const getExplorerWelcomeVirtualDom = isWide => {
|
|
|
5467
5488
|
}, text(youHaveNotYetOpenedAFolder()), {
|
|
5468
5489
|
type: Button$1,
|
|
5469
5490
|
className: mergeClassNames(Button$2, ButtonPrimary, isWide ? ButtonWide : ButtonNarrow),
|
|
5491
|
+
name: OpenFolder,
|
|
5470
5492
|
childCount: 1,
|
|
5471
5493
|
onClick: HandleClickOpenFolder
|
|
5472
5494
|
}, text(openFolder$1())];
|
|
@@ -5999,7 +6021,7 @@ const renderEventListeners = () => {
|
|
|
5999
6021
|
params: ['handleBlur']
|
|
6000
6022
|
}, {
|
|
6001
6023
|
name: HandleClick,
|
|
6002
|
-
params: ['handleClickAt', 'event.defaultPrevented',
|
|
6024
|
+
params: ['handleClickAt', 'event.defaultPrevented', Button$3, CtrlKey, 'event.shiftKey', ClientX, ClientY],
|
|
6003
6025
|
preventDefault: true
|
|
6004
6026
|
}, {
|
|
6005
6027
|
name: HandleInputClick,
|
|
@@ -6011,26 +6033,26 @@ const renderEventListeners = () => {
|
|
|
6011
6033
|
preventDefault: true
|
|
6012
6034
|
}, {
|
|
6013
6035
|
name: HandlePointerDown,
|
|
6014
|
-
params: ['handlePointerDown',
|
|
6036
|
+
params: ['handlePointerDown', Button$3, ClientX, ClientY]
|
|
6015
6037
|
// preventDefault: true,
|
|
6016
6038
|
}, {
|
|
6017
6039
|
name: HandleEditingInput,
|
|
6018
|
-
params: ['updateEditingValue',
|
|
6040
|
+
params: ['updateEditingValue', TargetValue]
|
|
6019
6041
|
}, {
|
|
6020
6042
|
name: HandleContextMenu,
|
|
6021
|
-
params: ['handleContextMenu',
|
|
6043
|
+
params: ['handleContextMenu', Button$3, ClientX, ClientY],
|
|
6022
6044
|
preventDefault: true
|
|
6023
6045
|
}, {
|
|
6024
6046
|
name: HandleWheel,
|
|
6025
|
-
params: ['handleWheel',
|
|
6047
|
+
params: ['handleWheel', DeltaMode, DeltaY],
|
|
6026
6048
|
passive: true
|
|
6027
6049
|
}, {
|
|
6028
6050
|
name: HandleDragOver,
|
|
6029
|
-
params: ['handleDragOver',
|
|
6051
|
+
params: ['handleDragOver', ClientX, ClientY],
|
|
6030
6052
|
preventDefault: true
|
|
6031
6053
|
}, {
|
|
6032
6054
|
name: HandleDrop,
|
|
6033
|
-
params: ['handleDrop',
|
|
6055
|
+
params: ['handleDrop', ClientX, ClientY, 'event.dataTransfer.files2', 'event.dataTransfer.files'],
|
|
6034
6056
|
preventDefault: true
|
|
6035
6057
|
}, {
|
|
6036
6058
|
name: HandleDragLeave,
|
|
@@ -6272,10 +6294,6 @@ const selectUp = state => {
|
|
|
6272
6294
|
};
|
|
6273
6295
|
};
|
|
6274
6296
|
|
|
6275
|
-
const terminate = () => {
|
|
6276
|
-
globalThis.close();
|
|
6277
|
-
};
|
|
6278
|
-
|
|
6279
6297
|
const getEditingIcon = async (editingType, value, direntType) => {
|
|
6280
6298
|
if (editingType === CreateFile) {
|
|
6281
6299
|
return invoke$1('IconTheme.getFileIcon', {
|