next-cloudinary 4.18.1 → 4.20.0
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/cld-video-player.css +2041 -0
- package/dist/fonts/cloudinary_icon_for_black_bg.svg +69 -0
- package/dist/fonts/cloudinary_icon_for_white_bg.svg +69 -0
- package/dist/index.d.mts +253 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
- package/plugins/copy-assets.ts +68 -0
- package/tsup.config.ts +3 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Plugin } from 'esbuild'
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { createWriteStream } from 'fs';
|
|
4
|
+
import { mkdirp } from 'mkdirp';
|
|
5
|
+
import https from 'https';
|
|
6
|
+
|
|
7
|
+
const version = '1.9.14';
|
|
8
|
+
|
|
9
|
+
const assets = [
|
|
10
|
+
`https://unpkg.com/cloudinary-video-player@${version}/dist/cld-video-player.css`,
|
|
11
|
+
{
|
|
12
|
+
directory: 'fonts',
|
|
13
|
+
assets: [
|
|
14
|
+
`https://unpkg.com/cloudinary-video-player@${version}/dist/fonts/cloudinary_icon_for_black_bg.svg`,
|
|
15
|
+
`https://unpkg.com/cloudinary-video-player@${version}/dist/fonts/cloudinary_icon_for_white_bg.svg`,
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
let hasWrittenAssets = false;
|
|
21
|
+
|
|
22
|
+
export const plugin: Plugin = {
|
|
23
|
+
name: 'copy-assets',
|
|
24
|
+
setup: async () => {
|
|
25
|
+
const rootPath = path.join(__dirname, '../');
|
|
26
|
+
const distPath = path.join(rootPath, 'dist');
|
|
27
|
+
|
|
28
|
+
if ( hasWrittenAssets ) return;
|
|
29
|
+
|
|
30
|
+
await mkdirp(distPath);
|
|
31
|
+
|
|
32
|
+
for ( const asset of assets ) {
|
|
33
|
+
|
|
34
|
+
if ( typeof asset === 'string' ) {
|
|
35
|
+
const writePath = path.join(distPath, path.basename(asset));
|
|
36
|
+
await downloadFile(asset, writePath);
|
|
37
|
+
console.log(`Wrote ${asset} to ${writePath}`);
|
|
38
|
+
} else if ( typeof asset.directory === 'string' ) {
|
|
39
|
+
await mkdirp(path.join(distPath, asset.directory));
|
|
40
|
+
|
|
41
|
+
for ( const dirAsset of asset.assets ) {
|
|
42
|
+
const writePath = path.join(distPath, asset.directory, path.basename(dirAsset));
|
|
43
|
+
await downloadFile(dirAsset, writePath);
|
|
44
|
+
console.log(`Wrote ${dirAsset} to ${writePath}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
hasWrittenAssets = true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* downloadFile
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
function downloadFile(assetUrl: string, writePath: string) {
|
|
58
|
+
return new Promise<void>((resolve) => {
|
|
59
|
+
const file = createWriteStream(writePath);
|
|
60
|
+
https.get(assetUrl, function(response) {
|
|
61
|
+
response.pipe(file);
|
|
62
|
+
file.on('finish', () => {
|
|
63
|
+
file.close();
|
|
64
|
+
resolve();
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
})
|
|
68
|
+
}
|
package/tsup.config.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineConfig } from 'tsup'
|
|
2
|
+
import { plugin as CopyAssetsPlugin } from './plugins/copy-assets';
|
|
2
3
|
|
|
3
4
|
export default defineConfig({
|
|
4
5
|
minify: true,
|
|
@@ -6,5 +7,6 @@ export default defineConfig({
|
|
|
6
7
|
external: ['react'],
|
|
7
8
|
sourcemap: true,
|
|
8
9
|
dts: true,
|
|
9
|
-
format: ['esm', 'cjs']
|
|
10
|
+
format: ['esm', 'cjs'],
|
|
11
|
+
esbuildPlugins: [CopyAssetsPlugin]
|
|
10
12
|
})
|