Skip to content

Commit

Permalink
chore: updated exports
Browse files Browse the repository at this point in the history
* perf: cleanup codec logic

chore: update videojs-contrib-dash

* chore: cleanup

* chore: updated exports

* chore: exports

* chore: exports
  • Loading branch information
tsi authored Mar 21, 2024
1 parent e31b44e commit 727e730
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 42 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Cloudinary Video Player",
"author": "Cloudinary",
"license": "MIT",
"module": "./lib/videoPlayer.js",
"module": "./lib/cld-video-player.js",
"main": "./dist/cld-video-player.min.js",
"style": "./dist/cld-video-player.min.css",
"types": "./types/cld-video-player.d.ts",
Expand All @@ -18,7 +18,7 @@
],
"exports": {
".": {
"import": "./lib/videoPlayer.js",
"import": "./lib/cld-video-player.js",
"require": "./dist/cld-video-player.js",
"types": "./types/cld-video-player.d.ts"
},
Expand Down
7 changes: 3 additions & 4 deletions src/index.all.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// This file is bundled as `cld-video-player.js` to be imported as a single module that
// includes all plugins.
// This file is bundled as `all.js` to be imported as a single module that includes all plugins.

// Usage:
// import { videoPlayer, videoPlayers } from 'cloudinary-video-player';
// import { videoPlayer, videoPlayers } from 'cloudinary-video-player/all';
// Or:
// import cloudinary from 'cloudinary-video-player';
// import cloudinary from 'cloudinary-video-player/all';

import cloudinary from './index.js';

Expand Down
19 changes: 15 additions & 4 deletions src/index.es.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
// This file is bundled as `videoPlayer.js` to be imported as a tree-shaken module.
// This file is bundled as `cld-video-player.js` to be imported as a tree-shaken module.
// It is the default export of the Cloudinary Video Player.

// Usage:
// import videoPlayer from 'cloudinary-video-player/videoPlayer';
// import dashjs from "cloudinary-video-player/dash";
// import cloudinary from 'cloudinary-video-player';
// Or:
// import { videoPlayer } from "cloudinary-video-player";

export { videoPlayer as default } from './index.js';
// Other modules can be imported like that:
// import dash from 'cloudinary-video-player/dash';

import cloudinary from './index.js';

export const videoPlayer = cloudinary.videoPlayer;
export const videoPlayers = cloudinary.videoPlayers;
export const videoPlayerWithProfile = cloudinary.videoPlayerWithProfile;

export default cloudinary;
19 changes: 2 additions & 17 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ import { assign } from 'utils/assign';
import { pick, convertKeysToSnakeCase } from './utils/object';
import { CLOUDINARY_CONFIG_PARAM } from './video-player.const';

if (window.cloudinary && window.cloudinary.Cloudinary) {
console.warn(
'For version 1.9.0 and above, cloudinary-core is not needed for using the Cloudinary Video Player'
);
}

const getConfig = (playerOptions = {}, cloudinaryConfig) => {
const snakeCaseCloudinaryConfig = pick(convertKeysToSnakeCase(playerOptions), CLOUDINARY_CONFIG_PARAM);

Expand All @@ -26,26 +20,17 @@ const getVideoPlayer = config => (id, playerOptions, ready) =>
const getVideoPlayers = config => (selector, playerOptions, ready) =>
VideoPlayer.all(selector, getConfig(playerOptions, config), ready);

const cloudinaryVideoPlayerConfig = config => ({
videoPlayer: getVideoPlayer(config),
videoPlayers: getVideoPlayers(config)
});
const getVideoPlayerWithProfile = config => (id, playerOptions, ready) => createVideoPlayerProfile(id, getConfig(playerOptions, config), ready);

export const videoPlayer = getVideoPlayer();
export const videoPlayers = getVideoPlayers();

const getVideoPlayerWithProfile = config => (id, playerOptions, ready) => createVideoPlayerProfile(id, getConfig(playerOptions, config), ready);
export const videoPlayerWithProfile = getVideoPlayerWithProfile();

const cloudinary = {
...(window.cloudinary || {}),
videoPlayer,
videoPlayers,
videoPlayerWithProfile,
Cloudinary: {
// Backwards compatibility with SDK v1
new: cloudinaryVideoPlayerConfig
}
videoPlayerWithProfile
};

window.cloudinary = cloudinary;
Expand Down
6 changes: 6 additions & 0 deletions src/index.videoPlayer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file is bundled as `videoPlayer.js` to be imported as a tree-shaken module.

// Usage:
// import videoPlayer from 'cloudinary-video-player/videoPlayer';

export { videoPlayer as default } from './index.js';
6 changes: 6 additions & 0 deletions src/index.videoPlayerWithProfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file is bundled as `videoPlayerWithProfile.js` to be imported as a tree-shaken module.

// Usage:
// import videoPlayerWithProfile from 'cloudinary-video-player/videoPlayerWithProfile';

export { videoPlayerWithProfile as default } from './index.js';
3 changes: 1 addition & 2 deletions src/video-player-profile.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import VideoPlayer from './video-player';
import { defaultProfiles } from './config/profiles';

export const getProfile = async (cloudName, profile) => {
const { defaultProfiles } = await import(/* webpackChunkName: "defaultProfiles" */ './config/profiles');

if (Object.keys(defaultProfiles).includes(profile)) {
return defaultProfiles[profile];
}
Expand Down
1 change: 0 additions & 1 deletion src/video-profile-export.es.js

This file was deleted.

10 changes: 1 addition & 9 deletions types/cld-video-player.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,11 @@ export const videoPlayer: VideoPlayerFunction;
export const videoPlayers: VideoMultiPlayersFunction;
export const videoPlayerWithProfile: VideoPlayerWithProfileFunction;

interface CommonCloudinary {
videoPlayer: VideoPlayerFunction;
videoPlayers: VideoMultiPlayersFunction;
videoPlayerWithProfile: VideoPlayerWithProfileFunction;
}

export interface Cloudinary extends CommonCloudinary {
export interface Cloudinary {
videoPlayer: VideoPlayerFunction;
videoPlayers: VideoMultiPlayersFunction;
videoPlayerWithProfile: VideoPlayerWithProfileFunction;
Cloudinary: {
new: (options?: any) => CommonCloudinary;
};
}

declare global {
Expand Down
8 changes: 5 additions & 3 deletions webpack/es6.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ const webpackCommon = require('./common.config');
const path = require('path');

delete webpackCommon.output; // overwrite
delete webpackCommon.devtool; // disable

module.exports = merge(webpackCommon, {
mode: 'production',

entry: {
'cld-video-player': './index.all.js',
'videoPlayer': './index.es.js',
'videoPlayerWithProfile': './video-profile-export.es.js'
'cld-video-player': './index.es.js', // default
'videoPlayer': './index.videoPlayer.js',
'videoPlayerWithProfile': './index.videoPlayerWithProfile.js',
'all': './index.all.js'
},

output: {
Expand Down

0 comments on commit 727e730

Please sign in to comment.