diff --git a/docs/pages/cldvideoplayer/basic-usage.mdx b/docs/pages/cldvideoplayer/basic-usage.mdx index 05f947d6..0ea8cd84 100644 --- a/docs/pages/cldvideoplayer/basic-usage.mdx +++ b/docs/pages/cldvideoplayer/basic-usage.mdx @@ -34,6 +34,12 @@ import { CldVideoPlayer } from 'next-cloudinary'; /> ``` +If you're using the Next.js 13 App Router, you must additionally import the Cloudinary Video Player stylesheet: + +```jsx +import 'next-cloudinary/dist/cld-video-player.css'; +``` + { + const rootPath = path.join(__dirname, '../'); + const distPath = path.join(rootPath, 'dist'); + + if ( hasWrittenAssets ) return; + + await mkdirp(distPath); + + for ( const asset of assets ) { + + if ( typeof asset === 'string' ) { + const writePath = path.join(distPath, path.basename(asset)); + await downloadFile(asset, writePath); + console.log(`Wrote ${asset} to ${writePath}`); + } else if ( typeof asset.directory === 'string' ) { + await mkdirp(path.join(distPath, asset.directory)); + + for ( const dirAsset of asset.assets ) { + const writePath = path.join(distPath, asset.directory, path.basename(dirAsset)); + await downloadFile(dirAsset, writePath); + console.log(`Wrote ${dirAsset} to ${writePath}`); + } + } + } + + hasWrittenAssets = true; + } +} + +/** + * downloadFile + */ + +function downloadFile(assetUrl: string, writePath: string) { + return new Promise((resolve) => { + const file = createWriteStream(writePath); + https.get(assetUrl, function(response) { + response.pipe(file); + file.on('finish', () => { + file.close(); + resolve(); + }); + }); + }) +} \ No newline at end of file diff --git a/next-cloudinary/src/components/CldVideoPlayer/CldVideoPlayer.tsx b/next-cloudinary/src/components/CldVideoPlayer/CldVideoPlayer.tsx index e26883e7..1ba0f10c 100644 --- a/next-cloudinary/src/components/CldVideoPlayer/CldVideoPlayer.tsx +++ b/next-cloudinary/src/components/CldVideoPlayer/CldVideoPlayer.tsx @@ -32,7 +32,7 @@ const CldVideoPlayer = (props: CldVideoPlayerProps) => { onEnded, src, transformation, - version = '1.9.4', + version = '1.9.14', quality = 'auto', width, } = props as CldVideoPlayerProps; @@ -40,6 +40,10 @@ const CldVideoPlayer = (props: CldVideoPlayerProps) => { const playerTransformations = Array.isArray(transformation) ? transformation : [transformation]; let publicId = src; + if ( typeof props.version === 'string' ) { + console.warn('The version prop will no longer be supported in future versions due to the unreliability of coordinating assets'); + } + // If the publicId/src is a URL, attempt to parse it as a Cloudinary URL // to get the public ID alone diff --git a/next-cloudinary/tests/nextjs-app/app/page.tsx b/next-cloudinary/tests/nextjs-app/app/page.tsx index 11fd9283..fe4aaf88 100644 --- a/next-cloudinary/tests/nextjs-app/app/page.tsx +++ b/next-cloudinary/tests/nextjs-app/app/page.tsx @@ -1,6 +1,8 @@ "use client"; -import { CldImage, CldUploadWidget } from '../../../'; +import { CldImage, CldUploadWidget, CldVideoPlayer } from '../../../'; + +import '../../../dist/cld-video-player.css'; export default function Home() { return ( @@ -12,6 +14,12 @@ export default function Home() { sources: ['local', 'camera'] }} /> + ) } diff --git a/next-cloudinary/tsup.config.ts b/next-cloudinary/tsup.config.ts index 30a601d5..fb146cb8 100644 --- a/next-cloudinary/tsup.config.ts +++ b/next-cloudinary/tsup.config.ts @@ -1,4 +1,5 @@ import { defineConfig } from 'tsup' +import { plugin as CopyAssetsPlugin } from './plugins/copy-assets'; export default defineConfig({ minify: true, @@ -6,5 +7,6 @@ export default defineConfig({ external: ['react'], sourcemap: true, dts: true, - format: ['esm', 'cjs'] + format: ['esm', 'cjs'], + esbuildPlugins: [CopyAssetsPlugin] }) \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index b34a8273..b5ca226a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4990,6 +4990,11 @@ minimatch@^3.0.4, minimatch@^3.1.1: dependencies: brace-expansion "^1.1.7" +mkdirp@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-3.0.1.tgz#e44e4c5607fb279c168241713cc6e0fea9adcb50" + integrity sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg== + mri@^1.1.0: version "1.2.0" resolved "https://registry.yarnpkg.com/mri/-/mri-1.2.0.tgz#6721480fec2a11a4889861115a48b6cbe7cc8f0b"