@contentful/experiences-visual-editor-react 1.36.0-dev-20250417T1301-b6204ec.0 → 1.36.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.
package/dist/renderApp.js CHANGED
@@ -43892,69 +43892,6 @@ var CodeNames$1;
43892
43892
  CodeNames["Custom"] = "custom";
43893
43893
  })(CodeNames$1 || (CodeNames$1 = {}));
43894
43894
 
43895
- function getOptimizedImageUrl(url, width, quality, format) {
43896
- if (url.startsWith('//')) {
43897
- url = 'https:' + url;
43898
- }
43899
- const params = new URLSearchParams();
43900
- if (width) {
43901
- params.append('w', width.toString());
43902
- }
43903
- if (quality && quality > 0 && quality < 100) {
43904
- params.append('q', quality.toString());
43905
- }
43906
- if (format) {
43907
- params.append('fm', format);
43908
- }
43909
- const queryString = params.toString();
43910
- return `${url}${queryString ? '?' + queryString : ''}`;
43911
- }
43912
-
43913
- function validateParams(file, quality, format) {
43914
- if (!file.details.image) {
43915
- throw Error('No image in file asset to transform');
43916
- }
43917
- if (quality < 0 || quality > 100) {
43918
- throw Error('Quality must be between 0 and 100');
43919
- }
43920
- if (format && !SUPPORTED_IMAGE_FORMATS.includes(format)) {
43921
- throw Error(`Format must be one of ${SUPPORTED_IMAGE_FORMATS.join(', ')}`);
43922
- }
43923
- return true;
43924
- }
43925
-
43926
- const MAX_WIDTH_ALLOWED$1 = 2000;
43927
- const getOptimizedBackgroundImageAsset = (file, widthStyle, quality = '100%', format) => {
43928
- const qualityNumber = Number(quality.replace('%', ''));
43929
- if (!validateParams(file, qualityNumber, format)) ;
43930
- if (!validateParams(file, qualityNumber, format)) ;
43931
- const url = file.url;
43932
- const { width1x, width2x } = getWidths(widthStyle, file);
43933
- const imageUrl1x = getOptimizedImageUrl(url, width1x, qualityNumber, format);
43934
- const imageUrl2x = getOptimizedImageUrl(url, width2x, qualityNumber, format);
43935
- const srcSet = [`url(${imageUrl1x}) 1x`, `url(${imageUrl2x}) 2x`];
43936
- const returnedUrl = getOptimizedImageUrl(url, width2x, qualityNumber, format);
43937
- const optimizedBackgroundImageAsset = {
43938
- url: returnedUrl,
43939
- srcSet,
43940
- file,
43941
- };
43942
- return optimizedBackgroundImageAsset;
43943
- function getWidths(widthStyle, file) {
43944
- let width1x = 0;
43945
- let width2x = 0;
43946
- const intrinsicImageWidth = file.details.image.width;
43947
- if (widthStyle.endsWith('px')) {
43948
- width1x = Math.min(Number(widthStyle.replace('px', '')), intrinsicImageWidth);
43949
- }
43950
- else {
43951
- width1x = Math.min(MAX_WIDTH_ALLOWED$1, intrinsicImageWidth);
43952
- }
43953
- width2x = Math.min(width1x * 2, intrinsicImageWidth);
43954
- return { width1x, width2x };
43955
- }
43956
- };
43957
-
43958
43895
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
43959
43896
  function get(obj, path) {
43960
43897
  if (!path.length) {
@@ -44025,6 +43962,69 @@ const resolveLinks = (node, entityStore) => {
44025
43962
  }
44026
43963
  };
44027
43964
 
43965
+ function getOptimizedImageUrl(url, width, quality, format) {
43966
+ if (url.startsWith('//')) {
43967
+ url = 'https:' + url;
43968
+ }
43969
+ const params = new URLSearchParams();
43970
+ if (width) {
43971
+ params.append('w', width.toString());
43972
+ }
43973
+ if (quality && quality > 0 && quality < 100) {
43974
+ params.append('q', quality.toString());
43975
+ }
43976
+ if (format) {
43977
+ params.append('fm', format);
43978
+ }
43979
+ const queryString = params.toString();
43980
+ return `${url}${queryString ? '?' + queryString : ''}`;
43981
+ }
43982
+
43983
+ function validateParams(file, quality, format) {
43984
+ if (!file.details.image) {
43985
+ throw Error('No image in file asset to transform');
43986
+ }
43987
+ if (quality < 0 || quality > 100) {
43988
+ throw Error('Quality must be between 0 and 100');
43989
+ }
43990
+ if (format && !SUPPORTED_IMAGE_FORMATS.includes(format)) {
43991
+ throw Error(`Format must be one of ${SUPPORTED_IMAGE_FORMATS.join(', ')}`);
43992
+ }
43993
+ return true;
43994
+ }
43995
+
43996
+ const MAX_WIDTH_ALLOWED$1 = 2000;
43997
+ const getOptimizedBackgroundImageAsset = (file, widthStyle, quality = '100%', format) => {
43998
+ const qualityNumber = Number(quality.replace('%', ''));
43999
+ if (!validateParams(file, qualityNumber, format)) ;
44000
+ if (!validateParams(file, qualityNumber, format)) ;
44001
+ const url = file.url;
44002
+ const { width1x, width2x } = getWidths(widthStyle, file);
44003
+ const imageUrl1x = getOptimizedImageUrl(url, width1x, qualityNumber, format);
44004
+ const imageUrl2x = getOptimizedImageUrl(url, width2x, qualityNumber, format);
44005
+ const srcSet = [`url(${imageUrl1x}) 1x`, `url(${imageUrl2x}) 2x`];
44006
+ const returnedUrl = getOptimizedImageUrl(url, width2x, qualityNumber, format);
44007
+ const optimizedBackgroundImageAsset = {
44008
+ url: returnedUrl,
44009
+ srcSet,
44010
+ file,
44011
+ };
44012
+ return optimizedBackgroundImageAsset;
44013
+ function getWidths(widthStyle, file) {
44014
+ let width1x = 0;
44015
+ let width2x = 0;
44016
+ const intrinsicImageWidth = file.details.image.width;
44017
+ if (widthStyle.endsWith('px')) {
44018
+ width1x = Math.min(Number(widthStyle.replace('px', '')), intrinsicImageWidth);
44019
+ }
44020
+ else {
44021
+ width1x = Math.min(MAX_WIDTH_ALLOWED$1, intrinsicImageWidth);
44022
+ }
44023
+ width2x = Math.min(width1x * 2, intrinsicImageWidth);
44024
+ return { width1x, width2x };
44025
+ }
44026
+ };
44027
+
44028
44028
  const MAX_WIDTH_ALLOWED = 4000;
44029
44029
  const getOptimizedImageAsset = ({ file, sizes, loading, quality = '100%', format, }) => {
44030
44030
  const qualityNumber = Number(quality.replace('%', ''));