@lvce-editor/explorer-view 7.14.0 → 7.15.1

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.
@@ -1387,7 +1387,7 @@ const createMockRpc = ({
1387
1387
  };
1388
1388
 
1389
1389
  const rpcs = Object.create(null);
1390
- const set$6 = (id, rpc) => {
1390
+ const set$7 = (id, rpc) => {
1391
1391
  rpcs[id] = rpc;
1392
1392
  };
1393
1393
  const get$1 = id => {
@@ -1420,7 +1420,7 @@ const create$1 = rpcId => {
1420
1420
  const mockRpc = createMockRpc({
1421
1421
  commandMap
1422
1422
  });
1423
- set$6(rpcId, mockRpc);
1423
+ set$7(rpcId, mockRpc);
1424
1424
  // @ts-ignore
1425
1425
  mockRpc[Symbol.dispose] = () => {
1426
1426
  remove$1(rpcId);
@@ -1429,7 +1429,7 @@ const create$1 = rpcId => {
1429
1429
  return mockRpc;
1430
1430
  },
1431
1431
  set(rpc) {
1432
- set$6(rpcId, rpc);
1432
+ set$7(rpcId, rpc);
1433
1433
  }
1434
1434
  };
1435
1435
  };
@@ -1656,17 +1656,17 @@ const FocusExplorer = 13;
1656
1656
  const FocusExplorerEditBox = 14;
1657
1657
 
1658
1658
  const {
1659
- set: set$5
1659
+ set: set$6
1660
1660
  } = create$1(FileSystemWorker$1);
1661
1661
 
1662
1662
  const FileSystemWorker = {
1663
1663
  __proto__: null,
1664
- set: set$5
1664
+ set: set$6
1665
1665
  };
1666
1666
 
1667
1667
  const {
1668
1668
  invoke: invoke$3,
1669
- set: set$4
1669
+ set: set$5
1670
1670
  } = create$1(IconThemeWorker);
1671
1671
  const getIcons = async iconRequests => {
1672
1672
  // @ts-ignore
@@ -1676,7 +1676,7 @@ const getIcons = async iconRequests => {
1676
1676
  const {
1677
1677
  invoke: invoke$2,
1678
1678
  invokeAndTransfer,
1679
- set: set$3
1679
+ set: set$4
1680
1680
  } = create$1(RendererWorker);
1681
1681
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
1682
1682
  number(uid);
@@ -1714,7 +1714,7 @@ const openUri$1 = async (uri, focus, options) => {
1714
1714
 
1715
1715
  const {
1716
1716
  invoke: invoke$1,
1717
- set: set$2
1717
+ set: set$3
1718
1718
  } = create$1(SourceControlWorker);
1719
1719
 
1720
1720
  // TODO use direct connection
@@ -1722,7 +1722,7 @@ const invoke = async (method, ...params) => {
1722
1722
  return invoke$2(method, ...params);
1723
1723
  };
1724
1724
  const {
1725
- set: set$1
1725
+ set: set$2
1726
1726
  } = FileSystemWorker;
1727
1727
 
1728
1728
  const remove = async dirent => {
@@ -2864,6 +2864,17 @@ const copyRelativePath = async state => {
2864
2864
  return state;
2865
2865
  };
2866
2866
 
2867
+ const commandCompletions = new WeakMap();
2868
+ const set$1 = (state, completion) => {
2869
+ commandCompletions.set(state, completion);
2870
+ return state;
2871
+ };
2872
+ const take = state => {
2873
+ const completion = commandCompletions.get(state);
2874
+ commandCompletions.delete(state);
2875
+ return completion;
2876
+ };
2877
+
2867
2878
  const getIconCacheKey = (path, type) => {
2868
2879
  switch (type) {
2869
2880
  case DirectoryExpanded:
@@ -3650,23 +3661,29 @@ const {
3650
3661
  } = create$a();
3651
3662
  const commandQueues = new Map();
3652
3663
  const runQueuedCommand = async (previousCommand, command) => {
3664
+ await previousCommand;
3665
+ return command();
3666
+ };
3667
+ const waitForStateCommand = async command => {
3653
3668
  try {
3654
- await previousCommand;
3669
+ await command;
3655
3670
  } catch {
3656
3671
  // Keep the queue usable after returning the error to the command caller
3657
3672
  }
3658
- await command();
3659
3673
  };
3660
3674
  const enqueueCommand = async (id, command) => {
3661
- const currentCommand = runQueuedCommand(commandQueues.get(id), command);
3662
- commandQueues.set(id, currentCommand);
3675
+ const stateCommand = runQueuedCommand(commandQueues.get(id), command);
3676
+ const queuedStateCommand = waitForStateCommand(stateCommand);
3677
+ commandQueues.set(id, queuedStateCommand);
3678
+ let result;
3663
3679
  try {
3664
- await currentCommand;
3680
+ result = await stateCommand;
3665
3681
  } finally {
3666
- if (commandQueues.get(id) === currentCommand) {
3682
+ if (commandQueues.get(id) === queuedStateCommand) {
3667
3683
  commandQueues.delete(id);
3668
3684
  }
3669
3685
  }
3686
+ await result.completion;
3670
3687
  };
3671
3688
  const hasSameVisibleExplorerItemInputs = (oldState, newState) => {
3672
3689
  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;
@@ -3693,8 +3710,11 @@ const wrapListItemCommandInternal = (fn, queued) => {
3693
3710
  newState
3694
3711
  } = get(id);
3695
3712
  const rawUpdatedState = await fn(newState, ...args);
3713
+ const completion = take(rawUpdatedState);
3696
3714
  if (newState === rawUpdatedState) {
3697
- return;
3715
+ return {
3716
+ completion
3717
+ };
3698
3718
  }
3699
3719
  const updatedState = await maybeUpdateGitIgnoredUris(newState, rawUpdatedState);
3700
3720
  const {
@@ -3719,7 +3739,9 @@ const wrapListItemCommandInternal = (fn, queued) => {
3719
3739
  if (updatedState.inputSource === User) {
3720
3740
  set(id, intermediate.oldState, updatedState);
3721
3741
  }
3722
- return;
3742
+ return {
3743
+ completion
3744
+ };
3723
3745
  }
3724
3746
  const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, items.length);
3725
3747
  const visible = items.slice(minLineY, maxLineY);
@@ -3737,14 +3759,18 @@ const wrapListItemCommandInternal = (fn, queued) => {
3737
3759
  };
3738
3760
  const intermediate2 = get(id);
3739
3761
  set(id, intermediate2.oldState, finalState);
3762
+ return {
3763
+ completion
3764
+ };
3740
3765
  };
3741
3766
  if (!queued) {
3742
- return runCommand;
3767
+ return async (id, ...args) => {
3768
+ const result = await runCommand(id, ...args);
3769
+ await result.completion;
3770
+ };
3743
3771
  }
3744
3772
  const wrappedCommand = async (id, ...args) => {
3745
- await enqueueCommand(id, async () => {
3746
- await runCommand(id, ...args);
3747
- });
3773
+ await enqueueCommand(id, () => runCommand(id, ...args));
3748
3774
  };
3749
3775
  return wrappedCommand;
3750
3776
  };
@@ -4576,14 +4602,15 @@ const handleClickDirectory = async (state, dirent, index, keepFocus) => {
4576
4602
  };
4577
4603
 
4578
4604
  const handleClickFile = async (state, dirent, index, keepFocus = false) => {
4579
- await openUri(dirent.path, !keepFocus, {
4605
+ const completion = openUri(dirent.path, !keepFocus, {
4580
4606
  preview: true
4581
4607
  });
4582
- return {
4608
+ const newState = {
4583
4609
  ...state,
4584
4610
  focused: keepFocus,
4585
4611
  focusedIndex: index
4586
4612
  };
4613
+ return set$1(newState, completion);
4587
4614
  };
4588
4615
 
4589
4616
  const handleClickSymLink = async (state, dirent, index) => {
@@ -4785,7 +4812,7 @@ const newDirent = async (state, editingType, editingIcon = '') => {
4785
4812
 
4786
4813
  // TODO much shared logic with newFolder
4787
4814
  const newFile = state => {
4788
- if (state.isReadonly) {
4815
+ if (state.root === '' || state.isReadonly) {
4789
4816
  return Promise.resolve(state);
4790
4817
  }
4791
4818
  return newDirent(state, CreateFile);
@@ -4818,7 +4845,7 @@ const getEditingIcon = async (editingType, value, direntType) => {
4818
4845
  };
4819
4846
 
4820
4847
  const newFolder = async state => {
4821
- if (state.isReadonly || state.editingIndex !== -1) {
4848
+ if (state.root === '' || state.isReadonly || state.editingIndex !== -1) {
4822
4849
  return state;
4823
4850
  }
4824
4851
  const editingIcon = await getEditingIcon(CreateFolder, '');
@@ -5049,10 +5076,12 @@ const handleClick = async (state, index, keepFocus = false) => {
5049
5076
  if (newState.editingIndex === -1) {
5050
5077
  return newState;
5051
5078
  }
5052
- return {
5079
+ const completion = take(newState);
5080
+ const finalState = {
5053
5081
  ...newState,
5054
5082
  ...resetEditing
5055
5083
  };
5084
+ return completion ? set$1(finalState, completion) : finalState;
5056
5085
  };
5057
5086
 
5058
5087
  // export const handleBlur=()=>{}
@@ -5300,7 +5329,7 @@ const handleDoubleClick = async (state, eventX, eventY) => {
5300
5329
  const item = state.items[index];
5301
5330
  const type = normalizeDirentType(item.type);
5302
5331
  if (type === File || type === SymLinkFile) {
5303
- await openUri(item.path, true);
5332
+ return set$1(state, openUri(item.path, true));
5304
5333
  }
5305
5334
  return state;
5306
5335
  };
@@ -8004,7 +8033,7 @@ const createFileSystemWorkerRpc = async () => {
8004
8033
 
8005
8034
  const initializeFileSystemWorker = async () => {
8006
8035
  const rpc = await createFileSystemWorkerRpc();
8007
- set$1(rpc);
8036
+ set$2(rpc);
8008
8037
  };
8009
8038
 
8010
8039
  const send$1 = port => {
@@ -8024,14 +8053,14 @@ const createIconThemeWorkerRpc = async () => {
8024
8053
 
8025
8054
  const initializeIconThemeWorker = async () => {
8026
8055
  const rpc = await createIconThemeWorkerRpc();
8027
- set$4(rpc);
8056
+ set$5(rpc);
8028
8057
  };
8029
8058
 
8030
8059
  const initializeRendererWorker = async () => {
8031
8060
  const rpc = await create$2({
8032
8061
  commandMap: commandMap
8033
8062
  });
8034
- set$3(rpc);
8063
+ set$4(rpc);
8035
8064
  };
8036
8065
 
8037
8066
  const send = port => {
@@ -8054,7 +8083,7 @@ const initializeSourceControlWorker = async () => {
8054
8083
  try {
8055
8084
  const rpc = await createSourceControlWorkerRpc();
8056
8085
  // TODO
8057
- set$2(rpc);
8086
+ set$3(rpc);
8058
8087
  } catch {
8059
8088
  // ignore
8060
8089
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "7.14.0",
3
+ "version": "7.15.1",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",