@lvce-editor/explorer-view 5.2.0 → 5.4.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.
@@ -2650,7 +2650,8 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
2650
2650
  errorMessageTop: 0,
2651
2651
  visibleExplorerItems: [],
2652
2652
  errorMessageWidth: 0,
2653
- decorations: []
2653
+ decorations: [],
2654
+ sourceControlDecorations: false
2654
2655
  };
2655
2656
  set(state.uid, state, state);
2656
2657
  return state;
@@ -4635,28 +4636,48 @@ const getWorkspacePath = () => {
4635
4636
  return invoke$2('Workspace.getPath');
4636
4637
  };
4637
4638
 
4638
- const DecorationsEnabled = false;
4639
+ const isValid = decoration => {
4640
+ return decoration && typeof decoration.decoration === 'string' && typeof decoration.uri === 'string';
4641
+ };
4642
+ const normalizeDecorations = decorations => {
4643
+ if (!decorations || !Array.isArray(decorations)) {
4644
+ return [];
4645
+ }
4646
+ return decorations.filter(isValid);
4647
+ };
4639
4648
 
4640
- const getFileDecorations = async (scheme, root, maybeUris) => {
4649
+ const getFileDecorations = async (scheme, root, maybeUris, decorationsEnabled) => {
4641
4650
  try {
4642
- if (!DecorationsEnabled) {
4651
+ if (!decorationsEnabled) {
4643
4652
  return [];
4644
4653
  }
4645
4654
  const providerIds = await invoke$1('SourceControl.getEnabledProviderIds', scheme, root);
4646
4655
  if (providerIds.length === 0) {
4647
4656
  return [];
4648
4657
  }
4649
- const providerId = providerIds[0];
4658
+ // TODO how to handle multiple providers?
4659
+ const providerId = providerIds.at(-1);
4650
4660
  const uris = ensureUris(maybeUris);
4651
4661
  const decorations = await invoke$1('SourceControl.getFileDecorations', providerId, uris);
4652
- return decorations;
4662
+ const normalized = normalizeDecorations(decorations);
4663
+ return normalized;
4653
4664
  } catch (error) {
4654
4665
  console.error(error);
4655
4666
  return [];
4656
4667
  }
4657
4668
  };
4658
4669
 
4670
+ const RE_PROTOCOL = /^[a-z+]:\/\//;
4671
+ const getScheme = uri => {
4672
+ const match = uri.match(RE_PROTOCOL);
4673
+ if (!match) {
4674
+ return '';
4675
+ }
4676
+ return match[0];
4677
+ };
4678
+
4659
4679
  const getSettings = async () => {
4680
+ // TODO don't return false always
4660
4681
  // TODO get all settings at once
4661
4682
  const useChevronsRaw = await invoke$2('Preferences.get', 'explorer.useChevrons');
4662
4683
  const useChevrons = useChevronsRaw === false ? false : true;
@@ -4664,10 +4685,13 @@ const getSettings = async () => {
4664
4685
  const confirmDelete = confirmDeleteRaw === false ? false : false;
4665
4686
  const confirmPasteRaw = await invoke$2('Preferences.get', 'explorer.confirmpaste');
4666
4687
  const confirmPaste = confirmPasteRaw === false ? false : false;
4688
+ const sourceControlDecorationsRaw = await invoke$2('Preferences.get', 'explorer.sourceControlDecorations');
4689
+ const sourceControlDecorations = sourceControlDecorationsRaw === false ? false : true;
4667
4690
  return {
4668
4691
  useChevrons,
4669
4692
  confirmDelete,
4670
- confirmPaste
4693
+ confirmPaste,
4694
+ sourceControlDecorations
4671
4695
  };
4672
4696
  };
4673
4697
 
@@ -4780,18 +4804,11 @@ const getExcluded = () => {
4780
4804
  const getSavedRoot = (savedState, workspacePath) => {
4781
4805
  return workspacePath;
4782
4806
  };
4783
- const RE_PROTOCOL = /^[a-z+]:\/\//;
4784
- const getScheme = uri => {
4785
- const match = uri.match(RE_PROTOCOL);
4786
- if (!match) {
4787
- return '';
4788
- }
4789
- return match[0];
4790
- };
4791
4807
  const loadContent = async (state, savedState) => {
4792
4808
  const {
4793
4809
  useChevrons,
4794
- confirmDelete
4810
+ confirmDelete,
4811
+ sourceControlDecorations
4795
4812
  } = await getSettings();
4796
4813
  const workspacePath = await getWorkspacePath();
4797
4814
  const root = getSavedRoot(savedState, workspacePath);
@@ -4808,10 +4825,11 @@ const loadContent = async (state, savedState) => {
4808
4825
  deltaY = savedState.deltaY;
4809
4826
  }
4810
4827
  const scheme = getScheme(root);
4811
- const decorations = await getFileDecorations(scheme, root, restoredDirents.filter(item => item.depth === 1).map(item => item.path));
4828
+ const decorations = await getFileDecorations(scheme, root, restoredDirents.filter(item => item.depth === 1).map(item => item.path), sourceControlDecorations);
4812
4829
  return {
4813
4830
  ...state,
4814
4831
  confirmDelete,
4832
+ decorations,
4815
4833
  deltaY,
4816
4834
  excluded,
4817
4835
  items: restoredDirents,
@@ -4819,8 +4837,7 @@ const loadContent = async (state, savedState) => {
4819
4837
  minLineY,
4820
4838
  pathSeparator,
4821
4839
  root,
4822
- useChevrons,
4823
- decorations
4840
+ useChevrons
4824
4841
  };
4825
4842
  };
4826
4843
 
@@ -4834,6 +4851,10 @@ const handleWorkspaceChange = async state => {
4834
4851
  return newState;
4835
4852
  };
4836
4853
 
4854
+ const handleWorkspaceRefresh = async state => {
4855
+ return refresh(state);
4856
+ };
4857
+
4837
4858
  const sendMessagePortToFileSystemWorker = async port => {
4838
4859
  await sendMessagePortToFileSystemWorker$1(port, 0);
4839
4860
  };
@@ -4893,9 +4914,6 @@ const createSourceControlWorkerRpc = async () => {
4893
4914
 
4894
4915
  const initializeSourceControlWorker = async () => {
4895
4916
  try {
4896
- if (!DecorationsEnabled) {
4897
- return;
4898
- }
4899
4917
  const rpc = await createSourceControlWorkerRpc();
4900
4918
  // TODO
4901
4919
  set$2(rpc);
@@ -6125,6 +6143,7 @@ const commandMap = {
6125
6143
  'Explorer.handleUpload': wrapListItemCommand(handleUpload),
6126
6144
  'Explorer.handleWheel': wrapListItemCommand(handleWheel),
6127
6145
  'Explorer.handleWorkspaceChange': wrapListItemCommand(handleWorkspaceChange),
6146
+ 'Explorer.handleWorkspaceRefresh': wrapListItemCommand(handleWorkspaceRefresh),
6128
6147
  'Explorer.loadContent': wrapListItemCommand(loadContent),
6129
6148
  'Explorer.newFile': wrapListItemCommand(newFile),
6130
6149
  'Explorer.newFolder': wrapListItemCommand(newFolder),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "5.2.0",
3
+ "version": "5.4.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",