@lvce-editor/extension-detail-view 3.58.0 → 3.59.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.
@@ -2847,6 +2847,13 @@ const isEnoentError = error => {
2847
2847
  return error && error.code === ENOENT;
2848
2848
  };
2849
2849
 
2850
+ /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
2851
+ const error = async error => {
2852
+ // TODO send message to error worker or log worker
2853
+ // @ts-ignore
2854
+ console.error(message);
2855
+ };
2856
+
2850
2857
  const join = (...parts) => {
2851
2858
  return parts.join('/');
2852
2859
  };
@@ -2856,14 +2863,12 @@ const loadChangelogContent = async path => {
2856
2863
  const changelogUrl = join(path, 'CHANGELOG.md');
2857
2864
  const changelogContent = await readFile(changelogUrl);
2858
2865
  return changelogContent;
2859
- } catch (error) {
2860
- if (isEnoentError(error)) {
2866
+ } catch (error$1) {
2867
+ if (isEnoentError(error$1)) {
2861
2868
  return '';
2862
2869
  }
2863
- // TODO send message to error worker
2864
- // @ts-ignore
2865
- console.error(new VError(error, 'Failed to load Changelog content'));
2866
- return `${error}`;
2870
+ await error(new VError(error$1, 'Failed to load Changelog content'));
2871
+ return `${error$1}`;
2867
2872
  }
2868
2873
  };
2869
2874
 
@@ -3143,6 +3148,19 @@ const getExtensionIdFromUri = uri => {
3143
3148
  return id;
3144
3149
  };
3145
3150
 
3151
+ const getPadding = width => {
3152
+ if (width < 400) {
3153
+ return 10;
3154
+ }
3155
+ if (width < 800) {
3156
+ return 20;
3157
+ }
3158
+ if (width < 1200) {
3159
+ return 30;
3160
+ }
3161
+ return 40;
3162
+ };
3163
+
3146
3164
  const getTabs = (selectedTab, hasReadme, hasFeatures, hasChangelog) => {
3147
3165
  const tabs = [{
3148
3166
  label: details(),
@@ -3224,6 +3242,36 @@ const getName = extension => {
3224
3242
  return 'n/a';
3225
3243
  };
3226
3244
 
3245
+ const getDownloadCount = extension => {
3246
+ if (!extension) {
3247
+ return 'n/a';
3248
+ }
3249
+
3250
+ // Check for download count in various possible locations
3251
+ const downloadCount = extension.downloadCount || extension.downloads || extension.marketplace?.downloadCount || extension.marketplace?.downloads || extension.packageJSON?.downloadCount || extension.packageJSON?.downloads;
3252
+ if (!downloadCount) {
3253
+ return 'n/a';
3254
+ }
3255
+
3256
+ // Format the number with commas for better readability
3257
+ return downloadCount.toLocaleString();
3258
+ };
3259
+
3260
+ const getRating = extension => {
3261
+ if (!extension) {
3262
+ return 'n/a';
3263
+ }
3264
+
3265
+ // Check for rating in various possible locations
3266
+ const rating = extension.rating || extension.averageRating || extension.marketplace?.rating || extension.marketplace?.averageRating || extension.packageJSON?.rating || extension.packageJSON?.averageRating;
3267
+ if (!rating) {
3268
+ return 'n/a';
3269
+ }
3270
+
3271
+ // Format rating to one decimal place
3272
+ return rating.toFixed(1);
3273
+ };
3274
+
3227
3275
  const getBadge = (builtin, badgeEnabled) => {
3228
3276
  if (builtin && badgeEnabled) {
3229
3277
  return 'builtin';
@@ -3249,16 +3297,20 @@ const loadHeaderContent = (state, platform, extension) => {
3249
3297
  const hasColorTheme = hasColorThemes(extension);
3250
3298
  const isBuiltin = extension?.builtin;
3251
3299
  const badge = getBadge(isBuiltin, builtinExtensionsBadgeEnabled);
3300
+ const downloadCount = getDownloadCount(extension);
3301
+ const rating = getRating(extension);
3252
3302
  return {
3253
3303
  badge,
3254
3304
  description,
3305
+ downloadCount,
3255
3306
  extension,
3256
3307
  extensionId,
3257
3308
  extensionUri,
3258
3309
  extensionVersion,
3259
3310
  hasColorTheme,
3260
3311
  iconSrc,
3261
- name
3312
+ name,
3313
+ rating
3262
3314
  };
3263
3315
  };
3264
3316
 
@@ -3517,12 +3569,14 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
3517
3569
  const {
3518
3570
  badge,
3519
3571
  description,
3572
+ downloadCount,
3520
3573
  extensionId,
3521
3574
  extensionUri,
3522
3575
  extensionVersion,
3523
3576
  hasColorTheme,
3524
3577
  iconSrc,
3525
- name
3578
+ name,
3579
+ rating
3526
3580
  } = headerData;
3527
3581
  const readmeUrl = join(extensionUri, 'README.md');
3528
3582
  const changelogUrl = join(extensionUri, 'CHANGELOG.md');
@@ -3559,8 +3613,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
3559
3613
  resources,
3560
3614
  folderSize
3561
3615
  } = await loadSideBarContent(extensionId, extensionVersion, extensionUri, isBuiltin);
3562
- const paddingLeft = 30;
3563
- const paddingRight = 30;
3616
+ const padding = getPadding(width);
3564
3617
  return {
3565
3618
  ...state,
3566
3619
  badge,
@@ -3572,6 +3625,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
3572
3625
  detailsVirtualDom,
3573
3626
  disabled,
3574
3627
  displaySize,
3628
+ downloadCount,
3575
3629
  extension,
3576
3630
  extensionId,
3577
3631
  extensionUri,
@@ -3584,6 +3638,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
3584
3638
  installationEntries,
3585
3639
  marketplaceEntries,
3586
3640
  name,
3641
+ rating,
3587
3642
  readmeScrollTop,
3588
3643
  readmeUrl,
3589
3644
  resources,
@@ -3593,8 +3648,8 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
3593
3648
  sizeOnDisk: size,
3594
3649
  sizeValue,
3595
3650
  tabs: enabledTabs,
3596
- paddingLeft,
3597
- paddingRight
3651
+ paddingLeft: padding,
3652
+ paddingRight: padding
3598
3653
  };
3599
3654
  };
3600
3655
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "3.58.0",
3
+ "version": "3.59.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "license": "MIT",
6
6
  "author": "Lvce Editor",