@lvce-editor/explorer-view 7.32.1 → 7.34.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.
@@ -1413,10 +1413,7 @@ const {
1413
1413
  invoke: invoke$6,
1414
1414
  set: set$9
1415
1415
  } = create$2(DragAndDropWorker);
1416
- const getDroppedItems$1 = async (itemIds, isElectron) => {
1417
- return invoke$6('DragAndDrop.getDroppedItems', itemIds, isElectron);
1418
- };
1419
- const getDroppedItemsByDropId = async (dropId, isElectron) => {
1416
+ const getDroppedItemsByDropId$1 = async (dropId, isElectron) => {
1420
1417
  return invoke$6('DragAndDrop.getDroppedItemsByDropId', dropId, isElectron);
1421
1418
  };
1422
1419
  const discardDrop = async dropId => {
@@ -1459,6 +1456,9 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
1459
1456
  number(y);
1460
1457
  await invoke$3('ContextMenu.show2', uid, menuId, x, y, args);
1461
1458
  };
1459
+ const getFileHandles = async fileIds => {
1460
+ return invoke$3('FileHandles.get', fileIds);
1461
+ };
1462
1462
  const sendMessagePortToDialogWorker = async port => {
1463
1463
  const command = 'HandleMessagePort.handleMessagePort';
1464
1464
  await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
@@ -6161,30 +6161,11 @@ const getFileOperations = (root, uploadTree) => {
6161
6161
  return operations;
6162
6162
  };
6163
6163
 
6164
- const isDroppedFile = item => {
6165
- return item.kind === 'file' && 'value' in item;
6166
- };
6167
- const getFileSystemHandle = item => {
6168
- if (isDroppedFile(item)) {
6169
- return item.value;
6170
- }
6171
- return item;
6172
- };
6173
- const getDroppedName = item => {
6174
- if (isDroppedFile(item)) {
6175
- return item.value.name;
6176
- }
6177
- return item.name;
6178
- };
6179
- const getFileSystemHandlesNormalized = fileSystemHandles => {
6180
- return Array.from(fileSystemHandles, getFileSystemHandle);
6181
- };
6182
6164
  const uploadFileSystemHandles = async (root, pathSeparator, fileSystemHandles) => {
6183
6165
  if (fileSystemHandles.length === 0) {
6184
6166
  return true;
6185
6167
  }
6186
- const fileSystemHandlesNormalized = getFileSystemHandlesNormalized(fileSystemHandles);
6187
- const uploadTree = await createUploadTree(root, fileSystemHandlesNormalized);
6168
+ const uploadTree = await createUploadTree(root, fileSystemHandles);
6188
6169
  const fileOperations = getFileOperations(root, uploadTree);
6189
6170
  await applyFileOperations(fileOperations);
6190
6171
 
@@ -6224,15 +6205,14 @@ const getFirstDroppedDirectory = (state, fileHandles) => {
6224
6205
  if (root !== '') {
6225
6206
  return undefined;
6226
6207
  }
6227
- for (const item of fileHandles) {
6228
- const fileHandle = getFileSystemHandle(item);
6208
+ for (const fileHandle of fileHandles) {
6229
6209
  if (isDirectoryHandle(fileHandle)) {
6230
6210
  return fileHandle;
6231
6211
  }
6232
6212
  }
6233
6213
  return undefined;
6234
6214
  };
6235
- const handleDrop$2 = async (state, fileHandles, files, paths) => {
6215
+ const handleDrop$2 = async (state, fileHandles, paths) => {
6236
6216
  const {
6237
6217
  excluded,
6238
6218
  items,
@@ -6269,7 +6249,9 @@ const getFileOperationsElectron = async (root, paths, fileHandles, pathSeparator
6269
6249
  const operations = [];
6270
6250
  for (let i = 0; i < paths.length; i++) {
6271
6251
  const fileHandle = fileHandles[i];
6272
- const name = getDroppedName(fileHandle);
6252
+ const {
6253
+ name
6254
+ } = fileHandle;
6273
6255
  const path = paths[i];
6274
6256
  operations.push({
6275
6257
  from: path,
@@ -6281,7 +6263,7 @@ const getFileOperationsElectron = async (root, paths, fileHandles, pathSeparator
6281
6263
  };
6282
6264
 
6283
6265
  // TODO copy files in parallel
6284
- const copyFilesElectron = async (root, fileHandles, files, paths) => {
6266
+ const copyFilesElectron = async (root, fileHandles, paths) => {
6285
6267
  const operations = await getFileOperationsElectron(root, paths, fileHandles, Slash);
6286
6268
  await applyFileOperations(operations);
6287
6269
  };
@@ -6310,14 +6292,14 @@ const getFirstDroppedDirectoryPath = (state, fileHandles, paths) => {
6310
6292
  return undefined;
6311
6293
  }
6312
6294
  for (let i = 0; i < fileHandles.length; i++) {
6313
- const fileHandle = getFileSystemHandle(fileHandles[i]);
6295
+ const fileHandle = fileHandles[i];
6314
6296
  if (isDirectoryHandle(fileHandle)) {
6315
6297
  return paths[i];
6316
6298
  }
6317
6299
  }
6318
6300
  return undefined;
6319
6301
  };
6320
- const handleDrop$1 = async (state, fileHandles, files, paths) => {
6302
+ const handleDrop$1 = async (state, fileHandles, paths) => {
6321
6303
  const {
6322
6304
  excluded,
6323
6305
  items,
@@ -6334,7 +6316,7 @@ const handleDrop$1 = async (state, fileHandles, files, paths) => {
6334
6316
  dropTargets: []
6335
6317
  };
6336
6318
  }
6337
- await copyFilesElectron(root, fileHandles, files, paths);
6319
+ await copyFilesElectron(root, fileHandles, paths);
6338
6320
  const mergedDirents = await getMergedDirents$1(root, pathSeparator, items, excluded);
6339
6321
  return {
6340
6322
  ...state,
@@ -6470,7 +6452,7 @@ const getModule = isElectron => {
6470
6452
  }
6471
6453
  return handleDrop$2;
6472
6454
  };
6473
- const handleDropRoot = async (state, fileHandles, files, paths) => {
6455
+ const handleDropRoot = async (state, fileHandles, paths) => {
6474
6456
  const {
6475
6457
  isReadonly,
6476
6458
  platform,
@@ -6484,7 +6466,7 @@ const handleDropRoot = async (state, fileHandles, files, paths) => {
6484
6466
  }
6485
6467
  const isElectron = platform === Electron;
6486
6468
  const fn = getModule(isElectron);
6487
- return fn(state, fileHandles, files, paths);
6469
+ return fn(state, fileHandles, paths);
6488
6470
  };
6489
6471
 
6490
6472
  const getEndIndex = (items, index, dirent) => {
@@ -6504,7 +6486,7 @@ const getMergedDirents = (items, index, dirent, childDirents) => {
6504
6486
  }, ...childDirents, ...items.slice(endIndex)];
6505
6487
  return mergedDirents;
6506
6488
  };
6507
- const handleDropIntoFolder = async (state, dirent, index, fileHandles, files, paths) => {
6489
+ const handleDropIntoFolder = async (state, dirent, index, fileHandles) => {
6508
6490
  const {
6509
6491
  excluded,
6510
6492
  items,
@@ -6521,17 +6503,17 @@ const handleDropIntoFolder = async (state, dirent, index, fileHandles, files, pa
6521
6503
  items: mergedDirents
6522
6504
  };
6523
6505
  };
6524
- const handleDropIntoFile = (state, dirent, index, fileHandles, files, paths) => {
6506
+ const handleDropIntoFile = (state, dirent, index, fileHandles, paths) => {
6525
6507
  const {
6526
6508
  items
6527
6509
  } = state;
6528
6510
  const parentIndex = getParentStartIndex(items, index);
6529
6511
  if (parentIndex === -1) {
6530
- return handleDropRoot(state, fileHandles, files, paths);
6512
+ return handleDropRoot(state, fileHandles, paths);
6531
6513
  }
6532
- return handleDropIndex(state, fileHandles, files, paths, parentIndex);
6514
+ return handleDropIndex(state, fileHandles, paths, parentIndex);
6533
6515
  };
6534
- const handleDropIndex = async (state, fileHandles, files, paths, index) => {
6516
+ const handleDropIndex = async (state, fileHandles, paths, index) => {
6535
6517
  const {
6536
6518
  isReadonly,
6537
6519
  items
@@ -6551,7 +6533,7 @@ const handleDropIndex = async (state, fileHandles, files, paths, index) => {
6551
6533
  case DirectoryExpanded:
6552
6534
  return handleDropIntoFolder(state, dirent, index, fileHandles);
6553
6535
  case File:
6554
- return handleDropIntoFile(state, dirent, index, fileHandles, files, paths);
6536
+ return handleDropIntoFile(state, dirent, index, fileHandles, paths);
6555
6537
  default:
6556
6538
  return state;
6557
6539
  }
@@ -6566,10 +6548,9 @@ const getDropHandler = index => {
6566
6548
  }
6567
6549
  };
6568
6550
 
6569
- const getDroppedItems = async (dropIdOrItemIds, isElectron) => {
6570
- const result = typeof dropIdOrItemIds === 'number' ? await getDroppedItemsByDropId(dropIdOrItemIds, isElectron) : await getDroppedItems$1(dropIdOrItemIds, isElectron);
6551
+ const toExplorerDroppedItems = (result, isElectron) => {
6571
6552
  const files = isElectron ? result.files : result.files.filter(file => file.handle);
6572
- const fileHandles = files.map(file => file.handle || {
6553
+ const fileHandles = files.map(file => file.handle ?? {
6573
6554
  kind: file.kind,
6574
6555
  name: file.name
6575
6556
  });
@@ -6580,6 +6561,29 @@ const getDroppedItems = async (dropIdOrItemIds, isElectron) => {
6580
6561
  uris: result.uris
6581
6562
  };
6582
6563
  };
6564
+ const getDroppedItemsByDropId = async (dropId, isElectron) => {
6565
+ const result = await getDroppedItemsByDropId$1(dropId, isElectron);
6566
+ return toExplorerDroppedItems(result, isElectron);
6567
+ };
6568
+ const getClipboardItems = async (itemIds, isElectron) => {
6569
+ const items = await getFileHandles(itemIds);
6570
+ const files = items.filter(item => item.kind === 'file' || isElectron && item.kind === 'file-legacy');
6571
+ const fileHandles = files.map(item => {
6572
+ if (item.kind === 'file') {
6573
+ return item.value;
6574
+ }
6575
+ return {
6576
+ kind: 'file',
6577
+ name: item.value.name
6578
+ };
6579
+ });
6580
+ const paths = files.map(item => item.path ?? '');
6581
+ return {
6582
+ fileHandles,
6583
+ paths,
6584
+ uris: []
6585
+ };
6586
+ };
6583
6587
 
6584
6588
  const directoryTypes$1 = new Set([Directory, DirectoryExpanded, DirectoryExpanding, EditingDirectoryExpanded, EditingFolder, SymLinkFolder]);
6585
6589
  const getDragUri = item => {
@@ -6606,7 +6610,7 @@ const getInternalDragPaths = (items, uris) => {
6606
6610
  return paths;
6607
6611
  };
6608
6612
 
6609
- const handleDrop = async (state, x, y, dropIdOrFileIds) => {
6613
+ const handleDrop = async (state, x, y, dropId) => {
6610
6614
  const {
6611
6615
  isReadonly,
6612
6616
  items,
@@ -6614,9 +6618,7 @@ const handleDrop = async (state, x, y, dropIdOrFileIds) => {
6614
6618
  root
6615
6619
  } = state;
6616
6620
  if (isReadonly && root !== '') {
6617
- if (typeof dropIdOrFileIds === 'number') {
6618
- await discardDrop(dropIdOrFileIds);
6619
- }
6621
+ await discardDrop(dropId);
6620
6622
  return state;
6621
6623
  }
6622
6624
  try {
@@ -6625,12 +6627,12 @@ const handleDrop = async (state, x, y, dropIdOrFileIds) => {
6625
6627
  fileHandles,
6626
6628
  paths,
6627
6629
  uris
6628
- } = await getDroppedItems(dropIdOrFileIds, isElectron);
6630
+ } = await getDroppedItemsByDropId(dropId, isElectron);
6629
6631
  const internalPaths = getInternalDragPaths(items, uris);
6630
6632
  const droppedPaths = internalPaths.length > 0 ? internalPaths : paths;
6631
6633
  const index = getIndexFromPosition(state, x, y);
6632
6634
  const fn = getDropHandler(index);
6633
- const result = await fn(state, fileHandles, [], droppedPaths, index);
6635
+ const result = await fn(state, fileHandles, droppedPaths, index);
6634
6636
  return result;
6635
6637
  } catch (error) {
6636
6638
  throw new VError(error, 'Failed to drop files');
@@ -7063,7 +7065,7 @@ const handleNativePaste = async (state, itemIds) => {
7063
7065
  const {
7064
7066
  fileHandles,
7065
7067
  paths
7066
- } = await getDroppedItems(itemIds, isElectron);
7068
+ } = await getClipboardItems(itemIds, isElectron);
7067
7069
  if (isElectron) {
7068
7070
  const nativePaths = paths.filter(Boolean);
7069
7071
  if (nativePaths.length === 0) {
@@ -7076,7 +7078,7 @@ const handleNativePaste = async (state, itemIds) => {
7076
7078
  });
7077
7079
  }
7078
7080
  const handleDrop = getDropHandler(focusedIndex);
7079
- return handleDrop(state, fileHandles, [], paths, focusedIndex);
7081
+ return handleDrop(state, fileHandles, paths, focusedIndex);
7080
7082
  } catch (error) {
7081
7083
  throw new VError(error, 'Failed to paste native files');
7082
7084
  }
@@ -4,7 +4,7 @@
4
4
  "description": "Controls whether the Explorer uses chevrons instead of folder icons to show expanded and collapsed folders.",
5
5
  "heading": "Use Chevrons",
6
6
  "id": "explorer.useChevrons",
7
- "type": 3,
7
+ "type": "boolean",
8
8
  "value": "true"
9
9
  },
10
10
  {
@@ -12,7 +12,7 @@
12
12
  "description": "Controls whether the Explorer asks for confirmation before deleting files and folders.",
13
13
  "heading": "Confirm Delete",
14
14
  "id": "explorer.confirmdelete",
15
- "type": 3,
15
+ "type": "boolean",
16
16
  "value": "true"
17
17
  },
18
18
  {
@@ -20,7 +20,7 @@
20
20
  "description": "Controls whether the Explorer asks for confirmation before pasting files and folders.",
21
21
  "heading": "Confirm Paste",
22
22
  "id": "explorer.confirmpaste",
23
- "type": 3,
23
+ "type": "boolean",
24
24
  "value": "false"
25
25
  },
26
26
  {
@@ -28,7 +28,7 @@
28
28
  "description": "Controls whether files ignored by Git are decorated in the Explorer.",
29
29
  "heading": "Git Ignore Decorations",
30
30
  "id": "explorer.gitIgnoreDecorations",
31
- "type": 3,
31
+ "type": "boolean",
32
32
  "value": "true"
33
33
  },
34
34
  {
@@ -36,7 +36,7 @@
36
36
  "description": "Controls whether expanded folders are preserved for the current workspace when the Explorer rebuilds and across editor restarts.",
37
37
  "heading": "Preserve Expand State",
38
38
  "id": "explorer.preserveExpandState",
39
- "type": 3,
39
+ "type": "boolean",
40
40
  "value": "true"
41
41
  },
42
42
  {
@@ -44,7 +44,7 @@
44
44
  "description": "Controls whether source control decorations are shown in the Explorer.",
45
45
  "heading": "Source Control Decorations",
46
46
  "id": "explorer.sourceControlDecorations",
47
- "type": 3,
47
+ "type": "boolean",
48
48
  "value": "true"
49
49
  },
50
50
  {
@@ -52,7 +52,7 @@
52
52
  "description": "Configures glob patterns for excluding files and folders from the Explorer.",
53
53
  "heading": "Exclude",
54
54
  "id": "files.exclude",
55
- "type": 4,
55
+ "type": "array",
56
56
  "value": {
57
57
  "**/.DS_Store": true,
58
58
  "**/.git": true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "7.32.1",
3
+ "version": "7.34.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",