@lvce-editor/extension-detail-view 3.8.0 → 3.10.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.
@@ -439,9 +439,9 @@ const get$2 = id => {
439
439
  const remove = id => {
440
440
  delete callbacks[id];
441
441
  };
442
- let id = 0;
442
+ let id$1 = 0;
443
443
  const create$3 = () => {
444
- return ++id;
444
+ return ++id$1;
445
445
  };
446
446
  const registerPromise = () => {
447
447
  const id = create$3();
@@ -767,12 +767,12 @@ const invokeAndTransfer = (ipc, method, ...params) => {
767
767
  return invokeHelper(ipc, method, params, true);
768
768
  };
769
769
 
770
- const commands = Object.create(null);
770
+ const commands$1 = Object.create(null);
771
771
  const register = commandMap => {
772
- Object.assign(commands, commandMap);
772
+ Object.assign(commands$1, commandMap);
773
773
  };
774
774
  const getCommand = key => {
775
- return commands[key];
775
+ return commands$1[key];
776
776
  };
777
777
  const execute = (command, ...args) => {
778
778
  const fn = getCommand(command);
@@ -874,7 +874,7 @@ const create = (uid, uri, width, height, platform) => {
874
874
  name: '',
875
875
  sanitizedReadmeHtml: '',
876
876
  selectedTab: '',
877
- size: 0,
877
+ sizeOnDisk: 0,
878
878
  width,
879
879
  uri,
880
880
  entries: [],
@@ -894,12 +894,18 @@ const AdditionalDetails = 'AdditionalDetails';
894
894
  const AdditionalDetailsEntry = 'AdditionalDetailsEntry';
895
895
  const AdditionalDetailsTitle = 'AdditionalDetailsTitle';
896
896
  const Aside$2 = 'Aside';
897
+ const Button$1 = 'Button';
898
+ const ButtonPrimary = 'ButtonPrimary';
897
899
  const Categories = 'Categories';
898
900
  const Category = 'Category';
899
901
  const Changelog$1 = 'Changelog';
902
+ const DefinitionListItem = 'DefinitionListItem';
903
+ const DefinitionListItemHeading = 'DefinitionListItemHeading';
904
+ const DefinitionListItemValue = 'DefinitionListItemValue';
900
905
  const ExtensionDetail = 'ExtensionDetail';
901
906
  const ExtensionDetailDescription = 'ExtensionDetailDescription';
902
907
  const ExtensionDetailHeader = 'ExtensionDetailHeader';
908
+ const ExtensionDetailHeaderActions = 'ExtensionDetailHeaderActions';
903
909
  const ExtensionDetailHeaderDetails = 'ExtensionDetailHeaderDetails';
904
910
  const ExtensionDetailIcon = 'ExtensionDetailIcon';
905
911
  const ExtensionDetailName = 'ExtensionDetailName';
@@ -908,15 +914,21 @@ const ExtensionDetailTab = 'ExtensionDetailTab';
908
914
  const ExtensionDetailTabs = 'ExtensionDetailTabs';
909
915
  const ExtensionDetailTabSelected = 'ExtensionDetailTabSelected';
910
916
  const Feature = 'Feature';
917
+ const FeatureContent = 'FeatureContent';
911
918
  const Features$1 = 'Features';
912
919
  const FeaturesList = 'FeaturesList';
920
+ const FeatureWebView = 'FeatureWebView';
921
+ const Large$1 = 'Large';
913
922
  const Markdown = 'Markdown';
914
923
  const MoreInfo = 'MoreInfo';
915
924
  const MoreInfoEntry = 'MoreInfoEntry';
916
925
  const MoreInfoEntryKey = 'MoreInfoEntryKey';
917
926
  const MoreInfoEntryValue = 'MoreInfoEntryValue';
927
+ const Normal$1 = 'Normal';
918
928
  const Resource = 'Resource';
919
929
  const Resources = 'Resources';
930
+ const Small$1 = 'Small';
931
+ const Table$1 = 'Table';
920
932
  const Viewlet = 'Viewlet';
921
933
 
922
934
  const BYTE_UNITS = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
@@ -1053,11 +1065,6 @@ const TabList = 'tablist';
1053
1065
  const Tab = 'tab';
1054
1066
  const Panel = 'panel';
1055
1067
 
1056
- const HandleClickSize = 'handleClickSize';
1057
- const HandleFeaturesClick = 'handleFeaturesClick';
1058
- const HandleReadmeContextMenu = 'handleReadmeContextMenu';
1059
- const HandleTabsClick = 'handleTabsClick';
1060
-
1061
1068
  const getAdditionalDetailsEntryVirtualDom = (heading, items, renderer) => {
1062
1069
  return [{
1063
1070
  type: Div$1,
@@ -1181,8 +1188,15 @@ const getResourcesVirtualDom = resources => {
1181
1188
  }, ...resources.flatMap(getResourceVirtualDom)];
1182
1189
  };
1183
1190
 
1184
- const getAdditionalDetailsVirtualDom = (firstHeading, entries, secondHeading, secondEntries, thirdHeading, categories, fourthHeading, resources) => {
1191
+ const getAdditionalDetailsVirtualDom = (showAdditionalDetails, firstHeading, entries, secondHeading, secondEntries, thirdHeading, categories, fourthHeading, resources) => {
1192
+ if (!showAdditionalDetails) {
1193
+ return [];
1194
+ }
1185
1195
  return [{
1196
+ type: Div$1,
1197
+ className: Aside$2,
1198
+ childCount: 1
1199
+ }, {
1186
1200
  type: Div$1,
1187
1201
  className: AdditionalDetails,
1188
1202
  tabIndex: 0,
@@ -1190,6 +1204,13 @@ const getAdditionalDetailsVirtualDom = (firstHeading, entries, secondHeading, se
1190
1204
  }, ...getAdditionalDetailsEntryVirtualDom(firstHeading, entries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(secondHeading, secondEntries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(thirdHeading, categories, getCategoriesDom), ...getAdditionalDetailsEntryVirtualDom(fourthHeading, resources, getResourcesVirtualDom)];
1191
1205
  };
1192
1206
 
1207
+ const HandleClickDisable = 'handleClickDisable';
1208
+ const HandleClickSize = 'handleClickSize';
1209
+ const HandleClickUninstall = 'handleClickUninstall';
1210
+ const HandleFeaturesClick = 'handleFeaturesClick';
1211
+ const HandleReadmeContextMenu = 'handleReadmeContextMenu';
1212
+ const HandleTabsClick = 'handleTabsClick';
1213
+
1193
1214
  const getInstallationEntries = (displaySize, extensionId, extensionVersion) => {
1194
1215
  const entries = [{
1195
1216
  key: 'Identifier',
@@ -1214,6 +1235,19 @@ const getInstallationEntries = (displaySize, extensionId, extensionVersion) => {
1214
1235
 
1215
1236
  const allowedMarkdownAttributes = ['src', 'id', 'className', 'title', 'alt', 'href', 'target', 'rel'];
1216
1237
 
1238
+ const getVirtualDomChildCount = markdownDom => {
1239
+ const max = markdownDom.length - 1;
1240
+ let stack = [];
1241
+ for (let i = max; i >= 0; i--) {
1242
+ const element = markdownDom[i];
1243
+ if (element.childCount > 0) {
1244
+ stack = stack.slice(element.childCount);
1245
+ }
1246
+ stack.unshift(element);
1247
+ }
1248
+ return stack.length;
1249
+ };
1250
+
1217
1251
  const Div = 'div';
1218
1252
  const H1 = 'h1';
1219
1253
  const H2 = 'h2';
@@ -1657,8 +1691,15 @@ const parseHtml = (html, allowedAttributes) => {
1657
1691
 
1658
1692
  const getMarkdownVirtualDom = html => {
1659
1693
  string(html);
1660
- const dom = parseHtml(html, allowedMarkdownAttributes);
1661
- return dom;
1694
+ const childDom = parseHtml(html, allowedMarkdownAttributes);
1695
+ const markdownChildCount = getVirtualDomChildCount(childDom);
1696
+ return [{
1697
+ type: Div$1,
1698
+ className: Markdown,
1699
+ role: Document,
1700
+ onContextMenu: HandleReadmeContextMenu,
1701
+ childCount: markdownChildCount
1702
+ }, ...childDom];
1662
1703
  };
1663
1704
 
1664
1705
  const getMarketplaceEntries = () => {
@@ -1672,22 +1713,7 @@ const getMarketplaceEntries = () => {
1672
1713
  }];
1673
1714
  };
1674
1715
 
1675
- const getVirtualDomChildCount = markdownDom => {
1676
- const max = markdownDom.length - 1;
1677
- let stack = [];
1678
- for (let i = max; i >= 0; i--) {
1679
- const element = markdownDom[i];
1680
- if (element.childCount > 0) {
1681
- stack = stack.slice(element.childCount);
1682
- }
1683
- stack.unshift(element);
1684
- }
1685
- return stack.length;
1686
- };
1687
-
1688
- const getDetailsVirtualDom = (sanitizedReadmeHtml, displaySize, extensionId, extensionVersion) => {
1689
- const markdownDom = getMarkdownVirtualDom(sanitizedReadmeHtml);
1690
- const childCount = getVirtualDomChildCount(markdownDom);
1716
+ const getDetailsVirtualDom = (sanitizedReadmeHtml, displaySize, extensionId, extensionVersion, width) => {
1691
1717
  const firstHeading = 'Installation';
1692
1718
  const entries = getInstallationEntries(displaySize, extensionId, extensionVersion);
1693
1719
  const secondHeading = 'Marketplace';
@@ -1711,25 +1737,96 @@ const getDetailsVirtualDom = (sanitizedReadmeHtml, displaySize, extensionId, ext
1711
1737
  label: 'License',
1712
1738
  url: '#'
1713
1739
  }];
1740
+ const showAdditionalDetailsBreakpoint = 600;
1741
+ const showAdditionalDetails = width > showAdditionalDetailsBreakpoint;
1742
+ const childCount = showAdditionalDetails ? 2 : 1;
1714
1743
  const dom = [{
1715
1744
  type: Div$1,
1716
1745
  className: ExtensionDetailPanel,
1717
- childCount: 2,
1746
+ childCount: childCount,
1718
1747
  role: Panel
1719
- }, {
1720
- type: Div$1,
1721
- className: Markdown,
1722
- role: Document,
1723
- onContextMenu: HandleReadmeContextMenu,
1724
- childCount
1725
- }, ...markdownDom, {
1726
- type: Div$1,
1727
- className: Aside$2,
1728
- childCount: 1
1729
- }, ...getAdditionalDetailsVirtualDom(firstHeading, entries, secondHeading, secondEntries, thirdHeading, categories, fourthHeading, resources)];
1748
+ }, ...getMarkdownVirtualDom(sanitizedReadmeHtml), ...getAdditionalDetailsVirtualDom(showAdditionalDetails, firstHeading, entries, secondHeading, secondEntries, thirdHeading, categories, fourthHeading, resources)];
1730
1749
  return dom;
1731
1750
  };
1732
1751
 
1752
+ const emptyObject = {};
1753
+ const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1754
+ const i18nString = (key, placeholders = emptyObject) => {
1755
+ if (placeholders === emptyObject) {
1756
+ return key;
1757
+ }
1758
+ const replacer = (match, rest) => {
1759
+ return placeholders[rest];
1760
+ };
1761
+ return key.replaceAll(RE_PLACEHOLDER, replacer);
1762
+ };
1763
+
1764
+ const Commands$1 = 'Commands';
1765
+ const ContentSecurityPolicy = 'ContentSecurityPolicy';
1766
+ const Copy = 'Copy';
1767
+ const Elements = 'Elements';
1768
+ const FileMatch = 'File Match';
1769
+ const Id = 'ID';
1770
+ const JsonValidation$1 = 'Json Validation';
1771
+ const OpenImageInNewTab = 'Open Image in New Tab';
1772
+ const OpenInNewTab = 'Open in New Tab';
1773
+ const ProgrammingLanguages$1 = 'Programming Languages';
1774
+ const SaveImageAs = 'Save Image as';
1775
+ const Schema = 'Schema';
1776
+ const Selector = 'Selector';
1777
+ const Settings$1 = 'Settings';
1778
+ const Theme$1 = 'Theme';
1779
+ const WebViews$1 = 'WebViews';
1780
+
1781
+ const copy = () => {
1782
+ return i18nString(Copy);
1783
+ };
1784
+ const openInNewTab = () => {
1785
+ return i18nString(OpenInNewTab);
1786
+ };
1787
+ const openImageInNewTab = () => {
1788
+ return i18nString(OpenImageInNewTab);
1789
+ };
1790
+ const saveImageAs = () => {
1791
+ return i18nString(SaveImageAs);
1792
+ };
1793
+ const fileMatch = () => {
1794
+ return i18nString(FileMatch);
1795
+ };
1796
+ const schema = () => {
1797
+ return i18nString(Schema);
1798
+ };
1799
+ const theme = () => {
1800
+ return i18nString(Theme$1);
1801
+ };
1802
+ const commands = () => {
1803
+ return i18nString(Commands$1);
1804
+ };
1805
+ const webViews = () => {
1806
+ return i18nString(WebViews$1);
1807
+ };
1808
+ const jsonValidation = () => {
1809
+ return i18nString(JsonValidation$1);
1810
+ };
1811
+ const programmingLanguages = () => {
1812
+ return i18nString(ProgrammingLanguages$1);
1813
+ };
1814
+ const settings = () => {
1815
+ return i18nString(Settings$1);
1816
+ };
1817
+ const id = () => {
1818
+ return i18nString(Id);
1819
+ };
1820
+ const selector = () => {
1821
+ return i18nString(Selector);
1822
+ };
1823
+ const contentSecurityPolicy = () => {
1824
+ return i18nString(ContentSecurityPolicy);
1825
+ };
1826
+ const elements = () => {
1827
+ return i18nString(Elements);
1828
+ };
1829
+
1733
1830
  const Text = 1;
1734
1831
  const Code = 2;
1735
1832
 
@@ -1756,9 +1853,17 @@ const getCommandTableEntries = extension => {
1756
1853
  };
1757
1854
  };
1758
1855
 
1856
+ const getFeatureContentHeadingVirtualDom = heading => {
1857
+ return [{
1858
+ type: H1$1,
1859
+ childCount: 1
1860
+ }, text(heading)];
1861
+ };
1862
+
1759
1863
  const getCellCodeVirtualDom = value => {
1760
1864
  return [{
1761
1865
  type: Td,
1866
+ className: 'TableCell',
1762
1867
  childCount: 1
1763
1868
  }, {
1764
1869
  type: Div$1,
@@ -1770,26 +1875,35 @@ const getCellCodeVirtualDom = value => {
1770
1875
  const getCellTextVirtualDom = value => {
1771
1876
  return [{
1772
1877
  type: Td,
1878
+ className: 'TableCell',
1773
1879
  childCount: 1
1774
1880
  }, text(value)];
1775
1881
  };
1776
1882
 
1883
+ const getCellRenderer = type => {
1884
+ switch (type) {
1885
+ case Code:
1886
+ return getCellCodeVirtualDom;
1887
+ case Text:
1888
+ return getCellTextVirtualDom;
1889
+ default:
1890
+ throw new Error(`unexpected cell type ${type}`);
1891
+ }
1892
+ };
1893
+
1777
1894
  const getCellVirtualDom = entry => {
1778
1895
  const {
1779
1896
  value,
1780
1897
  type
1781
1898
  } = entry;
1782
- switch (type) {
1783
- case Code:
1784
- return getCellCodeVirtualDom(value);
1785
- default:
1786
- return getCellTextVirtualDom(value);
1787
- }
1899
+ const fn = getCellRenderer(type);
1900
+ return fn(value);
1788
1901
  };
1789
1902
 
1790
1903
  const getTableHeadingVirtualDom = heading => {
1791
1904
  return [{
1792
1905
  type: Th,
1906
+ className: 'TableHeading',
1793
1907
  childCount: 1
1794
1908
  }, text(heading)];
1795
1909
  };
@@ -1807,7 +1921,7 @@ const getTableVirtualDom = tableInfo => {
1807
1921
  } = tableInfo;
1808
1922
  return [{
1809
1923
  type: Table,
1810
- className: 'Table',
1924
+ className: Table$1,
1811
1925
  childCount: 2
1812
1926
  }, {
1813
1927
  type: THead,
@@ -1822,55 +1936,13 @@ const getTableVirtualDom = tableInfo => {
1822
1936
  };
1823
1937
 
1824
1938
  const getFeatureCommandsVirtualDom = extension => {
1825
- // TODO use i18n strings
1826
- const heading = 'Commands';
1939
+ const heading = commands();
1827
1940
  const tableInfo = getCommandTableEntries(extension);
1828
1941
  return [{
1829
1942
  type: Div$1,
1830
- className: 'FeatureCommands',
1943
+ className: FeatureContent,
1831
1944
  childCount: 2
1832
- }, {
1833
- type: H1$1,
1834
- childCount: 1
1835
- }, text(heading), ...getTableVirtualDom(tableInfo)];
1836
- };
1837
-
1838
- const emptyObject = {};
1839
- const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1840
- const i18nString = (key, placeholders = emptyObject) => {
1841
- if (placeholders === emptyObject) {
1842
- return key;
1843
- }
1844
- const replacer = (match, rest) => {
1845
- return placeholders[rest];
1846
- };
1847
- return key.replaceAll(RE_PLACEHOLDER, replacer);
1848
- };
1849
-
1850
- const Copy = 'Copy';
1851
- const OpenInNewTab = 'Open in New Tab';
1852
- const OpenImageInNewTab = 'Open Image in New Tab';
1853
- const SaveImageAs = 'Save Image as';
1854
- const FileMatch = 'File Match';
1855
- const Schema = 'Schema';
1856
-
1857
- const copy = () => {
1858
- return i18nString(Copy);
1859
- };
1860
- const openInNewTab = () => {
1861
- return i18nString(OpenInNewTab);
1862
- };
1863
- const openImageInNewTab = () => {
1864
- return i18nString(OpenImageInNewTab);
1865
- };
1866
- const saveImageAs = () => {
1867
- return i18nString(SaveImageAs);
1868
- };
1869
- const fileMatch = () => {
1870
- return i18nString(FileMatch);
1871
- };
1872
- const schema = () => {
1873
- return i18nString(Schema);
1945
+ }, ...getFeatureContentHeadingVirtualDom(heading), ...getTableVirtualDom(tableInfo)];
1874
1946
  };
1875
1947
 
1876
1948
  const getJsonValidationTableEntry = validation => {
@@ -1886,6 +1958,7 @@ const getJsonValidationTableEntry = validation => {
1886
1958
  value: schema
1887
1959
  }];
1888
1960
  };
1961
+
1889
1962
  const getJsonValidationTableEntries = extension => {
1890
1963
  const validations = extension.jsonValidation || [];
1891
1964
  const rows = validations.map(getJsonValidationTableEntry);
@@ -1896,31 +1969,35 @@ const getJsonValidationTableEntries = extension => {
1896
1969
  };
1897
1970
 
1898
1971
  const getFeatureJsonValidationVirtualDom = extension => {
1899
- // TODO use i18n
1900
- const heading = 'Json Validation';
1972
+ const heading = jsonValidation();
1901
1973
  const tableInfo = getJsonValidationTableEntries(extension);
1902
1974
  return [{
1903
1975
  type: Div$1,
1904
- className: 'FeatureJsonValidation',
1976
+ className: FeatureContent,
1905
1977
  childCount: 2
1978
+ }, ...getFeatureContentHeadingVirtualDom(heading), ...getTableVirtualDom(tableInfo)];
1979
+ };
1980
+
1981
+ const getFeatureNotImplementedVirtualDom = () => {
1982
+ const heading = 'Not implemented';
1983
+ return [{
1984
+ type: Div$1,
1985
+ className: FeatureContent,
1986
+ childCount: 1
1906
1987
  }, {
1907
1988
  type: H1$1,
1908
1989
  childCount: 1
1909
- }, text(heading), ...getTableVirtualDom(tableInfo)];
1990
+ }, text(heading)];
1910
1991
  };
1911
1992
 
1912
1993
  const getFeatureProgrammingLanguagesVirtualDom = () => {
1913
- // TODO use i18n string
1914
- const heading = 'Programming Languages';
1994
+ const heading = programmingLanguages();
1915
1995
  // TODO
1916
1996
  return [{
1917
1997
  type: Div$1,
1918
- className: 'FeatureProgrammingLanguages',
1998
+ className: FeatureContent,
1919
1999
  childCount: 1
1920
- }, {
1921
- type: H1$1,
1922
- childCount: 1
1923
- }, text(heading)];
2000
+ }, ...getFeatureContentHeadingVirtualDom(heading)];
1924
2001
  };
1925
2002
 
1926
2003
  const getSettingsTableEntry = setting => {
@@ -1947,36 +2024,76 @@ const getSettingsTableEntries = extension => {
1947
2024
  };
1948
2025
 
1949
2026
  const getFeatureSettingsVirtualDom = extension => {
1950
- const heading = 'Settings';
2027
+ const heading = settings();
1951
2028
  const tableInfo = getSettingsTableEntries(extension);
1952
2029
  return [{
1953
2030
  type: Div$1,
1954
- className: 'FeatureSettings',
2031
+ className: FeatureContent,
1955
2032
  childCount: 2
1956
- }, {
1957
- type: H1$1,
1958
- childCount: 1
1959
- }, text(heading), ...getTableVirtualDom(tableInfo)];
2033
+ }, ...getFeatureContentHeadingVirtualDom(heading), ...getTableVirtualDom(tableInfo)];
1960
2034
  };
1961
2035
 
1962
2036
  const getFeatureThemesVirtualDom = themesHtml => {
1963
2037
  const markdownDom = getMarkdownVirtualDom(themesHtml);
1964
2038
  const childCount = getVirtualDomChildCount(markdownDom);
1965
- const heading = 'Themes';
2039
+ const heading = theme();
1966
2040
  return [{
1967
2041
  type: Div$1,
1968
- className: 'FeatureTheme',
2042
+ className: FeatureContent,
1969
2043
  childCount: 2
1970
- }, {
1971
- type: H1$1,
1972
- childCount: 1
1973
- }, text(heading), {
2044
+ }, ...getFeatureContentHeadingVirtualDom(heading), {
1974
2045
  type: Div$1,
1975
2046
  className: 'DefaultMarkdown',
1976
2047
  childCount
1977
2048
  }, ...markdownDom];
1978
2049
  };
1979
2050
 
2051
+ const heading$1 = {
2052
+ type: H2$1,
2053
+ className: DefinitionListItemHeading,
2054
+ childCount: 1
2055
+ };
2056
+ const pre = {
2057
+ type: Pre$1,
2058
+ className: DefinitionListItemValue,
2059
+ childCount: 1
2060
+ };
2061
+ const item = {
2062
+ type: Div$1,
2063
+ className: DefinitionListItem,
2064
+ childCount: 2
2065
+ };
2066
+ const getWebViewVirtualDom = webView => {
2067
+ const {
2068
+ id: id$1,
2069
+ selector: selector$1,
2070
+ contentSecurityPolicy: contentSecurityPolicy$1,
2071
+ elements: elements$1
2072
+ } = webView;
2073
+ const textId = id();
2074
+ const textSelector = selector();
2075
+ const textContentSecurityPolicy = contentSecurityPolicy();
2076
+ const textElements = elements();
2077
+ return [{
2078
+ type: Div$1,
2079
+ className: FeatureWebView,
2080
+ childCount: 5
2081
+ }, item, heading$1, text(textId), pre, text(id$1), item, heading$1, text(textSelector), pre, text(JSON.stringify(selector$1)), item, heading$1, text(textContentSecurityPolicy), pre, text(JSON.stringify(contentSecurityPolicy$1)), item, heading$1, text(textElements), pre, text(JSON.stringify(elements$1, null, 2))];
2082
+ };
2083
+
2084
+ const getFeatureWebViewsVirtualDom = extension => {
2085
+ const webViews$1 = extension.webViews || [];
2086
+ const heading = webViews();
2087
+ return [{
2088
+ type: Div$1,
2089
+ className: FeatureContent,
2090
+ childCount: 2
2091
+ }, ...getFeatureContentHeadingVirtualDom(heading), {
2092
+ type: Div$1,
2093
+ childCount: webViews$1.length
2094
+ }, ...webViews$1.flatMap(getWebViewVirtualDom)];
2095
+ };
2096
+
1980
2097
  const Changelog = 'Changelog';
1981
2098
  const Commands = 'Commands';
1982
2099
  const Details = 'Details';
@@ -1984,6 +2101,7 @@ const Features = 'Features';
1984
2101
  const JsonValidation = 'JsonValidation';
1985
2102
  const ProgrammingLanguages = 'ProgrammingLanguages';
1986
2103
  const Settings = 'Settings';
2104
+ const WebViews = 'WebViews';
1987
2105
  const Theme = 'Theme';
1988
2106
 
1989
2107
  const getFeatureContentVirtualDom = (features, themesHtml, selectedFeature, extension) => {
@@ -1998,12 +2116,10 @@ const getFeatureContentVirtualDom = (features, themesHtml, selectedFeature, exte
1998
2116
  return getFeatureProgrammingLanguagesVirtualDom();
1999
2117
  case Settings:
2000
2118
  return getFeatureSettingsVirtualDom(extension);
2119
+ case WebViews:
2120
+ return getFeatureWebViewsVirtualDom(extension);
2001
2121
  default:
2002
- return [{
2003
- type: Div$1,
2004
- className: 'FeatureContent',
2005
- childCount: 1
2006
- }, text('Not Implemented')];
2122
+ return getFeatureNotImplementedVirtualDom();
2007
2123
  }
2008
2124
  };
2009
2125
 
@@ -2034,6 +2150,13 @@ const getFeatureListVirtualDom = features => {
2034
2150
  };
2035
2151
 
2036
2152
  const getFeaturesVirtualDom = (features, themesHtml, selectedFeature, extension) => {
2153
+ if (features.length === 0) {
2154
+ return [{
2155
+ type: Div$1,
2156
+ className: Features$1,
2157
+ childCount: 3
2158
+ }, text('None')];
2159
+ }
2037
2160
  return [{
2038
2161
  type: Div$1,
2039
2162
  className: Features$1,
@@ -2045,10 +2168,10 @@ const getFeaturesVirtualDom = (features, themesHtml, selectedFeature, extension)
2045
2168
  }, ...getFeatureContentVirtualDom(features, themesHtml, selectedFeature, extension)];
2046
2169
  };
2047
2170
 
2048
- const getExtensionDetailContentVirtualDom = (sanitizedReadmeHtml, themesHtml, selectedTab, features, displaySize, extensionId, extensionVersion, selectedFeature, extension) => {
2171
+ const getExtensionDetailContentVirtualDom = (sanitizedReadmeHtml, themesHtml, selectedTab, features, displaySize, extensionId, extensionVersion, selectedFeature, extension, width) => {
2049
2172
  switch (selectedTab) {
2050
2173
  case Details:
2051
- return getDetailsVirtualDom(sanitizedReadmeHtml, displaySize, extensionId, extensionVersion);
2174
+ return getDetailsVirtualDom(sanitizedReadmeHtml, displaySize, extensionId, extensionVersion, width);
2052
2175
  case Features:
2053
2176
  return getFeaturesVirtualDom(features, themesHtml, selectedFeature, extension);
2054
2177
  case Changelog:
@@ -2058,6 +2181,24 @@ const getExtensionDetailContentVirtualDom = (sanitizedReadmeHtml, themesHtml, se
2058
2181
  }
2059
2182
  };
2060
2183
 
2184
+ const getButtonVirtualDom = (message, onClick) => {
2185
+ return [{
2186
+ type: Button,
2187
+ className: Button$1 + ' ' + ButtonPrimary,
2188
+ onClick,
2189
+ childCount: 1
2190
+ }, text(message)];
2191
+ };
2192
+
2193
+ const getExtensionDetailHeaderActionsVirtualDom = () => {
2194
+ const dom = [{
2195
+ type: Div$1,
2196
+ className: ExtensionDetailHeaderActions,
2197
+ childCount: 2
2198
+ }, ...getButtonVirtualDom('Disable', HandleClickDisable), ...getButtonVirtualDom('Uninstall', HandleClickUninstall)];
2199
+ return dom;
2200
+ };
2201
+
2061
2202
  const getExtensionDetailHeaderVirtualDom = extensionDetail => {
2062
2203
  const {
2063
2204
  name,
@@ -2078,7 +2219,7 @@ const getExtensionDetailHeaderVirtualDom = extensionDetail => {
2078
2219
  }, {
2079
2220
  type: Div$1,
2080
2221
  className: ExtensionDetailHeaderDetails,
2081
- childCount: 2
2222
+ childCount: 3
2082
2223
  }, {
2083
2224
  type: Div$1,
2084
2225
  className: ExtensionDetailName,
@@ -2087,35 +2228,43 @@ const getExtensionDetailHeaderVirtualDom = extensionDetail => {
2087
2228
  type: Div$1,
2088
2229
  className: ExtensionDetailDescription,
2089
2230
  childCount: 1
2090
- }, text(description)];
2231
+ }, text(description), ...getExtensionDetailHeaderActionsVirtualDom()];
2091
2232
  return dom;
2092
2233
  };
2093
2234
 
2094
- const getFeatures = selectedFeature => {
2235
+ const hasThemes = extension => {
2236
+ return extension && (extension.colorThemes || extension.iconThemes || extension.productIconThemes);
2237
+ };
2238
+ const hasCommands = extension => {
2239
+ return extension && extension.commands;
2240
+ };
2241
+ const hasJsonValidation = extension => {
2242
+ return extension && extension.jsonValidation;
2243
+ };
2244
+ const hasProgrammingLanguages = extension => {
2245
+ return extension && extension.programmingLanguages;
2246
+ };
2247
+ const hasSettings = extension => {
2248
+ return extension && extension.settings;
2249
+ };
2250
+ const hasWebViews = extension => {
2251
+ return extension && extension.webViews;
2252
+ };
2253
+ const ifElseFeature = (id, label, isEnabled, selectedFeature, extension) => {
2254
+ if (!isEnabled(extension)) {
2255
+ return [];
2256
+ }
2257
+ return [{
2258
+ id,
2259
+ label,
2260
+ selected: selectedFeature === id
2261
+ }];
2262
+ };
2263
+ const getFeatures = (selectedFeature, extension) => {
2095
2264
  if (!selectedFeature) {
2096
2265
  selectedFeature = Theme;
2097
2266
  }
2098
- const features = [{
2099
- id: Theme,
2100
- label: 'Theme',
2101
- selected: selectedFeature === Theme
2102
- }, {
2103
- id: Commands,
2104
- label: 'Commands',
2105
- selected: selectedFeature === Commands
2106
- }, {
2107
- id: JsonValidation,
2108
- label: 'Json Validation',
2109
- selected: selectedFeature === JsonValidation
2110
- }, {
2111
- id: ProgrammingLanguages,
2112
- label: 'Programming Languages',
2113
- selected: selectedFeature === ProgrammingLanguages
2114
- }, {
2115
- id: Settings,
2116
- label: 'Settings',
2117
- selected: selectedFeature === Settings
2118
- }];
2267
+ const features = [...ifElseFeature(Theme, 'Theme', hasThemes, selectedFeature, extension), ...ifElseFeature(Commands, 'Commands', hasCommands, selectedFeature, extension), ...ifElseFeature(JsonValidation, 'Json Validation', hasJsonValidation, selectedFeature, extension), ...ifElseFeature(ProgrammingLanguages, 'Programming Languages', hasProgrammingLanguages, selectedFeature, extension), ...ifElseFeature(Settings, 'Settings', hasSettings, selectedFeature, extension), ...ifElseFeature(WebViews, 'WebViews', hasWebViews, selectedFeature, extension)];
2119
2268
  return features;
2120
2269
  };
2121
2270
 
@@ -2176,6 +2325,33 @@ const getTabsVirtualDom = tabs => {
2176
2325
  }, ...tabs.flatMap(getTabVirtualDom)];
2177
2326
  };
2178
2327
 
2328
+ const Small = 1;
2329
+ const Normal = 2;
2330
+ const Large = 3;
2331
+
2332
+ const getViewletSize = width => {
2333
+ if (width < 180) {
2334
+ return Small;
2335
+ }
2336
+ if (width < 768) {
2337
+ return Normal;
2338
+ }
2339
+ return Large;
2340
+ };
2341
+
2342
+ const getClassNames = size => {
2343
+ switch (size) {
2344
+ case Small:
2345
+ return Small$1;
2346
+ case Normal:
2347
+ return Normal$1;
2348
+ case Large:
2349
+ return Large$1;
2350
+ default:
2351
+ return '';
2352
+ }
2353
+ };
2354
+
2179
2355
  const getExtensionDetailVirtualDom = (extensionDetail, sanitizedReadmeHtml, selectedTab, newState) => {
2180
2356
  // TODO move this to view model so that rendering occurs like
2181
2357
  // 1. state
@@ -2184,18 +2360,21 @@ const getExtensionDetailVirtualDom = (extensionDetail, sanitizedReadmeHtml, sele
2184
2360
  // 4. dom
2185
2361
  const themesHtml = newState?.selectedFeatureMarkdownDom || '';
2186
2362
  const selectedFeature = newState?.selectedFeature || '';
2187
- const features = newState?.features || getFeatures(selectedFeature);
2363
+ const extension = newState?.extension || {};
2364
+ const features = getFeatures(selectedFeature, extension);
2188
2365
  const size = newState.folderSize || 0;
2189
2366
  const extensionId = newState?.extension?.id || 'n/a';
2190
2367
  const extensionVersion = newState?.extension?.version || 'n/a';
2191
- const extension = newState?.extension || {};
2192
2368
  const displaySize = getDisplaySize(size);
2369
+ const width = newState?.width || 500;
2193
2370
  const tabs = getTabs(selectedTab);
2371
+ const sizeValue = getViewletSize(newState?.width || 0);
2372
+ const sizeClass = getClassNames(sizeValue);
2194
2373
  const dom = [{
2195
2374
  type: Div$1,
2196
- className: mergeClassNames(Viewlet, ExtensionDetail),
2375
+ className: mergeClassNames(Viewlet, ExtensionDetail, sizeClass),
2197
2376
  childCount: 3
2198
- }, ...getExtensionDetailHeaderVirtualDom(extensionDetail), ...getTabsVirtualDom(tabs), ...getExtensionDetailContentVirtualDom(sanitizedReadmeHtml, themesHtml, selectedTab, features, displaySize, extensionId, extensionVersion, selectedFeature, extension)];
2377
+ }, ...getExtensionDetailHeaderVirtualDom(extensionDetail), ...getTabsVirtualDom(tabs), ...getExtensionDetailContentVirtualDom(sanitizedReadmeHtml, themesHtml, selectedTab, features, displaySize, extensionId, extensionVersion, selectedFeature, extension, width)];
2199
2378
  return dom;
2200
2379
  };
2201
2380
 
@@ -2242,7 +2421,14 @@ const getLinkMenuEntries = props => {
2242
2421
 
2243
2422
  const getMenuEntries = props => [...getLinkMenuEntries(props), ...getImageMenuEntries(props), getCopyMenuEntry()];
2244
2423
 
2424
+ const handleClickDisable = async state => {
2425
+ return state;
2426
+ };
2427
+
2245
2428
  const selectFeature = async (state, name) => {
2429
+ if (!name) {
2430
+ return state;
2431
+ }
2246
2432
  const {
2247
2433
  features
2248
2434
  } = state;
@@ -2292,6 +2478,10 @@ const handleClickSize = async state => {
2292
2478
  return state;
2293
2479
  };
2294
2480
 
2481
+ const handleClickUninstall = async state => {
2482
+ return state;
2483
+ };
2484
+
2295
2485
  const assetDir = '';
2296
2486
 
2297
2487
  const ExtensionDefaultIcon = `${assetDir}/icons/extensionDefaultIcon.png`;
@@ -4862,6 +5052,7 @@ const selectTab$1 = async state => {
4862
5052
  iconThemes,
4863
5053
  productIconThemes
4864
5054
  } = extension;
5055
+ // TODO do this depending on featured tab content
4865
5056
  const markdown = getThemeMarkdown(colorThemes || [], iconThemes || [], productIconThemes || []);
4866
5057
  const rendered = await renderMarkdown(markdown, {
4867
5058
  baseUrl
@@ -5011,20 +5202,6 @@ const getSavedSelectedTab = savedState => {
5011
5202
  return Details;
5012
5203
  };
5013
5204
 
5014
- const Small = 1;
5015
- const Normal = 2;
5016
- const Large = 3;
5017
-
5018
- const getViewletSize = width => {
5019
- if (width < 180) {
5020
- return Small;
5021
- }
5022
- if (width < 768) {
5023
- return Normal;
5024
- }
5025
- return Large;
5026
- };
5027
-
5028
5205
  const readFile = async uri => {
5029
5206
  return invoke('FileSystem.readFile', uri);
5030
5207
  };
@@ -5073,7 +5250,7 @@ const loadContent = async (state, platform, savedState) => {
5073
5250
  const size = getViewletSize(width);
5074
5251
  const selectedTab = getSavedSelectedTab(savedState);
5075
5252
  const selectedFeature = getSavedSelectedFeature(savedState);
5076
- const features = getFeatures(selectedFeature);
5253
+ const features = getFeatures(selectedFeature, extension);
5077
5254
  const folderSize = await getFolderSize(extension.uri);
5078
5255
  const entries = [{
5079
5256
  key: 'Identifier',
@@ -5116,7 +5293,7 @@ const loadContent = async (state, platform, savedState) => {
5116
5293
  iconSrc,
5117
5294
  name,
5118
5295
  description,
5119
- size,
5296
+ sizeOnDisk: size,
5120
5297
  entries,
5121
5298
  secondEntries,
5122
5299
  categories,
@@ -5147,7 +5324,9 @@ const commandMap = {
5147
5324
  'ExtensionDetail.create': create,
5148
5325
  'ExtensionDetail.getMenuEntries': getMenuEntries,
5149
5326
  'ExtensionDetail.getVirtualDom': getExtensionDetailVirtualDom,
5327
+ 'ExtensionDetail.handleClickDisable': handleClickDisable,
5150
5328
  'ExtensionDetail.handleClickSize': handleClickSize,
5329
+ 'ExtensionDetail.handleClickUninstall': handleClickUninstall,
5151
5330
  'ExtensionDetail.handleFeaturesClick': handleClickFeatures,
5152
5331
  'ExtensionDetail.handleIconError': handleIconError,
5153
5332
  'ExtensionDetail.handleTabsClick': handleTabsClick,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "3.8.0",
3
+ "version": "3.10.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "keywords": [],
6
6
  "license": "MIT",