@lvce-editor/extension-detail-view 3.7.0 → 3.9.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.
- package/dist/extensionDetailViewWorkerMain.js +417 -115
- package/package.json +1 -1
|
@@ -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);
|
|
@@ -897,7 +897,10 @@ const Aside$2 = 'Aside';
|
|
|
897
897
|
const Categories = 'Categories';
|
|
898
898
|
const Category = 'Category';
|
|
899
899
|
const Changelog$1 = 'Changelog';
|
|
900
|
+
const FeatureProgrammingLanguages = 'FeatureProgrammingLanguages';
|
|
901
|
+
const FeatureJsonValidation = 'FeatureJsonValidation';
|
|
900
902
|
const ExtensionDetail = 'ExtensionDetail';
|
|
903
|
+
const FeatureCommands = 'FeatureCommands';
|
|
901
904
|
const ExtensionDetailDescription = 'ExtensionDetailDescription';
|
|
902
905
|
const ExtensionDetailHeader = 'ExtensionDetailHeader';
|
|
903
906
|
const ExtensionDetailHeaderDetails = 'ExtensionDetailHeaderDetails';
|
|
@@ -917,6 +920,7 @@ const MoreInfoEntryKey = 'MoreInfoEntryKey';
|
|
|
917
920
|
const MoreInfoEntryValue = 'MoreInfoEntryValue';
|
|
918
921
|
const Resource = 'Resource';
|
|
919
922
|
const Resources = 'Resources';
|
|
923
|
+
const Table$1 = 'Table';
|
|
920
924
|
const Viewlet = 'Viewlet';
|
|
921
925
|
|
|
922
926
|
const BYTE_UNITS = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
@@ -991,43 +995,49 @@ const getDisplaySize = size => {
|
|
|
991
995
|
});
|
|
992
996
|
};
|
|
993
997
|
|
|
998
|
+
const A$1 = 53;
|
|
999
|
+
const Abbr$1 = 54;
|
|
1000
|
+
const Article$1 = 27;
|
|
1001
|
+
const Aside$1 = 28;
|
|
1002
|
+
const Br$1 = 55;
|
|
994
1003
|
const Button = 1;
|
|
1004
|
+
const Cite$1 = 56;
|
|
1005
|
+
const Data$1 = 57;
|
|
1006
|
+
const Dd$1 = 43;
|
|
995
1007
|
const Div$1 = 4;
|
|
1008
|
+
const Dl$1 = 44;
|
|
1009
|
+
const Figcaption$1 = 45;
|
|
1010
|
+
const Figure$1 = 46;
|
|
1011
|
+
const Footer$1 = 29;
|
|
996
1012
|
const H1$1 = 5;
|
|
997
|
-
const Span$1 = 8;
|
|
998
|
-
const Text$1 = 12;
|
|
999
|
-
const Img$1 = 17;
|
|
1000
1013
|
const H2$1 = 22;
|
|
1001
1014
|
const H3$1 = 23;
|
|
1002
1015
|
const H4$1 = 24;
|
|
1003
1016
|
const H5$1 = 25;
|
|
1004
|
-
const Article$1 = 27;
|
|
1005
|
-
const Aside$1 = 28;
|
|
1006
|
-
const Footer$1 = 29;
|
|
1007
1017
|
const Header$1 = 30;
|
|
1008
|
-
const Nav$1 = 40;
|
|
1009
|
-
const Section$1 = 41;
|
|
1010
|
-
const Search$1 = 42;
|
|
1011
|
-
const Dd$1 = 43;
|
|
1012
|
-
const Dl$1 = 44;
|
|
1013
|
-
const Figcaption$1 = 45;
|
|
1014
|
-
const Figure$1 = 46;
|
|
1015
1018
|
const Hr$1 = 47;
|
|
1019
|
+
const Img$1 = 17;
|
|
1016
1020
|
const Li$1 = 48;
|
|
1021
|
+
const Nav$1 = 40;
|
|
1017
1022
|
const Ol$1 = 49;
|
|
1018
1023
|
const P$1 = 50;
|
|
1019
1024
|
const Pre$1 = 51;
|
|
1020
|
-
const
|
|
1021
|
-
const
|
|
1022
|
-
const
|
|
1023
|
-
const
|
|
1024
|
-
const
|
|
1025
|
-
const
|
|
1025
|
+
const Search$1 = 42;
|
|
1026
|
+
const Section$1 = 41;
|
|
1027
|
+
const Span$1 = 8;
|
|
1028
|
+
const Table = 9;
|
|
1029
|
+
const TBody = 10;
|
|
1030
|
+
const Td = 11;
|
|
1031
|
+
const Text$2 = 12;
|
|
1026
1032
|
const Tfoot$1 = 59;
|
|
1033
|
+
const Th = 13;
|
|
1034
|
+
const THead = 14;
|
|
1035
|
+
const Time$1 = 58;
|
|
1036
|
+
const Tr = 15;
|
|
1027
1037
|
|
|
1028
1038
|
const text = data => {
|
|
1029
1039
|
return {
|
|
1030
|
-
type: Text$
|
|
1040
|
+
type: Text$2,
|
|
1031
1041
|
text: data,
|
|
1032
1042
|
childCount: 0
|
|
1033
1043
|
};
|
|
@@ -1329,7 +1339,7 @@ const Doctype = 16;
|
|
|
1329
1339
|
const StartCommentDashes = 17;
|
|
1330
1340
|
const Comment = 18;
|
|
1331
1341
|
const EndCommentTag = 19;
|
|
1332
|
-
const Text = 20;
|
|
1342
|
+
const Text$1 = 20;
|
|
1333
1343
|
const CommentStart = 21;
|
|
1334
1344
|
|
|
1335
1345
|
const isSelfClosingTag = tag => {
|
|
@@ -1412,7 +1422,7 @@ const tokenizeHtml = text => {
|
|
|
1412
1422
|
token = Content;
|
|
1413
1423
|
state = State.TopLevelContent;
|
|
1414
1424
|
} else if (next = part.match(RE_ANGLE_BRACKET_OPEN)) {
|
|
1415
|
-
token = Text;
|
|
1425
|
+
token = Text$1;
|
|
1416
1426
|
state = State.TopLevelContent;
|
|
1417
1427
|
} else {
|
|
1418
1428
|
throw new UnexpectedTokenError();
|
|
@@ -1435,7 +1445,7 @@ const tokenizeHtml = text => {
|
|
|
1435
1445
|
token = ExclamationMark;
|
|
1436
1446
|
state = State.AfterExclamationMark;
|
|
1437
1447
|
} else if (next = part.match(RE_ANY_TEXT)) {
|
|
1438
|
-
token = Text;
|
|
1448
|
+
token = Text$1;
|
|
1439
1449
|
state = State.TopLevelContent;
|
|
1440
1450
|
} else {
|
|
1441
1451
|
text.slice(index); // ?
|
|
@@ -1474,7 +1484,7 @@ const tokenizeHtml = text => {
|
|
|
1474
1484
|
token = WhitespaceInsideOpeningTag;
|
|
1475
1485
|
state = State.InsideOpeningTagAfterWhitespace;
|
|
1476
1486
|
} else if (next = part.match(RE_TAG_TEXT)) {
|
|
1477
|
-
token = Text;
|
|
1487
|
+
token = Text$1;
|
|
1478
1488
|
state = State.TopLevelContent;
|
|
1479
1489
|
} else {
|
|
1480
1490
|
throw new UnexpectedTokenError();
|
|
@@ -1724,36 +1734,267 @@ const getDetailsVirtualDom = (sanitizedReadmeHtml, displaySize, extensionId, ext
|
|
|
1724
1734
|
return dom;
|
|
1725
1735
|
};
|
|
1726
1736
|
|
|
1727
|
-
const
|
|
1737
|
+
const emptyObject = {};
|
|
1738
|
+
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1739
|
+
const i18nString = (key, placeholders = emptyObject) => {
|
|
1740
|
+
if (placeholders === emptyObject) {
|
|
1741
|
+
return key;
|
|
1742
|
+
}
|
|
1743
|
+
const replacer = (match, rest) => {
|
|
1744
|
+
return placeholders[rest];
|
|
1745
|
+
};
|
|
1746
|
+
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1747
|
+
};
|
|
1748
|
+
|
|
1749
|
+
const Copy = 'Copy';
|
|
1750
|
+
const OpenInNewTab = 'Open in New Tab';
|
|
1751
|
+
const OpenImageInNewTab = 'Open Image in New Tab';
|
|
1752
|
+
const SaveImageAs = 'Save Image as';
|
|
1753
|
+
const FileMatch = 'File Match';
|
|
1754
|
+
const Schema = 'Schema';
|
|
1755
|
+
const Theme$1 = 'Theme';
|
|
1756
|
+
const Commands$1 = 'Commands';
|
|
1757
|
+
const JsonValidation$1 = 'Json Validation';
|
|
1758
|
+
const ProgrammingLanguages$1 = 'Programming Languages';
|
|
1759
|
+
const Settings$1 = 'Settings';
|
|
1760
|
+
|
|
1761
|
+
const copy = () => {
|
|
1762
|
+
return i18nString(Copy);
|
|
1763
|
+
};
|
|
1764
|
+
const openInNewTab = () => {
|
|
1765
|
+
return i18nString(OpenInNewTab);
|
|
1766
|
+
};
|
|
1767
|
+
const openImageInNewTab = () => {
|
|
1768
|
+
return i18nString(OpenImageInNewTab);
|
|
1769
|
+
};
|
|
1770
|
+
const saveImageAs = () => {
|
|
1771
|
+
return i18nString(SaveImageAs);
|
|
1772
|
+
};
|
|
1773
|
+
const fileMatch = () => {
|
|
1774
|
+
return i18nString(FileMatch);
|
|
1775
|
+
};
|
|
1776
|
+
const schema = () => {
|
|
1777
|
+
return i18nString(Schema);
|
|
1778
|
+
};
|
|
1779
|
+
const theme = () => {
|
|
1780
|
+
return i18nString(Theme$1);
|
|
1781
|
+
};
|
|
1782
|
+
const commands = () => {
|
|
1783
|
+
return i18nString(Commands$1);
|
|
1784
|
+
};
|
|
1785
|
+
const jsonValidation = () => {
|
|
1786
|
+
return i18nString(JsonValidation$1);
|
|
1787
|
+
};
|
|
1788
|
+
const programmingLanguages = () => {
|
|
1789
|
+
return i18nString(ProgrammingLanguages$1);
|
|
1790
|
+
};
|
|
1791
|
+
const settings = () => {
|
|
1792
|
+
return i18nString(Settings$1);
|
|
1793
|
+
};
|
|
1794
|
+
|
|
1795
|
+
const Text = 1;
|
|
1796
|
+
const Code = 2;
|
|
1797
|
+
|
|
1798
|
+
const getCommandTableEntry = command => {
|
|
1799
|
+
// TODO watch out for command being null/undefined/number/string/array
|
|
1728
1800
|
const {
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
} = feature;
|
|
1733
|
-
const className = selected ? 'Feature FeatureSelected' : Feature;
|
|
1801
|
+
id,
|
|
1802
|
+
label
|
|
1803
|
+
} = command;
|
|
1734
1804
|
return [{
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1805
|
+
type: Code,
|
|
1806
|
+
value: id
|
|
1807
|
+
}, {
|
|
1808
|
+
type: Text,
|
|
1809
|
+
value: label
|
|
1810
|
+
}];
|
|
1811
|
+
};
|
|
1812
|
+
const getCommandTableEntries = extension => {
|
|
1813
|
+
const commands = extension.commands || [];
|
|
1814
|
+
const rows = commands.map(getCommandTableEntry);
|
|
1815
|
+
return {
|
|
1816
|
+
headings: ['ID', 'Label'],
|
|
1817
|
+
rows
|
|
1818
|
+
};
|
|
1819
|
+
};
|
|
1820
|
+
|
|
1821
|
+
const getCellCodeVirtualDom = value => {
|
|
1822
|
+
return [{
|
|
1823
|
+
type: Td,
|
|
1824
|
+
className: 'TableCell',
|
|
1739
1825
|
childCount: 1
|
|
1740
|
-
},
|
|
1826
|
+
}, {
|
|
1827
|
+
type: Div$1,
|
|
1828
|
+
// TODO use code tag
|
|
1829
|
+
childCount: 1
|
|
1830
|
+
}, text(value)];
|
|
1741
1831
|
};
|
|
1742
1832
|
|
|
1743
|
-
const
|
|
1833
|
+
const getCellTextVirtualDom = value => {
|
|
1834
|
+
return [{
|
|
1835
|
+
type: Td,
|
|
1836
|
+
className: 'TableCell',
|
|
1837
|
+
childCount: 1
|
|
1838
|
+
}, text(value)];
|
|
1839
|
+
};
|
|
1840
|
+
|
|
1841
|
+
const getCellRenderer = type => {
|
|
1842
|
+
switch (type) {
|
|
1843
|
+
case Code:
|
|
1844
|
+
return getCellCodeVirtualDom;
|
|
1845
|
+
case Text:
|
|
1846
|
+
return getCellTextVirtualDom;
|
|
1847
|
+
default:
|
|
1848
|
+
throw new Error(`unexpected cell type ${type}`);
|
|
1849
|
+
}
|
|
1850
|
+
};
|
|
1851
|
+
|
|
1852
|
+
const getCellVirtualDom = entry => {
|
|
1853
|
+
const {
|
|
1854
|
+
value,
|
|
1855
|
+
type
|
|
1856
|
+
} = entry;
|
|
1857
|
+
const fn = getCellRenderer(type);
|
|
1858
|
+
return fn(value);
|
|
1859
|
+
};
|
|
1860
|
+
|
|
1861
|
+
const getTableHeadingVirtualDom = heading => {
|
|
1862
|
+
return [{
|
|
1863
|
+
type: Th,
|
|
1864
|
+
className: 'TableHeading',
|
|
1865
|
+
childCount: 1
|
|
1866
|
+
}, text(heading)];
|
|
1867
|
+
};
|
|
1868
|
+
|
|
1869
|
+
const getTableRowVirtualDom = entries => {
|
|
1870
|
+
return [{
|
|
1871
|
+
type: Tr,
|
|
1872
|
+
childCount: entries.length
|
|
1873
|
+
}, ...entries.flatMap(getCellVirtualDom)];
|
|
1874
|
+
};
|
|
1875
|
+
const getTableVirtualDom = tableInfo => {
|
|
1876
|
+
const {
|
|
1877
|
+
headings,
|
|
1878
|
+
rows
|
|
1879
|
+
} = tableInfo;
|
|
1880
|
+
return [{
|
|
1881
|
+
type: Table,
|
|
1882
|
+
className: Table$1,
|
|
1883
|
+
childCount: 2
|
|
1884
|
+
}, {
|
|
1885
|
+
type: THead,
|
|
1886
|
+
childCount: 1
|
|
1887
|
+
}, {
|
|
1888
|
+
type: Tr,
|
|
1889
|
+
childCount: headings.length
|
|
1890
|
+
}, ...headings.flatMap(getTableHeadingVirtualDom), {
|
|
1891
|
+
type: TBody,
|
|
1892
|
+
childCount: rows.length
|
|
1893
|
+
}, ...rows.flatMap(getTableRowVirtualDom)];
|
|
1894
|
+
};
|
|
1895
|
+
|
|
1896
|
+
const getFeatureCommandsVirtualDom = extension => {
|
|
1897
|
+
const heading = commands();
|
|
1898
|
+
const tableInfo = getCommandTableEntries(extension);
|
|
1744
1899
|
return [{
|
|
1745
|
-
// TODO use either list or tabs role
|
|
1746
1900
|
type: Div$1,
|
|
1747
|
-
className:
|
|
1748
|
-
childCount:
|
|
1749
|
-
|
|
1750
|
-
|
|
1901
|
+
className: FeatureCommands,
|
|
1902
|
+
childCount: 2
|
|
1903
|
+
}, {
|
|
1904
|
+
type: H1$1,
|
|
1905
|
+
childCount: 1
|
|
1906
|
+
}, text(heading), ...getTableVirtualDom(tableInfo)];
|
|
1907
|
+
};
|
|
1908
|
+
|
|
1909
|
+
const getJsonValidationTableEntry = validation => {
|
|
1910
|
+
const {
|
|
1911
|
+
fileMatch,
|
|
1912
|
+
schema
|
|
1913
|
+
} = validation;
|
|
1914
|
+
return [{
|
|
1915
|
+
type: Code,
|
|
1916
|
+
value: fileMatch
|
|
1917
|
+
}, {
|
|
1918
|
+
type: Code,
|
|
1919
|
+
value: schema
|
|
1920
|
+
}];
|
|
1921
|
+
};
|
|
1922
|
+
|
|
1923
|
+
const getJsonValidationTableEntries = extension => {
|
|
1924
|
+
const validations = extension.jsonValidation || [];
|
|
1925
|
+
const rows = validations.map(getJsonValidationTableEntry);
|
|
1926
|
+
return {
|
|
1927
|
+
headings: [fileMatch(), schema()],
|
|
1928
|
+
rows
|
|
1929
|
+
};
|
|
1930
|
+
};
|
|
1931
|
+
|
|
1932
|
+
const getFeatureJsonValidationVirtualDom = extension => {
|
|
1933
|
+
const heading = jsonValidation();
|
|
1934
|
+
const tableInfo = getJsonValidationTableEntries(extension);
|
|
1935
|
+
return [{
|
|
1936
|
+
type: Div$1,
|
|
1937
|
+
className: FeatureJsonValidation,
|
|
1938
|
+
childCount: 2
|
|
1939
|
+
}, {
|
|
1940
|
+
type: H1$1,
|
|
1941
|
+
childCount: 1
|
|
1942
|
+
}, text(heading), ...getTableVirtualDom(tableInfo)];
|
|
1943
|
+
};
|
|
1944
|
+
|
|
1945
|
+
const getFeatureProgrammingLanguagesVirtualDom = () => {
|
|
1946
|
+
const heading = programmingLanguages();
|
|
1947
|
+
// TODO
|
|
1948
|
+
return [{
|
|
1949
|
+
type: Div$1,
|
|
1950
|
+
className: FeatureProgrammingLanguages,
|
|
1951
|
+
childCount: 1
|
|
1952
|
+
}, {
|
|
1953
|
+
type: H1$1,
|
|
1954
|
+
childCount: 1
|
|
1955
|
+
}, text(heading)];
|
|
1956
|
+
};
|
|
1957
|
+
|
|
1958
|
+
const getSettingsTableEntry = setting => {
|
|
1959
|
+
const {
|
|
1960
|
+
id,
|
|
1961
|
+
label
|
|
1962
|
+
} = setting;
|
|
1963
|
+
// TODO watch out for null/undefined/number/string/array
|
|
1964
|
+
return [{
|
|
1965
|
+
type: Text,
|
|
1966
|
+
value: id
|
|
1967
|
+
}, {
|
|
1968
|
+
type: Text,
|
|
1969
|
+
value: label
|
|
1970
|
+
}];
|
|
1971
|
+
};
|
|
1972
|
+
const getSettingsTableEntries = extension => {
|
|
1973
|
+
const settings = extension.settings || [];
|
|
1974
|
+
const rows = settings.map(getSettingsTableEntry);
|
|
1975
|
+
return {
|
|
1976
|
+
headings: ['ID', 'Label'],
|
|
1977
|
+
rows
|
|
1978
|
+
};
|
|
1979
|
+
};
|
|
1980
|
+
|
|
1981
|
+
const getFeatureSettingsVirtualDom = extension => {
|
|
1982
|
+
const heading = settings();
|
|
1983
|
+
const tableInfo = getSettingsTableEntries(extension);
|
|
1984
|
+
return [{
|
|
1985
|
+
type: Div$1,
|
|
1986
|
+
className: 'FeatureSettings',
|
|
1987
|
+
childCount: 2
|
|
1988
|
+
}, {
|
|
1989
|
+
type: H1$1,
|
|
1990
|
+
childCount: 1
|
|
1991
|
+
}, text(heading), ...getTableVirtualDom(tableInfo)];
|
|
1751
1992
|
};
|
|
1752
1993
|
|
|
1753
1994
|
const getFeatureThemesVirtualDom = themesHtml => {
|
|
1754
1995
|
const markdownDom = getMarkdownVirtualDom(themesHtml);
|
|
1755
1996
|
const childCount = getVirtualDomChildCount(markdownDom);
|
|
1756
|
-
const heading =
|
|
1997
|
+
const heading = theme();
|
|
1757
1998
|
return [{
|
|
1758
1999
|
type: Div$1,
|
|
1759
2000
|
className: 'FeatureTheme',
|
|
@@ -1768,7 +2009,70 @@ const getFeatureThemesVirtualDom = themesHtml => {
|
|
|
1768
2009
|
}, ...markdownDom];
|
|
1769
2010
|
};
|
|
1770
2011
|
|
|
1771
|
-
const
|
|
2012
|
+
const Changelog = 'Changelog';
|
|
2013
|
+
const Commands = 'Commands';
|
|
2014
|
+
const Details = 'Details';
|
|
2015
|
+
const Features = 'Features';
|
|
2016
|
+
const JsonValidation = 'JsonValidation';
|
|
2017
|
+
const ProgrammingLanguages = 'ProgrammingLanguages';
|
|
2018
|
+
const Settings = 'Settings';
|
|
2019
|
+
const Theme = 'Theme';
|
|
2020
|
+
|
|
2021
|
+
const getFeatureContentVirtualDom = (features, themesHtml, selectedFeature, extension) => {
|
|
2022
|
+
switch (selectedFeature) {
|
|
2023
|
+
case Theme:
|
|
2024
|
+
return getFeatureThemesVirtualDom(themesHtml);
|
|
2025
|
+
case Commands:
|
|
2026
|
+
return getFeatureCommandsVirtualDom(extension);
|
|
2027
|
+
case JsonValidation:
|
|
2028
|
+
return getFeatureJsonValidationVirtualDom(extension);
|
|
2029
|
+
case ProgrammingLanguages:
|
|
2030
|
+
return getFeatureProgrammingLanguagesVirtualDom();
|
|
2031
|
+
case Settings:
|
|
2032
|
+
return getFeatureSettingsVirtualDom(extension);
|
|
2033
|
+
default:
|
|
2034
|
+
return [{
|
|
2035
|
+
type: Div$1,
|
|
2036
|
+
className: 'FeatureContent',
|
|
2037
|
+
childCount: 1
|
|
2038
|
+
}, text('Not Implemented')];
|
|
2039
|
+
}
|
|
2040
|
+
};
|
|
2041
|
+
|
|
2042
|
+
const getFeatureListItemVirtualDom = feature => {
|
|
2043
|
+
const {
|
|
2044
|
+
label,
|
|
2045
|
+
selected,
|
|
2046
|
+
id
|
|
2047
|
+
} = feature;
|
|
2048
|
+
const className = selected ? 'Feature FeatureSelected' : Feature;
|
|
2049
|
+
return [{
|
|
2050
|
+
// TODO use role list item or tab
|
|
2051
|
+
type: Button,
|
|
2052
|
+
name: id,
|
|
2053
|
+
className,
|
|
2054
|
+
childCount: 1
|
|
2055
|
+
}, text(label)];
|
|
2056
|
+
};
|
|
2057
|
+
|
|
2058
|
+
const getFeatureListVirtualDom = features => {
|
|
2059
|
+
return [{
|
|
2060
|
+
// TODO use either list or tabs role
|
|
2061
|
+
type: Div$1,
|
|
2062
|
+
className: FeaturesList,
|
|
2063
|
+
childCount: features.length,
|
|
2064
|
+
onClick: HandleFeaturesClick
|
|
2065
|
+
}, ...features.flatMap(getFeatureListItemVirtualDom)];
|
|
2066
|
+
};
|
|
2067
|
+
|
|
2068
|
+
const getFeaturesVirtualDom = (features, themesHtml, selectedFeature, extension) => {
|
|
2069
|
+
if (features.length === 0) {
|
|
2070
|
+
return [{
|
|
2071
|
+
type: Div$1,
|
|
2072
|
+
className: Features$1,
|
|
2073
|
+
childCount: 3
|
|
2074
|
+
}, text('None')];
|
|
2075
|
+
}
|
|
1772
2076
|
return [{
|
|
1773
2077
|
type: Div$1,
|
|
1774
2078
|
className: Features$1,
|
|
@@ -1777,24 +2081,15 @@ const getFeaturesVirtualDom = (features, themesHtml) => {
|
|
|
1777
2081
|
type: Div$1,
|
|
1778
2082
|
className: 'Sash SashVertical',
|
|
1779
2083
|
childCount: 0
|
|
1780
|
-
}, ...
|
|
2084
|
+
}, ...getFeatureContentVirtualDom(features, themesHtml, selectedFeature, extension)];
|
|
1781
2085
|
};
|
|
1782
2086
|
|
|
1783
|
-
const
|
|
1784
|
-
const Commands = 'Commands';
|
|
1785
|
-
const Details = 'Details';
|
|
1786
|
-
const Features = 'Features';
|
|
1787
|
-
const JsonValidation = 'JsonValidation';
|
|
1788
|
-
const ProgrammingLanguages = 'ProgrammingLanguages';
|
|
1789
|
-
const Settings = 'Settings';
|
|
1790
|
-
const Theme = 'Theme';
|
|
1791
|
-
|
|
1792
|
-
const getExtensionDetailContentVirtualDom = (sanitizedReadmeHtml, themesHtml, selectedTab, features, displaySize, extensionId, extensionVersion) => {
|
|
2087
|
+
const getExtensionDetailContentVirtualDom = (sanitizedReadmeHtml, themesHtml, selectedTab, features, displaySize, extensionId, extensionVersion, selectedFeature, extension) => {
|
|
1793
2088
|
switch (selectedTab) {
|
|
1794
2089
|
case Details:
|
|
1795
2090
|
return getDetailsVirtualDom(sanitizedReadmeHtml, displaySize, extensionId, extensionVersion);
|
|
1796
2091
|
case Features:
|
|
1797
|
-
return getFeaturesVirtualDom(features, themesHtml);
|
|
2092
|
+
return getFeaturesVirtualDom(features, themesHtml, selectedFeature, extension);
|
|
1798
2093
|
case Changelog:
|
|
1799
2094
|
return getChangelogVirtualDom();
|
|
1800
2095
|
default:
|
|
@@ -1835,28 +2130,36 @@ const getExtensionDetailHeaderVirtualDom = extensionDetail => {
|
|
|
1835
2130
|
return dom;
|
|
1836
2131
|
};
|
|
1837
2132
|
|
|
1838
|
-
const
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
2133
|
+
const hasThemes = extension => {
|
|
2134
|
+
return extension && (extension.colorThemes || extension.iconThemes || extension.productIconThemes);
|
|
2135
|
+
};
|
|
2136
|
+
const hasCommands = extension => {
|
|
2137
|
+
return extension && extension.commands;
|
|
2138
|
+
};
|
|
2139
|
+
const hasJsonValidation = extension => {
|
|
2140
|
+
return extension && extension.jsonValidation;
|
|
2141
|
+
};
|
|
2142
|
+
const hasProgrammingLanguages = extension => {
|
|
2143
|
+
return extension && extension.programmingLanguages;
|
|
2144
|
+
};
|
|
2145
|
+
const hasSettings = extension => {
|
|
2146
|
+
return extension && extension.settings;
|
|
2147
|
+
};
|
|
2148
|
+
const ifElseFeature = (id, label, isEnabled, selectedFeature, extension) => {
|
|
2149
|
+
if (!isEnabled(extension)) {
|
|
2150
|
+
return [];
|
|
2151
|
+
}
|
|
2152
|
+
return [{
|
|
2153
|
+
id,
|
|
2154
|
+
label,
|
|
2155
|
+
selected: selectedFeature === id
|
|
1859
2156
|
}];
|
|
2157
|
+
};
|
|
2158
|
+
const getFeatures = (selectedFeature, extension) => {
|
|
2159
|
+
if (!selectedFeature) {
|
|
2160
|
+
selectedFeature = Theme;
|
|
2161
|
+
}
|
|
2162
|
+
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)];
|
|
1860
2163
|
return features;
|
|
1861
2164
|
};
|
|
1862
2165
|
|
|
@@ -1918,8 +2221,15 @@ const getTabsVirtualDom = tabs => {
|
|
|
1918
2221
|
};
|
|
1919
2222
|
|
|
1920
2223
|
const getExtensionDetailVirtualDom = (extensionDetail, sanitizedReadmeHtml, selectedTab, newState) => {
|
|
2224
|
+
// TODO move this to view model so that rendering occurs like
|
|
2225
|
+
// 1. state
|
|
2226
|
+
// 2. view model
|
|
2227
|
+
// 3. virtual dom
|
|
2228
|
+
// 4. dom
|
|
1921
2229
|
const themesHtml = newState?.selectedFeatureMarkdownDom || '';
|
|
1922
|
-
const
|
|
2230
|
+
const selectedFeature = newState?.selectedFeature || '';
|
|
2231
|
+
const extension = newState?.extension || {};
|
|
2232
|
+
const features = getFeatures(selectedFeature, extension);
|
|
1923
2233
|
const size = newState.folderSize || 0;
|
|
1924
2234
|
const extensionId = newState?.extension?.id || 'n/a';
|
|
1925
2235
|
const extensionVersion = newState?.extension?.version || 'n/a';
|
|
@@ -1929,40 +2239,10 @@ const getExtensionDetailVirtualDom = (extensionDetail, sanitizedReadmeHtml, sele
|
|
|
1929
2239
|
type: Div$1,
|
|
1930
2240
|
className: mergeClassNames(Viewlet, ExtensionDetail),
|
|
1931
2241
|
childCount: 3
|
|
1932
|
-
}, ...getExtensionDetailHeaderVirtualDom(extensionDetail), ...getTabsVirtualDom(tabs), ...getExtensionDetailContentVirtualDom(sanitizedReadmeHtml, themesHtml, selectedTab, features, displaySize, extensionId, extensionVersion)];
|
|
2242
|
+
}, ...getExtensionDetailHeaderVirtualDom(extensionDetail), ...getTabsVirtualDom(tabs), ...getExtensionDetailContentVirtualDom(sanitizedReadmeHtml, themesHtml, selectedTab, features, displaySize, extensionId, extensionVersion, selectedFeature, extension)];
|
|
1933
2243
|
return dom;
|
|
1934
2244
|
};
|
|
1935
2245
|
|
|
1936
|
-
const emptyObject = {};
|
|
1937
|
-
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1938
|
-
const i18nString = (key, placeholders = emptyObject) => {
|
|
1939
|
-
if (placeholders === emptyObject) {
|
|
1940
|
-
return key;
|
|
1941
|
-
}
|
|
1942
|
-
const replacer = (match, rest) => {
|
|
1943
|
-
return placeholders[rest];
|
|
1944
|
-
};
|
|
1945
|
-
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1946
|
-
};
|
|
1947
|
-
|
|
1948
|
-
const Copy = 'Copy';
|
|
1949
|
-
const OpenInNewTab = 'Open in New Tab';
|
|
1950
|
-
const OpenImageInNewTab = 'Open Image in New Tab';
|
|
1951
|
-
const SaveImageAs = 'Save Image as';
|
|
1952
|
-
|
|
1953
|
-
const copy = () => {
|
|
1954
|
-
return i18nString(Copy);
|
|
1955
|
-
};
|
|
1956
|
-
const openInNewTab = () => {
|
|
1957
|
-
return i18nString(OpenInNewTab);
|
|
1958
|
-
};
|
|
1959
|
-
const openImageInNewTab = () => {
|
|
1960
|
-
return i18nString(OpenImageInNewTab);
|
|
1961
|
-
};
|
|
1962
|
-
const saveImageAs = () => {
|
|
1963
|
-
return i18nString(SaveImageAs);
|
|
1964
|
-
};
|
|
1965
|
-
|
|
1966
2246
|
const None = 0;
|
|
1967
2247
|
|
|
1968
2248
|
const getCopyMenuEntry = () => ({
|
|
@@ -4716,7 +4996,8 @@ const getAllExtensions = async platform => {
|
|
|
4716
4996
|
}
|
|
4717
4997
|
return invoke('ExtensionManagement.getAllExtensions');
|
|
4718
4998
|
};
|
|
4719
|
-
const getExtension = async (id, platform) => {
|
|
4999
|
+
const getExtension$1 = async (id, platform) => {
|
|
5000
|
+
// TODO only ask one extension from renderer worker instead of all
|
|
4720
5001
|
const allExtensions = await getAllExtensions(platform);
|
|
4721
5002
|
for (const extension of allExtensions) {
|
|
4722
5003
|
if (extension.id === id) {
|
|
@@ -4726,6 +5007,17 @@ const getExtension = async (id, platform) => {
|
|
|
4726
5007
|
return undefined;
|
|
4727
5008
|
};
|
|
4728
5009
|
|
|
5010
|
+
const getExtensionNew = async id => {
|
|
5011
|
+
return invoke('ExtensionManagement.getExtension', id);
|
|
5012
|
+
};
|
|
5013
|
+
const getExtension = async (id, platform) => {
|
|
5014
|
+
try {
|
|
5015
|
+
return await getExtensionNew(id);
|
|
5016
|
+
} catch {
|
|
5017
|
+
return getExtension$1(id, platform);
|
|
5018
|
+
}
|
|
5019
|
+
};
|
|
5020
|
+
|
|
4729
5021
|
const getRemoteSrc = uri => {
|
|
4730
5022
|
const src = `/remote${uri}`;
|
|
4731
5023
|
return src;
|
|
@@ -4749,6 +5041,13 @@ const getFolderSize = async uri => {
|
|
|
4749
5041
|
}
|
|
4750
5042
|
};
|
|
4751
5043
|
|
|
5044
|
+
const getSavedSelectedFeature = savedState => {
|
|
5045
|
+
if (savedState && typeof savedState === 'object' && 'selectedFeature' in savedState && typeof savedState.selectedFeature === 'string') {
|
|
5046
|
+
return savedState.selectedFeature;
|
|
5047
|
+
}
|
|
5048
|
+
return Details;
|
|
5049
|
+
};
|
|
5050
|
+
|
|
4752
5051
|
const getSavedSelectedTab = savedState => {
|
|
4753
5052
|
if (savedState && typeof savedState === 'object' && 'selectedTab' in savedState && typeof savedState.selectedTab === 'string') {
|
|
4754
5053
|
return savedState.selectedTab;
|
|
@@ -4817,7 +5116,8 @@ const loadContent = async (state, platform, savedState) => {
|
|
|
4817
5116
|
const name = getName(extension);
|
|
4818
5117
|
const size = getViewletSize(width);
|
|
4819
5118
|
const selectedTab = getSavedSelectedTab(savedState);
|
|
4820
|
-
const
|
|
5119
|
+
const selectedFeature = getSavedSelectedFeature(savedState);
|
|
5120
|
+
const features = getFeatures(selectedFeature, extension);
|
|
4821
5121
|
const folderSize = await getFolderSize(extension.uri);
|
|
4822
5122
|
const entries = [{
|
|
4823
5123
|
key: 'Identifier',
|
|
@@ -4874,10 +5174,12 @@ const loadContent = async (state, platform, savedState) => {
|
|
|
4874
5174
|
|
|
4875
5175
|
const saveState = state => {
|
|
4876
5176
|
const {
|
|
4877
|
-
selectedTab
|
|
5177
|
+
selectedTab,
|
|
5178
|
+
selectedFeature
|
|
4878
5179
|
} = state;
|
|
4879
5180
|
return {
|
|
4880
|
-
selectedTab
|
|
5181
|
+
selectedTab,
|
|
5182
|
+
selectedFeature
|
|
4881
5183
|
};
|
|
4882
5184
|
};
|
|
4883
5185
|
|