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.
@@ -1 +1 @@
1
- {"version":3,"file":"next-cloudinary.modern.mjs","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","createPlaceholderUrl","src","placeholder","rawTransformations","push","includes","color","split","splice","join","constructCloudinaryUrl","options","width","quality","config","cloud","cloudName","process","env","NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME","analytics","sdkCode","sdkSemver","techVersion","feature","pollForProcessingImage","Promise","resolve","reject","fetch","then","res","ok","e","status","cloudinaryLoader","loaderOptions","imageProps","cldOptions","cldConfig","parseInt","height","multiplier","widthResize","heightResize","Math","round","CldImage","props","CLD_OPTIONS","transformationPlugins","forEach","prop","Error","alt","Object","keys","filter","key","defaultImgKey","map","imgKey","setImgKey","useState","publicId","startsWith","getPublicId","blurDataURL","preserveTransformations","transformations","getTransformations","handleOnError","result","target","Date","now","_jsx","IMAGE_WIDTH","IMAGE_HEIGHT","TWITTER_CARD","CldOgImage","excludeTags","twitterTitle","_excluded","crop","gravity","ogImageUrl","_jsxs","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","floor","random","console","message","CldUploadButton","onClick","handleOnClick","preventDefault"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAMA,4BAA4B,GAAG,GAAG,CAAA;AACxC,MAAMC,uBAAuB,GAAGC,GAAG,CAACC,OAAO,CAAA;AAC3C,MAAMC,YAAY,GAAGC,OAAO,CAACF,OAAO;;ACD3C;;AAEG;AAEG,SAAUG,oBAAoB,CAAC;EAAEC,GAAG;AAAEC,EAAAA,WAAW,GAAG,IAAA;AAAmE,CAAA,EAAA;EAC3H,MAAMC,kBAAkB,GAAa,EAAE,CAAA;EAEvC,IAAKD,WAAW,KAAK,WAAW,EAAG;AACjCC,IAAAA,kBAAkB,CAACC,IAAI,CAAC,aAAa,CAAC,CAAA;AACvC,GAAA;EAED,IAAK,OAAOF,WAAW,KAAK,QAAQ,IAAIA,WAAW,CAACG,QAAQ,CAAC,QAAQ,CAAC,EAAG;AACvE,IAAA,MAAMC,KAAK,GAAGJ,WAAW,CAACK,KAAK,CAAC,GAAG,CAAC,CAACC,MAAM,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CAAA;AACxDN,IAAAA,kBAAkB,CAACC,IAAI,CAAC,aAAa,CAAC,CAAA;AACtCD,IAAAA,kBAAkB,CAACC,IAAI,EAAqBE,iBAAAA,EAAAA,KAAK,EAAE,CAAC,C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,YAAY,EAAEC,YAAa;AAAA,MAAA,QAAA,EAE1B,CAAC;AAAEyB,QAAAA,IAAAA;AAAI,OAAE,KAAI;QACZ,SAASU,aAAa,CAAC9F,CAAC,EAAA;UACtBA,CAAC,CAAC+F,cAAc,EAAE,CAAA;AAElBX,UAAAA,IAAI,EAAE,CAAA;AAEN,UAAA,IAAK,OAAOS,OAAO,KAAK,UAAU,EAAG;YACnCA,OAAO,CAAC7F,CAAC,CAAC,CAAA;AACX,WAAA;AACH,SAAA;AACA,QAAA,oBACE2C,2BAAY5B,KAAK,EAAA;AAAE,UAAA,OAAO,EAAE+E,aAAc;AAAA,UAAA,QAAA,EACvCtC,QAAQ,IAAI,QAAA;SACN,CAAA,CAAA,CAAA;AAEb,OAAA;AAAC,KAAA,CAAA;GAEF,CAAA,CAAA;AAEP;;;;"}
1
+ {"version":3,"file":"next-cloudinary.modern.mjs","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","createPlaceholderUrl","src","placeholder","rawTransformations","push","includes","color","split","splice","join","constructCloudinaryUrl","options","width","quality","config","cloud","cloudName","process","env","NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME","analytics","sdkCode","sdkSemver","techVersion","feature","pollForProcessingImage","Promise","resolve","reject","fetch","then","res","ok","e","status","cloudinaryLoader","loaderOptions","imageProps","cldOptions","cldConfig","parseInt","height","multiplier","widthResize","heightResize","Math","round","CldImage","props","CLD_OPTIONS","transformationPlugins","forEach","prop","Error","alt","Object","keys","filter","key","defaultImgKey","map","imgKey","setImgKey","useState","undefined","publicId","startsWith","getPublicId","blurDataURL","preserveTransformations","transformations","getTransformations","flat","console","warn","message","handleOnError","result","target","Date","now","_jsx","IMAGE_WIDTH","IMAGE_HEIGHT","TWITTER_CARD","CldOgImage","excludeTags","twitterTitle","_excluded","crop","gravity","ogImageUrl","_jsxs","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","floor","random","CldUploadButton","onClick","handleOnClick","preventDefault"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAMA,4BAA4B,GAAG,GAAG,CAAA;AACxC,MAAMC,uBAAuB,GAAGC,GAAG,CAACC,OAAO,CAAA;AAC3C,MAAMC,YAAY,GAAGC,OAAO,CAACF,OAAO;;ACD3C;;AAEG;AAEG,SAAUG,oBAAoB,CAAC;EAAEC,GAAG;AAAEC,EAAAA,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P;;;ACvHMoD,MAAAA,eAAe,GAAG,IAQnB,IAAA;EAAA,IARoB;MACvB/B,QAAQ;MACRgC,OAAO;MACP/B,QAAQ;MACRtF,OAAO;MACPuF,iBAAiB;AACjBC,MAAAA,YAAAA;KAED,GAAA,IAAA;IADInD,KAAK,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;EAER,oBACEiC,GAAA,CAAA2C,QAAA,EAAA;AAAA,IAAA,QAAA,eAEE3C,IAAC,eAAe,EAAA;AACd,MAAA,QAAQ,EAAEgB,QAAS;AACnB,MAAA,OAAO,EAAEtF,OAAQ;AACjB,MAAA,iBAAiB,EAAEuF,iBAAkB;AACrC,MAAA,YAAY,EAAEC,YAAa;AAAA,MAAA,QAAA,EAE1B,CAAC;AAAEwB,QAAAA,IAAAA;AAAI,OAAE,KAAI;QACZ,SAASM,aAAa,CAAChG,CAAC,EAAA;UACtBA,CAAC,CAACiG,cAAc,EAAE,CAAA;AAElBP,UAAAA,IAAI,EAAE,CAAA;AAEN,UAAA,IAAK,OAAOK,OAAO,KAAK,UAAU,EAAG;YACnCA,OAAO,CAAC/F,CAAC,CAAC,CAAA;AACX,WAAA;AACH,SAAA;AACA,QAAA,oBACEgD,2BAAYjC,KAAK,EAAA;AAAE,UAAA,OAAO,EAAEiF,aAAc;AAAA,UAAA,QAAA,EACvCjC,QAAQ,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 = {
@@ -227,7 +227,7 @@ var CldImage = function CldImage(props) {
227
227
  return Promise.reject(e);
228
228
  }
229
229
  };
230
- var CLD_OPTIONS = ['deliveryType'];
230
+ var CLD_OPTIONS = ['deliveryType', 'preserveTransformations'];
231
231
  transformationPlugins.forEach(function (_ref) {
232
232
  var _ref$props = _ref.props,
233
233
  props = _ref$props === void 0 ? [] : _ref$props;
@@ -238,7 +238,6 @@ var CldImage = function CldImage(props) {
238
238
  CLD_OPTIONS.push(prop);
239
239
  });
240
240
  });
241
- // Construct the base Image component props by filtering out Cloudinary-specific props
242
241
  var imageProps = {
243
242
  alt: props.alt,
244
243
  src: props.src
@@ -254,11 +253,10 @@ var CldImage = function CldImage(props) {
254
253
  var _useState = useState(defaultImgKey),
255
254
  imgKey = _useState[0],
256
255
  setImgKey = _useState[1];
257
- // Construct Cloudinary-specific props by looking for values for any of the supported prop keys
258
256
  var cldOptions = {};
259
257
  CLD_OPTIONS.forEach(function (key) {
260
258
  if (props[key]) {
261
- cldOptions[key] = props[key];
259
+ cldOptions[key] = props[key] || undefined;
262
260
  }
263
261
  });
264
262
  // If we see a placeholder option, configure a Cloudinary-based URL.
@@ -287,10 +285,16 @@ var CldImage = function CldImage(props) {
287
285
  imageProps.placeholder = 'blur';
288
286
  }
289
287
  }
290
- if (props.src && props.preserveTransformations) {
291
- var transformations = getTransformations(props.src, props.preserveTransformations);
292
- var rawTransformations = imageProps.rawTransformations ? [].concat(imageProps.rawTransformations) : [];
293
- imageProps.rawTransformations = [].concat(rawTransformations, transformations);
288
+ // Try to preserve the original transformations from the Cloudinary URL passed in
289
+ // to the component. This only works if the URL has a version number on it and otherwise
290
+ // will fail to load
291
+ if (props.preserveTransformations) {
292
+ try {
293
+ var transformations = getTransformations(props.src);
294
+ cldOptions.rawTransformations = [].concat(transformations.flat(), props.rawTransformations || []);
295
+ } catch (e) {
296
+ console.warn("Failed to preserve transformations: " + e.message);
297
+ }
294
298
  }
295
299
  return /*#__PURE__*/jsx(Image, _extends({}, imageProps, {
296
300
  loader: function loader(loaderOptions) {
@@ -370,22 +374,38 @@ var CldOgImage = function CldOgImage(_ref) {
370
374
  );
371
375
  };
372
376
 
377
+ var cloudinary;
378
+ var widget;
373
379
  var CldUploadWidget = function CldUploadWidget(_ref) {
374
380
  var children = _ref.children,
375
381
  onUpload = _ref.onUpload,
376
382
  options = _ref.options,
377
383
  signatureEndpoint = _ref.signatureEndpoint,
378
384
  uploadPreset = _ref.uploadPreset;
379
- var cloudinary = useRef();
380
- var widget = useRef();
381
385
  var signed = !!signatureEndpoint;
386
+ /**
387
+ * handleOnLoad
388
+ * @description Stores the Cloudinary window instance to a ref when the widget script loads
389
+ */
390
+ function handleOnLoad() {
391
+ if (!cloudinary) {
392
+ cloudinary = window.cloudinary;
393
+ }
394
+ // To help improve load time of the widget on first instance, use requestIdleCallback
395
+ // to trigger widget creation. Optional.
396
+ requestIdleCallback(function () {
397
+ if (!widget) {
398
+ widget = createWidget();
399
+ }
400
+ });
401
+ }
382
402
  /**
383
403
  * generateSignature
384
404
  * @description Makes a request to an endpoint to sign Cloudinary parameters as part of widget creation
385
405
  */
386
406
  function generateSignature(callback, paramsToSign) {
387
407
  fetch(signatureEndpoint, {
388
- method: "POST",
408
+ method: 'POST',
389
409
  body: JSON.stringify({
390
410
  paramsToSign: paramsToSign
391
411
  })
@@ -401,7 +421,7 @@ var CldUploadWidget = function CldUploadWidget(_ref) {
401
421
  * @description Creates a new instance of the Cloudinary widget and stores in a ref
402
422
  */
403
423
  function createWidget() {
404
- var _cloudinary$current;
424
+ var _cloudinary;
405
425
  // When creating a signed upload, you need to provide both your Cloudinary API Key
406
426
  // as well as a signature generator function that will sign any paramters
407
427
  // either on page load or during the upload process. Read more about signed uploads at:
@@ -418,13 +438,13 @@ var CldUploadWidget = function CldUploadWidget(_ref) {
418
438
  return new Error("Signed Upload needs apiKey!");
419
439
  }
420
440
  }
421
- return (_cloudinary$current = cloudinary.current) == null ? void 0 : _cloudinary$current.createUploadWidget(uploadOptions, function (error, result) {
441
+ return (_cloudinary = cloudinary) == null ? void 0 : _cloudinary.createUploadWidget(uploadOptions, function (error, result) {
422
442
  // The callback is a bit more chatty than failed or success so
423
443
  // only trigger when one of those are the case. You can additionally
424
444
  // create a separate handler such as onEvent and trigger it on
425
445
  // ever occurrence
426
446
  if (error || result.event === "success") {
427
- onUpload(error, result, widget == null ? void 0 : widget.current);
447
+ onUpload(error, result, widget);
428
448
  }
429
449
  });
430
450
  }
@@ -433,29 +453,18 @@ var CldUploadWidget = function CldUploadWidget(_ref) {
433
453
  * @description When triggered, uses the current widget instance to open the upload modal
434
454
  */
435
455
  function open() {
436
- if (!(widget != null && widget.current)) {
437
- widget.current = createWidget();
456
+ if (!widget) {
457
+ widget = createWidget();
438
458
  }
439
- // @ts-ignore
440
- (widget == null ? void 0 : widget.current) && widget.current.open();
441
- }
442
- /**
443
- * handleOnLoad
444
- * @description Stores the Cloudinary window instance to a ref when the widget script loads
445
- */
446
- function handleOnLoad() {
447
- // @ts-ignore
448
- cloudinary.current = window.cloudinary;
459
+ widget && widget.open();
449
460
  }
450
461
  return /*#__PURE__*/jsxs(Fragment, {
451
462
  children: [children({
452
- cloudinary: cloudinary.current,
453
- widget: widget.current,
463
+ cloudinary: cloudinary,
464
+ widget: widget,
454
465
  open: open
455
466
  }), /*#__PURE__*/jsx(Script, {
456
- id: "cloudinary-" + Math.floor(Math.random() * 100)
457
- // @ts-ignore
458
- ,
467
+ id: "cloudinary-" + Math.floor(Math.random() * 100),
459
468
  src: "https://widget.cloudinary.com/v2.0/global/all.js",
460
469
  onLoad: handleOnLoad,
461
470
  onError: function onError(e) {
@@ -1 +1 @@
1
- {"version":3,"file":"next-cloudinary.module.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_WIDTH","IMAGE_HEIGHT","TWITTER_CARD","CldOgImage","excludeTags","twitterTitle","_excluded","crop","gravity","ogImageUrl","_jsxs","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","floor","random","console","message","CldUploadButton","onClick","handleOnClick","preventDefault"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAMA,4BAA4B,GAAG,GAAG,CAAA;AACxC,IAAMC,uBAAuB,GAAGC,GAAG,CAACC,OAAO,CAAA;AAC3C,IAAMC,YAAY,GAAGC,OAAO,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,UAAO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A,OAAO,EAAE+E,aAAc;AAAA,UAAA,QAAA,EACvCtC,SAAQ,IAAI,QAAA;SACN,CAAA,CAAA,CAAA;AAEb,OAAA;AAAC,KAAA,CAAA;GAEF,CAAA,CAAA;AAEP;;;;"}
1
+ {"version":3,"file":"next-cloudinary.module.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_WIDTH","IMAGE_HEIGHT","TWITTER_CARD","CldOgImage","excludeTags","twitterTitle","_excluded","crop","gravity","ogImageUrl","_jsxs","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","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,OAAO,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,GA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AAA,IAAK,OAAOK,OAAO,KAAK,UAAU,EAAG;YACnCA,OAAO,CAACtH,CAAC,CAAC,CAAA;AACX,WAAA;AACH,SAAA;AACA,QAAA,oBACEuE,2BAAYjC,KAAK,EAAA;AAAE,UAAA,OAAO,EAAEiF,aAAc;AAAA,UAAA,QAAA,EACvCjC,SAAQ,IAAI,QAAA;SACN,CAAA,CAAA,CAAA;AAEb,OAAA;AAAC,KAAA,CAAA;GAEF,CAAA,CAAA;AAEP;;;;"}
@@ -38,7 +38,7 @@
38
38
  }
39
39
 
40
40
  var name = "next-cloudinary";
41
- var version = "2.0.0";
41
+ var version = "2.1.0";
42
42
  var main = "dist/next-cloudinary.umd.js";
43
43
  var module = "dist/next-cloudinary.module.js";
44
44
  var source = "src/index.ts";
@@ -51,7 +51,7 @@
51
51
  };
52
52
  var dependencies = {
53
53
  "@cloudinary-util/url-loader": "^1.2.4",
54
- "@cloudinary-util/util": "^1.1.1",
54
+ "@cloudinary-util/util": "^1.2.0",
55
55
  "@cloudinary/url-gen": "^1.8.6"
56
56
  };
57
57
  var devDependencies = {
@@ -230,7 +230,7 @@
230
230
  return Promise.reject(e);
231
231
  }
232
232
  };
233
- var CLD_OPTIONS = ['deliveryType'];
233
+ var CLD_OPTIONS = ['deliveryType', 'preserveTransformations'];
234
234
  urlLoader.transformationPlugins.forEach(function (_ref) {
235
235
  var _ref$props = _ref.props,
236
236
  props = _ref$props === void 0 ? [] : _ref$props;
@@ -241,7 +241,6 @@
241
241
  CLD_OPTIONS.push(prop);
242
242
  });
243
243
  });
244
- // Construct the base Image component props by filtering out Cloudinary-specific props
245
244
  var imageProps = {
246
245
  alt: props.alt,
247
246
  src: props.src
@@ -257,11 +256,10 @@
257
256
  var _useState = react.useState(defaultImgKey),
258
257
  imgKey = _useState[0],
259
258
  setImgKey = _useState[1];
260
- // Construct Cloudinary-specific props by looking for values for any of the supported prop keys
261
259
  var cldOptions = {};
262
260
  CLD_OPTIONS.forEach(function (key) {
263
261
  if (props[key]) {
264
- cldOptions[key] = props[key];
262
+ cldOptions[key] = props[key] || undefined;
265
263
  }
266
264
  });
267
265
  // If we see a placeholder option, configure a Cloudinary-based URL.
@@ -290,10 +288,16 @@
290
288
  imageProps.placeholder = 'blur';
291
289
  }
292
290
  }
293
- if (props.src && props.preserveTransformations) {
294
- var transformations = util.getTransformations(props.src, props.preserveTransformations);
295
- var rawTransformations = imageProps.rawTransformations ? [].concat(imageProps.rawTransformations) : [];
296
- imageProps.rawTransformations = [].concat(rawTransformations, transformations);
291
+ // Try to preserve the original transformations from the Cloudinary URL passed in
292
+ // to the component. This only works if the URL has a version number on it and otherwise
293
+ // will fail to load
294
+ if (props.preserveTransformations) {
295
+ try {
296
+ var transformations = util.getTransformations(props.src);
297
+ cldOptions.rawTransformations = [].concat(transformations.flat(), props.rawTransformations || []);
298
+ } catch (e) {
299
+ console.warn("Failed to preserve transformations: " + e.message);
300
+ }
297
301
  }
298
302
  return /*#__PURE__*/jsxRuntime.jsx(Image__default["default"], _extends({}, imageProps, {
299
303
  loader: function loader(loaderOptions) {
@@ -373,22 +377,38 @@
373
377
  );
374
378
  };
375
379
 
380
+ var cloudinary;
381
+ var widget;
376
382
  var CldUploadWidget = function CldUploadWidget(_ref) {
377
383
  var children = _ref.children,
378
384
  onUpload = _ref.onUpload,
379
385
  options = _ref.options,
380
386
  signatureEndpoint = _ref.signatureEndpoint,
381
387
  uploadPreset = _ref.uploadPreset;
382
- var cloudinary = react.useRef();
383
- var widget = react.useRef();
384
388
  var signed = !!signatureEndpoint;
389
+ /**
390
+ * handleOnLoad
391
+ * @description Stores the Cloudinary window instance to a ref when the widget script loads
392
+ */
393
+ function handleOnLoad() {
394
+ if (!cloudinary) {
395
+ cloudinary = window.cloudinary;
396
+ }
397
+ // To help improve load time of the widget on first instance, use requestIdleCallback
398
+ // to trigger widget creation. Optional.
399
+ requestIdleCallback(function () {
400
+ if (!widget) {
401
+ widget = createWidget();
402
+ }
403
+ });
404
+ }
385
405
  /**
386
406
  * generateSignature
387
407
  * @description Makes a request to an endpoint to sign Cloudinary parameters as part of widget creation
388
408
  */
389
409
  function generateSignature(callback, paramsToSign) {
390
410
  fetch(signatureEndpoint, {
391
- method: "POST",
411
+ method: 'POST',
392
412
  body: JSON.stringify({
393
413
  paramsToSign: paramsToSign
394
414
  })
@@ -404,7 +424,7 @@
404
424
  * @description Creates a new instance of the Cloudinary widget and stores in a ref
405
425
  */
406
426
  function createWidget() {
407
- var _cloudinary$current;
427
+ var _cloudinary;
408
428
  // When creating a signed upload, you need to provide both your Cloudinary API Key
409
429
  // as well as a signature generator function that will sign any paramters
410
430
  // either on page load or during the upload process. Read more about signed uploads at:
@@ -421,13 +441,13 @@
421
441
  return new Error("Signed Upload needs apiKey!");
422
442
  }
423
443
  }
424
- return (_cloudinary$current = cloudinary.current) == null ? void 0 : _cloudinary$current.createUploadWidget(uploadOptions, function (error, result) {
444
+ return (_cloudinary = cloudinary) == null ? void 0 : _cloudinary.createUploadWidget(uploadOptions, function (error, result) {
425
445
  // The callback is a bit more chatty than failed or success so
426
446
  // only trigger when one of those are the case. You can additionally
427
447
  // create a separate handler such as onEvent and trigger it on
428
448
  // ever occurrence
429
449
  if (error || result.event === "success") {
430
- onUpload(error, result, widget == null ? void 0 : widget.current);
450
+ onUpload(error, result, widget);
431
451
  }
432
452
  });
433
453
  }
@@ -436,29 +456,18 @@
436
456
  * @description When triggered, uses the current widget instance to open the upload modal
437
457
  */
438
458
  function open() {
439
- if (!(widget != null && widget.current)) {
440
- widget.current = createWidget();
459
+ if (!widget) {
460
+ widget = createWidget();
441
461
  }
442
- // @ts-ignore
443
- (widget == null ? void 0 : widget.current) && widget.current.open();
444
- }
445
- /**
446
- * handleOnLoad
447
- * @description Stores the Cloudinary window instance to a ref when the widget script loads
448
- */
449
- function handleOnLoad() {
450
- // @ts-ignore
451
- cloudinary.current = window.cloudinary;
462
+ widget && widget.open();
452
463
  }
453
464
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
454
465
  children: [children({
455
- cloudinary: cloudinary.current,
456
- widget: widget.current,
466
+ cloudinary: cloudinary,
467
+ widget: widget,
457
468
  open: open
458
469
  }), /*#__PURE__*/jsxRuntime.jsx(Script__default["default"], {
459
- id: "cloudinary-" + Math.floor(Math.random() * 100)
460
- // @ts-ignore
461
- ,
470
+ id: "cloudinary-" + Math.floor(Math.random() * 100),
462
471
  src: "https://widget.cloudinary.com/v2.0/global/all.js",
463
472
  onLoad: handleOnLoad,
464
473
  onError: function onError(e) {