@lvce-editor/extension-detail-view 3.8.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.
|
@@ -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'];
|
|
@@ -1730,6 +1734,64 @@ const getDetailsVirtualDom = (sanitizedReadmeHtml, displaySize, extensionId, ext
|
|
|
1730
1734
|
return dom;
|
|
1731
1735
|
};
|
|
1732
1736
|
|
|
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
|
+
|
|
1733
1795
|
const Text = 1;
|
|
1734
1796
|
const Code = 2;
|
|
1735
1797
|
|
|
@@ -1759,6 +1821,7 @@ const getCommandTableEntries = extension => {
|
|
|
1759
1821
|
const getCellCodeVirtualDom = value => {
|
|
1760
1822
|
return [{
|
|
1761
1823
|
type: Td,
|
|
1824
|
+
className: 'TableCell',
|
|
1762
1825
|
childCount: 1
|
|
1763
1826
|
}, {
|
|
1764
1827
|
type: Div$1,
|
|
@@ -1770,26 +1833,35 @@ const getCellCodeVirtualDom = value => {
|
|
|
1770
1833
|
const getCellTextVirtualDom = value => {
|
|
1771
1834
|
return [{
|
|
1772
1835
|
type: Td,
|
|
1836
|
+
className: 'TableCell',
|
|
1773
1837
|
childCount: 1
|
|
1774
1838
|
}, text(value)];
|
|
1775
1839
|
};
|
|
1776
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
|
+
|
|
1777
1852
|
const getCellVirtualDom = entry => {
|
|
1778
1853
|
const {
|
|
1779
1854
|
value,
|
|
1780
1855
|
type
|
|
1781
1856
|
} = entry;
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
return getCellCodeVirtualDom(value);
|
|
1785
|
-
default:
|
|
1786
|
-
return getCellTextVirtualDom(value);
|
|
1787
|
-
}
|
|
1857
|
+
const fn = getCellRenderer(type);
|
|
1858
|
+
return fn(value);
|
|
1788
1859
|
};
|
|
1789
1860
|
|
|
1790
1861
|
const getTableHeadingVirtualDom = heading => {
|
|
1791
1862
|
return [{
|
|
1792
1863
|
type: Th,
|
|
1864
|
+
className: 'TableHeading',
|
|
1793
1865
|
childCount: 1
|
|
1794
1866
|
}, text(heading)];
|
|
1795
1867
|
};
|
|
@@ -1807,7 +1879,7 @@ const getTableVirtualDom = tableInfo => {
|
|
|
1807
1879
|
} = tableInfo;
|
|
1808
1880
|
return [{
|
|
1809
1881
|
type: Table,
|
|
1810
|
-
className:
|
|
1882
|
+
className: Table$1,
|
|
1811
1883
|
childCount: 2
|
|
1812
1884
|
}, {
|
|
1813
1885
|
type: THead,
|
|
@@ -1822,12 +1894,11 @@ const getTableVirtualDom = tableInfo => {
|
|
|
1822
1894
|
};
|
|
1823
1895
|
|
|
1824
1896
|
const getFeatureCommandsVirtualDom = extension => {
|
|
1825
|
-
|
|
1826
|
-
const heading = 'Commands';
|
|
1897
|
+
const heading = commands();
|
|
1827
1898
|
const tableInfo = getCommandTableEntries(extension);
|
|
1828
1899
|
return [{
|
|
1829
1900
|
type: Div$1,
|
|
1830
|
-
className:
|
|
1901
|
+
className: FeatureCommands,
|
|
1831
1902
|
childCount: 2
|
|
1832
1903
|
}, {
|
|
1833
1904
|
type: H1$1,
|
|
@@ -1835,44 +1906,6 @@ const getFeatureCommandsVirtualDom = extension => {
|
|
|
1835
1906
|
}, text(heading), ...getTableVirtualDom(tableInfo)];
|
|
1836
1907
|
};
|
|
1837
1908
|
|
|
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);
|
|
1874
|
-
};
|
|
1875
|
-
|
|
1876
1909
|
const getJsonValidationTableEntry = validation => {
|
|
1877
1910
|
const {
|
|
1878
1911
|
fileMatch,
|
|
@@ -1886,6 +1919,7 @@ const getJsonValidationTableEntry = validation => {
|
|
|
1886
1919
|
value: schema
|
|
1887
1920
|
}];
|
|
1888
1921
|
};
|
|
1922
|
+
|
|
1889
1923
|
const getJsonValidationTableEntries = extension => {
|
|
1890
1924
|
const validations = extension.jsonValidation || [];
|
|
1891
1925
|
const rows = validations.map(getJsonValidationTableEntry);
|
|
@@ -1896,12 +1930,11 @@ const getJsonValidationTableEntries = extension => {
|
|
|
1896
1930
|
};
|
|
1897
1931
|
|
|
1898
1932
|
const getFeatureJsonValidationVirtualDom = extension => {
|
|
1899
|
-
|
|
1900
|
-
const heading = 'Json Validation';
|
|
1933
|
+
const heading = jsonValidation();
|
|
1901
1934
|
const tableInfo = getJsonValidationTableEntries(extension);
|
|
1902
1935
|
return [{
|
|
1903
1936
|
type: Div$1,
|
|
1904
|
-
className:
|
|
1937
|
+
className: FeatureJsonValidation,
|
|
1905
1938
|
childCount: 2
|
|
1906
1939
|
}, {
|
|
1907
1940
|
type: H1$1,
|
|
@@ -1910,12 +1943,11 @@ const getFeatureJsonValidationVirtualDom = extension => {
|
|
|
1910
1943
|
};
|
|
1911
1944
|
|
|
1912
1945
|
const getFeatureProgrammingLanguagesVirtualDom = () => {
|
|
1913
|
-
|
|
1914
|
-
const heading = 'Programming Languages';
|
|
1946
|
+
const heading = programmingLanguages();
|
|
1915
1947
|
// TODO
|
|
1916
1948
|
return [{
|
|
1917
1949
|
type: Div$1,
|
|
1918
|
-
className:
|
|
1950
|
+
className: FeatureProgrammingLanguages,
|
|
1919
1951
|
childCount: 1
|
|
1920
1952
|
}, {
|
|
1921
1953
|
type: H1$1,
|
|
@@ -1947,7 +1979,7 @@ const getSettingsTableEntries = extension => {
|
|
|
1947
1979
|
};
|
|
1948
1980
|
|
|
1949
1981
|
const getFeatureSettingsVirtualDom = extension => {
|
|
1950
|
-
const heading =
|
|
1982
|
+
const heading = settings();
|
|
1951
1983
|
const tableInfo = getSettingsTableEntries(extension);
|
|
1952
1984
|
return [{
|
|
1953
1985
|
type: Div$1,
|
|
@@ -1962,7 +1994,7 @@ const getFeatureSettingsVirtualDom = extension => {
|
|
|
1962
1994
|
const getFeatureThemesVirtualDom = themesHtml => {
|
|
1963
1995
|
const markdownDom = getMarkdownVirtualDom(themesHtml);
|
|
1964
1996
|
const childCount = getVirtualDomChildCount(markdownDom);
|
|
1965
|
-
const heading =
|
|
1997
|
+
const heading = theme();
|
|
1966
1998
|
return [{
|
|
1967
1999
|
type: Div$1,
|
|
1968
2000
|
className: 'FeatureTheme',
|
|
@@ -2034,6 +2066,13 @@ const getFeatureListVirtualDom = features => {
|
|
|
2034
2066
|
};
|
|
2035
2067
|
|
|
2036
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
|
+
}
|
|
2037
2076
|
return [{
|
|
2038
2077
|
type: Div$1,
|
|
2039
2078
|
className: Features$1,
|
|
@@ -2091,31 +2130,36 @@ const getExtensionDetailHeaderVirtualDom = extensionDetail => {
|
|
|
2091
2130
|
return dom;
|
|
2092
2131
|
};
|
|
2093
2132
|
|
|
2094
|
-
const
|
|
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
|
|
2156
|
+
}];
|
|
2157
|
+
};
|
|
2158
|
+
const getFeatures = (selectedFeature, extension) => {
|
|
2095
2159
|
if (!selectedFeature) {
|
|
2096
2160
|
selectedFeature = Theme;
|
|
2097
2161
|
}
|
|
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
|
-
}];
|
|
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)];
|
|
2119
2163
|
return features;
|
|
2120
2164
|
};
|
|
2121
2165
|
|
|
@@ -2184,11 +2228,11 @@ const getExtensionDetailVirtualDom = (extensionDetail, sanitizedReadmeHtml, sele
|
|
|
2184
2228
|
// 4. dom
|
|
2185
2229
|
const themesHtml = newState?.selectedFeatureMarkdownDom || '';
|
|
2186
2230
|
const selectedFeature = newState?.selectedFeature || '';
|
|
2187
|
-
const
|
|
2231
|
+
const extension = newState?.extension || {};
|
|
2232
|
+
const features = getFeatures(selectedFeature, extension);
|
|
2188
2233
|
const size = newState.folderSize || 0;
|
|
2189
2234
|
const extensionId = newState?.extension?.id || 'n/a';
|
|
2190
2235
|
const extensionVersion = newState?.extension?.version || 'n/a';
|
|
2191
|
-
const extension = newState?.extension || {};
|
|
2192
2236
|
const displaySize = getDisplaySize(size);
|
|
2193
2237
|
const tabs = getTabs(selectedTab);
|
|
2194
2238
|
const dom = [{
|
|
@@ -5073,7 +5117,7 @@ const loadContent = async (state, platform, savedState) => {
|
|
|
5073
5117
|
const size = getViewletSize(width);
|
|
5074
5118
|
const selectedTab = getSavedSelectedTab(savedState);
|
|
5075
5119
|
const selectedFeature = getSavedSelectedFeature(savedState);
|
|
5076
|
-
const features = getFeatures(selectedFeature);
|
|
5120
|
+
const features = getFeatures(selectedFeature, extension);
|
|
5077
5121
|
const folderSize = await getFolderSize(extension.uri);
|
|
5078
5122
|
const entries = [{
|
|
5079
5123
|
key: 'Identifier',
|