@glomex/integration-react 1.1544.1 → 1.1547.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/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from '@glomex/integration-web-component';
1
+ export * from '@turbo-player/integration-react';
2
2
  export { Integration } from './integration-react.js';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from '@glomex/integration-web-component';
1
+ export * from '@turbo-player/integration-react';
2
2
  export { Integration } from './integration-react.js';
@@ -1,65 +1,35 @@
1
- import { type IntegrationElement, type IntegrationProperties, type MediaItem, type MediaItemReference } from '@glomex/integration-web-component';
2
- import { type CSSProperties } from 'react';
3
- type IntegrationIntrinsicProps = Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'ref' | 'children'> & {
4
- ref?: React.Ref<IntegrationElement | null>;
5
- children?: React.ReactNode;
6
- index?: number;
7
- placement?: string;
8
- schain?: string;
9
- tenant?: string;
10
- 'integration-id'?: string;
11
- 'playlist-id'?: string;
12
- 'top-level-iframe'?: boolean;
13
- 'user-language'?: string;
14
- 'ad-player'?: string;
15
- env?: string;
16
- variant?: string;
17
- crossorigin?: string;
18
- hidden?: boolean;
19
- };
20
- declare module 'react/jsx-runtime' {
21
- namespace JSX {
22
- interface IntrinsicElements {
23
- 'glomex-integration': IntegrationIntrinsicProps;
24
- 'turbo-integration': IntegrationIntrinsicProps;
25
- }
26
- }
27
- }
1
+ import { type IntegrationElement } from '@turbo-player/integration-react';
28
2
  /**
29
- * React component for the integration.
3
+ * React component for the glomex integration.
30
4
  *
31
- * By default renders a `<glomex-integration>` custom element (tenant `"glomex"`).
32
- * When `tenant="joyn"` is passed, renders a `<turbo-integration>` element instead
33
- * and loads scripts/CSS from the joyn CDN.
5
+ * Renders a `<glomex-integration>` custom element and loads
6
+ * scripts/CSS from the glomex CDN.
34
7
  *
35
- * @example Default (glomex)
8
+ * @example
36
9
  * ```tsx
37
- * <Integration integrationId="my-integration">
10
+ * <Integration integrationId="your-integration-id">
38
11
  * <glomex-media-item id="MEDIA_ID" />
39
12
  * </Integration>
40
13
  * ```
41
14
  *
42
- * @example Joyn tenant (stage)
43
- * ```tsx
44
- * <Integration tenant="joyn" env="stage" integrationId="joyn-vod">
45
- * <joyn-media-item id="MEDIA_ID" />
46
- * </Integration>
47
- * ```
48
- *
49
15
  * @see {@link IntegrationElementEventMap} for all available events.
50
16
  */
51
- export declare const Integration: import("react").ForwardRefExoticComponent<IntegrationProperties & {
17
+ export declare const Integration: import("react").ForwardRefExoticComponent<Omit<import("react").HTMLAttributes<HTMLElement> & import("@turbo-player/integration-react").IntegrationProperties & {
52
18
  id?: string;
53
- mediaItems?: (MediaItem | MediaItemReference)[];
54
- preventLoadIntegration?: boolean;
19
+ moduleUrl?: string;
20
+ tagName: string;
21
+ stylesUrl?: string;
22
+ mediaItems?: (import("@turbo-player/integration-react").MediaItem | import("@turbo-player/integration-react").MediaItemReference)[];
55
23
  configs?: Record<string, unknown>;
56
- style?: CSSProperties;
57
- /**
58
- * Override the custom element tag name (e.g. `'turbo-integration'`).
59
- * When omitted the tag is derived from the `tenant` prop.
60
- */
61
- componentName?: string;
24
+ sharedContextData?: import("@turbo-player/integration-react").SharedContextData;
62
25
  } & {
63
26
  children?: import("react").ReactNode | undefined;
27
+ } & import("react").RefAttributes<IntegrationElement>, "tagName" | "ref"> & {
28
+ /**
29
+ * Override the custom element tag name rendered by the integration.
30
+ * Defaults to `'glomex-integration'`.
31
+ *
32
+ * @example 'your-integration'
33
+ */
34
+ tagName?: string;
64
35
  } & import("react").RefAttributes<IntegrationElement>>;
65
- export {};
@@ -1,88 +1,25 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { getIntegrationComponentName, getIntegrationCssUrl, loadIntegrationComponent, normalizeMediaItem, ScriptType } from '@glomex/integration-web-component';
3
- import { createElement, Fragment, forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
4
- import { ExternalMediaItemReact } from './external-media-item-react.js';
5
- import { GlomexMediaItemReact } from './glomex-media-item-react.js';
6
- import { JoynMediaItemReact } from './joyn-media-item-react.js';
2
+ import { Integration as TurboIntegration } from '@turbo-player/integration-react';
3
+ import { forwardRef } from 'react';
4
+ const MODULE_URL = 'https://player.glomex.com/integration/1/integration.js';
5
+ const STYLES_URL = 'https://player.glomex.com/variant/{id}/variant.css';
6
+ const TAG_NAME = 'glomex-integration';
7
7
  /**
8
- * React component for the integration.
8
+ * React component for the glomex integration.
9
9
  *
10
- * By default renders a `<glomex-integration>` custom element (tenant `"glomex"`).
11
- * When `tenant="joyn"` is passed, renders a `<turbo-integration>` element instead
12
- * and loads scripts/CSS from the joyn CDN.
10
+ * Renders a `<glomex-integration>` custom element and loads
11
+ * scripts/CSS from the glomex CDN.
13
12
  *
14
- * @example Default (glomex)
13
+ * @example
15
14
  * ```tsx
16
- * <Integration integrationId="my-integration">
15
+ * <Integration integrationId="your-integration-id">
17
16
  * <glomex-media-item id="MEDIA_ID" />
18
17
  * </Integration>
19
18
  * ```
20
19
  *
21
- * @example Joyn tenant (stage)
22
- * ```tsx
23
- * <Integration tenant="joyn" env="stage" integrationId="joyn-vod">
24
- * <joyn-media-item id="MEDIA_ID" />
25
- * </Integration>
26
- * ```
27
- *
28
20
  * @see {@link IntegrationElementEventMap} for all available events.
29
21
  */
30
22
  export const Integration = forwardRef((props, ref) => {
31
- const { children, integrationId, playlistId, index, hidden, topLevelIframe, placement, schain, tenant, env, mediaItems, configs, preventLoadIntegration, extraContext, userLanguage, componentName: componentNameOverride, ...rest } = props;
32
- const elementRef = useRef(null);
33
- const componentName = componentNameOverride || getIntegrationComponentName(tenant);
34
- if (mediaItems && playlistId) {
35
- throw new Error('Cannot specify both mediaItems and playlistId');
36
- }
37
- const mediaItemComponents = (mediaItems || []).map((item, index) => {
38
- const ref = normalizeMediaItem(item);
39
- const key = `${ref.id}-${index + 1}`;
40
- switch (ref.provider) {
41
- case 'glomex':
42
- return (_jsx(GlomexMediaItemReact, { id: ref.id, environment: ref.environment, item: ref.item }, key));
43
- case 'joyn':
44
- return (_jsx(JoynMediaItemReact, { id: ref.id, environment: ref.environment, item: ref.item }, key));
45
- default:
46
- return _jsx(ExternalMediaItemReact, { ...ref.item }, key);
47
- }
48
- });
49
- useEffect(() => {
50
- if (preventLoadIntegration)
51
- return;
52
- loadIntegrationComponent(tenant, env);
53
- }, [preventLoadIntegration, tenant, env]);
54
- useImperativeHandle(ref, () => {
55
- const element = elementRef.current;
56
- element.extraContext = extraContext;
57
- // patch ready when integration element was not upgraded yet
58
- element.ready =
59
- elementRef.current?.ready ||
60
- new Promise((resolve) => window.customElements
61
- .whenDefined(componentName)
62
- .then(() => elementRef.current?.ready.then(() => resolve())));
63
- return element;
64
- }, [extraContext, componentName]);
65
- const cssUrl = integrationId ? getIntegrationCssUrl(integrationId, tenant, env) : undefined;
66
- const elementProps = {
67
- ref: elementRef,
68
- 'integration-id': integrationId,
69
- 'playlist-id': playlistId,
70
- index,
71
- hidden,
72
- 'top-level-iframe': topLevelIframe,
73
- placement,
74
- schain,
75
- tenant,
76
- env,
77
- 'user-language': userLanguage,
78
- ...rest
79
- };
80
- const elementChildren = [
81
- ...mediaItemComponents,
82
- children,
83
- configs
84
- ? createElement('script', { type: ScriptType.INTEGRATION_CONFIGS }, JSON.stringify(configs))
85
- : null
86
- ];
87
- return createElement(Fragment, null, cssUrl ? createElement('link', { rel: 'stylesheet', href: cssUrl }) : null, createElement(componentName, elementProps, ...elementChildren));
23
+ const { tagName, stylesUrl, moduleUrl, ...rest } = props;
24
+ return (_jsx(TurboIntegration, { ref: ref, tagName: tagName ?? TAG_NAME, moduleUrl: moduleUrl ? moduleUrl : MODULE_URL, stylesUrl: stylesUrl ?? STYLES_URL, ...rest }));
88
25
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glomex/integration-react",
3
- "version": "1.1544.1",
3
+ "version": "1.1547.0",
4
4
  "description": "React component to integrate the glomex player",
5
5
  "documentation": "https://docs.glomex.com",
6
6
  "homepage": "https://glomex.com",
@@ -28,7 +28,7 @@
28
28
  "watch": "tsc --build --watch"
29
29
  },
30
30
  "dependencies": {
31
- "@glomex/integration-web-component": "1.1544.1"
31
+ "@turbo-player/integration-react": "1.1547.0"
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": "82c04eec4783512f0249d25ae4f6af11f6608b72"
60
+ "gitHead": "ae6260568f515b6806d9b486876886f1f842e98d"
61
61
  }
@@ -1,15 +0,0 @@
1
- import { type MediaItem } from '@glomex/integration-web-component';
2
- declare module 'react/jsx-runtime' {
3
- namespace JSX {
4
- interface IntrinsicElements {
5
- 'external-media-item': JSX.IntrinsicElements['div'] & {
6
- poster?: string;
7
- duration?: number;
8
- };
9
- }
10
- }
11
- }
12
- /**
13
- * React component to define an external media item.
14
- */
15
- export declare const ExternalMediaItemReact: (mediaItem?: MediaItem) => import("react/jsx-runtime").JSX.Element;
@@ -1,8 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ScriptType } from '@glomex/integration-web-component';
3
- /**
4
- * React component to define an external media item.
5
- */
6
- export const ExternalMediaItemReact = (mediaItem) => {
7
- return (_jsx("external-media-item", { children: _jsx("script", { type: ScriptType.EXTERNAL_MEDIA_ITEM, children: JSON.stringify(mediaItem || []) }) }));
8
- };
@@ -1,18 +0,0 @@
1
- import { type MediaItem } from '@glomex/integration-web-component';
2
- declare module 'react/jsx-runtime' {
3
- namespace JSX {
4
- interface IntrinsicElements {
5
- 'glomex-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 GlomexMediaItemReact: (props: {
15
- id: string;
16
- environment?: string;
17
- item?: Partial<MediaItem>;
18
- }) => import("react/jsx-runtime").JSX.Element;
@@ -1,9 +0,0 @@
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 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
- };
@@ -1,18 +0,0 @@
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;
@@ -1,9 +0,0 @@
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
- };