next-cloudinary 2.0.0 → 2.1.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/README.md CHANGED
@@ -20,6 +20,8 @@ High-performance image delivery and uploading at scale in Next.js powered by Clo
20
20
 
21
21
  <a href="#-features">Features</a> • <a href="#-getting-started">Getting Started</a> • <a href="#%EF%B8%8F-community--support">Community & Support</a> • <a href="#-contributing">Contributing</a>
22
22
 
23
+ **This plugin is a community library and not officially supported by Cloudinary.**
24
+
23
25
  ## ✨ Features
24
26
 
25
27
  * Automatically optimize images and deliver in modern formats
@@ -31,7 +33,6 @@ High-performance image delivery and uploading at scale in Next.js powered by Clo
31
33
  * Drop-in Upload Widget
32
34
  * ...all at scale with Cloudinary
33
35
 
34
- **This plugin is a community library and not officially supported by Cloudinary.**
35
36
 
36
37
  ## 🚀 Getting Started
37
38
 
@@ -42,7 +42,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
42
42
  }
43
43
 
44
44
  var name = "next-cloudinary";
45
- var version = "2.0.0";
45
+ var version = "2.1.0";
46
46
  var main = "dist/next-cloudinary.umd.js";
47
47
  var module$1 = "dist/next-cloudinary.module.js";
48
48
  var source = "src/index.ts";
@@ -55,7 +55,7 @@ var scripts = {
55
55
  };
56
56
  var dependencies = {
57
57
  "@cloudinary-util/url-loader": "^1.2.4",
58
- "@cloudinary-util/util": "^1.1.1",
58
+ "@cloudinary-util/util": "^1.2.0",
59
59
  "@cloudinary/url-gen": "^1.8.6"
60
60
  };
61
61
  var devDependencies = {
@@ -234,7 +234,7 @@ var CldImage = function CldImage(props) {
234
234
  return Promise.reject(e);
235
235
  }
236
236
  };
237
- var CLD_OPTIONS = ['deliveryType'];
237
+ var CLD_OPTIONS = ['deliveryType', 'preserveTransformations'];
238
238
  urlLoader.transformationPlugins.forEach(function (_ref) {
239
239
  var _ref$props = _ref.props,
240
240
  props = _ref$props === void 0 ? [] : _ref$props;
@@ -245,7 +245,6 @@ var CldImage = function CldImage(props) {
245
245
  CLD_OPTIONS.push(prop);
246
246
  });
247
247
  });
248
- // Construct the base Image component props by filtering out Cloudinary-specific props
249
248
  var imageProps = {
250
249
  alt: props.alt,
251
250
  src: props.src
@@ -261,11 +260,10 @@ var CldImage = function CldImage(props) {
261
260
  var _useState = react.useState(defaultImgKey),
262
261
  imgKey = _useState[0],
263
262
  setImgKey = _useState[1];
264
- // Construct Cloudinary-specific props by looking for values for any of the supported prop keys
265
263
  var cldOptions = {};
266
264
  CLD_OPTIONS.forEach(function (key) {
267
265
  if (props[key]) {
268
- cldOptions[key] = props[key];
266
+ cldOptions[key] = props[key] || undefined;
269
267
  }
270
268
  });
271
269
  // If we see a placeholder option, configure a Cloudinary-based URL.
@@ -294,10 +292,16 @@ var CldImage = function CldImage(props) {
294
292
  imageProps.placeholder = 'blur';
295
293
  }
296
294
  }
297
- if (props.src && props.preserveTransformations) {
298
- var transformations = util.getTransformations(props.src, props.preserveTransformations);
299
- var rawTransformations = imageProps.rawTransformations ? [].concat(imageProps.rawTransformations) : [];
300
- imageProps.rawTransformations = [].concat(rawTransformations, transformations);
295
+ // Try to preserve the original transformations from the Cloudinary URL passed in
296
+ // to the component. This only works if the URL has a version number on it and otherwise
297
+ // will fail to load
298
+ if (props.preserveTransformations) {
299
+ try {
300
+ var transformations = util.getTransformations(props.src);
301
+ cldOptions.rawTransformations = [].concat(transformations.flat(), props.rawTransformations || []);
302
+ } catch (e) {
303
+ console.warn("Failed to preserve transformations: " + e.message);
304
+ }
301
305
  }
302
306
  return /*#__PURE__*/jsxRuntime.jsx(Image__default["default"], _extends({}, imageProps, {
303
307
  loader: function loader(loaderOptions) {
@@ -377,22 +381,38 @@ var CldOgImage = function CldOgImage(_ref) {
377
381
  );
378
382
  };
379
383
 
384
+ var cloudinary;
385
+ var widget;
380
386
  var CldUploadWidget = function CldUploadWidget(_ref) {
381
387
  var children = _ref.children,
382
388
  onUpload = _ref.onUpload,
383
389
  options = _ref.options,
384
390
  signatureEndpoint = _ref.signatureEndpoint,
385
391
  uploadPreset = _ref.uploadPreset;
386
- var cloudinary = react.useRef();
387
- var widget = react.useRef();
388
392
  var signed = !!signatureEndpoint;
393
+ /**
394
+ * handleOnLoad
395
+ * @description Stores the Cloudinary window instance to a ref when the widget script loads
396
+ */
397
+ function handleOnLoad() {
398
+ if (!cloudinary) {
399
+ cloudinary = window.cloudinary;
400
+ }
401
+ // To help improve load time of the widget on first instance, use requestIdleCallback
402
+ // to trigger widget creation. Optional.
403
+ requestIdleCallback(function () {
404
+ if (!widget) {
405
+ widget = createWidget();
406
+ }
407
+ });
408
+ }
389
409
  /**
390
410
  * generateSignature
391
411
  * @description Makes a request to an endpoint to sign Cloudinary parameters as part of widget creation
392
412
  */
393
413
  function generateSignature(callback, paramsToSign) {
394
414
  fetch(signatureEndpoint, {
395
- method: "POST",
415
+ method: 'POST',
396
416
  body: JSON.stringify({
397
417
  paramsToSign: paramsToSign
398
418
  })
@@ -408,7 +428,7 @@ var CldUploadWidget = function CldUploadWidget(_ref) {
408
428
  * @description Creates a new instance of the Cloudinary widget and stores in a ref
409
429
  */
410
430
  function createWidget() {
411
- var _cloudinary$current;
431
+ var _cloudinary;
412
432
  // When creating a signed upload, you need to provide both your Cloudinary API Key
413
433
  // as well as a signature generator function that will sign any paramters
414
434
  // either on page load or during the upload process. Read more about signed uploads at:
@@ -425,13 +445,13 @@ var CldUploadWidget = function CldUploadWidget(_ref) {
425
445
  return new Error("Signed Upload needs apiKey!");
426
446
  }
427
447
  }
428
- return (_cloudinary$current = cloudinary.current) == null ? void 0 : _cloudinary$current.createUploadWidget(uploadOptions, function (error, result) {
448
+ return (_cloudinary = cloudinary) == null ? void 0 : _cloudinary.createUploadWidget(uploadOptions, function (error, result) {
429
449
  // The callback is a bit more chatty than failed or success so
430
450
  // only trigger when one of those are the case. You can additionally
431
451
  // create a separate handler such as onEvent and trigger it on
432
452
  // ever occurrence
433
453
  if (error || result.event === "success") {
434
- onUpload(error, result, widget == null ? void 0 : widget.current);
454
+ onUpload(error, result, widget);
435
455
  }
436
456
  });
437
457
  }
@@ -440,29 +460,18 @@ var CldUploadWidget = function CldUploadWidget(_ref) {
440
460
  * @description When triggered, uses the current widget instance to open the upload modal
441
461
  */
442
462
  function open() {
443
- if (!(widget != null && widget.current)) {
444
- widget.current = createWidget();
463
+ if (!widget) {
464
+ widget = createWidget();
445
465
  }
446
- // @ts-ignore
447
- (widget == null ? void 0 : widget.current) && widget.current.open();
448
- }
449
- /**
450
- * handleOnLoad
451
- * @description Stores the Cloudinary window instance to a ref when the widget script loads
452
- */
453
- function handleOnLoad() {
454
- // @ts-ignore
455
- cloudinary.current = window.cloudinary;
466
+ widget && widget.open();
456
467
  }
457
468
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
458
469
  children: [children({
459
- cloudinary: cloudinary.current,
460
- widget: widget.current,
470
+ cloudinary: cloudinary,
471
+ widget: widget,
461
472
  open: open
462
473
  }), /*#__PURE__*/jsxRuntime.jsx(Script__default["default"], {
463
- id: "cloudinary-" + Math.floor(Math.random() * 100)
464
- // @ts-ignore
465
- ,
474
+ id: "cloudinary-" + Math.floor(Math.random() * 100),
466
475
  src: "https://widget.cloudinary.com/v2.0/global/all.js",
467
476
  onLoad: handleOnLoad,
468
477
  onError: function onError(e) {
@@ -1 +1 @@
1
- {"version":3,"file":"next-cloudinary.js","sources":["../src/constants/analytics.js","../src/lib/cloudinary.ts","../src/loaders/cloudinary-loader.js","../src/components/CldImage/CldImage.tsx","../src/components/CldOgImage/CldOgImage.tsx","../src/components/CldUploadWidget/CldUploadWidget.tsx","../src/components/CldUploadButton/CldUploadButton.tsx"],"sourcesContent":["import nextPkg from 'next/package.json';\nimport pkg from '../../package.json';\n\nexport const NEXT_CLOUDINARY_ANALYTICS_ID = 'V';\nexport const NEXT_CLOUDINARY_VERSION = pkg.version;\nexport const NEXT_VERSION = nextPkg.version;","import { constructCloudinaryUrl } from '@cloudinary-util/url-loader';\n\nimport { NEXT_CLOUDINARY_ANALYTICS_ID, NEXT_CLOUDINARY_VERSION, NEXT_VERSION } from '../constants/analytics';\n\n/**\n * createPlaceholderUrl\n */\n\nexport function createPlaceholderUrl({ src, placeholder = true }: { src?: any, placeholder?: boolean | string, config?: any }) {\n const rawTransformations: string[] = [];\n\n if ( placeholder === 'grayscale' ) {\n rawTransformations.push('e_grayscale');\n }\n\n if ( typeof placeholder === 'string' && placeholder.includes('color:') ) {\n const color = placeholder.split(':').splice(1).join(':')\n rawTransformations.push('e_grayscale');\n rawTransformations.push(`e_colorize:60,co_${color}`);\n }\n\n return constructCloudinaryUrl({\n options: {\n src,\n width: 100,\n quality: 1,\n rawTransformations,\n },\n config: {\n cloud: {\n cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME\n }\n },\n analytics: {\n sdkCode: NEXT_CLOUDINARY_ANALYTICS_ID,\n sdkSemver: NEXT_CLOUDINARY_VERSION,\n techVersion: NEXT_VERSION,\n feature: ''\n }\n });\n}\n\n/**\n * pollForProcessingImage\n */\n\nexport async function pollForProcessingImage(options): Promise<boolean> {\n const { src } = options;\n try {\n await new Promise((resolve, reject) => {\n fetch(src).then(res => {\n if ( !res.ok ) {\n reject(res);\n return;\n }\n resolve(res);\n });\n });\n } catch(e: any) {\n if ( e.status === 423 ) {\n return await pollForProcessingImage(options);\n }\n return false;\n }\n return true;\n}","import { constructCloudinaryUrl } from '@cloudinary-util/url-loader';\n\nimport { NEXT_CLOUDINARY_ANALYTICS_ID, NEXT_CLOUDINARY_VERSION, NEXT_VERSION } from '../constants/analytics';\n\nexport function cloudinaryLoader({ loaderOptions, imageProps, cldOptions, cldConfig = {} }) {\n const options = {\n ...imageProps,\n ...cldOptions\n }\n\n options.width = parseInt(options.width);\n options.height = parseInt(options.height);\n\n // The loader options are used to create dynamic sizing when working with responsive images\n // so these should override the default options collected from the props alone if\n // the results are different. While we don't always use the height in the loader logic,\n // we always pass it here, as the usage is determined later based on cropping.js\n\n if ( loaderOptions?.width && loaderOptions.width !== options.width ) {\n const multiplier = loaderOptions.width / options.width;\n options.widthResize = loaderOptions.width;\n options.heightResize = Math.round(options.height * multiplier);\n }\n\n return constructCloudinaryUrl({\n options,\n config: {\n cloud: {\n cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME\n },\n ...cldConfig\n },\n analytics: {\n sdkCode: NEXT_CLOUDINARY_ANALYTICS_ID,\n sdkSemver: NEXT_CLOUDINARY_VERSION,\n techVersion: NEXT_VERSION,\n feature: ''\n }\n });\n}","'use client';\n\nimport { useState } from 'react';\nimport Image from 'next/image';\nimport { getTransformations, getPublicId } from '@cloudinary-util/util';\nimport { transformationPlugins } from '@cloudinary-util/url-loader';\n\nimport { createPlaceholderUrl, pollForProcessingImage } from '../../lib/cloudinary';\n\nimport { cloudinaryLoader } from '../../loaders/cloudinary-loader';\n\ndeclare type PlaceholderValue = 'blur' | 'empty'; // this is from next/image, but isn't exported\n\nconst CldImage = props => {\n const CLD_OPTIONS = [\n 'deliveryType'\n ];\n\n transformationPlugins.forEach(({ props = [] }) => {\n props.forEach(prop => {\n if ( CLD_OPTIONS.includes(prop) ) {\n throw new Error(`Option ${prop} already exists!`);\n }\n CLD_OPTIONS.push(prop);\n });\n })\n\n // Construct the base Image component props by filtering out Cloudinary-specific props\n\n const imageProps: {\n rawTransformations?: string[];\n blurDataURL?: string;\n placeholder?: PlaceholderValue;\n alt: string;\n src: string;\n } = {\n alt: props.alt,\n src: props.src\n };\n\n Object.keys(props)\n .filter(key => !CLD_OPTIONS.includes(key))\n .forEach(key => imageProps[key] = props[key]);\n\n const defaultImgKey = Object.keys(imageProps).map(key => `${key}:${imageProps[key]}`).join(';');\n const [imgKey, setImgKey] = useState(defaultImgKey);\n\n // Construct Cloudinary-specific props by looking for values for any of the supported prop keys\n\n const cldOptions = {};\n\n CLD_OPTIONS.forEach(key => {\n if ( props[key] ) {\n cldOptions[key] = props[key];\n }\n });\n\n // If we see a placeholder option, configure a Cloudinary-based URL.\n // The resulting image will always be blurred per Next.js, so we're\n // limited on options for placeholders.\n //\n // We need to do this logic here as we potentially need to mutate\n // an Image component prop as opposed to simply the URL\n //\n // https://nextjs.org/docs/api-reference/next/image#blurdataurl\n\n if ( imageProps.placeholder ) {\n let publicId;\n\n if ( props.src.startsWith('https://') ) {\n try {\n publicId = getPublicId(props.src);\n } catch(e) {}\n }\n\n if ( !publicId ) {\n publicId = props.src;\n }\n\n imageProps.blurDataURL = createPlaceholderUrl({\n src: publicId,\n placeholder: props.placeholder\n });\n\n if ( imageProps.placeholder !== 'blur' ) {\n imageProps.placeholder = 'blur';\n }\n }\n\n if (props.src && props.preserveTransformations) {\n const transformations = getTransformations(props.src,props.preserveTransformations);\n const rawTransformations = imageProps.rawTransformations ? [...imageProps.rawTransformations] : []\n imageProps.rawTransformations = [...rawTransformations,...transformations,];\n }\n\n /**\n * handleOnError\n */\n\n async function handleOnError(options) {\n const result = await pollForProcessingImage({ src: options.target.src })\n if ( result ) {\n setImgKey(`${defaultImgKey};${Date.now()}`);\n }\n }\n\n return (\n <Image\n key={imgKey}\n {...imageProps}\n loader={(loaderOptions) => cloudinaryLoader({ loaderOptions, imageProps, cldOptions })}\n onError={handleOnError}\n />\n );\n}\n\nexport default CldImage;\n","import Head from 'next/head';\nimport { constructCloudinaryUrl } from '@cloudinary-util/url-loader';\n\nimport { NEXT_CLOUDINARY_ANALYTICS_ID, NEXT_CLOUDINARY_VERSION, NEXT_VERSION } from '../../constants/analytics';\n\nconst IMAGE_WIDTH = 2400;\nconst IMAGE_HEIGHT = 1200;\n\nconst TWITTER_CARD = 'summary_large_image';\n\nconst CldOgImage = ({ excludeTags = [] as string[], twitterTitle, ...props }) => {\n const options = {\n ...props,\n alt: props.alt,\n crop: props.crop || 'fill',\n gravity: props.gravity || 'center',\n height: props.height || IMAGE_HEIGHT,\n src: props.src,\n width: props.width || IMAGE_WIDTH,\n }\n\n const ogImageUrl = constructCloudinaryUrl({\n options,\n config: {\n cloud: {\n cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME\n }\n },\n analytics: {\n sdkCode: NEXT_CLOUDINARY_ANALYTICS_ID,\n sdkSemver: NEXT_CLOUDINARY_VERSION,\n techVersion: NEXT_VERSION,\n feature: ''\n }\n });\n\n // We need to include the tags within the Next.js Head component rather than\n // direcly adding them inside of the Head otherwise we get unexpected results\n\n return (\n // @ts-ignore\n <Head>\n <meta property=\"og:image\" content={ogImageUrl} />\n <meta property=\"og:image:secure_url\" content={ogImageUrl} />\n <meta property=\"og:image:width\" content={options.width} />\n <meta property=\"og:image:height\" content={options.height} />\n\n {options.alt && (\n <meta property=\"og:image:alt\" content={options.alt} />\n )}\n\n {/* Required for summary_large_image, exclude vai excludeTags */}\n {/* https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/summary-card-with-large-image */}\n\n {!excludeTags.includes('twitter:title') && (\n <meta property=\"twitter:title\" content={twitterTitle || ' '} />\n )}\n\n <meta property=\"twitter:card\" content={TWITTER_CARD} />\n <meta property=\"twitter:image\" content={ogImageUrl} />\n </Head>\n );\n}\n\nexport default CldOgImage;","import { useRef } from 'react';\nimport Script from 'next/script';\n\nconst CldUploadWidget = ({\n children,\n onUpload,\n options,\n signatureEndpoint,\n uploadPreset,\n}) => {\n const cloudinary = useRef<any>();\n const widget = useRef();\n\n const signed = !!signatureEndpoint;\n\n /**\n * generateSignature\n * @description Makes a request to an endpoint to sign Cloudinary parameters as part of widget creation\n */\n\n function generateSignature(callback, paramsToSign) {\n fetch(signatureEndpoint, {\n method: \"POST\",\n body: JSON.stringify({\n paramsToSign,\n }),\n })\n .then((r) => r.json())\n .then(({ signature }) => {\n callback(signature);\n });\n }\n\n /**\n * createWidget\n * @description Creates a new instance of the Cloudinary widget and stores in a ref\n */\n\n function createWidget() {\n // When creating a signed upload, you need to provide both your Cloudinary API Key\n // as well as a signature generator function that will sign any paramters\n // either on page load or during the upload process. Read more about signed uploads at:\n // https://cloudinary.com/documentation/upload_widget#signed_uploads\n\n const uploadOptions = {\n cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME,\n uploadPreset: uploadPreset || process.env.NEXT_PUBLIC_CLOUDINARY_UPLOAD_PRESET,\n apiKey: process.env.NEXT_PUBLIC_CLOUDINARY_API_KEY,\n ...options,\n };\n\n if ( signed ) {\n uploadOptions.uploadSignature = generateSignature;\n\n // No need for apiSecret here because of api/sign-cloudinary-params\n\n if (!uploadOptions.apiKey) {\n return new Error(\"Signed Upload needs apiKey!\");\n }\n }\n\n return cloudinary.current?.createUploadWidget(\n uploadOptions,\n function (error, result) {\n // The callback is a bit more chatty than failed or success so\n // only trigger when one of those are the case. You can additionally\n // create a separate handler such as onEvent and trigger it on\n // ever occurrence\n if (error || result.event === \"success\") {\n onUpload(error, result, widget?.current);\n }\n }\n );\n }\n\n /**\n * open\n * @description When triggered, uses the current widget instance to open the upload modal\n */\n\n function open() {\n if (!widget?.current) {\n widget.current = createWidget();\n }\n\n // @ts-ignore\n widget?.current && widget.current.open();\n }\n\n /**\n * handleOnLoad\n * @description Stores the Cloudinary window instance to a ref when the widget script loads\n */\n\n function handleOnLoad() {\n // @ts-ignore\n cloudinary.current = window.cloudinary;\n }\n\n return (\n <>\n {children({\n cloudinary: cloudinary.current,\n widget: widget.current,\n open,\n })}\n <Script\n id={`cloudinary-${Math.floor(Math.random() * 100)}`}\n // @ts-ignore\n src=\"https://widget.cloudinary.com/v2.0/global/all.js\"\n onLoad={handleOnLoad}\n onError={(e) => console.error(`Failed to load Cloudinary: ${e.message}`)}\n />\n </>\n );\n};\n\nexport default CldUploadWidget;\n","import CldUploadWidget from '../CldUploadWidget';\n\nconst CldUploadButton = ({\n children,\n onClick,\n onUpload,\n options,\n signatureEndpoint,\n uploadPreset,\n ...props\n}) => {\n return (\n <>\n {/* @ts-ignore */}\n <CldUploadWidget\n onUpload={onUpload}\n options={options}\n signatureEndpoint={signatureEndpoint}\n uploadPreset={uploadPreset}\n >\n {({ open }) => {\n function handleOnClick(e) {\n e.preventDefault();\n\n open();\n\n if ( typeof onClick === 'function' ) {\n onClick(e);\n }\n }\n return (\n <button {...props} onClick={handleOnClick} >\n {children || 'Upload'}\n </button>\n );\n }}\n </CldUploadWidget>\n </>\n );\n};\n\nexport default CldUploadButton;\n"],"names":["NEXT_CLOUDINARY_ANALYTICS_ID","NEXT_CLOUDINARY_VERSION","pkg","version","NEXT_VERSION","nextPkg","pollForProcessingImage","options","src","Promise","resolve","reject","fetch","then","res","ok","e","status","createPlaceholderUrl","placeholder","rawTransformations","push","includes","color","split","splice","join","constructCloudinaryUrl","width","quality","config","cloud","cloudName","process","env","NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME","analytics","sdkCode","sdkSemver","techVersion","feature","cloudinaryLoader","loaderOptions","imageProps","cldOptions","cldConfig","parseInt","height","multiplier","widthResize","heightResize","Math","round","CldImage","props","handleOnError","target","result","setImgKey","defaultImgKey","Date","now","CLD_OPTIONS","transformationPlugins","forEach","prop","Error","alt","Object","keys","filter","key","map","useState","imgKey","publicId","startsWith","getPublicId","blurDataURL","preserveTransformations","transformations","getTransformations","_jsx","Image","IMAGE_WIDTH","IMAGE_HEIGHT","TWITTER_CARD","CldOgImage","excludeTags","twitterTitle","_excluded","crop","gravity","ogImageUrl","_jsxs","Head","CldUploadWidget","children","onUpload","signatureEndpoint","uploadPreset","cloudinary","useRef","widget","signed","generateSignature","callback","paramsToSign","method","body","JSON","stringify","r","json","signature","createWidget","uploadOptions","NEXT_PUBLIC_CLOUDINARY_UPLOAD_PRESET","apiKey","NEXT_PUBLIC_CLOUDINARY_API_KEY","uploadSignature","current","createUploadWidget","error","event","open","handleOnLoad","window","_Fragment","Script","floor","random","console","message","CldUploadButton","onClick","handleOnClick","preventDefault"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAMA,4BAA4B,GAAG,GAAG,CAAA;A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,QAAQ,QAARA,QAAQ;AACR3F,IAAAA,OAAO,QAAPA,OAAO;AACP4F,IAAAA,iBAAiB,QAAjBA,iBAAiB;AACjBC,IAAAA,YAAY,QAAZA,YAAY;IACT9C,KAAK,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;EAER,oBACE4B,cAAA,CAAA8C,mBAAA,EAAA;AAAA,IAAA,QAAA,eAEE9C,eAAC,eAAe,EAAA;AACd,MAAA,QAAQ,EAAEgB,QAAS;AACnB,MAAA,OAAO,EAAE3F,OAAQ;AACjB,MAAA,iBAAiB,EAAE4F,iBAAkB;AACrC,MAAA,YAAY,EAAEC,YAAa;AAAA,MAAA,QAAA,EAE1B,SAAa,QAAA,CAAA,KAAA,EAAA;QAAA,IAAVyB,IAAI,SAAJA,IAAI,CAAA;QACN,SAASW,aAAa,CAACxH,CAAC,EAAA;UACtBA,CAAC,CAACyH,cAAc,EAAE,CAAA;AAElBZ,UAAAA,IAAI,EAAE,CAAA;AAEN,UAAA,IAAK,OAAOU,OAAO,KAAK,UAAU,EAAG;YACnCA,OAAO,CAACvH,CAAC,CAAC,CAAA;AACX,WAAA;AACH,SAAA;AACA,QAAA,oBACEkE,sCAAY5B,KAAK,EAAA;AAAE,UAAA,OAAO,EAAEkF,aAAc;AAAA,UAAA,QAAA,EACvCvC,SAAQ,IAAI,QAAA;SACN,CAAA,CAAA,CAAA;AAEb,OAAA;AAAC,KAAA,CAAA;GAEF,CAAA,CAAA;AAEP;;;;;;;;"}
1
+ {"version":3,"file":"next-cloudinary.js","sources":["../src/constants/analytics.js","../src/lib/cloudinary.ts","../src/loaders/cloudinary-loader.js","../src/components/CldImage/CldImage.tsx","../src/components/CldOgImage/CldOgImage.tsx","../src/components/CldUploadWidget/CldUploadWidget.tsx","../src/components/CldUploadButton/CldUploadButton.tsx"],"sourcesContent":["import nextPkg from 'next/package.json';\nimport pkg from '../../package.json';\n\nexport const NEXT_CLOUDINARY_ANALYTICS_ID = 'V';\nexport const NEXT_CLOUDINARY_VERSION = pkg.version;\nexport const NEXT_VERSION = nextPkg.version;","import { constructCloudinaryUrl } from '@cloudinary-util/url-loader';\n\nimport { NEXT_CLOUDINARY_ANALYTICS_ID, NEXT_CLOUDINARY_VERSION, NEXT_VERSION } from '../constants/analytics';\n\n/**\n * createPlaceholderUrl\n */\n\nexport function createPlaceholderUrl({ src, placeholder = true }: { src?: any, placeholder?: boolean | string, config?: any }) {\n const rawTransformations: string[] = [];\n\n if ( placeholder === 'grayscale' ) {\n rawTransformations.push('e_grayscale');\n }\n\n if ( typeof placeholder === 'string' && placeholder.includes('color:') ) {\n const color = placeholder.split(':').splice(1).join(':')\n rawTransformations.push('e_grayscale');\n rawTransformations.push(`e_colorize:60,co_${color}`);\n }\n\n return constructCloudinaryUrl({\n options: {\n src,\n width: 100,\n quality: 1,\n rawTransformations,\n },\n config: {\n cloud: {\n cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME\n }\n },\n analytics: {\n sdkCode: NEXT_CLOUDINARY_ANALYTICS_ID,\n sdkSemver: NEXT_CLOUDINARY_VERSION,\n techVersion: NEXT_VERSION,\n feature: ''\n }\n });\n}\n\n/**\n * pollForProcessingImage\n */\n\nexport async function pollForProcessingImage(options): Promise<boolean> {\n const { src } = options;\n try {\n await new Promise((resolve, reject) => {\n fetch(src).then(res => {\n if ( !res.ok ) {\n reject(res);\n return;\n }\n resolve(res);\n });\n });\n } catch(e: any) {\n if ( e.status === 423 ) {\n return await pollForProcessingImage(options);\n }\n return false;\n }\n return true;\n}","import { constructCloudinaryUrl } from '@cloudinary-util/url-loader';\n\nimport { NEXT_CLOUDINARY_ANALYTICS_ID, NEXT_CLOUDINARY_VERSION, NEXT_VERSION } from '../constants/analytics';\n\nexport function cloudinaryLoader({ loaderOptions, imageProps, cldOptions, cldConfig = {} }) {\n const options = {\n ...imageProps,\n ...cldOptions\n }\n\n options.width = parseInt(options.width);\n options.height = parseInt(options.height);\n\n // The loader options are used to create dynamic sizing when working with responsive images\n // so these should override the default options collected from the props alone if\n // the results are different. While we don't always use the height in the loader logic,\n // we always pass it here, as the usage is determined later based on cropping.js\n\n if ( loaderOptions?.width && loaderOptions.width !== options.width ) {\n const multiplier = loaderOptions.width / options.width;\n options.widthResize = loaderOptions.width;\n options.heightResize = Math.round(options.height * multiplier);\n }\n\n return constructCloudinaryUrl({\n options,\n config: {\n cloud: {\n cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME\n },\n ...cldConfig\n },\n analytics: {\n sdkCode: NEXT_CLOUDINARY_ANALYTICS_ID,\n sdkSemver: NEXT_CLOUDINARY_VERSION,\n techVersion: NEXT_VERSION,\n feature: ''\n }\n });\n}","'use client';\n\nimport { useState } from 'react';\nimport Image from 'next/image';\nimport { getTransformations, getPublicId } from '@cloudinary-util/util';\nimport { transformationPlugins } from '@cloudinary-util/url-loader';\n\nimport { createPlaceholderUrl, pollForProcessingImage } from '../../lib/cloudinary';\n\nimport { cloudinaryLoader } from '../../loaders/cloudinary-loader';\n\nconst CldImage = props => {\n const CLD_OPTIONS = [\n 'deliveryType',\n 'preserveTransformations'\n ];\n\n transformationPlugins.forEach(({ props = [] }) => {\n props.forEach(prop => {\n if ( CLD_OPTIONS.includes(prop) ) {\n throw new Error(`Option ${prop} already exists!`);\n }\n CLD_OPTIONS.push(prop);\n });\n })\n\n // Construct the base Image component props by filtering out Cloudinary-specific props\n\n interface ImageProps {\n alt: string;\n blurDataURL?: string;\n placeholder?: 'blur' | 'empty'; // this is from next/image, but isn't exported\n src: string;\n }\n\n const imageProps: ImageProps = {\n alt: props.alt,\n src: props.src\n };\n\n Object.keys(props)\n .filter(key => !CLD_OPTIONS.includes(key))\n .forEach(key => imageProps[key] = props[key]);\n\n const defaultImgKey = Object.keys(imageProps).map(key => `${key}:${imageProps[key]}`).join(';');\n const [imgKey, setImgKey] = useState(defaultImgKey);\n\n // Construct Cloudinary-specific props by looking for values for any of the supported prop keys\n\n interface CldOptions {\n rawTransformations?: string[];\n }\n\n const cldOptions: CldOptions = {};\n\n CLD_OPTIONS.forEach(key => {\n if ( props[key] ) {\n cldOptions[key] = props[key] || undefined;\n }\n });\n\n // If we see a placeholder option, configure a Cloudinary-based URL.\n // The resulting image will always be blurred per Next.js, so we're\n // limited on options for placeholders.\n //\n // We need to do this logic here as we potentially need to mutate\n // an Image component prop as opposed to simply the URL\n //\n // https://nextjs.org/docs/api-reference/next/image#blurdataurl\n\n if ( imageProps.placeholder ) {\n let publicId;\n\n if ( props.src.startsWith('https://') ) {\n try {\n publicId = getPublicId(props.src);\n } catch(e) {}\n }\n\n if ( !publicId ) {\n publicId = props.src;\n }\n\n imageProps.blurDataURL = createPlaceholderUrl({\n src: publicId,\n placeholder: props.placeholder\n });\n\n if ( imageProps.placeholder !== 'blur' ) {\n imageProps.placeholder = 'blur';\n }\n }\n\n // Try to preserve the original transformations from the Cloudinary URL passed in\n // to the component. This only works if the URL has a version number on it and otherwise\n // will fail to load\n\n if (props.preserveTransformations) {\n try {\n const transformations = getTransformations(props.src);\n cldOptions.rawTransformations = [...transformations.flat(), ...(props.rawTransformations || [])];\n } catch(e) {\n console.warn(`Failed to preserve transformations: ${(e as Error).message}`)\n }\n }\n\n /**\n * handleOnError\n */\n\n async function handleOnError(options) {\n const result = await pollForProcessingImage({ src: options.target.src })\n if ( result ) {\n setImgKey(`${defaultImgKey};${Date.now()}`);\n }\n }\n\n return (\n <Image\n key={imgKey}\n {...imageProps}\n loader={(loaderOptions) => cloudinaryLoader({ loaderOptions, imageProps, cldOptions })}\n onError={handleOnError}\n />\n );\n}\n\nexport default CldImage;\n","import Head from 'next/head';\nimport { constructCloudinaryUrl } from '@cloudinary-util/url-loader';\n\nimport { NEXT_CLOUDINARY_ANALYTICS_ID, NEXT_CLOUDINARY_VERSION, NEXT_VERSION } from '../../constants/analytics';\n\nconst IMAGE_WIDTH = 2400;\nconst IMAGE_HEIGHT = 1200;\n\nconst TWITTER_CARD = 'summary_large_image';\n\nconst CldOgImage = ({ excludeTags = [] as string[], twitterTitle, ...props }) => {\n const options = {\n ...props,\n alt: props.alt,\n crop: props.crop || 'fill',\n gravity: props.gravity || 'center',\n height: props.height || IMAGE_HEIGHT,\n src: props.src,\n width: props.width || IMAGE_WIDTH,\n }\n\n const ogImageUrl = constructCloudinaryUrl({\n options,\n config: {\n cloud: {\n cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME\n }\n },\n analytics: {\n sdkCode: NEXT_CLOUDINARY_ANALYTICS_ID,\n sdkSemver: NEXT_CLOUDINARY_VERSION,\n techVersion: NEXT_VERSION,\n feature: ''\n }\n });\n\n // We need to include the tags within the Next.js Head component rather than\n // direcly adding them inside of the Head otherwise we get unexpected results\n\n return (\n // @ts-ignore\n <Head>\n <meta property=\"og:image\" content={ogImageUrl} />\n <meta property=\"og:image:secure_url\" content={ogImageUrl} />\n <meta property=\"og:image:width\" content={options.width} />\n <meta property=\"og:image:height\" content={options.height} />\n\n {options.alt && (\n <meta property=\"og:image:alt\" content={options.alt} />\n )}\n\n {/* Required for summary_large_image, exclude vai excludeTags */}\n {/* https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/summary-card-with-large-image */}\n\n {!excludeTags.includes('twitter:title') && (\n <meta property=\"twitter:title\" content={twitterTitle || ' '} />\n )}\n\n <meta property=\"twitter:card\" content={TWITTER_CARD} />\n <meta property=\"twitter:image\" content={ogImageUrl} />\n </Head>\n );\n}\n\nexport default CldOgImage;","import Script from 'next/script';\n\nlet cloudinary;\nlet widget;\n\nconst CldUploadWidget = ({\n children,\n onUpload,\n options,\n signatureEndpoint,\n uploadPreset,\n}) => {\n const signed = !!signatureEndpoint;\n\n /**\n * handleOnLoad\n * @description Stores the Cloudinary window instance to a ref when the widget script loads\n */\n\n function handleOnLoad() {\n if ( !cloudinary ) {\n cloudinary = (window as any).cloudinary;\n }\n\n // To help improve load time of the widget on first instance, use requestIdleCallback\n // to trigger widget creation. Optional.\n\n requestIdleCallback(() => {\n if ( !widget ) {\n widget = createWidget();\n }\n });\n }\n\n /**\n * generateSignature\n * @description Makes a request to an endpoint to sign Cloudinary parameters as part of widget creation\n */\n\n function generateSignature(callback, paramsToSign) {\n fetch(signatureEndpoint, {\n method: 'POST',\n body: JSON.stringify({\n paramsToSign,\n }),\n })\n .then((r) => r.json())\n .then(({ signature }) => {\n callback(signature);\n });\n }\n\n /**\n * createWidget\n * @description Creates a new instance of the Cloudinary widget and stores in a ref\n */\n\n function createWidget() {\n // When creating a signed upload, you need to provide both your Cloudinary API Key\n // as well as a signature generator function that will sign any paramters\n // either on page load or during the upload process. Read more about signed uploads at:\n // https://cloudinary.com/documentation/upload_widget#signed_uploads\n\n const uploadOptions = {\n cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME,\n uploadPreset: uploadPreset || process.env.NEXT_PUBLIC_CLOUDINARY_UPLOAD_PRESET,\n apiKey: process.env.NEXT_PUBLIC_CLOUDINARY_API_KEY,\n ...options,\n };\n\n if ( signed ) {\n uploadOptions.uploadSignature = generateSignature;\n\n // No need for apiSecret here because of api/sign-cloudinary-params\n\n if (!uploadOptions.apiKey) {\n return new Error(\"Signed Upload needs apiKey!\");\n }\n }\n\n return cloudinary?.createUploadWidget(\n uploadOptions,\n function (error, result) {\n // The callback is a bit more chatty than failed or success so\n // only trigger when one of those are the case. You can additionally\n // create a separate handler such as onEvent and trigger it on\n // ever occurrence\n if (error || result.event === \"success\") {\n onUpload(error, result, widget);\n }\n }\n );\n }\n\n /**\n * open\n * @description When triggered, uses the current widget instance to open the upload modal\n */\n\n function open() {\n if (!widget) {\n widget = createWidget();\n }\n widget && widget.open();\n }\n\n return (\n <>\n {children({\n cloudinary,\n widget,\n open,\n })}\n <Script\n id={`cloudinary-${Math.floor(Math.random() * 100)}`}\n src=\"https://widget.cloudinary.com/v2.0/global/all.js\"\n onLoad={handleOnLoad}\n onError={(e) => console.error(`Failed to load Cloudinary: ${e.message}`)}\n />\n </>\n );\n};\n\nexport default CldUploadWidget;\n","import CldUploadWidget from '../CldUploadWidget';\n\nconst CldUploadButton = ({\n children,\n onClick,\n onUpload,\n options,\n signatureEndpoint,\n uploadPreset,\n ...props\n}) => {\n return (\n <>\n {/* @ts-ignore */}\n <CldUploadWidget\n onUpload={onUpload}\n options={options}\n signatureEndpoint={signatureEndpoint}\n uploadPreset={uploadPreset}\n >\n {({ open }) => {\n function handleOnClick(e) {\n e.preventDefault();\n\n open();\n\n if ( typeof onClick === 'function' ) {\n onClick(e);\n }\n }\n return (\n <button {...props} onClick={handleOnClick} >\n {children || 'Upload'}\n </button>\n );\n }}\n </CldUploadWidget>\n </>\n );\n};\n\nexport default CldUploadButton;\n"],"names":["NEXT_CLOUDINARY_ANALYTICS_ID","NEXT_CLOUDINARY_VERSION","pkg","version","NEXT_VERSION","nextPkg","pollForProcessingImage","options","src","Promise","resolve","reject","fetch","then","res","ok","e","status","createPlaceholderUrl","placeholder","rawTransformations","push","includes","color","split","splice","join","constructCloudinaryUrl","width","quality","config","cloud","cloudName","process","env","NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME","analytics","sdkCode","sdkSemver","techVersion","feature","cloudinaryLoader","loaderOptions","imageProps","cldOptions","cldConfig","parseInt","height","multiplier","widthResize","heightResize","Math","round","CldImage","props","handleOnError","target","result","setImgKey","defaultImgKey","Date","now","CLD_OPTIONS","transformationPlugins","forEach","prop","Error","alt","Object","keys","filter","key","map","useState","imgKey","undefined","publicId","startsWith","getPublicId","blurDataURL","preserveTransformations","transformations","getTransformations","flat","console","warn","message","_jsx","Image","IMAGE_WIDTH","IMAGE_HEIGHT","TWITTER_CARD","CldOgImage","excludeTags","twitterTitle","_excluded","crop","gravity","ogImageUrl","_jsxs","Head","cloudinary","widget","CldUploadWidget","children","onUpload","signatureEndpoint","uploadPreset","signed","handleOnLoad","window","requestIdleCallback","createWidget","generateSignature","callback","paramsToSign","method","body","JSON","stringify","r","json","signature","uploadOptions","NEXT_PUBLIC_CLOUDINARY_UPLOAD_PRESET","apiKey","NEXT_PUBLIC_CLOUDINARY_API_KEY","uploadSignature","createUploadWidget","error","event","open","_Fragment","Script","floor","random","CldUploadButton","onClick","handleOnClick","preventDefault"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAMA,4BAA4B,GAAG,GAAG,CAAA;AACxC,IAAMC,uBAAuB,GAAGC,GAAG,CAACC,OAAO,CAAA;AAC3C,IAAMC,YAAY,GAAGC,2BAAO,CAACF,OAAO;;ACD3C;;AAEG;;AAoCH;;AAEG;;;;;;;;;;;;;AAEH,IAAsBG,sBAAsB,GAAA,SAAtBA,sBAAsB,CAACC,OAAO,EAAA;EAAA,IAAA;AAAA,IAAA,IAAA,MAAA,CAAA;AAClD,IAAA,IAAQC,GAAG,GAAKD,OAAO,CAAfC,GAAG,CAAA;IAAa,IACpB,MAAA,GAAA,MAAA,CAAA,YAAA;AAAA,MAAA,OAAA,OAAA,CAAA,OAAA,CACI,IAAIC,OAAO,CAAC,UAACC,OAAO,EAAEC,MAAM,EAAI;QACpCC,KAAK,CAACJ,GAAG,CAAC,CAACK,IAAI,CAAC,UAAAC,GAAG,EAAG;AACpB,UAAA,IAAK,CAACA,GAAG,CAACC,EAAE,EAAG;YACbJ,MAAM,CAACG,GAAG,CAAC,CAAA;AACX,YAAA,OAAA;AACD,WAAA;UACDJ,OAAO,CAACI,GAAG,CAAC,CAAA;AACd,SAAC,CAAC,CAAA;AACJ,OAAC,CAAC,CAAA,CAAA,IAAA,CAAA,YAAA,EAAA,CAAA,CAAA;KACH,EAAA,UAAOE,CAAM,EAAE;AAAA,MAAA,SAAA,MAAA,CAAA,QAAA,EAAA;AAAA,QAAA,IAAA,MAAA,EAAA,OAAA,QAAA,CAAA;AAAA,QAAA,MAAA,GAAA,CAAA,CAAA;AAAA,QAAA,OAIP,KAAK,CAAA;AAAA,OAAA;AAAA,MAAA,IAAA,KAAA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KAE5E,CAAA,CAAA;GAAG,CAAA,CAAA;AAEP;;;ACvHA,IAAMkD,eAAe,GAAG,SAAlBA,eAAe,CAQhB,IAAA,EAAA;EAAA,IAPHhC,SAAQ,QAARA,QAAQ;AACRiC,IAAAA,OAAO,QAAPA,OAAO;AACPhC,IAAAA,QAAQ,QAARA,QAAQ;AACRlG,IAAAA,OAAO,QAAPA,OAAO;AACPmG,IAAAA,iBAAiB,QAAjBA,iBAAiB;AACjBC,IAAAA,YAAY,QAAZA,YAAY;IACTrD,KAAK,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;EAER,oBACEiC,cAAA,CAAA6C,mBAAA,EAAA;AAAA,IAAA,QAAA,eAEE7C,eAAC,eAAe,EAAA;AACd,MAAA,QAAQ,EAAEkB,QAAS;AACnB,MAAA,OAAO,EAAElG,OAAQ;AACjB,MAAA,iBAAiB,EAAEmG,iBAAkB;AACrC,MAAA,YAAY,EAAEC,YAAa;AAAA,MAAA,QAAA,EAE1B,SAAa,QAAA,CAAA,KAAA,EAAA;QAAA,IAAVwB,IAAI,SAAJA,IAAI,CAAA;QACN,SAASO,aAAa,CAAC1H,CAAC,EAAA;UACtBA,CAAC,CAAC2H,cAAc,EAAE,CAAA;AAElBR,UAAAA,IAAI,EAAE,CAAA;AAEN,UAAA,IAAK,OAAOM,OAAO,KAAK,UAAU,EAAG;YACnCA,OAAO,CAACzH,CAAC,CAAC,CAAA;AACX,WAAA;AACH,SAAA;AACA,QAAA,oBACEuE,sCAAYjC,KAAK,EAAA;AAAE,UAAA,OAAO,EAAEoF,aAAc;AAAA,UAAA,QAAA,EACvClC,SAAQ,IAAI,QAAA;SACN,CAAA,CAAA,CAAA;AAEb,OAAA;AAAC,KAAA,CAAA;GAEF,CAAA,CAAA;AAEP;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { useState, useRef } from 'react';
1
+ import { useState } from 'react';
2
2
  import Image from 'next/image';
3
3
  import { getPublicId, getTransformations } from '@cloudinary-util/util';
4
4
  import { constructCloudinaryUrl, transformationPlugins } from '@cloudinary-util/url-loader';
@@ -35,7 +35,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
35
35
  }
36
36
 
37
37
  var name = "next-cloudinary";
38
- var version = "2.0.0";
38
+ var version = "2.1.0";
39
39
  var main = "dist/next-cloudinary.umd.js";
40
40
  var module = "dist/next-cloudinary.module.js";
41
41
  var source = "src/index.ts";
@@ -48,7 +48,7 @@ var scripts = {
48
48
  };
49
49
  var dependencies = {
50
50
  "@cloudinary-util/url-loader": "^1.2.4",
51
- "@cloudinary-util/util": "^1.1.1",
51
+ "@cloudinary-util/util": "^1.2.0",
52
52
  "@cloudinary/url-gen": "^1.8.6"
53
53
  };
54
54
  var devDependencies = {
@@ -183,7 +183,7 @@ function cloudinaryLoader({
183
183
  }
184
184
 
185
185
  const CldImage = props => {
186
- const CLD_OPTIONS = ['deliveryType'];
186
+ const CLD_OPTIONS = ['deliveryType', 'preserveTransformations'];
187
187
  transformationPlugins.forEach(({
188
188
  props: _props = []
189
189
  }) => {
@@ -194,7 +194,6 @@ const CldImage = props => {
194
194
  CLD_OPTIONS.push(prop);
195
195
  });
196
196
  });
197
- // Construct the base Image component props by filtering out Cloudinary-specific props
198
197
  const imageProps = {
199
198
  alt: props.alt,
200
199
  src: props.src
@@ -202,11 +201,10 @@ const CldImage = props => {
202
201
  Object.keys(props).filter(key => !CLD_OPTIONS.includes(key)).forEach(key => imageProps[key] = props[key]);
203
202
  const defaultImgKey = Object.keys(imageProps).map(key => `${key}:${imageProps[key]}`).join(';');
204
203
  const [imgKey, setImgKey] = useState(defaultImgKey);
205
- // Construct Cloudinary-specific props by looking for values for any of the supported prop keys
206
204
  const cldOptions = {};
207
205
  CLD_OPTIONS.forEach(key => {
208
206
  if (props[key]) {
209
- cldOptions[key] = props[key];
207
+ cldOptions[key] = props[key] || undefined;
210
208
  }
211
209
  });
212
210
  // If we see a placeholder option, configure a Cloudinary-based URL.
@@ -235,10 +233,16 @@ const CldImage = props => {
235
233
  imageProps.placeholder = 'blur';
236
234
  }
237
235
  }
238
- if (props.src && props.preserveTransformations) {
239
- const transformations = getTransformations(props.src, props.preserveTransformations);
240
- const rawTransformations = imageProps.rawTransformations ? [...imageProps.rawTransformations] : [];
241
- imageProps.rawTransformations = [...rawTransformations, ...transformations];
236
+ // Try to preserve the original transformations from the Cloudinary URL passed in
237
+ // to the component. This only works if the URL has a version number on it and otherwise
238
+ // will fail to load
239
+ if (props.preserveTransformations) {
240
+ try {
241
+ const transformations = getTransformations(props.src);
242
+ cldOptions.rawTransformations = [...transformations.flat(), ...(props.rawTransformations || [])];
243
+ } catch (e) {
244
+ console.warn(`Failed to preserve transformations: ${e.message}`);
245
+ }
242
246
  }
243
247
  /**
244
248
  * handleOnError
@@ -328,6 +332,8 @@ const CldOgImage = _ref => {
328
332
  );
329
333
  };
330
334
 
335
+ let cloudinary;
336
+ let widget;
331
337
  const CldUploadWidget = ({
332
338
  children,
333
339
  onUpload,
@@ -335,16 +341,30 @@ const CldUploadWidget = ({
335
341
  signatureEndpoint,
336
342
  uploadPreset
337
343
  }) => {
338
- const cloudinary = useRef();
339
- const widget = useRef();
340
344
  const signed = !!signatureEndpoint;
345
+ /**
346
+ * handleOnLoad
347
+ * @description Stores the Cloudinary window instance to a ref when the widget script loads
348
+ */
349
+ function handleOnLoad() {
350
+ if (!cloudinary) {
351
+ cloudinary = window.cloudinary;
352
+ }
353
+ // To help improve load time of the widget on first instance, use requestIdleCallback
354
+ // to trigger widget creation. Optional.
355
+ requestIdleCallback(() => {
356
+ if (!widget) {
357
+ widget = createWidget();
358
+ }
359
+ });
360
+ }
341
361
  /**
342
362
  * generateSignature
343
363
  * @description Makes a request to an endpoint to sign Cloudinary parameters as part of widget creation
344
364
  */
345
365
  function generateSignature(callback, paramsToSign) {
346
366
  fetch(signatureEndpoint, {
347
- method: "POST",
367
+ method: 'POST',
348
368
  body: JSON.stringify({
349
369
  paramsToSign
350
370
  })
@@ -359,7 +379,7 @@ const CldUploadWidget = ({
359
379
  * @description Creates a new instance of the Cloudinary widget and stores in a ref
360
380
  */
361
381
  function createWidget() {
362
- var _cloudinary$current;
382
+ var _cloudinary;
363
383
  // When creating a signed upload, you need to provide both your Cloudinary API Key
364
384
  // as well as a signature generator function that will sign any paramters
365
385
  // either on page load or during the upload process. Read more about signed uploads at:
@@ -376,13 +396,13 @@ const CldUploadWidget = ({
376
396
  return new Error("Signed Upload needs apiKey!");
377
397
  }
378
398
  }
379
- return (_cloudinary$current = cloudinary.current) == null ? void 0 : _cloudinary$current.createUploadWidget(uploadOptions, function (error, result) {
399
+ return (_cloudinary = cloudinary) == null ? void 0 : _cloudinary.createUploadWidget(uploadOptions, function (error, result) {
380
400
  // The callback is a bit more chatty than failed or success so
381
401
  // only trigger when one of those are the case. You can additionally
382
402
  // create a separate handler such as onEvent and trigger it on
383
403
  // ever occurrence
384
404
  if (error || result.event === "success") {
385
- onUpload(error, result, widget == null ? void 0 : widget.current);
405
+ onUpload(error, result, widget);
386
406
  }
387
407
  });
388
408
  }
@@ -391,29 +411,18 @@ const CldUploadWidget = ({
391
411
  * @description When triggered, uses the current widget instance to open the upload modal
392
412
  */
393
413
  function open() {
394
- if (!(widget != null && widget.current)) {
395
- widget.current = createWidget();
414
+ if (!widget) {
415
+ widget = createWidget();
396
416
  }
397
- // @ts-ignore
398
- (widget == null ? void 0 : widget.current) && widget.current.open();
399
- }
400
- /**
401
- * handleOnLoad
402
- * @description Stores the Cloudinary window instance to a ref when the widget script loads
403
- */
404
- function handleOnLoad() {
405
- // @ts-ignore
406
- cloudinary.current = window.cloudinary;
417
+ widget && widget.open();
407
418
  }
408
419
  return /*#__PURE__*/jsxs(Fragment, {
409
420
  children: [children({
410
- cloudinary: cloudinary.current,
411
- widget: widget.current,
421
+ cloudinary,
422
+ widget,
412
423
  open
413
424
  }), /*#__PURE__*/jsx(Script, {
414
- id: `cloudinary-${Math.floor(Math.random() * 100)}`
415
- // @ts-ignore
416
- ,
425
+ id: `cloudinary-${Math.floor(Math.random() * 100)}`,
417
426
  src: "https://widget.cloudinary.com/v2.0/global/all.js",
418
427
  onLoad: handleOnLoad,
419
428
  onError: e => console.error(`Failed to load Cloudinary: ${e.message}`)