@lvce-editor/extension-detail-view 3.5.0 → 3.7.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.
|
@@ -919,6 +919,78 @@ const Resource = 'Resource';
|
|
|
919
919
|
const Resources = 'Resources';
|
|
920
920
|
const Viewlet = 'Viewlet';
|
|
921
921
|
|
|
922
|
+
const BYTE_UNITS = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
923
|
+
const BIBYTE_UNITS = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
|
|
924
|
+
const BIT_UNITS = ['b', 'kbit', 'Mbit', 'Gbit', 'Tbit', 'Pbit', 'Ebit', 'Zbit', 'Ybit'];
|
|
925
|
+
const BIBIT_UNITS = ['b', 'kibit', 'Mibit', 'Gibit', 'Tibit', 'Pibit', 'Eibit', 'Zibit', 'Yibit'];
|
|
926
|
+
|
|
927
|
+
/*
|
|
928
|
+
Formats the given number using `Number#toLocaleString`.
|
|
929
|
+
- If locale is a string, the value is expected to be a locale-key (for example: `de`).
|
|
930
|
+
- If locale is true, the system default locale is used for translation.
|
|
931
|
+
- If no value for locale is specified, the number is returned unmodified.
|
|
932
|
+
*/
|
|
933
|
+
const toLocaleString = (number, locale, options) => {
|
|
934
|
+
let result = number;
|
|
935
|
+
if (typeof locale === 'string' || Array.isArray(locale)) {
|
|
936
|
+
result = number.toLocaleString(locale, options);
|
|
937
|
+
} else if (locale === true || options !== undefined) {
|
|
938
|
+
result = number.toLocaleString(undefined, options);
|
|
939
|
+
}
|
|
940
|
+
return result;
|
|
941
|
+
};
|
|
942
|
+
function prettyBytes(number, options) {
|
|
943
|
+
if (!Number.isFinite(number)) {
|
|
944
|
+
throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
|
|
945
|
+
}
|
|
946
|
+
options = {
|
|
947
|
+
bits: false,
|
|
948
|
+
binary: false,
|
|
949
|
+
space: true,
|
|
950
|
+
...options
|
|
951
|
+
};
|
|
952
|
+
const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
|
|
953
|
+
const separator = options.space ? ' ' : '';
|
|
954
|
+
if (options.signed && number === 0) {
|
|
955
|
+
return ` 0${separator}${UNITS[0]}`;
|
|
956
|
+
}
|
|
957
|
+
const isNegative = number < 0;
|
|
958
|
+
const prefix = isNegative ? '-' : options.signed ? '+' : '';
|
|
959
|
+
if (isNegative) {
|
|
960
|
+
number = -number;
|
|
961
|
+
}
|
|
962
|
+
let localeOptions;
|
|
963
|
+
if (options.minimumFractionDigits !== undefined) {
|
|
964
|
+
localeOptions = {
|
|
965
|
+
minimumFractionDigits: options.minimumFractionDigits
|
|
966
|
+
};
|
|
967
|
+
}
|
|
968
|
+
if (options.maximumFractionDigits !== undefined) {
|
|
969
|
+
localeOptions = {
|
|
970
|
+
maximumFractionDigits: options.maximumFractionDigits,
|
|
971
|
+
...localeOptions
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
if (number < 1) {
|
|
975
|
+
const numberString = toLocaleString(number, options.locale, localeOptions);
|
|
976
|
+
return prefix + numberString + separator + UNITS[0];
|
|
977
|
+
}
|
|
978
|
+
const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1);
|
|
979
|
+
number /= (options.binary ? 1024 : 1000) ** exponent;
|
|
980
|
+
if (!localeOptions) {
|
|
981
|
+
number = number.toPrecision(3);
|
|
982
|
+
}
|
|
983
|
+
const numberString = toLocaleString(Number(number), options.locale, localeOptions);
|
|
984
|
+
const unit = UNITS[exponent];
|
|
985
|
+
return prefix + numberString + separator + unit;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
const getDisplaySize = size => {
|
|
989
|
+
return prettyBytes(size, {
|
|
990
|
+
maximumFractionDigits: 1
|
|
991
|
+
});
|
|
992
|
+
};
|
|
993
|
+
|
|
922
994
|
const Button = 1;
|
|
923
995
|
const Div$1 = 4;
|
|
924
996
|
const H1$1 = 5;
|
|
@@ -975,9 +1047,10 @@ const TabList = 'tablist';
|
|
|
975
1047
|
const Tab = 'tab';
|
|
976
1048
|
const Panel = 'panel';
|
|
977
1049
|
|
|
1050
|
+
const HandleClickSize = 'handleClickSize';
|
|
1051
|
+
const HandleFeaturesClick = 'handleFeaturesClick';
|
|
978
1052
|
const HandleReadmeContextMenu = 'handleReadmeContextMenu';
|
|
979
1053
|
const HandleTabsClick = 'handleTabsClick';
|
|
980
|
-
const HandleFeaturesClick = 'handleFeaturesClick';
|
|
981
1054
|
|
|
982
1055
|
const getAdditionalDetailsEntryVirtualDom = (heading, items, renderer) => {
|
|
983
1056
|
return [{
|
|
@@ -1010,26 +1083,70 @@ const getCategoriesDom = categories => {
|
|
|
1010
1083
|
}, ...categories.flatMap(getCategoryVirtualDom)];
|
|
1011
1084
|
};
|
|
1012
1085
|
|
|
1013
|
-
const
|
|
1086
|
+
const getMoreInfoEntryKeyVirtualDom = item => {
|
|
1014
1087
|
const {
|
|
1015
|
-
key
|
|
1016
|
-
value
|
|
1088
|
+
key
|
|
1017
1089
|
} = item;
|
|
1018
1090
|
return [{
|
|
1019
|
-
type: Div$1,
|
|
1020
|
-
className: MoreInfoEntry,
|
|
1021
|
-
childCount: 2
|
|
1022
|
-
}, {
|
|
1023
1091
|
type: Div$1,
|
|
1024
1092
|
className: MoreInfoEntryKey,
|
|
1025
1093
|
childCount: 1
|
|
1026
|
-
}, text(key)
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1094
|
+
}, text(key)];
|
|
1095
|
+
};
|
|
1096
|
+
|
|
1097
|
+
const getTag = (onClick, code) => {
|
|
1098
|
+
if (onClick) {
|
|
1099
|
+
return A$1;
|
|
1100
|
+
}
|
|
1101
|
+
if (code) {
|
|
1102
|
+
// TODO use code tag
|
|
1103
|
+
return Div$1;
|
|
1104
|
+
}
|
|
1105
|
+
return Div$1;
|
|
1106
|
+
};
|
|
1107
|
+
const getClassName = (onClick, code) => {
|
|
1108
|
+
if (onClick) {
|
|
1109
|
+
return MoreInfoEntryValue + ' Link';
|
|
1110
|
+
}
|
|
1111
|
+
if (code) {
|
|
1112
|
+
return MoreInfoEntryValue + ' Code';
|
|
1113
|
+
}
|
|
1114
|
+
return MoreInfoEntryValue;
|
|
1115
|
+
};
|
|
1116
|
+
const getMoreInfoEntryValueVirtualDom = item => {
|
|
1117
|
+
const {
|
|
1118
|
+
value,
|
|
1119
|
+
onClick,
|
|
1120
|
+
code
|
|
1121
|
+
} = item;
|
|
1122
|
+
const type = getTag(onClick, code);
|
|
1123
|
+
const className = getClassName(onClick, code);
|
|
1124
|
+
return [{
|
|
1125
|
+
type: type,
|
|
1126
|
+
className,
|
|
1127
|
+
childCount: 1,
|
|
1128
|
+
onClick
|
|
1030
1129
|
}, text(value)];
|
|
1031
1130
|
};
|
|
1032
1131
|
|
|
1132
|
+
const parentNodeEven = {
|
|
1133
|
+
type: Div$1,
|
|
1134
|
+
className: MoreInfoEntry,
|
|
1135
|
+
childCount: 2
|
|
1136
|
+
};
|
|
1137
|
+
const parentNodeOdd = {
|
|
1138
|
+
type: Div$1,
|
|
1139
|
+
className: MoreInfoEntry + ' ' + 'MoreInfoEntryOdd',
|
|
1140
|
+
childCount: 2
|
|
1141
|
+
};
|
|
1142
|
+
const getMoreInfoEntryVirtualDom = item => {
|
|
1143
|
+
const {
|
|
1144
|
+
odd
|
|
1145
|
+
} = item;
|
|
1146
|
+
const node = odd ? parentNodeOdd : parentNodeEven;
|
|
1147
|
+
return [node, ...getMoreInfoEntryKeyVirtualDom(item), ...getMoreInfoEntryValueVirtualDom(item)];
|
|
1148
|
+
};
|
|
1149
|
+
|
|
1033
1150
|
const getMoreInfoVirtualDom = items => {
|
|
1034
1151
|
return [{
|
|
1035
1152
|
type: Div$1,
|
|
@@ -1062,10 +1179,33 @@ const getAdditionalDetailsVirtualDom = (firstHeading, entries, secondHeading, se
|
|
|
1062
1179
|
return [{
|
|
1063
1180
|
type: Div$1,
|
|
1064
1181
|
className: AdditionalDetails,
|
|
1182
|
+
tabIndex: 0,
|
|
1065
1183
|
childCount: 4
|
|
1066
1184
|
}, ...getAdditionalDetailsEntryVirtualDom(firstHeading, entries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(secondHeading, secondEntries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(thirdHeading, categories, getCategoriesDom), ...getAdditionalDetailsEntryVirtualDom(fourthHeading, resources, getResourcesVirtualDom)];
|
|
1067
1185
|
};
|
|
1068
1186
|
|
|
1187
|
+
const getInstallationEntries = (displaySize, extensionId, extensionVersion) => {
|
|
1188
|
+
const entries = [{
|
|
1189
|
+
key: 'Identifier',
|
|
1190
|
+
value: extensionId,
|
|
1191
|
+
odd: true,
|
|
1192
|
+
code: true
|
|
1193
|
+
}, {
|
|
1194
|
+
key: 'Version',
|
|
1195
|
+
value: extensionVersion,
|
|
1196
|
+
code: true
|
|
1197
|
+
}, {
|
|
1198
|
+
key: 'Last Updated',
|
|
1199
|
+
value: 'n/a',
|
|
1200
|
+
odd: true
|
|
1201
|
+
}, {
|
|
1202
|
+
key: 'Size',
|
|
1203
|
+
value: displaySize,
|
|
1204
|
+
onClick: HandleClickSize
|
|
1205
|
+
}];
|
|
1206
|
+
return entries;
|
|
1207
|
+
};
|
|
1208
|
+
|
|
1069
1209
|
const allowedMarkdownAttributes = ['src', 'id', 'className', 'title', 'alt', 'href', 'target', 'rel'];
|
|
1070
1210
|
|
|
1071
1211
|
const Div = 'div';
|
|
@@ -1515,6 +1655,17 @@ const getMarkdownVirtualDom = html => {
|
|
|
1515
1655
|
return dom;
|
|
1516
1656
|
};
|
|
1517
1657
|
|
|
1658
|
+
const getMarketplaceEntries = () => {
|
|
1659
|
+
return [{
|
|
1660
|
+
key: 'Published',
|
|
1661
|
+
value: 'n/a',
|
|
1662
|
+
odd: true
|
|
1663
|
+
}, {
|
|
1664
|
+
key: 'Last Released',
|
|
1665
|
+
value: 'n/a'
|
|
1666
|
+
}];
|
|
1667
|
+
};
|
|
1668
|
+
|
|
1518
1669
|
const getVirtualDomChildCount = markdownDom => {
|
|
1519
1670
|
const max = markdownDom.length - 1;
|
|
1520
1671
|
let stack = [];
|
|
@@ -1528,31 +1679,13 @@ const getVirtualDomChildCount = markdownDom => {
|
|
|
1528
1679
|
return stack.length;
|
|
1529
1680
|
};
|
|
1530
1681
|
|
|
1531
|
-
const getDetailsVirtualDom = sanitizedReadmeHtml => {
|
|
1682
|
+
const getDetailsVirtualDom = (sanitizedReadmeHtml, displaySize, extensionId, extensionVersion) => {
|
|
1532
1683
|
const markdownDom = getMarkdownVirtualDom(sanitizedReadmeHtml);
|
|
1533
1684
|
const childCount = getVirtualDomChildCount(markdownDom);
|
|
1534
1685
|
const firstHeading = 'Installation';
|
|
1535
|
-
const entries =
|
|
1536
|
-
key: 'Identifier',
|
|
1537
|
-
value: 'abc'
|
|
1538
|
-
}, {
|
|
1539
|
-
key: 'Version',
|
|
1540
|
-
value: '1.9.5'
|
|
1541
|
-
}, {
|
|
1542
|
-
key: 'Last Updated',
|
|
1543
|
-
value: 'n/a'
|
|
1544
|
-
}, {
|
|
1545
|
-
key: 'Size',
|
|
1546
|
-
value: '100kB'
|
|
1547
|
-
}];
|
|
1686
|
+
const entries = getInstallationEntries(displaySize, extensionId, extensionVersion);
|
|
1548
1687
|
const secondHeading = 'Marketplace';
|
|
1549
|
-
const secondEntries =
|
|
1550
|
-
key: 'Published',
|
|
1551
|
-
value: 'n/a'
|
|
1552
|
-
}, {
|
|
1553
|
-
key: 'Last Released',
|
|
1554
|
-
value: 'n/a'
|
|
1555
|
-
}];
|
|
1688
|
+
const secondEntries = getMarketplaceEntries();
|
|
1556
1689
|
const thirdHeading = 'Categories';
|
|
1557
1690
|
const categories = [{
|
|
1558
1691
|
id: 'themes',
|
|
@@ -1656,10 +1789,10 @@ const ProgrammingLanguages = 'ProgrammingLanguages';
|
|
|
1656
1789
|
const Settings = 'Settings';
|
|
1657
1790
|
const Theme = 'Theme';
|
|
1658
1791
|
|
|
1659
|
-
const getExtensionDetailContentVirtualDom = (sanitizedReadmeHtml, themesHtml, selectedTab, features) => {
|
|
1792
|
+
const getExtensionDetailContentVirtualDom = (sanitizedReadmeHtml, themesHtml, selectedTab, features, displaySize, extensionId, extensionVersion) => {
|
|
1660
1793
|
switch (selectedTab) {
|
|
1661
1794
|
case Details:
|
|
1662
|
-
return getDetailsVirtualDom(sanitizedReadmeHtml);
|
|
1795
|
+
return getDetailsVirtualDom(sanitizedReadmeHtml, displaySize, extensionId, extensionVersion);
|
|
1663
1796
|
case Features:
|
|
1664
1797
|
return getFeaturesVirtualDom(features, themesHtml);
|
|
1665
1798
|
case Changelog:
|
|
@@ -1787,12 +1920,16 @@ const getTabsVirtualDom = tabs => {
|
|
|
1787
1920
|
const getExtensionDetailVirtualDom = (extensionDetail, sanitizedReadmeHtml, selectedTab, newState) => {
|
|
1788
1921
|
const themesHtml = newState?.selectedFeatureMarkdownDom || '';
|
|
1789
1922
|
const features = newState?.features || getFeatures();
|
|
1923
|
+
const size = newState.folderSize || 0;
|
|
1924
|
+
const extensionId = newState?.extension?.id || 'n/a';
|
|
1925
|
+
const extensionVersion = newState?.extension?.version || 'n/a';
|
|
1926
|
+
const displaySize = getDisplaySize(size);
|
|
1790
1927
|
const tabs = getTabs(selectedTab);
|
|
1791
1928
|
const dom = [{
|
|
1792
1929
|
type: Div$1,
|
|
1793
1930
|
className: mergeClassNames(Viewlet, ExtensionDetail),
|
|
1794
1931
|
childCount: 3
|
|
1795
|
-
}, ...getExtensionDetailHeaderVirtualDom(extensionDetail), ...getTabsVirtualDom(tabs), ...getExtensionDetailContentVirtualDom(sanitizedReadmeHtml, themesHtml, selectedTab, features)];
|
|
1932
|
+
}, ...getExtensionDetailHeaderVirtualDom(extensionDetail), ...getTabsVirtualDom(tabs), ...getExtensionDetailContentVirtualDom(sanitizedReadmeHtml, themesHtml, selectedTab, features, displaySize, extensionId, extensionVersion)];
|
|
1796
1933
|
return dom;
|
|
1797
1934
|
};
|
|
1798
1935
|
|
|
@@ -1896,6 +2033,29 @@ const handleClickFeatures = async (state, name) => {
|
|
|
1896
2033
|
return selectFeature(state, name);
|
|
1897
2034
|
};
|
|
1898
2035
|
|
|
2036
|
+
const RendererWorker = 1;
|
|
2037
|
+
|
|
2038
|
+
const rpcs = Object.create(null);
|
|
2039
|
+
const set = (id, rpc) => {
|
|
2040
|
+
rpcs[id] = rpc;
|
|
2041
|
+
};
|
|
2042
|
+
const get = id => {
|
|
2043
|
+
return rpcs[id];
|
|
2044
|
+
};
|
|
2045
|
+
|
|
2046
|
+
const invoke = (method, ...params) => {
|
|
2047
|
+
const rpc = get(RendererWorker);
|
|
2048
|
+
return rpc.invoke(method, ...params);
|
|
2049
|
+
};
|
|
2050
|
+
|
|
2051
|
+
const handleClickSize = async state => {
|
|
2052
|
+
const {
|
|
2053
|
+
uri
|
|
2054
|
+
} = state.extension;
|
|
2055
|
+
await invoke('OpenNativeFolder.openNativeFolder', uri);
|
|
2056
|
+
return state;
|
|
2057
|
+
};
|
|
2058
|
+
|
|
1899
2059
|
const assetDir = '';
|
|
1900
2060
|
|
|
1901
2061
|
const ExtensionDefaultIcon = `${assetDir}/icons/extensionDefaultIcon.png`;
|
|
@@ -4550,21 +4710,6 @@ const getName = extension => {
|
|
|
4550
4710
|
return 'n/a';
|
|
4551
4711
|
};
|
|
4552
4712
|
|
|
4553
|
-
const RendererWorker = 1;
|
|
4554
|
-
|
|
4555
|
-
const rpcs = Object.create(null);
|
|
4556
|
-
const set = (id, rpc) => {
|
|
4557
|
-
rpcs[id] = rpc;
|
|
4558
|
-
};
|
|
4559
|
-
const get = id => {
|
|
4560
|
-
return rpcs[id];
|
|
4561
|
-
};
|
|
4562
|
-
|
|
4563
|
-
const invoke = (method, ...params) => {
|
|
4564
|
-
const rpc = get(RendererWorker);
|
|
4565
|
-
return rpc.invoke(method, ...params);
|
|
4566
|
-
};
|
|
4567
|
-
|
|
4568
4713
|
const getAllExtensions = async platform => {
|
|
4569
4714
|
if (platform === Web) {
|
|
4570
4715
|
return [];
|
|
@@ -4744,6 +4889,7 @@ const commandMap = {
|
|
|
4744
4889
|
'ExtensionDetail.create': create,
|
|
4745
4890
|
'ExtensionDetail.getMenuEntries': getMenuEntries,
|
|
4746
4891
|
'ExtensionDetail.getVirtualDom': getExtensionDetailVirtualDom,
|
|
4892
|
+
'ExtensionDetail.handleClickSize': handleClickSize,
|
|
4747
4893
|
'ExtensionDetail.handleFeaturesClick': handleClickFeatures,
|
|
4748
4894
|
'ExtensionDetail.handleIconError': handleIconError,
|
|
4749
4895
|
'ExtensionDetail.handleTabsClick': handleTabsClick,
|