@lvce-editor/explorer-view 7.28.0 → 7.29.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.
@@ -1443,12 +1443,13 @@ const getIcons = async iconRequests => {
1443
1443
 
1444
1444
  const {
1445
1445
  invoke: invoke$4,
1446
+ invokeAndTransfer: invokeAndTransfer$2,
1446
1447
  set: set$6
1447
1448
  } = create$2(RendererProcess);
1448
1449
 
1449
1450
  const {
1450
1451
  invoke: invoke$3,
1451
- invokeAndTransfer,
1452
+ invokeAndTransfer: invokeAndTransfer$1,
1452
1453
  set: set$5
1453
1454
  } = create$2(RendererWorker);
1454
1455
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
@@ -1458,21 +1459,17 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
1458
1459
  number(y);
1459
1460
  await invoke$3('ContextMenu.show2', uid, menuId, x, y, args);
1460
1461
  };
1461
- const sendMessagePortToDragAndDropWorker = async port => {
1462
- const command = 'DragAndDrop.handleMessagePort';
1463
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDragAndDropWorker', port, command);
1464
- };
1465
1462
  const sendMessagePortToDialogWorker = async port => {
1466
1463
  const command = 'HandleMessagePort.handleMessagePort';
1467
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
1464
+ await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
1468
1465
  };
1469
1466
  const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
1470
1467
  const command = 'IconTheme.handleMessagePort';
1471
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
1468
+ await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
1472
1469
  };
1473
1470
  const sendMessagePortToFileSystemWorker$1 = async (port, rpcId) => {
1474
1471
  const command = 'FileSystem.handleMessagePort';
1475
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
1472
+ await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
1476
1473
  };
1477
1474
  const confirm$1 = async (message, options) => {
1478
1475
  const result = await invoke$3('ConfirmPrompt.prompt', message, options);
@@ -1483,7 +1480,7 @@ const writeClipBoardText = async text => {
1483
1480
  };
1484
1481
  const sendMessagePortToSourceControlWorker = async port => {
1485
1482
  const command = 'SourceControl.handleMessagePort';
1486
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSourceControlWorker', port, command, 0);
1483
+ await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToSourceControlWorker', port, command, 0);
1487
1484
  };
1488
1485
  const openUri$1 = async (uri, focus, options) => {
1489
1486
  await invoke$3('Main.openUri', {
@@ -1506,7 +1503,8 @@ const create$1 = () => {
1506
1503
  const commandQueues = new Map();
1507
1504
  const generations = Object.create(null);
1508
1505
  const states = Object.create(null);
1509
- const commandMapRef = {};
1506
+ const commandMapRef = Object.create(null);
1507
+ const commandsById = Object.create(null);
1510
1508
  const getGeneration = uid => generations[uid] || 0;
1511
1509
  const isCurrentGeneration = (uid, generation) => {
1512
1510
  return states[uid] !== undefined && getGeneration(uid) === generation;
@@ -1568,6 +1566,18 @@ const create$1 = () => {
1568
1566
  delete states[key];
1569
1567
  }
1570
1568
  },
1569
+ createDirectEventCommandMap(requestRender) {
1570
+ return {
1571
+ async 'Viewlet.executeViewletCommand'(uid, command, ...args) {
1572
+ const fn = commandsById[command];
1573
+ if (!fn) {
1574
+ throw new Error(`Viewlet command not found: ${command}`);
1575
+ }
1576
+ await fn(uid, ...args);
1577
+ await requestRender(uid);
1578
+ }
1579
+ };
1580
+ },
1571
1581
  diff(uid, modules, numbers) {
1572
1582
  const {
1573
1583
  oldState,
@@ -1599,6 +1609,9 @@ const create$1 = () => {
1599
1609
  },
1600
1610
  registerCommands(commandMap) {
1601
1611
  Object.assign(commandMapRef, commandMap);
1612
+ for (const [key, fn] of Object.entries(commandMap)) {
1613
+ commandsById[toCommandId(key)] = fn;
1614
+ }
1602
1615
  },
1603
1616
  set(uid, oldState, newState, scheduledState) {
1604
1617
  const current = states[uid];
@@ -2315,6 +2328,9 @@ const isConnected = () => {
2315
2328
  const invoke = (method, ...params) => {
2316
2329
  return invoke$4(method, ...params);
2317
2330
  };
2331
+ const invokeAndTransfer = (method, ...params) => {
2332
+ return invokeAndTransfer$2(method, ...params);
2333
+ };
2318
2334
  const requestPostRenderFocus = uid => {
2319
2335
  postRenderFocusRequests.add(uid);
2320
2336
  };
@@ -2855,11 +2871,15 @@ const toCollapsedDirent = dirent => {
2855
2871
 
2856
2872
  const collapseAll = async state => {
2857
2873
  const {
2858
- items
2874
+ editingIndex
2859
2875
  } = state;
2876
+ const stateWithoutEdit = editingIndex === -1 ? state : await cancelEditInternal(state, true);
2877
+ const {
2878
+ items
2879
+ } = stateWithoutEdit;
2860
2880
  const newDirents = items.filter(isTopLevel).map(toCollapsedDirent);
2861
2881
  return {
2862
- ...state,
2882
+ ...stateWithoutEdit,
2863
2883
  expandedPaths: [],
2864
2884
  focusedIndex: 0,
2865
2885
  items: newDirents
@@ -4946,13 +4966,13 @@ const NewFolder$1 = 'NewFolder';
4946
4966
  const OpenFolder = 'OpenFolder';
4947
4967
  const Refresh$1 = 'Refresh';
4948
4968
 
4949
- const isFolder = direntType => {
4969
+ const isFolder$1 = direntType => {
4950
4970
  return [Directory, DirectoryExpanded, SymLinkFolder].includes(direntType);
4951
4971
  };
4952
4972
  const getFittingIndex = (dirents, startIndex) => {
4953
4973
  for (let i = startIndex; i >= 0; i--) {
4954
4974
  const dirent = dirents[i];
4955
- if (dirent && isFolder(dirent.type)) {
4975
+ if (dirent && isFolder$1(dirent.type)) {
4956
4976
  return i;
4957
4977
  }
4958
4978
  }
@@ -4995,7 +5015,14 @@ const getNewChildDirentsForNewDirent = async (items, depth, parentPath, direntTy
4995
5015
  return allChildDirents;
4996
5016
  };
4997
5017
 
4998
- const getNewDirentsForNewDirent = async (items, focusedIndex, type, root, excluded = []) => {
5018
+ const isFolder = type => {
5019
+ return [Directory, DirectoryExpanded, DirectoryExpanding, SymLinkFolder].includes(type);
5020
+ };
5021
+ const getTopLevelFileIndex = items => {
5022
+ const topLevelDepth = items[0]?.depth;
5023
+ return items.findIndex(item => item.depth === topLevelDepth && !isFolder(item.type));
5024
+ };
5025
+ const getNewDirentsForNewDirent = async (items, focusedIndex, type, root, excluded = [], insertAtFolderBoundary = false) => {
4999
5026
  if (items.length === 0 || focusedIndex === -1) {
5000
5027
  const newDirent = {
5001
5028
  depth: 0,
@@ -5010,7 +5037,14 @@ const getNewDirentsForNewDirent = async (items, focusedIndex, type, root, exclud
5010
5037
  if (type === EditingFolder) {
5011
5038
  return [newDirent, ...items];
5012
5039
  }
5013
- return [...items, newDirent];
5040
+ if (!insertAtFolderBoundary) {
5041
+ return [...items, newDirent];
5042
+ }
5043
+ const fileIndex = getTopLevelFileIndex(items);
5044
+ if (fileIndex === -1) {
5045
+ return [...items, newDirent];
5046
+ }
5047
+ return [...items.slice(0, fileIndex), newDirent, ...items.slice(fileIndex)];
5014
5048
  }
5015
5049
  const focusedItem = items[focusedIndex];
5016
5050
  if (!focusedItem) {
@@ -5060,7 +5094,6 @@ const getNewDirentType = editingType => {
5060
5094
  };
5061
5095
 
5062
5096
  const newDirent = async (state, editingType, editingIcon = '') => {
5063
- // TODO do it like vscode, select position between folders and files
5064
5097
  const {
5065
5098
  editingIndex,
5066
5099
  editingSessionId,
@@ -5074,7 +5107,7 @@ const newDirent = async (state, editingType, editingIcon = '') => {
5074
5107
  }
5075
5108
  const index = getFittingIndex(items, focusedIndex);
5076
5109
  const direntType = getNewDirentType(editingType);
5077
- const newDirents = await getNewDirentsForNewDirent(items, index, direntType, root, excluded);
5110
+ const newDirents = await getNewDirentsForNewDirent(items, index, direntType, root, excluded, focusedIndex === -1);
5078
5111
  const newEditingIndex = newDirents.findIndex(item => item.type === EditingFile || item.type === EditingFolder);
5079
5112
  return {
5080
5113
  ...state,
@@ -8570,7 +8603,7 @@ const commandMap = {
8570
8603
  };
8571
8604
 
8572
8605
  const send$2 = async port => {
8573
- await sendMessagePortToDragAndDropWorker(port);
8606
+ await invokeAndTransfer('DragAndDrop.handleMessagePort', port);
8574
8607
  };
8575
8608
  const createDragAndDropWorkerRpc = async () => {
8576
8609
  return create$4({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "7.28.0",
3
+ "version": "7.29.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",