@lvce-editor/explorer-view 7.27.0 → 7.28.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.
@@ -1355,10 +1355,10 @@ const Button$3 = 'event.button';
1355
1355
  const ClientX = 'event.clientX';
1356
1356
  const ClientY = 'event.clientY';
1357
1357
  const CtrlKey = 'event.ctrlKey';
1358
- const DataTransferFiles2 = 'event.dataTransfer.files2';
1359
1358
  const DefaultPrevented = 'event.defaultPrevented';
1360
1359
  const DeltaMode = 'event.deltaMode';
1361
1360
  const DeltaY = 'event.deltaY';
1361
+ const DropId = 'event.dropId';
1362
1362
  const EventTargetClassName = 'event.target.className';
1363
1363
  const IsTrusted = 'event.isTrusted';
1364
1364
  const Key = 'event.key';
@@ -1416,6 +1416,12 @@ const {
1416
1416
  const getDroppedItems$1 = async (itemIds, isElectron) => {
1417
1417
  return invoke$6('DragAndDrop.getDroppedItems', itemIds, isElectron);
1418
1418
  };
1419
+ const getDroppedItemsByDropId = async (dropId, isElectron) => {
1420
+ return invoke$6('DragAndDrop.getDroppedItemsByDropId', dropId, isElectron);
1421
+ };
1422
+ const discardDrop = async dropId => {
1423
+ await invoke$6('DragAndDrop.discardDrop', dropId);
1424
+ };
1419
1425
 
1420
1426
  const {
1421
1427
  set: set$8
@@ -2296,6 +2302,30 @@ const refreshWorkspace = async () => {
2296
2302
  }
2297
2303
  };
2298
2304
 
2305
+ const state$1 = {
2306
+ connected: false
2307
+ };
2308
+ const postRenderFocusRequests = new Set();
2309
+ const isConnected = () => {
2310
+ const {
2311
+ connected
2312
+ } = state$1;
2313
+ return connected;
2314
+ };
2315
+ const invoke = (method, ...params) => {
2316
+ return invoke$4(method, ...params);
2317
+ };
2318
+ const requestPostRenderFocus = uid => {
2319
+ postRenderFocusRequests.add(uid);
2320
+ };
2321
+ const set$2 = rpc => {
2322
+ set$6(rpc);
2323
+ state$1.connected = true;
2324
+ };
2325
+ const takePostRenderFocus = uid => {
2326
+ return postRenderFocusRequests.delete(uid);
2327
+ };
2328
+
2299
2329
  const treeToArrayInternal = (map, root, items, path, depth) => {
2300
2330
  const children = map[path];
2301
2331
  if (!children) {
@@ -2490,6 +2520,16 @@ const focusEditorAfterExplorerRender = () => {
2490
2520
  void invoke$3('Main.focus');
2491
2521
  }, 0);
2492
2522
  };
2523
+ const openCreatedFile = async absolutePath => {
2524
+ await openUri(absolutePath, true);
2525
+ focusEditorAfterExplorerRender();
2526
+ };
2527
+ const finishCreate = async (absolutePath, newDirentType) => {
2528
+ await refreshWorkspace();
2529
+ if (newDirentType === File) {
2530
+ await openCreatedFile(absolutePath);
2531
+ }
2532
+ };
2493
2533
  const acceptCreate = async (state, newDirentType) => {
2494
2534
  const {
2495
2535
  editingValue,
@@ -2497,7 +2537,8 @@ const acceptCreate = async (state, newDirentType) => {
2497
2537
  focusedIndex,
2498
2538
  items,
2499
2539
  pathSeparator,
2500
- root
2540
+ root,
2541
+ uid
2501
2542
  } = state;
2502
2543
  const newFileName = editingValue;
2503
2544
  const siblingFileNames = getSiblingFileNames(items, focusedIndex);
@@ -2526,10 +2567,13 @@ const acceptCreate = async (state, newDirentType) => {
2526
2567
  const newItems = treeToArray$1(merged, root);
2527
2568
  const dirents = newItems;
2528
2569
  const newFocusedIndex = getIndex(newItems, absolutePath);
2529
- await refreshWorkspace();
2530
- if (newDirentType === File) {
2531
- await openUri(absolutePath, true);
2532
- focusEditorAfterExplorerRender();
2570
+ if (isConnected()) {
2571
+ if (newDirentType === File) {
2572
+ await openUri(absolutePath, true);
2573
+ requestPostRenderFocus(uid);
2574
+ }
2575
+ } else {
2576
+ await finishCreate(absolutePath, newDirentType);
2533
2577
  }
2534
2578
  return {
2535
2579
  ...state,
@@ -2905,16 +2949,16 @@ const copyRelativePath = async state => {
2905
2949
  };
2906
2950
 
2907
2951
  const missingDialogWorkerRelay = 'Command "SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker" not found';
2908
- const state$1 = {
2952
+ const state = {
2909
2953
  isTest: false
2910
2954
  };
2911
2955
  const setIsTest = value => {
2912
- state$1.isTest = value;
2956
+ state.isTest = value;
2913
2957
  };
2914
2958
  const confirm = async message => {
2915
2959
  const {
2916
2960
  isTest
2917
- } = state$1;
2961
+ } = state;
2918
2962
  if (isTest) {
2919
2963
  return confirm$1(message);
2920
2964
  }
@@ -2929,7 +2973,7 @@ const confirm = async message => {
2929
2973
  };
2930
2974
 
2931
2975
  const commandCompletions = new WeakMap();
2932
- const set$2 = (state, completion) => {
2976
+ const set$1 = (state, completion) => {
2933
2977
  commandCompletions.set(state, completion);
2934
2978
  return state;
2935
2979
  };
@@ -3750,7 +3794,7 @@ const {
3750
3794
  get,
3751
3795
  getCommandIds,
3752
3796
  registerCommands,
3753
- set: set$1,
3797
+ set,
3754
3798
  wrapGetter
3755
3799
  } = create$1();
3756
3800
  const commandQueues = new Map();
@@ -3784,6 +3828,9 @@ const enqueueCommand = async (id, command) => {
3784
3828
  const hasSameVisibleExplorerItemInputs = (oldState, newState) => {
3785
3829
  return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.height === newState.height && oldState.itemHeight === newState.itemHeight && oldState.focusedIndex === newState.focusedIndex && oldState.editingIndex === newState.editingIndex && oldState.editingSessionId === newState.editingSessionId && oldState.editingIcon === newState.editingIcon && oldState.cutItems === newState.cutItems && oldState.editingErrorMessage === newState.editingErrorMessage && oldState.dropTargets === newState.dropTargets && oldState.fileIconCache === newState.fileIconCache && oldState.decorations === newState.decorations && oldState.useChevrons === newState.useChevrons && oldState.sourceControlIgnoredUris === newState.sourceControlIgnoredUris;
3786
3830
  };
3831
+ const hasSameDragDataInputs = (oldState, newState) => {
3832
+ return oldState.isPointerDown === newState.isPointerDown && oldState.pointerDownIndex === newState.pointerDownIndex;
3833
+ };
3787
3834
  const updateGitIgnoredUris = (state, generation, sourceControlIgnoredUris) => {
3788
3835
  const {
3789
3836
  gitIgnoreGeneration
@@ -3880,10 +3927,10 @@ const wrapListItemCommandInternal = (fn, queued) => {
3880
3927
  useChevrons
3881
3928
  } = updatedState;
3882
3929
  const intermediate = get(id);
3883
- set$1(id, intermediate.oldState, updatedState, intermediate.scheduledState);
3930
+ set(id, intermediate.oldState, updatedState, intermediate.scheduledState);
3884
3931
  if (hasSameVisibleExplorerItemInputs(intermediate.newState, updatedState)) {
3885
- if (updatedState.inputSource === User) {
3886
- set$1(id, intermediate.oldState, updatedState);
3932
+ if (updatedState.inputSource === User || !hasSameDragDataInputs(intermediate.newState, updatedState)) {
3933
+ set(id, intermediate.oldState, updatedState);
3887
3934
  }
3888
3935
  return {
3889
3936
  completion
@@ -3904,7 +3951,7 @@ const wrapListItemCommandInternal = (fn, queued) => {
3904
3951
  visibleExplorerItems
3905
3952
  };
3906
3953
  const intermediate2 = get(id);
3907
- set$1(id, intermediate2.oldState, finalState);
3954
+ set(id, intermediate2.oldState, finalState);
3908
3955
  maybeScheduleGitIgnoredUrisUpdate(newState, finalState);
3909
3956
  return {
3910
3957
  completion
@@ -4014,7 +4061,7 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0, ass
4014
4061
  x,
4015
4062
  y
4016
4063
  };
4017
- set$1(state.uid, state, state);
4064
+ set(state.uid, state, state);
4018
4065
  return state;
4019
4066
  };
4020
4067
 
@@ -4832,7 +4879,7 @@ const handleClickFile = async (state, dirent, index, keepFocus = false) => {
4832
4879
  focused: keepFocus,
4833
4880
  focusedIndex: index
4834
4881
  };
4835
- return set$2(newState, completion);
4882
+ return set$1(newState, completion);
4836
4883
  };
4837
4884
 
4838
4885
  const handleClickSymLink = async (state, dirent, index) => {
@@ -5261,7 +5308,7 @@ const handleClick = async (state, index, keepFocus = false) => {
5261
5308
  ...newState,
5262
5309
  ...resetEditing
5263
5310
  };
5264
- return completion ? set$2(finalState, completion) : finalState;
5311
+ return completion ? set$1(finalState, completion) : finalState;
5265
5312
  };
5266
5313
 
5267
5314
  // export const handleBlur=()=>{}
@@ -5409,7 +5456,7 @@ const handleContextMenuAtIndex = async (state, index, x, y) => {
5409
5456
  focusedIndex: index,
5410
5457
  items: newItems
5411
5458
  };
5412
- set$1(uid, state, newState);
5459
+ set(uid, state, newState);
5413
5460
  await show2(uid, Explorer, x, y, {
5414
5461
  menuId: Explorer
5415
5462
  });
@@ -5513,7 +5560,7 @@ const handleDoubleClick = async (state, eventX, eventY) => {
5513
5560
  const item = state.items[index];
5514
5561
  const type = normalizeDirentType(item.type);
5515
5562
  if (type === File || type === SymLinkFile) {
5516
- return set$2(state, openUri(item.path, true));
5563
+ return set$1(state, openUri(item.path, true));
5517
5564
  }
5518
5565
  return state;
5519
5566
  };
@@ -6403,8 +6450,8 @@ const getDropHandler = index => {
6403
6450
  }
6404
6451
  };
6405
6452
 
6406
- const getDroppedItems = async (itemIds, isElectron) => {
6407
- const result = await getDroppedItems$1(itemIds, isElectron);
6453
+ const getDroppedItems = async (dropIdOrItemIds, isElectron) => {
6454
+ const result = typeof dropIdOrItemIds === 'number' ? await getDroppedItemsByDropId(dropIdOrItemIds, isElectron) : await getDroppedItems$1(dropIdOrItemIds, isElectron);
6408
6455
  const files = isElectron ? result.files : result.files.filter(file => file.handle);
6409
6456
  const fileHandles = files.map(file => file.handle || {
6410
6457
  kind: file.kind,
@@ -6443,8 +6490,11 @@ const getInternalDragPaths = (items, uris) => {
6443
6490
  return paths;
6444
6491
  };
6445
6492
 
6446
- const handleDrop = async (state, x, y, fileIds) => {
6493
+ const handleDrop = async (state, x, y, dropIdOrFileIds) => {
6447
6494
  if (state.isReadonly && state.root !== '') {
6495
+ if (typeof dropIdOrFileIds === 'number') {
6496
+ await discardDrop(dropIdOrFileIds);
6497
+ }
6448
6498
  return state;
6449
6499
  }
6450
6500
  try {
@@ -6453,7 +6503,7 @@ const handleDrop = async (state, x, y, fileIds) => {
6453
6503
  fileHandles,
6454
6504
  paths,
6455
6505
  uris
6456
- } = await getDroppedItems(fileIds, isElectron);
6506
+ } = await getDroppedItems(dropIdOrFileIds, isElectron);
6457
6507
  const internalPaths = getInternalDragPaths(state.items, uris);
6458
6508
  const droppedPaths = internalPaths.length > 0 ? internalPaths : paths;
6459
6509
  const index = getIndexFromPosition(state, x, y);
@@ -6598,23 +6648,6 @@ const handleKeyDown = (state, defaultPrevented, key) => {
6598
6648
  };
6599
6649
  };
6600
6650
 
6601
- const state = {
6602
- connected: false
6603
- };
6604
- const isConnected = () => {
6605
- const {
6606
- connected
6607
- } = state;
6608
- return connected;
6609
- };
6610
- const invoke = (method, ...params) => {
6611
- return invoke$4(method, ...params);
6612
- };
6613
- const set = rpc => {
6614
- set$6(rpc);
6615
- state.connected = true;
6616
- };
6617
-
6618
6651
  const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess = true) => {
6619
6652
  const executeViewletCommand = async (uid, command, ...args) => {
6620
6653
  const fn = viewletCommandMap[`Explorer.${command}`];
@@ -6623,6 +6656,11 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
6623
6656
  }
6624
6657
  await fn(uid, ...args);
6625
6658
  await invoke$3('Viewlet.requestRender', uid);
6659
+ if (takePostRenderFocus(uid)) {
6660
+ setTimeout(() => {
6661
+ void invoke$3('Main.focus');
6662
+ }, 0);
6663
+ }
6626
6664
  };
6627
6665
  const rpc = await create$6({
6628
6666
  commandMap: {
@@ -6631,7 +6669,7 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
6631
6669
  messagePort: port
6632
6670
  });
6633
6671
  if (setAsRendererProcess) {
6634
- set(rpc);
6672
+ set$2(rpc);
6635
6673
  }
6636
6674
  };
6637
6675
 
@@ -7928,11 +7966,12 @@ const applyRender = (oldState, newState, diffResult) => {
7928
7966
 
7929
7967
  const render2 = async (uid, _diffResult) => {
7930
7968
  const {
7969
+ newState,
7931
7970
  oldState,
7932
7971
  scheduledState
7933
7972
  } = get(uid);
7934
7973
  const diffResult = diff(oldState, scheduledState);
7935
- set$1(uid, scheduledState, scheduledState);
7974
+ set(uid, scheduledState, newState, scheduledState);
7936
7975
  const commands = applyRender(oldState, scheduledState, diffResult);
7937
7976
  if (!isConnected()) {
7938
7977
  return commands;
@@ -7940,7 +7979,7 @@ const render2 = async (uid, _diffResult) => {
7940
7979
  const rendererWorkerCommands = commands.filter(command => command[0] === SetFocusContext);
7941
7980
  const rendererProcessCommands = commands.filter(command => command[0] !== SetFocusContext);
7942
7981
  const transactionId = await invoke('Viewlet.queueCommands', uid, rendererProcessCommands);
7943
- return [...rendererWorkerCommands, ['Viewlet.commitPending', uid, transactionId]];
7982
+ return [['Viewlet.commitPending', uid, transactionId], ...rendererWorkerCommands];
7944
7983
  };
7945
7984
 
7946
7985
  const Button = 1;
@@ -8104,7 +8143,7 @@ const renderEventListeners = () => {
8104
8143
  preventDefault: true
8105
8144
  }, {
8106
8145
  name: HandleDrop,
8107
- params: ['handleDrop', ClientX, ClientY, DataTransferFiles2],
8146
+ params: ['handleDrop', ClientX, ClientY, DropId],
8108
8147
  preventDefault: true
8109
8148
  }, {
8110
8149
  name: HandleNativePaste,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "7.27.0",
3
+ "version": "7.28.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",