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