next-cloudinary 0.3.0 → 0.4.1

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.
@@ -15,31 +15,26 @@ function _extends() {
15
15
  _extends = Object.assign ? Object.assign.bind() : function (target) {
16
16
  for (var i = 1; i < arguments.length; i++) {
17
17
  var source = arguments[i];
18
-
19
18
  for (var key in source) {
20
19
  if (Object.prototype.hasOwnProperty.call(source, key)) {
21
20
  target[key] = source[key];
22
21
  }
23
22
  }
24
23
  }
25
-
26
24
  return target;
27
25
  };
28
26
  return _extends.apply(this, arguments);
29
27
  }
30
-
31
28
  function _objectWithoutPropertiesLoose(source, excluded) {
32
29
  if (source == null) return {};
33
30
  var target = {};
34
31
  var sourceKeys = Object.keys(source);
35
32
  var key, i;
36
-
37
33
  for (i = 0; i < sourceKeys.length; i++) {
38
34
  key = sourceKeys[i];
39
35
  if (excluded.indexOf(key) >= 0) continue;
40
36
  target[key] = source[key];
41
37
  }
42
-
43
38
  return target;
44
39
  }
45
40
 
@@ -47,23 +42,19 @@ var cropsGravityAuto = ['crop', 'fill', 'lfill', 'fill_pad', 'thumb'];
47
42
  var props$6 = ['crop', 'gravity'];
48
43
  function plugin$6(_temp) {
49
44
  var _ref = _temp === void 0 ? {} : _temp,
50
- cldImage = _ref.cldImage,
51
- options = _ref.options;
52
-
45
+ cldImage = _ref.cldImage,
46
+ options = _ref.options;
53
47
  var width = options.width,
54
- height = options.height,
55
- _options$crop = options.crop,
56
- crop = _options$crop === void 0 ? 'limit' : _options$crop;
48
+ height = options.height,
49
+ _options$crop = options.crop,
50
+ crop = _options$crop === void 0 ? 'limit' : _options$crop;
57
51
  var transformationString = "c_" + crop + ",w_" + width;
58
-
59
52
  if (!options.gravity && cropsGravityAuto.includes(crop)) {
60
53
  options.gravity = 'auto';
61
54
  }
62
-
63
55
  if (!['limit'].includes(crop)) {
64
56
  transformationString = transformationString + ",h_" + height;
65
57
  }
66
-
67
58
  if (options.gravity) {
68
59
  if (options.gravity === 'auto' && !cropsGravityAuto.includes(crop)) {
69
60
  console.warn('Auto gravity can only be used with crop, fill, lfill, fill_pad or thumb. Not applying gravity.');
@@ -71,7 +62,6 @@ function plugin$6(_temp) {
71
62
  transformationString = transformationString + ",g_" + options.gravity;
72
63
  }
73
64
  }
74
-
75
65
  cldImage.resize(transformationString);
76
66
  }
77
67
 
@@ -132,13 +122,11 @@ var props$5 = params.map(function (param) {
132
122
  });
133
123
  function plugin$5(_temp) {
134
124
  var _ref = _temp === void 0 ? {} : _temp,
135
- cldImage = _ref.cldImage,
136
- options = _ref.options;
137
-
125
+ cldImage = _ref.cldImage,
126
+ options = _ref.options;
138
127
  params.forEach(function (key) {
139
128
  var prop = key.prop || key;
140
129
  var effect = key.effect || key;
141
-
142
130
  if (options[prop] === true) {
143
131
  cldImage.effect("e_" + effect);
144
132
  } else if (typeof options[prop] === 'string') {
@@ -154,6 +142,7 @@ var effectsPlugin = {
154
142
  };
155
143
 
156
144
  // aspectRatio
145
+
157
146
  var primary = {
158
147
  aspectRatio: {
159
148
  qualifier: 'ar'
@@ -217,19 +206,16 @@ var DEFAULT_TEXT_OPTIONS = {
217
206
  };
218
207
  function plugin$4(_temp) {
219
208
  var _ref = _temp === void 0 ? {} : _temp,
220
- cldImage = _ref.cldImage,
221
- options = _ref.options;
222
-
209
+ cldImage = _ref.cldImage,
210
+ options = _ref.options;
223
211
  var text$1 = options.text,
224
- _options$overlays = options.overlays,
225
- overlays = _options$overlays === void 0 ? [] : _options$overlays;
212
+ _options$overlays = options.overlays,
213
+ overlays = _options$overlays === void 0 ? [] : _options$overlays;
226
214
  var type = 'overlay';
227
215
  var typeQualifier = 'l';
228
-
229
216
  if (Array.isArray(overlays)) {
230
217
  overlays.forEach(applyOverlay);
231
218
  }
232
-
233
219
  if (typeof text$1 === 'string') {
234
220
  applyOverlay({
235
221
  text: _extends({}, DEFAULT_TEXT_OPTIONS, {
@@ -241,48 +227,51 @@ function plugin$4(_temp) {
241
227
  text: _extends({}, DEFAULT_TEXT_OPTIONS, text$1)
242
228
  });
243
229
  }
230
+
244
231
  /**
245
232
  * applyOverlay
246
233
  */
247
234
 
248
-
249
235
  function applyOverlay(_ref2) {
250
236
  var publicId = _ref2.publicId,
251
- position$1 = _ref2.position,
252
- text$1 = _ref2.text,
253
- _ref2$effects = _ref2.effects,
254
- layerEffects = _ref2$effects === void 0 ? [] : _ref2$effects,
255
- options = _objectWithoutPropertiesLoose(_ref2, _excluded$3);
256
-
237
+ position$1 = _ref2.position,
238
+ text$1 = _ref2.text,
239
+ _ref2$effects = _ref2.effects,
240
+ layerEffects = _ref2$effects === void 0 ? [] : _ref2$effects,
241
+ options = _objectWithoutPropertiesLoose(_ref2, _excluded$3);
257
242
  var hasPublicId = typeof publicId === 'string';
258
243
  var hasText = typeof text$1 === 'object' || typeof text$1 === 'string';
259
244
  var hasPosition = typeof position$1 === 'object';
260
-
261
245
  if (!hasPublicId && !hasText) {
262
246
  console.warn("An " + type + " is missing Public ID or Text");
263
247
  return;
264
- } // Start to construct the transformation string using text or the public ID
265
- // if it's image-based
248
+ }
266
249
 
250
+ // Start to construct the transformation string using text or the public ID
251
+ // if it's image-based
267
252
 
268
253
  var layerTransformation;
269
-
270
254
  if (hasText) {
271
255
  layerTransformation = typeQualifier + "_text";
272
256
  } else {
273
257
  layerTransformation = typeQualifier + "_" + publicId.replace(/\//g, ':');
274
- } // Begin organizing transformations based on what it is and the location
275
- // it needs to be placed in the URL
258
+ }
276
259
 
260
+ // Begin organizing transformations based on what it is and the location
261
+ // it needs to be placed in the URL
277
262
 
278
263
  var primary$1 = [];
279
- var applied = []; // Gemeral options
264
+ var applied = [];
265
+
266
+ // Gemeral options
280
267
 
281
268
  Object.keys(options).forEach(function (key) {
282
269
  if (!primary[key]) return;
283
270
  var qualifier = primary[key].qualifier;
284
271
  primary$1.push(qualifier + "_" + options[key]);
285
- }); // Layer effects
272
+ });
273
+
274
+ // Layer effects
286
275
 
287
276
  layerEffects.forEach(function (effect) {
288
277
  Object.keys(effect).forEach(function (key) {
@@ -290,7 +279,9 @@ function plugin$4(_temp) {
290
279
  var qualifier = primary[key].qualifier;
291
280
  primary$1.push(qualifier + "_" + effect[key]);
292
281
  });
293
- }); // Text styling
282
+ });
283
+
284
+ // Text styling
294
285
 
295
286
  if (hasText) {
296
287
  if (typeof text$1 === 'string') {
@@ -298,14 +289,12 @@ function plugin$4(_temp) {
298
289
  text: text$1
299
290
  });
300
291
  }
301
-
302
292
  var textTransformations = [];
303
293
  Object.keys(text$1).forEach(function (key) {
304
294
  if (!text[key]) return;
305
295
  var _qualifiersText$key = text[key],
306
- qualifier = _qualifiersText$key.qualifier,
307
- location = _qualifiersText$key.location;
308
-
296
+ qualifier = _qualifiersText$key.qualifier,
297
+ location = _qualifiersText$key.location;
309
298
  if (location === 'primary') {
310
299
  primary$1.push(qualifier + "_" + text$1[key]);
311
300
  } else {
@@ -313,8 +302,9 @@ function plugin$4(_temp) {
313
302
  }
314
303
  });
315
304
  layerTransformation = layerTransformation + ":" + textTransformations.join('_') + ":" + text$1.text;
316
- } // Positioning
305
+ }
317
306
 
307
+ // Positioning
318
308
 
319
309
  if (hasPosition) {
320
310
  Object.keys(position$1).forEach(function (key) {
@@ -322,17 +312,20 @@ function plugin$4(_temp) {
322
312
  var qualifier = position[key].qualifier;
323
313
  applied.push(qualifier + "_" + position$1[key]);
324
314
  });
325
- } // Add all primary transformations
315
+ }
326
316
 
317
+ // Add all primary transformations
327
318
 
328
- layerTransformation = layerTransformation + "," + primary$1.join(','); // Add all applied transformations
319
+ layerTransformation = layerTransformation + "," + primary$1.join(',');
329
320
 
330
- layerTransformation = layerTransformation + "/fl_layer_apply,fl_no_overflow";
321
+ // Add all applied transformations
331
322
 
323
+ layerTransformation = layerTransformation + "/fl_layer_apply,fl_no_overflow";
332
324
  if (applied.length > 0) {
333
325
  layerTransformation = layerTransformation + "," + applied.join(',');
334
- } // Finally add it to the image
326
+ }
335
327
 
328
+ // Finally add it to the image
336
329
 
337
330
  cldImage.addTransformation(layerTransformation);
338
331
  }
@@ -348,11 +341,10 @@ var overlaysPlugin = {
348
341
  var props$3 = ['rawTransformations'];
349
342
  function plugin$3(_temp) {
350
343
  var _ref = _temp === void 0 ? {} : _temp,
351
- cldImage = _ref.cldImage,
352
- options = _ref.options;
353
-
344
+ cldImage = _ref.cldImage,
345
+ options = _ref.options;
354
346
  var _options$rawTransform = options.rawTransformations,
355
- rawTransformations = _options$rawTransform === void 0 ? [] : _options$rawTransform;
347
+ rawTransformations = _options$rawTransform === void 0 ? [] : _options$rawTransform;
356
348
  rawTransformations.forEach(function (transformation) {
357
349
  cldImage.addTransformation(transformation);
358
350
  });
@@ -367,12 +359,10 @@ var rawTransformationsPlugin = {
367
359
  var props$2 = ['removeBackground'];
368
360
  function plugin$2(_temp) {
369
361
  var _ref = _temp === void 0 ? {} : _temp,
370
- cldImage = _ref.cldImage,
371
- options = _ref.options;
372
-
362
+ cldImage = _ref.cldImage,
363
+ options = _ref.options;
373
364
  var _options$removeBackgr = options.removeBackground,
374
- removeBackground = _options$removeBackgr === void 0 ? false : _options$removeBackgr;
375
-
365
+ removeBackground = _options$removeBackgr === void 0 ? false : _options$removeBackgr;
376
366
  if (removeBackground) {
377
367
  cldImage.effect('e_background_removal');
378
368
  }
@@ -388,68 +378,67 @@ var _excluded$2 = ["publicId", "type", "position", "text", "effects"];
388
378
  var props$1 = ['underlay', 'underlays'];
389
379
  function plugin$1(_temp) {
390
380
  var _ref = _temp === void 0 ? {} : _temp,
391
- cldImage = _ref.cldImage,
392
- options = _ref.options;
393
-
381
+ cldImage = _ref.cldImage,
382
+ options = _ref.options;
394
383
  var underlay = options.underlay,
395
- _options$underlays = options.underlays,
396
- underlays = _options$underlays === void 0 ? [] : _options$underlays;
384
+ _options$underlays = options.underlays,
385
+ underlays = _options$underlays === void 0 ? [] : _options$underlays;
397
386
  var typeQualifier = 'u';
398
-
399
387
  if (Array.isArray(underlays)) {
400
388
  underlays.forEach(applyUnderlay);
401
389
  }
402
-
403
390
  if (typeof underlay === 'string') {
404
391
  var underlayOptions = {
405
392
  publicId: underlay,
406
393
  crop: 'fill'
407
394
  };
408
-
409
395
  if (options.width) {
410
396
  underlayOptions.width = options.width;
411
397
  }
412
-
413
398
  if (options.height) {
414
399
  underlayOptions.height = options.height;
415
400
  }
416
-
417
401
  applyUnderlay(underlayOptions);
418
402
  }
403
+
419
404
  /**
420
405
  * applyUnderlay
421
406
  */
422
407
 
423
-
424
408
  function applyUnderlay(_ref2) {
425
409
  var publicId = _ref2.publicId,
426
- type = _ref2.type,
427
- position$1 = _ref2.position,
428
- _ref2$effects = _ref2.effects,
429
- layerEffects = _ref2$effects === void 0 ? [] : _ref2$effects,
430
- options = _objectWithoutPropertiesLoose(_ref2, _excluded$2);
431
-
410
+ type = _ref2.type,
411
+ position$1 = _ref2.position,
412
+ _ref2$effects = _ref2.effects,
413
+ layerEffects = _ref2$effects === void 0 ? [] : _ref2$effects,
414
+ options = _objectWithoutPropertiesLoose(_ref2, _excluded$2);
432
415
  var hasPublicId = typeof publicId === 'string';
433
416
  var hasPosition = typeof position$1 === 'object';
434
-
435
417
  if (!hasPublicId) {
436
418
  console.warn("An " + type + " is missing a Public ID");
437
419
  return;
438
- } // Start to construct the transformation string using text or the public ID
420
+ }
421
+
422
+ // Start to construct the transformation string using text or the public ID
439
423
  // if it's image-based
440
424
 
425
+ var layerTransformation = typeQualifier + "_" + publicId.replace(/\//g, ':');
441
426
 
442
- var layerTransformation = typeQualifier + "_" + publicId.replace(/\//g, ':'); // Begin organizing transformations based on what it is and the location
427
+ // Begin organizing transformations based on what it is and the location
443
428
  // it needs to be placed in the URL
444
429
 
445
430
  var primary$1 = [];
446
- var applied = []; // Gemeral options
431
+ var applied = [];
432
+
433
+ // Gemeral options
447
434
 
448
435
  Object.keys(options).forEach(function (key) {
449
436
  if (!primary[key]) return;
450
437
  var qualifier = primary[key].qualifier;
451
438
  primary$1.push(qualifier + "_" + options[key]);
452
- }); // Layer effects
439
+ });
440
+
441
+ // Layer effects
453
442
 
454
443
  layerEffects.forEach(function (effect) {
455
444
  Object.keys(effect).forEach(function (key) {
@@ -457,7 +446,9 @@ function plugin$1(_temp) {
457
446
  var qualifier = primary[key].qualifier;
458
447
  primary$1.push(qualifier + "_" + effect[key]);
459
448
  });
460
- }); // Positioning
449
+ });
450
+
451
+ // Positioning
461
452
 
462
453
  if (hasPosition) {
463
454
  Object.keys(position$1).forEach(function (key) {
@@ -465,17 +456,20 @@ function plugin$1(_temp) {
465
456
  var qualifier = position[key].qualifier;
466
457
  applied.push(qualifier + "_" + position$1[key]);
467
458
  });
468
- } // Add all primary transformations
459
+ }
469
460
 
461
+ // Add all primary transformations
470
462
 
471
- layerTransformation = layerTransformation + "," + primary$1.join(','); // Add all applied transformations
463
+ layerTransformation = layerTransformation + "," + primary$1.join(',');
472
464
 
473
- layerTransformation = layerTransformation + "/fl_layer_apply,fl_no_overflow";
465
+ // Add all applied transformations
474
466
 
467
+ layerTransformation = layerTransformation + "/fl_layer_apply,fl_no_overflow";
475
468
  if (applied.length > 0) {
476
469
  layerTransformation = layerTransformation + "," + applied.join(',');
477
- } // Finally add it to the image
470
+ }
478
471
 
472
+ // Finally add it to the image
479
473
 
480
474
  cldImage.addTransformation(layerTransformation);
481
475
  }
@@ -490,13 +484,11 @@ var underlaysPlugin = {
490
484
  var props = ['zoompan'];
491
485
  function plugin(_temp) {
492
486
  var _ref = _temp === void 0 ? {} : _temp,
493
- cldImage = _ref.cldImage,
494
- options = _ref.options;
495
-
487
+ cldImage = _ref.cldImage,
488
+ options = _ref.options;
496
489
  var _options$zoompan = options.zoompan,
497
- zoompan = _options$zoompan === void 0 ? false : _options$zoompan;
490
+ zoompan = _options$zoompan === void 0 ? false : _options$zoompan;
498
491
  var overrides = {};
499
-
500
492
  if (zoompan === true) {
501
493
  cldImage.effect('e_zoompan');
502
494
  } else if (typeof zoompan === 'string') {
@@ -508,29 +500,23 @@ function plugin(_temp) {
508
500
  }
509
501
  } else if (typeof zoompan === 'object') {
510
502
  var zoompanEffect = 'e_zoompan';
511
-
512
503
  if (typeof zoompan.options === 'string') {
513
504
  zoompanEffect = "" + zoompanEffect + zoompan.options;
514
505
  }
515
-
516
506
  cldImage.effect(zoompanEffect);
517
507
  var loopEffect;
518
-
519
508
  if (zoompan.loop === true) {
520
509
  loopEffect = 'e_loop';
521
510
  } else if (typeof zoompan.loop === 'string') {
522
511
  loopEffect = "e_loop" + zoompan.loop;
523
512
  }
524
-
525
513
  if (loopEffect) {
526
514
  cldImage.effect(loopEffect);
527
515
  }
528
516
  }
529
-
530
517
  if (zoompan !== false) {
531
518
  overrides.format = 'gif';
532
519
  }
533
-
534
520
  return {
535
521
  options: overrides
536
522
  };
@@ -542,19 +528,22 @@ var zoompanPlugin = {
542
528
  plugin: plugin
543
529
  };
544
530
 
545
- var transformationPlugins = [// Background Removal must always come first
546
- removeBackgroundPlugin, croppingPlugin, effectsPlugin, overlaysPlugin, underlaysPlugin, zoompanPlugin, // Raw transformations needs to be last simply to make sure
531
+ var transformationPlugins = [
532
+ // Background Removal must always come first
533
+ removeBackgroundPlugin, croppingPlugin, effectsPlugin, overlaysPlugin, underlaysPlugin, zoompanPlugin,
534
+ // Raw transformations needs to be last simply to make sure
547
535
  // it's always expected to applied the same way
536
+
548
537
  rawTransformationsPlugin];
549
538
  var cld;
539
+
550
540
  /**
551
541
  * constructCloudinaryUrl
552
542
  */
553
543
 
554
544
  function constructCloudinaryUrl(_ref) {
555
545
  var options = _ref.options,
556
- config = _ref.config;
557
-
546
+ config = _ref.config;
558
547
  if (!cld) {
559
548
  cld = new urlGen.Cloudinary(_extends({
560
549
  cloud: {
@@ -566,24 +555,22 @@ function constructCloudinaryUrl(_ref) {
566
555
  }
567
556
  }, config));
568
557
  }
569
-
570
558
  var publicId = getPublicId(options.src);
571
559
  var cldImage = cld.image(publicId);
572
560
  transformationPlugins.forEach(function (_ref2) {
573
561
  var plugin = _ref2.plugin;
574
-
575
562
  var _ref3 = plugin({
576
- cldImage: cldImage,
577
- options: options
578
- }) || {},
579
- pluginOptions = _ref3.options;
580
-
563
+ cldImage: cldImage,
564
+ options: options
565
+ }) || {},
566
+ pluginOptions = _ref3.options;
581
567
  if (pluginOptions != null && pluginOptions.format) {
582
568
  options.format = pluginOptions.format;
583
569
  }
584
570
  });
585
571
  return cldImage.setDeliveryType(options.deliveryType || 'upload').format(options.format || 'auto').delivery("q_" + (options.quality || 'auto')).toURL();
586
572
  }
573
+
587
574
  /**
588
575
  * Retrieves the public id of a cloudiary image url. If no url is recognized it returns the parameter it self.
589
576
  * If it's recognized that is a url and it's not possible to get the public id, it warns the user.
@@ -597,13 +584,11 @@ function getPublicId(src) {
597
584
  if (typeof src !== 'string') {
598
585
  throw new Error("Invalid src of type " + typeof src);
599
586
  }
600
-
601
587
  if (src.includes('res.cloudinary.com')) {
602
588
  var regexWithTransformations = /(https?)\:\/\/(res.cloudinary.com)\/([^\/]+)\/(image|video|raw)\/(upload|authenticated)\/(.*)\/(v[0-9]+)\/(.+)(?:\.[a-z]{3})?/;
603
589
  var regexWithoutTransformations = /(https?)\:\/\/(res.cloudinary.com)\/([^\/]+)\/(image|video|raw)\/(upload|authenticated)\/(v[0-9]+)\/(.+)(?:\.[a-z]{3})?/;
604
590
  var withTransformations = src.match(regexWithTransformations);
605
591
  var withoutTransformations = src.match(regexWithoutTransformations);
606
-
607
592
  if (withTransformations) {
608
593
  return withTransformations[withTransformations.length - 1];
609
594
  } else if (withoutTransformations) {
@@ -612,30 +597,27 @@ function getPublicId(src) {
612
597
  console.warn("Not possible to retrieve the publicUrl from " + src + ", make sure it's a valid cloudinary image url.");
613
598
  }
614
599
  }
615
-
616
600
  return src;
617
601
  }
602
+
618
603
  /**
619
604
  * createPlaceholderUrl
620
605
  */
621
606
 
622
607
  function createPlaceholderUrl(_ref4) {
623
608
  var src = _ref4.src,
624
- _ref4$placeholder = _ref4.placeholder,
625
- placeholder = _ref4$placeholder === void 0 ? true : _ref4$placeholder,
626
- config = _ref4.config;
609
+ _ref4$placeholder = _ref4.placeholder,
610
+ placeholder = _ref4$placeholder === void 0 ? true : _ref4$placeholder,
611
+ config = _ref4.config;
627
612
  var rawTransformations = [];
628
-
629
613
  if (placeholder === 'grayscale') {
630
614
  rawTransformations.push('e_grayscale');
631
615
  }
632
-
633
616
  if (typeof placeholder === 'string' && placeholder.includes('color:')) {
634
617
  var color = placeholder.split(':').splice(1).join(':');
635
618
  rawTransformations.push('e_grayscale');
636
619
  rawTransformations.push("e_colorize:60,co_" + color);
637
620
  }
638
-
639
621
  return constructCloudinaryUrl({
640
622
  options: {
641
623
  src: src,
@@ -651,7 +633,6 @@ function cloudinaryLoader(defaultOptions, cldOptions, cldConfig) {
651
633
  if (cldConfig === void 0) {
652
634
  cldConfig = {};
653
635
  }
654
-
655
636
  return constructCloudinaryUrl({
656
637
  options: _extends({}, defaultOptions, cldOptions),
657
638
  config: cldConfig
@@ -662,29 +643,34 @@ var CldImage = function CldImage(props) {
662
643
  var CLD_OPTIONS = [];
663
644
  transformationPlugins.forEach(function (_ref) {
664
645
  var _ref$props = _ref.props,
665
- props = _ref$props === void 0 ? [] : _ref$props;
646
+ props = _ref$props === void 0 ? [] : _ref$props;
666
647
  props.forEach(function (prop) {
667
648
  if (CLD_OPTIONS.includes(prop)) {
668
649
  throw new Error("Option " + prop + " already exists!");
669
650
  }
670
-
671
651
  CLD_OPTIONS.push(prop);
672
652
  });
673
- }); // Construct the base Image component props by filtering out Cloudinary-specific props
653
+ });
654
+
655
+ // Construct the base Image component props by filtering out Cloudinary-specific props
674
656
 
675
657
  var imageProps = {};
676
658
  Object.keys(props).filter(function (key) {
677
659
  return !CLD_OPTIONS.includes(key);
678
660
  }).forEach(function (key) {
679
661
  return imageProps[key] = props[key];
680
- }); // Construct Cloudinary-specific props by looking for values for any of the supported prop keys
662
+ });
663
+
664
+ // Construct Cloudinary-specific props by looking for values for any of the supported prop keys
681
665
 
682
666
  var cldOptions = {};
683
667
  CLD_OPTIONS.forEach(function (key) {
684
668
  if (props[key]) {
685
669
  cldOptions[key] = props[key];
686
670
  }
687
- }); // If we see a placeholder option, configure a Cloudinary-based URL.
671
+ });
672
+
673
+ // If we see a placeholder option, configure a Cloudinary-based URL.
688
674
  // The resulting image will always be blurred per Next.js, so we're
689
675
  // limited on options for placeholders.
690
676
  //
@@ -699,12 +685,10 @@ var CldImage = function CldImage(props) {
699
685
  src: publicId,
700
686
  placeholder: props.placeholder
701
687
  });
702
-
703
688
  if (imageProps.placeholder !== 'blur') {
704
689
  imageProps.placeholder = 'blur';
705
690
  }
706
691
  }
707
-
708
692
  return /*#__PURE__*/jsxRuntime.jsx(Image__default["default"], _extends({}, imageProps, {
709
693
  loader: function loader(options) {
710
694
  return cloudinaryLoader(_extends({}, imageProps, {
@@ -718,23 +702,22 @@ var _excluded$1 = ["excludeTags", "twitterTitle"];
718
702
  var IMAGE_WIDTH = 2400;
719
703
  var IMAGE_HEIGHT = 1200;
720
704
  var TWITTER_CARD = 'summary_large_image';
721
-
722
705
  var CldOgImage = function CldOgImage(_ref) {
723
706
  var _ref$excludeTags = _ref.excludeTags,
724
- excludeTags = _ref$excludeTags === void 0 ? [] : _ref$excludeTags,
725
- twitterTitle = _ref.twitterTitle,
726
- props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
727
-
707
+ excludeTags = _ref$excludeTags === void 0 ? [] : _ref$excludeTags,
708
+ twitterTitle = _ref.twitterTitle,
709
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
728
710
  var options = _extends({}, props, {
729
711
  width: props.width || IMAGE_WIDTH,
730
712
  height: props.height || IMAGE_HEIGHT,
731
713
  crop: props.crop || 'fill',
732
714
  gravity: props.gravity || 'center'
733
715
  });
734
-
735
716
  var ogImageUrl = constructCloudinaryUrl({
736
717
  options: options
737
- }); // We need to include the tags within the Next.js Head component rather than
718
+ });
719
+
720
+ // We need to include the tags within the Next.js Head component rather than
738
721
  // direcly adding them inside of the Head otherwise we get unexpected results
739
722
 
740
723
  return /*#__PURE__*/jsxRuntime.jsxs(Head__default["default"], {
@@ -768,12 +751,13 @@ var CldOgImage = function CldOgImage(_ref) {
768
751
 
769
752
  var CldUploadWidget = function CldUploadWidget(_ref) {
770
753
  var children = _ref.children,
771
- onUpload = _ref.onUpload,
772
- options = _ref.options,
773
- signed = _ref.signed,
774
- signatureEndpoint = _ref.signatureEndpoint;
754
+ onUpload = _ref.onUpload,
755
+ options = _ref.options,
756
+ signed = _ref.signed,
757
+ signatureEndpoint = _ref.signatureEndpoint;
775
758
  var cloudinary = react.useRef();
776
759
  var widget = react.useRef();
760
+
777
761
  /**
778
762
  * generateSignature
779
763
  * @description Makes a request to an endpoint to sign Cloudinary parameters as part of widget creation
@@ -792,28 +776,27 @@ var CldUploadWidget = function CldUploadWidget(_ref) {
792
776
  callback(signature);
793
777
  });
794
778
  }
779
+
795
780
  /**
796
781
  * createWidget
797
782
  * @description Creates a new instance of the Cloudinary widget and stores in a ref
798
783
  */
799
784
 
800
-
801
785
  function createWidget() {
802
786
  var _cloudinary$current;
803
-
804
787
  // When creating a signed upload, you need to provide both your Cloudinary API Key
805
788
  // as well as a signature generator function that will sign any paramters
806
789
  // either on page load or during the upload process. Read more about signed uploads at:
807
790
  // https://cloudinary.com/documentation/upload_widget#signed_uploads
791
+
808
792
  var totalOptions = _extends({}, options, !!signed && {
809
793
  uploadSignature: generateSignature
810
- }); // no need for apiSecret because of api/sign-cloudinary-params
811
-
794
+ });
812
795
 
796
+ // no need for apiSecret because of api/sign-cloudinary-params
813
797
  if (signed && !totalOptions.apiKey) {
814
798
  return new Error("Signed Upload needs apiKey!");
815
799
  }
816
-
817
800
  return (_cloudinary$current = cloudinary.current) == null ? void 0 : _cloudinary$current.createUploadWidget(totalOptions, function (error, result) {
818
801
  // The callback is a bit more chatty than failed or success so
819
802
  // only trigger when one of those are the case. You can additionally
@@ -824,29 +807,27 @@ var CldUploadWidget = function CldUploadWidget(_ref) {
824
807
  }
825
808
  });
826
809
  }
810
+
827
811
  /**
828
812
  * open
829
813
  * @description When triggered, uses the current widget instance to open the upload modal
830
814
  */
831
815
 
832
-
833
816
  function open() {
834
817
  if (!(widget != null && widget.current)) {
835
818
  widget.current = createWidget();
836
819
  }
837
-
838
820
  (widget == null ? void 0 : widget.current) && widget.current.open();
839
821
  }
822
+
840
823
  /**
841
824
  * handleOnLoad
842
825
  * @description Stores the Cloudinary window instance to a ref when the widget script loads
843
826
  */
844
827
 
845
-
846
828
  function handleOnLoad() {
847
829
  cloudinary.current = window.cloudinary;
848
830
  }
849
-
850
831
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
851
832
  children: [children({
852
833
  cloudinary: cloudinary.current,
@@ -864,14 +845,12 @@ var CldUploadWidget = function CldUploadWidget(_ref) {
864
845
  };
865
846
 
866
847
  var _excluded = ["onUpload", "options", "signed", "label", "children"];
867
-
868
848
  var CldUploadButton = function CldUploadButton(_ref) {
869
849
  var onUpload = _ref.onUpload,
870
- options = _ref.options,
871
- signed = _ref.signed,
872
- _children = _ref.children,
873
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
874
-
850
+ options = _ref.options,
851
+ signed = _ref.signed,
852
+ _children = _ref.children,
853
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
875
854
  return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
876
855
  children: /*#__PURE__*/jsxRuntime.jsx(CldUploadWidget, {
877
856
  signed: signed,
@@ -880,12 +859,10 @@ var CldUploadButton = function CldUploadButton(_ref) {
880
859
  signatureEndpoint: signed != null ? signed : props.signatureEndpoint,
881
860
  children: function children(_ref2) {
882
861
  var open = _ref2.open;
883
-
884
862
  function handleOnClick(e) {
885
863
  e.preventDefault();
886
864
  open();
887
865
  }
888
-
889
866
  return /*#__PURE__*/jsxRuntime.jsx("button", _extends({
890
867
  onClick: handleOnClick
891
868
  }, props, {