next-cloudinary 0.0.1
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 +88 -0
- package/dist/next-cloudinary.js.map +1 -0
- package/dist/next-cloudinary.modern.mjs +82 -0
- package/dist/next-cloudinary.modern.mjs.map +1 -0
- package/dist/next-cloudinary.module.js +84 -0
- package/dist/next-cloudinary.module.js.map +1 -0
- package/dist/next-cloudinary.umd.js +91 -0
- package/dist/next-cloudinary.umd.js.map +1 -0
- package/package.json +21 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var urlGen = require('@cloudinary/url-gen');
|
|
2
|
+
var Image = require('next/image');
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
|
|
5
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
6
|
+
|
|
7
|
+
var Image__default = /*#__PURE__*/_interopDefaultLegacy(Image);
|
|
8
|
+
|
|
9
|
+
function _extends() {
|
|
10
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
11
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
12
|
+
var source = arguments[i];
|
|
13
|
+
|
|
14
|
+
for (var key in source) {
|
|
15
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
16
|
+
target[key] = source[key];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return target;
|
|
22
|
+
};
|
|
23
|
+
return _extends.apply(this, arguments);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
27
|
+
if (source == null) return {};
|
|
28
|
+
var target = {};
|
|
29
|
+
var sourceKeys = Object.keys(source);
|
|
30
|
+
var key, i;
|
|
31
|
+
|
|
32
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
33
|
+
key = sourceKeys[i];
|
|
34
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
35
|
+
target[key] = source[key];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return target;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
var _excluded = ["effects", "removeBackground"];
|
|
42
|
+
var cld = new urlGen.Cloudinary({
|
|
43
|
+
cloud: {
|
|
44
|
+
cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
function cloudinaryLoader(options, cldOptions) {
|
|
49
|
+
var src = options.src,
|
|
50
|
+
width = options.width,
|
|
51
|
+
_options$format = options.format,
|
|
52
|
+
format = _options$format === void 0 ? 'auto' : _options$format,
|
|
53
|
+
_options$quality = options.quality,
|
|
54
|
+
quality = _options$quality === void 0 ? 'auto' : _options$quality;
|
|
55
|
+
var _cldOptions$effects = cldOptions.effects,
|
|
56
|
+
effects = _cldOptions$effects === void 0 ? [] : _cldOptions$effects,
|
|
57
|
+
_cldOptions$removeBac = cldOptions.removeBackground,
|
|
58
|
+
removeBackground = _cldOptions$removeBac === void 0 ? false : _cldOptions$removeBac;
|
|
59
|
+
var cldImage = cld.image(src);
|
|
60
|
+
|
|
61
|
+
if (removeBackground) {
|
|
62
|
+
cldImage.effect('e_background_removal');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
effects.forEach(function (effect) {
|
|
66
|
+
return cldImage.effect(effect);
|
|
67
|
+
});
|
|
68
|
+
return cldImage.resize("c_limit,w_" + width).format(format).delivery("q_" + quality).toURL();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
var CldImage = function CldImage(_ref) {
|
|
72
|
+
var effects = _ref.effects,
|
|
73
|
+
removeBackground = _ref.removeBackground,
|
|
74
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
75
|
+
|
|
76
|
+
var cldOptions = {
|
|
77
|
+
effects: effects,
|
|
78
|
+
removeBackground: removeBackground
|
|
79
|
+
};
|
|
80
|
+
return /*#__PURE__*/jsxRuntime.jsx(Image__default["default"], _extends({}, props, {
|
|
81
|
+
loader: function loader(options) {
|
|
82
|
+
return cloudinaryLoader(options, cldOptions);
|
|
83
|
+
}
|
|
84
|
+
}));
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
exports.CldImage = CldImage;
|
|
88
|
+
//# sourceMappingURL=next-cloudinary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-cloudinary.js","sources":["../src/components/CldImage/CldImage.js"],"sourcesContent":["import { Cloudinary } from '@cloudinary/url-gen';\nimport Image from 'next/image';\n\nconst cld = new Cloudinary({\n cloud: {\n cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME\n }\n});\n\nfunction cloudinaryLoader(options, cldOptions) {\n const {\n src,\n width,\n format = 'auto',\n quality = 'auto'\n } = options;\n\n const {\n effects = [],\n removeBackground = false\n } = cldOptions;\n\n const cldImage = cld.image(src);\n\n if ( removeBackground ) {\n cldImage.effect('e_background_removal');\n }\n\n effects.forEach(effect => cldImage.effect(effect));\n\n return cldImage.resize(`c_limit,w_${width}`).format(format).delivery(`q_${quality}`).toURL();\n}\n\nconst CldImage = ({ effects, removeBackground, ...props }) => {\n const cldOptions = {\n effects,\n removeBackground\n };\n return <Image {...props} loader={(options) => cloudinaryLoader(options, cldOptions)} />\n}\n\nexport default CldImage;"],"names":["cld","Cloudinary","cloud","cloudName","process","env","NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME","cloudinaryLoader","options","cldOptions","src","width","format","quality","effects","removeBackground","cldImage","image","effect","forEach","resize","delivery","toURL","CldImage","props","_jsx","Image"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAMA,GAAG,GAAG,IAAIC,iBAAJ,CAAe;AACzBC,EAAAA,KAAK,EAAE;AACLC,IAAAA,SAAS,EAAEC,OAAO,CAACC,GAAR,CAAYC,iCAAAA;AADlB,GAAA;AADkB,CAAf,CAAZ,CAAA;;AAMA,SAASC,gBAAT,CAA0BC,OAA1B,EAAmCC,UAAnC,EAA+C;AAC7C,EAAA,IACEC,GADF,GAKIF,OALJ,CACEE,GADF;AAAA,MAEEC,KAFF,GAKIH,OALJ,CAEEG,KAFF;MAKIH,eAAAA,GAAAA,OALJ,CAGEI,MAHF;MAGEA,MAHF,gCAGW,MAHX,GAAA,eAAA;MAKIJ,gBAAAA,GAAAA,OALJ,CAIEK,OAJF;MAIEA,OAJF,iCAIY,MAJZ,GAAA,gBAAA,CAAA;EAOA,IAGIJ,mBAAAA,GAAAA,UAHJ,CACEK,OADF;MACEA,OADF,oCACY,EADZ,GAAA,mBAAA;MAGIL,qBAAAA,GAAAA,UAHJ,CAEEM,gBAFF;MAEEA,gBAFF,sCAEqB,KAFrB,GAAA,qBAAA,CAAA;AAKA,EAAA,IAAMC,QAAQ,GAAGhB,GAAG,CAACiB,KAAJ,CAAUP,GAAV,CAAjB,CAAA;;AAEA,EAAA,IAAKK,gBAAL,EAAwB;IACtBC,QAAQ,CAACE,MAAT,CAAgB,sBAAhB,CAAA,CAAA;AACD,GAAA;;AAEDJ,EAAAA,OAAO,CAACK,OAAR,CAAgB,UAAAD,MAAM,EAAA;AAAA,IAAA,OAAIF,QAAQ,CAACE,MAAT,CAAgBA,MAAhB,CAAJ,CAAA;GAAtB,CAAA,CAAA;AAEA,EAAA,OAAOF,QAAQ,CAACI,MAAT,CAAA,YAAA,GAA6BT,KAA7B,CAAsCC,CAAAA,MAAtC,CAA6CA,MAA7C,EAAqDS,QAArD,CAAA,IAAA,GAAmER,OAAnE,CAAA,CAA8ES,KAA9E,EAAP,CAAA;AACD,CAAA;;AAED,IAAMC,QAAQ,GAAG,SAAXA,QAAW,CAA6C,IAAA,EAAA;EAAA,IAA1CT,OAA0C,QAA1CA,OAA0C;MAAjCC,gBAAiC,QAAjCA,gBAAiC;AAAA,MAAZS,KAAY,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAC5D,EAAA,IAAMf,UAAU,GAAG;AACjBK,IAAAA,OAAO,EAAPA,OADiB;AAEjBC,IAAAA,gBAAgB,EAAhBA,gBAAAA;GAFF,CAAA;EAIA,oBAAOU,cAAA,CAACC,yBAAD,EAAA,QAAA,CAAA,EAAA,EAAWF,KAAX,EAAA;IAAkB,MAAM,EAAE,gBAAChB,OAAD,EAAA;AAAA,MAAA,OAAaD,gBAAgB,CAACC,OAAD,EAAUC,UAAV,CAA7B,CAAA;AAAA,KAAA;GAAjC,CAAA,CAAA,CAAA;AACD;;;;"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Cloudinary } from '@cloudinary/url-gen';
|
|
2
|
+
import Image from 'next/image';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
function _extends() {
|
|
6
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
7
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
8
|
+
var source = arguments[i];
|
|
9
|
+
|
|
10
|
+
for (var key in source) {
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
12
|
+
target[key] = source[key];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return target;
|
|
18
|
+
};
|
|
19
|
+
return _extends.apply(this, arguments);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
23
|
+
if (source == null) return {};
|
|
24
|
+
var target = {};
|
|
25
|
+
var sourceKeys = Object.keys(source);
|
|
26
|
+
var key, i;
|
|
27
|
+
|
|
28
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
29
|
+
key = sourceKeys[i];
|
|
30
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
31
|
+
target[key] = source[key];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return target;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const _excluded = ["effects", "removeBackground"];
|
|
38
|
+
const cld = new Cloudinary({
|
|
39
|
+
cloud: {
|
|
40
|
+
cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
function cloudinaryLoader(options, cldOptions) {
|
|
45
|
+
const {
|
|
46
|
+
src,
|
|
47
|
+
width,
|
|
48
|
+
format = 'auto',
|
|
49
|
+
quality = 'auto'
|
|
50
|
+
} = options;
|
|
51
|
+
const {
|
|
52
|
+
effects = [],
|
|
53
|
+
removeBackground = false
|
|
54
|
+
} = cldOptions;
|
|
55
|
+
const cldImage = cld.image(src);
|
|
56
|
+
|
|
57
|
+
if (removeBackground) {
|
|
58
|
+
cldImage.effect('e_background_removal');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
effects.forEach(effect => cldImage.effect(effect));
|
|
62
|
+
return cldImage.resize(`c_limit,w_${width}`).format(format).delivery(`q_${quality}`).toURL();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const CldImage = _ref => {
|
|
66
|
+
let {
|
|
67
|
+
effects,
|
|
68
|
+
removeBackground
|
|
69
|
+
} = _ref,
|
|
70
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
71
|
+
|
|
72
|
+
const cldOptions = {
|
|
73
|
+
effects,
|
|
74
|
+
removeBackground
|
|
75
|
+
};
|
|
76
|
+
return /*#__PURE__*/jsx(Image, _extends({}, props, {
|
|
77
|
+
loader: options => cloudinaryLoader(options, cldOptions)
|
|
78
|
+
}));
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export { CldImage };
|
|
82
|
+
//# sourceMappingURL=next-cloudinary.modern.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-cloudinary.modern.mjs","sources":["../src/components/CldImage/CldImage.js"],"sourcesContent":["import { Cloudinary } from '@cloudinary/url-gen';\nimport Image from 'next/image';\n\nconst cld = new Cloudinary({\n cloud: {\n cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME\n }\n});\n\nfunction cloudinaryLoader(options, cldOptions) {\n const {\n src,\n width,\n format = 'auto',\n quality = 'auto'\n } = options;\n\n const {\n effects = [],\n removeBackground = false\n } = cldOptions;\n\n const cldImage = cld.image(src);\n\n if ( removeBackground ) {\n cldImage.effect('e_background_removal');\n }\n\n effects.forEach(effect => cldImage.effect(effect));\n\n return cldImage.resize(`c_limit,w_${width}`).format(format).delivery(`q_${quality}`).toURL();\n}\n\nconst CldImage = ({ effects, removeBackground, ...props }) => {\n const cldOptions = {\n effects,\n removeBackground\n };\n return <Image {...props} loader={(options) => cloudinaryLoader(options, cldOptions)} />\n}\n\nexport default CldImage;"],"names":["cld","Cloudinary","cloud","cloudName","process","env","NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME","cloudinaryLoader","options","cldOptions","src","width","format","quality","effects","removeBackground","cldImage","image","effect","forEach","resize","delivery","toURL","CldImage","props","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAMA,GAAG,GAAG,IAAIC,UAAJ,CAAe;AACzBC,EAAAA,KAAK,EAAE;AACLC,IAAAA,SAAS,EAAEC,OAAO,CAACC,GAAR,CAAYC,iCAAAA;AADlB,GAAA;AADkB,CAAf,CAAZ,CAAA;;AAMA,SAASC,gBAAT,CAA0BC,OAA1B,EAAmCC,UAAnC,EAA+C;EAC7C,MAAM;IACJC,GADI;IAEJC,KAFI;AAGJC,IAAAA,MAAM,GAAG,MAHL;AAIJC,IAAAA,OAAO,GAAG,MAAA;AAJN,GAAA,GAKFL,OALJ,CAAA;EAOA,MAAM;AACJM,IAAAA,OAAO,GAAG,EADN;AAEJC,IAAAA,gBAAgB,GAAG,KAAA;AAFf,GAAA,GAGFN,UAHJ,CAAA;AAKA,EAAA,MAAMO,QAAQ,GAAGhB,GAAG,CAACiB,KAAJ,CAAUP,GAAV,CAAjB,CAAA;;AAEA,EAAA,IAAKK,gBAAL,EAAwB;IACtBC,QAAQ,CAACE,MAAT,CAAgB,sBAAhB,CAAA,CAAA;AACD,GAAA;;EAEDJ,OAAO,CAACK,OAAR,CAAgBD,MAAM,IAAIF,QAAQ,CAACE,MAAT,CAAgBA,MAAhB,CAA1B,CAAA,CAAA;AAEA,EAAA,OAAOF,QAAQ,CAACI,MAAT,CAAiB,CAAYT,UAAAA,EAAAA,KAAM,EAAnC,CAAsCC,CAAAA,MAAtC,CAA6CA,MAA7C,CAAA,CAAqDS,QAArD,CAA+D,CAAA,EAAA,EAAIR,OAAQ,CAA3E,CAAA,CAAA,CAA8ES,KAA9E,EAAP,CAAA;AACD,CAAA;;AAEKC,MAAAA,QAAQ,GAAG,IAA6C,IAAA;EAAA,IAA5C;IAAET,OAAF;AAAWC,IAAAA,gBAAAA;GAAiC,GAAA,IAAA;AAAA,MAAZS,KAAY,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAC5D,EAAA,MAAMf,UAAU,GAAG;IACjBK,OADiB;AAEjBC,IAAAA,gBAAAA;GAFF,CAAA;EAIA,oBAAOU,GAAA,CAAC,KAAD,EAAA,QAAA,CAAA,EAAA,EAAWD,KAAX,EAAA;AAAkB,IAAA,MAAM,EAAGhB,OAAD,IAAaD,gBAAgB,CAACC,OAAD,EAAUC,UAAV,CAAA;GAA9D,CAAA,CAAA,CAAA;AACD;;;;"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Cloudinary } from '@cloudinary/url-gen';
|
|
2
|
+
import Image from 'next/image';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
function _extends() {
|
|
6
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
7
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
8
|
+
var source = arguments[i];
|
|
9
|
+
|
|
10
|
+
for (var key in source) {
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
12
|
+
target[key] = source[key];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return target;
|
|
18
|
+
};
|
|
19
|
+
return _extends.apply(this, arguments);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
23
|
+
if (source == null) return {};
|
|
24
|
+
var target = {};
|
|
25
|
+
var sourceKeys = Object.keys(source);
|
|
26
|
+
var key, i;
|
|
27
|
+
|
|
28
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
29
|
+
key = sourceKeys[i];
|
|
30
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
31
|
+
target[key] = source[key];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return target;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var _excluded = ["effects", "removeBackground"];
|
|
38
|
+
var cld = new Cloudinary({
|
|
39
|
+
cloud: {
|
|
40
|
+
cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
function cloudinaryLoader(options, cldOptions) {
|
|
45
|
+
var src = options.src,
|
|
46
|
+
width = options.width,
|
|
47
|
+
_options$format = options.format,
|
|
48
|
+
format = _options$format === void 0 ? 'auto' : _options$format,
|
|
49
|
+
_options$quality = options.quality,
|
|
50
|
+
quality = _options$quality === void 0 ? 'auto' : _options$quality;
|
|
51
|
+
var _cldOptions$effects = cldOptions.effects,
|
|
52
|
+
effects = _cldOptions$effects === void 0 ? [] : _cldOptions$effects,
|
|
53
|
+
_cldOptions$removeBac = cldOptions.removeBackground,
|
|
54
|
+
removeBackground = _cldOptions$removeBac === void 0 ? false : _cldOptions$removeBac;
|
|
55
|
+
var cldImage = cld.image(src);
|
|
56
|
+
|
|
57
|
+
if (removeBackground) {
|
|
58
|
+
cldImage.effect('e_background_removal');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
effects.forEach(function (effect) {
|
|
62
|
+
return cldImage.effect(effect);
|
|
63
|
+
});
|
|
64
|
+
return cldImage.resize("c_limit,w_" + width).format(format).delivery("q_" + quality).toURL();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
var CldImage = function CldImage(_ref) {
|
|
68
|
+
var effects = _ref.effects,
|
|
69
|
+
removeBackground = _ref.removeBackground,
|
|
70
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
71
|
+
|
|
72
|
+
var cldOptions = {
|
|
73
|
+
effects: effects,
|
|
74
|
+
removeBackground: removeBackground
|
|
75
|
+
};
|
|
76
|
+
return /*#__PURE__*/jsx(Image, _extends({}, props, {
|
|
77
|
+
loader: function loader(options) {
|
|
78
|
+
return cloudinaryLoader(options, cldOptions);
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export { CldImage };
|
|
84
|
+
//# sourceMappingURL=next-cloudinary.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-cloudinary.module.js","sources":["../src/components/CldImage/CldImage.js"],"sourcesContent":["import { Cloudinary } from '@cloudinary/url-gen';\nimport Image from 'next/image';\n\nconst cld = new Cloudinary({\n cloud: {\n cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME\n }\n});\n\nfunction cloudinaryLoader(options, cldOptions) {\n const {\n src,\n width,\n format = 'auto',\n quality = 'auto'\n } = options;\n\n const {\n effects = [],\n removeBackground = false\n } = cldOptions;\n\n const cldImage = cld.image(src);\n\n if ( removeBackground ) {\n cldImage.effect('e_background_removal');\n }\n\n effects.forEach(effect => cldImage.effect(effect));\n\n return cldImage.resize(`c_limit,w_${width}`).format(format).delivery(`q_${quality}`).toURL();\n}\n\nconst CldImage = ({ effects, removeBackground, ...props }) => {\n const cldOptions = {\n effects,\n removeBackground\n };\n return <Image {...props} loader={(options) => cloudinaryLoader(options, cldOptions)} />\n}\n\nexport default CldImage;"],"names":["cld","Cloudinary","cloud","cloudName","process","env","NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME","cloudinaryLoader","options","cldOptions","src","width","format","quality","effects","removeBackground","cldImage","image","effect","forEach","resize","delivery","toURL","CldImage","props","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAMA,GAAG,GAAG,IAAIC,UAAJ,CAAe;AACzBC,EAAAA,KAAK,EAAE;AACLC,IAAAA,SAAS,EAAEC,OAAO,CAACC,GAAR,CAAYC,iCAAAA;AADlB,GAAA;AADkB,CAAf,CAAZ,CAAA;;AAMA,SAASC,gBAAT,CAA0BC,OAA1B,EAAmCC,UAAnC,EAA+C;AAC7C,EAAA,IACEC,GADF,GAKIF,OALJ,CACEE,GADF;AAAA,MAEEC,KAFF,GAKIH,OALJ,CAEEG,KAFF;MAKIH,eAAAA,GAAAA,OALJ,CAGEI,MAHF;MAGEA,MAHF,gCAGW,MAHX,GAAA,eAAA;MAKIJ,gBAAAA,GAAAA,OALJ,CAIEK,OAJF;MAIEA,OAJF,iCAIY,MAJZ,GAAA,gBAAA,CAAA;EAOA,IAGIJ,mBAAAA,GAAAA,UAHJ,CACEK,OADF;MACEA,OADF,oCACY,EADZ,GAAA,mBAAA;MAGIL,qBAAAA,GAAAA,UAHJ,CAEEM,gBAFF;MAEEA,gBAFF,sCAEqB,KAFrB,GAAA,qBAAA,CAAA;AAKA,EAAA,IAAMC,QAAQ,GAAGhB,GAAG,CAACiB,KAAJ,CAAUP,GAAV,CAAjB,CAAA;;AAEA,EAAA,IAAKK,gBAAL,EAAwB;IACtBC,QAAQ,CAACE,MAAT,CAAgB,sBAAhB,CAAA,CAAA;AACD,GAAA;;AAEDJ,EAAAA,OAAO,CAACK,OAAR,CAAgB,UAAAD,MAAM,EAAA;AAAA,IAAA,OAAIF,QAAQ,CAACE,MAAT,CAAgBA,MAAhB,CAAJ,CAAA;GAAtB,CAAA,CAAA;AAEA,EAAA,OAAOF,QAAQ,CAACI,MAAT,CAAA,YAAA,GAA6BT,KAA7B,CAAsCC,CAAAA,MAAtC,CAA6CA,MAA7C,EAAqDS,QAArD,CAAA,IAAA,GAAmER,OAAnE,CAAA,CAA8ES,KAA9E,EAAP,CAAA;AACD,CAAA;;AAED,IAAMC,QAAQ,GAAG,SAAXA,QAAW,CAA6C,IAAA,EAAA;EAAA,IAA1CT,OAA0C,QAA1CA,OAA0C;MAAjCC,gBAAiC,QAAjCA,gBAAiC;AAAA,MAAZS,KAAY,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAC5D,EAAA,IAAMf,UAAU,GAAG;AACjBK,IAAAA,OAAO,EAAPA,OADiB;AAEjBC,IAAAA,gBAAgB,EAAhBA,gBAAAA;GAFF,CAAA;EAIA,oBAAOU,GAAA,CAAC,KAAD,EAAA,QAAA,CAAA,EAAA,EAAWD,KAAX,EAAA;IAAkB,MAAM,EAAE,gBAAChB,OAAD,EAAA;AAAA,MAAA,OAAaD,gBAAgB,CAACC,OAAD,EAAUC,UAAV,CAA7B,CAAA;AAAA,KAAA;GAAjC,CAAA,CAAA,CAAA;AACD;;;;"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@cloudinary/url-gen'), require('next/image'), require('react/jsx-runtime')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@cloudinary/url-gen', 'next/image', 'react/jsx-runtime'], factory) :
|
|
4
|
+
(global = global || self, factory(global.nextCloudinary = {}, global.urlGen, global.Image, global.jsxRuntime));
|
|
5
|
+
})(this, (function (exports, urlGen, Image, jsxRuntime) {
|
|
6
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
7
|
+
|
|
8
|
+
var Image__default = /*#__PURE__*/_interopDefaultLegacy(Image);
|
|
9
|
+
|
|
10
|
+
function _extends() {
|
|
11
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
12
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
13
|
+
var source = arguments[i];
|
|
14
|
+
|
|
15
|
+
for (var key in source) {
|
|
16
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
17
|
+
target[key] = source[key];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return target;
|
|
23
|
+
};
|
|
24
|
+
return _extends.apply(this, arguments);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
28
|
+
if (source == null) return {};
|
|
29
|
+
var target = {};
|
|
30
|
+
var sourceKeys = Object.keys(source);
|
|
31
|
+
var key, i;
|
|
32
|
+
|
|
33
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
34
|
+
key = sourceKeys[i];
|
|
35
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
36
|
+
target[key] = source[key];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return target;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var _excluded = ["effects", "removeBackground"];
|
|
43
|
+
var cld = new urlGen.Cloudinary({
|
|
44
|
+
cloud: {
|
|
45
|
+
cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
function cloudinaryLoader(options, cldOptions) {
|
|
50
|
+
var src = options.src,
|
|
51
|
+
width = options.width,
|
|
52
|
+
_options$format = options.format,
|
|
53
|
+
format = _options$format === void 0 ? 'auto' : _options$format,
|
|
54
|
+
_options$quality = options.quality,
|
|
55
|
+
quality = _options$quality === void 0 ? 'auto' : _options$quality;
|
|
56
|
+
var _cldOptions$effects = cldOptions.effects,
|
|
57
|
+
effects = _cldOptions$effects === void 0 ? [] : _cldOptions$effects,
|
|
58
|
+
_cldOptions$removeBac = cldOptions.removeBackground,
|
|
59
|
+
removeBackground = _cldOptions$removeBac === void 0 ? false : _cldOptions$removeBac;
|
|
60
|
+
var cldImage = cld.image(src);
|
|
61
|
+
|
|
62
|
+
if (removeBackground) {
|
|
63
|
+
cldImage.effect('e_background_removal');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
effects.forEach(function (effect) {
|
|
67
|
+
return cldImage.effect(effect);
|
|
68
|
+
});
|
|
69
|
+
return cldImage.resize("c_limit,w_" + width).format(format).delivery("q_" + quality).toURL();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
var CldImage = function CldImage(_ref) {
|
|
73
|
+
var effects = _ref.effects,
|
|
74
|
+
removeBackground = _ref.removeBackground,
|
|
75
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
76
|
+
|
|
77
|
+
var cldOptions = {
|
|
78
|
+
effects: effects,
|
|
79
|
+
removeBackground: removeBackground
|
|
80
|
+
};
|
|
81
|
+
return /*#__PURE__*/jsxRuntime.jsx(Image__default["default"], _extends({}, props, {
|
|
82
|
+
loader: function loader(options) {
|
|
83
|
+
return cloudinaryLoader(options, cldOptions);
|
|
84
|
+
}
|
|
85
|
+
}));
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
exports.CldImage = CldImage;
|
|
89
|
+
|
|
90
|
+
}));
|
|
91
|
+
//# sourceMappingURL=next-cloudinary.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-cloudinary.umd.js","sources":["../src/components/CldImage/CldImage.js"],"sourcesContent":["import { Cloudinary } from '@cloudinary/url-gen';\nimport Image from 'next/image';\n\nconst cld = new Cloudinary({\n cloud: {\n cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME\n }\n});\n\nfunction cloudinaryLoader(options, cldOptions) {\n const {\n src,\n width,\n format = 'auto',\n quality = 'auto'\n } = options;\n\n const {\n effects = [],\n removeBackground = false\n } = cldOptions;\n\n const cldImage = cld.image(src);\n\n if ( removeBackground ) {\n cldImage.effect('e_background_removal');\n }\n\n effects.forEach(effect => cldImage.effect(effect));\n\n return cldImage.resize(`c_limit,w_${width}`).format(format).delivery(`q_${quality}`).toURL();\n}\n\nconst CldImage = ({ effects, removeBackground, ...props }) => {\n const cldOptions = {\n effects,\n removeBackground\n };\n return <Image {...props} loader={(options) => cloudinaryLoader(options, cldOptions)} />\n}\n\nexport default CldImage;"],"names":["cld","Cloudinary","cloud","cloudName","process","env","NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME","cloudinaryLoader","options","cldOptions","src","width","format","quality","effects","removeBackground","cldImage","image","effect","forEach","resize","delivery","toURL","CldImage","props","_jsx","Image"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGA,IAAMA,GAAG,GAAG,IAAIC,iBAAJ,CAAe;EACzBC,EAAAA,KAAK,EAAE;EACLC,IAAAA,SAAS,EAAEC,OAAO,CAACC,GAAR,CAAYC,iCAAAA;EADlB,GAAA;EADkB,CAAf,CAAZ,CAAA;;EAMA,SAASC,gBAAT,CAA0BC,OAA1B,EAAmCC,UAAnC,EAA+C;EAC7C,EAAA,IACEC,GADF,GAKIF,OALJ,CACEE,GADF;EAAA,MAEEC,KAFF,GAKIH,OALJ,CAEEG,KAFF;QAKIH,eAAAA,GAAAA,OALJ,CAGEI,MAHF;QAGEA,MAHF,gCAGW,MAHX,GAAA,eAAA;QAKIJ,gBAAAA,GAAAA,OALJ,CAIEK,OAJF;QAIEA,OAJF,iCAIY,MAJZ,GAAA,gBAAA,CAAA;IAOA,IAGIJ,mBAAAA,GAAAA,UAHJ,CACEK,OADF;QACEA,OADF,oCACY,EADZ,GAAA,mBAAA;QAGIL,qBAAAA,GAAAA,UAHJ,CAEEM,gBAFF;QAEEA,gBAFF,sCAEqB,KAFrB,GAAA,qBAAA,CAAA;EAKA,EAAA,IAAMC,QAAQ,GAAGhB,GAAG,CAACiB,KAAJ,CAAUP,GAAV,CAAjB,CAAA;;EAEA,EAAA,IAAKK,gBAAL,EAAwB;MACtBC,QAAQ,CAACE,MAAT,CAAgB,sBAAhB,CAAA,CAAA;EACD,GAAA;;EAEDJ,EAAAA,OAAO,CAACK,OAAR,CAAgB,UAAAD,MAAM,EAAA;EAAA,IAAA,OAAIF,QAAQ,CAACE,MAAT,CAAgBA,MAAhB,CAAJ,CAAA;KAAtB,CAAA,CAAA;EAEA,EAAA,OAAOF,QAAQ,CAACI,MAAT,CAAA,YAAA,GAA6BT,KAA7B,CAAsCC,CAAAA,MAAtC,CAA6CA,MAA7C,EAAqDS,QAArD,CAAA,IAAA,GAAmER,OAAnE,CAAA,CAA8ES,KAA9E,EAAP,CAAA;EACD,CAAA;;AAED,MAAMC,QAAQ,GAAG,SAAXA,QAAW,CAA6C,IAAA,EAAA;IAAA,IAA1CT,OAA0C,QAA1CA,OAA0C;QAAjCC,gBAAiC,QAAjCA,gBAAiC;EAAA,MAAZS,KAAY,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;EAC5D,EAAA,IAAMf,UAAU,GAAG;EACjBK,IAAAA,OAAO,EAAPA,OADiB;EAEjBC,IAAAA,gBAAgB,EAAhBA,gBAAAA;KAFF,CAAA;IAIA,oBAAOU,cAAA,CAACC,yBAAD,EAAA,QAAA,CAAA,EAAA,EAAWF,KAAX,EAAA;MAAkB,MAAM,EAAE,gBAAChB,OAAD,EAAA;EAAA,MAAA,OAAaD,gBAAgB,CAACC,OAAD,EAAUC,UAAV,CAA7B,CAAA;EAAA,KAAA;KAAjC,CAAA,CAAA,CAAA;EACD;;;;;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "next-cloudinary",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "dist/next-cloudinary.umd.js",
|
|
5
|
+
"module": "dist/next-cloudinary.module.js",
|
|
6
|
+
"umd:main": "dist/next-cloudinary.umd.js",
|
|
7
|
+
"source": "src/index.js",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "microbundle --no-compress --jsx React.createElement --jsxFragment React.Fragment --jsxImportSource react"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@cloudinary/url-gen": "^1.8.5"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"microbundle": "^0.15.1"
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"next": "^12.2.5",
|
|
19
|
+
"react": "^18.2.0"
|
|
20
|
+
}
|
|
21
|
+
}
|