@streamscloud/embeddable 2.0.3 → 2.1.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/short-videos/short-videos-player/index.d.ts +3 -0
- package/dist/short-videos/short-videos-player/index.js +1 -1
- package/dist/streams/stream-player/cmp.stream-player.svelte +5 -1
- package/dist/streams/stream-player/cmp.stream-player.svelte.d.ts +1 -0
- package/dist/streams/stream-player/index.d.ts +8 -0
- package/dist/streams/stream-player/index.js +7 -1
- package/dist/streams/stream-player/operations.generated.d.ts +6 -0
- package/dist/streams/stream-player/operations.generated.js +10 -0
- package/dist/streams/stream-player/operations.graphql +3 -0
- package/dist/ui/shadow-dom/shadow-host.d.ts +4 -1
- package/dist/ui/shadow-dom/shadow-host.js +6 -1
- package/package.json +1 -1
|
@@ -25,4 +25,7 @@ export type { IShortVideosPlayerLocalization };
|
|
|
25
25
|
export declare const openShortVideosPlayer: (init: {
|
|
26
26
|
shortVideosProvider: PlayerItemsProvider<ShortVideoViewerModel>;
|
|
27
27
|
localization?: IShortVideosPlayerLocalization;
|
|
28
|
+
on?: {
|
|
29
|
+
playerClosed?: () => void;
|
|
30
|
+
};
|
|
28
31
|
}) => void;
|
|
@@ -23,7 +23,7 @@ import { mount } from 'svelte';
|
|
|
23
23
|
*/
|
|
24
24
|
export const openShortVideosPlayer = (init) => {
|
|
25
25
|
const { shortVideosProvider, localization } = init;
|
|
26
|
-
const shadowHost = new ShadowHost();
|
|
26
|
+
const shadowHost = new ShadowHost({ onClosed: () => init.on?.playerClosed?.() });
|
|
27
27
|
mount(ShortVideosPlayer, {
|
|
28
28
|
target: shadowHost.shadowRoot,
|
|
29
29
|
props: {
|
|
@@ -30,7 +30,7 @@ let loading = $state(true);
|
|
|
30
30
|
let activePageId = $derived.by(() => { var _a, _b; return (_b = (_a = buffer === null || buffer === void 0 ? void 0 : buffer.current) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : ''; });
|
|
31
31
|
const uiManager = new StreamPlayerUiManager();
|
|
32
32
|
onMount(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
-
var _a, _b;
|
|
33
|
+
var _a, _b, _c, _d;
|
|
34
34
|
uiManager.overviewCollapsed = window && window.innerWidth < window.innerHeight;
|
|
35
35
|
try {
|
|
36
36
|
const streamPayload = yield graphql.query(GetStreamDocument, { id: streamId }).toPromise();
|
|
@@ -39,6 +39,10 @@ onMount(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
39
39
|
(_b = on === null || on === void 0 ? void 0 : on.closePlayer) === null || _b === void 0 ? void 0 : _b.call(on);
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
+
(_c = on === null || on === void 0 ? void 0 : on.streamActivated) === null || _c === void 0 ? void 0 : _c.call(on, {
|
|
43
|
+
title: streamPayload.data.stream.title,
|
|
44
|
+
image: ((_d = streamPayload.data.stream.cover) === null || _d === void 0 ? void 0 : _d.url) || null
|
|
45
|
+
});
|
|
42
46
|
// start tracking the stream
|
|
43
47
|
model = mapStreamPlayerModel(streamPayload.data.stream);
|
|
44
48
|
buffer = new StreamPlayerBuffer({ graphql, streamId });
|
|
@@ -7,6 +7,7 @@ export type { IStreamPlayerLocalization };
|
|
|
7
7
|
* @param {string} init.streamId - The ID of the stream to open.
|
|
8
8
|
* @param {string} init.graphqlUrl - The URL of the GraphQL endpoint.
|
|
9
9
|
* @param {IStreamPlayerLocalization} [init.localization] - Optional localization settings for the player UI.
|
|
10
|
+
* @param init.on - Available callbacks.
|
|
10
11
|
*
|
|
11
12
|
* @example
|
|
12
13
|
* ```ts
|
|
@@ -26,4 +27,11 @@ export declare const openStreamPlayer: (init: {
|
|
|
26
27
|
streamId: string;
|
|
27
28
|
graphqlUrl: string;
|
|
28
29
|
localization?: IStreamPlayerLocalization;
|
|
30
|
+
on?: {
|
|
31
|
+
streamActivated?: (data: {
|
|
32
|
+
title: string;
|
|
33
|
+
image: string | null;
|
|
34
|
+
}) => void;
|
|
35
|
+
playerClosed?: () => void;
|
|
36
|
+
};
|
|
29
37
|
}) => void;
|
|
@@ -9,6 +9,7 @@ import { mount } from 'svelte';
|
|
|
9
9
|
* @param {string} init.streamId - The ID of the stream to open.
|
|
10
10
|
* @param {string} init.graphqlUrl - The URL of the GraphQL endpoint.
|
|
11
11
|
* @param {IStreamPlayerLocalization} [init.localization] - Optional localization settings for the player UI.
|
|
12
|
+
* @param init.on - Available callbacks.
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
15
|
* ```ts
|
|
@@ -26,7 +27,7 @@ import { mount } from 'svelte';
|
|
|
26
27
|
*/
|
|
27
28
|
export const openStreamPlayer = (init) => {
|
|
28
29
|
const { streamId, graphqlUrl, localization } = init;
|
|
29
|
-
const shadowHost = new ShadowHost();
|
|
30
|
+
const shadowHost = new ShadowHost({ onClosed: () => init.on?.playerClosed?.() });
|
|
30
31
|
mount(StreamPlayer, {
|
|
31
32
|
target: shadowHost.shadowRoot,
|
|
32
33
|
props: {
|
|
@@ -34,6 +35,11 @@ export const openStreamPlayer = (init) => {
|
|
|
34
35
|
graphql: createLocalGQLClient(graphqlUrl),
|
|
35
36
|
localization,
|
|
36
37
|
on: {
|
|
38
|
+
streamActivated: (data) => {
|
|
39
|
+
if (init.on?.streamActivated) {
|
|
40
|
+
init.on.streamActivated({ title: data.title, image: data.image });
|
|
41
|
+
}
|
|
42
|
+
},
|
|
37
43
|
closePlayer: () => {
|
|
38
44
|
shadowHost.remove();
|
|
39
45
|
}
|
|
@@ -11,6 +11,9 @@ export type GetStreamQuery = {
|
|
|
11
11
|
createdAt: any;
|
|
12
12
|
publishedAt: any | null;
|
|
13
13
|
pagesCount: number;
|
|
14
|
+
cover: {
|
|
15
|
+
url: string;
|
|
16
|
+
} | null;
|
|
14
17
|
ownerProfile: {
|
|
15
18
|
image: string | null;
|
|
16
19
|
name: string;
|
|
@@ -45,6 +48,9 @@ export type StreamPlayerPayloadFragment = {
|
|
|
45
48
|
createdAt: any;
|
|
46
49
|
publishedAt: any | null;
|
|
47
50
|
pagesCount: number;
|
|
51
|
+
cover: {
|
|
52
|
+
url: string;
|
|
53
|
+
} | null;
|
|
48
54
|
ownerProfile: {
|
|
49
55
|
image: string | null;
|
|
50
56
|
name: string;
|
|
@@ -13,6 +13,11 @@ export const StreamPlayerPayloadFragmentDoc = {
|
|
|
13
13
|
{ kind: 'Field', name: { kind: 'Name', value: 'subTitle' } },
|
|
14
14
|
{ kind: 'Field', name: { kind: 'Name', value: 'createdAt' } },
|
|
15
15
|
{ kind: 'Field', name: { kind: 'Name', value: 'publishedAt' } },
|
|
16
|
+
{
|
|
17
|
+
kind: 'Field',
|
|
18
|
+
name: { kind: 'Name', value: 'cover' },
|
|
19
|
+
selectionSet: { kind: 'SelectionSet', selections: [{ kind: 'Field', name: { kind: 'Name', value: 'url' } }] }
|
|
20
|
+
},
|
|
16
21
|
{
|
|
17
22
|
kind: 'Field',
|
|
18
23
|
name: { kind: 'Name', value: 'ownerProfile' },
|
|
@@ -88,6 +93,11 @@ export const GetStreamDocument = {
|
|
|
88
93
|
{ kind: 'Field', name: { kind: 'Name', value: 'subTitle' } },
|
|
89
94
|
{ kind: 'Field', name: { kind: 'Name', value: 'createdAt' } },
|
|
90
95
|
{ kind: 'Field', name: { kind: 'Name', value: 'publishedAt' } },
|
|
96
|
+
{
|
|
97
|
+
kind: 'Field',
|
|
98
|
+
name: { kind: 'Name', value: 'cover' },
|
|
99
|
+
selectionSet: { kind: 'SelectionSet', selections: [{ kind: 'Field', name: { kind: 'Name', value: 'url' } }] }
|
|
100
|
+
},
|
|
91
101
|
{
|
|
92
102
|
kind: 'Field',
|
|
93
103
|
name: { kind: 'Name', value: 'ownerProfile' },
|
|
@@ -3,7 +3,11 @@ import reset from './_reset.scss?raw';
|
|
|
3
3
|
export class ShadowHost {
|
|
4
4
|
shadowRoot;
|
|
5
5
|
host;
|
|
6
|
-
|
|
6
|
+
callbacks;
|
|
7
|
+
constructor(init) {
|
|
8
|
+
this.callbacks = {
|
|
9
|
+
onClosed: init.onClosed
|
|
10
|
+
};
|
|
7
11
|
const host = document.createElement('div');
|
|
8
12
|
host.style.all = 'unset';
|
|
9
13
|
host.style.position = 'fixed';
|
|
@@ -30,6 +34,7 @@ export class ShadowHost {
|
|
|
30
34
|
this.host.remove();
|
|
31
35
|
document.getElementsByTagName('html')[0].style.overflow = '';
|
|
32
36
|
document.removeEventListener('keydown', this.handleEsc);
|
|
37
|
+
this.callbacks.onClosed();
|
|
33
38
|
}
|
|
34
39
|
handleEsc = (event) => {
|
|
35
40
|
if (event.key === 'Escape' || event.key === 'Esc') {
|