next-cloudinary 1.4.0 → 1.5.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.
@@ -86,89 +86,6 @@ var croppingPlugin = {
86
86
  plugin: plugin$7
87
87
  };
88
88
 
89
- var params = ['art', {
90
- prop: 'autoBrightness',
91
- effect: 'auto_brightness'
92
- }, {
93
- prop: 'autoColor',
94
- effect: 'auto_color'
95
- }, {
96
- prop: 'autoContrast',
97
- effect: 'auto_contrast'
98
- }, {
99
- prop: 'assistColorblind',
100
- effect: 'assist_colorblind'
101
- }, 'blackwhite', 'blur', {
102
- prop: 'blurFaces',
103
- effect: 'blur_faces'
104
- }, {
105
- prop: 'blurRegion',
106
- effect: 'blur_region'
107
- }, 'brightness', {
108
- prop: 'brightnessHSB',
109
- effect: 'brightness_hsb'
110
- }, 'cartoonify', 'colorize', 'contrast', 'distort', {
111
- prop: 'fillLight',
112
- effect: 'fill_light'
113
- }, 'gamma', {
114
- prop: 'gradientFade',
115
- effect: 'gradient_fade'
116
- }, 'grayscale', 'improve', 'negate', {
117
- prop: 'oilPaint',
118
- effect: 'oil_paint'
119
- }, 'outline', 'pixelate', {
120
- prop: 'pixelateFaces',
121
- effect: 'pixelate_faces'
122
- }, {
123
- prop: 'pixelateRegion',
124
- effect: 'pixelate_region'
125
- }, 'redeye', {
126
- prop: 'replaceColor',
127
- effect: 'replace_color'
128
- }, 'saturation', 'sepia', 'shadow', 'sharpen', 'shear', {
129
- prop: 'simulateColorblind',
130
- effect: 'simulate_colorblind'
131
- }, 'tint', {
132
- prop: 'unsharpMask',
133
- effect: 'unsharp_mask'
134
- }, 'vectorize', 'vibrance', 'vignette'];
135
- var props$6 = params.map(function (param) {
136
- return param.prop || param;
137
- });
138
- function plugin$6(_temp) {
139
- var _ref = _temp === void 0 ? {} : _temp,
140
- cldImage = _ref.cldImage,
141
- options = _ref.options;
142
- params.forEach(function (key) {
143
- var prop = key.prop || key;
144
- var effect = key.effect || key;
145
- if (options[prop] === true) {
146
- cldImage.effect("e_" + effect);
147
- } else if (typeof options[prop] === 'string') {
148
- cldImage.effect("e_" + effect + ":" + options[prop]);
149
- }
150
- });
151
- }
152
-
153
- var effectsPlugin = {
154
- __proto__: null,
155
- props: props$6,
156
- plugin: plugin$6
157
- };
158
-
159
- /**
160
- * encodeBase64
161
- */
162
-
163
- function encodeBase64(value) {
164
- if (typeof btoa === 'function') {
165
- return btoa(value);
166
- }
167
- if (typeof Buffer !== 'undefined') {
168
- return Buffer.from(value).toString('base64');
169
- }
170
- }
171
-
172
89
  // aspectRatio
173
90
 
174
91
  var primary = {
@@ -236,6 +153,211 @@ var text = {
236
153
  qualifier: false
237
154
  }
238
155
  };
156
+ var effects = {
157
+ art: {
158
+ prefix: 'e',
159
+ qualifier: 'art'
160
+ },
161
+ autoBrightness: {
162
+ prefix: 'e',
163
+ qualifier: 'auto_brightness'
164
+ },
165
+ autoColor: {
166
+ prefix: 'e',
167
+ qualifier: 'auto_color'
168
+ },
169
+ autoContrast: {
170
+ prefix: 'e',
171
+ qualifier: 'auto_contrast'
172
+ },
173
+ assistColorblind: {
174
+ prefix: 'e',
175
+ qualifier: 'assist_colorblind'
176
+ },
177
+ blackwhite: {
178
+ prefix: 'e',
179
+ qualifier: 'blackwhite'
180
+ },
181
+ blur: {
182
+ prefix: 'e',
183
+ qualifier: 'blur'
184
+ },
185
+ blurFaces: {
186
+ prefix: 'e',
187
+ qualifier: 'blur_faces'
188
+ },
189
+ blurRegion: {
190
+ prefix: 'e',
191
+ qualifier: 'blur_region'
192
+ },
193
+ brightness: {
194
+ prefix: 'e',
195
+ qualifier: 'brightness'
196
+ },
197
+ brightnessHSB: {
198
+ prefix: 'e',
199
+ qualifier: 'brightness_hsb'
200
+ },
201
+ cartoonify: {
202
+ prefix: 'e',
203
+ qualifier: 'cartoonify'
204
+ },
205
+ colorize: {
206
+ prefix: 'e',
207
+ qualifier: 'colorize'
208
+ },
209
+ contrast: {
210
+ prefix: 'e',
211
+ qualifier: 'contrast'
212
+ },
213
+ distort: {
214
+ prefix: 'e',
215
+ qualifier: 'distort'
216
+ },
217
+ fillLight: {
218
+ prefix: 'e',
219
+ qualifier: 'fill_light'
220
+ },
221
+ gamma: {
222
+ prefix: 'e',
223
+ qualifier: 'gamma'
224
+ },
225
+ gradientFade: {
226
+ prefix: 'e',
227
+ qualifier: 'gradient_fade'
228
+ },
229
+ grayscale: {
230
+ prefix: 'e',
231
+ qualifier: 'grayscale'
232
+ },
233
+ improve: {
234
+ prefix: 'e',
235
+ qualifier: 'improve'
236
+ },
237
+ negate: {
238
+ prefix: 'e',
239
+ qualifier: 'negate'
240
+ },
241
+ oilPaint: {
242
+ prefix: 'e',
243
+ qualifier: 'oil_paint'
244
+ },
245
+ opacity: {
246
+ qualifier: 'o'
247
+ },
248
+ outline: {
249
+ prefix: 'e',
250
+ qualifier: 'outline'
251
+ },
252
+ pixelate: {
253
+ prefix: 'e',
254
+ qualifier: 'pixelate'
255
+ },
256
+ pixelateFaces: {
257
+ prefix: 'e',
258
+ qualifier: 'pixelate_faces'
259
+ },
260
+ pixelateRegion: {
261
+ prefix: 'e',
262
+ qualifier: 'pixelate_region'
263
+ },
264
+ redeye: {
265
+ prefix: 'e',
266
+ qualifier: 'redeye'
267
+ },
268
+ replaceColor: {
269
+ prefix: 'e',
270
+ qualifier: 'replace_color'
271
+ },
272
+ saturation: {
273
+ prefix: 'e',
274
+ qualifier: 'saturation'
275
+ },
276
+ sepia: {
277
+ prefix: 'e',
278
+ qualifier: 'sepia'
279
+ },
280
+ shadow: {
281
+ prefix: 'e',
282
+ qualifier: 'shadow'
283
+ },
284
+ sharpen: {
285
+ prefix: 'e',
286
+ qualifier: 'sharpen'
287
+ },
288
+ shear: {
289
+ prefix: 'e',
290
+ qualifier: 'shear'
291
+ },
292
+ simulateColorblind: {
293
+ prefix: 'e',
294
+ qualifier: 'simulate_colorblind'
295
+ },
296
+ tint: {
297
+ prefix: 'e',
298
+ qualifier: 'tint'
299
+ },
300
+ unsharpMask: {
301
+ prefix: 'e',
302
+ qualifier: 'unsharp_mask'
303
+ },
304
+ vectorize: {
305
+ prefix: 'e',
306
+ qualifier: 'vectorize'
307
+ },
308
+ vibrance: {
309
+ prefix: 'e',
310
+ qualifier: 'vibrance'
311
+ },
312
+ vignette: {
313
+ prefix: 'e',
314
+ qualifier: 'vignette'
315
+ }
316
+ };
317
+
318
+ var props$6 = Object.keys(effects);
319
+ function plugin$6(_temp) {
320
+ var _ref = _temp === void 0 ? {} : _temp,
321
+ cldImage = _ref.cldImage,
322
+ options = _ref.options;
323
+ Object.keys(effects).forEach(function (key) {
324
+ var _effects$key = effects[key],
325
+ prefix = _effects$key.prefix,
326
+ qualifier = _effects$key.qualifier;
327
+ var transformation = '';
328
+ if (prefix) {
329
+ transformation = prefix + "_";
330
+ }
331
+ if (options[key] === true) {
332
+ cldImage.effect("" + transformation + qualifier);
333
+ } else if (typeof options[key] === 'string') {
334
+ if (prefix) {
335
+ cldImage.effect("" + transformation + qualifier + ":" + options[key]);
336
+ } else {
337
+ cldImage.effect(qualifier + "_" + options[key]);
338
+ }
339
+ }
340
+ });
341
+ }
342
+
343
+ var effectsPlugin = {
344
+ __proto__: null,
345
+ props: props$6,
346
+ plugin: plugin$6
347
+ };
348
+
349
+ /**
350
+ * encodeBase64
351
+ */
352
+
353
+ function encodeBase64(value) {
354
+ if (typeof btoa === 'function') {
355
+ return btoa(value);
356
+ }
357
+ if (typeof Buffer !== 'undefined') {
358
+ return Buffer.from(value).toString('base64');
359
+ }
360
+ }
239
361
 
240
362
  var _excluded$3 = ["publicId", "url", "position", "text", "effects"];
241
363
  var props$5 = ['text', 'overlays'];
@@ -317,12 +439,33 @@ function plugin$5(_temp) {
317
439
  });
318
440
 
319
441
  // Layer effects
442
+ // For layer effects we allow both the standard effects to be applied as well
443
+ // as the primary ones like width and height as those can be used to modify
444
+ // the layer after it's created
320
445
 
321
446
  layerEffects.forEach(function (effect) {
322
447
  Object.keys(effect).forEach(function (key) {
323
- if (!primary[key]) return;
324
- var qualifier = primary[key].qualifier;
325
- primary$1.push(qualifier + "_" + effect[key]);
448
+ if (primary[key]) {
449
+ var qualifier = primary[key].qualifier;
450
+ primary$1.push(qualifier + "_" + effect[key]);
451
+ } else if (effects[key]) {
452
+ var _qualifiersEffects$ke = effects[key],
453
+ _qualifier = _qualifiersEffects$ke.qualifier,
454
+ prefix = _qualifiersEffects$ke.prefix;
455
+ var transformation = '';
456
+ if (prefix) {
457
+ transformation = prefix + "_";
458
+ }
459
+ if (effect[key] === true) {
460
+ primary$1.push("" + transformation + _qualifier);
461
+ } else if (typeof effect[key] === 'string' || typeof effect[key] === 'number') {
462
+ if (prefix) {
463
+ primary$1.push("" + transformation + _qualifier + ":" + effect[key]);
464
+ } else {
465
+ primary$1.push(_qualifier + "_" + effect[key]);
466
+ }
467
+ }
468
+ }
326
469
  });
327
470
  });
328
471