@lvce-editor/extension-detail-view 3.4.0 → 3.5.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.
|
@@ -883,7 +883,9 @@ const create = (uid, uri, width, height, platform) => {
|
|
|
883
883
|
resources: [],
|
|
884
884
|
selectedFeatureMarkdownDom: '',
|
|
885
885
|
extension: {},
|
|
886
|
-
baseUrl: ''
|
|
886
|
+
baseUrl: '',
|
|
887
|
+
features: [],
|
|
888
|
+
folderSize: 0
|
|
887
889
|
};
|
|
888
890
|
set$1(uid, state, state);
|
|
889
891
|
};
|
|
@@ -975,6 +977,19 @@ const Panel = 'panel';
|
|
|
975
977
|
|
|
976
978
|
const HandleReadmeContextMenu = 'handleReadmeContextMenu';
|
|
977
979
|
const HandleTabsClick = 'handleTabsClick';
|
|
980
|
+
const HandleFeaturesClick = 'handleFeaturesClick';
|
|
981
|
+
|
|
982
|
+
const getAdditionalDetailsEntryVirtualDom = (heading, items, renderer) => {
|
|
983
|
+
return [{
|
|
984
|
+
type: Div$1,
|
|
985
|
+
className: AdditionalDetailsEntry,
|
|
986
|
+
childCount: 2
|
|
987
|
+
}, {
|
|
988
|
+
type: Div$1,
|
|
989
|
+
className: AdditionalDetailsTitle,
|
|
990
|
+
childCount: 1
|
|
991
|
+
}, text(heading), ...renderer(items)];
|
|
992
|
+
};
|
|
978
993
|
|
|
979
994
|
const getCategoryVirtualDom = category => {
|
|
980
995
|
const {
|
|
@@ -1048,39 +1063,7 @@ const getAdditionalDetailsVirtualDom = (firstHeading, entries, secondHeading, se
|
|
|
1048
1063
|
type: Div$1,
|
|
1049
1064
|
className: AdditionalDetails,
|
|
1050
1065
|
childCount: 4
|
|
1051
|
-
},
|
|
1052
|
-
type: Div$1,
|
|
1053
|
-
className: AdditionalDetailsEntry,
|
|
1054
|
-
childCount: 2
|
|
1055
|
-
}, {
|
|
1056
|
-
type: Div$1,
|
|
1057
|
-
className: AdditionalDetailsTitle,
|
|
1058
|
-
childCount: 1
|
|
1059
|
-
}, text(firstHeading), ...getMoreInfoVirtualDom(entries), {
|
|
1060
|
-
type: Div$1,
|
|
1061
|
-
className: AdditionalDetailsEntry,
|
|
1062
|
-
childCount: 2
|
|
1063
|
-
}, {
|
|
1064
|
-
type: Div$1,
|
|
1065
|
-
className: AdditionalDetailsTitle,
|
|
1066
|
-
childCount: 1
|
|
1067
|
-
}, text(secondHeading), ...getMoreInfoVirtualDom(secondEntries), {
|
|
1068
|
-
type: Div$1,
|
|
1069
|
-
className: AdditionalDetailsEntry,
|
|
1070
|
-
childCount: 2
|
|
1071
|
-
}, {
|
|
1072
|
-
type: Div$1,
|
|
1073
|
-
className: AdditionalDetailsTitle,
|
|
1074
|
-
childCount: 1
|
|
1075
|
-
}, text(thirdHeading), ...getCategoriesDom(categories), {
|
|
1076
|
-
type: Div$1,
|
|
1077
|
-
className: AdditionalDetailsEntry,
|
|
1078
|
-
childCount: 2
|
|
1079
|
-
}, {
|
|
1080
|
-
type: Div$1,
|
|
1081
|
-
className: AdditionalDetailsTitle,
|
|
1082
|
-
childCount: 1
|
|
1083
|
-
}, text(fourthHeading), ...getResourcesVirtualDom(resources)];
|
|
1066
|
+
}, ...getAdditionalDetailsEntryVirtualDom(firstHeading, entries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(secondHeading, secondEntries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(thirdHeading, categories, getCategoriesDom), ...getAdditionalDetailsEntryVirtualDom(fourthHeading, resources, getResourcesVirtualDom)];
|
|
1084
1067
|
};
|
|
1085
1068
|
|
|
1086
1069
|
const allowedMarkdownAttributes = ['src', 'id', 'className', 'title', 'alt', 'href', 'target', 'rel'];
|
|
@@ -1558,6 +1541,9 @@ const getDetailsVirtualDom = sanitizedReadmeHtml => {
|
|
|
1558
1541
|
}, {
|
|
1559
1542
|
key: 'Last Updated',
|
|
1560
1543
|
value: 'n/a'
|
|
1544
|
+
}, {
|
|
1545
|
+
key: 'Size',
|
|
1546
|
+
value: '100kB'
|
|
1561
1547
|
}];
|
|
1562
1548
|
const secondHeading = 'Marketplace';
|
|
1563
1549
|
const secondEntries = [{
|
|
@@ -1607,12 +1593,16 @@ const getDetailsVirtualDom = sanitizedReadmeHtml => {
|
|
|
1607
1593
|
|
|
1608
1594
|
const getFeatureListItemVirtualDom = feature => {
|
|
1609
1595
|
const {
|
|
1610
|
-
label
|
|
1596
|
+
label,
|
|
1597
|
+
selected,
|
|
1598
|
+
id
|
|
1611
1599
|
} = feature;
|
|
1600
|
+
const className = selected ? 'Feature FeatureSelected' : Feature;
|
|
1612
1601
|
return [{
|
|
1613
1602
|
// TODO use role list item or tab
|
|
1614
|
-
type:
|
|
1615
|
-
|
|
1603
|
+
type: Button,
|
|
1604
|
+
name: id,
|
|
1605
|
+
className,
|
|
1616
1606
|
childCount: 1
|
|
1617
1607
|
}, text(label)];
|
|
1618
1608
|
};
|
|
@@ -1622,7 +1612,8 @@ const getFeatureListVirtualDom = features => {
|
|
|
1622
1612
|
// TODO use either list or tabs role
|
|
1623
1613
|
type: Div$1,
|
|
1624
1614
|
className: FeaturesList,
|
|
1625
|
-
childCount: features.length
|
|
1615
|
+
childCount: features.length,
|
|
1616
|
+
onClick: HandleFeaturesClick
|
|
1626
1617
|
}, ...features.flatMap(getFeatureListItemVirtualDom)];
|
|
1627
1618
|
};
|
|
1628
1619
|
|
|
@@ -1644,11 +1635,7 @@ const getFeatureThemesVirtualDom = themesHtml => {
|
|
|
1644
1635
|
}, ...markdownDom];
|
|
1645
1636
|
};
|
|
1646
1637
|
|
|
1647
|
-
const getFeaturesVirtualDom = themesHtml => {
|
|
1648
|
-
const features = [{
|
|
1649
|
-
id: 'theme',
|
|
1650
|
-
label: 'Theme'
|
|
1651
|
-
}];
|
|
1638
|
+
const getFeaturesVirtualDom = (features, themesHtml) => {
|
|
1652
1639
|
return [{
|
|
1653
1640
|
type: Div$1,
|
|
1654
1641
|
className: Features$1,
|
|
@@ -1660,16 +1647,21 @@ const getFeaturesVirtualDom = themesHtml => {
|
|
|
1660
1647
|
}, ...getFeatureThemesVirtualDom(themesHtml)];
|
|
1661
1648
|
};
|
|
1662
1649
|
|
|
1650
|
+
const Changelog = 'Changelog';
|
|
1651
|
+
const Commands = 'Commands';
|
|
1663
1652
|
const Details = 'Details';
|
|
1664
1653
|
const Features = 'Features';
|
|
1665
|
-
const
|
|
1654
|
+
const JsonValidation = 'JsonValidation';
|
|
1655
|
+
const ProgrammingLanguages = 'ProgrammingLanguages';
|
|
1656
|
+
const Settings = 'Settings';
|
|
1657
|
+
const Theme = 'Theme';
|
|
1666
1658
|
|
|
1667
|
-
const getExtensionDetailContentVirtualDom = (sanitizedReadmeHtml, themesHtml, selectedTab) => {
|
|
1659
|
+
const getExtensionDetailContentVirtualDom = (sanitizedReadmeHtml, themesHtml, selectedTab, features) => {
|
|
1668
1660
|
switch (selectedTab) {
|
|
1669
1661
|
case Details:
|
|
1670
1662
|
return getDetailsVirtualDom(sanitizedReadmeHtml);
|
|
1671
1663
|
case Features:
|
|
1672
|
-
return getFeaturesVirtualDom(themesHtml);
|
|
1664
|
+
return getFeaturesVirtualDom(features, themesHtml);
|
|
1673
1665
|
case Changelog:
|
|
1674
1666
|
return getChangelogVirtualDom();
|
|
1675
1667
|
default:
|
|
@@ -1710,6 +1702,31 @@ const getExtensionDetailHeaderVirtualDom = extensionDetail => {
|
|
|
1710
1702
|
return dom;
|
|
1711
1703
|
};
|
|
1712
1704
|
|
|
1705
|
+
const getFeatures = () => {
|
|
1706
|
+
const features = [{
|
|
1707
|
+
id: Theme,
|
|
1708
|
+
label: 'Theme',
|
|
1709
|
+
selected: true
|
|
1710
|
+
}, {
|
|
1711
|
+
id: Commands,
|
|
1712
|
+
label: 'Commands',
|
|
1713
|
+
selected: false
|
|
1714
|
+
}, {
|
|
1715
|
+
id: JsonValidation,
|
|
1716
|
+
label: 'Json Validation',
|
|
1717
|
+
selected: false
|
|
1718
|
+
}, {
|
|
1719
|
+
id: ProgrammingLanguages,
|
|
1720
|
+
label: 'Programming Languages',
|
|
1721
|
+
selected: false
|
|
1722
|
+
}, {
|
|
1723
|
+
id: Settings,
|
|
1724
|
+
label: 'Settings',
|
|
1725
|
+
selected: false
|
|
1726
|
+
}];
|
|
1727
|
+
return features;
|
|
1728
|
+
};
|
|
1729
|
+
|
|
1713
1730
|
const getTabs = selectedTab => {
|
|
1714
1731
|
const tabs = [{
|
|
1715
1732
|
label: 'Details',
|
|
@@ -1769,12 +1786,13 @@ const getTabsVirtualDom = tabs => {
|
|
|
1769
1786
|
|
|
1770
1787
|
const getExtensionDetailVirtualDom = (extensionDetail, sanitizedReadmeHtml, selectedTab, newState) => {
|
|
1771
1788
|
const themesHtml = newState?.selectedFeatureMarkdownDom || '';
|
|
1789
|
+
const features = newState?.features || getFeatures();
|
|
1772
1790
|
const tabs = getTabs(selectedTab);
|
|
1773
1791
|
const dom = [{
|
|
1774
1792
|
type: Div$1,
|
|
1775
1793
|
className: mergeClassNames(Viewlet, ExtensionDetail),
|
|
1776
1794
|
childCount: 3
|
|
1777
|
-
}, ...getExtensionDetailHeaderVirtualDom(extensionDetail), ...getTabsVirtualDom(tabs), ...getExtensionDetailContentVirtualDom(sanitizedReadmeHtml, themesHtml, selectedTab)];
|
|
1795
|
+
}, ...getExtensionDetailHeaderVirtualDom(extensionDetail), ...getTabsVirtualDom(tabs), ...getExtensionDetailContentVirtualDom(sanitizedReadmeHtml, themesHtml, selectedTab, features)];
|
|
1778
1796
|
return dom;
|
|
1779
1797
|
};
|
|
1780
1798
|
|
|
@@ -1851,6 +1869,33 @@ const getLinkMenuEntries = props => {
|
|
|
1851
1869
|
|
|
1852
1870
|
const getMenuEntries = props => [...getLinkMenuEntries(props), ...getImageMenuEntries(props), getCopyMenuEntry()];
|
|
1853
1871
|
|
|
1872
|
+
const selectFeature = async (state, name) => {
|
|
1873
|
+
const {
|
|
1874
|
+
features
|
|
1875
|
+
} = state;
|
|
1876
|
+
const newFeatures = features.map(feature => {
|
|
1877
|
+
if (feature.id === name) {
|
|
1878
|
+
return {
|
|
1879
|
+
...feature,
|
|
1880
|
+
selected: true
|
|
1881
|
+
};
|
|
1882
|
+
}
|
|
1883
|
+
return {
|
|
1884
|
+
...feature,
|
|
1885
|
+
selected: false
|
|
1886
|
+
};
|
|
1887
|
+
});
|
|
1888
|
+
return {
|
|
1889
|
+
...state,
|
|
1890
|
+
selectedFeature: name,
|
|
1891
|
+
features: newFeatures
|
|
1892
|
+
};
|
|
1893
|
+
};
|
|
1894
|
+
|
|
1895
|
+
const handleClickFeatures = async (state, name) => {
|
|
1896
|
+
return selectFeature(state, name);
|
|
1897
|
+
};
|
|
1898
|
+
|
|
1854
1899
|
const assetDir = '';
|
|
1855
1900
|
|
|
1856
1901
|
const ExtensionDefaultIcon = `${assetDir}/icons/extensionDefaultIcon.png`;
|
|
@@ -1877,6 +1922,10 @@ const selectTabChangelog = async state => {
|
|
|
1877
1922
|
};
|
|
1878
1923
|
};
|
|
1879
1924
|
|
|
1925
|
+
const selectTabDefault = async state => {
|
|
1926
|
+
return state;
|
|
1927
|
+
};
|
|
1928
|
+
|
|
1880
1929
|
const selectTabDetails = async state => {
|
|
1881
1930
|
// TODO load readmo markdown here
|
|
1882
1931
|
return {
|
|
@@ -4437,7 +4486,7 @@ const getSelectTabHandler = selectedTab => {
|
|
|
4437
4486
|
case Changelog:
|
|
4438
4487
|
return selectTabChangelog;
|
|
4439
4488
|
default:
|
|
4440
|
-
|
|
4489
|
+
return selectTabDefault;
|
|
4441
4490
|
}
|
|
4442
4491
|
};
|
|
4443
4492
|
|
|
@@ -4547,6 +4596,14 @@ const getBaseUrl = (extensionPath, platform) => {
|
|
|
4547
4596
|
}
|
|
4548
4597
|
};
|
|
4549
4598
|
|
|
4599
|
+
const getFolderSize = async uri => {
|
|
4600
|
+
try {
|
|
4601
|
+
return await invoke('FileSystem.getFolderSize', uri);
|
|
4602
|
+
} catch {
|
|
4603
|
+
return 0;
|
|
4604
|
+
}
|
|
4605
|
+
};
|
|
4606
|
+
|
|
4550
4607
|
const getSavedSelectedTab = savedState => {
|
|
4551
4608
|
if (savedState && typeof savedState === 'object' && 'selectedTab' in savedState && typeof savedState.selectedTab === 'string') {
|
|
4552
4609
|
return savedState.selectedTab;
|
|
@@ -4615,6 +4672,8 @@ const loadContent = async (state, platform, savedState) => {
|
|
|
4615
4672
|
const name = getName(extension);
|
|
4616
4673
|
const size = getViewletSize(width);
|
|
4617
4674
|
const selectedTab = getSavedSelectedTab(savedState);
|
|
4675
|
+
const features = getFeatures();
|
|
4676
|
+
const folderSize = await getFolderSize(extension.uri);
|
|
4618
4677
|
const entries = [{
|
|
4619
4678
|
key: 'Identifier',
|
|
4620
4679
|
value: 'abc'
|
|
@@ -4662,7 +4721,9 @@ const loadContent = async (state, platform, savedState) => {
|
|
|
4662
4721
|
categories,
|
|
4663
4722
|
resources,
|
|
4664
4723
|
extension,
|
|
4665
|
-
baseUrl
|
|
4724
|
+
baseUrl,
|
|
4725
|
+
features,
|
|
4726
|
+
folderSize
|
|
4666
4727
|
};
|
|
4667
4728
|
};
|
|
4668
4729
|
|
|
@@ -4681,14 +4742,15 @@ const terminate = () => {
|
|
|
4681
4742
|
|
|
4682
4743
|
const commandMap = {
|
|
4683
4744
|
'ExtensionDetail.create': create,
|
|
4684
|
-
'ExtensionDetail.saveState': saveState,
|
|
4685
4745
|
'ExtensionDetail.getMenuEntries': getMenuEntries,
|
|
4686
4746
|
'ExtensionDetail.getVirtualDom': getExtensionDetailVirtualDom,
|
|
4687
|
-
'ExtensionDetail.
|
|
4688
|
-
'ExtensionDetail.terminate': terminate,
|
|
4689
|
-
'ExtensionDetail.handleTabsClick': handleTabsClick,
|
|
4747
|
+
'ExtensionDetail.handleFeaturesClick': handleClickFeatures,
|
|
4690
4748
|
'ExtensionDetail.handleIconError': handleIconError,
|
|
4749
|
+
'ExtensionDetail.handleTabsClick': handleTabsClick,
|
|
4750
|
+
'ExtensionDetail.loadContent': loadContent,
|
|
4751
|
+
'ExtensionDetail.saveState': saveState,
|
|
4691
4752
|
'ExtensionDetail.selectTab': selectTab,
|
|
4753
|
+
'ExtensionDetail.terminate': terminate,
|
|
4692
4754
|
// deprecated
|
|
4693
4755
|
'HandleIconError.handleIconError': handleIconError,
|
|
4694
4756
|
'RenderMarkdown.renderMarkdown': renderMarkdown
|