next-cloudinary 6.16.0 → 7.0.0-beta.10

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.
Files changed (62) hide show
  1. package/dist/CldImage-841d87c1.cjs.js +121 -0
  2. package/dist/CldImage-c9af4fd9.esm.js +113 -0
  3. package/dist/CldUploadButton-196b419b.esm.js +101 -0
  4. package/dist/CldUploadButton-db9b095b.cjs.js +109 -0
  5. package/dist/CldUploadWidget-77f44ab3.esm.js +207 -0
  6. package/dist/CldUploadWidget-cdb65b22.cjs.js +215 -0
  7. package/dist/CldVideoPlayer-4db49132.esm.js +140 -0
  8. package/dist/CldVideoPlayer-a6525186.cjs.js +149 -0
  9. package/dist/cloudinary-1f1b51af.cjs.js +141 -0
  10. package/dist/cloudinary-cb3c790a.esm.js +134 -0
  11. package/dist/cloudinary-loader-ad7ad702.esm.js +57 -0
  12. package/dist/cloudinary-loader-c87ac9ae.cjs.js +60 -0
  13. package/dist/declarations/src/components/CldImage/CldImage.d.ts +14 -0
  14. package/dist/declarations/src/components/CldImage/CldImage.d.ts.map +1 -0
  15. package/dist/declarations/src/components/CldImage/index.d.ts +3 -0
  16. package/dist/declarations/src/components/CldImage/index.d.ts.map +1 -0
  17. package/dist/declarations/src/components/CldOgImage/CldOgImage.d.ts +9 -0
  18. package/dist/declarations/src/components/CldOgImage/CldOgImage.d.ts.map +1 -0
  19. package/dist/declarations/src/components/CldOgImage/index.d.ts +3 -0
  20. package/dist/declarations/src/components/CldOgImage/index.d.ts.map +1 -0
  21. package/dist/declarations/src/components/CldUploadButton/CldUploadButton.d.ts +9 -0
  22. package/dist/declarations/src/components/CldUploadButton/CldUploadButton.d.ts.map +1 -0
  23. package/dist/declarations/src/components/CldUploadButton/index.d.ts +3 -0
  24. package/dist/declarations/src/components/CldUploadButton/index.d.ts.map +1 -0
  25. package/dist/declarations/src/components/CldUploadWidget/CldUploadWidget.d.ts +4 -0
  26. package/dist/declarations/src/components/CldUploadWidget/CldUploadWidget.d.ts.map +1 -0
  27. package/dist/declarations/src/components/CldUploadWidget/CldUploadWidget.types.d.ts +59 -0
  28. package/dist/declarations/src/components/CldUploadWidget/CldUploadWidget.types.d.ts.map +1 -0
  29. package/dist/declarations/src/components/CldUploadWidget/index.d.ts +3 -0
  30. package/dist/declarations/src/components/CldUploadWidget/index.d.ts.map +1 -0
  31. package/dist/declarations/src/components/CldVideoPlayer/CldVideoPlayer.d.ts +4 -0
  32. package/dist/declarations/src/components/CldVideoPlayer/CldVideoPlayer.d.ts.map +1 -0
  33. package/dist/declarations/src/components/CldVideoPlayer/CldVideoPlayer.types.d.ts +28 -0
  34. package/dist/declarations/src/components/CldVideoPlayer/CldVideoPlayer.types.d.ts.map +1 -0
  35. package/dist/declarations/src/components/CldVideoPlayer/index.d.ts +3 -0
  36. package/dist/declarations/src/components/CldVideoPlayer/index.d.ts.map +1 -0
  37. package/dist/declarations/src/helpers/getCldImageUrl.d.ts +9 -0
  38. package/dist/declarations/src/helpers/getCldImageUrl.d.ts.map +1 -0
  39. package/dist/declarations/src/helpers/getCldOgImageUrl.d.ts +7 -0
  40. package/dist/declarations/src/helpers/getCldOgImageUrl.d.ts.map +1 -0
  41. package/dist/declarations/src/helpers/getCldVideoUrl.d.ts +9 -0
  42. package/dist/declarations/src/helpers/getCldVideoUrl.d.ts.map +1 -0
  43. package/dist/declarations/src/index.d.ts +21 -0
  44. package/dist/declarations/src/index.d.ts.map +1 -0
  45. package/dist/declarations/src/loaders/cloudinary-loader.d.ts +16 -0
  46. package/dist/declarations/src/loaders/cloudinary-loader.d.ts.map +1 -0
  47. package/dist/fonts/cloudinary_icon_for_white_bg.svg +1 -1
  48. package/dist/next-cloudinary.cjs.d.mts +2 -0
  49. package/dist/next-cloudinary.cjs.d.ts +2 -0
  50. package/dist/next-cloudinary.cjs.js +165 -0
  51. package/dist/next-cloudinary.cjs.mjs +11 -0
  52. package/dist/next-cloudinary.esm.js +134 -0
  53. package/package.json +51 -13
  54. package/dist/index.d.mts +0 -152
  55. package/dist/index.d.ts +0 -152
  56. package/dist/index.js +0 -4
  57. package/dist/index.js.map +0 -1
  58. package/dist/index.mjs +0 -4
  59. package/dist/index.mjs.map +0 -1
  60. package/plugins/copy-assets.ts +0 -80
  61. package/tsconfig.json +0 -23
  62. package/tsup.config.ts +0 -18
@@ -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-1f1b51af.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_ENV === '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,140 @@
1
+ 'use client';
2
+ import { useId, 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-cb3c790a.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 uniqueId = useId();
27
+ const cloudinaryConfig = getCloudinaryConfig(config);
28
+ const playerOptions = getVideoPlayerOptions(props, cloudinaryConfig);
29
+ const {
30
+ publicId
31
+ } = playerOptions;
32
+ if (typeof publicId === 'undefined') {
33
+ throw new Error('Video Player requires a Public ID or Cloudinary URL - please specify a src prop');
34
+ }
35
+
36
+ // Setup the refs and allow for the caller to pass through their
37
+ // own ref instance
38
+
39
+ const cloudinaryRef = useRef();
40
+ const defaultVideoRef = useRef();
41
+ const videoRef = props.videoRef || defaultVideoRef;
42
+ const defaultPlayerRef = useRef();
43
+ const playerRef = props.playerRef || defaultPlayerRef;
44
+ const playerId = id || `player-${uniqueId.replace(/:/g, '')}`;
45
+ let playerClassName = 'cld-video-player cld-fluid';
46
+ if (className) {
47
+ playerClassName = `${playerClassName} ${className}`;
48
+ }
49
+
50
+ // Check if the same id is being used for multiple video instances.
51
+ const checkForMultipleInstance = playerInstances.filter(id => id === playerId).length > 1;
52
+ if (checkForMultipleInstance) {
53
+ console.warn(`Multiple instances of the same video detected on the
54
+ page which may cause some features to not work.
55
+ Try adding a unique id to each player.`);
56
+ } else {
57
+ playerInstances.push(playerId);
58
+ }
59
+ const events = {
60
+ error: onError,
61
+ loadeddata: onDataLoad,
62
+ loadedmetadata: onMetadataLoad,
63
+ pause: onPause,
64
+ play: onPlay,
65
+ ended: onEnded
66
+ };
67
+
68
+ /**
69
+ * handleEvent
70
+ * @description Event handler for all player events
71
+ */
72
+
73
+ function handleEvent(event) {
74
+ const activeEvent = events[event.type];
75
+ if (typeof activeEvent === 'function') {
76
+ activeEvent(getPlayerRefs());
77
+ }
78
+ }
79
+
80
+ /**
81
+ * handleOnLoad
82
+ * @description Stores the Cloudinary window instance to a ref when the widget script loads
83
+ */
84
+
85
+ function handleOnLoad() {
86
+ if ('cloudinary' in window) {
87
+ cloudinaryRef.current = window.cloudinary;
88
+ playerRef.current = cloudinaryRef.current.videoPlayer(videoRef.current, playerOptions);
89
+ Object.keys(events).forEach(key => {
90
+ if (typeof events[key] === 'function') {
91
+ playerRef.current?.on(key, handleEvent);
92
+ }
93
+ });
94
+ }
95
+ }
96
+ useEffect(() => {
97
+ return () => {
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}`,
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,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-1f1b51af.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 uniqueId = react.useId();
36
+ const cloudinaryConfig = cloudinary.getCloudinaryConfig(config);
37
+ const playerOptions = urlLoader.getVideoPlayerOptions(props, cloudinaryConfig);
38
+ const {
39
+ publicId
40
+ } = playerOptions;
41
+ if (typeof publicId === 'undefined') {
42
+ throw new Error('Video Player requires a Public ID or Cloudinary URL - please specify a src prop');
43
+ }
44
+
45
+ // Setup the refs and allow for the caller to pass through their
46
+ // own ref instance
47
+
48
+ const cloudinaryRef = react.useRef();
49
+ const defaultVideoRef = react.useRef();
50
+ const videoRef = props.videoRef || defaultVideoRef;
51
+ const defaultPlayerRef = react.useRef();
52
+ const playerRef = props.playerRef || defaultPlayerRef;
53
+ const playerId = id || `player-${uniqueId.replace(/:/g, '')}`;
54
+ let playerClassName = 'cld-video-player cld-fluid';
55
+ if (className) {
56
+ playerClassName = `${playerClassName} ${className}`;
57
+ }
58
+
59
+ // Check if the same id is being used for multiple video instances.
60
+ const checkForMultipleInstance = playerInstances.filter(id => id === playerId).length > 1;
61
+ if (checkForMultipleInstance) {
62
+ console.warn(`Multiple instances of the same video detected on the
63
+ page which may cause some features to not work.
64
+ Try adding a unique id to each player.`);
65
+ } else {
66
+ playerInstances.push(playerId);
67
+ }
68
+ const events = {
69
+ error: onError,
70
+ loadeddata: onDataLoad,
71
+ loadedmetadata: onMetadataLoad,
72
+ pause: onPause,
73
+ play: onPlay,
74
+ ended: onEnded
75
+ };
76
+
77
+ /**
78
+ * handleEvent
79
+ * @description Event handler for all player events
80
+ */
81
+
82
+ function handleEvent(event) {
83
+ const activeEvent = events[event.type];
84
+ if (typeof activeEvent === 'function') {
85
+ activeEvent(getPlayerRefs());
86
+ }
87
+ }
88
+
89
+ /**
90
+ * handleOnLoad
91
+ * @description Stores the Cloudinary window instance to a ref when the widget script loads
92
+ */
93
+
94
+ function handleOnLoad() {
95
+ if ('cloudinary' in window) {
96
+ cloudinaryRef.current = window.cloudinary;
97
+ playerRef.current = cloudinaryRef.current.videoPlayer(videoRef.current, playerOptions);
98
+ Object.keys(events).forEach(key => {
99
+ if (typeof events[key] === 'function') {
100
+ playerRef.current?.on(key, handleEvent);
101
+ }
102
+ });
103
+ }
104
+ }
105
+ react.useEffect(() => {
106
+ return () => {
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}`,
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,141 @@
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.10",
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
+ files: [
35
+ "dist"
36
+ ],
37
+ scripts: {
38
+ build: "preconstruct build && tsx scripts/copy-assets.ts",
39
+ dev: "preconstruct watch",
40
+ prepublishOnly: "cp ../README.md . && cp ../LICENSE . && pnpm build",
41
+ postpublish: "rm ./README.md && rm ./LICENSE",
42
+ test: "vitest run",
43
+ "test:app": "NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME=\"test\" pnpm build && cd tests/nextjs-app && pnpm build",
44
+ "test:watch": "vitest"
45
+ },
46
+ dependencies: {
47
+ "@cloudinary-util/types": "1.6.0",
48
+ "@cloudinary-util/url-loader": "6.0.0",
49
+ "@cloudinary-util/util": "4.1.0"
50
+ },
51
+ devDependencies: {
52
+ "@babel/core": "^7.25.2",
53
+ "@babel/preset-env": "^7.25.4",
54
+ "@babel/preset-react": "^7.24.7",
55
+ "@babel/preset-typescript": "^7.24.7",
56
+ "@tsconfig/recommended": "^1.0.7",
57
+ "@types/node": "^22.0.2",
58
+ "@types/react": "^18.3.3",
59
+ "@types/react-dom": "^18.3.0",
60
+ dotenv: "^16.4.5",
61
+ mkdirp: "^3.0.1",
62
+ tsx: "^4.19.1",
63
+ typescript: "^5.5.4",
64
+ vitest: "^2.0.5"
65
+ },
66
+ peerDependencies: {
67
+ next: "^12 || ^13 || ^14 || >=15.0.0-rc || ^15",
68
+ react: "^17 || ^18 || >=19.0.0-beta || ^19"
69
+ },
70
+ preconstruct: {
71
+ exports: {
72
+ importConditionDefaultExport: "default",
73
+ extra: {
74
+ "./cld-video-player.css": "./dist/cld-video-player.css",
75
+ "./dist/cld-video-player.css": "./dist/cld-video-player.css",
76
+ "./cloudinary_icon_for_black_bg.svg": "./dist/cloudinary_icon_for_black_bg.svg",
77
+ "./dist/cloudinary_icon_for_black_bg.svg": "./dist/cloudinary_icon_for_black_bg.svg",
78
+ "./cloudinary_icon_for_white_bg.svg": "./dist/cloudinary_icon_for_white_bg.svg",
79
+ "./dist/cloudinary_icon_for_white_bg.svg": "./dist/cloudinary_icon_for_white_bg.svg"
80
+ }
81
+ },
82
+ ___experimentalFlags_WILL_CHANGE_IN_PATCH: {
83
+ importsConditions: true
84
+ }
85
+ }
86
+ };
87
+
88
+ const NEXT_CLOUDINARY_ANALYTICS_PRODUCT_ID = 'A';
89
+ const NEXT_CLOUDINARY_ANALYTICS_ID = 'V';
90
+ const NEXT_VERSION = normalizeVersion(nextPkg__default["default"].version);
91
+ const NEXT_CLOUDINARY_VERSION = normalizeVersion(pkg.version);
92
+ function normalizeVersion(version) {
93
+ let normalized = version;
94
+ if (normalized.includes('-')) {
95
+ normalized = normalized.split('-')[0];
96
+ }
97
+ return normalized;
98
+ }
99
+
100
+ /**
101
+ * getCloudinaryConfig
102
+ */
103
+
104
+ function getCloudinaryConfig(config) {
105
+ const cloudName = config?.cloud?.cloudName ?? process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME;
106
+ if (!cloudName) {
107
+ throw new Error('A Cloudinary Cloud name is required, please make sure NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME is set and configured in your environment.');
108
+ }
109
+ const apiKey = config?.cloud?.apiKey ?? process.env.NEXT_PUBLIC_CLOUDINARY_API_KEY;
110
+ const secureDistribution = config?.url?.secureDistribution ?? process.env.NEXT_PUBLIC_CLOUDINARY_SECURE_DISTRIBUTION;
111
+ const privateCdn = config?.url?.privateCdn ?? process.env.NEXT_PUBLIC_CLOUDINARY_PRIVATE_CDN;
112
+ return Object.assign({
113
+ cloud: {
114
+ ...config?.cloud,
115
+ apiKey,
116
+ cloudName
117
+ },
118
+ url: {
119
+ ...config?.url,
120
+ secureDistribution,
121
+ privateCdn
122
+ }
123
+ }, config);
124
+ }
125
+
126
+ /**
127
+ * getCloudinaryAnalytics
128
+ */
129
+
130
+ function getCloudinaryAnalytics(analytics) {
131
+ return Object.assign({
132
+ product: NEXT_CLOUDINARY_ANALYTICS_PRODUCT_ID,
133
+ sdkCode: NEXT_CLOUDINARY_ANALYTICS_ID,
134
+ sdkSemver: NEXT_CLOUDINARY_VERSION,
135
+ techVersion: NEXT_VERSION,
136
+ feature: ''
137
+ }, analytics);
138
+ }
139
+
140
+ exports.getCloudinaryAnalytics = getCloudinaryAnalytics;
141
+ exports.getCloudinaryConfig = getCloudinaryConfig;