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.
@@ -243,6 +243,10 @@ var effects = {
243
243
  prefix: 'e',
244
244
  qualifier: 'improve'
245
245
  },
246
+ multiply: {
247
+ prefix: 'e',
248
+ qualifier: 'multiply'
249
+ },
246
250
  negate: {
247
251
  prefix: 'e',
248
252
  qualifier: 'negate'
@@ -258,6 +262,10 @@ var effects = {
258
262
  prefix: 'e',
259
263
  qualifier: 'outline'
260
264
  },
265
+ overlay: {
266
+ prefix: 'e',
267
+ qualifier: 'overlay'
268
+ },
261
269
  pixelate: {
262
270
  prefix: 'e',
263
271
  qualifier: 'pixelate'
@@ -282,6 +290,10 @@ var effects = {
282
290
  prefix: 'e',
283
291
  qualifier: 'saturation'
284
292
  },
293
+ screen: {
294
+ prefix: 'e',
295
+ qualifier: 'screen'
296
+ },
285
297
  sepia: {
286
298
  prefix: 'e',
287
299
  qualifier: 'sepia'
@@ -324,6 +336,57 @@ var effects = {
324
336
  }
325
337
  };
326
338
 
339
+ /**
340
+ * constructTransformation
341
+ */
342
+
343
+ function constructTransformation(_ref) {
344
+ var prefix = _ref.prefix,
345
+ qualifier = _ref.qualifier,
346
+ value = _ref.value;
347
+ var transformation = '';
348
+ if (prefix) {
349
+ transformation = prefix + "_";
350
+ }
351
+ if (value === true || value === 'true') {
352
+ return "" + transformation + qualifier;
353
+ }
354
+ if (typeof value === 'string' || typeof value === 'number') {
355
+ if (prefix) {
356
+ return "" + transformation + qualifier + ":" + value;
357
+ } else {
358
+ return qualifier + "_" + value;
359
+ }
360
+ }
361
+ }
362
+
363
+ /**
364
+ * Retrieves the transformations added to a cloudiary image url. If no transformation is recognized it returns an empty array.
365
+ *
366
+ * @param {string} src The cloudiary url.
367
+ *
368
+ * @return {array} The array of transformations
369
+ */
370
+
371
+ function getTransformations(src, preserveTransformations) {
372
+ if (typeof src !== "string") {
373
+ throw new Error("Invalid src of type " + typeof src);
374
+ }
375
+ if (src.includes("res.cloudinary.com") && preserveTransformations) {
376
+ var regex = new RegExp("(https?)://(res.cloudinary.com)/([^/]+)/(image|video|raw)/(upload|authenticated)/(.*)/(v[0-9]+)/(.+)(?:.[a-z]{3})?", "gi");
377
+ var groups = regex.exec(src);
378
+ var transformationStr = groups.slice(1).find(function (i) {
379
+ return i.includes("_");
380
+ });
381
+ if (transformationStr) {
382
+ return transformationStr.split(",").join("/").split("/");
383
+ } else {
384
+ return [];
385
+ }
386
+ }
387
+ return [];
388
+ }
389
+
327
390
  var props$6 = [].concat(Object.keys(effects), ['effects']);
328
391
  function plugin$6(_temp) {
329
392
  var _ref = _temp === void 0 ? {} : _temp,
@@ -354,36 +417,16 @@ function plugin$6(_temp) {
354
417
  cldImage.effect(transformationString);
355
418
  });
356
419
  }
357
-
358
- /**
359
- * constructEffect
360
- */
361
-
362
- function constructEffect(_ref2) {
363
- var effect = _ref2.effect,
364
- value = _ref2.value;
365
- var prefix = effect.prefix,
366
- qualifier = effect.qualifier;
367
- var transformation = '';
368
- if (prefix) {
369
- transformation = prefix + "_";
370
- }
371
- if (value === true) {
372
- return "" + transformation + qualifier;
373
- } else if (typeof value === 'string' || typeof value === 'number') {
374
- if (prefix) {
375
- return "" + transformation + qualifier + ":" + value;
376
- } else {
377
- return qualifier + "_" + value;
378
- }
379
- }
380
- }
381
- function constructTransformationString(_ref3) {
382
- var effects = _ref3.effects,
383
- options = _ref3.options;
420
+ function constructTransformationString(_ref2) {
421
+ var effects = _ref2.effects,
422
+ options = _ref2.options;
384
423
  return Object.keys(effects).map(function (key) {
385
- return constructEffect({
386
- effect: effects[key],
424
+ var _effects$key = effects[key],
425
+ prefix = _effects$key.prefix,
426
+ qualifier = _effects$key.qualifier;
427
+ return constructTransformation({
428
+ qualifier: qualifier,
429
+ prefix: prefix,
387
430
  value: options[key]
388
431
  });
389
432
  });
@@ -409,7 +452,7 @@ function encodeBase64(value) {
409
452
  }
410
453
  }
411
454
 
412
- var _excluded$3 = ["publicId", "url", "position", "text", "effects"];
455
+ var _excluded$3 = ["publicId", "url", "position", "text", "effects", "appliedEffects"];
413
456
  var props$5 = ['text', 'overlays'];
414
457
  var DEFAULT_TEXT_OPTIONS = {
415
458
  color: 'black',
@@ -452,6 +495,8 @@ function plugin$5(_temp) {
452
495
  text$1 = _ref2.text,
453
496
  _ref2$effects = _ref2.effects,
454
497
  layerEffects = _ref2$effects === void 0 ? [] : _ref2$effects,
498
+ _ref2$appliedEffects = _ref2.appliedEffects,
499
+ appliedEffects = _ref2$appliedEffects === void 0 ? [] : _ref2$appliedEffects,
455
500
  options = _objectWithoutPropertiesLoose(_ref2, _excluded$3);
456
501
  var hasPublicId = typeof publicId === 'string';
457
502
  var hasUrl = typeof url === 'string';
@@ -485,7 +530,11 @@ function plugin$5(_temp) {
485
530
  Object.keys(options).forEach(function (key) {
486
531
  if (!primary[key]) return;
487
532
  var qualifier = primary[key].qualifier;
488
- primary$1.push(qualifier + "_" + options[key]);
533
+ var transformation = constructTransformation({
534
+ qualifier: qualifier,
535
+ value: options[key]
536
+ });
537
+ primary$1.push(transformation);
489
538
  });
490
539
 
491
540
  // Layer effects
@@ -495,27 +544,33 @@ function plugin$5(_temp) {
495
544
 
496
545
  layerEffects.forEach(function (effect) {
497
546
  Object.keys(effect).forEach(function (key) {
498
- if (primary[key]) {
499
- var qualifier = primary[key].qualifier;
500
- primary$1.push(qualifier + "_" + effect[key]);
501
- } else if (effects[key]) {
502
- var _qualifiersEffects$ke = effects[key],
503
- _qualifier = _qualifiersEffects$ke.qualifier,
504
- prefix = _qualifiersEffects$ke.prefix;
505
- var transformation = '';
506
- if (prefix) {
507
- transformation = prefix + "_";
508
- }
509
- if (effect[key] === true) {
510
- primary$1.push("" + transformation + _qualifier);
511
- } else if (typeof effect[key] === 'string' || typeof effect[key] === 'number') {
512
- if (prefix) {
513
- primary$1.push("" + transformation + _qualifier + ":" + effect[key]);
514
- } else {
515
- primary$1.push(_qualifier + "_" + effect[key]);
516
- }
517
- }
518
- }
547
+ var _ref3 = primary[key] || effects[key] || {},
548
+ qualifier = _ref3.qualifier,
549
+ prefix = _ref3.prefix;
550
+ var transformation = constructTransformation({
551
+ qualifier: qualifier,
552
+ prefix: prefix,
553
+ value: effect[key]
554
+ });
555
+ primary$1.push(transformation);
556
+ });
557
+ });
558
+
559
+ // Applied Layer effects
560
+ // Similar to layer effects but they get appended to an additional transformation
561
+ // along with fl_layer_applied
562
+
563
+ appliedEffects.forEach(function (effect) {
564
+ Object.keys(effect).forEach(function (key) {
565
+ var _ref4 = primary[key] || effects[key] || {},
566
+ qualifier = _ref4.qualifier,
567
+ prefix = _ref4.prefix;
568
+ var transformation = constructTransformation({
569
+ qualifier: qualifier,
570
+ prefix: prefix,
571
+ value: effect[key]
572
+ });
573
+ applied.push(transformation);
519
574
  });
520
575
  });
521
576
 
@@ -552,7 +607,11 @@ function plugin$5(_temp) {
552
607
  Object.keys(position$1).forEach(function (key) {
553
608
  if (!position[key]) return;
554
609
  var qualifier = position[key].qualifier;
555
- applied.push(qualifier + "_" + position$1[key]);
610
+ var transformation = constructTransformation({
611
+ qualifier: qualifier,
612
+ value: position$1[key]
613
+ });
614
+ applied.push(transformation);
556
615
  });
557
616
  }
558
617
 
@@ -927,33 +986,6 @@ function getPublicId(src) {
927
986
  return src;
928
987
  }
929
988
 
930
- /**
931
- * Retrieves the transformations added to a cloudiary image url. If no transformation is recognized it returns an empty array.
932
- *
933
- * @param {string} src The cloudiary url.
934
- *
935
- * @return {array} The array of transformations
936
- */
937
-
938
- function getTransformations(src, preserveTransformations) {
939
- if (typeof src !== "string") {
940
- throw new Error("Invalid src of type " + typeof src);
941
- }
942
- if (src.includes("res.cloudinary.com") && preserveTransformations) {
943
- var regex = new RegExp("(https?)://(res.cloudinary.com)/([^/]+)/(image|video|raw)/(upload|authenticated)/(.*)/(v[0-9]+)/(.+)(?:.[a-z]{3})?", "gi");
944
- var groups = regex.exec(src);
945
- var transformationStr = groups.slice(1).find(function (i) {
946
- return i.includes("_");
947
- });
948
- if (transformationStr) {
949
- return transformationStr.split(",").join("/").split("/");
950
- } else {
951
- return [];
952
- }
953
- }
954
- return [];
955
- }
956
-
957
989
  /**
958
990
  * createPlaceholderUrl
959
991
  */
@@ -1283,5 +1315,5 @@ var CldUploadButton = function CldUploadButton(_ref) {
1283
1315
  });
1284
1316
  };
1285
1317
 
1286
- export { CldImage, CldOgImage, CldUploadButton, CldUploadWidget, cloudinaryLoader, position, primary, text };
1318
+ export { CldImage, CldOgImage, CldUploadButton, CldUploadWidget, cloudinaryLoader, constructCloudinaryUrl, effects, position, primary, text };
1287
1319
  //# sourceMappingURL=next-cloudinary.module.js.map