next-cloudinary 1.6.0 → 1.8.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.
@@ -247,6 +247,10 @@
247
247
  prefix: 'e',
248
248
  qualifier: 'improve'
249
249
  },
250
+ multiply: {
251
+ prefix: 'e',
252
+ qualifier: 'multiply'
253
+ },
250
254
  negate: {
251
255
  prefix: 'e',
252
256
  qualifier: 'negate'
@@ -262,6 +266,10 @@
262
266
  prefix: 'e',
263
267
  qualifier: 'outline'
264
268
  },
269
+ overlay: {
270
+ prefix: 'e',
271
+ qualifier: 'overlay'
272
+ },
265
273
  pixelate: {
266
274
  prefix: 'e',
267
275
  qualifier: 'pixelate'
@@ -286,6 +294,10 @@
286
294
  prefix: 'e',
287
295
  qualifier: 'saturation'
288
296
  },
297
+ screen: {
298
+ prefix: 'e',
299
+ qualifier: 'screen'
300
+ },
289
301
  sepia: {
290
302
  prefix: 'e',
291
303
  qualifier: 'sepia'
@@ -328,6 +340,57 @@
328
340
  }
329
341
  };
330
342
 
343
+ /**
344
+ * constructTransformation
345
+ */
346
+
347
+ function constructTransformation(_ref) {
348
+ var prefix = _ref.prefix,
349
+ qualifier = _ref.qualifier,
350
+ value = _ref.value;
351
+ var transformation = '';
352
+ if (prefix) {
353
+ transformation = prefix + "_";
354
+ }
355
+ if (value === true || value === 'true') {
356
+ return "" + transformation + qualifier;
357
+ }
358
+ if (typeof value === 'string' || typeof value === 'number') {
359
+ if (prefix) {
360
+ return "" + transformation + qualifier + ":" + value;
361
+ } else {
362
+ return qualifier + "_" + value;
363
+ }
364
+ }
365
+ }
366
+
367
+ /**
368
+ * Retrieves the transformations added to a cloudiary image url. If no transformation is recognized it returns an empty array.
369
+ *
370
+ * @param {string} src The cloudiary url.
371
+ *
372
+ * @return {array} The array of transformations
373
+ */
374
+
375
+ function getTransformations(src, preserveTransformations) {
376
+ if (typeof src !== "string") {
377
+ throw new Error("Invalid src of type " + typeof src);
378
+ }
379
+ if (src.includes("res.cloudinary.com") && preserveTransformations) {
380
+ var regex = new RegExp("(https?)://(res.cloudinary.com)/([^/]+)/(image|video|raw)/(upload|authenticated)/(.*)/(v[0-9]+)/(.+)(?:.[a-z]{3})?", "gi");
381
+ var groups = regex.exec(src);
382
+ var transformationStr = groups.slice(1).find(function (i) {
383
+ return i.includes("_");
384
+ });
385
+ if (transformationStr) {
386
+ return transformationStr.split(",").join("/").split("/");
387
+ } else {
388
+ return [];
389
+ }
390
+ }
391
+ return [];
392
+ }
393
+
331
394
  var props$6 = [].concat(Object.keys(effects), ['effects']);
332
395
  function plugin$6(_temp) {
333
396
  var _ref = _temp === void 0 ? {} : _temp,
@@ -358,36 +421,16 @@
358
421
  cldImage.effect(transformationString);
359
422
  });
360
423
  }
361
-
362
- /**
363
- * constructEffect
364
- */
365
-
366
- function constructEffect(_ref2) {
367
- var effect = _ref2.effect,
368
- value = _ref2.value;
369
- var prefix = effect.prefix,
370
- qualifier = effect.qualifier;
371
- var transformation = '';
372
- if (prefix) {
373
- transformation = prefix + "_";
374
- }
375
- if (value === true) {
376
- return "" + transformation + qualifier;
377
- } else if (typeof value === 'string' || typeof value === 'number') {
378
- if (prefix) {
379
- return "" + transformation + qualifier + ":" + value;
380
- } else {
381
- return qualifier + "_" + value;
382
- }
383
- }
384
- }
385
- function constructTransformationString(_ref3) {
386
- var effects = _ref3.effects,
387
- options = _ref3.options;
424
+ function constructTransformationString(_ref2) {
425
+ var effects = _ref2.effects,
426
+ options = _ref2.options;
388
427
  return Object.keys(effects).map(function (key) {
389
- return constructEffect({
390
- effect: effects[key],
428
+ var _effects$key = effects[key],
429
+ prefix = _effects$key.prefix,
430
+ qualifier = _effects$key.qualifier;
431
+ return constructTransformation({
432
+ qualifier: qualifier,
433
+ prefix: prefix,
391
434
  value: options[key]
392
435
  });
393
436
  });
@@ -413,7 +456,7 @@
413
456
  }
414
457
  }
415
458
 
416
- var _excluded$3 = ["publicId", "url", "position", "text", "effects"];
459
+ var _excluded$3 = ["publicId", "url", "position", "text", "effects", "appliedEffects"];
417
460
  var props$5 = ['text', 'overlays'];
418
461
  var DEFAULT_TEXT_OPTIONS = {
419
462
  color: 'black',
@@ -456,6 +499,8 @@
456
499
  text$1 = _ref2.text,
457
500
  _ref2$effects = _ref2.effects,
458
501
  layerEffects = _ref2$effects === void 0 ? [] : _ref2$effects,
502
+ _ref2$appliedEffects = _ref2.appliedEffects,
503
+ appliedEffects = _ref2$appliedEffects === void 0 ? [] : _ref2$appliedEffects,
459
504
  options = _objectWithoutPropertiesLoose(_ref2, _excluded$3);
460
505
  var hasPublicId = typeof publicId === 'string';
461
506
  var hasUrl = typeof url === 'string';
@@ -489,7 +534,11 @@
489
534
  Object.keys(options).forEach(function (key) {
490
535
  if (!primary[key]) return;
491
536
  var qualifier = primary[key].qualifier;
492
- primary$1.push(qualifier + "_" + options[key]);
537
+ var transformation = constructTransformation({
538
+ qualifier: qualifier,
539
+ value: options[key]
540
+ });
541
+ primary$1.push(transformation);
493
542
  });
494
543
 
495
544
  // Layer effects
@@ -499,27 +548,33 @@
499
548
 
500
549
  layerEffects.forEach(function (effect) {
501
550
  Object.keys(effect).forEach(function (key) {
502
- if (primary[key]) {
503
- var qualifier = primary[key].qualifier;
504
- primary$1.push(qualifier + "_" + effect[key]);
505
- } else if (effects[key]) {
506
- var _qualifiersEffects$ke = effects[key],
507
- _qualifier = _qualifiersEffects$ke.qualifier,
508
- prefix = _qualifiersEffects$ke.prefix;
509
- var transformation = '';
510
- if (prefix) {
511
- transformation = prefix + "_";
512
- }
513
- if (effect[key] === true) {
514
- primary$1.push("" + transformation + _qualifier);
515
- } else if (typeof effect[key] === 'string' || typeof effect[key] === 'number') {
516
- if (prefix) {
517
- primary$1.push("" + transformation + _qualifier + ":" + effect[key]);
518
- } else {
519
- primary$1.push(_qualifier + "_" + effect[key]);
520
- }
521
- }
522
- }
551
+ var _ref3 = primary[key] || effects[key] || {},
552
+ qualifier = _ref3.qualifier,
553
+ prefix = _ref3.prefix;
554
+ var transformation = constructTransformation({
555
+ qualifier: qualifier,
556
+ prefix: prefix,
557
+ value: effect[key]
558
+ });
559
+ primary$1.push(transformation);
560
+ });
561
+ });
562
+
563
+ // Applied Layer effects
564
+ // Similar to layer effects but they get appended to an additional transformation
565
+ // along with fl_layer_applied
566
+
567
+ appliedEffects.forEach(function (effect) {
568
+ Object.keys(effect).forEach(function (key) {
569
+ var _ref4 = primary[key] || effects[key] || {},
570
+ qualifier = _ref4.qualifier,
571
+ prefix = _ref4.prefix;
572
+ var transformation = constructTransformation({
573
+ qualifier: qualifier,
574
+ prefix: prefix,
575
+ value: effect[key]
576
+ });
577
+ applied.push(transformation);
523
578
  });
524
579
  });
525
580
 
@@ -556,7 +611,11 @@
556
611
  Object.keys(position$1).forEach(function (key) {
557
612
  if (!position[key]) return;
558
613
  var qualifier = position[key].qualifier;
559
- applied.push(qualifier + "_" + position$1[key]);
614
+ var transformation = constructTransformation({
615
+ qualifier: qualifier,
616
+ value: position$1[key]
617
+ });
618
+ applied.push(transformation);
560
619
  });
561
620
  }
562
621
 
@@ -931,33 +990,6 @@
931
990
  return src;
932
991
  }
933
992
 
934
- /**
935
- * Retrieves the transformations added to a cloudiary image url. If no transformation is recognized it returns an empty array.
936
- *
937
- * @param {string} src The cloudiary url.
938
- *
939
- * @return {array} The array of transformations
940
- */
941
-
942
- function getTransformations(src, preserveTransformations) {
943
- if (typeof src !== "string") {
944
- throw new Error("Invalid src of type " + typeof src);
945
- }
946
- if (src.includes("res.cloudinary.com") && preserveTransformations) {
947
- var regex = new RegExp("(https?)://(res.cloudinary.com)/([^/]+)/(image|video|raw)/(upload|authenticated)/(.*)/(v[0-9]+)/(.+)(?:.[a-z]{3})?", "gi");
948
- var groups = regex.exec(src);
949
- var transformationStr = groups.slice(1).find(function (i) {
950
- return i.includes("_");
951
- });
952
- if (transformationStr) {
953
- return transformationStr.split(",").join("/").split("/");
954
- } else {
955
- return [];
956
- }
957
- }
958
- return [];
959
- }
960
-
961
993
  /**
962
994
  * createPlaceholderUrl
963
995
  */
@@ -1292,6 +1324,8 @@
1292
1324
  exports.CldUploadButton = CldUploadButton;
1293
1325
  exports.CldUploadWidget = CldUploadWidget;
1294
1326
  exports.cloudinaryLoader = cloudinaryLoader;
1327
+ exports.constructCloudinaryUrl = constructCloudinaryUrl;
1328
+ exports.effects = effects;
1295
1329
  exports.position = position;
1296
1330
  exports.primary = primary;
1297
1331
  exports.text = text;