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.
@@ -0,0 +1,215 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var react = require('react');
7
+ var Script = require('next/script');
8
+ var urlLoader = require('@cloudinary-util/url-loader');
9
+ var cloudinary = require('./cloudinary-1cbbab64.cjs.js');
10
+ var jsxRuntime = require('react/jsx-runtime');
11
+ require('next/package.json');
12
+
13
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
14
+
15
+ var Script__default = /*#__PURE__*/_interopDefault(Script);
16
+
17
+ /**
18
+ * triggerOnIdle
19
+ * @see MDN Polyfill https://github.com/behnammodi/polyfill/blob/master/window.polyfill.js#L7-L24
20
+ */
21
+
22
+ function triggerOnIdle(callback) {
23
+ if (typeof window !== undefined && 'requestIdleCallback' in window) {
24
+ return requestIdleCallback(callback);
25
+ }
26
+ return setTimeout(() => callback(), 1);
27
+ }
28
+
29
+ const CldUploadWidget = ({
30
+ children,
31
+ config,
32
+ onError,
33
+ onOpen,
34
+ onUpload,
35
+ options,
36
+ signatureEndpoint,
37
+ uploadPreset,
38
+ ...props
39
+ }) => {
40
+ const cloudinary$1 = react.useRef();
41
+ const widget = react.useRef();
42
+ const [error, setError] = react.useState(undefined);
43
+ const [results, setResults] = react.useState(undefined);
44
+ const [isScriptLoading, setIsScriptLoading] = react.useState(true);
45
+
46
+ // When creating a signed upload, you need to provide both your Cloudinary API Key
47
+ // as well as a signature generator function that will sign any paramters
48
+ // either on page load or during the upload process. Read more about signed uploads at:
49
+ // https://cloudinary.com/documentation/upload_widget#signed_uploads
50
+
51
+ const cloudinaryConfig = cloudinary.getCloudinaryConfig(config);
52
+ const uploadSignature = signatureEndpoint && urlLoader.generateSignatureCallback({
53
+ signatureEndpoint: String(signatureEndpoint),
54
+ fetch
55
+ });
56
+ const uploadOptions = urlLoader.getUploadWidgetOptions({
57
+ uploadPreset: uploadPreset || process.env.NEXT_PUBLIC_CLOUDINARY_UPLOAD_PRESET,
58
+ uploadSignature,
59
+ ...options
60
+ }, cloudinaryConfig);
61
+ const resultsCallback = urlLoader.generateUploadWidgetResultCallback({
62
+ onError: uploadError => {
63
+ setError(uploadError);
64
+ if (typeof onError === 'function') {
65
+ onError(uploadError, {
66
+ widget: widget.current,
67
+ ...instanceMethods
68
+ });
69
+ }
70
+ },
71
+ onResult: uploadResult => {
72
+ if (typeof uploadResult?.event !== 'string') return;
73
+ setResults(uploadResult);
74
+ const widgetEvent = urlLoader.UPLOAD_WIDGET_EVENTS[uploadResult.event];
75
+ if (typeof widgetEvent === 'string' && typeof props[widgetEvent] === 'function') {
76
+ const callback = props[widgetEvent];
77
+ callback(uploadResult, {
78
+ widget: widget.current,
79
+ ...instanceMethods
80
+ });
81
+ }
82
+ const widgetEventAction = `${widgetEvent}Action`;
83
+ if (widgetEventAction && typeof props[widgetEventAction] === 'function') {
84
+ const action = props[widgetEventAction];
85
+ action(uploadResult);
86
+ }
87
+ }
88
+ });
89
+
90
+ // Handle result states and callbacks
91
+
92
+ react.useEffect(() => {
93
+ if (typeof results === 'undefined') return;
94
+ const isSuccess = results.event === 'success';
95
+ if (isSuccess && typeof onUpload === 'function') {
96
+ if (process.env.NODE_ENVIRONMENT === 'development') {
97
+ console.warn('The onUpload callback is deprecated. Please use onSuccess instead.');
98
+ }
99
+ onUpload(results, widget.current);
100
+ }
101
+ }, [results]);
102
+
103
+ /**
104
+ * handleOnLoad
105
+ * @description Stores the Cloudinary window instance to a ref when the widget script loads
106
+ */
107
+
108
+ function handleOnLoad() {
109
+ setIsScriptLoading(false);
110
+ if (!cloudinary$1.current) {
111
+ cloudinary$1.current = window.cloudinary;
112
+ }
113
+
114
+ // To help improve load time of the widget on first instance, use requestIdleCallback
115
+ // to trigger widget creation. Optional.
116
+
117
+ triggerOnIdle(() => {
118
+ if (!widget.current) {
119
+ widget.current = createWidget();
120
+ }
121
+ });
122
+ }
123
+ react.useEffect(() => {
124
+ return () => {
125
+ widget.current?.destroy();
126
+ widget.current = undefined;
127
+ };
128
+ }, []);
129
+
130
+ /**
131
+ * Instance Methods
132
+ * Gives the ability to interface directly with the Upload Widget instance methods like open and close
133
+ * https://cloudinary.com/documentation/upload_widget_reference#instance_methods
134
+ */
135
+
136
+ function invokeInstanceMethod(method, options = []) {
137
+ if (!widget.current) {
138
+ widget.current = createWidget();
139
+ }
140
+ if (typeof widget?.current[method] === "function") {
141
+ return widget.current[method](...options);
142
+ }
143
+ }
144
+ function close(options) {
145
+ invokeInstanceMethod('close', [options]);
146
+ }
147
+ function destroy(options) {
148
+ return invokeInstanceMethod('destroy', [options]);
149
+ }
150
+ function hide() {
151
+ invokeInstanceMethod('hide');
152
+ }
153
+ function isDestroyed() {
154
+ return invokeInstanceMethod('isDestroyed');
155
+ }
156
+ function isMinimized() {
157
+ return invokeInstanceMethod('isMinimized');
158
+ }
159
+ function isShowing() {
160
+ return invokeInstanceMethod('isShowing');
161
+ }
162
+ function minimize() {
163
+ invokeInstanceMethod('minimize');
164
+ }
165
+ function open(widgetSource, options) {
166
+ invokeInstanceMethod('open', [widgetSource, options]);
167
+ if (typeof onOpen === 'function') {
168
+ onOpen(widget.current);
169
+ }
170
+ }
171
+ function show() {
172
+ invokeInstanceMethod('show');
173
+ }
174
+ function update() {
175
+ invokeInstanceMethod('update');
176
+ }
177
+ const instanceMethods = {
178
+ close,
179
+ destroy,
180
+ hide,
181
+ isDestroyed,
182
+ isMinimized,
183
+ isShowing,
184
+ minimize,
185
+ open,
186
+ show,
187
+ update
188
+ };
189
+
190
+ /**
191
+ * createWidget
192
+ * @description Creates a new instance of the Cloudinary widget and stores in a ref
193
+ */
194
+
195
+ function createWidget() {
196
+ return cloudinary$1.current?.createUploadWidget(uploadOptions, resultsCallback);
197
+ }
198
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
199
+ children: [typeof children === 'function' && children({
200
+ cloudinary: cloudinary$1.current,
201
+ widget: widget.current,
202
+ results,
203
+ error,
204
+ isLoading: isScriptLoading,
205
+ ...instanceMethods
206
+ }), /*#__PURE__*/jsxRuntime.jsx(Script__default["default"], {
207
+ id: `cloudinary-uploadwidget-${Math.floor(Math.random() * 100)}`,
208
+ src: "https://upload-widget.cloudinary.com/global/all.js",
209
+ onLoad: handleOnLoad,
210
+ onError: e => console.error(`Failed to load Cloudinary Upload Widget: ${e.message}`)
211
+ })]
212
+ });
213
+ };
214
+
215
+ exports["default"] = CldUploadWidget;
@@ -0,0 +1,149 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var react = require('react');
7
+ var Script = require('next/script');
8
+ var Head = require('next/head');
9
+ var urlLoader = require('@cloudinary-util/url-loader');
10
+ var cloudinary = require('./cloudinary-1cbbab64.cjs.js');
11
+ var jsxRuntime = require('react/jsx-runtime');
12
+ require('next/package.json');
13
+
14
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
15
+
16
+ var Script__default = /*#__PURE__*/_interopDefault(Script);
17
+ var Head__default = /*#__PURE__*/_interopDefault(Head);
18
+
19
+ let playerInstances = [];
20
+ const PLAYER_VERSION = '1.11.1';
21
+ const CldVideoPlayer = props => {
22
+ const {
23
+ className,
24
+ config,
25
+ height,
26
+ id,
27
+ onDataLoad,
28
+ onError,
29
+ onMetadataLoad,
30
+ onPause,
31
+ onPlay,
32
+ onEnded,
33
+ width
34
+ } = props;
35
+ const cloudinaryConfig = cloudinary.getCloudinaryConfig(config);
36
+ const playerOptions = urlLoader.getVideoPlayerOptions(props, cloudinaryConfig);
37
+ const {
38
+ publicId
39
+ } = playerOptions;
40
+ if (typeof publicId === 'undefined') {
41
+ throw new Error('Video Player requires a Public ID or Cloudinary URL - please specify a src prop');
42
+ }
43
+
44
+ // Setup the refs and allow for the caller to pass through their
45
+ // own ref instance
46
+
47
+ const cloudinaryRef = react.useRef();
48
+ const defaultVideoRef = react.useRef();
49
+ const videoRef = props.videoRef || defaultVideoRef;
50
+ const defaultPlayerRef = react.useRef();
51
+ const playerRef = props.playerRef || defaultPlayerRef;
52
+ const playerId = id || `player-${publicId.replace('/', '-')}`;
53
+ let playerClassName = 'cld-video-player cld-fluid';
54
+ if (className) {
55
+ playerClassName = `${playerClassName} ${className}`;
56
+ }
57
+
58
+ // Check if the same id is being used for multiple video instances.
59
+ const checkForMultipleInstance = playerInstances.filter(id => id === playerId).length > 1;
60
+ if (checkForMultipleInstance) {
61
+ console.warn(`Multiple instances of the same video detected on the
62
+ page which may cause some features to not work.
63
+ Try adding a unique id to each player.`);
64
+ } else {
65
+ playerInstances.push(playerId);
66
+ }
67
+ const events = {
68
+ error: onError,
69
+ loadeddata: onDataLoad,
70
+ loadedmetadata: onMetadataLoad,
71
+ pause: onPause,
72
+ play: onPlay,
73
+ ended: onEnded
74
+ };
75
+
76
+ /**
77
+ * handleEvent
78
+ * @description Event handler for all player events
79
+ */
80
+
81
+ function handleEvent(event) {
82
+ const activeEvent = events[event.type];
83
+ if (typeof activeEvent === 'function') {
84
+ activeEvent(getPlayerRefs());
85
+ }
86
+ }
87
+
88
+ /**
89
+ * handleOnLoad
90
+ * @description Stores the Cloudinary window instance to a ref when the widget script loads
91
+ */
92
+
93
+ function handleOnLoad() {
94
+ if ('cloudinary' in window) {
95
+ cloudinaryRef.current = window.cloudinary;
96
+ playerRef.current = cloudinaryRef.current.videoPlayer(videoRef.current, playerOptions);
97
+ Object.keys(events).forEach(key => {
98
+ if (typeof events[key] === 'function') {
99
+ playerRef.current?.on(key, handleEvent);
100
+ }
101
+ });
102
+ }
103
+ }
104
+ react.useEffect(() => {
105
+ return () => {
106
+ //@ts-ignore
107
+ playerRef.current?.videojs.cloudinary.dispose();
108
+ playerInstances = playerInstances.filter(id => id !== playerId);
109
+ };
110
+ }, []);
111
+
112
+ /**
113
+ *getPlayerRefs
114
+ */
115
+
116
+ function getPlayerRefs() {
117
+ return {
118
+ player: playerRef.current,
119
+ video: videoRef.current
120
+ };
121
+ }
122
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
123
+ children: [/*#__PURE__*/jsxRuntime.jsx(Head__default["default"], {
124
+ children: /*#__PURE__*/jsxRuntime.jsx("link", {
125
+ href: `https://unpkg.com/cloudinary-video-player@${PLAYER_VERSION}/dist/cld-video-player.min.css`,
126
+ rel: "stylesheet"
127
+ })
128
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
129
+ style: {
130
+ width: '100%',
131
+ aspectRatio: `${width} / ${height}`
132
+ },
133
+ children: [/*#__PURE__*/jsxRuntime.jsx("video", {
134
+ ref: videoRef,
135
+ id: playerId,
136
+ className: playerClassName,
137
+ width: width,
138
+ height: height
139
+ }), /*#__PURE__*/jsxRuntime.jsx(Script__default["default"], {
140
+ id: `cloudinary-videoplayer-${playerId}-${Math.floor(Math.random() * 100)}`,
141
+ src: `https://unpkg.com/cloudinary-video-player@${PLAYER_VERSION}/dist/cld-video-player.min.js`,
142
+ onLoad: handleOnLoad,
143
+ onError: e => console.error(`Failed to load Cloudinary Video Player: ${e.message}`)
144
+ })]
145
+ })]
146
+ });
147
+ };
148
+
149
+ exports["default"] = CldVideoPlayer;
@@ -0,0 +1,140 @@
1
+ 'use client';
2
+ import { useRef, useEffect } from 'react';
3
+ import Script from 'next/script';
4
+ import Head from 'next/head';
5
+ import { getVideoPlayerOptions } from '@cloudinary-util/url-loader';
6
+ import { g as getCloudinaryConfig } from './cloudinary-9437f0ad.esm.js';
7
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
8
+ import 'next/package.json';
9
+
10
+ let playerInstances = [];
11
+ const PLAYER_VERSION = '1.11.1';
12
+ const CldVideoPlayer = props => {
13
+ const {
14
+ className,
15
+ config,
16
+ height,
17
+ id,
18
+ onDataLoad,
19
+ onError,
20
+ onMetadataLoad,
21
+ onPause,
22
+ onPlay,
23
+ onEnded,
24
+ width
25
+ } = props;
26
+ const cloudinaryConfig = getCloudinaryConfig(config);
27
+ const playerOptions = getVideoPlayerOptions(props, cloudinaryConfig);
28
+ const {
29
+ publicId
30
+ } = playerOptions;
31
+ if (typeof publicId === 'undefined') {
32
+ throw new Error('Video Player requires a Public ID or Cloudinary URL - please specify a src prop');
33
+ }
34
+
35
+ // Setup the refs and allow for the caller to pass through their
36
+ // own ref instance
37
+
38
+ const cloudinaryRef = useRef();
39
+ const defaultVideoRef = useRef();
40
+ const videoRef = props.videoRef || defaultVideoRef;
41
+ const defaultPlayerRef = useRef();
42
+ const playerRef = props.playerRef || defaultPlayerRef;
43
+ const playerId = id || `player-${publicId.replace('/', '-')}`;
44
+ let playerClassName = 'cld-video-player cld-fluid';
45
+ if (className) {
46
+ playerClassName = `${playerClassName} ${className}`;
47
+ }
48
+
49
+ // Check if the same id is being used for multiple video instances.
50
+ const checkForMultipleInstance = playerInstances.filter(id => id === playerId).length > 1;
51
+ if (checkForMultipleInstance) {
52
+ console.warn(`Multiple instances of the same video detected on the
53
+ page which may cause some features to not work.
54
+ Try adding a unique id to each player.`);
55
+ } else {
56
+ playerInstances.push(playerId);
57
+ }
58
+ const events = {
59
+ error: onError,
60
+ loadeddata: onDataLoad,
61
+ loadedmetadata: onMetadataLoad,
62
+ pause: onPause,
63
+ play: onPlay,
64
+ ended: onEnded
65
+ };
66
+
67
+ /**
68
+ * handleEvent
69
+ * @description Event handler for all player events
70
+ */
71
+
72
+ function handleEvent(event) {
73
+ const activeEvent = events[event.type];
74
+ if (typeof activeEvent === 'function') {
75
+ activeEvent(getPlayerRefs());
76
+ }
77
+ }
78
+
79
+ /**
80
+ * handleOnLoad
81
+ * @description Stores the Cloudinary window instance to a ref when the widget script loads
82
+ */
83
+
84
+ function handleOnLoad() {
85
+ if ('cloudinary' in window) {
86
+ cloudinaryRef.current = window.cloudinary;
87
+ playerRef.current = cloudinaryRef.current.videoPlayer(videoRef.current, playerOptions);
88
+ Object.keys(events).forEach(key => {
89
+ if (typeof events[key] === 'function') {
90
+ playerRef.current?.on(key, handleEvent);
91
+ }
92
+ });
93
+ }
94
+ }
95
+ useEffect(() => {
96
+ return () => {
97
+ //@ts-ignore
98
+ playerRef.current?.videojs.cloudinary.dispose();
99
+ playerInstances = playerInstances.filter(id => id !== playerId);
100
+ };
101
+ }, []);
102
+
103
+ /**
104
+ *getPlayerRefs
105
+ */
106
+
107
+ function getPlayerRefs() {
108
+ return {
109
+ player: playerRef.current,
110
+ video: videoRef.current
111
+ };
112
+ }
113
+ return /*#__PURE__*/jsxs(Fragment, {
114
+ children: [/*#__PURE__*/jsx(Head, {
115
+ children: /*#__PURE__*/jsx("link", {
116
+ href: `https://unpkg.com/cloudinary-video-player@${PLAYER_VERSION}/dist/cld-video-player.min.css`,
117
+ rel: "stylesheet"
118
+ })
119
+ }), /*#__PURE__*/jsxs("div", {
120
+ style: {
121
+ width: '100%',
122
+ aspectRatio: `${width} / ${height}`
123
+ },
124
+ children: [/*#__PURE__*/jsx("video", {
125
+ ref: videoRef,
126
+ id: playerId,
127
+ className: playerClassName,
128
+ width: width,
129
+ height: height
130
+ }), /*#__PURE__*/jsx(Script, {
131
+ id: `cloudinary-videoplayer-${playerId}-${Math.floor(Math.random() * 100)}`,
132
+ src: `https://unpkg.com/cloudinary-video-player@${PLAYER_VERSION}/dist/cld-video-player.min.js`,
133
+ onLoad: handleOnLoad,
134
+ onError: e => console.error(`Failed to load Cloudinary Video Player: ${e.message}`)
135
+ })]
136
+ })]
137
+ });
138
+ };
139
+
140
+ export { CldVideoPlayer as default };
@@ -0,0 +1,138 @@
1
+ 'use strict';
2
+
3
+ var nextPkg = require('next/package.json');
4
+
5
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
6
+
7
+ var nextPkg__default = /*#__PURE__*/_interopDefault(nextPkg);
8
+
9
+ var pkg = {
10
+ name: "next-cloudinary",
11
+ version: "7.0.0-beta.1",
12
+ license: "MIT",
13
+ main: "dist/next-cloudinary.cjs.js",
14
+ module: "dist/next-cloudinary.esm.js",
15
+ exports: {
16
+ ".": {
17
+ types: {
18
+ "import": "./dist/next-cloudinary.cjs.mjs",
19
+ "default": "./dist/next-cloudinary.cjs.js"
20
+ },
21
+ module: "./dist/next-cloudinary.esm.js",
22
+ "import": "./dist/next-cloudinary.cjs.mjs",
23
+ "default": "./dist/next-cloudinary.cjs.js"
24
+ },
25
+ "./package.json": "./package.json",
26
+ "./cld-video-player.css": "./dist/cld-video-player.css",
27
+ "./dist/cld-video-player.css": "./dist/cld-video-player.css",
28
+ "./cloudinary_icon_for_black_bg.svg": "./dist/cloudinary_icon_for_black_bg.svg",
29
+ "./dist/cloudinary_icon_for_black_bg.svg": "./dist/cloudinary_icon_for_black_bg.svg",
30
+ "./cloudinary_icon_for_white_bg.svg": "./dist/cloudinary_icon_for_white_bg.svg",
31
+ "./dist/cloudinary_icon_for_white_bg.svg": "./dist/cloudinary_icon_for_white_bg.svg"
32
+ },
33
+ types: "./dist/next-cloudinary.cjs.d.ts",
34
+ scripts: {
35
+ build: "preconstruct build && tsx scripts/copy-assets.ts",
36
+ dev: "preconstruct watch",
37
+ prepublishOnly: "cp ../README.md . && cp ../LICENSE . && pnpm build",
38
+ postpublish: "rm ./README.md && rm ./LICENSE",
39
+ test: "vitest run",
40
+ "test:app": "NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME=\"test\" pnpm build && cd tests/nextjs-app && pnpm build",
41
+ "test:watch": "vitest"
42
+ },
43
+ dependencies: {
44
+ "@cloudinary-util/types": "1.5.8",
45
+ "@cloudinary-util/url-loader": "5.10.3",
46
+ "@cloudinary-util/util": "^3.3.2"
47
+ },
48
+ devDependencies: {
49
+ "@babel/core": "^7.25.2",
50
+ "@babel/preset-env": "^7.25.4",
51
+ "@babel/preset-react": "^7.24.7",
52
+ "@babel/preset-typescript": "^7.24.7",
53
+ "@tsconfig/recommended": "^1.0.7",
54
+ "@types/node": "^22.0.2",
55
+ "@types/react": "^18.3.3",
56
+ "@types/react-dom": "^18.3.0",
57
+ dotenv: "^16.4.5",
58
+ mkdirp: "^3.0.1",
59
+ tsx: "^4.19.1",
60
+ typescript: "^5.5.4",
61
+ vitest: "^2.0.5"
62
+ },
63
+ peerDependencies: {
64
+ next: "^12 || ^13 || ^14 || >=15.0.0-rc",
65
+ react: "^17 || ^18 || >=19.0.0-beta"
66
+ },
67
+ preconstruct: {
68
+ exports: {
69
+ importConditionDefaultExport: "default",
70
+ extra: {
71
+ "./cld-video-player.css": "./dist/cld-video-player.css",
72
+ "./dist/cld-video-player.css": "./dist/cld-video-player.css",
73
+ "./cloudinary_icon_for_black_bg.svg": "./dist/cloudinary_icon_for_black_bg.svg",
74
+ "./dist/cloudinary_icon_for_black_bg.svg": "./dist/cloudinary_icon_for_black_bg.svg",
75
+ "./cloudinary_icon_for_white_bg.svg": "./dist/cloudinary_icon_for_white_bg.svg",
76
+ "./dist/cloudinary_icon_for_white_bg.svg": "./dist/cloudinary_icon_for_white_bg.svg"
77
+ }
78
+ },
79
+ ___experimentalFlags_WILL_CHANGE_IN_PATCH: {
80
+ importsConditions: true
81
+ }
82
+ }
83
+ };
84
+
85
+ const NEXT_CLOUDINARY_ANALYTICS_PRODUCT_ID = 'A';
86
+ const NEXT_CLOUDINARY_ANALYTICS_ID = 'V';
87
+ const NEXT_VERSION = normalizeVersion(nextPkg__default["default"].version);
88
+ const NEXT_CLOUDINARY_VERSION = normalizeVersion(pkg.version);
89
+ function normalizeVersion(version) {
90
+ let normalized = version;
91
+ if (normalized.includes('-')) {
92
+ normalized = normalized.split('-')[0];
93
+ }
94
+ return normalized;
95
+ }
96
+
97
+ /**
98
+ * getCloudinaryConfig
99
+ */
100
+
101
+ function getCloudinaryConfig(config) {
102
+ const cloudName = config?.cloud?.cloudName ?? process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME;
103
+ if (!cloudName) {
104
+ throw new Error('A Cloudinary Cloud name is required, please make sure NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME is set and configured in your environment.');
105
+ }
106
+ const apiKey = config?.cloud?.apiKey ?? process.env.NEXT_PUBLIC_CLOUDINARY_API_KEY;
107
+ const secureDistribution = config?.url?.secureDistribution ?? process.env.NEXT_PUBLIC_CLOUDINARY_SECURE_DISTRIBUTION;
108
+ const privateCdn = config?.url?.privateCdn ?? process.env.NEXT_PUBLIC_CLOUDINARY_PRIVATE_CDN;
109
+ return Object.assign({
110
+ cloud: {
111
+ ...config?.cloud,
112
+ apiKey,
113
+ cloudName
114
+ },
115
+ url: {
116
+ ...config?.url,
117
+ secureDistribution,
118
+ privateCdn
119
+ }
120
+ }, config);
121
+ }
122
+
123
+ /**
124
+ * getCloudinaryAnalytics
125
+ */
126
+
127
+ function getCloudinaryAnalytics(analytics) {
128
+ return Object.assign({
129
+ product: NEXT_CLOUDINARY_ANALYTICS_PRODUCT_ID,
130
+ sdkCode: NEXT_CLOUDINARY_ANALYTICS_ID,
131
+ sdkSemver: NEXT_CLOUDINARY_VERSION,
132
+ techVersion: NEXT_VERSION,
133
+ feature: ''
134
+ }, analytics);
135
+ }
136
+
137
+ exports.getCloudinaryAnalytics = getCloudinaryAnalytics;
138
+ exports.getCloudinaryConfig = getCloudinaryConfig;