oasys-lib 2.24.0 → 2.25.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.
@@ -501,6 +501,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
501
501
  type: Input
502
502
  }] } });
503
503
 
504
+ const IMAGE_URL_PROVIDER = new InjectionToken('IMAGE_URL_PROVIDER');
505
+ const IMAGE_BREAKPOINTS = new InjectionToken('IMAGE_BREAKPOINTS', {
506
+ providedIn: 'root',
507
+ factory: () => [
508
+ 320, 360, 375, 414, 640, 750, 768, 1080, 1280, 1366, 1440, 1536, 1600, 1680, 1920, 2560, 3440,
509
+ 3840,
510
+ ],
511
+ });
512
+
504
513
  const MEDIA_BASE_URL_TOKEN = new InjectionToken('MEDIA_BASE_URL_TOKEN');
505
514
 
506
515
  const ROUTING_HANDLER = new InjectionToken('ROUTING_HANDLER');
@@ -955,13 +964,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
955
964
  }]
956
965
  }] });
957
966
 
967
+ /**
968
+ * @deprecated Use IMAGE_URL_PROVIDER token instead. This service will be removed in a future major version.
969
+ * Consuming applications should provide their own ImageUrlProvider implementation via the token.
970
+ */
958
971
  class ImageService {
959
972
  mediaUrl = inject(MEDIA_BASE_URL_TOKEN).mediaBaseUrl;
960
- fallbackBreakpoint = 768;
961
- breakpoints = [
962
- 320, 360, 375, 414, 640, 750, 768, 1080, 1280, 1366, 1440, 1536, 1600, 1680, 1920, 2560, 3440,
963
- 3840,
964
- ];
965
973
  getQualityForWidth(width) {
966
974
  return width > 1440 ? 50 : 75;
967
975
  }
@@ -997,18 +1005,18 @@ class ImageService {
997
1005
  getImageUrlsFromCDN(baseUrl, format, sizes, isFallback) {
998
1006
  const cdnType = this.detectCdnType(baseUrl);
999
1007
  if (isFallback) {
1000
- sizes = [this.fallbackBreakpoint];
1008
+ sizes = [sizes[0]];
1001
1009
  }
1002
1010
  return this.generateUrls(baseUrl, format, sizes, isFallback, cdnType);
1003
1011
  }
1004
- generateImageUrl(baseUrl) {
1012
+ generateImageUrl(sourceUrl, breakpoints, fallbackBreakpoint) {
1005
1013
  return {
1006
- srcSetUrls: this.getImageUrlsFromCDN(baseUrl, 'webp', this.breakpoints, false),
1007
- fallbackUrl: this.getImageUrlsFromCDN(baseUrl, 'jpg', this.breakpoints, true),
1014
+ srcSetUrls: this.getImageUrlsFromCDN(sourceUrl, 'webp', breakpoints, false),
1015
+ fallbackUrl: this.getImageUrlsFromCDN(sourceUrl, 'jpg', [fallbackBreakpoint], true),
1008
1016
  };
1009
1017
  }
1010
- getImageSizes() {
1011
- return this.breakpoints.map((size) => `(max-width: ${size}px) ${size}px`).join(', ');
1018
+ getImageSizes(breakpoints) {
1019
+ return breakpoints.map((size) => `(max-width: ${size}px) ${size}px`).join(', ');
1012
1020
  }
1013
1021
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: ImageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1014
1022
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: ImageService, providedIn: 'root' });
@@ -1037,13 +1045,16 @@ class ImageComponent {
1037
1045
  preload_aspect_ratio = '1:1';
1038
1046
  image_width = null; // source when defining sizes either relates on viewport width or a specificed width in pixels
1039
1047
  image_loaded = new EventEmitter();
1040
- imageService = inject(ImageService);
1048
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- ImageService is the backwards-compatible fallback until consumers provide IMAGE_URL_PROVIDER
1049
+ imageUrlProvider = inject(IMAGE_URL_PROVIDER, { optional: true }) ?? inject(ImageService);
1041
1050
  el = inject((ElementRef));
1042
1051
  image = signal(null, ...(ngDevMode ? [{ debugName: "image" }] : []));
1043
- imageSizes = this.imageService.getImageSizes();
1052
+ breakpoints = inject(IMAGE_BREAKPOINTS);
1053
+ fallbackBreakpoint = 768;
1054
+ imageSizes = this.breakpoints.map((size) => `(max-width: ${size}px) ${size}px`).join(', ');
1044
1055
  intersectionObserver = null;
1045
1056
  get class() {
1046
- return `${this.image_fill ? 'imageFill' : ''}`;
1057
+ return this.image_fill ? 'imageFill' : '';
1047
1058
  }
1048
1059
  /**
1049
1060
  * On init lifecycle hook to create the image.
@@ -1056,10 +1067,10 @@ class ImageComponent {
1056
1067
  * On changes, handle any changes in input properties.
1057
1068
  */
1058
1069
  ngOnChanges(changes) {
1059
- if (changes['image_src'] || changes['image_width'] || changes['preload_aspect_ratio']) {
1070
+ if ('image_src' in changes || 'image_width' in changes || 'preload_aspect_ratio' in changes) {
1060
1071
  this.createImage();
1061
1072
  this.cleanupObserver();
1062
- this.setupLazyLoading();
1073
+ void this.setupLazyLoading();
1063
1074
  }
1064
1075
  }
1065
1076
  /**
@@ -1073,7 +1084,7 @@ class ImageComponent {
1073
1084
  */
1074
1085
  createImage() {
1075
1086
  const ratios = this.preload_aspect_ratio.split(':');
1076
- const imageUrlResponse = this.imageService.generateImageUrl(this.image_src);
1087
+ const imageUrlResponse = this.imageUrlProvider.generateImageUrl(this.image_src, this.breakpoints, this.fallbackBreakpoint);
1077
1088
  const newImage = {
1078
1089
  ...imageUrlResponse,
1079
1090
  ratioWidth: parseInt(ratios[0], 10),
@@ -4238,5 +4249,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
4238
4249
  * Generated bundle index. Do not edit.
4239
4250
  */
4240
4251
 
4241
- export { BannerComponent, BreadcrumbsComponent, CardComponent, CarouselComponent, CheckboxComponent, ChipComponent, ComboboxComponent, DividerComponent, FormErrorsComponent, FormGroupComponent, HeroComponent, IconComponent, ImageComponent, LayoutBoxComponent, LayoutContainerComponent, LayoutGridColumnComponent, LayoutGridComponent, LayoutStackComponent, MEDIA_BASE_URL_TOKEN, OasysAlertCancelDirective, OasysAlertComponent, OasysAlertConfirmDirective, OasysAlertContentDirective, OasysAlertModule, OasysAlertTitleDirective, BannerComponent as OasysBannerComponent, OasysBannerModule, OasysBreadcrumbModule, BreadcrumbsComponent as OasysBreadcrumbsComponent, OasysButtonComponent, OasysButtonGroupComponent, OasysButtonGroupModule, OasysButtonModule, CardComponent as OasysCardComponent, OasysCardModule, CarouselComponent as OasysCarouselComponent, OasysCarouselModule, CheckboxComponent as OasysCheckboxComponent, OasysCheckboxModule, ChipComponent as OasysChipComponent, OasysChipModule, ComboboxComponent as OasysComboboxComponent, OasysComboboxModule, DividerComponent as OasysDividerComponent, OasysDividerModule, FormErrorsComponent as OasysFormErrorsComponent, OasysFormErrorsModule, OasysFormErrorsSummaryComponent, OasysFormErrorsSummaryItemComponent, OasysFormErrorsSummaryTitleComponent, FormGroupComponent as OasysFormGroupComponent, OasysFormGroupModule, OasysHeadingComponent, OasysHeadingModule, HeroComponent as OasysHeroComponent, OasysHeroModule, IconComponent as OasysIconComponent, OasysIconModule, ImageComponent as OasysImageComponent, OasysImageModule, LayoutBoxComponent as OasysLayoutBoxComponent, LayoutContainerComponent as OasysLayoutContainerComponent, LayoutGridColumnComponent as OasysLayoutGridColumnComponent, LayoutGridComponent as OasysLayoutGridComponent, OasysLayoutModule, LayoutStackComponent as OasysLayoutStackComponent, OasysPillComponent, OasysPillGroupComponent, OasysPillGroupModule, OasysPillModule, ProgressBarComponent as OasysProgressBarComponent, PromoCardComponent as OasysPromoCardComponent, OasysPromoCardModule, RadioComponent as OasysRadioComponent, OasysRadioModule, SectionComponent as OasysSectionComponent, SelectCardComponent as OasysSelectCardComponent, OasysSelectCardModule, SeoBlockComponent as OasysSeoBlockComponent, OasysSeoBlockModule, OasysTabComponent, OasysTabGroupComponent, OasysTabsModule, TextComponent as OasysTextComponent, TextInputComponent as OasysTextInputComponent, OasysTextInputModule, OasysTextModule, ProgressBarComponent, PromoCardComponent, ROUTING_HANDLER, RadioComponent, SWIPER_PROVIDER_TOKEN, SectionComponent, SectionModule, SelectCardComponent, SeoBlockComponent, SwiperProvider, TextComponent };
4252
+ export { BannerComponent, BreadcrumbsComponent, CardComponent, CarouselComponent, CheckboxComponent, ChipComponent, ComboboxComponent, DividerComponent, FormErrorsComponent, FormGroupComponent, HeroComponent, IMAGE_BREAKPOINTS, IMAGE_URL_PROVIDER, IconComponent, ImageComponent, LayoutBoxComponent, LayoutContainerComponent, LayoutGridColumnComponent, LayoutGridComponent, LayoutStackComponent, MEDIA_BASE_URL_TOKEN, OasysAlertCancelDirective, OasysAlertComponent, OasysAlertConfirmDirective, OasysAlertContentDirective, OasysAlertModule, OasysAlertTitleDirective, BannerComponent as OasysBannerComponent, OasysBannerModule, OasysBreadcrumbModule, BreadcrumbsComponent as OasysBreadcrumbsComponent, OasysButtonComponent, OasysButtonGroupComponent, OasysButtonGroupModule, OasysButtonModule, CardComponent as OasysCardComponent, OasysCardModule, CarouselComponent as OasysCarouselComponent, OasysCarouselModule, CheckboxComponent as OasysCheckboxComponent, OasysCheckboxModule, ChipComponent as OasysChipComponent, OasysChipModule, ComboboxComponent as OasysComboboxComponent, OasysComboboxModule, DividerComponent as OasysDividerComponent, OasysDividerModule, FormErrorsComponent as OasysFormErrorsComponent, OasysFormErrorsModule, OasysFormErrorsSummaryComponent, OasysFormErrorsSummaryItemComponent, OasysFormErrorsSummaryTitleComponent, FormGroupComponent as OasysFormGroupComponent, OasysFormGroupModule, OasysHeadingComponent, OasysHeadingModule, HeroComponent as OasysHeroComponent, OasysHeroModule, IconComponent as OasysIconComponent, OasysIconModule, ImageComponent as OasysImageComponent, OasysImageModule, LayoutBoxComponent as OasysLayoutBoxComponent, LayoutContainerComponent as OasysLayoutContainerComponent, LayoutGridColumnComponent as OasysLayoutGridColumnComponent, LayoutGridComponent as OasysLayoutGridComponent, OasysLayoutModule, LayoutStackComponent as OasysLayoutStackComponent, OasysPillComponent, OasysPillGroupComponent, OasysPillGroupModule, OasysPillModule, ProgressBarComponent as OasysProgressBarComponent, PromoCardComponent as OasysPromoCardComponent, OasysPromoCardModule, RadioComponent as OasysRadioComponent, OasysRadioModule, SectionComponent as OasysSectionComponent, SelectCardComponent as OasysSelectCardComponent, OasysSelectCardModule, SeoBlockComponent as OasysSeoBlockComponent, OasysSeoBlockModule, OasysTabComponent, OasysTabGroupComponent, OasysTabsModule, TextComponent as OasysTextComponent, TextInputComponent as OasysTextInputComponent, OasysTextInputModule, OasysTextModule, ProgressBarComponent, PromoCardComponent, ROUTING_HANDLER, RadioComponent, SWIPER_PROVIDER_TOKEN, SectionComponent, SectionModule, SelectCardComponent, SeoBlockComponent, SwiperProvider, TextComponent };
4242
4253
  //# sourceMappingURL=oasys-lib.mjs.map