next-cloudinary 0.0.2 → 0.0.5

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.
@@ -34,29 +34,104 @@ function _objectWithoutPropertiesLoose(source, excluded) {
34
34
  return target;
35
35
  }
36
36
 
37
+ function _readOnlyError(name) {
38
+ throw new TypeError("\"" + name + "\" is read-only");
39
+ }
40
+
41
+ var cld$1 = new Cloudinary({
42
+ cloud: {
43
+ cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
44
+ },
45
+ url: {
46
+ // Used to avoid issues with SSR particularly for the blurred placeholder
47
+ analytics: false
48
+ }
49
+ });
50
+ /**
51
+ * createPlaceholderUrl
52
+ */
53
+
54
+ function createPlaceholderUrl(_ref) {
55
+ var src = _ref.src,
56
+ placeholder = _ref.placeholder;
57
+ var cldImage = cld$1.image(src).resize('c_limit,w_100').delivery('q_1').format('auto');
58
+
59
+ if (placeholder === 'grayscale') {
60
+ cldImage.effect('e_grayscale');
61
+ }
62
+
63
+ if (placeholder.includes('color:')) {
64
+ var color = placeholder.split(':').splice(1).join(':');
65
+ cldImage.effect('e_grayscale');
66
+ cldImage.effect("e_colorize:60,co_" + color);
67
+ }
68
+
69
+ return cldImage.toURL();
70
+ }
71
+
72
+ var cropsGravityAuto = ['crop', 'fill', 'lfill', 'fill_pad', 'thumb'];
73
+ function croppingPlugin(_temp) {
74
+ var _ref = _temp === void 0 ? {} : _temp,
75
+ cldImage = _ref.cldImage,
76
+ options = _ref.options,
77
+ cldOptions = _ref.cldOptions;
78
+
79
+ var width = options.width,
80
+ height = options.height;
81
+ var _cldOptions$crop = cldOptions.crop,
82
+ crop = _cldOptions$crop === void 0 ? 'limit' : _cldOptions$crop,
83
+ gravity = cldOptions.gravity;
84
+ var transformationString = "c_" + crop + ",w_" + width;
85
+
86
+ if (!gravity && cropsGravityAuto.includes(crop)) {
87
+ _readOnlyError("gravity");
88
+ }
89
+
90
+ if (!['limit'].includes(crop)) {
91
+ transformationString = transformationString + ",h_" + height;
92
+ }
93
+
94
+ if (gravity) {
95
+ if (gravity === 'auto' && !cropsGravityAuto.includes(crop)) {
96
+ console.warn('Auto gravity can only be used with crop, fill, lfill, fill_pad or thumb. Not applying gravity.');
97
+ } else {
98
+ transformationString = transformationString + ",g_" + gravity;
99
+ }
100
+ }
101
+
102
+ cldImage.resize(transformationString);
103
+ }
104
+
105
+ // aspectRatio
37
106
  var primary = {
38
- gravity: {
39
- qualifier: 'g'
107
+ aspectRatio: {
108
+ qualifier: 'ar'
40
109
  },
41
110
  crop: {
42
111
  qualifier: 'c'
43
112
  },
44
- width: {
45
- qualifier: 'w'
113
+ gravity: {
114
+ qualifier: 'g'
46
115
  },
47
116
  height: {
48
117
  qualifier: 'h'
118
+ },
119
+ width: {
120
+ qualifier: 'w'
49
121
  }
50
122
  };
51
123
  var position = {
124
+ angle: {
125
+ qualifier: 'a'
126
+ },
127
+ gravity: {
128
+ qualifier: 'g'
129
+ },
52
130
  x: {
53
131
  qualifier: 'x'
54
132
  },
55
133
  y: {
56
134
  qualifier: 'y'
57
- },
58
- gravity: {
59
- qualifier: 'g'
60
135
  }
61
136
  };
62
137
  var text = {
@@ -64,79 +139,48 @@ var text = {
64
139
  qualifier: 'co',
65
140
  location: 'primary'
66
141
  },
67
- fontFamily: {},
68
- fontSize: {},
69
- fontWeight: {},
70
- textDecoration: {},
142
+ textDecoration: {
143
+ qualifier: false
144
+ },
145
+ fontFamily: {
146
+ qualifier: false
147
+ },
148
+ fontSize: {
149
+ qualifier: false
150
+ },
151
+ fontWeight: {
152
+ qualifier: false
153
+ },
71
154
  letterSpacing: {
72
155
  qualifier: 'letter_spacing'
73
156
  }
74
157
  };
75
158
 
76
- var _excluded$1 = ["publicId", "type", "position", "text", "effects"];
77
- var cld = new Cloudinary({
78
- cloud: {
79
- cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
80
- }
81
- });
82
- function cloudinaryLoader(options, cldOptions) {
83
- var src = options.src,
84
- width = options.width,
85
- _options$format = options.format,
86
- format = _options$format === void 0 ? 'auto' : _options$format,
87
- _options$quality = options.quality,
88
- quality = _options$quality === void 0 ? 'auto' : _options$quality;
89
- var _cldOptions$overlays = cldOptions.overlays,
90
- overlays = _cldOptions$overlays === void 0 ? [] : _cldOptions$overlays,
91
- _cldOptions$removeBac = cldOptions.removeBackground,
92
- removeBackground = _cldOptions$removeBac === void 0 ? false : _cldOptions$removeBac,
93
- _cldOptions$underlays = cldOptions.underlays,
94
- underlays = _cldOptions$underlays === void 0 ? [] : _cldOptions$underlays;
95
- var cldImage = cld.image(src);
96
-
97
- if (removeBackground) {
98
- cldImage.effect('e_background_removal');
99
- } // Adding overlays and underlays allows you to compose your image
100
- // by using layering with overlays appearing on top of and udnerlays
101
- // appearing below your base image layer
102
- //
103
- // Learn more: https://cloudinary.com/documentation/layers
104
-
159
+ var _excluded$2 = ["publicId", "position", "text", "effects"];
160
+ function overlaysPlugin(_temp) {
161
+ var _ref = _temp === void 0 ? {} : _temp,
162
+ cldImage = _ref.cldImage,
163
+ cldOptions = _ref.cldOptions;
105
164
 
106
- var layers = [].concat(overlays.map(function (overlay) {
107
- return _extends({}, overlay, {
108
- type: 'overlay'
109
- });
110
- }), underlays.map(function (underlay) {
111
- return _extends({}, underlay, {
112
- type: 'underlay'
113
- });
114
- }));
115
- layers.forEach(function (_ref) {
116
- var publicId = _ref.publicId,
117
- type = _ref.type,
118
- position$1 = _ref.position,
119
- text$1 = _ref.text,
120
- _ref$effects = _ref.effects,
121
- layerEffects = _ref$effects === void 0 ? [] : _ref$effects,
122
- options = _objectWithoutPropertiesLoose(_ref, _excluded$1);
165
+ var _cldOptions$overlays = cldOptions.overlays,
166
+ overlays = _cldOptions$overlays === void 0 ? [] : _cldOptions$overlays;
167
+ var type = 'overlay';
168
+ var typeQualifier = 'l';
169
+ overlays.forEach(function (_ref2) {
170
+ var publicId = _ref2.publicId,
171
+ position$1 = _ref2.position,
172
+ text$1 = _ref2.text,
173
+ _ref2$effects = _ref2.effects,
174
+ layerEffects = _ref2$effects === void 0 ? [] : _ref2$effects,
175
+ options = _objectWithoutPropertiesLoose(_ref2, _excluded$2);
123
176
 
124
177
  var hasPublicId = typeof publicId === 'string';
125
178
  var hasText = typeof text$1 === 'object';
126
179
  var hasPosition = typeof position$1 === 'object';
127
180
 
128
181
  if (!hasPublicId && !hasText) {
129
- console.warn(type + " is missing Public ID or Text");
182
+ console.warn("An " + type + " is missing Public ID or Text");
130
183
  return;
131
- } // Determine the qualifier for the type of layer
132
-
133
-
134
- var typeQualifier;
135
-
136
- if (type === 'overlay') {
137
- typeQualifier = 'l';
138
- } else if (type === 'underlay') {
139
- typeQualifier = 'u';
140
184
  } // Start to construct the transformation string using text or the public ID
141
185
  // if it's image-based
142
186
 
@@ -206,25 +250,166 @@ function cloudinaryLoader(options, cldOptions) {
206
250
 
207
251
  cldImage.addTransformation(layerTransformation);
208
252
  });
209
- return cldImage.resize("c_limit,w_" + width).format(format).delivery("q_" + quality).toURL();
210
253
  }
211
254
 
212
- var _excluded = ["overlays", "removeBackground", "underlays"];
255
+ function removeBackgroundPlugin(_temp) {
256
+ var _ref = _temp === void 0 ? {} : _temp,
257
+ cldImage = _ref.cldImage,
258
+ cldOptions = _ref.cldOptions;
259
+
260
+ var _cldOptions$removeBac = cldOptions.removeBackground,
261
+ removeBackground = _cldOptions$removeBac === void 0 ? false : _cldOptions$removeBac;
262
+
263
+ if (removeBackground) {
264
+ cldImage.effect('e_background_removal');
265
+ }
266
+ }
267
+
268
+ function tintPlugin(_temp) {
269
+ var _ref = _temp === void 0 ? {} : _temp,
270
+ cldImage = _ref.cldImage,
271
+ cldOptions = _ref.cldOptions;
272
+
273
+ var tint = cldOptions.tint;
274
+
275
+ if (tint) {
276
+ cldImage.effect("e_tint:" + tint);
277
+ }
278
+ }
279
+
280
+ var _excluded$1 = ["publicId", "type", "position", "text", "effects"];
281
+ function underlaysPlugin(_temp) {
282
+ var _ref = _temp === void 0 ? {} : _temp,
283
+ cldImage = _ref.cldImage,
284
+ cldOptions = _ref.cldOptions;
285
+
286
+ var _cldOptions$underlays = cldOptions.underlays,
287
+ underlays = _cldOptions$underlays === void 0 ? [] : _cldOptions$underlays;
288
+ var typeQualifier = 'u';
289
+ underlays.forEach(function (_ref2) {
290
+ var publicId = _ref2.publicId,
291
+ type = _ref2.type,
292
+ position$1 = _ref2.position,
293
+ _ref2$effects = _ref2.effects,
294
+ layerEffects = _ref2$effects === void 0 ? [] : _ref2$effects,
295
+ options = _objectWithoutPropertiesLoose(_ref2, _excluded$1);
296
+
297
+ var hasPublicId = typeof publicId === 'string';
298
+ var hasPosition = typeof position$1 === 'object';
299
+
300
+ if (!hasPublicId) {
301
+ console.warn("An " + type + " is missing a Public ID");
302
+ return;
303
+ } // Start to construct the transformation string using text or the public ID
304
+ // if it's image-based
305
+
306
+
307
+ var layerTransformation = typeQualifier + "_" + publicId.replace(/\//g, ':'); // Begin organizing transformations based on what it is and the location
308
+ // it needs to be placed in the URL
309
+
310
+ var primary$1 = [];
311
+ var applied = []; // Gemeral options
312
+
313
+ Object.keys(options).forEach(function (key) {
314
+ if (!primary[key]) return;
315
+ var qualifier = primary[key].qualifier;
316
+ primary$1.push(qualifier + "_" + options[key]);
317
+ }); // Layer effects
318
+
319
+ layerEffects.forEach(function (effect) {
320
+ Object.keys(effect).forEach(function (key) {
321
+ if (!primary[key]) return;
322
+ var qualifier = primary[key].qualifier;
323
+ primary$1.push(qualifier + "_" + effect[key]);
324
+ });
325
+ }); // Positioning
326
+
327
+ if (hasPosition) {
328
+ Object.keys(position$1).forEach(function (key) {
329
+ if (!position[key]) return;
330
+ var qualifier = position[key].qualifier;
331
+ applied.push(qualifier + "_" + position$1[key]);
332
+ });
333
+ } // Add all primary transformations
334
+
335
+
336
+ layerTransformation = layerTransformation + "," + primary$1.join(','); // Add all applied transformations
337
+
338
+ layerTransformation = layerTransformation + "/fl_layer_apply";
339
+
340
+ if (applied.length > 0) {
341
+ layerTransformation = layerTransformation + "," + applied.join(',');
342
+ } // Finally add it to the image
343
+
344
+
345
+ cldImage.addTransformation(layerTransformation);
346
+ });
347
+ }
348
+
349
+ var cld = new Cloudinary({
350
+ cloud: {
351
+ cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
352
+ }
353
+ });
354
+ var transformationPlugins = [// Background Removal must always come first
355
+ removeBackgroundPlugin, croppingPlugin, tintPlugin, overlaysPlugin, underlaysPlugin];
356
+ function cloudinaryLoader(options, cldOptions) {
357
+ var src = options.src,
358
+ _options$format = options.format,
359
+ format = _options$format === void 0 ? 'auto' : _options$format,
360
+ _options$quality = options.quality,
361
+ quality = _options$quality === void 0 ? 'auto' : _options$quality;
362
+ var cldImage = cld.image(src);
363
+ transformationPlugins.forEach(function (plugin) {
364
+ plugin({
365
+ cldImage: cldImage,
366
+ options: options,
367
+ cldOptions: cldOptions
368
+ });
369
+ });
370
+ return cldImage.format(format).delivery("q_" + quality).toURL();
371
+ }
372
+
373
+ var _excluded = ["crop", "gravity", "overlays", "removeBackground", "tint", "underlays"];
213
374
 
214
375
  var CldImage = function CldImage(_ref) {
215
- var overlays = _ref.overlays,
376
+ var crop = _ref.crop,
377
+ gravity = _ref.gravity,
378
+ overlays = _ref.overlays,
216
379
  removeBackground = _ref.removeBackground,
380
+ tint = _ref.tint,
217
381
  underlays = _ref.underlays,
218
382
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
219
383
 
220
384
  var cldOptions = {
385
+ crop: crop,
386
+ gravity: gravity,
221
387
  overlays: overlays,
222
388
  removeBackground: removeBackground,
389
+ tint: tint,
223
390
  underlays: underlays
224
391
  };
225
- return /*#__PURE__*/jsx(Image, _extends({}, props, {
392
+ var imageProps = {}; // If we see a placeholder option, configure a Cloudinary-based URL.
393
+ // The resulting image will always be blurred per Next.js, so we're
394
+ // limited on options for placeholders.
395
+ // https://nextjs.org/docs/api-reference/next/image#blurdataurl
396
+
397
+ if (props.placeholder) {
398
+ imageProps.blurDataURL = createPlaceholderUrl({
399
+ src: props.src,
400
+ placeholder: props.placeholder
401
+ });
402
+
403
+ if (props.placeholder !== 'blur') {
404
+ props.placeholder = 'blur';
405
+ }
406
+ }
407
+
408
+ return /*#__PURE__*/jsx(Image, _extends({}, imageProps, props, {
226
409
  loader: function loader(options) {
227
- return cloudinaryLoader(options, cldOptions);
410
+ return cloudinaryLoader(_extends({}, props, {
411
+ options: options
412
+ }), cldOptions);
228
413
  }
229
414
  }));
230
415
  };
@@ -1 +1 @@
1
- {"version":3,"file":"next-cloudinary.module.js","sources":["../src/constants/qualifiers.js","../src/loaders/cloudinary-loader.js","../src/components/CldImage/CldImage.js"],"sourcesContent":["export const primary = {\n gravity: {\n qualifier: 'g'\n },\n crop: {\n qualifier: 'c'\n },\n width: {\n qualifier: 'w'\n },\n height: {\n qualifier: 'h'\n }\n};\n\nexport const position = {\n x: {\n qualifier: 'x'\n },\n y: {\n qualifier: 'y'\n },\n gravity: {\n qualifier: 'g'\n },\n}\n\nexport const text = {\n color: {\n qualifier: 'co',\n location: 'primary'\n },\n fontFamily: {\n },\n fontSize: {\n },\n fontWeight: {\n },\n textDecoration: {\n },\n letterSpacing: {\n qualifier: 'letter_spacing'\n }\n}","import { Cloudinary } from '@cloudinary/url-gen';\n\nimport {\n primary as qualifiersPrimary,\n text as qualifiersText,\n position as qualifiersPosition\n} from '../constants/qualifiers';\n\nconst cld = new Cloudinary({\n cloud: {\n cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME\n }\n});\n\nexport function cloudinaryLoader(options, cldOptions) {\n const {\n src,\n width,\n format = 'auto',\n quality = 'auto',\n } = options;\n\n const {\n overlays = [],\n effects = [],\n removeBackground = false,\n underlays = []\n } = cldOptions;\n\n const cldImage = cld.image(src);\n\n if ( removeBackground ) {\n cldImage.effect('e_background_removal');\n }\n\n // Adding overlays and underlays allows you to compose your image\n // by using layering with overlays appearing on top of and udnerlays\n // appearing below your base image layer\n //\n // Learn more: https://cloudinary.com/documentation/layers\n\n const layers = [\n ...overlays.map(overlay => ({ ...overlay, type: 'overlay' })),\n ...underlays.map(underlay => ({ ...underlay, type: 'underlay' })),\n ];\n\n layers.forEach(({ publicId, type, position, text, effects: layerEffects = [], ...options }) => {\n const hasPublicId = typeof publicId === 'string';\n const hasText = typeof text === 'object';\n const hasPosition = typeof position === 'object';\n\n if ( !hasPublicId && !hasText ) {\n console.warn(`${type} is missing Public ID or Text`);\n return;\n }\n\n // Determine the qualifier for the type of layer\n\n let typeQualifier;\n\n if ( type === 'overlay' ) {\n typeQualifier = 'l';\n } else if ( type === 'underlay' ) {\n typeQualifier = 'u';\n }\n\n // Start to construct the transformation string using text or the public ID\n // if it's image-based\n\n let layerTransformation;\n\n if ( hasText ) {\n layerTransformation = `${typeQualifier}_text`;\n } else {\n layerTransformation = `${typeQualifier}_${publicId.replace(/\\//g, ':')}`;\n }\n\n // Begin organizing transformations based on what it is and the location\n // it needs to be placed in the URL\n\n const primary = [];\n const applied = [];\n\n // Gemeral options\n\n Object.keys(options).forEach(key => {\n if ( !qualifiersPrimary[key] ) return;\n const { qualifier } = qualifiersPrimary[key];\n primary.push(`${qualifier}_${options[key]}`);\n });\n\n // Layer effects\n\n layerEffects.forEach(effect => {\n Object.keys(effect).forEach(key => {\n if ( !qualifiersPrimary[key] ) return;\n const { qualifier } = qualifiersPrimary[key];\n primary.push(`${qualifier}_${effect[key]}`);\n });\n });\n\n // Text styling\n\n if ( hasText ) {\n const textTransformations = [];\n\n Object.keys(text).forEach(key => {\n if ( !qualifiersText[key] ) return;\n\n const { qualifier, location } = qualifiersText[key];\n\n if ( location === 'primary' ) {\n primary.push(`${qualifier}_${text[key]}`);\n } else {\n textTransformations.push(text[key]);\n }\n });\n\n layerTransformation = `${layerTransformation}:${textTransformations.join('_')}:${text.text}`\n }\n\n // Positioning\n\n if ( hasPosition ) {\n Object.keys(position).forEach(key => {\n if ( !qualifiersPosition[key] ) return;\n\n const { qualifier } = qualifiersPosition[key];\n\n applied.push(`${qualifier}_${position[key]}`);\n });\n }\n\n // Add all primary transformations\n\n layerTransformation = `${layerTransformation},${primary.join(',')}`;\n\n // Add all applied transformations\n\n layerTransformation = `${layerTransformation}/fl_layer_apply`;\n\n if ( applied.length > 0 ) {\n layerTransformation = `${layerTransformation},${applied.join(',')}`;\n }\n\n // Finally add it to the image\n\n cldImage.addTransformation(layerTransformation);\n });\n\n return cldImage.resize(`c_limit,w_${width}`).format(format).delivery(`q_${quality}`).toURL();\n}","\nimport Image from 'next/image';\n\nimport { cloudinaryLoader } from '../../loaders/cloudinary-loader';\n\nconst CldImage = ({ overlays, removeBackground, underlays, ...props }) => {\n const cldOptions = {\n overlays,\n removeBackground,\n underlays,\n };\n return <Image {...props} loader={(options) => cloudinaryLoader(options, cldOptions)} />\n}\n\nexport default CldImage;"],"names":["primary","gravity","qualifier","crop","width","height","position","x","y","text","color","location","fontFamily","fontSize","fontWeight","textDecoration","letterSpacing","cld","Cloudinary","cloud","cloudName","process","env","NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME","cloudinaryLoader","options","cldOptions","src","format","quality","overlays","removeBackground","underlays","cldImage","image","effect","layers","map","overlay","type","underlay","forEach","publicId","effects","layerEffects","_excluded","hasPublicId","hasText","hasPosition","console","warn","typeQualifier","layerTransformation","replace","applied","Object","keys","key","qualifiersPrimary","push","textTransformations","qualifiersText","join","qualifiersPosition","length","addTransformation","resize","delivery","toURL","CldImage","props","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAMA,OAAO,GAAG;AACrBC,EAAAA,OAAO,EAAE;AACPC,IAAAA,SAAS,EAAE,GAAA;GAFQ;AAIrBC,EAAAA,IAAI,EAAE;AACJD,IAAAA,SAAS,EAAE,GAAA;GALQ;AAOrBE,EAAAA,KAAK,EAAE;AACLF,IAAAA,SAAS,EAAE,GAAA;GARQ;AAUrBG,EAAAA,MAAM,EAAE;AACNH,IAAAA,SAAS,EAAE,GAAA;AADL,G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EAAhBA,gBAFiB;AAGjBC,IAAAA,SAAS,EAATA,SAAAA;GAHF,CAAA;EAKA,oBAAOuC,GAAA,CAAC,KAAD,EAAA,QAAA,CAAA,EAAA,EAAWD,KAAX,EAAA;IAAkB,MAAM,EAAE,gBAAC7C,OAAD,EAAA;AAAA,MAAA,OAAaD,gBAAgB,CAACC,OAAD,EAAUC,UAAV,CAA7B,CAAA;AAAA,KAAA;GAAjC,CAAA,CAAA,CAAA;AACD;;;;"}
1
+ {"version":3,"file":"next-cloudinary.module.js","sources":["../src/lib/cloudinary.js","../src/plugins/cropping.js","../src/constants/qualifiers.js","../src/plugins/overlays.js","../src/plugins/remove-background.js","../src/plugins/tint.js","../src/plugins/underlays.js","../src/loaders/cloudinary-loader.js","../src/components/CldImage/CldImage.js"],"sourcesContent":["import { Cloudinary } from '@cloudinary/url-gen';\n\nconst cld = new Cloudinary({\n cloud: {\n cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME\n },\n url: {\n // Used to avoid issues with SSR particularly for the blurred placeholder\n analytics: false\n }\n});\n\n/**\n * createPlaceholderUrl\n */\n\nexport function createPlaceholderUrl({ src, placeholder }) {\n const cldImage = cld.image(src)\n .resize('c_limit,w_100')\n .delivery('q_1')\n .format('auto');\n\n if ( placeholder === 'grayscale' ) {\n cldImage.effect('e_grayscale');\n }\n\n if ( placeholder.includes('color:') ) {\n const color = placeholder.split(':').splice(1).join(':')\n cldImage.effect('e_grayscale');\n cldImage.effect(`e_colorize:60,co_${color}`);\n }\n\n return cldImage.toURL();\n}","const cropsGravityAuto = [ 'crop', 'fill', 'lfill', 'fill_pad', 'thumb' ];\n\nexport function croppingPlugin({ cldImage, options, cldOptions } = {}) {\n const { width, height } = options;\n const { crop = 'limit', gravity } = cldOptions;\n\n let transformationString = `c_${crop},w_${width}`;\n\n if ( !gravity && cropsGravityAuto.includes(crop) ) {\n gravity = 'auto';\n }\n\n if ( !['limit'].includes(crop) ) {\n transformationString = `${transformationString},h_${height}`;\n }\n\n if ( gravity ) {\n if ( gravity === 'auto' && !cropsGravityAuto.includes(crop) ) {\n console.warn('Auto gravity can only be used with crop, fill, lfill, fill_pad or thumb. Not applying gravity.');\n } else {\n transformationString = `${transformationString},g_${gravity}`;\n }\n }\n\n cldImage.resize(transformationString);\n}","// aspectRatio\n\nexport const primary = {\n aspectRatio: {\n qualifier: 'ar'\n },\n crop: {\n qualifier: 'c'\n },\n gravity: {\n qualifier: 'g'\n },\n height: {\n qualifier: 'h'\n },\n width: {\n qualifier: 'w'\n },\n};\n\nexport const position = {\n angle: {\n qualifier: 'a'\n },\n gravity: {\n qualifier: 'g'\n },\n x: {\n qualifier: 'x'\n },\n y: {\n qualifier: 'y'\n },\n}\n\nexport const text = {\n color: {\n qualifier: 'co',\n location: 'primary'\n },\n textDecoration: {\n qualifier: false\n },\n fontFamily: {\n qualifier: false\n },\n fontSize: {\n qualifier: false\n },\n fontWeight: {\n qualifier: false\n },\n letterSpacing: {\n qualifier: 'letter_spacing'\n }\n}","import {\n primary as qualifiersPrimary,\n text as qualifiersText,\n position as qualifiersPosition\n} from '../constants/qualifiers';\n\nexport function overlaysPlugin({ cldImage, options, cldOptions } = {}) {\n const { overlays = [] } = cldOptions;\n\n const type = 'overlay';\n const typeQualifier = 'l';\n\n overlays.forEach(({ publicId, position, text, effects: layerEffects = [], ...options }) => {\n const hasPublicId = typeof publicId === 'string';\n const hasText = typeof text === 'object';\n const hasPosition = typeof position === 'object';\n\n if ( !hasPublicId && !hasText ) {\n console.warn(`An ${type} is missing Public ID or Text`);\n return;\n }\n\n // Start to construct the transformation string using text or the public ID\n // if it's image-based\n\n let layerTransformation;\n\n if ( hasText ) {\n layerTransformation = `${typeQualifier}_text`;\n } else {\n layerTransformation = `${typeQualifier}_${publicId.replace(/\\//g, ':')}`;\n }\n\n // Begin organizing transformations based on what it is and the location\n // it needs to be placed in the URL\n\n const primary = [];\n const applied = [];\n\n // Gemeral options\n\n Object.keys(options).forEach(key => {\n if ( !qualifiersPrimary[key] ) return;\n const { qualifier } = qualifiersPrimary[key];\n primary.push(`${qualifier}_${options[key]}`);\n });\n\n // Layer effects\n\n layerEffects.forEach(effect => {\n Object.keys(effect).forEach(key => {\n if ( !qualifiersPrimary[key] ) return;\n const { qualifier } = qualifiersPrimary[key];\n primary.push(`${qualifier}_${effect[key]}`);\n });\n });\n\n // Text styling\n\n if ( hasText ) {\n const textTransformations = [];\n\n Object.keys(text).forEach(key => {\n if ( !qualifiersText[key] ) return;\n\n const { qualifier, location } = qualifiersText[key];\n\n if ( location === 'primary' ) {\n primary.push(`${qualifier}_${text[key]}`);\n } else {\n textTransformations.push(text[key]);\n }\n });\n\n layerTransformation = `${layerTransformation}:${textTransformations.join('_')}:${text.text}`\n }\n\n // Positioning\n\n if ( hasPosition ) {\n Object.keys(position).forEach(key => {\n if ( !qualifiersPosition[key] ) return;\n\n const { qualifier } = qualifiersPosition[key];\n\n applied.push(`${qualifier}_${position[key]}`);\n });\n }\n\n // Add all primary transformations\n\n layerTransformation = `${layerTransformation},${primary.join(',')}`;\n\n // Add all applied transformations\n\n layerTransformation = `${layerTransformation}/fl_layer_apply`;\n\n if ( applied.length > 0 ) {\n layerTransformation = `${layerTransformation},${applied.join(',')}`;\n }\n\n // Finally add it to the image\n\n cldImage.addTransformation(layerTransformation);\n });\n}","export function removeBackgroundPlugin({ cldImage, options, cldOptions } = {}) {\n const { removeBackground = false } = cldOptions;\n if ( removeBackground ) {\n cldImage.effect('e_background_removal');\n }\n}","export function tintPlugin({ cldImage, options, cldOptions } = {}) {\n const { tint } = cldOptions;\n\n if ( tint ) {\n cldImage.effect(`e_tint:${tint}`);\n }\n}","import {\n primary as qualifiersPrimary,\n text as qualifiersText,\n position as qualifiersPosition\n} from '../constants/qualifiers';\n\nexport function underlaysPlugin({ cldImage, options, cldOptions } = {}) {\n const { underlays = [] } = cldOptions;\n\n const type = 'underlay';\n const typeQualifier = 'u';\n\n underlays.forEach(({ publicId, type, position, text, effects: layerEffects = [], ...options }) => {\n const hasPublicId = typeof publicId === 'string';\n const hasPosition = typeof position === 'object';\n\n if ( !hasPublicId ) {\n console.warn(`An ${type} is missing a Public ID`);\n return;\n }\n\n // Start to construct the transformation string using text or the public ID\n // if it's image-based\n\n let layerTransformation = `${typeQualifier}_${publicId.replace(/\\//g, ':')}`;\n\n // Begin organizing transformations based on what it is and the location\n // it needs to be placed in the URL\n\n const primary = [];\n const applied = [];\n\n // Gemeral options\n\n Object.keys(options).forEach(key => {\n if ( !qualifiersPrimary[key] ) return;\n const { qualifier } = qualifiersPrimary[key];\n primary.push(`${qualifier}_${options[key]}`);\n });\n\n // Layer effects\n\n layerEffects.forEach(effect => {\n Object.keys(effect).forEach(key => {\n if ( !qualifiersPrimary[key] ) return;\n const { qualifier } = qualifiersPrimary[key];\n primary.push(`${qualifier}_${effect[key]}`);\n });\n });\n\n // Positioning\n\n if ( hasPosition ) {\n Object.keys(position).forEach(key => {\n if ( !qualifiersPosition[key] ) return;\n\n const { qualifier } = qualifiersPosition[key];\n\n applied.push(`${qualifier}_${position[key]}`);\n });\n }\n\n // Add all primary transformations\n\n layerTransformation = `${layerTransformation},${primary.join(',')}`;\n\n // Add all applied transformations\n\n layerTransformation = `${layerTransformation}/fl_layer_apply`;\n\n if ( applied.length > 0 ) {\n layerTransformation = `${layerTransformation},${applied.join(',')}`;\n }\n\n // Finally add it to the image\n\n cldImage.addTransformation(layerTransformation);\n });\n}","import { Cloudinary } from '@cloudinary/url-gen';\n\nimport { croppingPlugin } from '../plugins/cropping';\nimport { overlaysPlugin } from '../plugins/overlays';\nimport { removeBackgroundPlugin } from '../plugins/remove-background';\nimport { tintPlugin } from '../plugins/tint';\nimport { underlaysPlugin } from '../plugins/underlays';\n\nimport {\n primary as qualifiersPrimary,\n text as qualifiersText,\n position as qualifiersPosition\n} from '../constants/qualifiers';\n\nconst cld = new Cloudinary({\n cloud: {\n cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME\n },\n});\n\nconst transformationPlugins = [\n // Background Removal must always come first\n removeBackgroundPlugin,\n\n croppingPlugin,\n tintPlugin,\n overlaysPlugin,\n underlaysPlugin\n];\n\nexport function cloudinaryLoader(options, cldOptions) {\n const {\n src,\n width,\n format = 'auto',\n quality = 'auto',\n } = options;\n\n const cldImage = cld.image(src);\n\n transformationPlugins.forEach(plugin => {\n plugin({\n cldImage,\n options,\n cldOptions\n });\n });\n\n return cldImage.format(format).delivery(`q_${quality}`).toURL();\n}","import Image from 'next/image';\n\nimport { createPlaceholderUrl } from '../../lib/cloudinary';\nimport { cloudinaryLoader } from '../../loaders/cloudinary-loader';\n\nconst CldImage = ({ crop, gravity, overlays, removeBackground, tint, underlays, ...props }) => {\n const cldOptions = {\n crop,\n gravity,\n overlays,\n removeBackground,\n tint,\n underlays,\n };\n\n const imageProps = {};\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 // https://nextjs.org/docs/api-reference/next/image#blurdataurl\n\n if ( props.placeholder ) {\n imageProps.blurDataURL = createPlaceholderUrl({\n src: props.src,\n placeholder: props.placeholder\n });\n\n if ( props.placeholder !== 'blur' ) {\n props.placeholder = 'blur';\n }\n }\n\n return (\n <Image\n {...imageProps}\n {...props}\n loader={(options) => cloudinaryLoader({ ...props, options }, cldOptions)}\n />\n );\n}\n\nexport default CldImage;"],"names":["cld","Cloudinary","cloud","cloudName","process","env","NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME","url","analytics","createPlaceholderUrl","src","placeholder","cldImage","image","resize","delivery","format","effect","includes","color","split","splice","join","toURL","cropsGravityAuto","croppingPlugin","options","cldOptions","width","height","crop","gravity","transformationString","console","warn","primary","aspectRatio","qualifier","position","angle","x","y","text","location","textDecoration","fontFamily","fontSize","fontWeight","letterSpacing","overlaysPlugin","overlays","type","typeQualifier","forEach","publicId","effects","layerEffects","_excluded","hasPublicId","hasText","hasPosition","layerTransformation","replace","applied","Object","keys","key","qualifiersPrimary","push","textTransformations","qualifiersText","qualifiersPosition","length","addTransformation","removeBackgroundPlugin","removeBackground","tintPlugin","tint","underlaysPlugin","underlays","transformationPlugins","cloudinaryLoader","quality","plugin","CldImage","props","imageProps","blurDataURL","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,KAAG,GAAG,IAAIC,UAAJ,CAAe;AACzBC,EAAAA,KAAK,EAAE;AACLC,IAAAA,SAAS,EAAEC,OAAO,CAACC,GAAR,CAAYC,iCAAAA;GAFA;AAIzBC,EAAAA,GAAG,EAAE;AACH;AACAC,IAAAA,SAAS,EAAE,KAAA;AAFR,GAAA;AAJoB,CAAf,CAAZ,CAAA;AAUA;AACA;AACA;;AAEO,SAASC,oBAAT,CAAoD,IAAA,EAAA;EAAA,IAApBC,GAAoB,QAApBA,GAAoB;MAAfC,WAAe,QAAfA,WAAe,CAAA;AACzD,EAAA,IAAMC,QAAQ,GAAGZ,KAAG,CAACa,KAAJ,CAAUH,GAAV,CACII,CAAAA,MADJ,CACW,eADX,CAAA,CAEIC,QAFJ,CAEa,KAFb,EAGIC,MAHJ,CAGW,MAHX,CAAjB,CAAA;;EAKA,IAAKL,WAAW,KAAK,WAArB,EAAmC;IACjCC,QAAQ,CAACK,MAAT,CAAgB,aAAhB,CAAA,CAAA;AACD,GAAA;;AAED,EAAA,IAAKN,WAAW,CAACO,QAAZ,CAAqB,QAArB,CAAL,EAAsC;AACpC,IAAA,IAAMC,KAAK,GAAGR,WAAW,CAACS,KAAZ,CAAkB,GAAlB,CAAuBC,CAAAA,MAAvB,CAA8B,CAA9B,CAAA,CAAiCC,IAAjC,CAAsC,GAAtC,CAAd,CAAA;IACAV,QAAQ,CAACK,MAAT,CAAgB,aAAhB,CAAA,CAAA;IACAL,QAAQ,CAACK,MAAT,CAAA,mBAAA,GAAoCE,KAApC,CAAA,CAAA;AACD,GAAA;;EAED,OAAOP,QAAQ,CAACW,KAAT,EAAP,CAAA;AACD;;ACjC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