@brightcove/components-embed-code-modal 1.1.0 → 1.1.2

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 (187) hide show
  1. package/__tests__/PrismPlayerControls.test.d.ts +2 -0
  2. package/__tests__/PrismPlayerControls.test.d.ts.map +1 -0
  3. package/{build/index.js → index.js} +1 -1
  4. package/index.js.map +1 -0
  5. package/package.json +5 -15
  6. package/{build/src → src}/js/components/prism/PrismPlayerControls.d.ts.map +1 -1
  7. package/.eslintignore +0 -7
  8. package/.eslintrc +0 -23
  9. package/.github/workflows/ci.yml +0 -23
  10. package/.husky/pre-commit +0 -4
  11. package/.nvmrc +0 -1
  12. package/.prettierignore +0 -7
  13. package/.prettierrc +0 -5
  14. package/.release-it.json +0 -40
  15. package/.whitesource +0 -3
  16. package/CHANGELOG.md +0 -398
  17. package/CODEOWNERS +0 -37
  18. package/PULL_REQUEST_TEMPLATE.md +0 -17
  19. package/__tests__/EmbedCode.test.tsx +0 -51
  20. package/__tests__/InteractivityProject.test.tsx +0 -50
  21. package/__tests__/PlayerPreview.test.tsx +0 -23
  22. package/__tests__/PrismPlayerPreview.test.tsx +0 -168
  23. package/__tests__/TabsHeader.test.tsx +0 -19
  24. package/__tests__/TabsSection.test.tsx +0 -46
  25. package/__tests__/TitleWithTooltip.test.tsx +0 -45
  26. package/__tests__/VideoPlayer.test.tsx +0 -38
  27. package/__tests__/embedCodeGenerator.test.ts +0 -111
  28. package/__tests__/util.test.ts +0 -89
  29. package/babel.config.json +0 -17
  30. package/build/README.md +0 -109
  31. package/build/index.js.map +0 -1
  32. package/build/package.json +0 -100
  33. package/etc/wildcard.brightcove.com.key +0 -27
  34. package/etc/wildcard.brightcove.com.pem +0 -96
  35. package/jest/jest.setup.js +0 -90
  36. package/jest/jest.stub.js +0 -4
  37. package/jest.config.js +0 -24
  38. package/scripts/create-dist-pkg-prod.js +0 -18
  39. package/src/index.ts +0 -17
  40. package/src/js/EmbedCodeModal.tsx +0 -105
  41. package/src/js/components/CustomSettingsDropdown.tsx +0 -184
  42. package/src/js/components/EmbedCopySection.tsx +0 -130
  43. package/src/js/components/ModalContainer.tsx +0 -367
  44. package/src/js/components/NoPlayerModal.tsx +0 -42
  45. package/src/js/components/PlayerPreview.tsx +0 -116
  46. package/src/js/components/TabsHeader.tsx +0 -31
  47. package/src/js/components/TabsSection.tsx +0 -74
  48. package/src/js/components/TitleWithTooltip.tsx +0 -39
  49. package/src/js/components/VideoLinks.tsx +0 -83
  50. package/src/js/components/VideoPlayer.tsx +0 -324
  51. package/src/js/components/index.ts +0 -9
  52. package/src/js/components/prism/PrismLiveModal.tsx +0 -162
  53. package/src/js/components/prism/PrismPlayerControls.tsx +0 -343
  54. package/src/js/components/prism/PrismPlayerPreview.tsx +0 -188
  55. package/src/js/components/prism/index.ts +0 -3
  56. package/src/js/constants/baseUrls.ts +0 -4
  57. package/src/js/constants/embed.ts +0 -12
  58. package/src/js/constants/player.ts +0 -32
  59. package/src/js/constants/pluginsRegistry.ts +0 -30
  60. package/src/js/hooks/useGetPlayers.ts +0 -12
  61. package/src/js/i18n.ts +0 -43
  62. package/src/js/services/players-api.ts +0 -26
  63. package/src/js/services/url-shortener.ts +0 -10
  64. package/src/js/types/EmbedCodeModalProps.ts +0 -72
  65. package/src/js/types/EmbedCodeProps.ts +0 -13
  66. package/src/js/types/brightcoveEmbedCode.d.ts +0 -18
  67. package/src/js/types/players.ts +0 -64
  68. package/src/js/types/react-i18next.d.ts +0 -8
  69. package/src/js/types/studioModule.ts +0 -7
  70. package/src/js/utils/addPluginsDataToPlayers.ts +0 -59
  71. package/src/js/utils/call.ts +0 -31
  72. package/src/js/utils/dimensions.ts +0 -53
  73. package/src/js/utils/embedCodeGenerator.ts +0 -120
  74. package/src/js/utils/featureSwitches.ts +0 -16
  75. package/src/js/utils/util.ts +0 -153
  76. package/src/module.tsx +0 -280
  77. package/src/styles/CustomSettingsDropdown.sass +0 -42
  78. package/src/styles/EmbedCode.sass +0 -30
  79. package/src/styles/EmbedCodeModal.sass +0 -76
  80. package/src/styles/base.sass +0 -1
  81. package/src/styles/prism/PrismLiveModal.sass +0 -155
  82. package/src/styles/theme.sass +0 -11
  83. package/src/styles/typings.td.ts +0 -9
  84. package/src/translations/en.json +0 -65
  85. package/src/translations/es.json +0 -65
  86. package/src/translations/fr.json +0 -65
  87. package/src/translations/ja.json +0 -65
  88. package/src/translations/ko.json +0 -65
  89. package/src/translations/zh.json +0 -65
  90. package/src/types/studio.ts +0 -197
  91. package/tsconfig.json +0 -34
  92. package/webpack.config.js +0 -117
  93. /package/{build/__tests__ → __tests__}/EmbedCode.test.d.ts +0 -0
  94. /package/{build/__tests__ → __tests__}/EmbedCode.test.d.ts.map +0 -0
  95. /package/{build/__tests__ → __tests__}/InteractivityProject.test.d.ts +0 -0
  96. /package/{build/__tests__ → __tests__}/InteractivityProject.test.d.ts.map +0 -0
  97. /package/{build/__tests__ → __tests__}/PlayerPreview.test.d.ts +0 -0
  98. /package/{build/__tests__ → __tests__}/PlayerPreview.test.d.ts.map +0 -0
  99. /package/{build/__tests__ → __tests__}/PrismPlayerPreview.test.d.ts +0 -0
  100. /package/{build/__tests__ → __tests__}/PrismPlayerPreview.test.d.ts.map +0 -0
  101. /package/{build/__tests__ → __tests__}/TabsHeader.test.d.ts +0 -0
  102. /package/{build/__tests__ → __tests__}/TabsHeader.test.d.ts.map +0 -0
  103. /package/{build/__tests__ → __tests__}/TabsSection.test.d.ts +0 -0
  104. /package/{build/__tests__ → __tests__}/TabsSection.test.d.ts.map +0 -0
  105. /package/{build/__tests__ → __tests__}/TitleWithTooltip.test.d.ts +0 -0
  106. /package/{build/__tests__ → __tests__}/TitleWithTooltip.test.d.ts.map +0 -0
  107. /package/{build/__tests__ → __tests__}/VideoPlayer.test.d.ts +0 -0
  108. /package/{build/__tests__ → __tests__}/VideoPlayer.test.d.ts.map +0 -0
  109. /package/{build/__tests__ → __tests__}/embedCodeGenerator.test.d.ts +0 -0
  110. /package/{build/__tests__ → __tests__}/embedCodeGenerator.test.d.ts.map +0 -0
  111. /package/{build/__tests__ → __tests__}/util.test.d.ts +0 -0
  112. /package/{build/__tests__ → __tests__}/util.test.d.ts.map +0 -0
  113. /package/{build/src → src}/index.d.ts +0 -0
  114. /package/{build/src → src}/index.d.ts.map +0 -0
  115. /package/{build/src → src}/js/EmbedCodeModal.d.ts +0 -0
  116. /package/{build/src → src}/js/EmbedCodeModal.d.ts.map +0 -0
  117. /package/{build/src → src}/js/components/CustomSettingsDropdown.d.ts +0 -0
  118. /package/{build/src → src}/js/components/CustomSettingsDropdown.d.ts.map +0 -0
  119. /package/{build/src → src}/js/components/EmbedCopySection.d.ts +0 -0
  120. /package/{build/src → src}/js/components/EmbedCopySection.d.ts.map +0 -0
  121. /package/{build/src → src}/js/components/ModalContainer.d.ts +0 -0
  122. /package/{build/src → src}/js/components/ModalContainer.d.ts.map +0 -0
  123. /package/{build/src → src}/js/components/NoPlayerModal.d.ts +0 -0
  124. /package/{build/src → src}/js/components/NoPlayerModal.d.ts.map +0 -0
  125. /package/{build/src → src}/js/components/PlayerPreview.d.ts +0 -0
  126. /package/{build/src → src}/js/components/PlayerPreview.d.ts.map +0 -0
  127. /package/{build/src → src}/js/components/TabsHeader.d.ts +0 -0
  128. /package/{build/src → src}/js/components/TabsHeader.d.ts.map +0 -0
  129. /package/{build/src → src}/js/components/TabsSection.d.ts +0 -0
  130. /package/{build/src → src}/js/components/TabsSection.d.ts.map +0 -0
  131. /package/{build/src → src}/js/components/TitleWithTooltip.d.ts +0 -0
  132. /package/{build/src → src}/js/components/TitleWithTooltip.d.ts.map +0 -0
  133. /package/{build/src → src}/js/components/VideoLinks.d.ts +0 -0
  134. /package/{build/src → src}/js/components/VideoLinks.d.ts.map +0 -0
  135. /package/{build/src → src}/js/components/VideoPlayer.d.ts +0 -0
  136. /package/{build/src → src}/js/components/VideoPlayer.d.ts.map +0 -0
  137. /package/{build/src → src}/js/components/index.d.ts +0 -0
  138. /package/{build/src → src}/js/components/index.d.ts.map +0 -0
  139. /package/{build/src → src}/js/components/prism/PrismLiveModal.d.ts +0 -0
  140. /package/{build/src → src}/js/components/prism/PrismLiveModal.d.ts.map +0 -0
  141. /package/{build/src → src}/js/components/prism/PrismPlayerControls.d.ts +0 -0
  142. /package/{build/src → src}/js/components/prism/PrismPlayerPreview.d.ts +0 -0
  143. /package/{build/src → src}/js/components/prism/PrismPlayerPreview.d.ts.map +0 -0
  144. /package/{build/src → src}/js/components/prism/index.d.ts +0 -0
  145. /package/{build/src → src}/js/components/prism/index.d.ts.map +0 -0
  146. /package/{build/src → src}/js/constants/baseUrls.d.ts +0 -0
  147. /package/{build/src → src}/js/constants/baseUrls.d.ts.map +0 -0
  148. /package/{build/src → src}/js/constants/embed.d.ts +0 -0
  149. /package/{build/src → src}/js/constants/embed.d.ts.map +0 -0
  150. /package/{build/src → src}/js/constants/player.d.ts +0 -0
  151. /package/{build/src → src}/js/constants/player.d.ts.map +0 -0
  152. /package/{build/src → src}/js/constants/pluginsRegistry.d.ts +0 -0
  153. /package/{build/src → src}/js/constants/pluginsRegistry.d.ts.map +0 -0
  154. /package/{build/src → src}/js/hooks/useGetPlayers.d.ts +0 -0
  155. /package/{build/src → src}/js/hooks/useGetPlayers.d.ts.map +0 -0
  156. /package/{build/src → src}/js/i18n.d.ts +0 -0
  157. /package/{build/src → src}/js/i18n.d.ts.map +0 -0
  158. /package/{build/src → src}/js/services/players-api.d.ts +0 -0
  159. /package/{build/src → src}/js/services/players-api.d.ts.map +0 -0
  160. /package/{build/src → src}/js/services/url-shortener.d.ts +0 -0
  161. /package/{build/src → src}/js/services/url-shortener.d.ts.map +0 -0
  162. /package/{build/src → src}/js/types/EmbedCodeModalProps.d.ts +0 -0
  163. /package/{build/src → src}/js/types/EmbedCodeModalProps.d.ts.map +0 -0
  164. /package/{build/src → src}/js/types/EmbedCodeProps.d.ts +0 -0
  165. /package/{build/src → src}/js/types/EmbedCodeProps.d.ts.map +0 -0
  166. /package/{build/src → src}/js/types/players.d.ts +0 -0
  167. /package/{build/src → src}/js/types/players.d.ts.map +0 -0
  168. /package/{build/src → src}/js/types/studioModule.d.ts +0 -0
  169. /package/{build/src → src}/js/types/studioModule.d.ts.map +0 -0
  170. /package/{build/src → src}/js/utils/addPluginsDataToPlayers.d.ts +0 -0
  171. /package/{build/src → src}/js/utils/addPluginsDataToPlayers.d.ts.map +0 -0
  172. /package/{build/src → src}/js/utils/call.d.ts +0 -0
  173. /package/{build/src → src}/js/utils/call.d.ts.map +0 -0
  174. /package/{build/src → src}/js/utils/dimensions.d.ts +0 -0
  175. /package/{build/src → src}/js/utils/dimensions.d.ts.map +0 -0
  176. /package/{build/src → src}/js/utils/embedCodeGenerator.d.ts +0 -0
  177. /package/{build/src → src}/js/utils/embedCodeGenerator.d.ts.map +0 -0
  178. /package/{build/src → src}/js/utils/featureSwitches.d.ts +0 -0
  179. /package/{build/src → src}/js/utils/featureSwitches.d.ts.map +0 -0
  180. /package/{build/src → src}/js/utils/util.d.ts +0 -0
  181. /package/{build/src → src}/js/utils/util.d.ts.map +0 -0
  182. /package/{build/src → src}/module.d.ts +0 -0
  183. /package/{build/src → src}/module.d.ts.map +0 -0
  184. /package/{build/src → src}/styles/typings.td.d.ts +0 -0
  185. /package/{build/src → src}/styles/typings.td.d.ts.map +0 -0
  186. /package/{build/src → src}/types/studio.d.ts +0 -0
  187. /package/{build/src → src}/types/studio.d.ts.map +0 -0
@@ -1,10 +0,0 @@
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
- };
@@ -1,72 +0,0 @@
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
- }
@@ -1,13 +0,0 @@
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
- };
@@ -1,18 +0,0 @@
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
- }
@@ -1,64 +0,0 @@
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
- };
@@ -1,8 +0,0 @@
1
- import 'react-i18next';
2
- import { resources } from 'js/i18n';
3
-
4
- declare module 'react-i18next' {
5
- interface CustomTypeOptions {
6
- resources: typeof resources.en;
7
- }
8
- }
@@ -1,7 +0,0 @@
1
- import { StudioModule, StudioBrightcove } from 'types/studio';
2
- declare global {
3
- interface Window {
4
- StudioModule: StudioModule;
5
- brightcove: StudioBrightcove;
6
- }
7
- }
@@ -1,59 +0,0 @@
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
- }
@@ -1,31 +0,0 @@
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
- };
@@ -1,53 +0,0 @@
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
- };
@@ -1,120 +0,0 @@
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
- };
@@ -1,16 +0,0 @@
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
- };
@@ -1,153 +0,0 @@
1
- import {
2
- QA_URL,
3
- PROD_URL,
4
- QA_PREVIEW_URL,
5
- PROD_PREVIEW_URL,
6
- } from 'js/constants/baseUrls';
7
- import { StudioModule, StudioBrightcove } from 'types/studio';
8
- import { PlayerSelectItem } from '../types/players';
9
-
10
- const QA = 'qa';
11
- const PRODUCTION = 'production';
12
- const TITLE_CHAR_LIMIT = 60;
13
- export const ROLES = {
14
- PUBLISHING: 'PUBLISHING',
15
- };
16
- export const PREVIEW_URL_BASE = () => {
17
- const env = getStudioEnvironment();
18
- const envMap = {
19
- qa: '.qa',
20
- staging: '.staging',
21
- production: '',
22
- };
23
- return `//preview-players${envMap[env]}.brightcove.net/v2/accounts`;
24
- };
25
-
26
- /**
27
- * Get the studio environment as a string.
28
- * @returns the studio environment
29
- */
30
- export function getStudioEnvironment(): string {
31
- return window.StudioModule?.config.product.env || PRODUCTION;
32
- }
33
-
34
- /**
35
- * Is the module running in QA environment?
36
- */
37
- export function isQA() {
38
- return getStudioEnvironment() === QA;
39
- }
40
-
41
- /**
42
- * Gets the correct player url base depending on environment
43
- */
44
- export function getUrlBase() {
45
- return isQA() ? QA_URL : PROD_URL;
46
- }
47
-
48
- /**
49
- *
50
- * @param options : array of PlayerSelectItem
51
- * @returns options ordered ascending
52
- */
53
- export function sortAsc(options: PlayerSelectItem[]): PlayerSelectItem[] {
54
- return options.sort((a, b) => a.label.localeCompare(b.label));
55
- }
56
-
57
- export type VideoPreviewLinkOptions = {
58
- accountId: string;
59
- videoId?: string;
60
- interactivityProjectId?: string;
61
- playerId: string;
62
- adConfigId?: string;
63
- livePlaybackToken?: string;
64
- };
65
- /**
66
- *
67
- * @param accountId : accountId of current user
68
- * @param videoId : VideoPayload type info
69
- * @param interactivityProjectId : id of interactivity project
70
- * @param playerId : playerId used for preview
71
- * @returns a working preview link with given information
72
- * @param adConfigId : token for live playback
73
- * @param livePlaybackToken : token for live playback
74
- */
75
- export const getVideoPreviewLink = (options: VideoPreviewLinkOptions) => {
76
- const {
77
- accountId,
78
- videoId,
79
- interactivityProjectId,
80
- playerId,
81
- adConfigId,
82
- livePlaybackToken,
83
- } = options;
84
- const params = new URLSearchParams();
85
- if (interactivityProjectId) {
86
- params.append('interactivityProjectId', interactivityProjectId);
87
- }
88
-
89
- if (videoId) {
90
- params.append('videoId', videoId);
91
- }
92
-
93
- if (adConfigId) {
94
- params.append('adConfigId', adConfigId);
95
- }
96
-
97
- if (livePlaybackToken) {
98
- params.append('livePlaybackToken', livePlaybackToken);
99
- }
100
- const paramsString = params.toString();
101
- return `${getUrlBase()}${accountId}/${playerId}_default/index.html${
102
- paramsString !== '' ? `?${paramsString}` : ''
103
- }`;
104
- };
105
-
106
- /**
107
- * Truncates a video title property
108
- * @param videoName - video title
109
- * @returns truncated video title
110
- */
111
- export const truncateVideoTitle = (videoName: string): string => {
112
- if (videoName.length > TITLE_CHAR_LIMIT) {
113
- return `${videoName.substring(0, TITLE_CHAR_LIMIT).trim()}...`;
114
- }
115
- return videoName;
116
- };
117
-
118
- export function getPreviewUrlBase() {
119
- return isQA() ? QA_PREVIEW_URL : PROD_PREVIEW_URL;
120
- }
121
-
122
- /**
123
- *
124
- * @param accountId : account id of current user
125
- * @param playerId : playerId used for preview
126
- * @returns a working preview url with given information
127
- */
128
- export const getPreviewPlayerUrl = (
129
- accountId: string,
130
- playerId: string,
131
- ): string =>
132
- `${getPreviewUrlBase()}/v2/accounts/${accountId}/players/${playerId}/preview/embeds/default/master/index.html`;
133
-
134
- export const getStudioModule = (): StudioModule => window.StudioModule;
135
-
136
- export const getBrightcove = (): StudioBrightcove => window.brightcove;
137
-
138
- export function getProductPath(): string {
139
- return getStudioModule()?.config?.product?.path || '/products/videocloud';
140
- }
141
-
142
- /**
143
- * @returns Player Manager Module URL
144
- */
145
- export const getPlayerManagerModuleUrl = () => {
146
- return `${getProductPath()}/players`;
147
- };
148
-
149
- export const decodeHtmlEntities = (str: string) => {
150
- const textarea = document.createElement('textarea');
151
- textarea.innerHTML = str;
152
- return textarea.value;
153
- };