@glomex/integration-react 1.1531.0 → 1.1532.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/integration-react.d.ts +42 -10
- package/dist/integration-react.js +49 -9
- package/package.json +4 -3
|
@@ -1,24 +1,50 @@
|
|
|
1
1
|
import { type IntegrationElement, type IntegrationProperties, type MediaItem, type MediaItemReference } from '@glomex/integration-web-component';
|
|
2
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
|
+
tenant?: string;
|
|
9
|
+
'integration-id'?: string;
|
|
10
|
+
'playlist-id'?: string;
|
|
11
|
+
'top-level-iframe'?: boolean;
|
|
12
|
+
'user-language'?: string;
|
|
13
|
+
'ad-player'?: string;
|
|
14
|
+
env?: string;
|
|
15
|
+
variant?: string;
|
|
16
|
+
crossorigin?: string;
|
|
17
|
+
hidden?: boolean;
|
|
18
|
+
};
|
|
3
19
|
declare module 'react/jsx-runtime' {
|
|
4
20
|
namespace JSX {
|
|
5
21
|
interface IntrinsicElements {
|
|
6
|
-
'glomex-integration':
|
|
7
|
-
|
|
8
|
-
children?: React.ReactNode;
|
|
9
|
-
index?: number;
|
|
10
|
-
placement?: string;
|
|
11
|
-
'integration-id'?: string;
|
|
12
|
-
'playlist-id'?: string;
|
|
13
|
-
'top-level-iframe'?: boolean;
|
|
14
|
-
hidden?: boolean;
|
|
15
|
-
};
|
|
22
|
+
'glomex-integration': IntegrationIntrinsicProps;
|
|
23
|
+
'turbo-integration': IntegrationIntrinsicProps;
|
|
16
24
|
}
|
|
17
25
|
}
|
|
18
26
|
}
|
|
19
27
|
/**
|
|
20
28
|
* React component for the integration.
|
|
21
29
|
*
|
|
30
|
+
* By default renders a `<glomex-integration>` custom element (tenant `"glomex"`).
|
|
31
|
+
* When `tenant="joyn"` is passed, renders a `<turbo-integration>` element instead
|
|
32
|
+
* and loads scripts/CSS from the joyn CDN.
|
|
33
|
+
*
|
|
34
|
+
* @example Default (glomex)
|
|
35
|
+
* ```tsx
|
|
36
|
+
* <Integration integrationId="my-integration">
|
|
37
|
+
* <glomex-media-item id="MEDIA_ID" />
|
|
38
|
+
* </Integration>
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @example Joyn tenant (stage)
|
|
42
|
+
* ```tsx
|
|
43
|
+
* <Integration tenant="joyn" env="stage" integrationId="joyn-vod">
|
|
44
|
+
* <joyn-media-item id="MEDIA_ID" />
|
|
45
|
+
* </Integration>
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
22
48
|
* @see {@link IntegrationElementEventMap} for all available events.
|
|
23
49
|
*/
|
|
24
50
|
export declare const Integration: import("react").ForwardRefExoticComponent<IntegrationProperties & {
|
|
@@ -27,6 +53,12 @@ export declare const Integration: import("react").ForwardRefExoticComponent<Inte
|
|
|
27
53
|
preventLoadIntegration?: boolean;
|
|
28
54
|
configs?: Record<string, unknown>;
|
|
29
55
|
style?: CSSProperties;
|
|
56
|
+
/**
|
|
57
|
+
* Override the custom element tag name (e.g. `'turbo-integration'`).
|
|
58
|
+
* When omitted the tag is derived from the `tenant` prop.
|
|
59
|
+
*/
|
|
60
|
+
componentName?: string;
|
|
30
61
|
} & {
|
|
31
62
|
children?: import("react").ReactNode | undefined;
|
|
32
63
|
} & import("react").RefAttributes<IntegrationElement>>;
|
|
64
|
+
export {};
|
|
@@ -1,17 +1,36 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import {
|
|
3
|
-
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
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
4
|
import { ExternalMediaItemReact } from './external-media-item-react.js';
|
|
5
5
|
import { GlomexMediaItemReact } from './glomex-media-item-react.js';
|
|
6
6
|
import { JoynMediaItemReact } from './joyn-media-item-react.js';
|
|
7
7
|
/**
|
|
8
8
|
* React component for the 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.
|
|
13
|
+
*
|
|
14
|
+
* @example Default (glomex)
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <Integration integrationId="my-integration">
|
|
17
|
+
* <glomex-media-item id="MEDIA_ID" />
|
|
18
|
+
* </Integration>
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
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
|
+
*
|
|
10
28
|
* @see {@link IntegrationElementEventMap} for all available events.
|
|
11
29
|
*/
|
|
12
30
|
export const Integration = forwardRef((props, ref) => {
|
|
13
|
-
const { children, integrationId, playlistId, index, hidden, topLevelIframe, placement, mediaItems, configs, preventLoadIntegration, extraContext, userLanguage, ...rest } = props;
|
|
31
|
+
const { children, integrationId, playlistId, index, hidden, topLevelIframe, placement, tenant, env, mediaItems, configs, preventLoadIntegration, extraContext, userLanguage, componentName: componentNameOverride, ...rest } = props;
|
|
14
32
|
const elementRef = useRef(null);
|
|
33
|
+
const componentName = componentNameOverride || getIntegrationComponentName(tenant);
|
|
15
34
|
if (mediaItems && playlistId) {
|
|
16
35
|
throw new Error('Cannot specify both mediaItems and playlistId');
|
|
17
36
|
}
|
|
@@ -30,8 +49,8 @@ export const Integration = forwardRef((props, ref) => {
|
|
|
30
49
|
useEffect(() => {
|
|
31
50
|
if (preventLoadIntegration)
|
|
32
51
|
return;
|
|
33
|
-
loadIntegrationComponent();
|
|
34
|
-
}, [preventLoadIntegration]);
|
|
52
|
+
loadIntegrationComponent(tenant, env);
|
|
53
|
+
}, [preventLoadIntegration, tenant, env]);
|
|
35
54
|
useImperativeHandle(ref, () => {
|
|
36
55
|
const element = elementRef.current;
|
|
37
56
|
element.extraContext = extraContext;
|
|
@@ -39,9 +58,30 @@ export const Integration = forwardRef((props, ref) => {
|
|
|
39
58
|
element.ready =
|
|
40
59
|
elementRef.current?.ready ||
|
|
41
60
|
new Promise((resolve) => window.customElements
|
|
42
|
-
.whenDefined(
|
|
61
|
+
.whenDefined(componentName)
|
|
43
62
|
.then(() => elementRef.current?.ready.then(() => resolve())));
|
|
44
63
|
return element;
|
|
45
|
-
}, [extraContext]);
|
|
46
|
-
|
|
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
|
+
tenant,
|
|
75
|
+
env,
|
|
76
|
+
'user-language': userLanguage,
|
|
77
|
+
...rest
|
|
78
|
+
};
|
|
79
|
+
const elementChildren = [
|
|
80
|
+
...mediaItemComponents,
|
|
81
|
+
children,
|
|
82
|
+
configs
|
|
83
|
+
? createElement('script', { type: ScriptType.INTEGRATION_CONFIGS }, JSON.stringify(configs))
|
|
84
|
+
: null
|
|
85
|
+
];
|
|
86
|
+
return createElement(Fragment, null, cssUrl ? createElement('link', { rel: 'stylesheet', href: cssUrl }) : null, createElement(componentName, elementProps, ...elementChildren));
|
|
47
87
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glomex/integration-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1532.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": "
|
|
31
|
+
"@glomex/integration-web-component": "1.1532.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"preact": ">=10",
|
|
@@ -56,5 +56,6 @@
|
|
|
56
56
|
"@types/react-dom": "^19.2.2",
|
|
57
57
|
"preact": "catalog:",
|
|
58
58
|
"typescript": "catalog:"
|
|
59
|
-
}
|
|
59
|
+
},
|
|
60
|
+
"gitHead": "60743cdfa3c12ee68a9559f2a3d7af85c0ca8408"
|
|
60
61
|
}
|