@lvce-editor/extension-detail-view 3.58.0 → 3.60.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.
@@ -2538,7 +2538,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
2538
2538
  selectedTab: '',
2539
2539
  settings: [],
2540
2540
  settingsButtonEnabled: false,
2541
- showAdditionalDetailsBreakpoint: 600,
2541
+ showAdditionalDetailsBreakpoint: 700,
2542
2542
  sizeOnDisk: 0,
2543
2543
  sizeValue: 0,
2544
2544
  tabs: [],
@@ -2548,13 +2548,15 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
2548
2548
  width,
2549
2549
  readmeUrl: '',
2550
2550
  paddingLeft: 0,
2551
- paddingRight: 0
2551
+ paddingRight: 0,
2552
+ showSideBar: true,
2553
+ sideBarWidth: 0
2552
2554
  };
2553
2555
  set(uid, state, state);
2554
2556
  };
2555
2557
 
2556
2558
  const isEqual$3 = (oldState, newState) => {
2557
- return oldState.paddingLeft === newState.paddingLeft && oldState.paddingRight === newState.paddingRight;
2559
+ return oldState.paddingLeft === newState.paddingLeft && oldState.paddingRight === newState.paddingRight && oldState.sideBarWidth === newState.sideBarWidth;
2558
2560
  };
2559
2561
 
2560
2562
  const isEqual$2 = (oldState, newState) => {
@@ -2562,7 +2564,7 @@ const isEqual$2 = (oldState, newState) => {
2562
2564
  };
2563
2565
 
2564
2566
  const isEqual$1 = (oldState, newState) => {
2565
- return oldState.activationEvents === newState.activationEvents && oldState.badge === newState.badge && oldState.categories === newState.categories && oldState.changelogVirtualDom === newState.changelogVirtualDom && oldState.commands === newState.commands && oldState.description === newState.description && oldState.detailsVirtualDom === newState.detailsVirtualDom && oldState.displaySize === newState.displaySize && oldState.extensionId === newState.extensionId && oldState.extensionVersion === newState.extensionVersion && oldState.jsonValidation === newState.jsonValidation && oldState.selectedFeature === newState.selectedFeature && oldState.selectedTab === newState.selectedTab && oldState.settings === newState.settings && oldState.themesMarkdownDom === newState.themesMarkdownDom && oldState.webViews === newState.webViews && oldState.sizeValue === newState.sizeValue;
2567
+ return oldState.activationEvents === newState.activationEvents && oldState.badge === newState.badge && oldState.categories === newState.categories && oldState.changelogVirtualDom === newState.changelogVirtualDom && oldState.commands === newState.commands && oldState.description === newState.description && oldState.detailsVirtualDom === newState.detailsVirtualDom && oldState.displaySize === newState.displaySize && oldState.extensionId === newState.extensionId && oldState.extensionVersion === newState.extensionVersion && oldState.jsonValidation === newState.jsonValidation && oldState.selectedFeature === newState.selectedFeature && oldState.selectedTab === newState.selectedTab && oldState.settings === newState.settings && oldState.themesMarkdownDom === newState.themesMarkdownDom && oldState.webViews === newState.webViews && oldState.sizeValue === newState.sizeValue && oldState.showSideBar === newState.showSideBar;
2566
2568
  };
2567
2569
 
2568
2570
  const User = 1;
@@ -2847,6 +2849,13 @@ const isEnoentError = error => {
2847
2849
  return error && error.code === ENOENT;
2848
2850
  };
2849
2851
 
2852
+ /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
2853
+ const error = async error => {
2854
+ // TODO send message to error worker or log worker
2855
+ // @ts-ignore
2856
+ console.error(message);
2857
+ };
2858
+
2850
2859
  const join = (...parts) => {
2851
2860
  return parts.join('/');
2852
2861
  };
@@ -2856,14 +2865,12 @@ const loadChangelogContent = async path => {
2856
2865
  const changelogUrl = join(path, 'CHANGELOG.md');
2857
2866
  const changelogContent = await readFile(changelogUrl);
2858
2867
  return changelogContent;
2859
- } catch (error) {
2860
- if (isEnoentError(error)) {
2868
+ } catch (error$1) {
2869
+ if (isEnoentError(error$1)) {
2861
2870
  return '';
2862
2871
  }
2863
- // TODO send message to error worker
2864
- // @ts-ignore
2865
- console.error(new VError(error, 'Failed to load Changelog content'));
2866
- return `${error}`;
2872
+ await error(new VError(error$1, 'Failed to load Changelog content'));
2873
+ return `${error$1}`;
2867
2874
  }
2868
2875
  };
2869
2876
 
@@ -3143,6 +3150,38 @@ const getExtensionIdFromUri = uri => {
3143
3150
  return id;
3144
3151
  };
3145
3152
 
3153
+ const interpolate = (value, inMin, inMax, outMin, outMax) => {
3154
+ const clamped = Math.min(Math.max(value, inMin), inMax);
3155
+ const ratio = (clamped - inMin) / (inMax - inMin);
3156
+ const mapped = outMin + ratio * (outMax - outMin);
3157
+ return Math.round(mapped);
3158
+ };
3159
+
3160
+ const getPadding = width => {
3161
+ if (width < 600) {
3162
+ return 10;
3163
+ }
3164
+ if (width < 800) {
3165
+ return 10;
3166
+ }
3167
+ if (width < 1200) {
3168
+ return interpolate(width, 800, 1200, 10, 30);
3169
+ }
3170
+ return 30;
3171
+ };
3172
+ const getSideBarWidth = width => {
3173
+ if (width < 490) {
3174
+ return 0;
3175
+ }
3176
+ if (width < 650) {
3177
+ return Math.max(175 + Math.round(20 * (width / 100)), Math.round(width / 4));
3178
+ }
3179
+ if (width < 800) {
3180
+ return Math.max(175 + Math.round(20 * (width / 100)), Math.round(width / 4));
3181
+ }
3182
+ return Math.max(175 + Math.round(20 * (width / 100)), Math.round(width / 4));
3183
+ };
3184
+
3146
3185
  const getTabs = (selectedTab, hasReadme, hasFeatures, hasChangelog) => {
3147
3186
  const tabs = [{
3148
3187
  label: details(),
@@ -3224,6 +3263,36 @@ const getName = extension => {
3224
3263
  return 'n/a';
3225
3264
  };
3226
3265
 
3266
+ const getDownloadCount = extension => {
3267
+ if (!extension) {
3268
+ return 'n/a';
3269
+ }
3270
+
3271
+ // Check for download count in various possible locations
3272
+ const downloadCount = extension.downloadCount || extension.downloads || extension.marketplace?.downloadCount || extension.marketplace?.downloads || extension.packageJSON?.downloadCount || extension.packageJSON?.downloads;
3273
+ if (!downloadCount) {
3274
+ return 'n/a';
3275
+ }
3276
+
3277
+ // Format the number with commas for better readability
3278
+ return downloadCount.toLocaleString();
3279
+ };
3280
+
3281
+ const getRating = extension => {
3282
+ if (!extension) {
3283
+ return 'n/a';
3284
+ }
3285
+
3286
+ // Check for rating in various possible locations
3287
+ const rating = extension.rating || extension.averageRating || extension.marketplace?.rating || extension.marketplace?.averageRating || extension.packageJSON?.rating || extension.packageJSON?.averageRating;
3288
+ if (!rating) {
3289
+ return 'n/a';
3290
+ }
3291
+
3292
+ // Format rating to one decimal place
3293
+ return rating.toFixed(1);
3294
+ };
3295
+
3227
3296
  const getBadge = (builtin, badgeEnabled) => {
3228
3297
  if (builtin && badgeEnabled) {
3229
3298
  return 'builtin';
@@ -3249,16 +3318,20 @@ const loadHeaderContent = (state, platform, extension) => {
3249
3318
  const hasColorTheme = hasColorThemes(extension);
3250
3319
  const isBuiltin = extension?.builtin;
3251
3320
  const badge = getBadge(isBuiltin, builtinExtensionsBadgeEnabled);
3321
+ const downloadCount = getDownloadCount(extension);
3322
+ const rating = getRating(extension);
3252
3323
  return {
3253
3324
  badge,
3254
3325
  description,
3326
+ downloadCount,
3255
3327
  extension,
3256
3328
  extensionId,
3257
3329
  extensionUri,
3258
3330
  extensionVersion,
3259
3331
  hasColorTheme,
3260
3332
  iconSrc,
3261
- name
3333
+ name,
3334
+ rating
3262
3335
  };
3263
3336
  };
3264
3337
 
@@ -3517,12 +3590,14 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
3517
3590
  const {
3518
3591
  badge,
3519
3592
  description,
3593
+ downloadCount,
3520
3594
  extensionId,
3521
3595
  extensionUri,
3522
3596
  extensionVersion,
3523
3597
  hasColorTheme,
3524
3598
  iconSrc,
3525
- name
3599
+ name,
3600
+ rating
3526
3601
  } = headerData;
3527
3602
  const readmeUrl = join(extensionUri, 'README.md');
3528
3603
  const changelogUrl = join(extensionUri, 'CHANGELOG.md');
@@ -3559,8 +3634,9 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
3559
3634
  resources,
3560
3635
  folderSize
3561
3636
  } = await loadSideBarContent(extensionId, extensionVersion, extensionUri, isBuiltin);
3562
- const paddingLeft = 30;
3563
- const paddingRight = 30;
3637
+ const padding = getPadding(width);
3638
+ const sideBarWidth = getSideBarWidth(width);
3639
+ const showSideBar = sideBarWidth > 0;
3564
3640
  return {
3565
3641
  ...state,
3566
3642
  badge,
@@ -3572,6 +3648,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
3572
3648
  detailsVirtualDom,
3573
3649
  disabled,
3574
3650
  displaySize,
3651
+ downloadCount,
3575
3652
  extension,
3576
3653
  extensionId,
3577
3654
  extensionUri,
@@ -3584,17 +3661,20 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
3584
3661
  installationEntries,
3585
3662
  marketplaceEntries,
3586
3663
  name,
3664
+ paddingLeft: padding,
3665
+ paddingRight: padding,
3666
+ rating,
3587
3667
  readmeScrollTop,
3588
3668
  readmeUrl,
3589
3669
  resources,
3590
3670
  scrollSource: Script,
3591
3671
  scrollToTopButtonEnabled: true,
3592
3672
  selectedTab,
3673
+ showSideBar,
3674
+ sideBarWidth,
3593
3675
  sizeOnDisk: size,
3594
3676
  sizeValue,
3595
- tabs: enabledTabs,
3596
- paddingLeft,
3597
- paddingRight
3677
+ tabs: enabledTabs
3598
3678
  };
3599
3679
  };
3600
3680
 
@@ -3627,11 +3707,13 @@ const renderCss = (oldState, newState) => {
3627
3707
  const {
3628
3708
  uid,
3629
3709
  paddingLeft,
3630
- paddingRight
3710
+ paddingRight,
3711
+ sideBarWidth
3631
3712
  } = newState;
3632
3713
  const css = createCss({
3633
3714
  ExtensionDetailPaddingLeft: paddingLeft,
3634
- ExtensionDetailPaddingRight: paddingRight
3715
+ ExtensionDetailPaddingRight: paddingRight,
3716
+ ExtensionDetailSideBarWidth: sideBarWidth
3635
3717
  });
3636
3718
  return ['Viewlet.setCss', uid, css];
3637
3719
  };
@@ -3802,12 +3884,12 @@ const getChildCount = (additionalDetails, scrollToTopEnabled) => {
3802
3884
  }
3803
3885
  return count;
3804
3886
  };
3805
- const getDetailsVirtualDom = (sanitizedReadmeHtml, width, scrollToTopButtonEnabled, categories$1, resources$1, showAdditionalDetailsBreakpoint, installationEntries, marketplaceEntries, hasReadme) => {
3887
+ const getDetailsVirtualDom = (sanitizedReadmeHtml, width, scrollToTopButtonEnabled, categories$1, resources$1, showAdditionalDetailsBreakpoint, installationEntries, marketplaceEntries, hasReadme, showSideBar) => {
3806
3888
  const firstHeading = installation();
3807
3889
  const secondHeading = marketplace();
3808
3890
  const thirdHeading = categories();
3809
3891
  const fourthHeading = resources();
3810
- const showAdditionalDetails = width > showAdditionalDetailsBreakpoint;
3892
+ const showAdditionalDetails = showSideBar;
3811
3893
  const childCount = getChildCount(showAdditionalDetails);
3812
3894
  const contentDom = hasReadme ? sanitizedReadmeHtml : [{
3813
3895
  type: VirtualDomElements.Div,
@@ -3879,7 +3961,7 @@ const getFeaturesVirtualDom = (features, selectedFeature, state) => {
3879
3961
  const getExtensionDetailContentVirtualDom = (sanitizedReadmeHtml, selectedTab, width, scrollToTopButtonEnabled, categories, resources, breakpoint, changelogDom, state) => {
3880
3962
  switch (selectedTab) {
3881
3963
  case Details:
3882
- return getDetailsVirtualDom(sanitizedReadmeHtml, width, scrollToTopButtonEnabled, categories, resources, breakpoint, state.installationEntries, state.marketplaceEntries, state.hasReadme);
3964
+ return getDetailsVirtualDom(sanitizedReadmeHtml, width, scrollToTopButtonEnabled, categories, resources, breakpoint, state.installationEntries, state.marketplaceEntries, state.hasReadme, state.showSideBar);
3883
3965
  case Features:
3884
3966
  return getFeaturesVirtualDom(state.features, state.selectedFeature, state);
3885
3967
  case Changelog:
@@ -4181,9 +4263,16 @@ const renderEventListeners = () => {
4181
4263
  };
4182
4264
 
4183
4265
  const resize = (state, dimensions) => {
4266
+ const padding = getPadding(dimensions.width);
4267
+ const sideBarWidth = getSideBarWidth(dimensions.width);
4268
+ const showSideBar = sideBarWidth > 0;
4184
4269
  return {
4185
4270
  ...state,
4186
- ...dimensions
4271
+ ...dimensions,
4272
+ showSideBar,
4273
+ paddingLeft: padding,
4274
+ paddingRight: padding,
4275
+ sideBarWidth
4187
4276
  };
4188
4277
  };
4189
4278
 
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.60.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "license": "MIT",
6
6
  "author": "Lvce Editor",