next-cloudinary 6.13.0 → 7.0.0-beta.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/CldImage-4b579fe8.esm.js +138 -0
- package/dist/CldImage-68dff3e6.cjs.js +146 -0
- package/dist/CldUploadButton-196b419b.esm.js +101 -0
- package/dist/CldUploadButton-db9b095b.cjs.js +109 -0
- package/dist/CldUploadWidget-a9c04a78.esm.js +207 -0
- package/dist/CldUploadWidget-e39838cc.cjs.js +215 -0
- package/dist/CldVideoPlayer-49ac4380.cjs.js +149 -0
- package/dist/CldVideoPlayer-7b1734a7.esm.js +140 -0
- package/dist/cloudinary-1cbbab64.cjs.js +138 -0
- package/dist/cloudinary-9437f0ad.esm.js +131 -0
- package/dist/cloudinary-loader-1863f0f4.esm.js +59 -0
- package/dist/cloudinary-loader-80d421f0.cjs.js +62 -0
- package/dist/next-cloudinary.cjs.d.mts +2 -0
- package/dist/next-cloudinary.cjs.d.ts +2 -0
- package/dist/next-cloudinary.cjs.js +165 -0
- package/dist/next-cloudinary.cjs.mjs +11 -0
- package/dist/next-cloudinary.esm.js +134 -0
- package/package.json +47 -12
- package/scripts/copy-assets.ts +78 -0
- package/tsconfig.json +3 -3
- package/dist/index.d.mts +0 -152
- package/dist/index.d.ts +0 -152
- package/dist/index.js +0 -4
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -4
- package/dist/index.mjs.map +0 -1
- package/plugins/copy-assets.ts +0 -80
- package/tsup.config.ts +0 -18
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import nextPkg from 'next/package.json';
|
|
2
|
+
|
|
3
|
+
var pkg = {
|
|
4
|
+
name: "next-cloudinary",
|
|
5
|
+
version: "7.0.0-beta.1",
|
|
6
|
+
license: "MIT",
|
|
7
|
+
main: "dist/next-cloudinary.cjs.js",
|
|
8
|
+
module: "dist/next-cloudinary.esm.js",
|
|
9
|
+
exports: {
|
|
10
|
+
".": {
|
|
11
|
+
types: {
|
|
12
|
+
"import": "./dist/next-cloudinary.cjs.mjs",
|
|
13
|
+
"default": "./dist/next-cloudinary.cjs.js"
|
|
14
|
+
},
|
|
15
|
+
module: "./dist/next-cloudinary.esm.js",
|
|
16
|
+
"import": "./dist/next-cloudinary.cjs.mjs",
|
|
17
|
+
"default": "./dist/next-cloudinary.cjs.js"
|
|
18
|
+
},
|
|
19
|
+
"./package.json": "./package.json",
|
|
20
|
+
"./cld-video-player.css": "./dist/cld-video-player.css",
|
|
21
|
+
"./dist/cld-video-player.css": "./dist/cld-video-player.css",
|
|
22
|
+
"./cloudinary_icon_for_black_bg.svg": "./dist/cloudinary_icon_for_black_bg.svg",
|
|
23
|
+
"./dist/cloudinary_icon_for_black_bg.svg": "./dist/cloudinary_icon_for_black_bg.svg",
|
|
24
|
+
"./cloudinary_icon_for_white_bg.svg": "./dist/cloudinary_icon_for_white_bg.svg",
|
|
25
|
+
"./dist/cloudinary_icon_for_white_bg.svg": "./dist/cloudinary_icon_for_white_bg.svg"
|
|
26
|
+
},
|
|
27
|
+
types: "./dist/next-cloudinary.cjs.d.ts",
|
|
28
|
+
scripts: {
|
|
29
|
+
build: "preconstruct build && tsx scripts/copy-assets.ts",
|
|
30
|
+
dev: "preconstruct watch",
|
|
31
|
+
prepublishOnly: "cp ../README.md . && cp ../LICENSE . && pnpm build",
|
|
32
|
+
postpublish: "rm ./README.md && rm ./LICENSE",
|
|
33
|
+
test: "vitest run",
|
|
34
|
+
"test:app": "NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME=\"test\" pnpm build && cd tests/nextjs-app && pnpm build",
|
|
35
|
+
"test:watch": "vitest"
|
|
36
|
+
},
|
|
37
|
+
dependencies: {
|
|
38
|
+
"@cloudinary-util/types": "1.5.8",
|
|
39
|
+
"@cloudinary-util/url-loader": "5.10.3",
|
|
40
|
+
"@cloudinary-util/util": "^3.3.2"
|
|
41
|
+
},
|
|
42
|
+
devDependencies: {
|
|
43
|
+
"@babel/core": "^7.25.2",
|
|
44
|
+
"@babel/preset-env": "^7.25.4",
|
|
45
|
+
"@babel/preset-react": "^7.24.7",
|
|
46
|
+
"@babel/preset-typescript": "^7.24.7",
|
|
47
|
+
"@tsconfig/recommended": "^1.0.7",
|
|
48
|
+
"@types/node": "^22.0.2",
|
|
49
|
+
"@types/react": "^18.3.3",
|
|
50
|
+
"@types/react-dom": "^18.3.0",
|
|
51
|
+
dotenv: "^16.4.5",
|
|
52
|
+
mkdirp: "^3.0.1",
|
|
53
|
+
tsx: "^4.19.1",
|
|
54
|
+
typescript: "^5.5.4",
|
|
55
|
+
vitest: "^2.0.5"
|
|
56
|
+
},
|
|
57
|
+
peerDependencies: {
|
|
58
|
+
next: "^12 || ^13 || ^14 || >=15.0.0-rc",
|
|
59
|
+
react: "^17 || ^18 || >=19.0.0-beta"
|
|
60
|
+
},
|
|
61
|
+
preconstruct: {
|
|
62
|
+
exports: {
|
|
63
|
+
importConditionDefaultExport: "default",
|
|
64
|
+
extra: {
|
|
65
|
+
"./cld-video-player.css": "./dist/cld-video-player.css",
|
|
66
|
+
"./dist/cld-video-player.css": "./dist/cld-video-player.css",
|
|
67
|
+
"./cloudinary_icon_for_black_bg.svg": "./dist/cloudinary_icon_for_black_bg.svg",
|
|
68
|
+
"./dist/cloudinary_icon_for_black_bg.svg": "./dist/cloudinary_icon_for_black_bg.svg",
|
|
69
|
+
"./cloudinary_icon_for_white_bg.svg": "./dist/cloudinary_icon_for_white_bg.svg",
|
|
70
|
+
"./dist/cloudinary_icon_for_white_bg.svg": "./dist/cloudinary_icon_for_white_bg.svg"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
___experimentalFlags_WILL_CHANGE_IN_PATCH: {
|
|
74
|
+
importsConditions: true
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const NEXT_CLOUDINARY_ANALYTICS_PRODUCT_ID = 'A';
|
|
80
|
+
const NEXT_CLOUDINARY_ANALYTICS_ID = 'V';
|
|
81
|
+
const NEXT_VERSION = normalizeVersion(nextPkg.version);
|
|
82
|
+
const NEXT_CLOUDINARY_VERSION = normalizeVersion(pkg.version);
|
|
83
|
+
function normalizeVersion(version) {
|
|
84
|
+
let normalized = version;
|
|
85
|
+
if (normalized.includes('-')) {
|
|
86
|
+
normalized = normalized.split('-')[0];
|
|
87
|
+
}
|
|
88
|
+
return normalized;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* getCloudinaryConfig
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
function getCloudinaryConfig(config) {
|
|
96
|
+
const cloudName = config?.cloud?.cloudName ?? process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME;
|
|
97
|
+
if (!cloudName) {
|
|
98
|
+
throw new Error('A Cloudinary Cloud name is required, please make sure NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME is set and configured in your environment.');
|
|
99
|
+
}
|
|
100
|
+
const apiKey = config?.cloud?.apiKey ?? process.env.NEXT_PUBLIC_CLOUDINARY_API_KEY;
|
|
101
|
+
const secureDistribution = config?.url?.secureDistribution ?? process.env.NEXT_PUBLIC_CLOUDINARY_SECURE_DISTRIBUTION;
|
|
102
|
+
const privateCdn = config?.url?.privateCdn ?? process.env.NEXT_PUBLIC_CLOUDINARY_PRIVATE_CDN;
|
|
103
|
+
return Object.assign({
|
|
104
|
+
cloud: {
|
|
105
|
+
...config?.cloud,
|
|
106
|
+
apiKey,
|
|
107
|
+
cloudName
|
|
108
|
+
},
|
|
109
|
+
url: {
|
|
110
|
+
...config?.url,
|
|
111
|
+
secureDistribution,
|
|
112
|
+
privateCdn
|
|
113
|
+
}
|
|
114
|
+
}, config);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* getCloudinaryAnalytics
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
function getCloudinaryAnalytics(analytics) {
|
|
122
|
+
return Object.assign({
|
|
123
|
+
product: NEXT_CLOUDINARY_ANALYTICS_PRODUCT_ID,
|
|
124
|
+
sdkCode: NEXT_CLOUDINARY_ANALYTICS_ID,
|
|
125
|
+
sdkSemver: NEXT_CLOUDINARY_VERSION,
|
|
126
|
+
techVersion: NEXT_VERSION,
|
|
127
|
+
feature: ''
|
|
128
|
+
}, analytics);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { getCloudinaryAnalytics as a, getCloudinaryConfig as g };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { constructCloudinaryUrl } from '@cloudinary-util/url-loader';
|
|
2
|
+
import { g as getCloudinaryConfig, a as getCloudinaryAnalytics } from './cloudinary-9437f0ad.esm.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* getCldImageUrl
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
function getCldImageUrl(options, config, analytics) {
|
|
9
|
+
return constructCloudinaryUrl({
|
|
10
|
+
options,
|
|
11
|
+
config: getCloudinaryConfig(config),
|
|
12
|
+
analytics: getCloudinaryAnalytics(analytics)
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function cloudinaryLoader({
|
|
17
|
+
loaderOptions,
|
|
18
|
+
imageProps,
|
|
19
|
+
cldOptions,
|
|
20
|
+
cldConfig = {}
|
|
21
|
+
}) {
|
|
22
|
+
const options = {
|
|
23
|
+
...imageProps,
|
|
24
|
+
...cldOptions
|
|
25
|
+
};
|
|
26
|
+
options.width = typeof options.width === 'string' ? parseInt(options.width) : options.width;
|
|
27
|
+
options.height = typeof options.height === 'string' ? parseInt(options.height) : options.height;
|
|
28
|
+
|
|
29
|
+
// // The loader options are used to create dynamic sizing when working with responsive images
|
|
30
|
+
// // so these should override the default options collected from the props alone if
|
|
31
|
+
// // the results are different. While we don't always use the height in the loader logic,
|
|
32
|
+
// // we always pass it here, as the usage is determined later based on cropping.js
|
|
33
|
+
|
|
34
|
+
if (typeof loaderOptions?.width === 'number' && typeof options.width === 'number' && loaderOptions.width !== options.width) {
|
|
35
|
+
const multiplier = loaderOptions.width / options.width;
|
|
36
|
+
options.width = loaderOptions.width;
|
|
37
|
+
|
|
38
|
+
// The height may change based off of the value passed through via the loader options
|
|
39
|
+
// In an example where the user sizes is 800x600, but the loader is passing in 400
|
|
40
|
+
// due to responsive sizing, we want to ensure we're using a height that will
|
|
41
|
+
// resolve to the same aspect ratio
|
|
42
|
+
|
|
43
|
+
if (typeof options.height === 'number') {
|
|
44
|
+
options.height = Math.floor(options.height * multiplier);
|
|
45
|
+
}
|
|
46
|
+
} else if (typeof loaderOptions?.width === 'number' && typeof options?.width !== 'number') {
|
|
47
|
+
// If we don't have a width on the options object, this may mean that the component is using
|
|
48
|
+
// the fill option: https://nextjs.org/docs/pages/api-reference/components/image#fill
|
|
49
|
+
// The Fill option does not allow someone to pass in a width or a height
|
|
50
|
+
// If this is the case, we still need to define a width for sizing optimization but also
|
|
51
|
+
// for responsive sizing to take effect, so we can utilize the loader width for the base width
|
|
52
|
+
options.width = loaderOptions?.width;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
return getCldImageUrl(options, cldConfig);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { cloudinaryLoader as c, getCldImageUrl as g };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var urlLoader = require('@cloudinary-util/url-loader');
|
|
4
|
+
var cloudinary = require('./cloudinary-1cbbab64.cjs.js');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* getCldImageUrl
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
function getCldImageUrl(options, config, analytics) {
|
|
11
|
+
return urlLoader.constructCloudinaryUrl({
|
|
12
|
+
options,
|
|
13
|
+
config: cloudinary.getCloudinaryConfig(config),
|
|
14
|
+
analytics: cloudinary.getCloudinaryAnalytics(analytics)
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function cloudinaryLoader({
|
|
19
|
+
loaderOptions,
|
|
20
|
+
imageProps,
|
|
21
|
+
cldOptions,
|
|
22
|
+
cldConfig = {}
|
|
23
|
+
}) {
|
|
24
|
+
const options = {
|
|
25
|
+
...imageProps,
|
|
26
|
+
...cldOptions
|
|
27
|
+
};
|
|
28
|
+
options.width = typeof options.width === 'string' ? parseInt(options.width) : options.width;
|
|
29
|
+
options.height = typeof options.height === 'string' ? parseInt(options.height) : options.height;
|
|
30
|
+
|
|
31
|
+
// // The loader options are used to create dynamic sizing when working with responsive images
|
|
32
|
+
// // so these should override the default options collected from the props alone if
|
|
33
|
+
// // the results are different. While we don't always use the height in the loader logic,
|
|
34
|
+
// // we always pass it here, as the usage is determined later based on cropping.js
|
|
35
|
+
|
|
36
|
+
if (typeof loaderOptions?.width === 'number' && typeof options.width === 'number' && loaderOptions.width !== options.width) {
|
|
37
|
+
const multiplier = loaderOptions.width / options.width;
|
|
38
|
+
options.width = loaderOptions.width;
|
|
39
|
+
|
|
40
|
+
// The height may change based off of the value passed through via the loader options
|
|
41
|
+
// In an example where the user sizes is 800x600, but the loader is passing in 400
|
|
42
|
+
// due to responsive sizing, we want to ensure we're using a height that will
|
|
43
|
+
// resolve to the same aspect ratio
|
|
44
|
+
|
|
45
|
+
if (typeof options.height === 'number') {
|
|
46
|
+
options.height = Math.floor(options.height * multiplier);
|
|
47
|
+
}
|
|
48
|
+
} else if (typeof loaderOptions?.width === 'number' && typeof options?.width !== 'number') {
|
|
49
|
+
// If we don't have a width on the options object, this may mean that the component is using
|
|
50
|
+
// the fill option: https://nextjs.org/docs/pages/api-reference/components/image#fill
|
|
51
|
+
// The Fill option does not allow someone to pass in a width or a height
|
|
52
|
+
// If this is the case, we still need to define a width for sizing optimization but also
|
|
53
|
+
// for responsive sizing to take effect, so we can utilize the loader width for the base width
|
|
54
|
+
options.width = loaderOptions?.width;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
return getCldImageUrl(options, cldConfig);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
exports.cloudinaryLoader = cloudinaryLoader;
|
|
62
|
+
exports.getCldImageUrl = getCldImageUrl;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export * from "./declarations/src/index.js";
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmV4dC1jbG91ZGluYXJ5LmNqcy5kLm10cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4vZGVjbGFyYXRpb25zL3NyYy9pbmRleC5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export * from "./declarations/src/index";
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmV4dC1jbG91ZGluYXJ5LmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi9kZWNsYXJhdGlvbnMvc3JjL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var CldImage = require('./CldImage-68dff3e6.cjs.js');
|
|
6
|
+
var Head = require('next/head');
|
|
7
|
+
var cloudinaryLoader = require('./cloudinary-loader-80d421f0.cjs.js');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
var CldUploadButton = require('./CldUploadButton-db9b095b.cjs.js');
|
|
10
|
+
var CldUploadWidget = require('./CldUploadWidget-e39838cc.cjs.js');
|
|
11
|
+
var CldVideoPlayer = require('./CldVideoPlayer-49ac4380.cjs.js');
|
|
12
|
+
var urlLoader = require('@cloudinary-util/url-loader');
|
|
13
|
+
var cloudinary = require('./cloudinary-1cbbab64.cjs.js');
|
|
14
|
+
require('next/package.json');
|
|
15
|
+
|
|
16
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
17
|
+
|
|
18
|
+
var CldImage__default = /*#__PURE__*/_interopDefault(CldImage);
|
|
19
|
+
var Head__default = /*#__PURE__*/_interopDefault(Head);
|
|
20
|
+
var CldUploadButton__default = /*#__PURE__*/_interopDefault(CldUploadButton);
|
|
21
|
+
var CldUploadWidget__default = /*#__PURE__*/_interopDefault(CldUploadWidget);
|
|
22
|
+
var CldVideoPlayer__default = /*#__PURE__*/_interopDefault(CldVideoPlayer);
|
|
23
|
+
|
|
24
|
+
const OG_IMAGE_WIDTH = 1200;
|
|
25
|
+
const OG_IMAGE_HEIGHT = 627;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* getCldImageUrl
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
function getCldOgImageUrl(options) {
|
|
32
|
+
return cloudinaryLoader.getCldImageUrl({
|
|
33
|
+
...options,
|
|
34
|
+
format: options.format || 'jpg',
|
|
35
|
+
width: options.width || OG_IMAGE_WIDTH,
|
|
36
|
+
height: options.height || OG_IMAGE_HEIGHT,
|
|
37
|
+
crop: options.crop || {
|
|
38
|
+
type: 'fill',
|
|
39
|
+
gravity: 'center',
|
|
40
|
+
source: true
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const TWITTER_CARD = 'summary_large_image';
|
|
46
|
+
const CldOgImage = ({
|
|
47
|
+
excludeTags = [],
|
|
48
|
+
twitterTitle,
|
|
49
|
+
keys = {},
|
|
50
|
+
...props
|
|
51
|
+
}) => {
|
|
52
|
+
const {
|
|
53
|
+
alt
|
|
54
|
+
} = props;
|
|
55
|
+
|
|
56
|
+
// We need to separately handle the width and the height to allow our user to pass in
|
|
57
|
+
// a custom value, but also we need to know this at the component level so that we can
|
|
58
|
+
// use it when rendering the meta tags
|
|
59
|
+
|
|
60
|
+
let {
|
|
61
|
+
width = OG_IMAGE_WIDTH,
|
|
62
|
+
height = OG_IMAGE_HEIGHT
|
|
63
|
+
} = props;
|
|
64
|
+
|
|
65
|
+
// Normalize the width and height
|
|
66
|
+
|
|
67
|
+
width = typeof width === 'string' ? parseInt(width) : width;
|
|
68
|
+
height = typeof height === 'string' ? parseInt(height) : height;
|
|
69
|
+
|
|
70
|
+
// Render the final URLs. We use two different format versions to deliver
|
|
71
|
+
// webp for Twitter as it supports it (and we can control with tags) where
|
|
72
|
+
// other platforms may not support webp, so we deliver jpg
|
|
73
|
+
|
|
74
|
+
const ogImageUrl = getCldOgImageUrl({
|
|
75
|
+
...props,
|
|
76
|
+
width,
|
|
77
|
+
height
|
|
78
|
+
});
|
|
79
|
+
const twitterImageUrl = getCldOgImageUrl({
|
|
80
|
+
...props,
|
|
81
|
+
width,
|
|
82
|
+
height,
|
|
83
|
+
format: props.format || 'webp'
|
|
84
|
+
});
|
|
85
|
+
const metaKeys = {
|
|
86
|
+
'og:image': 'og-image',
|
|
87
|
+
'og:image:secure_url': 'og-image-secureurl',
|
|
88
|
+
'og:image:width': 'og-image-width',
|
|
89
|
+
'og:image:height': 'og-image-height',
|
|
90
|
+
'og:image:alt': 'og-image-alt',
|
|
91
|
+
'twitter:title': 'twitter-title',
|
|
92
|
+
'twitter:card': 'twitter-card',
|
|
93
|
+
'twitter:image': 'twitter-image',
|
|
94
|
+
...keys
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// We need to include the tags within the Next.js Head component rather than
|
|
98
|
+
// direcly adding them inside of the Head otherwise we get unexpected results
|
|
99
|
+
|
|
100
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Head__default["default"], {
|
|
101
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("meta", {
|
|
102
|
+
property: "og:image",
|
|
103
|
+
content: ogImageUrl
|
|
104
|
+
}, metaKeys['og:image']), /*#__PURE__*/jsxRuntime.jsx("meta", {
|
|
105
|
+
property: "og:image:secure_url",
|
|
106
|
+
content: ogImageUrl
|
|
107
|
+
}, metaKeys['og:image:secure_url']), /*#__PURE__*/jsxRuntime.jsx("meta", {
|
|
108
|
+
property: "og:image:width",
|
|
109
|
+
content: `${width}`
|
|
110
|
+
}, metaKeys['og:image:width']), /*#__PURE__*/jsxRuntime.jsx("meta", {
|
|
111
|
+
property: "og:image:height",
|
|
112
|
+
content: `${height}`
|
|
113
|
+
}, metaKeys['og:image:height']), alt && /*#__PURE__*/jsxRuntime.jsx("meta", {
|
|
114
|
+
property: "og:image:alt",
|
|
115
|
+
content: alt
|
|
116
|
+
}, metaKeys['og:image:alt']), !excludeTags.includes('twitter:title') && /*#__PURE__*/jsxRuntime.jsx("meta", {
|
|
117
|
+
property: "twitter:title",
|
|
118
|
+
content: twitterTitle || ' '
|
|
119
|
+
}, metaKeys['twitter:title']), /*#__PURE__*/jsxRuntime.jsx("meta", {
|
|
120
|
+
property: "twitter:card",
|
|
121
|
+
content: TWITTER_CARD
|
|
122
|
+
}, metaKeys['twitter:card']), /*#__PURE__*/jsxRuntime.jsx("meta", {
|
|
123
|
+
property: "twitter:image",
|
|
124
|
+
content: twitterImageUrl
|
|
125
|
+
}, metaKeys['twitter:image'])]
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* getCldVideoUrl
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
function getCldVideoUrl(options, config, analytics) {
|
|
134
|
+
return urlLoader.constructCloudinaryUrl({
|
|
135
|
+
options: {
|
|
136
|
+
assetType: 'video',
|
|
137
|
+
format: 'auto:video',
|
|
138
|
+
...options
|
|
139
|
+
},
|
|
140
|
+
config: cloudinary.getCloudinaryConfig(config),
|
|
141
|
+
analytics: cloudinary.getCloudinaryAnalytics(analytics)
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
Object.defineProperty(exports, 'CldImage', {
|
|
146
|
+
enumerable: true,
|
|
147
|
+
get: function () { return CldImage__default["default"]; }
|
|
148
|
+
});
|
|
149
|
+
exports.cloudinaryLoader = cloudinaryLoader.cloudinaryLoader;
|
|
150
|
+
exports.getCldImageUrl = cloudinaryLoader.getCldImageUrl;
|
|
151
|
+
Object.defineProperty(exports, 'CldUploadButton', {
|
|
152
|
+
enumerable: true,
|
|
153
|
+
get: function () { return CldUploadButton__default["default"]; }
|
|
154
|
+
});
|
|
155
|
+
Object.defineProperty(exports, 'CldUploadWidget', {
|
|
156
|
+
enumerable: true,
|
|
157
|
+
get: function () { return CldUploadWidget__default["default"]; }
|
|
158
|
+
});
|
|
159
|
+
Object.defineProperty(exports, 'CldVideoPlayer', {
|
|
160
|
+
enumerable: true,
|
|
161
|
+
get: function () { return CldVideoPlayer__default["default"]; }
|
|
162
|
+
});
|
|
163
|
+
exports.CldOgImage = CldOgImage;
|
|
164
|
+
exports.getCldOgImageUrl = getCldOgImageUrl;
|
|
165
|
+
exports.getCldVideoUrl = getCldVideoUrl;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
export { default as CldImage } from './CldImage-4b579fe8.esm.js';
|
|
2
|
+
import Head from 'next/head';
|
|
3
|
+
import { g as getCldImageUrl } from './cloudinary-loader-1863f0f4.esm.js';
|
|
4
|
+
export { c as cloudinaryLoader, g as getCldImageUrl } from './cloudinary-loader-1863f0f4.esm.js';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
export { default as CldUploadButton } from './CldUploadButton-196b419b.esm.js';
|
|
7
|
+
export { default as CldUploadWidget } from './CldUploadWidget-a9c04a78.esm.js';
|
|
8
|
+
export { default as CldVideoPlayer } from './CldVideoPlayer-7b1734a7.esm.js';
|
|
9
|
+
import { constructCloudinaryUrl } from '@cloudinary-util/url-loader';
|
|
10
|
+
import { g as getCloudinaryConfig, a as getCloudinaryAnalytics } from './cloudinary-9437f0ad.esm.js';
|
|
11
|
+
import 'next/package.json';
|
|
12
|
+
|
|
13
|
+
const OG_IMAGE_WIDTH = 1200;
|
|
14
|
+
const OG_IMAGE_HEIGHT = 627;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* getCldImageUrl
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function getCldOgImageUrl(options) {
|
|
21
|
+
return getCldImageUrl({
|
|
22
|
+
...options,
|
|
23
|
+
format: options.format || 'jpg',
|
|
24
|
+
width: options.width || OG_IMAGE_WIDTH,
|
|
25
|
+
height: options.height || OG_IMAGE_HEIGHT,
|
|
26
|
+
crop: options.crop || {
|
|
27
|
+
type: 'fill',
|
|
28
|
+
gravity: 'center',
|
|
29
|
+
source: true
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const TWITTER_CARD = 'summary_large_image';
|
|
35
|
+
const CldOgImage = ({
|
|
36
|
+
excludeTags = [],
|
|
37
|
+
twitterTitle,
|
|
38
|
+
keys = {},
|
|
39
|
+
...props
|
|
40
|
+
}) => {
|
|
41
|
+
const {
|
|
42
|
+
alt
|
|
43
|
+
} = props;
|
|
44
|
+
|
|
45
|
+
// We need to separately handle the width and the height to allow our user to pass in
|
|
46
|
+
// a custom value, but also we need to know this at the component level so that we can
|
|
47
|
+
// use it when rendering the meta tags
|
|
48
|
+
|
|
49
|
+
let {
|
|
50
|
+
width = OG_IMAGE_WIDTH,
|
|
51
|
+
height = OG_IMAGE_HEIGHT
|
|
52
|
+
} = props;
|
|
53
|
+
|
|
54
|
+
// Normalize the width and height
|
|
55
|
+
|
|
56
|
+
width = typeof width === 'string' ? parseInt(width) : width;
|
|
57
|
+
height = typeof height === 'string' ? parseInt(height) : height;
|
|
58
|
+
|
|
59
|
+
// Render the final URLs. We use two different format versions to deliver
|
|
60
|
+
// webp for Twitter as it supports it (and we can control with tags) where
|
|
61
|
+
// other platforms may not support webp, so we deliver jpg
|
|
62
|
+
|
|
63
|
+
const ogImageUrl = getCldOgImageUrl({
|
|
64
|
+
...props,
|
|
65
|
+
width,
|
|
66
|
+
height
|
|
67
|
+
});
|
|
68
|
+
const twitterImageUrl = getCldOgImageUrl({
|
|
69
|
+
...props,
|
|
70
|
+
width,
|
|
71
|
+
height,
|
|
72
|
+
format: props.format || 'webp'
|
|
73
|
+
});
|
|
74
|
+
const metaKeys = {
|
|
75
|
+
'og:image': 'og-image',
|
|
76
|
+
'og:image:secure_url': 'og-image-secureurl',
|
|
77
|
+
'og:image:width': 'og-image-width',
|
|
78
|
+
'og:image:height': 'og-image-height',
|
|
79
|
+
'og:image:alt': 'og-image-alt',
|
|
80
|
+
'twitter:title': 'twitter-title',
|
|
81
|
+
'twitter:card': 'twitter-card',
|
|
82
|
+
'twitter:image': 'twitter-image',
|
|
83
|
+
...keys
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// We need to include the tags within the Next.js Head component rather than
|
|
87
|
+
// direcly adding them inside of the Head otherwise we get unexpected results
|
|
88
|
+
|
|
89
|
+
return /*#__PURE__*/jsxs(Head, {
|
|
90
|
+
children: [/*#__PURE__*/jsx("meta", {
|
|
91
|
+
property: "og:image",
|
|
92
|
+
content: ogImageUrl
|
|
93
|
+
}, metaKeys['og:image']), /*#__PURE__*/jsx("meta", {
|
|
94
|
+
property: "og:image:secure_url",
|
|
95
|
+
content: ogImageUrl
|
|
96
|
+
}, metaKeys['og:image:secure_url']), /*#__PURE__*/jsx("meta", {
|
|
97
|
+
property: "og:image:width",
|
|
98
|
+
content: `${width}`
|
|
99
|
+
}, metaKeys['og:image:width']), /*#__PURE__*/jsx("meta", {
|
|
100
|
+
property: "og:image:height",
|
|
101
|
+
content: `${height}`
|
|
102
|
+
}, metaKeys['og:image:height']), alt && /*#__PURE__*/jsx("meta", {
|
|
103
|
+
property: "og:image:alt",
|
|
104
|
+
content: alt
|
|
105
|
+
}, metaKeys['og:image:alt']), !excludeTags.includes('twitter:title') && /*#__PURE__*/jsx("meta", {
|
|
106
|
+
property: "twitter:title",
|
|
107
|
+
content: twitterTitle || ' '
|
|
108
|
+
}, metaKeys['twitter:title']), /*#__PURE__*/jsx("meta", {
|
|
109
|
+
property: "twitter:card",
|
|
110
|
+
content: TWITTER_CARD
|
|
111
|
+
}, metaKeys['twitter:card']), /*#__PURE__*/jsx("meta", {
|
|
112
|
+
property: "twitter:image",
|
|
113
|
+
content: twitterImageUrl
|
|
114
|
+
}, metaKeys['twitter:image'])]
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* getCldVideoUrl
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
function getCldVideoUrl(options, config, analytics) {
|
|
123
|
+
return constructCloudinaryUrl({
|
|
124
|
+
options: {
|
|
125
|
+
assetType: 'video',
|
|
126
|
+
format: 'auto:video',
|
|
127
|
+
...options
|
|
128
|
+
},
|
|
129
|
+
config: getCloudinaryConfig(config),
|
|
130
|
+
analytics: getCloudinaryAnalytics(analytics)
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { CldOgImage, getCldOgImageUrl, getCldVideoUrl };
|
package/package.json
CHANGED
|
@@ -1,26 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-cloudinary",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-beta.1",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"main": "
|
|
6
|
-
"module": "
|
|
7
|
-
"
|
|
8
|
-
|
|
5
|
+
"main": "dist/next-cloudinary.cjs.js",
|
|
6
|
+
"module": "dist/next-cloudinary.esm.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": {
|
|
10
|
+
"import": "./dist/next-cloudinary.cjs.mjs",
|
|
11
|
+
"default": "./dist/next-cloudinary.cjs.js"
|
|
12
|
+
},
|
|
13
|
+
"module": "./dist/next-cloudinary.esm.js",
|
|
14
|
+
"import": "./dist/next-cloudinary.cjs.mjs",
|
|
15
|
+
"default": "./dist/next-cloudinary.cjs.js"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json",
|
|
18
|
+
"./cld-video-player.css": "./dist/cld-video-player.css",
|
|
19
|
+
"./dist/cld-video-player.css": "./dist/cld-video-player.css",
|
|
20
|
+
"./cloudinary_icon_for_black_bg.svg": "./dist/cloudinary_icon_for_black_bg.svg",
|
|
21
|
+
"./dist/cloudinary_icon_for_black_bg.svg": "./dist/cloudinary_icon_for_black_bg.svg",
|
|
22
|
+
"./cloudinary_icon_for_white_bg.svg": "./dist/cloudinary_icon_for_white_bg.svg",
|
|
23
|
+
"./dist/cloudinary_icon_for_white_bg.svg": "./dist/cloudinary_icon_for_white_bg.svg"
|
|
24
|
+
},
|
|
25
|
+
"types": "./dist/next-cloudinary.cjs.d.ts",
|
|
9
26
|
"dependencies": {
|
|
10
27
|
"@cloudinary-util/types": "1.5.8",
|
|
11
28
|
"@cloudinary-util/url-loader": "5.10.3",
|
|
12
|
-
"@cloudinary-util/util": "^3.3.2"
|
|
13
|
-
"@tsconfig/recommended": "^1.0.7"
|
|
29
|
+
"@cloudinary-util/util": "^3.3.2"
|
|
14
30
|
},
|
|
15
31
|
"devDependencies": {
|
|
16
32
|
"@babel/core": "^7.25.2",
|
|
17
|
-
"@babel/preset-env": "^7.25.
|
|
33
|
+
"@babel/preset-env": "^7.25.4",
|
|
34
|
+
"@babel/preset-react": "^7.24.7",
|
|
35
|
+
"@babel/preset-typescript": "^7.24.7",
|
|
36
|
+
"@tsconfig/recommended": "^1.0.7",
|
|
18
37
|
"@types/node": "^22.0.2",
|
|
19
38
|
"@types/react": "^18.3.3",
|
|
20
39
|
"@types/react-dom": "^18.3.0",
|
|
21
40
|
"dotenv": "^16.4.5",
|
|
22
41
|
"mkdirp": "^3.0.1",
|
|
23
|
-
"
|
|
42
|
+
"tsx": "^4.19.1",
|
|
24
43
|
"typescript": "^5.5.4",
|
|
25
44
|
"vitest": "^2.0.5"
|
|
26
45
|
},
|
|
@@ -28,11 +47,27 @@
|
|
|
28
47
|
"next": "^12 || ^13 || ^14 || >=15.0.0-rc",
|
|
29
48
|
"react": "^17 || ^18 || >=19.0.0-beta"
|
|
30
49
|
},
|
|
50
|
+
"preconstruct": {
|
|
51
|
+
"exports": {
|
|
52
|
+
"importConditionDefaultExport": "default",
|
|
53
|
+
"extra": {
|
|
54
|
+
"./cld-video-player.css": "./dist/cld-video-player.css",
|
|
55
|
+
"./dist/cld-video-player.css": "./dist/cld-video-player.css",
|
|
56
|
+
"./cloudinary_icon_for_black_bg.svg": "./dist/cloudinary_icon_for_black_bg.svg",
|
|
57
|
+
"./dist/cloudinary_icon_for_black_bg.svg": "./dist/cloudinary_icon_for_black_bg.svg",
|
|
58
|
+
"./cloudinary_icon_for_white_bg.svg": "./dist/cloudinary_icon_for_white_bg.svg",
|
|
59
|
+
"./dist/cloudinary_icon_for_white_bg.svg": "./dist/cloudinary_icon_for_white_bg.svg"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"___experimentalFlags_WILL_CHANGE_IN_PATCH": {
|
|
63
|
+
"importsConditions": true
|
|
64
|
+
}
|
|
65
|
+
},
|
|
31
66
|
"scripts": {
|
|
32
|
-
"build": "
|
|
33
|
-
"dev": "
|
|
67
|
+
"build": "preconstruct build && tsx scripts/copy-assets.ts",
|
|
68
|
+
"dev": "preconstruct watch",
|
|
34
69
|
"test": "vitest run",
|
|
35
|
-
"test:app": "NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME=\"test\" pnpm build && cd tests/nextjs-app &&
|
|
70
|
+
"test:app": "NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME=\"test\" pnpm build && cd tests/nextjs-app && pnpm build",
|
|
36
71
|
"test:watch": "vitest"
|
|
37
72
|
}
|
|
38
73
|
}
|