@lvce-editor/extension-detail-view 3.5.0 → 3.6.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,43 @@ 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 getMoreInfoEntryValueVirtualDom = item => {
|
|
1098
|
+
const {
|
|
1099
|
+
value,
|
|
1100
|
+
onClick
|
|
1101
|
+
} = item;
|
|
1102
|
+
const valueTag = onClick ? A$1 : Div$1;
|
|
1103
|
+
let valueClassName = MoreInfoEntryValue;
|
|
1104
|
+
if (onClick) {
|
|
1105
|
+
valueClassName += ' Link';
|
|
1106
|
+
}
|
|
1107
|
+
return [{
|
|
1108
|
+
type: valueTag,
|
|
1109
|
+
className: valueClassName,
|
|
1110
|
+
childCount: 1,
|
|
1111
|
+
onClick
|
|
1030
1112
|
}, text(value)];
|
|
1031
1113
|
};
|
|
1032
1114
|
|
|
1115
|
+
const getMoreInfoEntryVirtualDom = item => {
|
|
1116
|
+
return [{
|
|
1117
|
+
type: Div$1,
|
|
1118
|
+
className: MoreInfoEntry,
|
|
1119
|
+
childCount: 2
|
|
1120
|
+
}, ...getMoreInfoEntryKeyVirtualDom(item), ...getMoreInfoEntryValueVirtualDom(item)];
|
|
1121
|
+
};
|
|
1122
|
+
|
|
1033
1123
|
const getMoreInfoVirtualDom = items => {
|
|
1034
1124
|
return [{
|
|
1035
1125
|
type: Div$1,
|
|
@@ -1066,6 +1156,24 @@ const getAdditionalDetailsVirtualDom = (firstHeading, entries, secondHeading, se
|
|
|
1066
1156
|
}, ...getAdditionalDetailsEntryVirtualDom(firstHeading, entries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(secondHeading, secondEntries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(thirdHeading, categories, getCategoriesDom), ...getAdditionalDetailsEntryVirtualDom(fourthHeading, resources, getResourcesVirtualDom)];
|
|
1067
1157
|
};
|
|
1068
1158
|
|
|
1159
|
+
const getInstallationEntries = displaySize => {
|
|
1160
|
+
const entries = [{
|
|
1161
|
+
key: 'Identifier',
|
|
1162
|
+
value: 'abc'
|
|
1163
|
+
}, {
|
|
1164
|
+
key: 'Version',
|
|
1165
|
+
value: '1.9.5'
|
|
1166
|
+
}, {
|
|
1167
|
+
key: 'Last Updated',
|
|
1168
|
+
value: 'n/a'
|
|
1169
|
+
}, {
|
|
1170
|
+
key: 'Size',
|
|
1171
|
+
value: `${displaySize}`,
|
|
1172
|
+
onClick: HandleClickSize
|
|
1173
|
+
}];
|
|
1174
|
+
return entries;
|
|
1175
|
+
};
|
|
1176
|
+
|
|
1069
1177
|
const allowedMarkdownAttributes = ['src', 'id', 'className', 'title', 'alt', 'href', 'target', 'rel'];
|
|
1070
1178
|
|
|
1071
1179
|
const Div = 'div';
|
|
@@ -1528,23 +1636,11 @@ const getVirtualDomChildCount = markdownDom => {
|
|
|
1528
1636
|
return stack.length;
|
|
1529
1637
|
};
|
|
1530
1638
|
|
|
1531
|
-
const getDetailsVirtualDom = sanitizedReadmeHtml => {
|
|
1639
|
+
const getDetailsVirtualDom = (sanitizedReadmeHtml, displaySize) => {
|
|
1532
1640
|
const markdownDom = getMarkdownVirtualDom(sanitizedReadmeHtml);
|
|
1533
1641
|
const childCount = getVirtualDomChildCount(markdownDom);
|
|
1534
1642
|
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
|
-
}];
|
|
1643
|
+
const entries = getInstallationEntries(displaySize);
|
|
1548
1644
|
const secondHeading = 'Marketplace';
|
|
1549
1645
|
const secondEntries = [{
|
|
1550
1646
|
key: 'Published',
|
|
@@ -1656,10 +1752,10 @@ const ProgrammingLanguages = 'ProgrammingLanguages';
|
|
|
1656
1752
|
const Settings = 'Settings';
|
|
1657
1753
|
const Theme = 'Theme';
|
|
1658
1754
|
|
|
1659
|
-
const getExtensionDetailContentVirtualDom = (sanitizedReadmeHtml, themesHtml, selectedTab, features) => {
|
|
1755
|
+
const getExtensionDetailContentVirtualDom = (sanitizedReadmeHtml, themesHtml, selectedTab, features, displaySize) => {
|
|
1660
1756
|
switch (selectedTab) {
|
|
1661
1757
|
case Details:
|
|
1662
|
-
return getDetailsVirtualDom(sanitizedReadmeHtml);
|
|
1758
|
+
return getDetailsVirtualDom(sanitizedReadmeHtml, displaySize);
|
|
1663
1759
|
case Features:
|
|
1664
1760
|
return getFeaturesVirtualDom(features, themesHtml);
|
|
1665
1761
|
case Changelog:
|
|
@@ -1787,12 +1883,14 @@ const getTabsVirtualDom = tabs => {
|
|
|
1787
1883
|
const getExtensionDetailVirtualDom = (extensionDetail, sanitizedReadmeHtml, selectedTab, newState) => {
|
|
1788
1884
|
const themesHtml = newState?.selectedFeatureMarkdownDom || '';
|
|
1789
1885
|
const features = newState?.features || getFeatures();
|
|
1886
|
+
const size = newState.folderSize || 0;
|
|
1887
|
+
const displaySize = getDisplaySize(size);
|
|
1790
1888
|
const tabs = getTabs(selectedTab);
|
|
1791
1889
|
const dom = [{
|
|
1792
1890
|
type: Div$1,
|
|
1793
1891
|
className: mergeClassNames(Viewlet, ExtensionDetail),
|
|
1794
1892
|
childCount: 3
|
|
1795
|
-
}, ...getExtensionDetailHeaderVirtualDom(extensionDetail), ...getTabsVirtualDom(tabs), ...getExtensionDetailContentVirtualDom(sanitizedReadmeHtml, themesHtml, selectedTab, features)];
|
|
1893
|
+
}, ...getExtensionDetailHeaderVirtualDom(extensionDetail), ...getTabsVirtualDom(tabs), ...getExtensionDetailContentVirtualDom(sanitizedReadmeHtml, themesHtml, selectedTab, features, displaySize)];
|
|
1796
1894
|
return dom;
|
|
1797
1895
|
};
|
|
1798
1896
|
|
|
@@ -1896,6 +1994,29 @@ const handleClickFeatures = async (state, name) => {
|
|
|
1896
1994
|
return selectFeature(state, name);
|
|
1897
1995
|
};
|
|
1898
1996
|
|
|
1997
|
+
const RendererWorker = 1;
|
|
1998
|
+
|
|
1999
|
+
const rpcs = Object.create(null);
|
|
2000
|
+
const set = (id, rpc) => {
|
|
2001
|
+
rpcs[id] = rpc;
|
|
2002
|
+
};
|
|
2003
|
+
const get = id => {
|
|
2004
|
+
return rpcs[id];
|
|
2005
|
+
};
|
|
2006
|
+
|
|
2007
|
+
const invoke = (method, ...params) => {
|
|
2008
|
+
const rpc = get(RendererWorker);
|
|
2009
|
+
return rpc.invoke(method, ...params);
|
|
2010
|
+
};
|
|
2011
|
+
|
|
2012
|
+
const handleClickSize = async state => {
|
|
2013
|
+
const {
|
|
2014
|
+
uri
|
|
2015
|
+
} = state.extension;
|
|
2016
|
+
await invoke('OpenNativeFolder.openNativeFolder', uri);
|
|
2017
|
+
return state;
|
|
2018
|
+
};
|
|
2019
|
+
|
|
1899
2020
|
const assetDir = '';
|
|
1900
2021
|
|
|
1901
2022
|
const ExtensionDefaultIcon = `${assetDir}/icons/extensionDefaultIcon.png`;
|
|
@@ -4550,21 +4671,6 @@ const getName = extension => {
|
|
|
4550
4671
|
return 'n/a';
|
|
4551
4672
|
};
|
|
4552
4673
|
|
|
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
4674
|
const getAllExtensions = async platform => {
|
|
4569
4675
|
if (platform === Web) {
|
|
4570
4676
|
return [];
|
|
@@ -4744,6 +4850,7 @@ const commandMap = {
|
|
|
4744
4850
|
'ExtensionDetail.create': create,
|
|
4745
4851
|
'ExtensionDetail.getMenuEntries': getMenuEntries,
|
|
4746
4852
|
'ExtensionDetail.getVirtualDom': getExtensionDetailVirtualDom,
|
|
4853
|
+
'ExtensionDetail.handleClickSize': handleClickSize,
|
|
4747
4854
|
'ExtensionDetail.handleFeaturesClick': handleClickFeatures,
|
|
4748
4855
|
'ExtensionDetail.handleIconError': handleIconError,
|
|
4749
4856
|
'ExtensionDetail.handleTabsClick': handleTabsClick,
|