@streamscloud/embeddable 8.2.0 → 9.0.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/ads/ad-card/cmp.ad-card.svelte +8 -5
- package/dist/ads/ad-card/cmp.ad-card.svelte.d.ts +2 -0
- package/dist/content-player/cmp.content-player.svelte +1 -0
- package/dist/content-player/content-player-config.svelte.d.ts +8 -0
- package/dist/content-player/content-player-config.svelte.js +9 -1
- package/dist/content-player/controls-and-attachments.svelte +1 -0
- package/dist/core/enums.d.ts +5 -1
- package/dist/core/enums.js +4 -0
- package/dist/marketing-tracking/index.d.ts +2 -0
- package/dist/marketing-tracking/index.js +1 -0
- package/dist/marketing-tracking/service.d.ts +11 -0
- package/dist/marketing-tracking/service.js +35 -0
- package/dist/marketing-tracking/types.d.ts +5 -0
- package/dist/media-center/config/internal-media-center-analytics-handler.d.ts +3 -2
- package/dist/media-center/config/internal-media-center-analytics-handler.js +1 -0
- package/dist/media-center/config/internal-media-center-config.d.ts +1 -1
- package/dist/media-center/config/internal-media-center-config.js +11 -11
- package/dist/media-center/config/operations.generated.d.ts +4 -4
- package/dist/media-center/config/operations.generated.js +5 -8
- package/dist/media-center/config/operations.graphql +3 -3
- package/dist/media-center/config/types.d.ts +7 -5
- package/dist/media-center/config/types.js +1 -1
- package/dist/media-center/media-center/cmp.media-center.svelte +74 -17
- package/dist/media-center/media-center/cmp.media-center.svelte.d.ts +3 -3
- package/dist/media-center/media-center/discover-panel-handler.svelte.d.ts +5 -2
- package/dist/media-center/media-center/discover-panel-handler.svelte.js +8 -3
- package/dist/media-center/media-center/discover-panel.svelte +1 -1
- package/dist/media-center/media-center/discover-panel.svelte.d.ts +2 -2
- package/dist/media-center/media-center/post-player-provider-generator.d.ts +8 -0
- package/dist/media-center/media-center/{short-video-resources-generator.js → post-player-provider-generator.js} +8 -3
- package/dist/media-center/media-center/types.d.ts +1 -1
- package/dist/posts/attachments/cmp.attachments.svelte +14 -2
- package/dist/posts/attachments/cmp.attachments.svelte.d.ts +2 -0
- package/dist/posts/handlers/index.d.ts +1 -0
- package/dist/posts/handlers/index.js +1 -0
- package/dist/{short-videos/short-videos-player/internal-short-video-analytics-handler.d.ts → posts/handlers/internal-post-analytics-handler.d.ts} +3 -2
- package/dist/{short-videos/short-videos-player/internal-short-video-analytics-handler.js → posts/handlers/internal-post-analytics-handler.js} +2 -1
- package/dist/posts/model/post-model.d.ts +2 -0
- package/dist/posts/model/post-model.js +3 -0
- package/dist/posts/model/types.d.ts +2 -1
- package/dist/posts/model/types.js +1 -1
- package/dist/posts/post-viewer/attachments-horizontal.svelte +5 -4
- package/dist/posts/post-viewer/attachments-horizontal.svelte.d.ts +2 -0
- package/dist/posts/post-viewer/cmp.post-viewer.svelte +13 -2
- package/dist/posts/post-viewer/cmp.post-viewer.svelte.d.ts +2 -0
- package/dist/posts/post-viewer/mapper.js +18 -1
- package/dist/{short-videos/short-videos-player/cmp.short-videos-player.svelte → posts/posts-player/cmp.posts-player.svelte} +3 -3
- package/dist/posts/posts-player/cmp.posts-player.svelte.d.ts +4 -0
- package/dist/posts/posts-player/index.d.ts +31 -17
- package/dist/posts/posts-player/index.js +48 -31
- package/dist/posts/posts-player/mapper.d.ts +3 -0
- package/dist/{short-videos/short-videos-player → posts/posts-player}/mapper.js +2 -2
- package/dist/posts/posts-player/operations.generated.d.ts +80 -0
- package/dist/posts/posts-player/operations.generated.js +229 -0
- package/dist/posts/posts-player/operations.graphql +7 -0
- package/dist/posts/posts-player/posts-player-view.svelte +38 -4
- package/dist/posts/posts-player/posts-player-view.svelte.d.ts +5 -1
- package/dist/posts/posts-player/types.d.ts +7 -1
- package/dist/products/product-card/cmp.product-card.svelte +10 -7
- package/dist/products/product-card/cmp.product-card.svelte.d.ts +2 -0
- package/dist/products/product-card/mapper.d.ts +3 -1
- package/dist/products/product-card/mapper.js +2 -2
- package/dist/short-videos/data-providers/index.d.ts +1 -0
- package/dist/short-videos/data-providers/index.js +1 -0
- package/dist/short-videos/{short-videos-player/internal-short-video-player-provider.d.ts → data-providers/internal-short-video-player-items-provider.d.ts} +4 -4
- package/dist/short-videos/{short-videos-player/internal-short-video-player-provider.js → data-providers/internal-short-video-player-items-provider.js} +3 -3
- package/dist/short-videos/{short-videos-player → data-providers}/operations.generated.d.ts +0 -78
- package/dist/short-videos/{short-videos-player → data-providers}/operations.generated.js +2 -234
- package/dist/short-videos/{short-videos-player → data-providers}/operations.graphql +1 -9
- package/dist/short-videos/short-videos-player/index.d.ts +13 -62
- package/dist/short-videos/short-videos-player/index.js +76 -30
- package/dist/streams/layout/cmp.slot-content.svelte +14 -6
- package/dist/streams/layout/cmp.slot-content.svelte.d.ts +2 -0
- package/dist/streams/layout/element-views/cmp.container-stream-element.svelte +7 -2
- package/dist/streams/layout/element-views/cmp.container-stream-element.svelte.d.ts +2 -0
- package/dist/streams/layout/element-views/cmp.short-video-stream-element.svelte +8 -2
- package/dist/streams/layout/element-views/cmp.short-video-stream-element.svelte.d.ts +2 -0
- package/dist/streams/layout/element-views/cmp.stream-element.svelte +3 -2
- package/dist/streams/layout/element-views/cmp.stream-element.svelte.d.ts +2 -0
- package/dist/streams/layout/index.d.ts +1 -0
- package/dist/streams/layout/models/mapper.js +2 -1
- package/dist/streams/layout/serializer.svelte.js +0 -1
- package/dist/streams/layout/types.d.ts +4 -0
- package/dist/streams/layout/types.js +1 -0
- package/dist/streams/stream-page-viewer/cmp.stream-page-viewer.svelte +2 -2
- package/dist/streams/stream-page-viewer/cmp.stream-page-viewer.svelte.d.ts +2 -0
- package/dist/streams/stream-player/stream-player-view.svelte +15 -3
- package/dist/ui/player-slider/player-buffer.svelte.d.ts +1 -0
- package/dist/ui/swipe-indicator/cmp.swipe-indicator.svelte +7 -8
- package/package.json +1 -1
- package/dist/media-center/media-center/short-video-resources-generator.d.ts +0 -8
- package/dist/short-videos/short-videos-player/cmp.short-videos-player.svelte.d.ts +0 -4
- package/dist/short-videos/short-videos-player/mapper.d.ts +0 -3
- package/dist/short-videos/short-videos-player/short-videos-player-view.svelte +0 -82
- package/dist/short-videos/short-videos-player/short-videos-player-view.svelte.d.ts +0 -8
- package/dist/short-videos/short-videos-player/types.d.ts +0 -26
- /package/dist/{short-videos/short-videos-player → marketing-tracking}/types.js +0 -0
|
@@ -1,46 +1,93 @@
|
|
|
1
|
-
import { toastrWarning } from '../../core/toastr';
|
|
2
1
|
import { InternalMediaCenterConfig } from '../../media-center/config/internal-media-center-config';
|
|
3
2
|
import {} from '../../media-center/config/types';
|
|
4
3
|
import { MediaCenter } from '../../media-center/media-center';
|
|
4
|
+
import { InternalPostAnalyticsHandler } from '../../posts/handlers';
|
|
5
|
+
import { InternalShortVideoPlayerItemsProvider } from '../data-providers';
|
|
5
6
|
import { ModalShadowHost } from '../../ui/shadow-dom';
|
|
6
|
-
import { default as ShortVideosPlayer } from './cmp.short-videos-player.svelte';
|
|
7
|
-
import { InternalShortVideoAnalyticsHandler } from './internal-short-video-analytics-handler';
|
|
8
|
-
import { InternalShortVideoPlayerProvider } from './internal-short-video-player-provider';
|
|
9
|
-
import { mapToShortVideoPlayerModel } from './mapper';
|
|
10
7
|
import { mount, unmount } from 'svelte';
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Opens the short videos player modal.
|
|
10
|
+
*
|
|
11
|
+
* @param init Configuration options.
|
|
12
|
+
*
|
|
13
|
+
* IDs mode (overload 2)
|
|
14
|
+
* @param {string[]} init.ids
|
|
15
|
+
* List of short-video IDs to display.
|
|
16
|
+
* @param {string} init.initiator
|
|
17
|
+
* Identifier of the initiator (used for tracking/analytics and GraphQL).
|
|
18
|
+
* @param {string} [init.graphqlOrigin]
|
|
19
|
+
* Optional GraphQL origin (base URL). If omitted, the default origin is determined internally.
|
|
20
|
+
* @param {string} [init.initialId]
|
|
21
|
+
* ID of the video to open first (optional).
|
|
22
|
+
* @param {string} [init.mediaPageId]
|
|
23
|
+
* Optional media page ID used to construct an internal media-center config.
|
|
24
|
+
*
|
|
25
|
+
* Player settings
|
|
26
|
+
* @param {IPostSocialInteractionsHandler} [init.socialInteractionsHandler]
|
|
27
|
+
* Handler for social interactions (like, share, etc.).
|
|
28
|
+
* @param [init.playerSettings]
|
|
29
|
+
* Player UI and behavior settings.
|
|
30
|
+
*
|
|
31
|
+
* Fields of ContentPlayerSettings:
|
|
32
|
+
* - {boolean} [hideCloseButton]
|
|
33
|
+
* If true, hides the close button.
|
|
34
|
+
* - {Locale} [locale='en']
|
|
35
|
+
* Localization for the player UI. Supported values: 'en' | 'no'.
|
|
36
|
+
* If omitted, the default locale 'en' is used.
|
|
37
|
+
*
|
|
38
|
+
* Events
|
|
39
|
+
* @param {{ playerClosed?: () => void; videoActivated?: (id: string) => void }} [init.on]
|
|
40
|
+
* Optional event handlers.
|
|
41
|
+
* @param {() => void} [init.on.playerClosed]
|
|
42
|
+
* Called after the player is fully closed (after unmount and removal from the DOM).
|
|
43
|
+
* @param {(id: string) => void} [init.on.videoActivated]
|
|
44
|
+
* Called when a video becomes active (receives the video's id).
|
|
45
|
+
*
|
|
46
|
+
* @returns {void}
|
|
47
|
+
*
|
|
48
|
+
* @example <caption>IDs mode</caption>
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { openShortVideosPlayer } from '@streamscloud/embeddable/short-videos-player';
|
|
51
|
+
*
|
|
52
|
+
* openShortVideosPlayer({
|
|
53
|
+
* ids: ['id1', 'id2', 'id3'],
|
|
54
|
+
* initiator: 'campaign-autumn',
|
|
55
|
+
* graphqlOrigin: 'https://graphql.example.com',
|
|
56
|
+
* initialId: 'id2',
|
|
57
|
+
* mediaPageId: 'media-page-123',
|
|
58
|
+
* playerSettings: {
|
|
59
|
+
* // Default locale is 'en'; set 'no' to switch to Norwegian:
|
|
60
|
+
* locale: 'no',
|
|
61
|
+
* disableBackground: false,
|
|
62
|
+
* hideCloseButton: false,
|
|
63
|
+
* showStreamsCloudWatermark: true,
|
|
64
|
+
* },
|
|
65
|
+
* on: {
|
|
66
|
+
* playerClosed: () => console.log('Player closed'),
|
|
67
|
+
* }
|
|
68
|
+
* });
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
13
71
|
export function openShortVideosPlayer(init) {
|
|
14
|
-
const {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
if (!dataProvider) {
|
|
20
|
-
toastrWarning('Data provider is not specified.');
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
let mediaCenterConfig = init.mediaCenterConfig;
|
|
24
|
-
if (!mediaCenterConfig && init.mediaPageId) {
|
|
25
|
-
mediaCenterConfig = new InternalMediaCenterConfig(init.mediaPageId, graphqlOrigin);
|
|
26
|
-
}
|
|
27
|
-
let analyticsHandler = init.analyticsHandler;
|
|
28
|
-
if (!analyticsHandler && !init.shortVideosProvider) {
|
|
29
|
-
// Only create internal analytics handler if using internal data provider
|
|
30
|
-
analyticsHandler = new InternalShortVideoAnalyticsHandler(graphqlOrigin);
|
|
31
|
-
}
|
|
72
|
+
const { ids, graphqlOrigin, initialId, initiator, playerSettings, on } = init;
|
|
73
|
+
const dataProvider = new InternalShortVideoPlayerItemsProvider({ ids, graphqlOrigin, initialId, initiator });
|
|
74
|
+
const mediaCenterConfig = init.mediaPageId ? new InternalMediaCenterConfig(init.mediaPageId, graphqlOrigin) : undefined;
|
|
75
|
+
const analyticsHandler = new InternalPostAnalyticsHandler(graphqlOrigin);
|
|
32
76
|
const shadowHost = new ModalShadowHost();
|
|
33
77
|
const mounted = mount(MediaCenter, {
|
|
34
78
|
target: shadowHost.shadowRoot,
|
|
35
79
|
props: {
|
|
36
80
|
config: mediaCenterConfig || null,
|
|
37
81
|
playerProps: {
|
|
38
|
-
mode: '
|
|
82
|
+
mode: 'posts',
|
|
39
83
|
props: {
|
|
40
84
|
dataProvider,
|
|
41
|
-
socialInteractionsHandler,
|
|
42
85
|
analyticsHandler,
|
|
43
|
-
playerSettings
|
|
86
|
+
playerSettings: {
|
|
87
|
+
hideCloseButton: playerSettings?.hideCloseButton,
|
|
88
|
+
locale: playerSettings?.locale,
|
|
89
|
+
showStreamsCloudWatermark: true
|
|
90
|
+
},
|
|
44
91
|
on: {
|
|
45
92
|
playerClosed: async () => {
|
|
46
93
|
await unmount(mounted);
|
|
@@ -48,8 +95,7 @@ export function openShortVideosPlayer(init) {
|
|
|
48
95
|
if (on?.playerClosed) {
|
|
49
96
|
on.playerClosed();
|
|
50
97
|
}
|
|
51
|
-
}
|
|
52
|
-
videoActivated: on?.videoActivated
|
|
98
|
+
}
|
|
53
99
|
}
|
|
54
100
|
}
|
|
55
101
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script lang="ts">import { Utils } from '../../core/utils';
|
|
2
|
+
import { enrichProductLinkWithTracking } from '../../marketing-tracking';
|
|
2
3
|
import { StreamElementView } from './element-views';
|
|
3
4
|
import { StreamComponentDataType } from './enums';
|
|
4
|
-
let { model, locale, on } = $props();
|
|
5
|
+
let { model, locale, trackingParams, on } = $props();
|
|
5
6
|
const component = $derived.by(() => {
|
|
6
7
|
return model.components.find((c) => (model.data ? c.dataType === model.data.type : c.dataType === StreamComponentDataType.NoData));
|
|
7
8
|
});
|
|
@@ -27,6 +28,13 @@ const productModel = $derived.by(() => {
|
|
|
27
28
|
var _a;
|
|
28
29
|
return ((_a = model.data) === null || _a === void 0 ? void 0 : _a.type) === StreamComponentDataType.Product ? model.data.product : undefined;
|
|
29
30
|
});
|
|
31
|
+
const enrichedLink = $derived((productModel === null || productModel === void 0 ? void 0 : productModel.link)
|
|
32
|
+
? enrichProductLinkWithTracking({
|
|
33
|
+
link: productModel.link,
|
|
34
|
+
productId: productModel.id,
|
|
35
|
+
trackingParams
|
|
36
|
+
})
|
|
37
|
+
: null);
|
|
30
38
|
const handleProductClick = (e) => {
|
|
31
39
|
e.preventDefault();
|
|
32
40
|
if (!productModel) {
|
|
@@ -35,8 +43,8 @@ const handleProductClick = (e) => {
|
|
|
35
43
|
if (productModel.id && (on === null || on === void 0 ? void 0 : on.productClick)) {
|
|
36
44
|
on.productClick(productModel.id);
|
|
37
45
|
}
|
|
38
|
-
if (
|
|
39
|
-
window.open(
|
|
46
|
+
if (enrichedLink) {
|
|
47
|
+
window.open(enrichedLink, '_blank', 'noopener noreferrer');
|
|
40
48
|
}
|
|
41
49
|
};
|
|
42
50
|
const productLinkMounted = (node, productModel) => {
|
|
@@ -65,14 +73,14 @@ const productLinkMounted = (node, productModel) => {
|
|
|
65
73
|
{#snippet slotContent()}
|
|
66
74
|
{#if component && (!model.data || dataIsFilled)}
|
|
67
75
|
{#each component.elements as element (element)}
|
|
68
|
-
<StreamElementView model={element} data={model.data} locale={locale} on={on} />
|
|
76
|
+
<StreamElementView model={element} data={model.data} trackingParams={trackingParams} locale={locale} on={on} />
|
|
69
77
|
{/each}
|
|
70
78
|
{/if}
|
|
71
79
|
{/snippet}
|
|
72
|
-
{#if productModel
|
|
80
|
+
{#if productModel && enrichedLink}
|
|
73
81
|
<a
|
|
74
82
|
class="stream-slot-content-product-link"
|
|
75
|
-
href={
|
|
83
|
+
href={enrichedLink.href}
|
|
76
84
|
onclick={handleProductClick}
|
|
77
85
|
target="_blank"
|
|
78
86
|
rel="noopener noreferrer"
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { Locale } from '../../core/locale';
|
|
2
|
+
import type { StreamTrackingParams } from './types';
|
|
2
3
|
import type { StreamSlot } from './slot';
|
|
3
4
|
type Props = {
|
|
4
5
|
model: StreamSlot;
|
|
5
6
|
locale: Locale;
|
|
7
|
+
trackingParams: StreamTrackingParams;
|
|
6
8
|
on?: {
|
|
7
9
|
productClick: (productId: string) => void;
|
|
8
10
|
productImpression?: (productId: string) => void;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
<script lang="ts">import { StreamElementStyleDirection } from '../enums';
|
|
2
2
|
import { generateContainerStyles } from '../styles-transformer';
|
|
3
3
|
import { default as StreamElement } from './cmp.stream-element.svelte';
|
|
4
|
-
let { model, data, locale } = $props();
|
|
4
|
+
let { model, data, trackingParams, locale } = $props();
|
|
5
5
|
</script>
|
|
6
6
|
|
|
7
7
|
<div class="container-stream-element" style={generateContainerStyles(model.styles)}>
|
|
8
8
|
{#each model.elements as element (element)}
|
|
9
|
-
<StreamElement
|
|
9
|
+
<StreamElement
|
|
10
|
+
model={element}
|
|
11
|
+
data={data}
|
|
12
|
+
trackingParams={trackingParams}
|
|
13
|
+
constainerDirection={model.styles?.direction ?? StreamElementStyleDirection.Vertical}
|
|
14
|
+
locale={locale} />
|
|
10
15
|
{/each}
|
|
11
16
|
</div>
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { Locale } from '../../../core/locale';
|
|
2
|
+
import type { StreamTrackingParams } from '..';
|
|
2
3
|
import type { ContainerStreamElementModel } from '../elements';
|
|
3
4
|
import type { StreamSlotData } from '../slot-data';
|
|
4
5
|
type Props = {
|
|
5
6
|
model: ContainerStreamElementModel;
|
|
6
7
|
data: StreamSlotData | null;
|
|
8
|
+
trackingParams: StreamTrackingParams;
|
|
7
9
|
locale: Locale;
|
|
8
10
|
};
|
|
9
11
|
declare const Cmp: import("svelte").Component<Props, {}, "">;
|
|
@@ -2,8 +2,14 @@
|
|
|
2
2
|
import { PostViewer } from '../../../posts/post-viewer';
|
|
3
3
|
import { ShortVideoStreamElementLocalization } from './short-video-stream-element-localization';
|
|
4
4
|
import { mapToPostModel } from '../models';
|
|
5
|
-
let { data, locale, on } = $props();
|
|
5
|
+
let { data, trackingParams, locale, on } = $props();
|
|
6
6
|
const localization = $derived(new ShortVideoStreamElementLocalization(locale));
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
|
-
<PostViewer
|
|
9
|
+
<PostViewer
|
|
10
|
+
model={new PostModel(mapToPostModel(data))}
|
|
11
|
+
trackingParams={trackingParams ? { streamId: trackingParams.streamId, campaignId: trackingParams.campaignId } : false}
|
|
12
|
+
autoplay={false}
|
|
13
|
+
enableControls={false}
|
|
14
|
+
locale={localization.shortVideoViewerLocale}
|
|
15
|
+
on={on} />
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Locale } from '../../../core/locale';
|
|
2
|
+
import type { StreamTrackingParams } from '..';
|
|
2
3
|
import { type StreamLayoutShortVideoModel } from '../models';
|
|
3
4
|
type Props = {
|
|
4
5
|
data: StreamLayoutShortVideoModel;
|
|
6
|
+
trackingParams: StreamTrackingParams;
|
|
5
7
|
locale: Locale;
|
|
6
8
|
on?: {
|
|
7
9
|
progress?: (progress: number) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">import { AnnotationStreamElementView, ContainerStreamElementView, ImageRefStreamElementView, ImagesStreamElementView, PriceStreamElementView, ShortVideoStreamElementView, SpacerStreamElementView, StockStreamElementView, TextRefStreamElementView, TextStreamElementView, WebViewStreamElementView } from '.';
|
|
2
2
|
import { StreamElementLocalization } from './stream-element-localization';
|
|
3
3
|
import { StreamComponentDataType, StreamElementStyleDirection, StreamElementType } from '../enums';
|
|
4
|
-
let { model, data, constainerDirection = StreamElementStyleDirection.Vertical, locale, on } = $props();
|
|
4
|
+
let { model, data, trackingParams, constainerDirection = StreamElementStyleDirection.Vertical, locale, on } = $props();
|
|
5
5
|
const localization = $derived(new StreamElementLocalization(locale));
|
|
6
6
|
const shortVideoModel = $derived.by(() => {
|
|
7
7
|
if (!data) {
|
|
@@ -44,7 +44,7 @@ const productModel = $derived.by(() => {
|
|
|
44
44
|
{#if model.type === StreamElementType.Annotation}
|
|
45
45
|
<AnnotationStreamElementView model={model} />
|
|
46
46
|
{:else if model.type === StreamElementType.Container}
|
|
47
|
-
<ContainerStreamElementView model={model} data={data} locale={locale} />
|
|
47
|
+
<ContainerStreamElementView model={model} data={data} trackingParams={trackingParams} locale={locale} />
|
|
48
48
|
{:else if model.type === StreamElementType.ImageRef && data}
|
|
49
49
|
<ImageRefStreamElementView model={model} data={data} />
|
|
50
50
|
{:else if model.type === StreamElementType.Images && imagesModel?.length}
|
|
@@ -54,6 +54,7 @@ const productModel = $derived.by(() => {
|
|
|
54
54
|
{:else if model.type === StreamElementType.ShortVideo && shortVideoModel}
|
|
55
55
|
<ShortVideoStreamElementView
|
|
56
56
|
data={shortVideoModel}
|
|
57
|
+
trackingParams={trackingParams}
|
|
57
58
|
locale={localization.shortVideoElementLocalization}
|
|
58
59
|
on={on
|
|
59
60
|
? {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { Locale } from '../../../core/locale';
|
|
2
|
+
import type { StreamTrackingParams } from '..';
|
|
2
3
|
import type { StreamElementModel } from '../elements';
|
|
3
4
|
import { StreamElementStyleDirection } from '../enums';
|
|
4
5
|
import type { StreamSlotData } from '../slot-data';
|
|
5
6
|
type Props = {
|
|
6
7
|
model: StreamElementModel;
|
|
7
8
|
data: StreamSlotData | null;
|
|
9
|
+
trackingParams: StreamTrackingParams;
|
|
8
10
|
constainerDirection?: StreamElementStyleDirection;
|
|
9
11
|
locale: Locale;
|
|
10
12
|
on?: {
|
|
@@ -7,6 +7,7 @@ export { default as StreamLayoutSlot } from './cmp.slot.svelte';
|
|
|
7
7
|
export { default as StreamLayoutSlotContent } from './cmp.slot-content.svelte';
|
|
8
8
|
export * from './layout';
|
|
9
9
|
export * from './svg-attributes';
|
|
10
|
+
export type { StreamTrackingParams } from './types';
|
|
10
11
|
export { parseToStreamLayout, parseToStreamLayoutTemplate, stringifyToStreamLayoutInput, IdPopulator } from './serializer.svelte';
|
|
11
12
|
export declare const getAllowedDataTypesForSlot: (slot: StreamSlot) => StreamComponentDataType[];
|
|
12
13
|
export declare const getSingleShortVideoFromLayout: (layout: StreamLayout) => StreamLayoutShortVideoModel | null;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { MediaType } from '../../../core/enums';
|
|
1
|
+
import { MediaType, PostType } from '../../../core/enums';
|
|
2
2
|
import {} from '../../../posts/model';
|
|
3
3
|
export const mapToPostModel = (model) => {
|
|
4
4
|
return {
|
|
5
5
|
id: model.id,
|
|
6
|
+
postType: PostType.ShortVideo,
|
|
6
7
|
media: [
|
|
7
8
|
model.media.type === MediaType.Image
|
|
8
9
|
? { isImage: true, url: model.media.url }
|
|
@@ -79,7 +79,6 @@ export class IdPopulator {
|
|
|
79
79
|
}
|
|
80
80
|
static populateElementId(element) {
|
|
81
81
|
element.$id = nanoid(10);
|
|
82
|
-
// Рекурсивно обрабатываем дочерние элементы
|
|
83
82
|
if (element.type === StreamElementType.Container && element.elements) {
|
|
84
83
|
element.elements.forEach((element) => IdPopulator.populateElementId(element));
|
|
85
84
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">import { StreamLayoutSlot, StreamPageLayout, StreamLayoutSlotContent } from '../layout';
|
|
2
2
|
import { StreamPageViewerLocalization } from './stream-page-viewer-localization';
|
|
3
|
-
let { page, locale, on } = $props();
|
|
3
|
+
let { page, trackingParams, locale, on } = $props();
|
|
4
4
|
const localization = $derived(new StreamPageViewerLocalization(locale));
|
|
5
5
|
</script>
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ const localization = $derived(new StreamPageViewerLocalization(locale));
|
|
|
8
8
|
<StreamPageLayout model={page.layout}>
|
|
9
9
|
{#each page.layout.slots as slot (slot)}
|
|
10
10
|
<StreamLayoutSlot model={slot}>
|
|
11
|
-
<StreamLayoutSlotContent model={slot} on={on} locale={localization.elementsLocale} />
|
|
11
|
+
<StreamLayoutSlotContent model={slot} trackingParams={trackingParams} on={on} locale={localization.elementsLocale} />
|
|
12
12
|
</StreamLayoutSlot>
|
|
13
13
|
{/each}
|
|
14
14
|
</StreamPageLayout>
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Locale } from '../../core/locale';
|
|
2
|
+
import { type StreamTrackingParams } from '../layout';
|
|
2
3
|
import type { StreamPageViewerModel } from './types';
|
|
3
4
|
type Props = {
|
|
4
5
|
page: StreamPageViewerModel;
|
|
6
|
+
trackingParams: StreamTrackingParams;
|
|
5
7
|
locale: Locale;
|
|
6
8
|
on?: {
|
|
7
9
|
productClick: (productId: string) => void;
|
|
@@ -29,9 +29,6 @@ let isActive = true;
|
|
|
29
29
|
let activityTimeout = null;
|
|
30
30
|
let trackingInterval = null;
|
|
31
31
|
let maxPageIndexViewed = 0;
|
|
32
|
-
if (amplificationParameters) {
|
|
33
|
-
console.warn(`amplificationParameters: ${JSON.stringify(amplificationParameters)}`);
|
|
34
|
-
}
|
|
35
32
|
$effect(() => {
|
|
36
33
|
void streamId;
|
|
37
34
|
untrack(() => {
|
|
@@ -51,6 +48,20 @@ $effect(() => {
|
|
|
51
48
|
};
|
|
52
49
|
});
|
|
53
50
|
$effect(() => contentPlayerConfig.updateMediaCenterData(mediaCenterData));
|
|
51
|
+
$effect(() => contentPlayerConfig.updateTrackingParams(currentStreamModel
|
|
52
|
+
? {
|
|
53
|
+
streamId: currentStreamModel.id,
|
|
54
|
+
campaignId: amplificationParameters === null || amplificationParameters === void 0 ? void 0 : amplificationParameters.campaignId
|
|
55
|
+
}
|
|
56
|
+
: null));
|
|
57
|
+
const streamTrackingParams = $derived.by(() => {
|
|
58
|
+
return currentStreamModel
|
|
59
|
+
? {
|
|
60
|
+
streamId: currentStreamModel.id,
|
|
61
|
+
campaignId: amplificationParameters === null || amplificationParameters === void 0 ? void 0 : amplificationParameters.campaignId
|
|
62
|
+
}
|
|
63
|
+
: false;
|
|
64
|
+
});
|
|
54
65
|
const initNewStream = (streamId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
66
|
var _a, _b;
|
|
56
67
|
const stream = yield dataProvider.getStream(streamId);
|
|
@@ -201,6 +212,7 @@ const stopActivityTracking = () => {
|
|
|
201
212
|
{#if item.type === 'general'}
|
|
202
213
|
<StreamPageViewer
|
|
203
214
|
page={item}
|
|
215
|
+
trackingParams={streamTrackingParams}
|
|
204
216
|
locale={localization.locale}
|
|
205
217
|
on={{
|
|
206
218
|
progress: (videoId, progress) => onProgress(item.id, videoId, progress),
|
|
@@ -27,8 +27,7 @@ const indicatorMounted = (_) => {
|
|
|
27
27
|
</div>
|
|
28
28
|
</div>
|
|
29
29
|
|
|
30
|
-
<style>@
|
|
31
|
-
@keyframes fadeIn {
|
|
30
|
+
<style>@keyframes fadeIn {
|
|
32
31
|
0% {
|
|
33
32
|
opacity: 1;
|
|
34
33
|
}
|
|
@@ -87,37 +86,37 @@ const indicatorMounted = (_) => {
|
|
|
87
86
|
transform: translateY(0);
|
|
88
87
|
}
|
|
89
88
|
10% {
|
|
90
|
-
transform: translateY(-24px);
|
|
89
|
+
transform: translateY(-24px);
|
|
91
90
|
}
|
|
92
91
|
18% {
|
|
93
92
|
transform: translateY(0);
|
|
94
93
|
}
|
|
95
94
|
26% {
|
|
96
|
-
transform: translateY(-12px);
|
|
95
|
+
transform: translateY(-12px);
|
|
97
96
|
}
|
|
98
97
|
34% {
|
|
99
98
|
transform: translateY(0);
|
|
100
99
|
}
|
|
101
100
|
41% {
|
|
102
|
-
transform: translateY(-8px);
|
|
101
|
+
transform: translateY(-8px);
|
|
103
102
|
}
|
|
104
103
|
48% {
|
|
105
104
|
transform: translateY(0);
|
|
106
105
|
}
|
|
107
106
|
54% {
|
|
108
|
-
transform: translateY(-4px);
|
|
107
|
+
transform: translateY(-4px);
|
|
109
108
|
}
|
|
110
109
|
60% {
|
|
111
110
|
transform: translateY(0);
|
|
112
111
|
}
|
|
113
112
|
65% {
|
|
114
|
-
transform: translateY(-2px);
|
|
113
|
+
transform: translateY(-2px);
|
|
115
114
|
}
|
|
116
115
|
70% {
|
|
117
116
|
transform: translateY(0);
|
|
118
117
|
}
|
|
119
118
|
75% {
|
|
120
|
-
transform: translateY(-1px);
|
|
119
|
+
transform: translateY(-1px);
|
|
121
120
|
}
|
|
122
121
|
80% {
|
|
123
122
|
transform: translateY(0);
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ShortVideoPlayerModel } from '../../short-videos/short-videos-player';
|
|
2
|
-
import type { IPlayerItemsProvider } from '../../ui/player-slider';
|
|
3
|
-
import type { IMediaCenterConfig } from '../config/types';
|
|
4
|
-
export declare const makeShortVideosProvider: (data: {
|
|
5
|
-
config: IMediaCenterConfig;
|
|
6
|
-
categoryId?: string;
|
|
7
|
-
prefetchedItems?: ShortVideoPlayerModel[];
|
|
8
|
-
}) => IPlayerItemsProvider<ShortVideoPlayerModel>;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
<script lang="ts">var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { ContentPlayer, ContentPlayerConfig } from '../../content-player';
|
|
11
|
-
import { ContentPlayerSettings } from '../../content-player/content-player-settings';
|
|
12
|
-
import { preloadImage } from '../../core/image-preloader';
|
|
13
|
-
import { getPostCoverImage } from '../../posts/model';
|
|
14
|
-
import { PlayerBuffer } from '../../ui/player-slider';
|
|
15
|
-
import { InternalShortVideoPlayerProvider } from './internal-short-video-player-provider';
|
|
16
|
-
import { untrack } from 'svelte';
|
|
17
|
-
let { dataProvider, socialInteractionsHandler, playerSettings, analyticsHandler, on, mediaCenterData } = $props();
|
|
18
|
-
$effect(() => {
|
|
19
|
-
void dataProvider;
|
|
20
|
-
untrack(() => {
|
|
21
|
-
contentPlayerConfig.playerBuffer = null;
|
|
22
|
-
initBuffer(dataProvider);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
$effect(() => contentPlayerConfig.updateMediaCenterData(mediaCenterData));
|
|
26
|
-
const initBuffer = (dataProvider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
-
if (dataProvider instanceof InternalShortVideoPlayerProvider) {
|
|
28
|
-
yield dataProvider.prefetch();
|
|
29
|
-
}
|
|
30
|
-
new PlayerBuffer(dataProvider, {
|
|
31
|
-
preloaded: (instance) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
-
if (instance.loaded.length) {
|
|
33
|
-
const coverUrl = getPostCoverImage(instance.loaded[0]);
|
|
34
|
-
yield preloadImage(coverUrl);
|
|
35
|
-
contentPlayerConfig.setBackgroundImageUrl(coverUrl);
|
|
36
|
-
}
|
|
37
|
-
contentPlayerConfig.playerBuffer = instance;
|
|
38
|
-
})
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
const contentPlayerConfig = new ContentPlayerConfig({
|
|
42
|
-
playerBuffer: null,
|
|
43
|
-
mappers: {
|
|
44
|
-
postModelFromCurrentItem: (item) => item
|
|
45
|
-
},
|
|
46
|
-
socialInteractionsHandler,
|
|
47
|
-
mediaCenterData,
|
|
48
|
-
settings: new ContentPlayerSettings(playerSettings),
|
|
49
|
-
callbacks: {
|
|
50
|
-
close: on === null || on === void 0 ? void 0 : on.playerClosed,
|
|
51
|
-
productClick: (id, videoId) => {
|
|
52
|
-
analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackShortVideoProductClick(id, videoId);
|
|
53
|
-
},
|
|
54
|
-
productImpression: (id, videoId) => {
|
|
55
|
-
analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackShortVideoProductImpression(id, videoId);
|
|
56
|
-
},
|
|
57
|
-
adClick: (id) => {
|
|
58
|
-
analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackAdClick(id);
|
|
59
|
-
},
|
|
60
|
-
adImpression: (id) => {
|
|
61
|
-
analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackAdImpression(id);
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
playerSliderCallbacks: {
|
|
65
|
-
itemActivated: (id) => {
|
|
66
|
-
var _a, _b;
|
|
67
|
-
const shortVideo = (_a = contentPlayerConfig.playerBuffer) === null || _a === void 0 ? void 0 : _a.loaded.find((x) => x.id === id);
|
|
68
|
-
if (!shortVideo) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
contentPlayerConfig.setBackgroundImageUrl(getPostCoverImage(shortVideo));
|
|
72
|
-
if (shortVideo.analyticsOrganizationId) {
|
|
73
|
-
analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.setOrganizationId(shortVideo.analyticsOrganizationId);
|
|
74
|
-
}
|
|
75
|
-
analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackShortVideoView(id);
|
|
76
|
-
(_b = on === null || on === void 0 ? void 0 : on.videoActivated) === null || _b === void 0 ? void 0 : _b.call(on, id);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
</script>
|
|
81
|
-
|
|
82
|
-
<ContentPlayer config={contentPlayerConfig} />
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { MediaCenterData } from '../../media-center/model/types';
|
|
2
|
-
import type { ShortVideoPlayerProps } from './types';
|
|
3
|
-
type $$ComponentProps = ShortVideoPlayerProps & {
|
|
4
|
-
mediaCenterData?: MediaCenterData;
|
|
5
|
-
};
|
|
6
|
-
declare const ShortVideosPlayerView: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
-
type ShortVideosPlayerView = ReturnType<typeof ShortVideosPlayerView>;
|
|
8
|
-
export default ShortVideosPlayerView;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { IContentPlayerSettingsInitializer } from '../../content-player/content-player-settings';
|
|
2
|
-
import type { IPostModel } from '../../posts';
|
|
3
|
-
import type { IPostSocialInteractionsHandler } from '../../posts/social-interactions';
|
|
4
|
-
import type { IPlayerItemsProvider } from '../../ui/player-slider';
|
|
5
|
-
export interface IShortVideoAnalyticsHandler {
|
|
6
|
-
setOrganizationId: (organizationId: string) => void;
|
|
7
|
-
trackShortVideoView: (videoId: string) => void;
|
|
8
|
-
trackShortVideoProductImpression: (productId: string, videoId: string) => void;
|
|
9
|
-
trackShortVideoProductClick: (productId: string, videoId: string) => void;
|
|
10
|
-
trackAdClick: (adId: string) => void;
|
|
11
|
-
trackAdImpression: (adId: string) => void;
|
|
12
|
-
}
|
|
13
|
-
export type ShortVideoPlayerModel = IPostModel & {
|
|
14
|
-
analyticsOrganizationId: string | null;
|
|
15
|
-
};
|
|
16
|
-
export type ShortVideoPlayerProps = {
|
|
17
|
-
dataProvider: IPlayerItemsProvider<ShortVideoPlayerModel>;
|
|
18
|
-
socialInteractionsHandler?: IPostSocialInteractionsHandler;
|
|
19
|
-
analyticsHandler?: IShortVideoAnalyticsHandler;
|
|
20
|
-
playerSettings?: ShortVideoPlayerSettings;
|
|
21
|
-
on?: {
|
|
22
|
-
playerClosed?: () => void;
|
|
23
|
-
videoActivated?: (id: string) => void;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export type ShortVideoPlayerSettings = Pick<IContentPlayerSettingsInitializer, 'disableBackground' | 'hideCloseButton' | 'locale' | 'showStreamsCloudWatermark'>;
|
|
File without changes
|