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