@lvce-editor/source-control-worker 3.10.1 → 3.10.3

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.
@@ -1340,6 +1340,8 @@ const SourceControl$1 = 22;
1340
1340
  const None = 0;
1341
1341
 
1342
1342
  const Web = 1;
1343
+ const Electron = 2;
1344
+ const Remote = 3;
1343
1345
 
1344
1346
  const SetCss = 'Viewlet.setCss';
1345
1347
  const SetDom2 = 'Viewlet.setDom2';
@@ -1622,12 +1624,17 @@ const getEnabledProviderIds$1 = (scheme, root, assetDir, platform) => {
1622
1624
  // noProviderFoundMessage: 'No source control provider found',
1623
1625
  });
1624
1626
  };
1625
- const getIconDefinitions$1 = async providerId => {
1626
- // @ts-ignore
1627
- const result = await invoke$2('ExtensionHostSourceControl.getIconDefinitions', providerId);
1628
- return result;
1627
+
1628
+ const isCompatible = (extension, platform) => {
1629
+ return platform !== Web || extension?.compatibility?.web !== false;
1630
+ };
1631
+ const getExtensions = async (assetDir, platform) => {
1632
+ const extensions = await invoke$1('Extensions.getAllExtensions', assetDir, platform);
1633
+ return extensions.filter(extension => isCompatible(extension, platform));
1629
1634
  };
1630
1635
 
1636
+ const EmptyString = '';
1637
+
1631
1638
  const Disk = 'file';
1632
1639
 
1633
1640
  const RE_PROTOCOL = /^([a-z-]+):\/\//;
@@ -1641,6 +1648,19 @@ const getProtocol = uri => {
1641
1648
  }
1642
1649
  return Disk;
1643
1650
  };
1651
+ const PROTOCOL_POST_FIX_LENGTH = 3;
1652
+ const getPath = (protocol, uri) => {
1653
+ if (!uri) {
1654
+ return '';
1655
+ }
1656
+ if (protocol === Disk && !uri.startsWith('file://')) {
1657
+ return uri;
1658
+ }
1659
+ if (protocol === EmptyString) {
1660
+ return uri;
1661
+ }
1662
+ return uri.slice(protocol.length + PROTOCOL_POST_FIX_LENGTH);
1663
+ };
1644
1664
 
1645
1665
  const acceptInput$1 = (providerId, text, assetDir, platform) => {
1646
1666
  string(providerId);
@@ -1704,12 +1724,29 @@ const getEnabledProviderIds = (scheme, root, assetDir, platform) => {
1704
1724
  const getGroups$1 = (providerId, root, assetDir, platform) => {
1705
1725
  return getGroups$2(providerId, root, assetDir, platform);
1706
1726
  };
1707
- const getIconDefinitions = async providerIds => {
1727
+ const getIconDefinitions = async (providerIds, assetDir, platform) => {
1708
1728
  try {
1709
1729
  if (providerIds.length === 0) {
1710
1730
  return [];
1711
1731
  }
1712
- return await getIconDefinitions$1(providerIds[0]);
1732
+ const extensions = await getExtensions(assetDir, platform);
1733
+ const extension = extensions.find(extension => {
1734
+ const idParts = typeof extension?.id === 'string' ? extension.id.split('.') : [];
1735
+ return idParts[1] === providerIds[0];
1736
+ });
1737
+ if (!Array.isArray(extension?.['source-control-icons']) || typeof extension.uri !== 'string') {
1738
+ return [];
1739
+ }
1740
+ const icons = extension['source-control-icons'].filter(icon => typeof icon === 'string');
1741
+ return icons.map(icon => {
1742
+ const uri = `${extension.uri}/${icon}`;
1743
+ if (platform === Electron || platform === Remote) {
1744
+ const protocol = getProtocol(uri);
1745
+ const path = getPath(protocol, uri);
1746
+ return `/remote${path.startsWith('/') ? '' : '/'}${path}`;
1747
+ }
1748
+ return uri;
1749
+ });
1713
1750
  } catch {
1714
1751
  return [];
1715
1752
  }
@@ -1924,14 +1961,6 @@ const get$1 = key => {
1924
1961
  return getPreference(key);
1925
1962
  };
1926
1963
 
1927
- const isCompatible = (extension, platform) => {
1928
- return platform !== Web || extension?.compatibility?.web !== false;
1929
- };
1930
- const getExtensions = async (assetDir, platform) => {
1931
- const extensions = await invoke$1('Extensions.getAllExtensions', assetDir, platform);
1932
- return extensions.filter(extension => isCompatible(extension, platform));
1933
- };
1934
-
1935
1964
  const requestSourceActions = async (assetDir = '', platform = 0) => {
1936
1965
  const extensions = await getExtensions(assetDir, platform);
1937
1966
  const newCache = Object.create(null);
@@ -2018,7 +2047,7 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
2018
2047
  };
2019
2048
  };
2020
2049
 
2021
- const loadContent = async (state, savedState) => {
2050
+ const loadContentActual = async (state, savedState) => {
2022
2051
  const {
2023
2052
  fileIconCache,
2024
2053
  height,
@@ -2045,7 +2074,7 @@ const loadContent = async (state, savedState) => {
2045
2074
  const enabledProviderIds = await getEnabledProviderIds(scheme, root, assetDir, platform);
2046
2075
  const providerUnavailableMessage = enabledProviderIds.length === 0 ? await getSourceControlUnavailableMessage(assetDir, platform) : '';
2047
2076
  const showGenerateCommitMessageButton = enabledProviderIds.length === 0 ? false : await getShowGenerateCommitMessageButton(enabledProviderIds[0], assetDir, platform);
2048
- const iconDefinitions = await getIconDefinitions(enabledProviderIds);
2077
+ const iconDefinitions = await getIconDefinitions(enabledProviderIds, assetDir, platform);
2049
2078
  const {
2050
2079
  allGroups,
2051
2080
  gitRoot
@@ -2084,7 +2113,6 @@ const loadContent = async (state, savedState) => {
2084
2113
  gitRoot,
2085
2114
  headerHeight,
2086
2115
  iconDefinitions,
2087
- initial: false,
2088
2116
  inputBoxHeight,
2089
2117
  inputPlaceholder,
2090
2118
  inputValue,
@@ -2100,6 +2128,14 @@ const loadContent = async (state, savedState) => {
2100
2128
  visibleItems
2101
2129
  };
2102
2130
  };
2131
+ const loadContent = (state, savedState) => {
2132
+ // eslint-disable-next-line unicorn/prefer-await
2133
+ return loadContentActual(state, savedState).catch(error => ({
2134
+ ...state,
2135
+ loading: false,
2136
+ providerUnavailableMessage: error.message
2137
+ }));
2138
+ };
2103
2139
 
2104
2140
  const info = (...args) => {
2105
2141
  // @ts-ignore
@@ -3637,8 +3673,7 @@ const messageNode = {
3637
3673
  };
3638
3674
  const getSourceControlVirtualDom = (items, buttons, disabled, placeholder, inputMessage, message, loading, scrollBarHeight, scrollBarActive) => {
3639
3675
  const content = message ? [messageNode, text(message)] : [...getSourceControlHeaderVirtualDom(placeholder, inputMessage), ...buttons.flatMap(button => getSourceControlButtonVirtualDom(button, disabled)), ...getSourceControlListVirtualDom(items, scrollBarHeight, scrollBarActive)];
3640
- const progressDom = loading ? getProgressVirtualDom() : [];
3641
- const dom = [{
3676
+ return [{
3642
3677
  ariaBusy: loading,
3643
3678
  childCount: (message ? 1 : 2 + buttons.length) + (loading ? 1 : 0),
3644
3679
  className: className,
@@ -3648,8 +3683,9 @@ const getSourceControlVirtualDom = (items, buttons, disabled, placeholder, input
3648
3683
  onWheel: HandleWheel,
3649
3684
  tabIndex: 0,
3650
3685
  type: Div
3651
- }, ...progressDom, ...content];
3652
- return dom;
3686
+ },
3687
+ // eslint-disable-next-line virtual-dom/no-conditional-spread
3688
+ ...(loading ? getProgressVirtualDom() : []), ...content];
3653
3689
  };
3654
3690
 
3655
3691
  const renderItems = (oldState, newState) => {
@@ -3669,8 +3705,7 @@ const renderItems = (oldState, newState) => {
3669
3705
  if (initial) {
3670
3706
  return [SetDom2, id, []];
3671
3707
  }
3672
- const unavailableMessage = loading ? '' : providerUnavailableMessage;
3673
- const dom = getSourceControlVirtualDom(visibleItems, sourceControlButtons, items.length === 0, inputPlaceholder, inputMessage, unavailableMessage, loading, scrollBarHeight, scrollBarActive);
3708
+ const dom = getSourceControlVirtualDom(visibleItems, sourceControlButtons, items.length === 0, inputPlaceholder, inputMessage, loading ? '' : providerUnavailableMessage, loading, scrollBarHeight, scrollBarActive);
3674
3709
  return [SetDom2, id, dom];
3675
3710
  };
3676
3711
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/source-control-worker",
3
- "version": "3.10.1",
3
+ "version": "3.10.3",
4
4
  "description": "Source Control Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"