@glomex/integration-react 1.1299.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/README.md +64 -0
- package/build/external-media-item-react.d.ts +17 -0
- package/build/external-media-item-react.js +8 -0
- package/build/glomex-media-item-react.d.ts +27 -0
- package/build/glomex-media-item-react.js +8 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +3 -0
- package/build/integration-react.d.ts +34 -0
- package/build/integration-react.js +34 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# @glomex/integration-react
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
`@glomex/integration-react` exposes a React component and types to easily integrate the glomex player. In order to use this component, you need to have a glomex account. You can get one by following the instructions in the [Getting Started](https://docs.glomex.com/publisher/getting-started) section.
|
|
6
|
+
|
|
7
|
+
## About glomex
|
|
8
|
+
|
|
9
|
+
[glomex](https://glomex.com) operates Germany’s largest marketplace for premium video content. Our platform connects publishers, content creators, and advertisers, enabling the seamless distribution of high-quality video content across the web.
|
|
10
|
+
|
|
11
|
+
Our ecosystem is designed to create value for all participants:
|
|
12
|
+
|
|
13
|
+
- **Publishers** gain access to premium video content and monetization opportunities
|
|
14
|
+
- **Content Owners** receive wide distribution and revenue for their video assets
|
|
15
|
+
- **Advertisers** reach targeted audiences across a network of quality websites
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### Loading & integrating the player
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { type React, useRef } from 'react';
|
|
23
|
+
import { IntegrationReact, IntegrationEvent } from '@glomex/integration-react';
|
|
24
|
+
|
|
25
|
+
const MyApp = () => {
|
|
26
|
+
const integrationRef = useRef<React.ElementRef<typeof IntegrationReact>>(null);
|
|
27
|
+
|
|
28
|
+
const handlePlay = () => {
|
|
29
|
+
integrationRef.current?.play();
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const handleContentStart = () => {
|
|
33
|
+
console.log('content start', integrationRef.current?.content);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
integrationRef.current?.addEventListener(
|
|
38
|
+
IntegrationEvent.CONTENT_START,
|
|
39
|
+
handleContentStart
|
|
40
|
+
);
|
|
41
|
+
return () => {
|
|
42
|
+
integrationRef.current?.removeEventListener(
|
|
43
|
+
IntegrationEvent.CONTENT_START,
|
|
44
|
+
handleContentStart
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
}, [integrationRef]);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<div>
|
|
51
|
+
<IntegrationReact
|
|
52
|
+
ref={integrationRef}
|
|
53
|
+
integrationId="FILL_IN_INTEGRATION_ID"
|
|
54
|
+
playlistId="FILL_IN_PLAYLIST_ID"
|
|
55
|
+
/>
|
|
56
|
+
<button type="button" onClick={handlePlay}>
|
|
57
|
+
Play
|
|
58
|
+
</button>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default MyApp;
|
|
64
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ExternalMediaItemElement, type MediaItem, type MinimalMediaItem } from '@glomex/integration-web-component';
|
|
2
|
+
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
|
|
3
|
+
declare global {
|
|
4
|
+
namespace JSX {
|
|
5
|
+
interface IntrinsicElements {
|
|
6
|
+
'glomex-external-media-item': DetailedHTMLProps<HTMLAttributes<ExternalMediaItemElement> & {
|
|
7
|
+
poster?: string;
|
|
8
|
+
duration?: number;
|
|
9
|
+
type?: string;
|
|
10
|
+
}, ExternalMediaItemElement>;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* React component to define an external media item.
|
|
16
|
+
*/
|
|
17
|
+
export declare const ExternalMediaItemReact: (mediaItem: MediaItem | MinimalMediaItem) => JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
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("glomex-external-media-item", { id: mediaItem.id, poster: mediaItem.poster, duration: mediaItem.duration, type: mediaItem.type, "channel-name": 'channelName' in mediaItem ? mediaItem.channelName : undefined, "channel-logo": 'channelLogo' in mediaItem ? mediaItem.channelLogo : undefined, title: mediaItem.title, "aspect-ratio": mediaItem.aspectRatio, "minimum-age": mediaItem.minimumAge, "release-date": mediaItem.releaseDate, "has-product-placement": 'hasProductPlacement' in mediaItem ? mediaItem.hasProductPlacement : undefined, children: mediaItem ? (_jsx("script", { type: ScriptType.EXTERNAL_MEDIA_ITEM, children: JSON.stringify(mediaItem) })) : null }));
|
|
8
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { GlomexMediaItemElement } from '@glomex/integration-web-component';
|
|
2
|
+
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
|
|
3
|
+
declare global {
|
|
4
|
+
namespace JSX {
|
|
5
|
+
interface IntrinsicElements {
|
|
6
|
+
'glomex-media-item': DetailedHTMLProps<HTMLAttributes<GlomexMediaItemElement> & {
|
|
7
|
+
poster?: string;
|
|
8
|
+
}, GlomexMediaItemElement>;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* React component to define a glomex media item.
|
|
14
|
+
*/
|
|
15
|
+
export declare const GlomexMediaItemReact: ({ id, overrides }: {
|
|
16
|
+
id: string | {
|
|
17
|
+
id: string;
|
|
18
|
+
overrides?: {
|
|
19
|
+
title?: string;
|
|
20
|
+
poster?: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
overrides?: {
|
|
24
|
+
title?: string;
|
|
25
|
+
poster?: string;
|
|
26
|
+
};
|
|
27
|
+
}) => JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* React component to define a glomex media item.
|
|
4
|
+
*/
|
|
5
|
+
export const GlomexMediaItemReact = ({ id, overrides }) => {
|
|
6
|
+
const { id: mediaItemId, overrides: mediaItemOverrides } = typeof id === 'string' ? { id, overrides } : id;
|
|
7
|
+
return (_jsx("glomex-media-item", { id: mediaItemId, title: mediaItemOverrides?.title, poster: mediaItemOverrides?.poster }));
|
|
8
|
+
};
|
package/build/index.d.ts
ADDED
package/build/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type IntegrationElement, type IntegrationProperties, type MediaItem, type MinimalMediaItem } from '@glomex/integration-web-component';
|
|
2
|
+
import { type CSSProperties, type DetailedHTMLProps, type HTMLAttributes } from 'react';
|
|
3
|
+
declare global {
|
|
4
|
+
namespace JSX {
|
|
5
|
+
interface IntrinsicElements {
|
|
6
|
+
'glomex-integration': DetailedHTMLProps<HTMLAttributes<IntegrationElement> & {
|
|
7
|
+
index?: number;
|
|
8
|
+
placement?: string;
|
|
9
|
+
hidden?: boolean;
|
|
10
|
+
style?: CSSProperties;
|
|
11
|
+
}, IntegrationElement>;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* React component for the integration.
|
|
17
|
+
*
|
|
18
|
+
* @see {@link IntegrationElementEventMap} for all available events.
|
|
19
|
+
*/
|
|
20
|
+
export declare const IntegrationReact: import("react").ForwardRefExoticComponent<IntegrationProperties & {
|
|
21
|
+
id?: string;
|
|
22
|
+
mediaItems?: (string | {
|
|
23
|
+
id: string;
|
|
24
|
+
overrides: {
|
|
25
|
+
title?: string;
|
|
26
|
+
poster?: string;
|
|
27
|
+
};
|
|
28
|
+
} | MinimalMediaItem | MediaItem)[];
|
|
29
|
+
preventLoadIntegration?: boolean;
|
|
30
|
+
configs?: Record<string, unknown>;
|
|
31
|
+
style?: CSSProperties;
|
|
32
|
+
} & {
|
|
33
|
+
children?: import("react").ReactNode | undefined;
|
|
34
|
+
} & import("react").RefAttributes<IntegrationElement>>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { ScriptType, getIntegrationCssUrl, loadIntegrationComponent } from '@glomex/integration-web-component';
|
|
3
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
4
|
+
import { ExternalMediaItemReact } from './external-media-item-react';
|
|
5
|
+
import { GlomexMediaItemReact } from './glomex-media-item-react';
|
|
6
|
+
/**
|
|
7
|
+
* React component for the integration.
|
|
8
|
+
*
|
|
9
|
+
* @see {@link IntegrationElementEventMap} for all available events.
|
|
10
|
+
*/
|
|
11
|
+
export const IntegrationReact = forwardRef((props, ref) => {
|
|
12
|
+
const { children, integrationId, playlistId, index, hidden, topLevelIframe, placement, mediaItems, configs, preventLoadIntegration, ...rest } = props;
|
|
13
|
+
const elementRef = useRef(null);
|
|
14
|
+
if (mediaItems && playlistId) {
|
|
15
|
+
throw new Error('Cannot specify both mediaItems and playlistId');
|
|
16
|
+
}
|
|
17
|
+
const mediaItemComponents = (mediaItems || []).map((item, index) => {
|
|
18
|
+
const keyIndex = index + 1;
|
|
19
|
+
if (typeof item === 'string') {
|
|
20
|
+
return _jsx(GlomexMediaItemReact, { id: item }, `${item}-${keyIndex}`);
|
|
21
|
+
}
|
|
22
|
+
if ('id' in item && !('title' in item)) {
|
|
23
|
+
return (_jsx(GlomexMediaItemReact, { id: item.id, overrides: item.overrides }, `${item.id}-${keyIndex}`));
|
|
24
|
+
}
|
|
25
|
+
return _jsx(ExternalMediaItemReact, { ...item }, `${item.id}-${keyIndex}`);
|
|
26
|
+
});
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (preventLoadIntegration)
|
|
29
|
+
return;
|
|
30
|
+
loadIntegrationComponent();
|
|
31
|
+
}, [preventLoadIntegration]);
|
|
32
|
+
useImperativeHandle(ref, () => elementRef.current, []);
|
|
33
|
+
return (_jsxs(_Fragment, { children: [integrationId && _jsx("link", { rel: "stylesheet", href: getIntegrationCssUrl(integrationId) }), _jsxs("glomex-integration", { ref: elementRef, "integration-id": integrationId, "playlist-id": playlistId, index: index, hidden: hidden, "top-level-iframe": topLevelIframe, placement: placement, ...rest, children: [mediaItemComponents, children, configs && (_jsx("script", { type: ScriptType.INTEGRATION_CONFIGS, children: JSON.stringify(configs) }))] })] }));
|
|
34
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@glomex/integration-react",
|
|
3
|
+
"version": "1.1299.0",
|
|
4
|
+
"description": "React component to integrate the glomex player",
|
|
5
|
+
"documentation": "https://docs.glomex.com",
|
|
6
|
+
"homepage": "https://glomex.com",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"glomex",
|
|
9
|
+
"video",
|
|
10
|
+
"player",
|
|
11
|
+
"streaming",
|
|
12
|
+
"media-player",
|
|
13
|
+
"web-player",
|
|
14
|
+
"react"
|
|
15
|
+
],
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "./build/index.js",
|
|
18
|
+
"types": "./build/index.d.ts",
|
|
19
|
+
"files": [
|
|
20
|
+
"build/**/*.js",
|
|
21
|
+
"build/**/*.d.ts"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"prepare": "tsc --build",
|
|
25
|
+
"build": "rm -rf build &&tsc --build",
|
|
26
|
+
"lint": "tsc --noEmit && biome ci",
|
|
27
|
+
"watch": "tsc --build --watch"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@glomex/integration-web-component": "^1.1299.0"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"react": ">=16.8.0",
|
|
34
|
+
"react-dom": ">=16.8.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@biomejs/biome": "^1.9.4",
|
|
38
|
+
"typescript": "^5.8.2"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "0639a6ddf352930238f560cc0887345f7b401d60"
|
|
44
|
+
}
|