@lvce-editor/extension-detail-view 3.31.0 → 3.33.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.
@@ -944,30 +944,37 @@ const {
944
944
 
945
945
  const create$1 = (uid, uri, x, y, width, height, platform, assetDir) => {
946
946
  const state = {
947
+ assetDir: assetDir || '',
948
+ baseUrl: '',
949
+ builtinExtensionsBadgeEnabled: true,
950
+ categories: [],
951
+ changelogVirtualDom: [],
947
952
  description: '',
948
- iconSrc: '',
949
- selectedFeature: '',
950
- name: '',
951
- sanitizedReadmeHtml: '',
952
- selectedTab: '',
953
- sizeOnDisk: 0,
954
- width,
955
- uri,
953
+ detailsVirtualDom: [],
954
+ displaySize: '',
956
955
  entries: [],
957
- secondEntries: [],
958
- categories: [],
959
- resources: [],
960
- selectedFeatureMarkdownDom: '',
961
956
  extension: {},
962
- baseUrl: '',
963
957
  features: [],
958
+ featuresVirtualDom: [],
964
959
  folderSize: 0,
965
- assetDir: assetDir || '',
960
+ iconSrc: '',
961
+ name: '',
966
962
  platform,
967
963
  readmeScrollTop: 0,
964
+ resources: [],
965
+ scrollToTopButtonEnabled: false,
966
+ secondEntries: [],
967
+ selectedFeature: '',
968
+ themesMarkdownDom: [],
969
+ selectedTab: '',
968
970
  settingsButtonEnabled: false,
969
- builtinExtensionsBadgeEnabled: true,
970
- scrollToTopButtonEnabled: false
971
+ showAdditionalDetailsBreakpoint: 600,
972
+ sizeOnDisk: 0,
973
+ uri,
974
+ width,
975
+ hasColorTheme: false,
976
+ isBuiltin: false,
977
+ sizeValue: 0
971
978
  };
972
979
  set$1(uid, state, state);
973
980
  };
@@ -1402,10 +1409,61 @@ const SetColorTheme = 'SetColorTheme';
1402
1409
  const Disable = 'Disable';
1403
1410
  const Uninstall = 'Uninstall';
1404
1411
 
1412
+ const getMarkdownVirtualDom = async html => {
1413
+ string(html);
1414
+ const dom = await getMarkdownDom(html);
1415
+ return dom;
1416
+ };
1417
+
1418
+ const readFile = async uri => {
1419
+ return readFile$1(uri);
1420
+ };
1421
+
1422
+ const ENOENT = 'ENOENT';
1423
+
1424
+ const isEnoentError = error => {
1425
+ return error && error.code === ENOENT;
1426
+ };
1427
+
1428
+ const join = (pathSeparator, ...parts) => {
1429
+ return parts.join(pathSeparator);
1430
+ };
1431
+
1432
+ const loadChangelogContent = async path => {
1433
+ try {
1434
+ const changelogUrl = join('/', path, 'CHANGELOG.md');
1435
+ const changelogContent = await readFile(changelogUrl);
1436
+ return changelogContent;
1437
+ } catch (error) {
1438
+ if (isEnoentError(error)) {
1439
+ return '';
1440
+ }
1441
+ // TODO send message to error worker
1442
+ // @ts-ignore
1443
+ console.error(new VError(error, 'Failed to load Changelog content'));
1444
+ return `${error}`;
1445
+ }
1446
+ };
1447
+
1448
+ const renderMarkdown = async (markdown, options = {}) => {
1449
+ const html = await renderMarkdown$1(markdown, options);
1450
+ return html;
1451
+ };
1452
+
1405
1453
  const selectTabChangelog = async state => {
1454
+ const {
1455
+ extension,
1456
+ baseUrl
1457
+ } = state;
1458
+ const changelogContent = await loadChangelogContent(extension.path); // TODO use uri
1459
+ const changelogMarkdownHtml = await renderMarkdown(changelogContent, {
1460
+ baseUrl
1461
+ });
1462
+ const changelogDom = await getMarkdownVirtualDom(changelogMarkdownHtml);
1406
1463
  return {
1407
1464
  ...state,
1408
- selectedTab: Changelog$1
1465
+ selectedTab: Changelog$1,
1466
+ changelogVirtualDom: changelogDom
1409
1467
  };
1410
1468
  };
1411
1469
 
@@ -1413,11 +1471,36 @@ const selectTabDefault = async state => {
1413
1471
  return state;
1414
1472
  };
1415
1473
 
1474
+ const loadReadmeContent = async path => {
1475
+ try {
1476
+ const readmeUrl = join('/', path, 'README.md');
1477
+ const readmeContent = await readFile(readmeUrl);
1478
+ return readmeContent;
1479
+ } catch (error) {
1480
+ if (isEnoentError(error)) {
1481
+ return '';
1482
+ }
1483
+ // TODO send message to error worker
1484
+ // @ts-ignore
1485
+ console.error(new VError(error, 'Failed to load Readme content'));
1486
+ return `${error}`;
1487
+ }
1488
+ };
1489
+
1416
1490
  const selectTabDetails = async state => {
1417
- // TODO load readmo markdown here
1491
+ const {
1492
+ extension,
1493
+ baseUrl
1494
+ } = state;
1495
+ const readmeContent = await loadReadmeContent(extension.path);
1496
+ const readmeHtml = await renderMarkdown(readmeContent, {
1497
+ baseUrl
1498
+ });
1499
+ const detailsDom = await getMarkdownVirtualDom(readmeHtml);
1418
1500
  return {
1419
1501
  ...state,
1420
- selectedTab: Details
1502
+ selectedTab: Details,
1503
+ detailsVirtualDom: detailsDom
1421
1504
  };
1422
1505
  };
1423
1506
 
@@ -1454,30 +1537,31 @@ const getThemeMarkdown = (themes, iconThemes, productIconThemes) => {
1454
1537
  return markdown;
1455
1538
  };
1456
1539
 
1457
- const renderMarkdown = async (markdown, options = {}) => {
1458
- const html = await renderMarkdown$1(markdown, options);
1459
- return html;
1460
- };
1461
-
1462
- const selectTab$1 = async state => {
1540
+ const selectTabFeatures = async state => {
1463
1541
  const {
1464
1542
  extension,
1465
- baseUrl
1543
+ baseUrl,
1544
+ selectedFeature
1466
1545
  } = state;
1467
- const {
1468
- colorThemes,
1469
- iconThemes,
1470
- productIconThemes
1471
- } = extension;
1472
- // TODO do this depending on featured tab content
1473
- const markdown = getThemeMarkdown(colorThemes || [], iconThemes || [], productIconThemes || []);
1474
- const rendered = await renderMarkdown(markdown, {
1475
- baseUrl
1476
- });
1546
+
1547
+ // Only generate theme markdown when the selected feature is actually "Theme"
1548
+ let themesMarkdownDom = [];
1549
+ if (!selectedFeature || selectedFeature === Theme) {
1550
+ const {
1551
+ colorThemes,
1552
+ iconThemes,
1553
+ productIconThemes
1554
+ } = extension;
1555
+ const markdown = getThemeMarkdown(colorThemes || [], iconThemes || [], productIconThemes || []);
1556
+ const rendered = await renderMarkdown(markdown, {
1557
+ baseUrl
1558
+ });
1559
+ themesMarkdownDom = await getMarkdownVirtualDom(rendered);
1560
+ }
1477
1561
  return {
1478
1562
  ...state,
1479
1563
  selectedTab: Features$1,
1480
- selectedFeatureMarkdownDom: rendered
1564
+ themesMarkdownDom: themesMarkdownDom
1481
1565
  };
1482
1566
  };
1483
1567
 
@@ -1486,7 +1570,7 @@ const getSelectTabHandler = selectedTab => {
1486
1570
  case Details:
1487
1571
  return selectTabDetails;
1488
1572
  case Features$1:
1489
- return selectTab$1;
1573
+ return selectTabFeatures;
1490
1574
  case Changelog$1:
1491
1575
  return selectTabChangelog;
1492
1576
  default:
@@ -1618,6 +1702,99 @@ const getCategories = () => {
1618
1702
  }];
1619
1703
  };
1620
1704
 
1705
+ const BYTE_UNITS = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
1706
+ const BIBYTE_UNITS = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
1707
+ const BIT_UNITS = ['b', 'kbit', 'Mbit', 'Gbit', 'Tbit', 'Pbit', 'Ebit', 'Zbit', 'Ybit'];
1708
+ const BIBIT_UNITS = ['b', 'kibit', 'Mibit', 'Gibit', 'Tibit', 'Pibit', 'Eibit', 'Zibit', 'Yibit'];
1709
+
1710
+ /*
1711
+ Formats the given number using `Number#toLocaleString`.
1712
+ - If locale is a string, the value is expected to be a locale-key (for example: `de`).
1713
+ - If locale is true, the system default locale is used for translation.
1714
+ - If no value for locale is specified, the number is returned unmodified.
1715
+ */
1716
+ const toLocaleString = (number, locale, options) => {
1717
+ let result = number;
1718
+ if (typeof locale === 'string' || Array.isArray(locale)) {
1719
+ result = number.toLocaleString(locale, options);
1720
+ } else if (locale === true || options !== undefined) {
1721
+ result = number.toLocaleString(undefined, options);
1722
+ }
1723
+ return result;
1724
+ };
1725
+ const log10 = numberOrBigInt => {
1726
+ if (typeof numberOrBigInt === 'number') {
1727
+ return Math.log10(numberOrBigInt);
1728
+ }
1729
+ const string = numberOrBigInt.toString(10);
1730
+ return string.length + Math.log10('0.' + string.slice(0, 15));
1731
+ };
1732
+ const log = numberOrBigInt => {
1733
+ if (typeof numberOrBigInt === 'number') {
1734
+ return Math.log(numberOrBigInt);
1735
+ }
1736
+ return log10(numberOrBigInt) * Math.log(10);
1737
+ };
1738
+ const divide = (numberOrBigInt, divisor) => {
1739
+ if (typeof numberOrBigInt === 'number') {
1740
+ return numberOrBigInt / divisor;
1741
+ }
1742
+ const integerPart = numberOrBigInt / BigInt(divisor);
1743
+ const remainder = numberOrBigInt % BigInt(divisor);
1744
+ return Number(integerPart) + Number(remainder) / divisor;
1745
+ };
1746
+ function prettyBytes(number, options) {
1747
+ if (typeof number !== 'bigint' && !Number.isFinite(number)) {
1748
+ throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
1749
+ }
1750
+ options = {
1751
+ bits: false,
1752
+ binary: false,
1753
+ space: true,
1754
+ ...options
1755
+ };
1756
+ const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
1757
+ const separator = options.space ? ' ' : '';
1758
+ if (options.signed && (typeof number === 'number' ? number === 0 : number === 0n)) {
1759
+ return ` 0${separator}${UNITS[0]}`;
1760
+ }
1761
+ const isNegative = number < 0;
1762
+ const prefix = isNegative ? '-' : options.signed ? '+' : '';
1763
+ if (isNegative) {
1764
+ number = -number;
1765
+ }
1766
+ let localeOptions;
1767
+ if (options.minimumFractionDigits !== undefined) {
1768
+ localeOptions = {
1769
+ minimumFractionDigits: options.minimumFractionDigits
1770
+ };
1771
+ }
1772
+ if (options.maximumFractionDigits !== undefined) {
1773
+ localeOptions = {
1774
+ maximumFractionDigits: options.maximumFractionDigits,
1775
+ ...localeOptions
1776
+ };
1777
+ }
1778
+ if (number < 1) {
1779
+ const numberString = toLocaleString(number, options.locale, localeOptions);
1780
+ return prefix + numberString + separator + UNITS[0];
1781
+ }
1782
+ const exponent = Math.min(Math.floor(options.binary ? log(number) / Math.log(1024) : log10(number) / 3), UNITS.length - 1);
1783
+ number = divide(number, (options.binary ? 1024 : 1000) ** exponent);
1784
+ if (!localeOptions) {
1785
+ number = number.toPrecision(3);
1786
+ }
1787
+ const numberString = toLocaleString(Number(number), options.locale, localeOptions);
1788
+ const unit = UNITS[exponent];
1789
+ return prefix + numberString + separator + unit;
1790
+ }
1791
+
1792
+ const getDisplaySize = size => {
1793
+ return prettyBytes(size, {
1794
+ maximumFractionDigits: 1
1795
+ });
1796
+ };
1797
+
1621
1798
  const getEntries = () => {
1622
1799
  return [{
1623
1800
  key: 'Identifier',
@@ -1729,34 +1906,8 @@ const getViewletSize = width => {
1729
1906
  return Large$1;
1730
1907
  };
1731
1908
 
1732
- const readFile = async uri => {
1733
- return readFile$1(uri);
1734
- };
1735
-
1736
- const ENOENT = 'ENOENT';
1737
-
1738
- const isEnoentError = error => {
1739
- return error && error.code === ENOENT;
1740
- };
1741
-
1742
- const join = (pathSeparator, ...parts) => {
1743
- return parts.join(pathSeparator);
1744
- };
1745
-
1746
- const loadReadmeContent = async path => {
1747
- try {
1748
- const readmeUrl = join('/', path, 'README.md');
1749
- const readmeContent = await readFile(readmeUrl);
1750
- return readmeContent;
1751
- } catch (error) {
1752
- if (isEnoentError(error)) {
1753
- return '';
1754
- }
1755
- // TODO send message to error worker
1756
- // @ts-ignore
1757
- console.error(new VError(error, 'Failed to load Readme content'));
1758
- return `${error}`;
1759
- }
1909
+ const hasColorThemes = extension => {
1910
+ return Boolean(extension && extension.colorThemes && extension.colorThemes.length > 0);
1760
1911
  };
1761
1912
 
1762
1913
  const getSavedSelectedFeature = savedState => {
@@ -1798,8 +1949,7 @@ const loadContent = async (state, platform, savedState) => {
1798
1949
  const readmeHtml = await renderMarkdown(readmeContent, {
1799
1950
  baseUrl
1800
1951
  });
1801
- const sanitizedReadmeHtml = readmeHtml;
1802
- const normalizedReadmeHtml = sanitizedReadmeHtml;
1952
+ const detailsVirtualDom = await getMarkdownVirtualDom(readmeHtml);
1803
1953
  const iconSrc = getIcon(extension, platform, assetDir);
1804
1954
  const description = getDescription(extension);
1805
1955
  const name = getName(extension);
@@ -1811,26 +1961,34 @@ const loadContent = async (state, platform, savedState) => {
1811
1961
  const features = getFeatures(selectedFeature, extension);
1812
1962
  const extensionUri = extension.uri || extension.path;
1813
1963
  const folderSize = await getFolderSize(extensionUri);
1964
+ const displaySize = getDisplaySize(size);
1814
1965
  const entries = getEntries();
1815
1966
  const secondEntries = getSecondEntries();
1816
1967
  const categories = getCategories();
1817
1968
  const resources = getResources();
1969
+ const sizeValue = getViewletSize(width || 0);
1970
+ const isBuiltin = extension?.builtin;
1971
+ const hasColorTheme = hasColorThemes(extension);
1818
1972
  return {
1819
1973
  ...state,
1820
- selectedTab,
1821
- sanitizedReadmeHtml: normalizedReadmeHtml,
1822
- iconSrc,
1823
- name,
1974
+ baseUrl,
1975
+ categories,
1824
1976
  description,
1825
- sizeOnDisk: size,
1977
+ detailsVirtualDom,
1978
+ displaySize,
1826
1979
  entries,
1827
- secondEntries,
1828
- categories,
1829
- resources,
1830
1980
  extension,
1831
- baseUrl,
1832
1981
  features,
1833
- folderSize
1982
+ folderSize,
1983
+ hasColorTheme,
1984
+ iconSrc,
1985
+ isBuiltin,
1986
+ name,
1987
+ resources,
1988
+ secondEntries,
1989
+ selectedTab,
1990
+ sizeOnDisk: size,
1991
+ sizeValue
1834
1992
  };
1835
1993
  };
1836
1994
 
@@ -1934,106 +2092,13 @@ const TableCell = 'TableCell';
1934
2092
  const TableHeading = 'TableHeading';
1935
2093
  const Viewlet = 'Viewlet';
1936
2094
 
1937
- const getBadge = (extension, state) => {
1938
- if (extension?.builtin && state.builtinExtensionsBadgeEnabled) {
2095
+ const getBadge = (builtin, badgeEnabled) => {
2096
+ if (builtin && badgeEnabled) {
1939
2097
  return 'builtin';
1940
2098
  }
1941
2099
  return '';
1942
2100
  };
1943
2101
 
1944
- const BYTE_UNITS = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
1945
- const BIBYTE_UNITS = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
1946
- const BIT_UNITS = ['b', 'kbit', 'Mbit', 'Gbit', 'Tbit', 'Pbit', 'Ebit', 'Zbit', 'Ybit'];
1947
- const BIBIT_UNITS = ['b', 'kibit', 'Mibit', 'Gibit', 'Tibit', 'Pibit', 'Eibit', 'Zibit', 'Yibit'];
1948
-
1949
- /*
1950
- Formats the given number using `Number#toLocaleString`.
1951
- - If locale is a string, the value is expected to be a locale-key (for example: `de`).
1952
- - If locale is true, the system default locale is used for translation.
1953
- - If no value for locale is specified, the number is returned unmodified.
1954
- */
1955
- const toLocaleString = (number, locale, options) => {
1956
- let result = number;
1957
- if (typeof locale === 'string' || Array.isArray(locale)) {
1958
- result = number.toLocaleString(locale, options);
1959
- } else if (locale === true || options !== undefined) {
1960
- result = number.toLocaleString(undefined, options);
1961
- }
1962
- return result;
1963
- };
1964
- const log10 = numberOrBigInt => {
1965
- if (typeof numberOrBigInt === 'number') {
1966
- return Math.log10(numberOrBigInt);
1967
- }
1968
- const string = numberOrBigInt.toString(10);
1969
- return string.length + Math.log10('0.' + string.slice(0, 15));
1970
- };
1971
- const log = numberOrBigInt => {
1972
- if (typeof numberOrBigInt === 'number') {
1973
- return Math.log(numberOrBigInt);
1974
- }
1975
- return log10(numberOrBigInt) * Math.log(10);
1976
- };
1977
- const divide = (numberOrBigInt, divisor) => {
1978
- if (typeof numberOrBigInt === 'number') {
1979
- return numberOrBigInt / divisor;
1980
- }
1981
- const integerPart = numberOrBigInt / BigInt(divisor);
1982
- const remainder = numberOrBigInt % BigInt(divisor);
1983
- return Number(integerPart) + Number(remainder) / divisor;
1984
- };
1985
- function prettyBytes(number, options) {
1986
- if (typeof number !== 'bigint' && !Number.isFinite(number)) {
1987
- throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
1988
- }
1989
- options = {
1990
- bits: false,
1991
- binary: false,
1992
- space: true,
1993
- ...options
1994
- };
1995
- const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
1996
- const separator = options.space ? ' ' : '';
1997
- if (options.signed && (typeof number === 'number' ? number === 0 : number === 0n)) {
1998
- return ` 0${separator}${UNITS[0]}`;
1999
- }
2000
- const isNegative = number < 0;
2001
- const prefix = isNegative ? '-' : options.signed ? '+' : '';
2002
- if (isNegative) {
2003
- number = -number;
2004
- }
2005
- let localeOptions;
2006
- if (options.minimumFractionDigits !== undefined) {
2007
- localeOptions = {
2008
- minimumFractionDigits: options.minimumFractionDigits
2009
- };
2010
- }
2011
- if (options.maximumFractionDigits !== undefined) {
2012
- localeOptions = {
2013
- maximumFractionDigits: options.maximumFractionDigits,
2014
- ...localeOptions
2015
- };
2016
- }
2017
- if (number < 1) {
2018
- const numberString = toLocaleString(number, options.locale, localeOptions);
2019
- return prefix + numberString + separator + UNITS[0];
2020
- }
2021
- const exponent = Math.min(Math.floor(options.binary ? log(number) / Math.log(1024) : log10(number) / 3), UNITS.length - 1);
2022
- number = divide(number, (options.binary ? 1024 : 1000) ** exponent);
2023
- if (!localeOptions) {
2024
- number = number.toPrecision(3);
2025
- }
2026
- const numberString = toLocaleString(Number(number), options.locale, localeOptions);
2027
- const unit = UNITS[exponent];
2028
- return prefix + numberString + separator + unit;
2029
- }
2030
-
2031
- const getDisplaySize = size => {
2032
- return prettyBytes(size, {
2033
- maximumFractionDigits: 1
2034
- });
2035
- };
2036
-
2037
2102
  const HandleClickCategory = 'handleClickCategory';
2038
2103
  const HandleClickDisable = 'handleClickDisable';
2039
2104
  const HandleClickScrollToTop = 'handleClickScrollToTop';
@@ -2047,15 +2112,11 @@ const HandleReadmeContextMenu = 'handleReadmeContextMenu';
2047
2112
  const HandleReadmeWheel = 'handleReadmeWheel';
2048
2113
  const HandleTabsClick = 'handleTabsClick';
2049
2114
 
2050
- const hasColorThemes = extension => {
2051
- return Boolean(extension && extension.colorThemes && extension.colorThemes.length > 0);
2052
- };
2053
-
2054
- const getExtensionDetailButtons = extension => {
2115
+ const getExtensionDetailButtons = (hasColorTheme, isBuiltin) => {
2055
2116
  const allActions = [{
2056
2117
  label: setColorTheme$3(),
2057
2118
  onClick: HandleClickSetColorTheme,
2058
- enabled: hasColorThemes(extension),
2119
+ enabled: hasColorTheme,
2059
2120
  name: SetColorTheme
2060
2121
  }, {
2061
2122
  label: disable(),
@@ -2065,7 +2126,7 @@ const getExtensionDetailButtons = extension => {
2065
2126
  }, {
2066
2127
  label: uninstall(),
2067
2128
  onClick: HandleClickUninstall,
2068
- enabled: !extension?.builtin,
2129
+ enabled: !isBuiltin,
2069
2130
  name: Uninstall
2070
2131
  }];
2071
2132
  return allActions;
@@ -2253,12 +2314,6 @@ const getInstallationEntries = (displaySize, extensionId, extensionVersion, exte
2253
2314
  return entries;
2254
2315
  };
2255
2316
 
2256
- const getMarkdownVirtualDom = async html => {
2257
- string(html);
2258
- const dom = await getMarkdownDom(html);
2259
- return dom;
2260
- };
2261
-
2262
2317
  const getMarketplaceEntries = () => {
2263
2318
  return [{
2264
2319
  key: 'Published',
@@ -2294,14 +2349,14 @@ const getChildCount = (additionalDetails, scrollToTopEnabled) => {
2294
2349
  }
2295
2350
  return count;
2296
2351
  };
2297
- const getDetailsVirtualDom = async (sanitizedReadmeHtml, displaySize, extensionId, extensionVersion, width, extensionUri, scrollToTopButtonEnabled, categories$1, resources$1) => {
2352
+ const getDetailsVirtualDom = (sanitizedReadmeHtml, displaySize, extensionId, extensionVersion, width, extensionUri, scrollToTopButtonEnabled, categories$1, resources$1, showAdditionalDetailsBreakpoint // new parameter, no default
2353
+ ) => {
2298
2354
  const firstHeading = installation();
2299
2355
  const entries = getInstallationEntries(displaySize, extensionId, extensionVersion, extensionUri);
2300
2356
  const secondHeading = marketplace();
2301
2357
  const secondEntries = getMarketplaceEntries();
2302
2358
  const thirdHeading = categories();
2303
2359
  const fourthHeading = resources();
2304
- const showAdditionalDetailsBreakpoint = 600;
2305
2360
  const showAdditionalDetails = width > showAdditionalDetailsBreakpoint;
2306
2361
  const childCount = getChildCount(showAdditionalDetails, scrollToTopButtonEnabled);
2307
2362
  const dom = [{
@@ -2309,7 +2364,7 @@ const getDetailsVirtualDom = async (sanitizedReadmeHtml, displaySize, extensionI
2309
2364
  className: ExtensionDetailPanel,
2310
2365
  childCount: childCount,
2311
2366
  role: Panel
2312
- }, ...getScrollToTopVirtualDom(scrollToTopButtonEnabled), ...(await getMarkdownVirtualDom(sanitizedReadmeHtml)), ...getAdditionalDetailsVirtualDom(showAdditionalDetails, firstHeading, entries, secondHeading, secondEntries, thirdHeading, categories$1, fourthHeading, resources$1)];
2367
+ }, ...getScrollToTopVirtualDom(scrollToTopButtonEnabled), ...sanitizedReadmeHtml, ...getAdditionalDetailsVirtualDom(showAdditionalDetails, firstHeading, entries, secondHeading, secondEntries, thirdHeading, categories$1, fourthHeading, resources$1)];
2313
2368
  return dom;
2314
2369
  };
2315
2370
 
@@ -2540,9 +2595,8 @@ const getVirtualDomChildCount = dom => {
2540
2595
  return stack.length;
2541
2596
  };
2542
2597
 
2543
- const getFeatureThemesVirtualDom = async themesHtml => {
2544
- const markdownDom = await getMarkdownVirtualDom(themesHtml);
2545
- const childCount = getVirtualDomChildCount(markdownDom);
2598
+ const getFeatureThemesVirtualDom = themesDom => {
2599
+ const childCount = getVirtualDomChildCount(themesDom);
2546
2600
  const heading = theme();
2547
2601
  return [{
2548
2602
  type: VirtualDomElements.Div,
@@ -2552,7 +2606,7 @@ const getFeatureThemesVirtualDom = async themesHtml => {
2552
2606
  type: VirtualDomElements.Div,
2553
2607
  className: DefaultMarkdown,
2554
2608
  childCount
2555
- }, ...markdownDom];
2609
+ }, ...themesDom];
2556
2610
  };
2557
2611
 
2558
2612
  const toWebView = rawWebView => {
@@ -2621,10 +2675,10 @@ const getFeatureWebViewsVirtualDom = extension => {
2621
2675
  }, ...webViews$1.flatMap(getWebViewVirtualDom)];
2622
2676
  };
2623
2677
 
2624
- const getFeatureContentVirtualDom = async (features, themesHtml, selectedFeature, extension) => {
2678
+ const getFeatureContentVirtualDom = (features, themesDom, selectedFeature, extension) => {
2625
2679
  switch (selectedFeature) {
2626
2680
  case Theme:
2627
- return await getFeatureThemesVirtualDom(themesHtml);
2681
+ return getFeatureThemesVirtualDom(themesDom);
2628
2682
  case Commands:
2629
2683
  return getFeatureCommandsVirtualDom(extension);
2630
2684
  case JsonValidation:
@@ -2666,7 +2720,7 @@ const getFeatureListVirtualDom = features => {
2666
2720
  }, ...features.flatMap(getFeatureListItemVirtualDom)];
2667
2721
  };
2668
2722
 
2669
- const getFeaturesVirtualDom = async (features, themesHtml, selectedFeature, extension) => {
2723
+ const getFeaturesVirtualDom = (features, themesDom, selectedFeature, extension) => {
2670
2724
  if (features.length === 0) {
2671
2725
  const none$1 = none();
2672
2726
  return [{
@@ -2683,15 +2737,15 @@ const getFeaturesVirtualDom = async (features, themesHtml, selectedFeature, exte
2683
2737
  type: VirtualDomElements.Div,
2684
2738
  className: mergeClassNames(Sash, SashVertical),
2685
2739
  childCount: 0
2686
- }, ...(await getFeatureContentVirtualDom(features, themesHtml, selectedFeature, extension))];
2740
+ }, ...getFeatureContentVirtualDom(features, themesDom, selectedFeature, extension)];
2687
2741
  };
2688
2742
 
2689
- const getExtensionDetailContentVirtualDom = async (sanitizedReadmeHtml, themesHtml, selectedTab, features, displaySize, extensionId, extensionVersion, selectedFeature, extension, width, scrollToTopButtonEnabled, categories, resources) => {
2743
+ const getExtensionDetailContentVirtualDom = (sanitizedReadmeHtml, themesDom, selectedTab, features, displaySize, extensionId, extensionVersion, selectedFeature, extension, width, scrollToTopButtonEnabled, categories, resources, breakpoint) => {
2690
2744
  switch (selectedTab) {
2691
2745
  case Details:
2692
- return await getDetailsVirtualDom(sanitizedReadmeHtml, displaySize, extensionId, extensionVersion, width, extension.uri || extension.path || '', scrollToTopButtonEnabled, categories, resources);
2746
+ return getDetailsVirtualDom(sanitizedReadmeHtml, displaySize, extensionId, extensionVersion, width, extension.uri || extension.path || '', scrollToTopButtonEnabled, categories, resources, breakpoint);
2693
2747
  case Features$1:
2694
- return await getFeaturesVirtualDom(features, themesHtml, selectedFeature, extension);
2748
+ return getFeaturesVirtualDom(features, themesDom, selectedFeature, extension);
2695
2749
  case Changelog$1:
2696
2750
  return getChangelogVirtualDom();
2697
2751
  default:
@@ -2748,6 +2802,17 @@ const getExtensionDetailHeaderActionsVirtualDom = (buttonDefs, settingsButtonEna
2748
2802
  return dom;
2749
2803
  };
2750
2804
 
2805
+ const getExtensionDetailIconVirtualDom = iconSrc => {
2806
+ return {
2807
+ type: VirtualDomElements.Img,
2808
+ className: ExtensionDetailIcon,
2809
+ alt: '',
2810
+ draggable: false,
2811
+ childCount: 0,
2812
+ src: iconSrc
2813
+ };
2814
+ };
2815
+
2751
2816
  const getNameBadgeVirtualDom = badge => {
2752
2817
  if (!badge) {
2753
2818
  return [];
@@ -2772,14 +2837,7 @@ const getExtensionDetailHeaderVirtualDom = (name, iconSrc, description, badge, b
2772
2837
  type: VirtualDomElements.Div,
2773
2838
  className: ExtensionDetailHeader,
2774
2839
  childCount: 2
2775
- }, {
2776
- type: VirtualDomElements.Img,
2777
- className: ExtensionDetailIcon,
2778
- alt: '',
2779
- draggable: false,
2780
- childCount: 0,
2781
- src: iconSrc
2782
- }, {
2840
+ }, getExtensionDetailIconVirtualDom(iconSrc), {
2783
2841
  type: VirtualDomElements.Div,
2784
2842
  className: ExtensionDetailHeaderDetails,
2785
2843
  childCount: 3
@@ -2849,31 +2907,34 @@ const getClassNames = size => {
2849
2907
  }
2850
2908
  };
2851
2909
 
2852
- const getExtensionDetailVirtualDom = async (newState, sanitizedReadmeHtml, selectedTab) => {
2910
+ const getExtensionDetailVirtualDom = (newState, selectedTab) => {
2853
2911
  // TODO move this to view model so that rendering occurs like
2854
2912
  // 1. state
2855
2913
  // 2. view model
2856
2914
  // 3. virtual dom
2857
2915
  // 4. dom
2858
- const themesHtml = newState?.selectedFeatureMarkdownDom || '';
2916
+ const themesHtml = newState.themesMarkdownDom;
2859
2917
  const selectedFeature = newState?.selectedFeature || '';
2860
2918
  const extension = newState?.extension || {};
2861
2919
  const features = getFeatures(selectedFeature, extension);
2862
- const size = newState.folderSize || 0;
2863
2920
  const extensionId = newState?.extension?.id || 'n/a';
2864
2921
  const extensionVersion = newState?.extension?.version || 'n/a';
2865
- const displaySize = getDisplaySize(size);
2922
+ const {
2923
+ displaySize
2924
+ } = newState;
2866
2925
  const width = newState?.width || 500;
2867
2926
  const tabs = getTabs(selectedTab);
2868
- const sizeValue = getViewletSize(newState?.width || 0);
2927
+ const {
2928
+ sizeValue
2929
+ } = newState;
2869
2930
  const sizeClass = getClassNames(sizeValue);
2870
- const buttonDefs = getExtensionDetailButtons(extension);
2931
+ const buttonDefs = getExtensionDetailButtons(newState.hasColorTheme, newState.isBuiltin);
2871
2932
  const {
2872
2933
  name,
2873
2934
  iconSrc,
2874
2935
  description
2875
2936
  } = newState;
2876
- const badge = getBadge(extension, newState);
2937
+ const badge = getBadge(newState.isBuiltin, newState.builtinExtensionsBadgeEnabled); // TODO compute in loadContent
2877
2938
  const {
2878
2939
  settingsButtonEnabled
2879
2940
  } = newState;
@@ -2881,16 +2942,16 @@ const getExtensionDetailVirtualDom = async (newState, sanitizedReadmeHtml, selec
2881
2942
  type: VirtualDomElements.Div,
2882
2943
  className: mergeClassNames(Viewlet, ExtensionDetail, sizeClass),
2883
2944
  childCount: 3
2884
- }, ...getExtensionDetailHeaderVirtualDom(name, iconSrc, description, badge, buttonDefs, settingsButtonEnabled), ...getTabsVirtualDom(tabs), ...(await getExtensionDetailContentVirtualDom(sanitizedReadmeHtml, themesHtml, selectedTab, features, displaySize, extensionId, extensionVersion, selectedFeature, extension, width, newState.scrollToTopButtonEnabled, newState.categories, newState.resources))];
2945
+ }, ...getExtensionDetailHeaderVirtualDom(name, iconSrc, description, badge, buttonDefs, settingsButtonEnabled), ...getTabsVirtualDom(tabs), ...getExtensionDetailContentVirtualDom(newState.detailsVirtualDom, themesHtml, selectedTab, features, displaySize, extensionId, extensionVersion, selectedFeature, extension, width, newState.scrollToTopButtonEnabled, newState.categories, newState.resources, newState.showAdditionalDetailsBreakpoint)];
2885
2946
  return dom;
2886
2947
  };
2887
2948
 
2888
- const renderDom = async (oldState, newState) => {
2889
- const dom = await getExtensionDetailVirtualDom(newState, newState.sanitizedReadmeHtml, newState.selectedTab);
2949
+ const renderDom = (oldState, newState) => {
2950
+ const dom = getExtensionDetailVirtualDom(newState, newState.selectedTab);
2890
2951
  return ['Viewlet.setDom2', dom];
2891
2952
  };
2892
2953
 
2893
- const renderFocus = async (oldState, newState) => {
2954
+ const renderFocus = (oldState, newState) => {
2894
2955
  return ['Viewlet.focusElementByName', ''];
2895
2956
  };
2896
2957
 
@@ -2905,22 +2966,22 @@ const getRenderer = diffType => {
2905
2966
  }
2906
2967
  };
2907
2968
 
2908
- const applyRender = async (oldState, newState, diffResult) => {
2969
+ const applyRender = (oldState, newState, diffResult) => {
2909
2970
  const commands = [];
2910
2971
  for (const item of diffResult) {
2911
2972
  const fn = getRenderer(item);
2912
- commands.push(await fn(oldState, newState));
2973
+ commands.push(fn(oldState, newState));
2913
2974
  }
2914
2975
  return commands;
2915
2976
  };
2916
2977
 
2917
- const render2 = async (uid, diffResult) => {
2978
+ const render2 = (uid, diffResult) => {
2918
2979
  const {
2919
2980
  oldState,
2920
2981
  newState
2921
2982
  } = get$1(uid);
2922
2983
  set$1(uid, oldState, newState);
2923
- const commands = await applyRender(oldState, newState, diffResult);
2984
+ const commands = applyRender(oldState, newState, diffResult);
2924
2985
  return commands;
2925
2986
  };
2926
2987
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "3.31.0",
3
+ "version": "3.33.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "license": "MIT",
6
6
  "author": "Lvce Editor",