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.
@@ -38,29 +38,104 @@ function _objectWithoutPropertiesLoose(source, excluded) {
38
38
  return target;
39
39
  }
40
40
 
41
+ function _readOnlyError(name) {
42
+ throw new TypeError("\"" + name + "\" is read-only");
43
+ }
44
+
45
+ var cld$1 = new urlGen.Cloudinary({
46
+ cloud: {
47
+ cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
48
+ },
49
+ url: {
50
+ // Used to avoid issues with SSR particularly for the blurred placeholder
51
+ analytics: false
52
+ }
53
+ });
54
+ /**
55
+ * createPlaceholderUrl
56
+ */
57
+
58
+ function createPlaceholderUrl(_ref) {
59
+ var src = _ref.src,
60
+ placeholder = _ref.placeholder;
61
+ var cldImage = cld$1.image(src).resize('c_limit,w_100').delivery('q_1').format('auto');
62
+
63
+ if (placeholder === 'grayscale') {
64
+ cldImage.effect('e_grayscale');
65
+ }
66
+
67
+ if (placeholder.includes('color:')) {
68
+ var color = placeholder.split(':').splice(1).join(':');
69
+ cldImage.effect('e_grayscale');
70
+ cldImage.effect("e_colorize:60,co_" + color);
71
+ }
72
+
73
+ return cldImage.toURL();
74
+ }
75
+
76
+ var cropsGravityAuto = ['crop', 'fill', 'lfill', 'fill_pad', 'thumb'];
77
+ function croppingPlugin(_temp) {
78
+ var _ref = _temp === void 0 ? {} : _temp,
79
+ cldImage = _ref.cldImage,
80
+ options = _ref.options,
81
+ cldOptions = _ref.cldOptions;
82
+
83
+ var width = options.width,
84
+ height = options.height;
85
+ var _cldOptions$crop = cldOptions.crop,
86
+ crop = _cldOptions$crop === void 0 ? 'limit' : _cldOptions$crop,
87
+ gravity = cldOptions.gravity;
88
+ var transformationString = "c_" + crop + ",w_" + width;
89
+
90
+ if (!gravity && cropsGravityAuto.includes(crop)) {
91
+ _readOnlyError("gravity");
92
+ }
93
+
94
+ if (!['limit'].includes(crop)) {
95
+ transformationString = transformationString + ",h_" + height;
96
+ }
97
+
98
+ if (gravity) {
99
+ if (gravity === 'auto' && !cropsGravityAuto.includes(crop)) {
100
+ console.warn('Auto gravity can only be used with crop, fill, lfill, fill_pad or thumb. Not applying gravity.');
101
+ } else {
102
+ transformationString = transformationString + ",g_" + gravity;
103
+ }
104
+ }
105
+
106
+ cldImage.resize(transformationString);
107
+ }
108
+
109
+ // aspectRatio
41
110
  var primary = {
42
- gravity: {
43
- qualifier: 'g'
111
+ aspectRatio: {
112
+ qualifier: 'ar'
44
113
  },
45
114
  crop: {
46
115
  qualifier: 'c'
47
116
  },
48
- width: {
49
- qualifier: 'w'
117
+ gravity: {
118
+ qualifier: 'g'
50
119
  },
51
120
  height: {
52
121
  qualifier: 'h'
122
+ },
123
+ width: {
124
+ qualifier: 'w'
53
125
  }
54
126
  };
55
127
  var position = {
128
+ angle: {
129
+ qualifier: 'a'
130
+ },
131
+ gravity: {
132
+ qualifier: 'g'
133
+ },
56
134
  x: {
57
135
  qualifier: 'x'
58
136
  },
59
137
  y: {
60
138
  qualifier: 'y'
61
- },
62
- gravity: {
63
- qualifier: 'g'
64
139
  }
65
140
  };
66
141
  var text = {
@@ -68,79 +143,48 @@ var text = {
68
143
  qualifier: 'co',
69
144
  location: 'primary'
70
145
  },
71
- fontFamily: {},
72
- fontSize: {},
73
- fontWeight: {},
74
- textDecoration: {},
146
+ textDecoration: {
147
+ qualifier: false
148
+ },
149
+ fontFamily: {
150
+ qualifier: false
151
+ },
152
+ fontSize: {
153
+ qualifier: false
154
+ },
155
+ fontWeight: {
156
+ qualifier: false
157
+ },
75
158
  letterSpacing: {
76
159
  qualifier: 'letter_spacing'
77
160
  }
78
161
  };
79
162
 
80
- var _excluded$1 = ["publicId", "type", "position", "text", "effects"];
81
- var cld = new urlGen.Cloudinary({
82
- cloud: {
83
- cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
84
- }
85
- });
86
- function cloudinaryLoader(options, cldOptions) {
87
- var src = options.src,
88
- width = options.width,
89
- _options$format = options.format,
90
- format = _options$format === void 0 ? 'auto' : _options$format,
91
- _options$quality = options.quality,
92
- quality = _options$quality === void 0 ? 'auto' : _options$quality;
93
- var _cldOptions$overlays = cldOptions.overlays,
94
- overlays = _cldOptions$overlays === void 0 ? [] : _cldOptions$overlays,
95
- _cldOptions$removeBac = cldOptions.removeBackground,
96
- removeBackground = _cldOptions$removeBac === void 0 ? false : _cldOptions$removeBac,
97
- _cldOptions$underlays = cldOptions.underlays,
98
- underlays = _cldOptions$underlays === void 0 ? [] : _cldOptions$underlays;
99
- var cldImage = cld.image(src);
100
-
101
- if (removeBackground) {
102
- cldImage.effect('e_background_removal');
103
- } // Adding overlays and underlays allows you to compose your image
104
- // by using layering with overlays appearing on top of and udnerlays
105
- // appearing below your base image layer
106
- //
107
- // Learn more: https://cloudinary.com/documentation/layers
108
-
163
+ var _excluded$2 = ["publicId", "position", "text", "effects"];
164
+ function overlaysPlugin(_temp) {
165
+ var _ref = _temp === void 0 ? {} : _temp,
166
+ cldImage = _ref.cldImage,
167
+ cldOptions = _ref.cldOptions;
109
168
 
110
- var layers = [].concat(overlays.map(function (overlay) {
111
- return _extends({}, overlay, {
112
- type: 'overlay'
113
- });
114
- }), underlays.map(function (underlay) {
115
- return _extends({}, underlay, {
116
- type: 'underlay'
117
- });
118
- }));
119
- layers.forEach(function (_ref) {
120
- var publicId = _ref.publicId,
121
- type = _ref.type,
122
- position$1 = _ref.position,
123
- text$1 = _ref.text,
124
- _ref$effects = _ref.effects,
125
- layerEffects = _ref$effects === void 0 ? [] : _ref$effects,
126
- options = _objectWithoutPropertiesLoose(_ref, _excluded$1);
169
+ var _cldOptions$overlays = cldOptions.overlays,
170
+ overlays = _cldOptions$overlays === void 0 ? [] : _cldOptions$overlays;
171
+ var type = 'overlay';
172
+ var typeQualifier = 'l';
173
+ overlays.forEach(function (_ref2) {
174
+ var publicId = _ref2.publicId,
175
+ position$1 = _ref2.position,
176
+ text$1 = _ref2.text,
177
+ _ref2$effects = _ref2.effects,
178
+ layerEffects = _ref2$effects === void 0 ? [] : _ref2$effects,
179
+ options = _objectWithoutPropertiesLoose(_ref2, _excluded$2);
127
180
 
128
181
  var hasPublicId = typeof publicId === 'string';
129
182
  var hasText = typeof text$1 === 'object';
130
183
  var hasPosition = typeof position$1 === 'object';
131
184
 
132
185
  if (!hasPublicId && !hasText) {
133
- console.warn(type + " is missing Public ID or Text");
186
+ console.warn("An " + type + " is missing Public ID or Text");
134
187
  return;
135
- } // Determine the qualifier for the type of layer
136
-
137
-
138
- var typeQualifier;
139
-
140
- if (type === 'overlay') {
141
- typeQualifier = 'l';
142
- } else if (type === 'underlay') {
143
- typeQualifier = 'u';
144
188
  } // Start to construct the transformation string using text or the public ID
145
189
  // if it's image-based
146
190
 
@@ -210,25 +254,166 @@ function cloudinaryLoader(options, cldOptions) {
210
254
 
211
255
  cldImage.addTransformation(layerTransformation);
212
256
  });
213
- return cldImage.resize("c_limit,w_" + width).format(format).delivery("q_" + quality).toURL();
214
257
  }
215
258
 
216
- var _excluded = ["overlays", "removeBackground", "underlays"];
259
+ function removeBackgroundPlugin(_temp) {
260
+ var _ref = _temp === void 0 ? {} : _temp,
261
+ cldImage = _ref.cldImage,
262
+ cldOptions = _ref.cldOptions;
263
+
264
+ var _cldOptions$removeBac = cldOptions.removeBackground,
265
+ removeBackground = _cldOptions$removeBac === void 0 ? false : _cldOptions$removeBac;
266
+
267
+ if (removeBackground) {
268
+ cldImage.effect('e_background_removal');
269
+ }
270
+ }
271
+
272
+ function tintPlugin(_temp) {
273
+ var _ref = _temp === void 0 ? {} : _temp,
274
+ cldImage = _ref.cldImage,
275
+ cldOptions = _ref.cldOptions;
276
+
277
+ var tint = cldOptions.tint;
278
+
279
+ if (tint) {
280
+ cldImage.effect("e_tint:" + tint);
281
+ }
282
+ }
283
+
284
+ var _excluded$1 = ["publicId", "type", "position", "text", "effects"];
285
+ function underlaysPlugin(_temp) {
286
+ var _ref = _temp === void 0 ? {} : _temp,
287
+ cldImage = _ref.cldImage,
288
+ cldOptions = _ref.cldOptions;
289
+
290
+ var _cldOptions$underlays = cldOptions.underlays,
291
+ underlays = _cldOptions$underlays === void 0 ? [] : _cldOptions$underlays;
292
+ var typeQualifier = 'u';
293
+ underlays.forEach(function (_ref2) {
294
+ var publicId = _ref2.publicId,
295
+ type = _ref2.type,
296
+ position$1 = _ref2.position,
297
+ _ref2$effects = _ref2.effects,
298
+ layerEffects = _ref2$effects === void 0 ? [] : _ref2$effects,
299
+ options = _objectWithoutPropertiesLoose(_ref2, _excluded$1);
300
+
301
+ var hasPublicId = typeof publicId === 'string';
302
+ var hasPosition = typeof position$1 === 'object';
303
+
304
+ if (!hasPublicId) {
305
+ console.warn("An " + type + " is missing a Public ID");
306
+ return;
307
+ } // Start to construct the transformation string using text or the public ID
308
+ // if it's image-based
309
+
310
+
311
+ var layerTransformation = typeQualifier + "_" + publicId.replace(/\//g, ':'); // Begin organizing transformations based on what it is and the location
312
+ // it needs to be placed in the URL
313
+
314
+ var primary$1 = [];
315
+ var applied = []; // Gemeral options
316
+
317
+ Object.keys(options).forEach(function (key) {
318
+ if (!primary[key]) return;
319
+ var qualifier = primary[key].qualifier;
320
+ primary$1.push(qualifier + "_" + options[key]);
321
+ }); // Layer effects
322
+
323
+ layerEffects.forEach(function (effect) {
324
+ Object.keys(effect).forEach(function (key) {
325
+ if (!primary[key]) return;
326
+ var qualifier = primary[key].qualifier;
327
+ primary$1.push(qualifier + "_" + effect[key]);
328
+ });
329
+ }); // Positioning
330
+
331
+ if (hasPosition) {
332
+ Object.keys(position$1).forEach(function (key) {
333
+ if (!position[key]) return;
334
+ var qualifier = position[key].qualifier;
335
+ applied.push(qualifier + "_" + position$1[key]);
336
+ });
337
+ } // Add all primary transformations
338
+
339
+
340
+ layerTransformation = layerTransformation + "," + primary$1.join(','); // Add all applied transformations
341
+
342
+ layerTransformation = layerTransformation + "/fl_layer_apply";
343
+
344
+ if (applied.length > 0) {
345
+ layerTransformation = layerTransformation + "," + applied.join(',');
346
+ } // Finally add it to the image
347
+
348
+
349
+ cldImage.addTransformation(layerTransformation);
350
+ });
351
+ }
352
+
353
+ var cld = new urlGen.Cloudinary({
354
+ cloud: {
355
+ cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
356
+ }
357
+ });
358
+ var transformationPlugins = [// Background Removal must always come first
359
+ removeBackgroundPlugin, croppingPlugin, tintPlugin, overlaysPlugin, underlaysPlugin];
360
+ function cloudinaryLoader(options, cldOptions) {
361
+ var src = options.src,
362
+ _options$format = options.format,
363
+ format = _options$format === void 0 ? 'auto' : _options$format,
364
+ _options$quality = options.quality,
365
+ quality = _options$quality === void 0 ? 'auto' : _options$quality;
366
+ var cldImage = cld.image(src);
367
+ transformationPlugins.forEach(function (plugin) {
368
+ plugin({
369
+ cldImage: cldImage,
370
+ options: options,
371
+ cldOptions: cldOptions
372
+ });
373
+ });
374
+ return cldImage.format(format).delivery("q_" + quality).toURL();
375
+ }
376
+
377
+ var _excluded = ["crop", "gravity", "overlays", "removeBackground", "tint", "underlays"];
217
378
 
218
379
  var CldImage = function CldImage(_ref) {
219
- var overlays = _ref.overlays,
380
+ var crop = _ref.crop,
381
+ gravity = _ref.gravity,
382
+ overlays = _ref.overlays,
220
383
  removeBackground = _ref.removeBackground,
384
+ tint = _ref.tint,
221
385
  underlays = _ref.underlays,
222
386
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
223
387
 
224
388
  var cldOptions = {
389
+ crop: crop,
390
+ gravity: gravity,
225
391
  overlays: overlays,
226
392
  removeBackground: removeBackground,
393
+ tint: tint,
227
394
  underlays: underlays
228
395
  };
229
- return /*#__PURE__*/jsxRuntime.jsx(Image__default["default"], _extends({}, props, {
396
+ var imageProps = {}; // If we see a placeholder option, configure a Cloudinary-based URL.
397
+ // The resulting image will always be blurred per Next.js, so we're
398
+ // limited on options for placeholders.
399
+ // https://nextjs.org/docs/api-reference/next/image#blurdataurl
400
+
401
+ if (props.placeholder) {
402
+ imageProps.blurDataURL = createPlaceholderUrl({
403
+ src: props.src,
404
+ placeholder: props.placeholder
405
+ });
406
+
407
+ if (props.placeholder !== 'blur') {
408
+ props.placeholder = 'blur';
409
+ }
410
+ }
411
+
412
+ return /*#__PURE__*/jsxRuntime.jsx(Image__default["default"], _extends({}, imageProps, props, {
230
413
  loader: function loader(options) {
231
- return cloudinaryLoader(options, cldOptions);
414
+ return cloudinaryLoader(_extends({}, props, {
415
+ options: options
416
+ }), cldOptions);
232
417
  }
233
418
  }));
234
419
  };
@@ -1 +1 @@
1
- {"version":3,"file":"next-cloudinary.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","Image"],"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,E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ACjBI,IAAAA,QAAQ,EAARA,QADiB;AAEjBC,IAAAA,gBAAgB,EAAhBA,gBAFiB;AAGjBC,IAAAA,SAAS,EAATA,SAAAA;GAHF,CAAA;EAKA,oBAAOuC,cAAA,CAACC,yBAAD,EAAA,QAAA,CAAA,EAAA,EAAWF,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.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","Image"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,KAAG,GAAG,IAAIC,iBAAJ,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,CA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