@streamscloud/embeddable 5.1.3 → 6.0.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.
- package/dist/ads/ad-card/mapper.js +1 -1
- package/dist/core/browser.d.ts +1 -0
- package/dist/core/browser.js +1 -0
- package/dist/core/continuation-token.d.ts +1 -0
- package/dist/core/continuation-token.js +3 -0
- package/dist/core/locale.d.ts +0 -1
- package/dist/core/locale.js +0 -12
- package/dist/core/media/media-item-url.service.d.ts +1 -1
- package/dist/core/media/media-item-url.service.js +1 -6
- package/dist/media-center/data-provider/index.d.ts +2 -0
- package/dist/media-center/data-provider/index.js +1 -0
- package/dist/media-center/data-provider/internal-media-center-data-provider.svelte.d.ts +8 -0
- package/dist/media-center/data-provider/internal-media-center-data-provider.svelte.js +44 -0
- package/dist/media-center/data-provider/operations.generated.d.ts +89 -0
- package/dist/media-center/data-provider/operations.generated.js +275 -0
- package/dist/media-center/data-provider/operations.graphql +25 -0
- package/dist/media-center/data-provider/types.d.ts +24 -0
- package/dist/media-center/data-provider/types.js +1 -0
- package/dist/media-center/index.d.ts +1 -0
- package/dist/media-center/index.js +1 -0
- package/dist/media-center/media-center/cmp.media-center.svelte +433 -0
- package/dist/media-center/media-center/cmp.media-center.svelte.d.ts +20 -0
- package/dist/media-center/media-center/index.d.ts +3 -0
- package/dist/media-center/media-center/index.js +2 -0
- package/dist/media-center/media-center/media-center-localization.d.ts +13 -0
- package/dist/media-center/media-center/media-center-localization.js +21 -0
- package/dist/media-center/media-center/overview.svelte +151 -0
- package/dist/media-center/media-center/overview.svelte.d.ts +13 -0
- package/dist/media-center/media-center/short-video-resources-generator.d.ts +8 -0
- package/dist/media-center/media-center/short-video-resources-generator.js +26 -0
- package/dist/media-center/media-center/types.d.ts +10 -0
- package/dist/media-center/media-center/types.js +5 -0
- package/dist/products/product-card/cmp.product-card.svelte +11 -6
- package/dist/products/product-card/mapper.js +3 -3
- package/dist/short-videos/short-video-card/cmp.short-video-card.svelte +118 -0
- package/dist/short-videos/short-video-card/cmp.short-video-card.svelte.d.ts +11 -0
- package/dist/short-videos/short-video-card/index.d.ts +2 -0
- package/dist/short-videos/short-video-card/index.js +1 -0
- package/dist/short-videos/short-video-card/types.d.ts +5 -0
- package/dist/short-videos/short-video-card/types.js +1 -0
- package/dist/short-videos/short-video-viewer/cmp.short-video-controls.svelte +3 -3
- package/dist/short-videos/short-video-viewer/cmp.short-video-controls.svelte.d.ts +2 -2
- package/dist/short-videos/short-video-viewer/cmp.short-video-viewer.svelte +8 -26
- package/dist/short-videos/short-video-viewer/cmp.short-video-viewer.svelte.d.ts +2 -3
- package/dist/short-videos/short-video-viewer/index.d.ts +1 -1
- package/dist/short-videos/short-video-viewer/mapper.js +6 -3
- package/dist/short-videos/short-video-viewer/types.d.ts +8 -6
- package/dist/short-videos/short-video-viewer/ui-manager.svelte.d.ts +0 -5
- package/dist/short-videos/short-video-viewer/ui-manager.svelte.js +0 -11
- package/dist/short-videos/short-videos-player/cmp.short-videos-player.svelte +16 -12
- package/dist/short-videos/short-videos-player/cmp.short-videos-player.svelte.d.ts +5 -15
- package/dist/short-videos/short-videos-player/controls.svelte +39 -4
- package/dist/short-videos/short-videos-player/controls.svelte.d.ts +3 -2
- package/dist/short-videos/short-videos-player/fade-mixins.scss +12 -0
- package/dist/short-videos/short-videos-player/index.d.ts +66 -36
- package/dist/short-videos/short-videos-player/index.js +40 -104
- package/dist/short-videos/short-videos-player/internal-short-video-player-provider.d.ts +17 -0
- package/dist/short-videos/short-videos-player/internal-short-video-player-provider.js +59 -0
- package/dist/short-videos/short-videos-player/operations.generated.d.ts +1 -0
- package/dist/short-videos/short-videos-player/operations.generated.js +2 -1
- package/dist/short-videos/short-videos-player/operations.graphql +1 -0
- package/dist/short-videos/short-videos-player/short-videos-player-view.svelte +36 -55
- package/dist/short-videos/short-videos-player/short-videos-player-view.svelte.d.ts +12 -15
- package/dist/short-videos/short-videos-player/types.d.ts +8 -29
- package/dist/short-videos/short-videos-player/types.js +1 -6
- package/dist/short-videos/short-videos-player/ui-manager.svelte.d.ts +6 -6
- package/dist/short-videos/short-videos-player/ui-manager.svelte.js +28 -16
- package/dist/streams/layout/element-views/cmp.short-video-stream-element.svelte +6 -1
- package/dist/streams/stream-page-viewer/index.d.ts +1 -0
- package/dist/streams/stream-page-viewer/index.js +1 -0
- package/dist/streams/stream-player/controls.svelte +2 -2
- package/dist/streams/stream-player/controls.svelte.d.ts +2 -2
- package/dist/streams/stream-player/index.d.ts +84 -27
- package/dist/streams/stream-player/index.js +46 -48
- package/dist/streams/stream-player/internal-stream-analytics-handler.d.ts +12 -0
- package/dist/streams/stream-player/internal-stream-analytics-handler.js +17 -0
- package/dist/streams/stream-player/internal-stream-player-data-provider.d.ts +10 -0
- package/dist/streams/stream-player/internal-stream-player-data-provider.js +48 -0
- package/dist/streams/stream-player/mapper.js +2 -0
- package/dist/streams/stream-player/operations.generated.d.ts +0 -2
- package/dist/streams/stream-player/operations.generated.js +2 -4
- package/dist/streams/stream-player/operations.graphql +0 -1
- package/dist/streams/stream-player/stream-player-buffer.svelte.d.ts +5 -5
- package/dist/streams/stream-player/stream-player-buffer.svelte.js +12 -27
- package/dist/streams/stream-player/{cmp.stream-player.svelte → stream-player.svelte} +19 -37
- package/dist/streams/stream-player/stream-player.svelte.d.ts +4 -0
- package/dist/streams/stream-player/types.d.ts +40 -0
- package/dist/ui/dropdown/cmp.dropdown.svelte +187 -0
- package/dist/ui/dropdown/cmp.dropdown.svelte.d.ts +23 -0
- package/dist/ui/dropdown/dropdown-ignore.d.ts +6 -0
- package/dist/ui/dropdown/dropdown-ignore.js +11 -0
- package/dist/ui/dropdown/index.d.ts +3 -0
- package/dist/ui/dropdown/index.js +2 -0
- package/dist/ui/player/index.d.ts +1 -1
- package/dist/ui/player/player-buffer.svelte.d.ts +3 -3
- package/package.json +8 -1
- package/dist/streams/stream-player/cmp.stream-player.svelte.d.ts +0 -22
|
@@ -8,66 +8,34 @@
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { handleEsc } from '../../core/document.event-handlers';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { ShortVideoViewer } from '../short-video-viewer';
|
|
12
|
+
import { InternalShortVideoPlayerProvider } from './internal-short-video-player-provider';
|
|
13
13
|
import { Loading } from '../../ui/loading';
|
|
14
14
|
import { PlayerBuffer, PlayerSlider } from '../../ui/player';
|
|
15
15
|
import { SpotlightLayout } from '../../ui/spotlight-layout';
|
|
16
16
|
import { SwipeIndicator } from '../../ui/swipe-indicator';
|
|
17
17
|
import { default as Controls } from './controls.svelte';
|
|
18
|
-
import { GetShortVideosDocument } from './operations.generated';
|
|
19
18
|
import { ShortVideosPlayerLocalization } from './short-videos-player-localization';
|
|
20
19
|
import { ShortVideosPlayerUiManager } from './ui-manager.svelte';
|
|
21
|
-
import { onMount } from 'svelte';
|
|
22
|
-
let {
|
|
20
|
+
import { onMount, untrack } from 'svelte';
|
|
21
|
+
let { dataProvider, socialInteractionsHandler, localization: localizationInit = 'en', showStreamsCloudWatermark, disableBackground, on, categoriesSwitcher, playerLogo = null, fadeContent = false } = $props();
|
|
23
22
|
const localization = $derived(new ShortVideosPlayerLocalization(localizationInit));
|
|
24
23
|
let everTouched = $state(false);
|
|
25
24
|
let background = $state(null);
|
|
26
|
-
let buffer = $
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
const { graphqlOrigin, ids, initialId } = input;
|
|
31
|
-
const graphql = createLocalGQLClient(graphqlOrigin, { 'x-initiator': input.initiator || 'player/short-videos' });
|
|
32
|
-
const payload = yield graphql
|
|
33
|
-
.query(GetShortVideosDocument, {
|
|
34
|
-
input: {
|
|
35
|
-
filter: {
|
|
36
|
-
ids
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
.toPromise();
|
|
41
|
-
const posts = ((_b = (_a = payload.data) === null || _a === void 0 ? void 0 : _a.shortVideos) === null || _b === void 0 ? void 0 : _b.items) || [];
|
|
42
|
-
const idOrder = new Map(ids.map((id, index) => [id, index]));
|
|
43
|
-
posts.sort((a, b) => {
|
|
44
|
-
var _a, _b;
|
|
45
|
-
return ((_a = idOrder.get(a.id)) !== null && _a !== void 0 ? _a : Infinity) - ((_b = idOrder.get(b.id)) !== null && _b !== void 0 ? _b : Infinity);
|
|
46
|
-
});
|
|
47
|
-
const index = initialId ? posts.findIndex((p) => p.id === initialId) : 0;
|
|
48
|
-
const provider = {
|
|
49
|
-
initialData: {
|
|
50
|
-
prefetchedItems: posts.map(mapToShortVideoViewerModel),
|
|
51
|
-
startIndex: index
|
|
52
|
-
},
|
|
53
|
-
loadMore: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
-
// No more items to load, as all are already prefetched
|
|
55
|
-
return [];
|
|
56
|
-
})
|
|
57
|
-
};
|
|
58
|
-
buffer = new PlayerBuffer(provider);
|
|
59
|
-
}
|
|
60
|
-
catch (_c) {
|
|
61
|
-
console.error('Failed to load short videos by IDs:', input.ids);
|
|
62
|
-
buffer = null; // Reset buffer on error
|
|
63
|
-
}
|
|
25
|
+
let buffer = $derived.by(() => {
|
|
26
|
+
void dataProvider;
|
|
27
|
+
return untrack(() => (dataProvider instanceof InternalShortVideoPlayerProvider ? null : new PlayerBuffer(dataProvider)));
|
|
64
28
|
});
|
|
65
29
|
const uiManager = new ShortVideosPlayerUiManager();
|
|
66
30
|
onMount(() => {
|
|
67
|
-
if (
|
|
68
|
-
initBuffer(
|
|
31
|
+
if (dataProvider instanceof InternalShortVideoPlayerProvider) {
|
|
32
|
+
initBuffer(dataProvider);
|
|
69
33
|
}
|
|
70
34
|
});
|
|
35
|
+
const initBuffer = (provider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
yield provider.prefetch();
|
|
37
|
+
buffer = new PlayerBuffer(provider);
|
|
38
|
+
});
|
|
71
39
|
const onItemActivated = (id) => {
|
|
72
40
|
var _a;
|
|
73
41
|
const shortVideo = buffer === null || buffer === void 0 ? void 0 : buffer.loaded.find((x) => x.id === id);
|
|
@@ -96,9 +64,12 @@ const handleDimensionsChanged = (dimensions) => {
|
|
|
96
64
|
viewTotalWidth: dimensions.totalWidth
|
|
97
65
|
});
|
|
98
66
|
};
|
|
67
|
+
const onMediaCenterHeaderMounted = (data) => {
|
|
68
|
+
uiManager.updateMediaCenterHeaderHeight(data.height);
|
|
69
|
+
};
|
|
99
70
|
const onPlayerClose = () => {
|
|
100
71
|
var _a;
|
|
101
|
-
(_a = on === null || on === void 0 ? void 0 : on.
|
|
72
|
+
(_a = on === null || on === void 0 ? void 0 : on.playerClosed) === null || _a === void 0 ? void 0 : _a.call(on);
|
|
102
73
|
};
|
|
103
74
|
</script>
|
|
104
75
|
|
|
@@ -107,7 +78,15 @@ const onPlayerClose = () => {
|
|
|
107
78
|
<div
|
|
108
79
|
class="short-videos-player-container"
|
|
109
80
|
class:short-videos-player-container--background-enabled={!disableBackground}
|
|
81
|
+
class:short-videos-player-container--faded={fadeContent}
|
|
110
82
|
style={background && !disableBackground ? `--background-image: url(${background})` : null}>
|
|
83
|
+
{#if categoriesSwitcher}
|
|
84
|
+
{@render categoriesSwitcher({
|
|
85
|
+
maxItemsWidth: Math.min(uiManager.mainViewColumnWidth * 1.4, uiManager.viewTotalWidth),
|
|
86
|
+
onMounted: onMediaCenterHeaderMounted
|
|
87
|
+
})}
|
|
88
|
+
{/if}
|
|
89
|
+
|
|
111
90
|
<div class="short-videos-player" style={uiManager.globalCssVariables}>
|
|
112
91
|
{#if showStreamsCloudWatermark}
|
|
113
92
|
<div class="short-videos-player__watermark">
|
|
@@ -144,7 +123,8 @@ const onPlayerClose = () => {
|
|
|
144
123
|
uiManager={uiManager}
|
|
145
124
|
localization={localization}
|
|
146
125
|
socialInteractionsHandler={socialInteractionsHandler}
|
|
147
|
-
|
|
126
|
+
playerLogo={playerLogo}
|
|
127
|
+
on={{ closePlayer: on?.playerClosed }} />
|
|
148
128
|
{:else}
|
|
149
129
|
<Loading positionFixedCenter={true} timeout={1000} />
|
|
150
130
|
{/if}
|
|
@@ -163,6 +143,7 @@ const onPlayerClose = () => {
|
|
|
163
143
|
}
|
|
164
144
|
}
|
|
165
145
|
.short-videos-player-container {
|
|
146
|
+
--short-videos-player--elements-opacity: 1;
|
|
166
147
|
width: 100%;
|
|
167
148
|
min-width: 100%;
|
|
168
149
|
max-width: 100%;
|
|
@@ -179,11 +160,14 @@ const onPlayerClose = () => {
|
|
|
179
160
|
background-size: cover;
|
|
180
161
|
background-blend-mode: multiply;
|
|
181
162
|
}
|
|
163
|
+
.short-videos-player-container--faded {
|
|
164
|
+
--short-videos-player--elements-opacity: 0;
|
|
165
|
+
}
|
|
182
166
|
|
|
183
167
|
.short-videos-player {
|
|
184
168
|
display: flex;
|
|
185
169
|
flex: 1;
|
|
186
|
-
padding:
|
|
170
|
+
padding: var(--short-videos-player--padding);
|
|
187
171
|
backdrop-filter: blur(30px);
|
|
188
172
|
position: relative;
|
|
189
173
|
/* Set 'container-type: inline-size;' to reference container*/
|
|
@@ -197,15 +181,12 @@ const onPlayerClose = () => {
|
|
|
197
181
|
position: absolute;
|
|
198
182
|
bottom: 5rem;
|
|
199
183
|
left: 5rem;
|
|
184
|
+
opacity: var(--short-videos-player--elements-opacity);
|
|
185
|
+
transition: opacity 0.3s ease-in-out;
|
|
200
186
|
}
|
|
201
187
|
.short-videos-player__content {
|
|
202
188
|
width: 100%;
|
|
203
189
|
height: 100%;
|
|
204
|
-
--short-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
@container (width < 576px) {
|
|
208
|
-
.short-videos-player__content {
|
|
209
|
-
--short-video-viewer--actions-panel--top: 5rem;
|
|
210
|
-
}
|
|
190
|
+
opacity: var(--short-videos-player--elements-opacity);
|
|
191
|
+
transition: opacity 0.3s ease-in-out;
|
|
211
192
|
}</style>
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
closePlayer?: () => void;
|
|
13
|
-
videoActivated?: (id: string) => void;
|
|
14
|
-
};
|
|
1
|
+
import type { ShortVideoPlayerProps } from './types';
|
|
2
|
+
import { type Snippet } from 'svelte';
|
|
3
|
+
type $$ComponentProps = ShortVideoPlayerProps & {
|
|
4
|
+
categoriesSwitcher?: Snippet<[{
|
|
5
|
+
maxItemsWidth: number;
|
|
6
|
+
onMounted: (data: {
|
|
7
|
+
height: number;
|
|
8
|
+
}) => void;
|
|
9
|
+
}]>;
|
|
10
|
+
playerLogo?: string | null;
|
|
11
|
+
fadeContent?: boolean;
|
|
15
12
|
};
|
|
16
|
-
declare const ShortVideosPlayerView: import("svelte").Component
|
|
13
|
+
declare const ShortVideosPlayerView: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
17
14
|
type ShortVideosPlayerView = ReturnType<typeof ShortVideosPlayerView>;
|
|
18
15
|
export default ShortVideosPlayerView;
|
|
@@ -1,38 +1,17 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Locale } from '../../core/locale';
|
|
2
|
+
import type { ShortVideoViewerModel, IPostSocialInteractionsHandler } from '../short-video-viewer';
|
|
3
|
+
import type { IPlayerItemsProvider } from '../../ui/player';
|
|
3
4
|
import type { IShortVideosPlayerLocalization } from './short-videos-player-localization';
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
type: 'provider';
|
|
7
|
-
provider: PlayerItemsProvider<ShortVideoViewerModel>;
|
|
5
|
+
export type ShortVideoPlayerProps = PlayerSettings & {
|
|
6
|
+
dataProvider: IPlayerItemsProvider<ShortVideoViewerModel>;
|
|
8
7
|
};
|
|
9
|
-
export type
|
|
10
|
-
|
|
11
|
-
ids: string[];
|
|
12
|
-
initialId?: string;
|
|
13
|
-
graphqlOrigin?: string;
|
|
14
|
-
initiator?: string;
|
|
15
|
-
};
|
|
16
|
-
export type OpenShortVideosPlayerInit = ProviderInit | IdsInit;
|
|
17
|
-
type ProviderInit = PlayerSettings & {
|
|
18
|
-
shortVideosProvider: PlayerItemsProvider<ShortVideoViewerModel>;
|
|
19
|
-
};
|
|
20
|
-
type IdsInit = PlayerSettings & {
|
|
21
|
-
ids: string[];
|
|
22
|
-
graphqlOrigin?: string;
|
|
23
|
-
initialId?: string;
|
|
24
|
-
initiator?: string;
|
|
25
|
-
};
|
|
26
|
-
type PlayerSettings = {
|
|
27
|
-
socialInteractionsHandler?: ShortVideoSocialInteractionsHandler;
|
|
8
|
+
export type PlayerSettings = {
|
|
9
|
+
socialInteractionsHandler?: IPostSocialInteractionsHandler;
|
|
28
10
|
disableBackground?: boolean;
|
|
29
|
-
localization?: IShortVideosPlayerLocalization |
|
|
11
|
+
localization?: IShortVideosPlayerLocalization | Locale;
|
|
30
12
|
showStreamsCloudWatermark?: boolean;
|
|
31
13
|
on?: {
|
|
32
14
|
playerClosed?: () => void;
|
|
33
15
|
videoActivated?: (id: string) => void;
|
|
34
16
|
};
|
|
35
17
|
};
|
|
36
|
-
export declare const isShortVideosProviderInit: (init: unknown) => init is ProviderInit;
|
|
37
|
-
export declare function isIdsInit(init: unknown): init is IdsInit;
|
|
38
|
-
export {};
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
return typeof init === 'object' && init !== null && 'shortVideosProvider' in init;
|
|
3
|
-
};
|
|
4
|
-
export function isIdsInit(init) {
|
|
5
|
-
return typeof init === 'object' && init !== null && 'ids' in init && 'graphqlOrigin' in init;
|
|
6
|
-
}
|
|
1
|
+
export {};
|
|
@@ -4,14 +4,14 @@ export declare class ShortVideosPlayerUiManager {
|
|
|
4
4
|
isMobileView: boolean;
|
|
5
5
|
viewInitialized: boolean;
|
|
6
6
|
showShortVideoOverlay: boolean;
|
|
7
|
-
private
|
|
8
|
-
private
|
|
9
|
-
private
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
private mainViewColumnWidth;
|
|
7
|
+
private _viewTotalWidth;
|
|
8
|
+
private _mainViewColumnWidth;
|
|
9
|
+
private _mediaCenterHeaderHeight;
|
|
10
|
+
get viewTotalWidth(): number;
|
|
11
|
+
get mainViewColumnWidth(): number;
|
|
13
12
|
updateDimensions: (dimensions: {
|
|
14
13
|
viewTotalWidth: number;
|
|
15
14
|
mainViewColumnWidth: number;
|
|
16
15
|
}) => void;
|
|
16
|
+
updateMediaCenterHeaderHeight: (height: number) => void;
|
|
17
17
|
}
|
|
@@ -1,26 +1,38 @@
|
|
|
1
|
+
const CONTROLS_PADDING_HORIZONTAL = 28;
|
|
2
|
+
const CONTROLS_PADDING_VERTICAL = 28;
|
|
3
|
+
const PLAYER_PADDING_VERTICAL = 10;
|
|
4
|
+
const BUTTON_SIZE = 48;
|
|
5
|
+
const ICON_SIZE = 28;
|
|
1
6
|
export class ShortVideosPlayerUiManager {
|
|
2
7
|
showAttachments = $state(true);
|
|
3
8
|
globalCssVariables = $derived.by(() => {
|
|
4
9
|
const values = [
|
|
5
|
-
`--short-videos-player--button--size: ${
|
|
6
|
-
`--short-videos-player--
|
|
7
|
-
`--short-videos-player--controls--
|
|
8
|
-
`--short-videos-player--
|
|
9
|
-
`--short-videos-player--
|
|
10
|
+
`--short-videos-player--button--size: ${BUTTON_SIZE}px`,
|
|
11
|
+
`--short-videos-player--controls--available-space: ${(this._viewTotalWidth - this._mainViewColumnWidth) / 2}px`,
|
|
12
|
+
`--short-videos-player--controls--padding: ${this._mediaCenterHeaderHeight ? 0 : CONTROLS_PADDING_VERTICAL}px ${CONTROLS_PADDING_HORIZONTAL}px ${CONTROLS_PADDING_VERTICAL}px`,
|
|
13
|
+
`--short-videos-player--icon--size: ${ICON_SIZE}px`,
|
|
14
|
+
`--short-videos-player--media-center-header--height: ${this._mediaCenterHeaderHeight}px`,
|
|
15
|
+
`--short-videos-player--padding: ${this._mediaCenterHeaderHeight ? this._mediaCenterHeaderHeight : PLAYER_PADDING_VERTICAL}px 0 ${PLAYER_PADDING_VERTICAL}px`
|
|
10
16
|
];
|
|
11
17
|
return values.join(';');
|
|
12
18
|
});
|
|
13
|
-
isMobileView = $derived.by(() => this.
|
|
14
|
-
viewInitialized = $derived.by(() => !!this.
|
|
15
|
-
showShortVideoOverlay = $derived.by(() => this.viewInitialized && (this.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
isMobileView = $derived.by(() => this._viewTotalWidth <= 576);
|
|
20
|
+
viewInitialized = $derived.by(() => !!this._viewTotalWidth && !!this._mainViewColumnWidth);
|
|
21
|
+
showShortVideoOverlay = $derived.by(() => this.viewInitialized && (this._viewTotalWidth - this._mainViewColumnWidth) / 2 <= 85);
|
|
22
|
+
_viewTotalWidth = $state(0);
|
|
23
|
+
_mainViewColumnWidth = $state(0);
|
|
24
|
+
_mediaCenterHeaderHeight = $state(0);
|
|
25
|
+
get viewTotalWidth() {
|
|
26
|
+
return this._viewTotalWidth;
|
|
27
|
+
}
|
|
28
|
+
get mainViewColumnWidth() {
|
|
29
|
+
return this._mainViewColumnWidth;
|
|
30
|
+
}
|
|
22
31
|
updateDimensions = (dimensions) => {
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
32
|
+
this._viewTotalWidth = dimensions.viewTotalWidth;
|
|
33
|
+
this._mainViewColumnWidth = dimensions.mainViewColumnWidth;
|
|
34
|
+
};
|
|
35
|
+
updateMediaCenterHeaderHeight = (height) => {
|
|
36
|
+
this._mediaCenterHeaderHeight = height;
|
|
25
37
|
};
|
|
26
38
|
}
|
|
@@ -5,4 +5,9 @@ let { data, localization: localizationInit, on } = $props();
|
|
|
5
5
|
const localization = $derived(new ShortVideoStreamElementLocalization(localizationInit));
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
|
-
<ShortVideoViewer
|
|
8
|
+
<ShortVideoViewer
|
|
9
|
+
model={mapToShortVideoViewerModel(data)}
|
|
10
|
+
autoplay={false}
|
|
11
|
+
showControls={false}
|
|
12
|
+
localization={localization.shortVideoViewerLocalization}
|
|
13
|
+
on={on} />
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { default as StreamPageViewer } from './cmp.stream-page-viewer.svelte';
|
|
2
2
|
export type { StreamPageViewerModel } from './types';
|
|
3
3
|
export type { IStreamPageViewerLocalization } from './stream-page-viewer-localization';
|
|
4
|
+
export { mapToStreamPageViewerModel } from './mapper';
|
|
@@ -9,7 +9,7 @@ import { StreamPlayerLocalization } from './stream-player-localization';
|
|
|
9
9
|
import IconChevronDown from '@fluentui/svg-icons/icons/chevron_down_28_regular.svg?raw';
|
|
10
10
|
import IconChevronUp from '@fluentui/svg-icons/icons/chevron_up_28_regular.svg?raw';
|
|
11
11
|
import IconDismiss from '@fluentui/svg-icons/icons/dismiss_28_regular.svg?raw';
|
|
12
|
-
let { buffer, uiManager,
|
|
12
|
+
let { buffer, uiManager, postSocialInteractionsHandler, localization, on } = $props();
|
|
13
13
|
const shortVideo = $derived(((_a = buffer.current) === null || _a === void 0 ? void 0 : _a.type) === 'short-video' && ((_b = buffer.current) === null || _b === void 0 ? void 0 : _b.shortVideo) ? mapToShortVideoViewerModel(buffer.current.shortVideo) : null);
|
|
14
14
|
const singleWebViewPage = $derived.by(() => {
|
|
15
15
|
var _a;
|
|
@@ -58,7 +58,7 @@ const changeShowShortVideoAttachments = () => {
|
|
|
58
58
|
{/if}
|
|
59
59
|
<ShortVideoControls
|
|
60
60
|
model={shortVideo}
|
|
61
|
-
socialInteractionsHandler={
|
|
61
|
+
socialInteractionsHandler={postSocialInteractionsHandler}
|
|
62
62
|
on={{ attachmentsClicked: changeShowShortVideoAttachments }} />
|
|
63
63
|
</div>
|
|
64
64
|
{/if}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type IPostSocialInteractionsHandler } from '../../short-videos/short-video-viewer';
|
|
2
2
|
import type { StreamPlayerBuffer } from './stream-player-buffer.svelte';
|
|
3
3
|
import { StreamPlayerLocalization } from './stream-player-localization';
|
|
4
4
|
import type { StreamPlayerUiManager } from './ui-manager.svelte';
|
|
5
5
|
type Props = {
|
|
6
6
|
buffer: StreamPlayerBuffer;
|
|
7
7
|
uiManager: StreamPlayerUiManager;
|
|
8
|
-
|
|
8
|
+
postSocialInteractionsHandler?: IPostSocialInteractionsHandler;
|
|
9
9
|
localization: StreamPlayerLocalization;
|
|
10
10
|
on: {
|
|
11
11
|
closePlayer: () => void;
|
|
@@ -1,41 +1,98 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type IMediaCenterDataProvider } from '../../media-center/data-provider';
|
|
2
|
+
import type { StreamPageViewerModel } from '../stream-page-viewer/types';
|
|
2
3
|
import type { IStreamPlayerLocalization } from './stream-player-localization';
|
|
3
|
-
|
|
4
|
+
import type { IStreamAnalyticsHandler, IStreamPlayerDataProvider, PlayerSettings, StreamPlayerModel } from './types';
|
|
5
|
+
export type { IStreamPlayerLocalization, IStreamPlayerDataProvider, IStreamAnalyticsHandler, IMediaCenterDataProvider, StreamPlayerModel, StreamPageViewerModel };
|
|
4
6
|
/**
|
|
5
|
-
* Opens the stream player modal
|
|
7
|
+
* Opens the stream player modal.
|
|
6
8
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @param {IStreamPlayerLocalization} [init.localization] - Optional localization settings for the player UI.
|
|
11
|
-
* @param init.on - Available callbacks.
|
|
9
|
+
* Two overloads (mutually exclusive; enforced by TypeScript):
|
|
10
|
+
* - Provider mode: openStreamPlayer({ dataProvider, mediaCenterDataProvider?, analyticsHandler?, ...common })
|
|
11
|
+
* - Internal provider mode: openStreamPlayer({ initiator, graphqlOrigin?, mediaPageId?, ...common })
|
|
12
12
|
*
|
|
13
|
-
* @
|
|
13
|
+
* @param init Configuration options.
|
|
14
|
+
*
|
|
15
|
+
* Common (required)
|
|
16
|
+
* @param {string} init.streamId
|
|
17
|
+
* The ID of the stream to open.
|
|
18
|
+
*
|
|
19
|
+
* Provider mode (overload 1)
|
|
20
|
+
* @param {IStreamPlayerDataProvider} init.dataProvider
|
|
21
|
+
* Provider that supplies the stream data to the player.
|
|
22
|
+
* @param {IMediaCenterDataProvider} [init.mediaCenterDataProvider]
|
|
23
|
+
* Optional media-center data provider.
|
|
24
|
+
* @param {IStreamAnalyticsHandler} [init.analyticsHandler]
|
|
25
|
+
* Optional analytics handler to capture player/stream analytics events.
|
|
26
|
+
* If omitted in provider mode, analytics is not auto-initialized.
|
|
27
|
+
*
|
|
28
|
+
* Internal provider mode (overload 2)
|
|
29
|
+
* @param {string} init.initiator
|
|
30
|
+
* Initiator identifier (used for tracking/analytics and GraphQL).
|
|
31
|
+
* @param {string} [init.graphqlOrigin]
|
|
32
|
+
* Optional GraphQL origin (base URL). If omitted, the default origin is determined internally.
|
|
33
|
+
* @param {string} [init.mediaPageId]
|
|
34
|
+
* Optional media page ID used to construct an internal media-center data provider.
|
|
35
|
+
*
|
|
36
|
+
* Common (optional)
|
|
37
|
+
* @param {IStreamPlayerLocalization | Locale} [init.localization]
|
|
38
|
+
* Localization for the player UI. If omitted, 'en' is used.
|
|
39
|
+
* @param {boolean} [init.showStreamsCloudWatermark]
|
|
40
|
+
* If true, shows the StreamsCloud watermark.
|
|
41
|
+
* @param {IPostSocialInteractionsHandler} [init.postSocialInteractionsHandler]
|
|
42
|
+
* Handler for social interactions (like, share, etc.).
|
|
43
|
+
*
|
|
44
|
+
* Events
|
|
45
|
+
* @param {{ streamActivated?: (data: { title: string; image: string | null }) => void; playerClosed?: () => void }} [init.on]
|
|
46
|
+
* Optional event handlers.
|
|
47
|
+
* @param {(data: { title: string; image: string | null }) => void} [init.on.streamActivated]
|
|
48
|
+
* Called when the stream becomes active. Receives a subset of data with title and image.
|
|
49
|
+
* @param {() => void} [init.on.playerClosed]
|
|
50
|
+
* Called after the player is fully closed (after unmount and removal from the DOM).
|
|
51
|
+
*
|
|
52
|
+
* @returns {void}
|
|
53
|
+
*
|
|
54
|
+
* @example <caption>Provider mode</caption>
|
|
55
|
+
* ```ts
|
|
56
|
+
* import { openStreamPlayer } from '@streamscloud/embeddable/stream-player';
|
|
57
|
+
*
|
|
58
|
+
* openStreamPlayer({
|
|
59
|
+
* streamId: 'stream_123',
|
|
60
|
+
* dataProvider: myStreamProvider,
|
|
61
|
+
* mediaCenterDataProvider: myMediaCenterProvider,
|
|
62
|
+
* analyticsHandler: myAnalyticsHandler,
|
|
63
|
+
* localization: { play: 'Play', pause: 'Pause' },
|
|
64
|
+
* showStreamsCloudWatermark: true,
|
|
65
|
+
* on: {
|
|
66
|
+
* streamActivated: ({ title, image }) => console.log('Stream active:', title, image),
|
|
67
|
+
* playerClosed: () => console.log('Player closed')
|
|
68
|
+
* }
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example <caption>Internal provider mode</caption>
|
|
14
73
|
* ```ts
|
|
15
74
|
* import { openStreamPlayer } from '@streamscloud/embeddable/stream-player';
|
|
16
75
|
*
|
|
17
76
|
* openStreamPlayer({
|
|
18
|
-
* streamId: '
|
|
77
|
+
* streamId: 'stream_123',
|
|
78
|
+
* initiator: 'marketing-campaign',
|
|
19
79
|
* graphqlOrigin: 'https://api.example.com',
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
80
|
+
* mediaPageId: 'media-page-123',
|
|
81
|
+
* localization: { play: 'Play', pause: 'Pause' },
|
|
82
|
+
* on: {
|
|
83
|
+
* streamActivated: ({ title, image }) => console.log('Stream active:', title, image),
|
|
84
|
+
* playerClosed: () => console.log('Player closed')
|
|
23
85
|
* }
|
|
24
86
|
* });
|
|
25
87
|
* ```
|
|
26
88
|
*/
|
|
27
|
-
export declare
|
|
28
|
-
|
|
89
|
+
export declare function openStreamPlayer(init: PlayerSettings & {
|
|
90
|
+
dataProvider: IStreamPlayerDataProvider;
|
|
91
|
+
mediaCenterDataProvider?: IMediaCenterDataProvider;
|
|
92
|
+
analyticsHandler?: IStreamAnalyticsHandler;
|
|
93
|
+
}): void;
|
|
94
|
+
export declare function openStreamPlayer(init: PlayerSettings & {
|
|
95
|
+
initiator: string;
|
|
29
96
|
graphqlOrigin?: string;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
shortVideoSocialInteractionsHandler?: ShortVideoSocialInteractionsHandler;
|
|
33
|
-
initiator?: string;
|
|
34
|
-
on?: {
|
|
35
|
-
streamActivated?: (data: {
|
|
36
|
-
title: string;
|
|
37
|
-
image: string | null;
|
|
38
|
-
}) => void;
|
|
39
|
-
playerClosed?: () => void;
|
|
40
|
-
};
|
|
41
|
-
}) => void;
|
|
97
|
+
mediaPageId?: string;
|
|
98
|
+
}): void;
|
|
@@ -1,59 +1,57 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toastrWarning } from '../../core/toastr';
|
|
2
|
+
import { InternalMediaCenterDataProvider } from '../../media-center/data-provider';
|
|
3
|
+
import { MediaCenter, MediaCenterMode } from '../../media-center/media-center';
|
|
2
4
|
import { ModalShadowHost } from '../../ui/shadow-dom';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
+
import { InternalStreamAnalyticsHandler } from './internal-stream-analytics-handler';
|
|
6
|
+
import { InternalStreamPlayerDataProvider } from './internal-stream-player-data-provider';
|
|
5
7
|
import { mount, unmount } from 'svelte';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* localization: {
|
|
23
|
-
* play: 'Play',
|
|
24
|
-
* pause: 'Pause'
|
|
25
|
-
* }
|
|
26
|
-
* });
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export const openStreamPlayer = (init) => {
|
|
30
|
-
const { streamId, graphqlOrigin, localization, showStreamsCloudWatermark, shortVideoSocialInteractionsHandler, initiator } = init;
|
|
8
|
+
export function openStreamPlayer(init) {
|
|
9
|
+
const { streamId, graphqlOrigin, localization, showStreamsCloudWatermark, postSocialInteractionsHandler, initiator } = init;
|
|
10
|
+
const dataProvider = init.dataProvider ?? new InternalStreamPlayerDataProvider({ graphqlOrigin, initiator });
|
|
11
|
+
if (!dataProvider) {
|
|
12
|
+
toastrWarning('Data provider is not specified.');
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
let mediaCenterDataProvider = init.mediaCenterDataProvider;
|
|
16
|
+
if (!mediaCenterDataProvider && init.mediaPageId) {
|
|
17
|
+
mediaCenterDataProvider = new InternalMediaCenterDataProvider(init.mediaPageId, graphqlOrigin);
|
|
18
|
+
}
|
|
19
|
+
let analyticsHandler = init.analyticsHandler;
|
|
20
|
+
if (!analyticsHandler && !init.dataProvider) {
|
|
21
|
+
// Only create internal analytics handler if using internal data provider
|
|
22
|
+
analyticsHandler = new InternalStreamAnalyticsHandler(graphqlOrigin);
|
|
23
|
+
}
|
|
31
24
|
const shadowHost = new ModalShadowHost();
|
|
32
|
-
const mounted = mount(
|
|
25
|
+
const mounted = mount(MediaCenter, {
|
|
33
26
|
target: shadowHost.shadowRoot,
|
|
34
27
|
props: {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
28
|
+
dataProvider: mediaCenterDataProvider || null,
|
|
29
|
+
playerProps: {
|
|
30
|
+
type: MediaCenterMode.Stream,
|
|
31
|
+
props: {
|
|
32
|
+
streamId,
|
|
33
|
+
dataProvider,
|
|
34
|
+
analyticsHandler,
|
|
35
|
+
localization,
|
|
36
|
+
showStreamsCloudWatermark,
|
|
37
|
+
postSocialInteractionsHandler,
|
|
38
|
+
on: {
|
|
39
|
+
streamActivated: (data) => {
|
|
40
|
+
if (init.on?.streamActivated) {
|
|
41
|
+
init.on.streamActivated({ title: data.title, image: data.image });
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
playerClosed: async () => {
|
|
45
|
+
await unmount(mounted);
|
|
46
|
+
shadowHost.remove();
|
|
47
|
+
if (init.on?.playerClosed) {
|
|
48
|
+
init.on.playerClosed();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
46
51
|
}
|
|
47
|
-
},
|
|
48
|
-
closePlayer: async () => {
|
|
49
|
-
if (init.on?.playerClosed) {
|
|
50
|
-
init.on.playerClosed();
|
|
51
|
-
}
|
|
52
|
-
await unmount(mounted);
|
|
53
|
-
shadowHost.remove();
|
|
54
52
|
}
|
|
55
53
|
}
|
|
56
54
|
}
|
|
57
55
|
});
|
|
58
56
|
shadowHost.attachToBody();
|
|
59
|
-
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IStreamAnalyticsHandler } from './types';
|
|
2
|
+
export declare class InternalStreamAnalyticsHandler implements IStreamAnalyticsHandler {
|
|
3
|
+
constructor(graphqlOrigin: string | undefined);
|
|
4
|
+
setOrganizationId: (organizationId: string) => void;
|
|
5
|
+
trackStreamView: (streamId: string) => void;
|
|
6
|
+
trackStreamPageView: (pageId: string, streamId: string) => void;
|
|
7
|
+
trackStreamProductClicked: (productId: string, streamId: string) => void;
|
|
8
|
+
trackStreamEngagementTime: (streamId: string, engagementTime: number) => void;
|
|
9
|
+
trackStreamScrollDepth: (streamId: string, scrollDepth: number) => void;
|
|
10
|
+
reportPageVideoViews: (videoId: string, streamId: string) => void;
|
|
11
|
+
trackShortVideoProgress: (pageId: string, videoId: string, progress: number, streamId: string) => void;
|
|
12
|
+
}
|