@brightcove/components-embed-code-modal 1.1.2 → 1.1.3
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/.eslintignore +7 -0
- package/.eslintrc +23 -0
- package/.github/workflows/ci.yml +23 -0
- package/.husky/pre-commit +4 -0
- package/.nvmrc +1 -0
- package/.prettierignore +7 -0
- package/.prettierrc +5 -0
- package/.release-it.json +40 -0
- package/.whitesource +3 -0
- package/CHANGELOG.md +423 -0
- package/CODEOWNERS +37 -0
- package/PULL_REQUEST_TEMPLATE.md +17 -0
- package/__tests__/EmbedCode.test.tsx +51 -0
- package/__tests__/InteractivityProject.test.tsx +50 -0
- package/__tests__/PlayerPreview.test.tsx +23 -0
- package/__tests__/PrismLiveModal.test.tsx +85 -0
- package/__tests__/PrismPlayerControls.test.tsx +139 -0
- package/__tests__/PrismPlayerPreview.test.tsx +168 -0
- package/__tests__/TabsHeader.test.tsx +19 -0
- package/__tests__/TabsSection.test.tsx +46 -0
- package/__tests__/TitleWithTooltip.test.tsx +45 -0
- package/__tests__/VideoPlayer.test.tsx +105 -0
- package/__tests__/embedCodeGenerator.test.ts +111 -0
- package/__tests__/util.test.ts +89 -0
- package/babel.config.json +17 -0
- package/build/README.md +109 -0
- package/build/__tests__/PrismLiveModal.test.d.ts +2 -0
- package/build/__tests__/PrismLiveModal.test.d.ts.map +1 -0
- package/build/index.js +9 -0
- package/build/index.js.map +1 -0
- package/build/package.json +100 -0
- package/{src → build/src}/js/components/prism/PrismLiveModal.d.ts.map +1 -1
- package/{src → build/src}/js/components/prism/PrismPlayerControls.d.ts +2 -1
- package/{src → build/src}/js/components/prism/PrismPlayerControls.d.ts.map +1 -1
- package/{src → build/src}/js/components/prism/PrismPlayerPreview.d.ts +2 -1
- package/build/src/js/components/prism/PrismPlayerPreview.d.ts.map +1 -0
- package/build/src/js/hooks/useIsMobile.d.ts +3 -0
- package/build/src/js/hooks/useIsMobile.d.ts.map +1 -0
- package/{src → build/src}/js/i18n.d.ts +24 -0
- package/{src → build/src}/js/i18n.d.ts.map +1 -1
- package/etc/wildcard.brightcove.com.key +27 -0
- package/etc/wildcard.brightcove.com.pem +96 -0
- package/jest/jest.setup.js +90 -0
- package/jest/jest.stub.js +4 -0
- package/jest.config.js +24 -0
- package/package.json +17 -7
- package/scripts/create-dist-pkg-prod.js +19 -0
- package/src/index.ts +17 -0
- package/src/js/EmbedCodeModal.tsx +105 -0
- package/src/js/components/CustomSettingsDropdown.tsx +184 -0
- package/src/js/components/EmbedCopySection.tsx +130 -0
- package/src/js/components/ModalContainer.tsx +367 -0
- package/src/js/components/NoPlayerModal.tsx +42 -0
- package/src/js/components/PlayerPreview.tsx +116 -0
- package/src/js/components/TabsHeader.tsx +31 -0
- package/src/js/components/TabsSection.tsx +74 -0
- package/src/js/components/TitleWithTooltip.tsx +39 -0
- package/src/js/components/VideoLinks.tsx +83 -0
- package/src/js/components/VideoPlayer.tsx +324 -0
- package/src/js/components/index.ts +9 -0
- package/src/js/components/prism/PrismLiveModal.tsx +196 -0
- package/src/js/components/prism/PrismPlayerControls.tsx +356 -0
- package/src/js/components/prism/PrismPlayerPreview.tsx +200 -0
- package/src/js/components/prism/index.ts +3 -0
- package/src/js/constants/baseUrls.ts +4 -0
- package/src/js/constants/embed.ts +12 -0
- package/src/js/constants/player.ts +32 -0
- package/src/js/constants/pluginsRegistry.ts +30 -0
- package/src/js/hooks/useGetPlayers.ts +12 -0
- package/src/js/hooks/useIsMobile.ts +33 -0
- package/src/js/i18n.ts +43 -0
- package/src/js/services/players-api.ts +26 -0
- package/src/js/services/url-shortener.ts +10 -0
- package/src/js/types/EmbedCodeModalProps.ts +72 -0
- package/src/js/types/EmbedCodeProps.ts +13 -0
- package/src/js/types/brightcoveEmbedCode.d.ts +18 -0
- package/src/js/types/players.ts +64 -0
- package/src/js/types/react-i18next.d.ts +8 -0
- package/src/js/types/studioModule.ts +7 -0
- package/src/js/utils/addPluginsDataToPlayers.ts +59 -0
- package/src/js/utils/call.ts +31 -0
- package/src/js/utils/dimensions.ts +53 -0
- package/src/js/utils/embedCodeGenerator.ts +120 -0
- package/src/js/utils/featureSwitches.ts +16 -0
- package/src/js/utils/util.ts +153 -0
- package/src/module.tsx +280 -0
- package/src/styles/CustomSettingsDropdown.sass +42 -0
- package/src/styles/EmbedCode.sass +30 -0
- package/src/styles/EmbedCodeModal.sass +76 -0
- package/src/styles/base.sass +1 -0
- package/src/styles/prism/PrismLiveModal.sass +128 -0
- package/src/styles/theme.sass +11 -0
- package/src/styles/typings.td.ts +9 -0
- package/src/translations/en.json +69 -0
- package/src/translations/es.json +69 -0
- package/src/translations/fr.json +69 -0
- package/src/translations/ja.json +69 -0
- package/src/translations/ko.json +69 -0
- package/src/translations/zh.json +69 -0
- package/src/types/studio.ts +197 -0
- package/tsconfig.json +34 -0
- package/webpack.config.js +117 -0
- package/index.js +0 -9
- package/index.js.map +0 -1
- package/src/js/components/prism/PrismPlayerPreview.d.ts.map +0 -1
- /package/{__tests__ → build/__tests__}/EmbedCode.test.d.ts +0 -0
- /package/{__tests__ → build/__tests__}/EmbedCode.test.d.ts.map +0 -0
- /package/{__tests__ → build/__tests__}/InteractivityProject.test.d.ts +0 -0
- /package/{__tests__ → build/__tests__}/InteractivityProject.test.d.ts.map +0 -0
- /package/{__tests__ → build/__tests__}/PlayerPreview.test.d.ts +0 -0
- /package/{__tests__ → build/__tests__}/PlayerPreview.test.d.ts.map +0 -0
- /package/{__tests__ → build/__tests__}/PrismPlayerControls.test.d.ts +0 -0
- /package/{__tests__ → build/__tests__}/PrismPlayerControls.test.d.ts.map +0 -0
- /package/{__tests__ → build/__tests__}/PrismPlayerPreview.test.d.ts +0 -0
- /package/{__tests__ → build/__tests__}/PrismPlayerPreview.test.d.ts.map +0 -0
- /package/{__tests__ → build/__tests__}/TabsHeader.test.d.ts +0 -0
- /package/{__tests__ → build/__tests__}/TabsHeader.test.d.ts.map +0 -0
- /package/{__tests__ → build/__tests__}/TabsSection.test.d.ts +0 -0
- /package/{__tests__ → build/__tests__}/TabsSection.test.d.ts.map +0 -0
- /package/{__tests__ → build/__tests__}/TitleWithTooltip.test.d.ts +0 -0
- /package/{__tests__ → build/__tests__}/TitleWithTooltip.test.d.ts.map +0 -0
- /package/{__tests__ → build/__tests__}/VideoPlayer.test.d.ts +0 -0
- /package/{__tests__ → build/__tests__}/VideoPlayer.test.d.ts.map +0 -0
- /package/{__tests__ → build/__tests__}/embedCodeGenerator.test.d.ts +0 -0
- /package/{__tests__ → build/__tests__}/embedCodeGenerator.test.d.ts.map +0 -0
- /package/{__tests__ → build/__tests__}/util.test.d.ts +0 -0
- /package/{__tests__ → build/__tests__}/util.test.d.ts.map +0 -0
- /package/{src → build/src}/index.d.ts +0 -0
- /package/{src → build/src}/index.d.ts.map +0 -0
- /package/{src → build/src}/js/EmbedCodeModal.d.ts +0 -0
- /package/{src → build/src}/js/EmbedCodeModal.d.ts.map +0 -0
- /package/{src → build/src}/js/components/CustomSettingsDropdown.d.ts +0 -0
- /package/{src → build/src}/js/components/CustomSettingsDropdown.d.ts.map +0 -0
- /package/{src → build/src}/js/components/EmbedCopySection.d.ts +0 -0
- /package/{src → build/src}/js/components/EmbedCopySection.d.ts.map +0 -0
- /package/{src → build/src}/js/components/ModalContainer.d.ts +0 -0
- /package/{src → build/src}/js/components/ModalContainer.d.ts.map +0 -0
- /package/{src → build/src}/js/components/NoPlayerModal.d.ts +0 -0
- /package/{src → build/src}/js/components/NoPlayerModal.d.ts.map +0 -0
- /package/{src → build/src}/js/components/PlayerPreview.d.ts +0 -0
- /package/{src → build/src}/js/components/PlayerPreview.d.ts.map +0 -0
- /package/{src → build/src}/js/components/TabsHeader.d.ts +0 -0
- /package/{src → build/src}/js/components/TabsHeader.d.ts.map +0 -0
- /package/{src → build/src}/js/components/TabsSection.d.ts +0 -0
- /package/{src → build/src}/js/components/TabsSection.d.ts.map +0 -0
- /package/{src → build/src}/js/components/TitleWithTooltip.d.ts +0 -0
- /package/{src → build/src}/js/components/TitleWithTooltip.d.ts.map +0 -0
- /package/{src → build/src}/js/components/VideoLinks.d.ts +0 -0
- /package/{src → build/src}/js/components/VideoLinks.d.ts.map +0 -0
- /package/{src → build/src}/js/components/VideoPlayer.d.ts +0 -0
- /package/{src → build/src}/js/components/VideoPlayer.d.ts.map +0 -0
- /package/{src → build/src}/js/components/index.d.ts +0 -0
- /package/{src → build/src}/js/components/index.d.ts.map +0 -0
- /package/{src → build/src}/js/components/prism/PrismLiveModal.d.ts +0 -0
- /package/{src → build/src}/js/components/prism/index.d.ts +0 -0
- /package/{src → build/src}/js/components/prism/index.d.ts.map +0 -0
- /package/{src → build/src}/js/constants/baseUrls.d.ts +0 -0
- /package/{src → build/src}/js/constants/baseUrls.d.ts.map +0 -0
- /package/{src → build/src}/js/constants/embed.d.ts +0 -0
- /package/{src → build/src}/js/constants/embed.d.ts.map +0 -0
- /package/{src → build/src}/js/constants/player.d.ts +0 -0
- /package/{src → build/src}/js/constants/player.d.ts.map +0 -0
- /package/{src → build/src}/js/constants/pluginsRegistry.d.ts +0 -0
- /package/{src → build/src}/js/constants/pluginsRegistry.d.ts.map +0 -0
- /package/{src → build/src}/js/hooks/useGetPlayers.d.ts +0 -0
- /package/{src → build/src}/js/hooks/useGetPlayers.d.ts.map +0 -0
- /package/{src → build/src}/js/services/players-api.d.ts +0 -0
- /package/{src → build/src}/js/services/players-api.d.ts.map +0 -0
- /package/{src → build/src}/js/services/url-shortener.d.ts +0 -0
- /package/{src → build/src}/js/services/url-shortener.d.ts.map +0 -0
- /package/{src → build/src}/js/types/EmbedCodeModalProps.d.ts +0 -0
- /package/{src → build/src}/js/types/EmbedCodeModalProps.d.ts.map +0 -0
- /package/{src → build/src}/js/types/EmbedCodeProps.d.ts +0 -0
- /package/{src → build/src}/js/types/EmbedCodeProps.d.ts.map +0 -0
- /package/{src → build/src}/js/types/players.d.ts +0 -0
- /package/{src → build/src}/js/types/players.d.ts.map +0 -0
- /package/{src → build/src}/js/types/studioModule.d.ts +0 -0
- /package/{src → build/src}/js/types/studioModule.d.ts.map +0 -0
- /package/{src → build/src}/js/utils/addPluginsDataToPlayers.d.ts +0 -0
- /package/{src → build/src}/js/utils/addPluginsDataToPlayers.d.ts.map +0 -0
- /package/{src → build/src}/js/utils/call.d.ts +0 -0
- /package/{src → build/src}/js/utils/call.d.ts.map +0 -0
- /package/{src → build/src}/js/utils/dimensions.d.ts +0 -0
- /package/{src → build/src}/js/utils/dimensions.d.ts.map +0 -0
- /package/{src → build/src}/js/utils/embedCodeGenerator.d.ts +0 -0
- /package/{src → build/src}/js/utils/embedCodeGenerator.d.ts.map +0 -0
- /package/{src → build/src}/js/utils/featureSwitches.d.ts +0 -0
- /package/{src → build/src}/js/utils/featureSwitches.d.ts.map +0 -0
- /package/{src → build/src}/js/utils/util.d.ts +0 -0
- /package/{src → build/src}/js/utils/util.d.ts.map +0 -0
- /package/{src → build/src}/module.d.ts +0 -0
- /package/{src → build/src}/module.d.ts.map +0 -0
- /package/{src → build/src}/styles/typings.td.d.ts +0 -0
- /package/{src → build/src}/styles/typings.td.d.ts.map +0 -0
- /package/{src → build/src}/types/studio.d.ts +0 -0
- /package/{src → build/src}/types/studio.d.ts.map +0 -0
package/src/js/i18n.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import i18n from 'i18next';
|
|
2
|
+
import { initReactI18next } from 'react-i18next';
|
|
3
|
+
|
|
4
|
+
import common_en from 'translations/en.json';
|
|
5
|
+
import common_es from 'translations/es.json';
|
|
6
|
+
import common_fr from 'translations/fr.json';
|
|
7
|
+
import common_ja from 'translations/ja.json';
|
|
8
|
+
import common_ko from 'translations/ko.json';
|
|
9
|
+
import common_zh from 'translations/zh.json';
|
|
10
|
+
|
|
11
|
+
export const resources = {
|
|
12
|
+
en: {
|
|
13
|
+
translation: common_en,
|
|
14
|
+
},
|
|
15
|
+
es: {
|
|
16
|
+
translation: common_es,
|
|
17
|
+
},
|
|
18
|
+
fr: {
|
|
19
|
+
translation: common_fr,
|
|
20
|
+
},
|
|
21
|
+
ja: {
|
|
22
|
+
translation: common_ja,
|
|
23
|
+
},
|
|
24
|
+
ko: {
|
|
25
|
+
translation: common_ko,
|
|
26
|
+
},
|
|
27
|
+
zh: {
|
|
28
|
+
translation: common_zh,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
i18n.use(initReactI18next).init({
|
|
33
|
+
lng: window.StudioModule?.config?.lang || 'en',
|
|
34
|
+
fallbackLng: 'en',
|
|
35
|
+
debug: true,
|
|
36
|
+
returnObjects: true,
|
|
37
|
+
resources,
|
|
38
|
+
interpolation: {
|
|
39
|
+
escapeValue: false, // react already safe from xss
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export default i18n;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getAllPlayers,
|
|
3
|
+
createPlayer as createPlayerAPI,
|
|
4
|
+
getPlayer as getPlayerAPI,
|
|
5
|
+
} from '@brightcove/studio-api-services/api/players-api';
|
|
6
|
+
import { callAPI } from 'js/utils/call';
|
|
7
|
+
import {
|
|
8
|
+
GetPlayersPayload,
|
|
9
|
+
CreatePlayerPayload,
|
|
10
|
+
CreatePlayerResponse,
|
|
11
|
+
PlayerItem,
|
|
12
|
+
} from 'js/types/players';
|
|
13
|
+
|
|
14
|
+
export const getPlayers = async (): Promise<GetPlayersPayload> => {
|
|
15
|
+
return callAPI(getAllPlayers, {});
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const createPlayer = async (
|
|
19
|
+
payload: CreatePlayerPayload,
|
|
20
|
+
): Promise<CreatePlayerResponse> => {
|
|
21
|
+
return callAPI(createPlayerAPI, payload);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const getPlayer = async (playerId: string): Promise<PlayerItem> => {
|
|
25
|
+
return callAPI(getPlayerAPI, { playerId });
|
|
26
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getShortenedUrl } from '@brightcove/studio-api-services/api/url-shortener-api';
|
|
2
|
+
import { callAPI } from 'js/utils/call';
|
|
3
|
+
|
|
4
|
+
export const shortenUrl = async ({
|
|
5
|
+
longUrl,
|
|
6
|
+
}: {
|
|
7
|
+
longUrl: string;
|
|
8
|
+
}): Promise<string> => {
|
|
9
|
+
return callAPI(getShortenedUrl, { longUrl });
|
|
10
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// export payload that will be used to pass data into component
|
|
2
|
+
export interface VideoPayload {
|
|
3
|
+
videoId: string;
|
|
4
|
+
videoName: string;
|
|
5
|
+
accountId: string;
|
|
6
|
+
posterUrl?: string;
|
|
7
|
+
duration: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface PlayerPayload {
|
|
11
|
+
id: string;
|
|
12
|
+
configuration?: Record<string, unknown>;
|
|
13
|
+
name?: string;
|
|
14
|
+
accountId?: string;
|
|
15
|
+
embedCodeProperties?: EmbedCodeProperties;
|
|
16
|
+
isOutstreamPlayer?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ProjectPayload {
|
|
20
|
+
accountId: string;
|
|
21
|
+
videoId: string;
|
|
22
|
+
interactivityProjectId: string;
|
|
23
|
+
interactivityProjectName: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface LivePayload {
|
|
27
|
+
videoId: string;
|
|
28
|
+
accountId: string;
|
|
29
|
+
livePlaybackToken: string;
|
|
30
|
+
adConfigId: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export enum EmbedCodeModalTypes {
|
|
34
|
+
PLAYER = 'player',
|
|
35
|
+
VIDEO = 'video',
|
|
36
|
+
PROJECT = 'project',
|
|
37
|
+
LIVE = 'live',
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export enum NoInteractivityPlayerModalTypes {
|
|
41
|
+
NO_PLAYER = 'no-player',
|
|
42
|
+
NO_PERMISSION = 'no-permission',
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type ModalDataPayload =
|
|
46
|
+
| VideoPayload
|
|
47
|
+
| PlayerPayload
|
|
48
|
+
| ProjectPayload
|
|
49
|
+
| LivePayload;
|
|
50
|
+
|
|
51
|
+
export enum EmbedCodeUnits {
|
|
52
|
+
PX = 'px',
|
|
53
|
+
EM = 'em',
|
|
54
|
+
PERCENT = '%',
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export enum EmbedCodeAspectRatio {
|
|
58
|
+
FLUID = 'fluid',
|
|
59
|
+
CUSTOM = 'custom',
|
|
60
|
+
ONE_ONE = '1:1',
|
|
61
|
+
FOUR_THREE = '4:3',
|
|
62
|
+
SIXTEEN_NINE = '16:9',
|
|
63
|
+
NINE_SIXTEEN = '9:16',
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface EmbedCodeProperties {
|
|
67
|
+
width: number;
|
|
68
|
+
height: number;
|
|
69
|
+
units: EmbedCodeUnits;
|
|
70
|
+
responsive: boolean;
|
|
71
|
+
aspectRatio: EmbedCodeAspectRatio;
|
|
72
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EmbedCodeProperties } from './EmbedCodeModalProps';
|
|
2
|
+
|
|
3
|
+
export type EmbedCodeProps = {
|
|
4
|
+
iframe: boolean;
|
|
5
|
+
accountId: string;
|
|
6
|
+
videoId?: string;
|
|
7
|
+
playerId: string;
|
|
8
|
+
interactivityProjectId?: string;
|
|
9
|
+
embedCodeProperties?: EmbedCodeProperties;
|
|
10
|
+
isOutstreamPlayer?: boolean;
|
|
11
|
+
livePlaybackToken?: string;
|
|
12
|
+
adConfigId?: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare module '@brightcove/player-embed-code' {
|
|
2
|
+
export interface EmbedCodeOptions {
|
|
3
|
+
accountId: string;
|
|
4
|
+
playerId?: string;
|
|
5
|
+
iframe?: boolean;
|
|
6
|
+
videoId?: string;
|
|
7
|
+
interactivityProjectId?: string;
|
|
8
|
+
width?: number;
|
|
9
|
+
height?: number;
|
|
10
|
+
responsive?: boolean;
|
|
11
|
+
urlBase?: string;
|
|
12
|
+
playlistIsHorizontal?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default function brightcoveEmbedCode(
|
|
16
|
+
options: EmbedCodeOptions,
|
|
17
|
+
): string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export type PlayerSelectItem = {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export type PlayersObjectItem = {
|
|
7
|
+
label: string;
|
|
8
|
+
id: string;
|
|
9
|
+
hasCustomPlugins: boolean;
|
|
10
|
+
hasCampaignPlugin: boolean;
|
|
11
|
+
hasInteractivityPlugin: boolean;
|
|
12
|
+
hasViewerIDSource: boolean;
|
|
13
|
+
hasBcMapTracking: boolean;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type PlayersObject = {
|
|
17
|
+
[key: string]: PlayersObjectItem;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type PlayerItem = {
|
|
21
|
+
account_id: string;
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
description: string;
|
|
25
|
+
branches: object;
|
|
26
|
+
created_at: string;
|
|
27
|
+
embed_count: number;
|
|
28
|
+
url: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type GetPlayersPayload = {
|
|
32
|
+
item_count: number;
|
|
33
|
+
items: PlayerItem[];
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type TabsSelectedId = string | number | undefined;
|
|
37
|
+
|
|
38
|
+
export type CreatePlayerPayload = {
|
|
39
|
+
data: {
|
|
40
|
+
name: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
configuration?: {
|
|
43
|
+
autoplay?;
|
|
44
|
+
loop?: boolean;
|
|
45
|
+
video_cloud?: {
|
|
46
|
+
video: string;
|
|
47
|
+
};
|
|
48
|
+
plugins?: {
|
|
49
|
+
registry_id: string;
|
|
50
|
+
version: string;
|
|
51
|
+
}[];
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type CreatePlayerResponse = {
|
|
57
|
+
id: string;
|
|
58
|
+
url: string;
|
|
59
|
+
embed_code: string;
|
|
60
|
+
embed_in_page: string;
|
|
61
|
+
preview_url: string;
|
|
62
|
+
preview_embed_in_page: string;
|
|
63
|
+
preview_embed_code: string;
|
|
64
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { sortAsc } from 'js/utils/util';
|
|
2
|
+
import {
|
|
3
|
+
GetPlayersPayload,
|
|
4
|
+
PlayerSelectItem,
|
|
5
|
+
PlayersObject,
|
|
6
|
+
} from 'js/types/players';
|
|
7
|
+
import {
|
|
8
|
+
bcHostedPlugins,
|
|
9
|
+
CAMPAIGN_PLUGIN_NAME,
|
|
10
|
+
INTERACTIVITY_REGISTRY_ID,
|
|
11
|
+
INTERACTIVITY_PLUGIN_NAME,
|
|
12
|
+
VIEWER_ID_KEY_NAME,
|
|
13
|
+
BC_MAP_TRACKING_NAME,
|
|
14
|
+
} from 'js/constants/pluginsRegistry';
|
|
15
|
+
|
|
16
|
+
export function addPluginsDataToPlayers(players: GetPlayersPayload) {
|
|
17
|
+
const playerListForSelection: PlayerSelectItem[] = [];
|
|
18
|
+
const playersObject: PlayersObject = {};
|
|
19
|
+
players?.items.forEach((player) => {
|
|
20
|
+
const playerConfig = player.branches['master'].configuration;
|
|
21
|
+
const plugins = playerConfig.plugins ?? [];
|
|
22
|
+
const hasPlugins = plugins ? plugins.length > 0 : false;
|
|
23
|
+
|
|
24
|
+
let hasBCHostedPlugin = false;
|
|
25
|
+
let hasCampaignPlugin = false;
|
|
26
|
+
let hasInteractivityPlugin = false;
|
|
27
|
+
const hasViewerIDSource = !!playerConfig[VIEWER_ID_KEY_NAME];
|
|
28
|
+
let hasBcMapTracking = false;
|
|
29
|
+
|
|
30
|
+
for (const plugin of plugins) {
|
|
31
|
+
const { name } = plugin;
|
|
32
|
+
hasBCHostedPlugin = bcHostedPlugins.includes(name);
|
|
33
|
+
hasCampaignPlugin =
|
|
34
|
+
hasCampaignPlugin || plugin.name === CAMPAIGN_PLUGIN_NAME;
|
|
35
|
+
hasInteractivityPlugin =
|
|
36
|
+
hasInteractivityPlugin ||
|
|
37
|
+
plugin.registry_id === INTERACTIVITY_REGISTRY_ID ||
|
|
38
|
+
plugin.name === INTERACTIVITY_PLUGIN_NAME;
|
|
39
|
+
hasBcMapTracking =
|
|
40
|
+
hasBcMapTracking || plugin.name === BC_MAP_TRACKING_NAME;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
playerListForSelection.push({ label: player.name, value: player.id });
|
|
44
|
+
playersObject[player.id] = {
|
|
45
|
+
label: player.name,
|
|
46
|
+
id: player.id,
|
|
47
|
+
hasCustomPlugins: !hasBCHostedPlugin && hasPlugins,
|
|
48
|
+
hasCampaignPlugin,
|
|
49
|
+
hasInteractivityPlugin,
|
|
50
|
+
hasViewerIDSource,
|
|
51
|
+
hasBcMapTracking,
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
players: playersObject,
|
|
57
|
+
playerListForSelection: sortAsc(playerListForSelection),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const getStudioConfig = () => window.StudioModule.config;
|
|
2
|
+
|
|
3
|
+
export const getAccountId = (): string => {
|
|
4
|
+
const config = getStudioConfig();
|
|
5
|
+
return config.user.currentAccount.id;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const getConfig = () => {
|
|
9
|
+
const config = getStudioConfig();
|
|
10
|
+
const apiConfig = {
|
|
11
|
+
publisherId: getAccountId(),
|
|
12
|
+
api: config.module.api,
|
|
13
|
+
};
|
|
14
|
+
return { apiConfig };
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const call = <T>(options): Promise<T> => {
|
|
18
|
+
const studioModule = window.StudioModule;
|
|
19
|
+
const api = studioModule.api();
|
|
20
|
+
|
|
21
|
+
const callback = (resolve, reject) => {
|
|
22
|
+
api.call(options, resolve, reject);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return new Promise(callback);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const callAPI = <T>(apiEndpoint, apiArgs) => {
|
|
29
|
+
const endpoint = apiEndpoint({ ...apiArgs, ...getConfig() });
|
|
30
|
+
return call<T>(endpoint);
|
|
31
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { EmbedCodeAspectRatio } from 'js/types/EmbedCodeModalProps';
|
|
2
|
+
|
|
3
|
+
const precision = 100;
|
|
4
|
+
export const calculateHeight = (
|
|
5
|
+
height: number,
|
|
6
|
+
aspectRatio: EmbedCodeAspectRatio,
|
|
7
|
+
) => {
|
|
8
|
+
height = isNaN(height) ? 0 : height;
|
|
9
|
+
let newHeight: number;
|
|
10
|
+
switch (aspectRatio) {
|
|
11
|
+
case EmbedCodeAspectRatio.CUSTOM:
|
|
12
|
+
return height;
|
|
13
|
+
case EmbedCodeAspectRatio.ONE_ONE:
|
|
14
|
+
newHeight = height;
|
|
15
|
+
break;
|
|
16
|
+
case EmbedCodeAspectRatio.FOUR_THREE:
|
|
17
|
+
newHeight = height / (4 / 3);
|
|
18
|
+
break;
|
|
19
|
+
case EmbedCodeAspectRatio.NINE_SIXTEEN:
|
|
20
|
+
newHeight = height / (9 / 16);
|
|
21
|
+
break;
|
|
22
|
+
case EmbedCodeAspectRatio.SIXTEEN_NINE:
|
|
23
|
+
default:
|
|
24
|
+
newHeight = height / (16 / 9);
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
return Math.round(precision * newHeight) / precision;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const calculateWidthForVerticalAspectRatio = (width: number) => {
|
|
31
|
+
return (Math.round(precision * (width * (9 / 16))) / precision).toString();
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const shouldUpdateWidth = (
|
|
35
|
+
oldAspectRatio: EmbedCodeAspectRatio,
|
|
36
|
+
aspectRatio: EmbedCodeAspectRatio,
|
|
37
|
+
) =>
|
|
38
|
+
oldAspectRatio !== EmbedCodeAspectRatio.NINE_SIXTEEN &&
|
|
39
|
+
aspectRatio === EmbedCodeAspectRatio.NINE_SIXTEEN;
|
|
40
|
+
|
|
41
|
+
export const calculateDimensions = (
|
|
42
|
+
calculateNewWidth: boolean,
|
|
43
|
+
aspectRatio: EmbedCodeAspectRatio,
|
|
44
|
+
width: number,
|
|
45
|
+
height: number,
|
|
46
|
+
) => {
|
|
47
|
+
return {
|
|
48
|
+
height: calculateNewWidth ? width : calculateHeight(height, aspectRatio),
|
|
49
|
+
width: calculateNewWidth
|
|
50
|
+
? calculateWidthForVerticalAspectRatio(width)
|
|
51
|
+
: height,
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import brightcoveEmbedCode from '@brightcove/player-embed-code';
|
|
2
|
+
import { getUrlBase, decodeHtmlEntities } from 'js/utils/util';
|
|
3
|
+
import {
|
|
4
|
+
EmbedCodeProperties,
|
|
5
|
+
EmbedCodeUnits,
|
|
6
|
+
EmbedCodeAspectRatio,
|
|
7
|
+
} from 'js/types/EmbedCodeModalProps';
|
|
8
|
+
|
|
9
|
+
interface GenerateEmbedCodeParams {
|
|
10
|
+
accountId: string;
|
|
11
|
+
playerId: string;
|
|
12
|
+
videoId?: string;
|
|
13
|
+
embedProperties: EmbedCodeProperties;
|
|
14
|
+
isCampaign?: boolean;
|
|
15
|
+
isViewerIdSource?: boolean;
|
|
16
|
+
isBcMapTracking?: boolean;
|
|
17
|
+
interactivityProjectId?: string;
|
|
18
|
+
livePlaybackToken?: string;
|
|
19
|
+
adConfigId?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const DEFAULT_HEIGHT = 540;
|
|
23
|
+
const DEFAULT_WIDTH = 960;
|
|
24
|
+
|
|
25
|
+
const defaultConfig = {
|
|
26
|
+
responsive: false,
|
|
27
|
+
width: DEFAULT_WIDTH,
|
|
28
|
+
height: DEFAULT_HEIGHT,
|
|
29
|
+
urlBase: getUrlBase(),
|
|
30
|
+
playlistIsHorizontal: true,
|
|
31
|
+
units: EmbedCodeUnits.PX,
|
|
32
|
+
aspectRatio: EmbedCodeAspectRatio.FLUID,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// Breaks the single-line embed snippet onto multiple lines so the
|
|
36
|
+
// PrismCodeCard gutter renders one line number per attribute.
|
|
37
|
+
export const formatEmbedSnippet = (snippet: string): string =>
|
|
38
|
+
snippet
|
|
39
|
+
.replace(/<(iframe|video-js|script)\s+/g, '<$1\n ')
|
|
40
|
+
.replace(/"\s+([a-zA-Z-]+=)/g, '"\n $1')
|
|
41
|
+
.replace(/>\s*<script/g, '>\n<script');
|
|
42
|
+
|
|
43
|
+
const normalizeEmbedProperties = (
|
|
44
|
+
embedProperties: EmbedCodeProperties,
|
|
45
|
+
): EmbedCodeProperties =>
|
|
46
|
+
embedProperties.aspectRatio === EmbedCodeAspectRatio.CUSTOM
|
|
47
|
+
? { ...embedProperties, aspectRatio: EmbedCodeAspectRatio.FLUID }
|
|
48
|
+
: embedProperties;
|
|
49
|
+
|
|
50
|
+
export const generateEmbedCode = ({
|
|
51
|
+
accountId,
|
|
52
|
+
playerId,
|
|
53
|
+
videoId,
|
|
54
|
+
embedProperties,
|
|
55
|
+
interactivityProjectId,
|
|
56
|
+
livePlaybackToken,
|
|
57
|
+
adConfigId,
|
|
58
|
+
}: GenerateEmbedCodeParams): { embedCode: string; embedCodeJS: string } => {
|
|
59
|
+
const normalizedEmbedProperties = normalizeEmbedProperties(embedProperties);
|
|
60
|
+
|
|
61
|
+
const baseConfig = {
|
|
62
|
+
accountId,
|
|
63
|
+
playerId,
|
|
64
|
+
videoId,
|
|
65
|
+
livePlaybackToken,
|
|
66
|
+
adConfigId,
|
|
67
|
+
interactivityProjectId,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// Generate iFrame embed code
|
|
71
|
+
const iframeConfig = Object.assign(
|
|
72
|
+
{},
|
|
73
|
+
{
|
|
74
|
+
...defaultConfig,
|
|
75
|
+
...baseConfig,
|
|
76
|
+
...normalizedEmbedProperties,
|
|
77
|
+
iframe: true,
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
if (iframeConfig.aspectRatio) {
|
|
82
|
+
const { ...rest } = iframeConfig;
|
|
83
|
+
const iframeCode = brightcoveEmbedCode(rest);
|
|
84
|
+
const embedCode = formatEmbedSnippet(decodeHtmlEntities(iframeCode));
|
|
85
|
+
|
|
86
|
+
// Generate JavaScript embed code
|
|
87
|
+
const jsConfig = Object.assign(
|
|
88
|
+
{},
|
|
89
|
+
{
|
|
90
|
+
...defaultConfig,
|
|
91
|
+
...baseConfig,
|
|
92
|
+
...normalizedEmbedProperties,
|
|
93
|
+
iframe: false,
|
|
94
|
+
},
|
|
95
|
+
);
|
|
96
|
+
const { ...jsRest } = jsConfig;
|
|
97
|
+
const jsCode = brightcoveEmbedCode(jsRest);
|
|
98
|
+
const embedCodeJS = formatEmbedSnippet(decodeHtmlEntities(jsCode));
|
|
99
|
+
|
|
100
|
+
return { embedCode, embedCodeJS };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const iframeCode = brightcoveEmbedCode(iframeConfig);
|
|
104
|
+
const embedCode = formatEmbedSnippet(decodeHtmlEntities(iframeCode));
|
|
105
|
+
|
|
106
|
+
// Generate JavaScript embed code
|
|
107
|
+
const jsConfig = Object.assign(
|
|
108
|
+
{},
|
|
109
|
+
{
|
|
110
|
+
...defaultConfig,
|
|
111
|
+
...baseConfig,
|
|
112
|
+
...normalizedEmbedProperties,
|
|
113
|
+
iframe: false,
|
|
114
|
+
},
|
|
115
|
+
);
|
|
116
|
+
const jsCode = brightcoveEmbedCode(jsConfig);
|
|
117
|
+
const embedCodeJS = formatEmbedSnippet(decodeHtmlEntities(jsCode));
|
|
118
|
+
|
|
119
|
+
return { embedCode, embedCodeJS };
|
|
120
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_PLAYER_ID,
|
|
3
|
+
FAVORITE_PLAYER_SETTING,
|
|
4
|
+
} from 'js/constants/player';
|
|
5
|
+
|
|
6
|
+
const getStudioModule = () => window.StudioModule;
|
|
7
|
+
const getUser = () => getStudioModule()?.getUser();
|
|
8
|
+
|
|
9
|
+
// Gets the favorite player in a user's account
|
|
10
|
+
// If the setting value is not found, use default player
|
|
11
|
+
export const getFavoritePlayer = (): string => {
|
|
12
|
+
const user = getUser();
|
|
13
|
+
const favoritePlayerSetting =
|
|
14
|
+
user.currentAccount.settings.account[FAVORITE_PLAYER_SETTING];
|
|
15
|
+
return (favoritePlayerSetting?.values as string) ?? DEFAULT_PLAYER_ID;
|
|
16
|
+
};
|