@lvce-editor/extension-detail-view 7.14.0 → 7.14.2

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.
@@ -4196,7 +4196,10 @@ const getExtension$1 = async (id, platform) => {
4196
4196
  const getExtensionNew = async id => {
4197
4197
  try {
4198
4198
  const rpc = get$2(ExtensionManagementWorker);
4199
- return await rpc.invoke('Extensions.getExtension', id);
4199
+ const extension = await rpc.invoke('Extensions.getExtension', id);
4200
+ if (extension) {
4201
+ return extension;
4202
+ }
4200
4203
  } catch {
4201
4204
  // ignore
4202
4205
  }
@@ -4398,6 +4401,26 @@ const handleClickUninstall = async state => {
4398
4401
  return state;
4399
4402
  };
4400
4403
 
4404
+ const handleColorThemeChanged = (state, colorThemeId) => {
4405
+ if (state.currentColorThemeId === colorThemeId) {
4406
+ return state;
4407
+ }
4408
+ const {
4409
+ disabled,
4410
+ extension,
4411
+ hasColorTheme
4412
+ } = state;
4413
+ const extensionColorThemeId = getColorThemeId(extension) || '';
4414
+ const extensionColorThemeLabel = getColorThemeLabel(extension) || '';
4415
+ const isBuiltin = extension?.isBuiltin || extension?.builtin || false;
4416
+ const buttons = getExtensionDetailButtons(hasColorTheme, isBuiltin, disabled, extensionColorThemeId, extensionColorThemeLabel, colorThemeId);
4417
+ return {
4418
+ ...state,
4419
+ buttons,
4420
+ currentColorThemeId: colorThemeId
4421
+ };
4422
+ };
4423
+
4401
4424
  const existsFile = async uri => {
4402
4425
  try {
4403
4426
  return await exists(uri);
@@ -4759,10 +4782,10 @@ const loadHeaderContent = (state, platform, extension) => {
4759
4782
  const extensionId = extension?.id || 'n/a';
4760
4783
  const extensionVersion = extension?.version || 'n/a';
4761
4784
  const hasColorTheme = hasColorThemes(extension);
4762
- const isBuiltin = extension?.builtin;
4785
+ const isBuiltin = extension?.isBuiltin || extension?.builtin || false;
4763
4786
  const badge = getBadge(isBuiltin, builtinExtensionsBadgeEnabled);
4764
- const downloadCount = getDownloadCount(extension);
4765
- const rating = getRating(extension);
4787
+ const downloadCount = isBuiltin ? 'n/a' : getDownloadCount(extension);
4788
+ const rating = isBuiltin ? 'n/a' : getRating(extension);
4766
4789
  return {
4767
4790
  badge,
4768
4791
  description,
@@ -4921,21 +4944,17 @@ function prettyBytes(number, options) {
4921
4944
  number = -number;
4922
4945
  }
4923
4946
  const localeOptions = buildLocaleOptions(options);
4924
- let result;
4925
- if (number < 1) {
4926
- const numberString = toLocaleString(number, options.locale, localeOptions);
4927
- result = prefix + numberString + separator + UNITS[0];
4928
- } else {
4929
- const exponent = Math.min(Math.floor(options.binary ? log(number) / Math.log(1024) : log10(number) / 3), UNITS.length - 1);
4930
- number = divide(number, (options.binary ? 1024 : 1000) ** exponent);
4931
- if (!localeOptions) {
4932
- const minPrecision = Math.max(3, Math.floor(number).toString().length);
4933
- number = number.toPrecision(minPrecision);
4934
- }
4935
- const numberString = toLocaleString(Number(number), options.locale, localeOptions);
4936
- const unit = UNITS[exponent];
4937
- result = prefix + numberString + separator + unit;
4947
+ let exponent = 0;
4948
+ if (number >= 1) {
4949
+ exponent = Math.min(Math.floor(options.binary ? log(number) / Math.log(1024) : log10(number) / 3), UNITS.length - 1);
4950
+ }
4951
+ number = divide(number, (options.binary ? 1024 : 1000) ** exponent);
4952
+ if (!localeOptions) {
4953
+ const minPrecision = Math.max(3, Math.floor(number).toString().length);
4954
+ number = Number(number.toPrecision(minPrecision));
4938
4955
  }
4956
+ const numberString = toLocaleString(number, options.locale, localeOptions);
4957
+ const result = prefix + numberString + separator + UNITS[exponent];
4939
4958
  return applyFixedWidth(result, options.fixedWidth);
4940
4959
  }
4941
4960
 
@@ -6576,11 +6595,18 @@ const getStatisticVirtualDom = (label, value, className) => {
6576
6595
  }, text(value)];
6577
6596
  };
6578
6597
  const getExtensionDetailMetadataVirtualDom = (downloadCount$1, rating$1) => {
6598
+ const hasDownloadCount = downloadCount$1 !== 'n/a';
6599
+ const hasRating = rating$1 !== 'n/a';
6600
+ if (!hasDownloadCount && !hasRating) {
6601
+ return [];
6602
+ }
6603
+ const downloadCountDom = hasDownloadCount ? getStatisticVirtualDom(downloadCount(), downloadCount$1, ExtensionDetailDownloadCount) : [];
6604
+ const ratingDom = hasRating ? getStatisticVirtualDom(rating(), rating$1, ExtensionDetailRating) : [];
6579
6605
  return [{
6580
- childCount: 2,
6606
+ childCount: Number(hasDownloadCount) + Number(hasRating),
6581
6607
  className: ExtensionDetailMetadata,
6582
6608
  type: Div
6583
- }, ...getStatisticVirtualDom(downloadCount(), downloadCount$1, ExtensionDetailDownloadCount), ...getStatisticVirtualDom(rating(), rating$1, ExtensionDetailRating)];
6609
+ }, ...downloadCountDom, ...ratingDom];
6584
6610
  };
6585
6611
 
6586
6612
  const getNameBadgeVirtualDom = badge => {
@@ -6619,16 +6645,17 @@ const getExtensionDetailNameVirtualDom = (name, badge) => {
6619
6645
  };
6620
6646
 
6621
6647
  const getExtensionDetailHeaderVirtualDom = (name, iconSrc, description, badge, buttonDefs, settingsButtonEnabled, downloadCount = 'n/a', rating = 'n/a') => {
6648
+ const metadataDom = getExtensionDetailMetadataVirtualDom(downloadCount, rating);
6622
6649
  const dom = [{
6623
6650
  childCount: 2,
6624
6651
  className: ExtensionDetailHeader,
6625
6652
  type: Div
6626
6653
  }, getExtensionDetailIconVirtualDom(iconSrc), {
6627
- childCount: 4,
6654
+ childCount: metadataDom.length > 0 ? 4 : 3,
6628
6655
  className: ExtensionDetailHeaderDetails,
6629
6656
  onContextMenu: HandleHeaderContextMenu,
6630
6657
  type: Div
6631
- }, ...getExtensionDetailNameVirtualDom(name, badge), ...getExtensionDetailDescriptionVirtualDom(description), ...getExtensionDetailMetadataVirtualDom(downloadCount, rating), ...getExtensionDetailHeaderActionsVirtualDom(buttonDefs, settingsButtonEnabled)];
6658
+ }, ...getExtensionDetailNameVirtualDom(name, badge), ...getExtensionDetailDescriptionVirtualDom(description), ...metadataDom, ...getExtensionDetailHeaderActionsVirtualDom(buttonDefs, settingsButtonEnabled)];
6632
6659
  return dom;
6633
6660
  };
6634
6661
 
@@ -6974,6 +7001,7 @@ const commandMap = {
6974
7001
  'ExtensionDetail.handleClickSettings': wrapCommand(handleClickSettings),
6975
7002
  'ExtensionDetail.handleClickSize': wrapCommand(handleClickSize),
6976
7003
  'ExtensionDetail.handleClickUninstall': wrapCommand(handleClickUninstall),
7004
+ 'ExtensionDetail.handleColorThemeChanged': wrapCommand(handleColorThemeChanged),
6977
7005
  'ExtensionDetail.handleExtensionsChanged': wrapCommand(handleExtensionsChanged),
6978
7006
  'ExtensionDetail.handleExtensionsStatusUpdate': wrapCommand(handleExtensionsStatusUpdate),
6979
7007
  'ExtensionDetail.handleFeaturesClick': wrapCommand(handleClickFeatures),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "7.14.0",
3
+ "version": "7.14.2",
4
4
  "description": "Extension Detail View Worker",
5
5
  "repository": {
6
6
  "type": "git",