@streamscloud/embeddable 8.3.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.
Files changed (52) hide show
  1. package/dist/media-center/config/internal-media-center-analytics-handler.d.ts +3 -2
  2. package/dist/media-center/config/internal-media-center-analytics-handler.js +1 -0
  3. package/dist/media-center/config/internal-media-center-config.d.ts +1 -1
  4. package/dist/media-center/config/internal-media-center-config.js +11 -11
  5. package/dist/media-center/config/operations.generated.d.ts +4 -4
  6. package/dist/media-center/config/operations.generated.js +5 -8
  7. package/dist/media-center/config/operations.graphql +3 -3
  8. package/dist/media-center/config/types.d.ts +7 -5
  9. package/dist/media-center/config/types.js +1 -1
  10. package/dist/media-center/media-center/cmp.media-center.svelte +74 -17
  11. package/dist/media-center/media-center/cmp.media-center.svelte.d.ts +3 -3
  12. package/dist/media-center/media-center/discover-panel-handler.svelte.d.ts +3 -2
  13. package/dist/media-center/media-center/discover-panel-handler.svelte.js +2 -1
  14. package/dist/media-center/media-center/discover-panel.svelte.d.ts +2 -2
  15. package/dist/media-center/media-center/post-player-provider-generator.d.ts +8 -0
  16. package/dist/media-center/media-center/{short-video-resources-generator.js → post-player-provider-generator.js} +8 -3
  17. package/dist/media-center/media-center/types.d.ts +1 -1
  18. package/dist/posts/handlers/index.d.ts +1 -0
  19. package/dist/posts/handlers/index.js +1 -0
  20. package/dist/{short-videos/short-videos-player/internal-short-video-analytics-handler.d.ts → posts/handlers/internal-post-analytics-handler.d.ts} +3 -2
  21. package/dist/{short-videos/short-videos-player/internal-short-video-analytics-handler.js → posts/handlers/internal-post-analytics-handler.js} +2 -1
  22. package/dist/{short-videos/short-videos-player/cmp.short-videos-player.svelte → posts/posts-player/cmp.posts-player.svelte} +3 -3
  23. package/dist/posts/posts-player/cmp.posts-player.svelte.d.ts +4 -0
  24. package/dist/posts/posts-player/index.d.ts +31 -17
  25. package/dist/posts/posts-player/index.js +48 -31
  26. package/dist/posts/posts-player/mapper.d.ts +3 -0
  27. package/dist/{short-videos/short-videos-player → posts/posts-player}/mapper.js +2 -2
  28. package/dist/posts/posts-player/operations.generated.d.ts +80 -0
  29. package/dist/posts/posts-player/operations.generated.js +229 -0
  30. package/dist/posts/posts-player/operations.graphql +7 -0
  31. package/dist/posts/posts-player/posts-player-view.svelte +38 -4
  32. package/dist/posts/posts-player/posts-player-view.svelte.d.ts +5 -1
  33. package/dist/posts/posts-player/types.d.ts +7 -1
  34. package/dist/short-videos/data-providers/index.d.ts +1 -0
  35. package/dist/short-videos/data-providers/index.js +1 -0
  36. 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
  37. package/dist/short-videos/{short-videos-player/internal-short-video-player-provider.js → data-providers/internal-short-video-player-items-provider.js} +3 -3
  38. package/dist/short-videos/{short-videos-player → data-providers}/operations.generated.d.ts +0 -78
  39. package/dist/short-videos/{short-videos-player → data-providers}/operations.generated.js +2 -234
  40. package/dist/short-videos/{short-videos-player → data-providers}/operations.graphql +1 -9
  41. package/dist/short-videos/short-videos-player/index.d.ts +13 -62
  42. package/dist/short-videos/short-videos-player/index.js +76 -30
  43. package/dist/ui/player-slider/player-buffer.svelte.d.ts +1 -0
  44. package/dist/ui/swipe-indicator/cmp.swipe-indicator.svelte +7 -8
  45. package/package.json +1 -1
  46. package/dist/media-center/media-center/short-video-resources-generator.d.ts +0 -8
  47. package/dist/short-videos/short-videos-player/cmp.short-videos-player.svelte.d.ts +0 -4
  48. package/dist/short-videos/short-videos-player/mapper.d.ts +0 -3
  49. package/dist/short-videos/short-videos-player/short-videos-player-view.svelte +0 -82
  50. package/dist/short-videos/short-videos-player/short-videos-player-view.svelte.d.ts +0 -8
  51. package/dist/short-videos/short-videos-player/types.d.ts +0 -26
  52. package/dist/short-videos/short-videos-player/types.js +0 -1
@@ -1,73 +1,87 @@
1
+ import { type IMediaCenterConfig } from '../../media-center/config/types';
1
2
  import type { IPostSocialInteractionsHandler } from '../social-interactions';
2
3
  import type { IPlayerItemsProvider } from '../../ui/player-slider';
4
+ import { default as PostsPlayer } from './cmp.posts-player.svelte';
5
+ import { mapToPostPlayerModel } from './mapper';
3
6
  import type { IPostAnalyticsHandler, PostPlayerModel, PostPlayerSettings } from './types';
4
- export { type PostPlayerModel };
5
- export type { IPlayerItemsProvider, IPostAnalyticsHandler };
7
+ export { PostsPlayer, type PostPlayerModel };
8
+ export type { IMediaCenterConfig, IPlayerItemsProvider, IPostAnalyticsHandler };
9
+ export { mapToPostPlayerModel };
6
10
  /**
7
11
  * Opens the posts player modal.
8
12
  *
9
- * This version works only with a posts provider and removes legacy IDs/GraphQL modes.
10
- *
11
13
  * @param init Configuration options.
12
14
  *
13
- * Required
15
+ * Data provider (required)
14
16
  * @param {IPlayerItemsProvider<PostPlayerModel>} init.postsProvider
15
17
  * Provider that supplies post items to the player.
16
18
  *
17
- * Optional
19
+ * Media center (optional)
20
+ * @param {IMediaCenterConfig} [init.mediaCenterConfig]
21
+ * Optional media-center config passed to MediaCenter.
22
+ *
23
+ * Analytics (optional)
18
24
  * @param {IPostAnalyticsHandler} [init.analyticsHandler]
19
- * Analytics events handler.
25
+ * Custom analytics handler for posts player events.
26
+ *
27
+ * Social interactions (optional)
20
28
  * @param {IPostSocialInteractionsHandler} [init.socialInteractionsHandler]
21
29
  * Handler for social interactions (like, share, etc.).
22
- * @param {ContentPlayerSettings} [init.playerSettings]
23
- * Player UI and behavior settings.
24
30
  *
25
- * Fields of ContentPlayerSettings:
31
+ * Player settings
32
+ * @param {PostPlayerSettings} [init.playerSettings]
33
+ * Player UI and behavior settings.
34
+ * Fields of PostPlayerSettings:
26
35
  * - {boolean} [disableBackground]
27
36
  * If true, hides the player's background image.
28
37
  * - {boolean} [hideCloseButton]
29
38
  * If true, hides the close button.
30
- * - {Locale} [locale='en']
31
- * Localization for the player UI. Supported values: 'en' | 'no'.
32
- * If omitted, the default locale 'en' is used.
39
+ * - {'en'|'no'} [locale='en']
40
+ * Localization for the player UI. Default is 'en'; use 'no' for Norwegian.
33
41
  * - {boolean} [showStreamsCloudWatermark]
34
42
  * If true, shows the StreamsCloud watermark.
35
43
  *
36
44
  * Events
37
- * @param {{ playerClosed?: () => void }} [init.on]
45
+ * @param {{ playerClosed?: () => void; postActivated?: (id: string) => void }} [init.on]
38
46
  * Optional event handlers.
39
47
  * @param {() => void} [init.on.playerClosed]
40
48
  * Called after the player is fully closed (after unmount and removal from the DOM).
49
+ * @param {(id: string) => void} [init.on.postActivated]
50
+ * Called when a post becomes active (receives the post's id).
41
51
  *
42
52
  * @returns {void}
43
53
  *
44
54
  * @example
45
55
  * ```ts
46
- * import { openPostsPlayer } from '@streamscloud/embeddable/short-videos-player';
56
+ * import { openPostsPlayer } from '@streamscloud/embeddable/posts-player';
47
57
  *
48
58
  * openPostsPlayer({
49
59
  * postsProvider: myPostsProvider,
60
+ * mediaCenterConfig: myMediaCenterConfig,
50
61
  * analyticsHandler: myAnalyticsHandler,
51
62
  * socialInteractionsHandler: mySocialHandler,
52
63
  * playerSettings: {
64
+ * // Default locale is 'en'; set 'no' to switch to Norwegian:
65
+ * locale: 'no',
53
66
  * disableBackground: false,
54
67
  * hideCloseButton: false,
55
- * // Locale is 'en' by default; set 'no' to switch to Norwegian:
56
- * locale: 'no',
57
68
  * showStreamsCloudWatermark: true,
58
69
  * },
59
70
  * on: {
60
71
  * playerClosed: () => console.log('Player closed'),
72
+ * postActivated: (id) => console.log('Activated post', id),
61
73
  * },
62
74
  * });
63
75
  * ```
64
76
  */
65
77
  export declare function openPostsPlayer(init: {
66
78
  postsProvider: IPlayerItemsProvider<PostPlayerModel>;
79
+ mediaCenterConfig?: IMediaCenterConfig;
67
80
  analyticsHandler?: IPostAnalyticsHandler;
68
81
  socialInteractionsHandler?: IPostSocialInteractionsHandler;
69
82
  playerSettings?: PostPlayerSettings;
70
83
  on?: {
71
84
  playerClosed?: () => void;
85
+ postActivated?: (id: string) => void;
72
86
  };
73
87
  }): void;
@@ -1,84 +1,101 @@
1
+ import {} from '../../media-center/config/types';
2
+ import { MediaCenter } from '../../media-center/media-center';
1
3
  import { ModalShadowHost } from '../../ui/shadow-dom';
2
- import { default as PostPlayerView } from './posts-player-view.svelte';
4
+ import { default as PostsPlayer } from './cmp.posts-player.svelte';
5
+ import { mapToPostPlayerModel } from './mapper';
3
6
  import { mount, unmount } from 'svelte';
4
- export {};
7
+ export { PostsPlayer };
8
+ export { mapToPostPlayerModel };
5
9
  /**
6
10
  * Opens the posts player modal.
7
11
  *
8
- * This version works only with a posts provider and removes legacy IDs/GraphQL modes.
9
- *
10
12
  * @param init Configuration options.
11
13
  *
12
- * Required
14
+ * Data provider (required)
13
15
  * @param {IPlayerItemsProvider<PostPlayerModel>} init.postsProvider
14
16
  * Provider that supplies post items to the player.
15
17
  *
16
- * Optional
18
+ * Media center (optional)
19
+ * @param {IMediaCenterConfig} [init.mediaCenterConfig]
20
+ * Optional media-center config passed to MediaCenter.
21
+ *
22
+ * Analytics (optional)
17
23
  * @param {IPostAnalyticsHandler} [init.analyticsHandler]
18
- * Analytics events handler.
24
+ * Custom analytics handler for posts player events.
25
+ *
26
+ * Social interactions (optional)
19
27
  * @param {IPostSocialInteractionsHandler} [init.socialInteractionsHandler]
20
28
  * Handler for social interactions (like, share, etc.).
21
- * @param {ContentPlayerSettings} [init.playerSettings]
22
- * Player UI and behavior settings.
23
29
  *
24
- * Fields of ContentPlayerSettings:
30
+ * Player settings
31
+ * @param {PostPlayerSettings} [init.playerSettings]
32
+ * Player UI and behavior settings.
33
+ * Fields of PostPlayerSettings:
25
34
  * - {boolean} [disableBackground]
26
35
  * If true, hides the player's background image.
27
36
  * - {boolean} [hideCloseButton]
28
37
  * If true, hides the close button.
29
- * - {Locale} [locale='en']
30
- * Localization for the player UI. Supported values: 'en' | 'no'.
31
- * If omitted, the default locale 'en' is used.
38
+ * - {'en'|'no'} [locale='en']
39
+ * Localization for the player UI. Default is 'en'; use 'no' for Norwegian.
32
40
  * - {boolean} [showStreamsCloudWatermark]
33
41
  * If true, shows the StreamsCloud watermark.
34
42
  *
35
43
  * Events
36
- * @param {{ playerClosed?: () => void }} [init.on]
44
+ * @param {{ playerClosed?: () => void; postActivated?: (id: string) => void }} [init.on]
37
45
  * Optional event handlers.
38
46
  * @param {() => void} [init.on.playerClosed]
39
47
  * Called after the player is fully closed (after unmount and removal from the DOM).
48
+ * @param {(id: string) => void} [init.on.postActivated]
49
+ * Called when a post becomes active (receives the post's id).
40
50
  *
41
51
  * @returns {void}
42
52
  *
43
53
  * @example
44
54
  * ```ts
45
- * import { openPostsPlayer } from '@streamscloud/embeddable/short-videos-player';
55
+ * import { openPostsPlayer } from '@streamscloud/embeddable/posts-player';
46
56
  *
47
57
  * openPostsPlayer({
48
58
  * postsProvider: myPostsProvider,
59
+ * mediaCenterConfig: myMediaCenterConfig,
49
60
  * analyticsHandler: myAnalyticsHandler,
50
61
  * socialInteractionsHandler: mySocialHandler,
51
62
  * playerSettings: {
63
+ * // Default locale is 'en'; set 'no' to switch to Norwegian:
64
+ * locale: 'no',
52
65
  * disableBackground: false,
53
66
  * hideCloseButton: false,
54
- * // Locale is 'en' by default; set 'no' to switch to Norwegian:
55
- * locale: 'no',
56
67
  * showStreamsCloudWatermark: true,
57
68
  * },
58
69
  * on: {
59
70
  * playerClosed: () => console.log('Player closed'),
71
+ * postActivated: (id) => console.log('Activated post', id),
60
72
  * },
61
73
  * });
62
74
  * ```
63
75
  */
64
76
  export function openPostsPlayer(init) {
65
- const { postsProvider, socialInteractionsHandler, playerSettings, on } = init;
66
- const dataProvider = postsProvider;
67
- const analyticsHandler = init.analyticsHandler;
77
+ const { postsProvider: dataProvider, mediaCenterConfig, analyticsHandler, socialInteractionsHandler, playerSettings, on } = init;
68
78
  const shadowHost = new ModalShadowHost();
69
- const mounted = mount(PostPlayerView, {
79
+ const mounted = mount(MediaCenter, {
70
80
  target: shadowHost.shadowRoot,
71
81
  props: {
72
- dataProvider,
73
- socialInteractionsHandler,
74
- playerSettings,
75
- analyticsHandler,
76
- on: {
77
- playerClosed: async () => {
78
- await unmount(mounted);
79
- shadowHost.remove();
80
- if (on?.playerClosed) {
81
- on.playerClosed();
82
+ config: mediaCenterConfig || null,
83
+ playerProps: {
84
+ mode: 'posts',
85
+ props: {
86
+ dataProvider,
87
+ socialInteractionsHandler,
88
+ analyticsHandler,
89
+ playerSettings,
90
+ on: {
91
+ playerClosed: async () => {
92
+ await unmount(mounted);
93
+ shadowHost.remove();
94
+ if (on?.playerClosed) {
95
+ on.playerClosed();
96
+ }
97
+ },
98
+ postActivated: on?.postActivated
82
99
  }
83
100
  }
84
101
  }
@@ -0,0 +1,3 @@
1
+ import type { PostsPlayerPayloadFragment } from './operations.generated';
2
+ import type { PostPlayerModel } from './types';
3
+ export declare const mapToPostPlayerModel: (payload: PostsPlayerPayloadFragment) => PostPlayerModel;
@@ -1,6 +1,6 @@
1
1
  import { ProfileType } from '../../core/enums';
2
- import { mapToPostModel } from '../../posts/post-viewer';
3
- export const mapToShortVideoPlayerModel = (payload) => {
2
+ import { mapToPostModel } from '../post-viewer';
3
+ export const mapToPostPlayerModel = (payload) => {
4
4
  const viewerModel = mapToPostModel(payload);
5
5
  return {
6
6
  ...viewerModel,
@@ -0,0 +1,80 @@
1
+ import type * as SchemaTypes from '../../../gql/types';
2
+ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
3
+ export type PostsPlayerPayloadFragment = {
4
+ id: string;
5
+ enableSocialInteractions: boolean;
6
+ ownerProfile: {
7
+ id: string;
8
+ type: SchemaTypes.ProfileType;
9
+ };
10
+ allProducts: Array<{
11
+ id: string;
12
+ title: string;
13
+ shortDescription: string | null;
14
+ link: string | null;
15
+ media: Array<{
16
+ url: string;
17
+ thumbnailUrl: string | null;
18
+ type: SchemaTypes.MediaType;
19
+ }>;
20
+ brand: {
21
+ name: string;
22
+ } | null;
23
+ priceAndAvailability: {
24
+ currency: SchemaTypes.Currency;
25
+ price: number;
26
+ productSalePrices: Array<{
27
+ salePrice: number;
28
+ salePriceEffectiveDateFrom: any | null;
29
+ salePriceEffectiveDateTo: any | null;
30
+ }> | null;
31
+ };
32
+ }>;
33
+ ad: {
34
+ id: string;
35
+ title: string;
36
+ description: string | null;
37
+ price: number | null;
38
+ priceInfo: string | null;
39
+ currency: SchemaTypes.Currency | null;
40
+ type: SchemaTypes.AdType;
41
+ ctaButton: {
42
+ background: string;
43
+ textColor: string;
44
+ text: string;
45
+ url: string;
46
+ border: string;
47
+ } | null;
48
+ media: Array<{
49
+ url: string;
50
+ thumbnailUrl: string | null;
51
+ type: SchemaTypes.MediaType;
52
+ }>;
53
+ } | null;
54
+ postData: {
55
+ media: Array<{
56
+ url: string;
57
+ thumbnailUrl: string | null;
58
+ type: SchemaTypes.MediaType;
59
+ }>;
60
+ articleData: {
61
+ title: string;
62
+ kicker: string | null;
63
+ articleId: string;
64
+ } | null;
65
+ mediaData: {
66
+ text: string | null;
67
+ } | null;
68
+ momentData: {
69
+ text: string | null;
70
+ } | null;
71
+ shortVideoData: {
72
+ text: string | null;
73
+ } | null;
74
+ videoData: {
75
+ title: string | null;
76
+ text: string | null;
77
+ } | null;
78
+ };
79
+ };
80
+ export declare const PostsPlayerPayloadFragmentDoc: DocumentNode<PostsPlayerPayloadFragment, unknown>;
@@ -0,0 +1,229 @@
1
+ export const PostsPlayerPayloadFragmentDoc = {
2
+ kind: 'Document',
3
+ definitions: [
4
+ {
5
+ kind: 'FragmentDefinition',
6
+ name: { kind: 'Name', value: 'PostsPlayerPayloadFragment' },
7
+ typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Post' } },
8
+ selectionSet: {
9
+ kind: 'SelectionSet',
10
+ selections: [
11
+ { kind: 'FragmentSpread', name: { kind: 'Name', value: 'PostViewerPayloadFragment' } },
12
+ {
13
+ kind: 'Field',
14
+ name: { kind: 'Name', value: 'ownerProfile' },
15
+ selectionSet: {
16
+ kind: 'SelectionSet',
17
+ selections: [
18
+ { kind: 'Field', name: { kind: 'Name', value: 'id' } },
19
+ { kind: 'Field', name: { kind: 'Name', value: 'type' } }
20
+ ]
21
+ }
22
+ }
23
+ ]
24
+ }
25
+ },
26
+ {
27
+ kind: 'FragmentDefinition',
28
+ name: { kind: 'Name', value: 'PostViewerPayloadFragment' },
29
+ typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Post' } },
30
+ selectionSet: {
31
+ kind: 'SelectionSet',
32
+ selections: [
33
+ { kind: 'Field', name: { kind: 'Name', value: 'id' } },
34
+ { kind: 'Field', name: { kind: 'Name', value: 'enableSocialInteractions' } },
35
+ {
36
+ kind: 'Field',
37
+ name: { kind: 'Name', value: 'allProducts' },
38
+ selectionSet: {
39
+ kind: 'SelectionSet',
40
+ selections: [
41
+ { kind: 'Field', name: { kind: 'Name', value: 'id' } },
42
+ { kind: 'Field', name: { kind: 'Name', value: 'title' } },
43
+ { kind: 'Field', name: { kind: 'Name', value: 'shortDescription' } },
44
+ { kind: 'Field', name: { kind: 'Name', value: 'link' } },
45
+ {
46
+ kind: 'Field',
47
+ name: { kind: 'Name', value: 'media' },
48
+ selectionSet: {
49
+ kind: 'SelectionSet',
50
+ selections: [
51
+ {
52
+ kind: 'Field',
53
+ name: { kind: 'Name', value: 'url' },
54
+ arguments: [{ kind: 'Argument', name: { kind: 'Name', value: 'scale' }, value: { kind: 'EnumValue', value: 'SMALL' } }]
55
+ },
56
+ {
57
+ kind: 'Field',
58
+ name: { kind: 'Name', value: 'thumbnailUrl' },
59
+ arguments: [{ kind: 'Argument', name: { kind: 'Name', value: 'scale' }, value: { kind: 'EnumValue', value: 'SMALL' } }]
60
+ },
61
+ { kind: 'Field', name: { kind: 'Name', value: 'type' } }
62
+ ]
63
+ }
64
+ },
65
+ {
66
+ kind: 'Field',
67
+ name: { kind: 'Name', value: 'brand' },
68
+ selectionSet: { kind: 'SelectionSet', selections: [{ kind: 'Field', name: { kind: 'Name', value: 'name' } }] }
69
+ },
70
+ {
71
+ kind: 'Field',
72
+ name: { kind: 'Name', value: 'priceAndAvailability' },
73
+ selectionSet: {
74
+ kind: 'SelectionSet',
75
+ selections: [
76
+ { kind: 'Field', name: { kind: 'Name', value: 'currency' } },
77
+ { kind: 'Field', name: { kind: 'Name', value: 'price' } },
78
+ {
79
+ kind: 'Field',
80
+ name: { kind: 'Name', value: 'productSalePrices' },
81
+ selectionSet: {
82
+ kind: 'SelectionSet',
83
+ selections: [
84
+ { kind: 'Field', name: { kind: 'Name', value: 'salePrice' } },
85
+ { kind: 'Field', name: { kind: 'Name', value: 'salePriceEffectiveDateFrom' } },
86
+ { kind: 'Field', name: { kind: 'Name', value: 'salePriceEffectiveDateTo' } }
87
+ ]
88
+ }
89
+ }
90
+ ]
91
+ }
92
+ }
93
+ ]
94
+ }
95
+ },
96
+ {
97
+ kind: 'Field',
98
+ name: { kind: 'Name', value: 'ad' },
99
+ selectionSet: {
100
+ kind: 'SelectionSet',
101
+ selections: [
102
+ { kind: 'Field', name: { kind: 'Name', value: 'id' } },
103
+ { kind: 'Field', name: { kind: 'Name', value: 'title' } },
104
+ { kind: 'Field', name: { kind: 'Name', value: 'description' } },
105
+ { kind: 'Field', name: { kind: 'Name', value: 'price' } },
106
+ { kind: 'Field', name: { kind: 'Name', value: 'priceInfo' } },
107
+ { kind: 'Field', name: { kind: 'Name', value: 'currency' } },
108
+ {
109
+ kind: 'Field',
110
+ name: { kind: 'Name', value: 'ctaButton' },
111
+ selectionSet: {
112
+ kind: 'SelectionSet',
113
+ selections: [
114
+ { kind: 'Field', name: { kind: 'Name', value: 'background' } },
115
+ { kind: 'Field', name: { kind: 'Name', value: 'textColor' } },
116
+ { kind: 'Field', name: { kind: 'Name', value: 'text' } },
117
+ { kind: 'Field', name: { kind: 'Name', value: 'url' } },
118
+ { kind: 'Field', name: { kind: 'Name', value: 'border' } }
119
+ ]
120
+ }
121
+ },
122
+ { kind: 'Field', name: { kind: 'Name', value: 'type' } },
123
+ {
124
+ kind: 'Field',
125
+ name: { kind: 'Name', value: 'media' },
126
+ selectionSet: {
127
+ kind: 'SelectionSet',
128
+ selections: [
129
+ {
130
+ kind: 'Field',
131
+ name: { kind: 'Name', value: 'url' },
132
+ arguments: [{ kind: 'Argument', name: { kind: 'Name', value: 'scale' }, value: { kind: 'EnumValue', value: 'SMALL' } }]
133
+ },
134
+ {
135
+ kind: 'Field',
136
+ name: { kind: 'Name', value: 'thumbnailUrl' },
137
+ arguments: [{ kind: 'Argument', name: { kind: 'Name', value: 'scale' }, value: { kind: 'EnumValue', value: 'SMALL' } }]
138
+ },
139
+ { kind: 'Field', name: { kind: 'Name', value: 'type' } }
140
+ ]
141
+ }
142
+ }
143
+ ]
144
+ }
145
+ },
146
+ {
147
+ kind: 'Field',
148
+ name: { kind: 'Name', value: 'postData' },
149
+ selectionSet: {
150
+ kind: 'SelectionSet',
151
+ selections: [
152
+ {
153
+ kind: 'Field',
154
+ name: { kind: 'Name', value: 'media' },
155
+ selectionSet: {
156
+ kind: 'SelectionSet',
157
+ selections: [
158
+ {
159
+ kind: 'Field',
160
+ name: { kind: 'Name', value: 'url' },
161
+ arguments: [
162
+ {
163
+ kind: 'Argument',
164
+ name: { kind: 'Name', value: 'scale' },
165
+ value: { kind: 'Variable', name: { kind: 'Name', value: 'image_scale' } }
166
+ }
167
+ ]
168
+ },
169
+ {
170
+ kind: 'Field',
171
+ name: { kind: 'Name', value: 'thumbnailUrl' },
172
+ arguments: [
173
+ {
174
+ kind: 'Argument',
175
+ name: { kind: 'Name', value: 'scale' },
176
+ value: { kind: 'Variable', name: { kind: 'Name', value: 'image_scale' } }
177
+ }
178
+ ]
179
+ },
180
+ { kind: 'Field', name: { kind: 'Name', value: 'type' } }
181
+ ]
182
+ }
183
+ },
184
+ {
185
+ kind: 'Field',
186
+ name: { kind: 'Name', value: 'articleData' },
187
+ selectionSet: {
188
+ kind: 'SelectionSet',
189
+ selections: [
190
+ { kind: 'Field', name: { kind: 'Name', value: 'title' } },
191
+ { kind: 'Field', name: { kind: 'Name', value: 'kicker' } },
192
+ { kind: 'Field', name: { kind: 'Name', value: 'articleId' } }
193
+ ]
194
+ }
195
+ },
196
+ {
197
+ kind: 'Field',
198
+ name: { kind: 'Name', value: 'mediaData' },
199
+ selectionSet: { kind: 'SelectionSet', selections: [{ kind: 'Field', name: { kind: 'Name', value: 'text' } }] }
200
+ },
201
+ {
202
+ kind: 'Field',
203
+ name: { kind: 'Name', value: 'momentData' },
204
+ selectionSet: { kind: 'SelectionSet', selections: [{ kind: 'Field', name: { kind: 'Name', value: 'text' } }] }
205
+ },
206
+ {
207
+ kind: 'Field',
208
+ name: { kind: 'Name', value: 'shortVideoData' },
209
+ selectionSet: { kind: 'SelectionSet', selections: [{ kind: 'Field', name: { kind: 'Name', value: 'text' } }] }
210
+ },
211
+ {
212
+ kind: 'Field',
213
+ name: { kind: 'Name', value: 'videoData' },
214
+ selectionSet: {
215
+ kind: 'SelectionSet',
216
+ selections: [
217
+ { kind: 'Field', name: { kind: 'Name', value: 'title' } },
218
+ { kind: 'Field', name: { kind: 'Name', value: 'text' } }
219
+ ]
220
+ }
221
+ }
222
+ ]
223
+ }
224
+ }
225
+ ]
226
+ }
227
+ }
228
+ ]
229
+ };
@@ -0,0 +1,7 @@
1
+ fragment PostsPlayerPayloadFragment on Post {
2
+ ...PostViewerPayloadFragment
3
+ ownerProfile {
4
+ id
5
+ type
6
+ }
7
+ }
@@ -7,13 +7,14 @@
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ import { PostType } from '../..';
10
11
  import { ContentPlayer, ContentPlayerConfig } from '../../content-player';
11
12
  import { ContentPlayerSettings } from '../../content-player/content-player-settings';
12
13
  import { preloadImage } from '../../core/image-preloader';
13
14
  import { getPostCoverImage } from '../model';
14
15
  import { PlayerBuffer } from '../../ui/player-slider';
15
16
  import { untrack } from 'svelte';
16
- let { dataProvider, socialInteractionsHandler, playerSettings, analyticsHandler, on } = $props();
17
+ let { dataProvider, socialInteractionsHandler, playerSettings, analyticsHandler, on, mediaCenterData } = $props();
17
18
  $effect(() => {
18
19
  void dataProvider;
19
20
  untrack(() => {
@@ -21,7 +22,11 @@ $effect(() => {
21
22
  initBuffer(dataProvider);
22
23
  });
23
24
  });
25
+ $effect(() => contentPlayerConfig.updateMediaCenterData(mediaCenterData));
24
26
  const initBuffer = (dataProvider) => __awaiter(void 0, void 0, void 0, function* () {
27
+ if (dataProvider.prefetch) {
28
+ yield dataProvider.prefetch();
29
+ }
25
30
  new PlayerBuffer(dataProvider, {
26
31
  preloaded: (instance) => __awaiter(void 0, void 0, void 0, function* () {
27
32
  if (instance.loaded.length) {
@@ -33,20 +38,45 @@ const initBuffer = (dataProvider) => __awaiter(void 0, void 0, void 0, function*
33
38
  })
34
39
  });
35
40
  });
41
+ const getLoadedItemById = (id) => {
42
+ if (!contentPlayerConfig.playerBuffer) {
43
+ return null;
44
+ }
45
+ return contentPlayerConfig.playerBuffer.loaded.find((item) => item.id === id) || null;
46
+ };
36
47
  const contentPlayerConfig = new ContentPlayerConfig({
37
48
  playerBuffer: null,
38
49
  mappers: {
39
50
  postModelFromCurrentItem: (item) => item
40
51
  },
41
52
  socialInteractionsHandler,
53
+ mediaCenterData,
42
54
  settings: new ContentPlayerSettings(playerSettings),
43
55
  callbacks: {
44
- close: on === null || on === void 0 ? void 0 : on.playerClosed
56
+ close: on === null || on === void 0 ? void 0 : on.playerClosed,
57
+ productClick: (id, postId) => {
58
+ var _a;
59
+ if (((_a = getLoadedItemById(postId)) === null || _a === void 0 ? void 0 : _a.postType) === PostType.ShortVideo) {
60
+ analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackShortVideoProductClick(id, postId);
61
+ }
62
+ },
63
+ productImpression: (id, postId) => {
64
+ var _a;
65
+ if (((_a = getLoadedItemById(postId)) === null || _a === void 0 ? void 0 : _a.postType) === PostType.ShortVideo) {
66
+ analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackShortVideoProductImpression(id, postId);
67
+ }
68
+ },
69
+ adClick: (id) => {
70
+ analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackAdClick(id);
71
+ },
72
+ adImpression: (id) => {
73
+ analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackAdImpression(id);
74
+ }
45
75
  },
46
76
  playerSliderCallbacks: {
47
77
  itemActivated: (id) => {
48
78
  var _a;
49
- const post = (_a = contentPlayerConfig.playerBuffer) === null || _a === void 0 ? void 0 : _a.loaded.find((x) => x.id === id);
79
+ const post = getLoadedItemById(id);
50
80
  if (!post) {
51
81
  return;
52
82
  }
@@ -54,9 +84,13 @@ const contentPlayerConfig = new ContentPlayerConfig({
54
84
  if (post.analyticsOrganizationId) {
55
85
  analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.setOrganizationId(post.analyticsOrganizationId);
56
86
  }
57
- if (post.analyticsOrganizationId) {
87
+ if (post.postType === PostType.ShortVideo) {
88
+ analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackShortVideoView(id);
89
+ }
90
+ else if (post.analyticsOrganizationId) {
58
91
  analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackPostOpened(id, post.analyticsOrganizationId);
59
92
  }
93
+ (_a = on === null || on === void 0 ? void 0 : on.postActivated) === null || _a === void 0 ? void 0 : _a.call(on, id);
60
94
  }
61
95
  }
62
96
  });