next-cloudinary 1.4.0 → 1.6.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.
@@ -90,89 +90,6 @@
90
90
  plugin: plugin$7
91
91
  };
92
92
 
93
- var params = ['art', {
94
- prop: 'autoBrightness',
95
- effect: 'auto_brightness'
96
- }, {
97
- prop: 'autoColor',
98
- effect: 'auto_color'
99
- }, {
100
- prop: 'autoContrast',
101
- effect: 'auto_contrast'
102
- }, {
103
- prop: 'assistColorblind',
104
- effect: 'assist_colorblind'
105
- }, 'blackwhite', 'blur', {
106
- prop: 'blurFaces',
107
- effect: 'blur_faces'
108
- }, {
109
- prop: 'blurRegion',
110
- effect: 'blur_region'
111
- }, 'brightness', {
112
- prop: 'brightnessHSB',
113
- effect: 'brightness_hsb'
114
- }, 'cartoonify', 'colorize', 'contrast', 'distort', {
115
- prop: 'fillLight',
116
- effect: 'fill_light'
117
- }, 'gamma', {
118
- prop: 'gradientFade',
119
- effect: 'gradient_fade'
120
- }, 'grayscale', 'improve', 'negate', {
121
- prop: 'oilPaint',
122
- effect: 'oil_paint'
123
- }, 'outline', 'pixelate', {
124
- prop: 'pixelateFaces',
125
- effect: 'pixelate_faces'
126
- }, {
127
- prop: 'pixelateRegion',
128
- effect: 'pixelate_region'
129
- }, 'redeye', {
130
- prop: 'replaceColor',
131
- effect: 'replace_color'
132
- }, 'saturation', 'sepia', 'shadow', 'sharpen', 'shear', {
133
- prop: 'simulateColorblind',
134
- effect: 'simulate_colorblind'
135
- }, 'tint', {
136
- prop: 'unsharpMask',
137
- effect: 'unsharp_mask'
138
- }, 'vectorize', 'vibrance', 'vignette'];
139
- var props$6 = params.map(function (param) {
140
- return param.prop || param;
141
- });
142
- function plugin$6(_temp) {
143
- var _ref = _temp === void 0 ? {} : _temp,
144
- cldImage = _ref.cldImage,
145
- options = _ref.options;
146
- params.forEach(function (key) {
147
- var prop = key.prop || key;
148
- var effect = key.effect || key;
149
- if (options[prop] === true) {
150
- cldImage.effect("e_" + effect);
151
- } else if (typeof options[prop] === 'string') {
152
- cldImage.effect("e_" + effect + ":" + options[prop]);
153
- }
154
- });
155
- }
156
-
157
- var effectsPlugin = {
158
- __proto__: null,
159
- props: props$6,
160
- plugin: plugin$6
161
- };
162
-
163
- /**
164
- * encodeBase64
165
- */
166
-
167
- function encodeBase64(value) {
168
- if (typeof btoa === 'function') {
169
- return btoa(value);
170
- }
171
- if (typeof Buffer !== 'undefined') {
172
- return Buffer.from(value).toString('base64');
173
- }
174
- }
175
-
176
93
  // aspectRatio
177
94
 
178
95
  var primary = {
@@ -240,6 +157,261 @@
240
157
  qualifier: false
241
158
  }
242
159
  };
160
+ var effects = {
161
+ art: {
162
+ prefix: 'e',
163
+ qualifier: 'art'
164
+ },
165
+ autoBrightness: {
166
+ prefix: 'e',
167
+ qualifier: 'auto_brightness'
168
+ },
169
+ autoColor: {
170
+ prefix: 'e',
171
+ qualifier: 'auto_color'
172
+ },
173
+ autoContrast: {
174
+ prefix: 'e',
175
+ qualifier: 'auto_contrast'
176
+ },
177
+ assistColorblind: {
178
+ prefix: 'e',
179
+ qualifier: 'assist_colorblind'
180
+ },
181
+ background: {
182
+ qualifier: 'b'
183
+ },
184
+ blackwhite: {
185
+ prefix: 'e',
186
+ qualifier: 'blackwhite'
187
+ },
188
+ blur: {
189
+ prefix: 'e',
190
+ qualifier: 'blur'
191
+ },
192
+ blurFaces: {
193
+ prefix: 'e',
194
+ qualifier: 'blur_faces'
195
+ },
196
+ blurRegion: {
197
+ prefix: 'e',
198
+ qualifier: 'blur_region'
199
+ },
200
+ border: {
201
+ qualifier: 'bo'
202
+ },
203
+ brightness: {
204
+ prefix: 'e',
205
+ qualifier: 'brightness'
206
+ },
207
+ brightnessHSB: {
208
+ prefix: 'e',
209
+ qualifier: 'brightness_hsb'
210
+ },
211
+ cartoonify: {
212
+ prefix: 'e',
213
+ qualifier: 'cartoonify'
214
+ },
215
+ color: {
216
+ qualifier: 'co'
217
+ },
218
+ colorize: {
219
+ prefix: 'e',
220
+ qualifier: 'colorize'
221
+ },
222
+ contrast: {
223
+ prefix: 'e',
224
+ qualifier: 'contrast'
225
+ },
226
+ distort: {
227
+ prefix: 'e',
228
+ qualifier: 'distort'
229
+ },
230
+ fillLight: {
231
+ prefix: 'e',
232
+ qualifier: 'fill_light'
233
+ },
234
+ gamma: {
235
+ prefix: 'e',
236
+ qualifier: 'gamma'
237
+ },
238
+ gradientFade: {
239
+ prefix: 'e',
240
+ qualifier: 'gradient_fade'
241
+ },
242
+ grayscale: {
243
+ prefix: 'e',
244
+ qualifier: 'grayscale'
245
+ },
246
+ improve: {
247
+ prefix: 'e',
248
+ qualifier: 'improve'
249
+ },
250
+ negate: {
251
+ prefix: 'e',
252
+ qualifier: 'negate'
253
+ },
254
+ oilPaint: {
255
+ prefix: 'e',
256
+ qualifier: 'oil_paint'
257
+ },
258
+ opacity: {
259
+ qualifier: 'o'
260
+ },
261
+ outline: {
262
+ prefix: 'e',
263
+ qualifier: 'outline'
264
+ },
265
+ pixelate: {
266
+ prefix: 'e',
267
+ qualifier: 'pixelate'
268
+ },
269
+ pixelateFaces: {
270
+ prefix: 'e',
271
+ qualifier: 'pixelate_faces'
272
+ },
273
+ pixelateRegion: {
274
+ prefix: 'e',
275
+ qualifier: 'pixelate_region'
276
+ },
277
+ redeye: {
278
+ prefix: 'e',
279
+ qualifier: 'redeye'
280
+ },
281
+ replaceColor: {
282
+ prefix: 'e',
283
+ qualifier: 'replace_color'
284
+ },
285
+ saturation: {
286
+ prefix: 'e',
287
+ qualifier: 'saturation'
288
+ },
289
+ sepia: {
290
+ prefix: 'e',
291
+ qualifier: 'sepia'
292
+ },
293
+ shadow: {
294
+ prefix: 'e',
295
+ qualifier: 'shadow'
296
+ },
297
+ sharpen: {
298
+ prefix: 'e',
299
+ qualifier: 'sharpen'
300
+ },
301
+ shear: {
302
+ prefix: 'e',
303
+ qualifier: 'shear'
304
+ },
305
+ simulateColorblind: {
306
+ prefix: 'e',
307
+ qualifier: 'simulate_colorblind'
308
+ },
309
+ tint: {
310
+ prefix: 'e',
311
+ qualifier: 'tint'
312
+ },
313
+ unsharpMask: {
314
+ prefix: 'e',
315
+ qualifier: 'unsharp_mask'
316
+ },
317
+ vectorize: {
318
+ prefix: 'e',
319
+ qualifier: 'vectorize'
320
+ },
321
+ vibrance: {
322
+ prefix: 'e',
323
+ qualifier: 'vibrance'
324
+ },
325
+ vignette: {
326
+ prefix: 'e',
327
+ qualifier: 'vignette'
328
+ }
329
+ };
330
+
331
+ var props$6 = [].concat(Object.keys(effects), ['effects']);
332
+ function plugin$6(_temp) {
333
+ var _ref = _temp === void 0 ? {} : _temp,
334
+ cldImage = _ref.cldImage,
335
+ options = _ref.options;
336
+ // Handle any top-level effect props
337
+
338
+ constructTransformationString({
339
+ effects: effects,
340
+ options: options
341
+ }).filter(function (t) {
342
+ return !!t;
343
+ }).forEach(function (transformation) {
344
+ return cldImage.effect(transformation);
345
+ });
346
+
347
+ // If we're passing in an effects prop explicitly, treat it as an array of
348
+ // effects that we need to process
349
+
350
+ if (Array.isArray(options.effects)) {
351
+ options.effects.forEach(function (effectsSet) {
352
+ var transformationString = constructTransformationString({
353
+ effects: effects,
354
+ options: effectsSet
355
+ }).filter(function (t) {
356
+ return !!t;
357
+ }).join(',');
358
+ cldImage.effect(transformationString);
359
+ });
360
+ }
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;
388
+ return Object.keys(effects).map(function (key) {
389
+ return constructEffect({
390
+ effect: effects[key],
391
+ value: options[key]
392
+ });
393
+ });
394
+ }
395
+ }
396
+
397
+ var effectsPlugin = {
398
+ __proto__: null,
399
+ props: props$6,
400
+ plugin: plugin$6
401
+ };
402
+
403
+ /**
404
+ * encodeBase64
405
+ */
406
+
407
+ function encodeBase64(value) {
408
+ if (typeof btoa === 'function') {
409
+ return btoa(value);
410
+ }
411
+ if (typeof Buffer !== 'undefined') {
412
+ return Buffer.from(value).toString('base64');
413
+ }
414
+ }
243
415
 
244
416
  var _excluded$3 = ["publicId", "url", "position", "text", "effects"];
245
417
  var props$5 = ['text', 'overlays'];
@@ -321,12 +493,33 @@
321
493
  });
322
494
 
323
495
  // Layer effects
496
+ // For layer effects we allow both the standard effects to be applied as well
497
+ // as the primary ones like width and height as those can be used to modify
498
+ // the layer after it's created
324
499
 
325
500
  layerEffects.forEach(function (effect) {
326
501
  Object.keys(effect).forEach(function (key) {
327
- if (!primary[key]) return;
328
- var qualifier = primary[key].qualifier;
329
- primary$1.push(qualifier + "_" + effect[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
+ }
330
523
  });
331
524
  });
332
525