@glomex/integration-react 1.1507.1 → 1.1508.1

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.
@@ -2,7 +2,7 @@ import { type MediaItem } from '@glomex/integration-web-component';
2
2
  declare module 'react/jsx-runtime' {
3
3
  namespace JSX {
4
4
  interface IntrinsicElements {
5
- 'glomex-external-media-item': JSX.IntrinsicElements['div'] & {
5
+ 'external-media-item': JSX.IntrinsicElements['div'] & {
6
6
  poster?: string;
7
7
  duration?: number;
8
8
  };
@@ -12,4 +12,4 @@ declare module 'react/jsx-runtime' {
12
12
  /**
13
13
  * React component to define an external media item.
14
14
  */
15
- export declare const ExternalMediaItemReact: (mediaItem: MediaItem) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const ExternalMediaItemReact: (mediaItem?: MediaItem) => import("react/jsx-runtime").JSX.Element;
@@ -4,5 +4,5 @@ import { ScriptType } from '@glomex/integration-web-component';
4
4
  * React component to define an external media item.
5
5
  */
6
6
  export const ExternalMediaItemReact = (mediaItem) => {
7
- return (_jsx("glomex-external-media-item", { id: mediaItem.id, poster: mediaItem.poster, duration: mediaItem.duration, "channel-name": mediaItem.channel?.name, "channel-logo": mediaItem.channel?.logo, title: mediaItem.title, "aspect-ratio": mediaItem.aspectRatio, "minimum-age": mediaItem.minimumAge, "release-date": mediaItem.releaseDate, "has-product-placement": mediaItem.hasProductPlacement, children: mediaItem ? (_jsx("script", { type: ScriptType.EXTERNAL_MEDIA_ITEM, children: JSON.stringify(mediaItem) })) : null }));
7
+ return (_jsx("external-media-item", { children: _jsx("script", { type: ScriptType.EXTERNAL_MEDIA_ITEM, children: JSON.stringify(mediaItem || []) }) }));
8
8
  };
@@ -1,9 +1,9 @@
1
- import { type GlomexMediaItemWithOverrides } from '@glomex/integration-web-component';
1
+ import { type MediaItem } from '@glomex/integration-web-component';
2
2
  declare module 'react/jsx-runtime' {
3
3
  namespace JSX {
4
4
  interface IntrinsicElements {
5
5
  'glomex-media-item': JSX.IntrinsicElements['div'] & {
6
- poster?: string;
6
+ environment?: string;
7
7
  };
8
8
  }
9
9
  }
@@ -11,7 +11,8 @@ declare module 'react/jsx-runtime' {
11
11
  /**
12
12
  * React component to define a glomex media item.
13
13
  */
14
- export declare const GlomexMediaItemReact: (item: {
14
+ export declare const GlomexMediaItemReact: (props: {
15
15
  id: string;
16
- overrides?: GlomexMediaItemWithOverrides["overrides"];
16
+ environment?: string;
17
+ item?: Partial<MediaItem>;
17
18
  }) => import("react/jsx-runtime").JSX.Element;
@@ -3,7 +3,7 @@ import { ScriptType } from '@glomex/integration-web-component';
3
3
  /**
4
4
  * React component to define a glomex media item.
5
5
  */
6
- export const GlomexMediaItemReact = (item) => {
7
- const { id: mediaItemId, overrides: mediaItemOverrides } = item;
8
- return (_jsx("glomex-media-item", { id: mediaItemId, ...(mediaItemOverrides?.title && { title: mediaItemOverrides.title }), ...(mediaItemOverrides?.poster && { poster: mediaItemOverrides.poster }), children: _jsx("script", { type: ScriptType.EXTERNAL_MEDIA_ITEM, children: JSON.stringify(mediaItemOverrides || {}) }) }));
6
+ export const GlomexMediaItemReact = (props) => {
7
+ const { id: mediaItemId, item } = props;
8
+ return (_jsx("glomex-media-item", { id: mediaItemId, environment: props.environment, children: item && _jsx("script", { type: ScriptType.EXTERNAL_MEDIA_ITEM, children: JSON.stringify(item) }) }));
9
9
  };
@@ -1,4 +1,4 @@
1
- import { type GlomexMediaItemWithOverrides, type IntegrationElement, type IntegrationProperties, type MediaItem } from '@glomex/integration-web-component';
1
+ import { type IntegrationElement, type IntegrationProperties, type MediaItem, type MediaItemReference } from '@glomex/integration-web-component';
2
2
  import { type CSSProperties } from 'react';
3
3
  declare module 'react/jsx-runtime' {
4
4
  namespace JSX {
@@ -23,7 +23,7 @@ declare module 'react/jsx-runtime' {
23
23
  */
24
24
  export declare const Integration: import("react").ForwardRefExoticComponent<IntegrationProperties & {
25
25
  id?: string;
26
- mediaItems?: (string | GlomexMediaItemWithOverrides | MediaItem)[];
26
+ mediaItems?: (MediaItem | MediaItemReference)[];
27
27
  preventLoadIntegration?: boolean;
28
28
  configs?: Record<string, unknown>;
29
29
  style?: CSSProperties;
@@ -1,13 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { ComponentName, getIntegrationCssUrl, loadIntegrationComponent, ScriptType } from '@glomex/integration-web-component';
2
+ import { ComponentName, getIntegrationCssUrl, loadIntegrationComponent, normalizeMediaItem, ScriptType } from '@glomex/integration-web-component';
3
3
  import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
4
4
  import { ExternalMediaItemReact } from './external-media-item-react.js';
5
5
  import { GlomexMediaItemReact } from './glomex-media-item-react.js';
6
- function isGlomexMediaItem(item) {
7
- return (typeof item === 'object' &&
8
- item !== null &&
9
- ('overrides' in item || (Object.keys(item).length === 1 && 'id' in item)));
10
- }
6
+ import { JoynMediaItemReact } from './joyn-media-item-react.js';
11
7
  /**
12
8
  * React component for the integration.
13
9
  *
@@ -20,14 +16,16 @@ export const Integration = forwardRef((props, ref) => {
20
16
  throw new Error('Cannot specify both mediaItems and playlistId');
21
17
  }
22
18
  const mediaItemComponents = (mediaItems || []).map((item, index) => {
23
- const keyIndex = index + 1;
24
- if (typeof item === 'string') {
25
- return _jsx(GlomexMediaItemReact, { id: item }, `${item}-${keyIndex}`);
19
+ const ref = normalizeMediaItem(item);
20
+ const key = `${ref.id}-${index + 1}`;
21
+ switch (ref.provider) {
22
+ case 'glomex':
23
+ return (_jsx(GlomexMediaItemReact, { id: ref.id, environment: ref.environment, item: ref.item }, key));
24
+ case 'joyn':
25
+ return (_jsx(JoynMediaItemReact, { id: ref.id, environment: ref.environment, item: ref.item }, key));
26
+ default:
27
+ return _jsx(ExternalMediaItemReact, { ...ref.item }, key);
26
28
  }
27
- if (isGlomexMediaItem(item)) {
28
- return (_jsx(GlomexMediaItemReact, { id: item.id, overrides: item.overrides }, `${item.id}-${keyIndex}`));
29
- }
30
- return _jsx(ExternalMediaItemReact, { ...item }, `${item.id}-${keyIndex}`);
31
29
  });
32
30
  useEffect(() => {
33
31
  if (preventLoadIntegration)
@@ -0,0 +1,18 @@
1
+ import { type MediaItem } from '@glomex/integration-web-component';
2
+ declare module 'react/jsx-runtime' {
3
+ namespace JSX {
4
+ interface IntrinsicElements {
5
+ 'joyn-media-item': JSX.IntrinsicElements['div'] & {
6
+ environment?: string;
7
+ };
8
+ }
9
+ }
10
+ }
11
+ /**
12
+ * React component to define a glomex media item.
13
+ */
14
+ export declare const JoynMediaItemReact: (props: {
15
+ id: string;
16
+ environment?: string;
17
+ item?: Partial<MediaItem>;
18
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ScriptType } from '@glomex/integration-web-component';
3
+ /**
4
+ * React component to define a glomex media item.
5
+ */
6
+ export const JoynMediaItemReact = (props) => {
7
+ const { id: mediaItemId, item } = props;
8
+ return (_jsx("joyn-media-item", { id: mediaItemId, environment: props.environment, children: item && _jsx("script", { type: ScriptType.EXTERNAL_MEDIA_ITEM, children: JSON.stringify(item) }) }));
9
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glomex/integration-react",
3
- "version": "1.1507.1",
3
+ "version": "1.1508.1",
4
4
  "description": "React component to integrate the glomex player",
5
5
  "documentation": "https://docs.glomex.com",
6
6
  "homepage": "https://glomex.com",
@@ -23,12 +23,12 @@
23
23
  ],
24
24
  "scripts": {
25
25
  "prepack": "npm run build",
26
- "build": "rm -rf build && tsc --build",
26
+ "build": "rm -rf dist && tsc --build --force",
27
27
  "lint": "tsc --noEmit && biome ci",
28
28
  "watch": "tsc --build --watch"
29
29
  },
30
30
  "dependencies": {
31
- "@glomex/integration-web-component": "1.1507.1"
31
+ "@glomex/integration-web-component": "1.1508.1"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "preact": ">=10",
@@ -57,5 +57,5 @@
57
57
  "preact": "catalog:",
58
58
  "typescript": "catalog:"
59
59
  },
60
- "gitHead": "07fe5c36d239ea603c322391ff72fc379ee5c041"
60
+ "gitHead": "b6ee0e2d31bcc5c9a2616cdbcea98ce1b2b7e1ea"
61
61
  }