@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.
Files changed (97) hide show
  1. package/dist/ads/ad-card/mapper.js +1 -1
  2. package/dist/core/browser.d.ts +1 -0
  3. package/dist/core/browser.js +1 -0
  4. package/dist/core/continuation-token.d.ts +1 -0
  5. package/dist/core/continuation-token.js +3 -0
  6. package/dist/core/locale.d.ts +0 -1
  7. package/dist/core/locale.js +0 -12
  8. package/dist/core/media/media-item-url.service.d.ts +1 -1
  9. package/dist/core/media/media-item-url.service.js +1 -6
  10. package/dist/media-center/data-provider/index.d.ts +2 -0
  11. package/dist/media-center/data-provider/index.js +1 -0
  12. package/dist/media-center/data-provider/internal-media-center-data-provider.svelte.d.ts +8 -0
  13. package/dist/media-center/data-provider/internal-media-center-data-provider.svelte.js +44 -0
  14. package/dist/media-center/data-provider/operations.generated.d.ts +89 -0
  15. package/dist/media-center/data-provider/operations.generated.js +275 -0
  16. package/dist/media-center/data-provider/operations.graphql +25 -0
  17. package/dist/media-center/data-provider/types.d.ts +24 -0
  18. package/dist/media-center/data-provider/types.js +1 -0
  19. package/dist/media-center/index.d.ts +1 -0
  20. package/dist/media-center/index.js +1 -0
  21. package/dist/media-center/media-center/cmp.media-center.svelte +433 -0
  22. package/dist/media-center/media-center/cmp.media-center.svelte.d.ts +20 -0
  23. package/dist/media-center/media-center/index.d.ts +3 -0
  24. package/dist/media-center/media-center/index.js +2 -0
  25. package/dist/media-center/media-center/media-center-localization.d.ts +13 -0
  26. package/dist/media-center/media-center/media-center-localization.js +21 -0
  27. package/dist/media-center/media-center/overview.svelte +151 -0
  28. package/dist/media-center/media-center/overview.svelte.d.ts +13 -0
  29. package/dist/media-center/media-center/short-video-resources-generator.d.ts +8 -0
  30. package/dist/media-center/media-center/short-video-resources-generator.js +26 -0
  31. package/dist/media-center/media-center/types.d.ts +10 -0
  32. package/dist/media-center/media-center/types.js +5 -0
  33. package/dist/products/product-card/cmp.product-card.svelte +11 -6
  34. package/dist/products/product-card/mapper.js +3 -3
  35. package/dist/short-videos/short-video-card/cmp.short-video-card.svelte +118 -0
  36. package/dist/short-videos/short-video-card/cmp.short-video-card.svelte.d.ts +11 -0
  37. package/dist/short-videos/short-video-card/index.d.ts +2 -0
  38. package/dist/short-videos/short-video-card/index.js +1 -0
  39. package/dist/short-videos/short-video-card/types.d.ts +5 -0
  40. package/dist/short-videos/short-video-card/types.js +1 -0
  41. package/dist/short-videos/short-video-viewer/cmp.short-video-controls.svelte +3 -3
  42. package/dist/short-videos/short-video-viewer/cmp.short-video-controls.svelte.d.ts +2 -2
  43. package/dist/short-videos/short-video-viewer/cmp.short-video-viewer.svelte +8 -26
  44. package/dist/short-videos/short-video-viewer/cmp.short-video-viewer.svelte.d.ts +2 -3
  45. package/dist/short-videos/short-video-viewer/index.d.ts +1 -1
  46. package/dist/short-videos/short-video-viewer/mapper.js +6 -3
  47. package/dist/short-videos/short-video-viewer/types.d.ts +8 -6
  48. package/dist/short-videos/short-video-viewer/ui-manager.svelte.d.ts +0 -5
  49. package/dist/short-videos/short-video-viewer/ui-manager.svelte.js +0 -11
  50. package/dist/short-videos/short-videos-player/cmp.short-videos-player.svelte +16 -12
  51. package/dist/short-videos/short-videos-player/cmp.short-videos-player.svelte.d.ts +5 -15
  52. package/dist/short-videos/short-videos-player/controls.svelte +39 -4
  53. package/dist/short-videos/short-videos-player/controls.svelte.d.ts +3 -2
  54. package/dist/short-videos/short-videos-player/fade-mixins.scss +12 -0
  55. package/dist/short-videos/short-videos-player/index.d.ts +66 -36
  56. package/dist/short-videos/short-videos-player/index.js +40 -104
  57. package/dist/short-videos/short-videos-player/internal-short-video-player-provider.d.ts +17 -0
  58. package/dist/short-videos/short-videos-player/internal-short-video-player-provider.js +59 -0
  59. package/dist/short-videos/short-videos-player/operations.generated.d.ts +1 -0
  60. package/dist/short-videos/short-videos-player/operations.generated.js +2 -1
  61. package/dist/short-videos/short-videos-player/operations.graphql +1 -0
  62. package/dist/short-videos/short-videos-player/short-videos-player-view.svelte +36 -55
  63. package/dist/short-videos/short-videos-player/short-videos-player-view.svelte.d.ts +12 -15
  64. package/dist/short-videos/short-videos-player/types.d.ts +8 -29
  65. package/dist/short-videos/short-videos-player/types.js +1 -6
  66. package/dist/short-videos/short-videos-player/ui-manager.svelte.d.ts +6 -6
  67. package/dist/short-videos/short-videos-player/ui-manager.svelte.js +28 -16
  68. package/dist/streams/layout/element-views/cmp.short-video-stream-element.svelte +6 -1
  69. package/dist/streams/stream-page-viewer/index.d.ts +1 -0
  70. package/dist/streams/stream-page-viewer/index.js +1 -0
  71. package/dist/streams/stream-player/controls.svelte +2 -2
  72. package/dist/streams/stream-player/controls.svelte.d.ts +2 -2
  73. package/dist/streams/stream-player/index.d.ts +84 -27
  74. package/dist/streams/stream-player/index.js +46 -48
  75. package/dist/streams/stream-player/internal-stream-analytics-handler.d.ts +12 -0
  76. package/dist/streams/stream-player/internal-stream-analytics-handler.js +17 -0
  77. package/dist/streams/stream-player/internal-stream-player-data-provider.d.ts +10 -0
  78. package/dist/streams/stream-player/internal-stream-player-data-provider.js +48 -0
  79. package/dist/streams/stream-player/mapper.js +2 -0
  80. package/dist/streams/stream-player/operations.generated.d.ts +0 -2
  81. package/dist/streams/stream-player/operations.generated.js +2 -4
  82. package/dist/streams/stream-player/operations.graphql +0 -1
  83. package/dist/streams/stream-player/stream-player-buffer.svelte.d.ts +5 -5
  84. package/dist/streams/stream-player/stream-player-buffer.svelte.js +12 -27
  85. package/dist/streams/stream-player/{cmp.stream-player.svelte → stream-player.svelte} +19 -37
  86. package/dist/streams/stream-player/stream-player.svelte.d.ts +4 -0
  87. package/dist/streams/stream-player/types.d.ts +40 -0
  88. package/dist/ui/dropdown/cmp.dropdown.svelte +187 -0
  89. package/dist/ui/dropdown/cmp.dropdown.svelte.d.ts +23 -0
  90. package/dist/ui/dropdown/dropdown-ignore.d.ts +6 -0
  91. package/dist/ui/dropdown/dropdown-ignore.js +11 -0
  92. package/dist/ui/dropdown/index.d.ts +3 -0
  93. package/dist/ui/dropdown/index.js +2 -0
  94. package/dist/ui/player/index.d.ts +1 -1
  95. package/dist/ui/player/player-buffer.svelte.d.ts +3 -3
  96. package/package.json +8 -1
  97. package/dist/streams/stream-player/cmp.stream-player.svelte.d.ts +0 -22
@@ -5,7 +5,7 @@ import { ShortVideosPlayerLocalization } from './short-videos-player-localizatio
5
5
  import IconChevronDown from '@fluentui/svg-icons/icons/chevron_down_20_regular.svg?raw';
6
6
  import IconChevronUp from '@fluentui/svg-icons/icons/chevron_up_20_regular.svg?raw';
7
7
  import IconDismiss from '@fluentui/svg-icons/icons/dismiss_20_regular.svg?raw';
8
- let { buffer, uiManager, localization, socialInteractionsHandler, on } = $props();
8
+ let { buffer, uiManager, localization, socialInteractionsHandler, playerLogo, on } = $props();
9
9
  const shortVideo = $derived(buffer.current);
10
10
  const changeShowAttachments = () => {
11
11
  uiManager.showAttachments = !uiManager.showAttachments;
@@ -13,7 +13,7 @@ const changeShowAttachments = () => {
13
13
  </script>
14
14
 
15
15
  {#if uiManager.viewInitialized && !uiManager.showShortVideoOverlay}
16
- <div class="short-videos-player-controls">
16
+ <div class="short-videos-player-controls" class:short-videos-player-controls--with-logo={!!playerLogo}>
17
17
  <div class="short-videos-player-controls__left">
18
18
  {#if shortVideo}
19
19
  <div class="short-videos-player-controls__short-video-hub">
@@ -39,6 +39,11 @@ const changeShowAttachments = () => {
39
39
  </div>
40
40
  </div>
41
41
  <div class="short-videos-player-controls__right">
42
+ {#if playerLogo}
43
+ <div class="short-videos-player-controls__player-logo">
44
+ <img src={playerLogo} class="short-videos-player-controls__logo-img" alt="Player Logo" />
45
+ </div>
46
+ {/if}
42
47
  {#if shortVideo && uiManager.showAttachments}
43
48
  <div class="short-videos-player-controls__short-video-attachments" transition:slideHorizontally|local>
44
49
  <ShortVideoViewerAttachments
@@ -75,18 +80,24 @@ const changeShowAttachments = () => {
75
80
  top: 0;
76
81
  right: 0;
77
82
  height: 100%;
78
- width: var(--short-videos-player--sidebar--available-space);
83
+ width: var(--short-videos-player--controls--available-space);
79
84
  display: flex;
80
85
  justify-content: space-between;
81
- padding: var(--short-videos-player--controls--offset-vertical) var(--short-videos-player--controls--offset-horizontal);
86
+ padding: var(--short-videos-player--controls--padding);
82
87
  container-type: inline-size;
83
88
  }
89
+ .short-videos-player-controls--with-logo {
90
+ padding-top: 0;
91
+ }
84
92
  .short-videos-player-controls__left {
85
93
  display: flex;
86
94
  flex-direction: column;
87
95
  gap: 2.3125rem;
88
96
  justify-content: flex-end;
89
97
  align-items: center;
98
+ padding-top: var(--short-videos-player--media-center-header--height);
99
+ opacity: var(--short-videos-player--elements-opacity);
100
+ transition: opacity 0.3s ease-in-out;
90
101
  }
91
102
  .short-videos-player-controls__right {
92
103
  flex: 1;
@@ -131,6 +142,28 @@ const changeShowAttachments = () => {
131
142
  justify-content: flex-end;
132
143
  --short-video-controls--icon--size: var(--short-videos-player--icon--size);
133
144
  }
145
+ .short-videos-player-controls__player-logo {
146
+ width: 11rem;
147
+ max-width: 11rem;
148
+ height: var(--short-videos-player--media-center-header--height);
149
+ min-height: var(--short-videos-player--media-center-header--height);
150
+ max-height: var(--short-videos-player--media-center-header--height);
151
+ min-height: 4.375rem;
152
+ display: flex;
153
+ justify-content: center;
154
+ align-items: center;
155
+ /* Set 'container-type: inline-size;' to reference container*/
156
+ }
157
+ @container (width < calc(11rem + 3.75rem)) {
158
+ .short-videos-player-controls__player-logo {
159
+ display: none;
160
+ }
161
+ }
162
+ .short-videos-player-controls__logo-img {
163
+ width: 6.25rem;
164
+ min-width: 6.25rem;
165
+ max-width: 6.25rem;
166
+ }
134
167
  .short-videos-player-controls__short-video-attachments-inline {
135
168
  display: none;
136
169
  /* Set 'container-type: inline-size;' to reference container*/
@@ -144,6 +177,8 @@ const changeShowAttachments = () => {
144
177
  flex: 1;
145
178
  width: 11rem;
146
179
  max-width: 11rem;
180
+ opacity: var(--short-videos-player--elements-opacity);
181
+ transition: opacity 0.3s ease-in-out;
147
182
  /* Set 'container-type: inline-size;' to reference container*/
148
183
  }
149
184
  @container (width < calc(11rem + 3.75rem)) {
@@ -1,4 +1,4 @@
1
- import { type ShortVideoSocialInteractionsHandler, type ShortVideoViewerModel } from '../short-video-viewer';
1
+ import { type IPostSocialInteractionsHandler, type ShortVideoViewerModel } from '../short-video-viewer';
2
2
  import type { IPlayerBuffer } from '../../ui/player';
3
3
  import { ShortVideosPlayerLocalization } from './short-videos-player-localization';
4
4
  import type { ShortVideosPlayerUiManager } from './ui-manager.svelte';
@@ -6,7 +6,8 @@ type Props = {
6
6
  buffer: IPlayerBuffer<ShortVideoViewerModel>;
7
7
  uiManager: ShortVideosPlayerUiManager;
8
8
  localization: ShortVideosPlayerLocalization;
9
- socialInteractionsHandler?: ShortVideoSocialInteractionsHandler;
9
+ socialInteractionsHandler?: IPostSocialInteractionsHandler;
10
+ playerLogo: string | null;
10
11
  on: {
11
12
  closePlayer?: () => void;
12
13
  productClick?: (productId: string) => void;
@@ -0,0 +1,12 @@
1
+ @mixin default-opacity {
2
+ --short-videos-player--elements-opacity: 1;
3
+ }
4
+
5
+ @mixin fade-opacity {
6
+ --short-videos-player--elements-opacity: 0;
7
+ }
8
+
9
+ @mixin handle-fade {
10
+ opacity: var(--short-videos-player--elements-opacity);
11
+ transition: opacity 0.3s ease-in-out;
12
+ }
@@ -1,70 +1,100 @@
1
+ import { type IMediaCenterDataProvider } from '../../media-center/data-provider';
2
+ import type { ShortVideoViewerModel } from '../short-video-viewer';
3
+ import type { IPlayerItemsProvider } from '../../ui/player';
1
4
  import { default as ShortVideosPlayer } from './cmp.short-videos-player.svelte';
2
5
  import type { IShortVideosPlayerLocalization } from './short-videos-player-localization';
3
- import { type OpenShortVideosPlayerInit } from './types';
6
+ import { type PlayerSettings } from './types';
4
7
  export { ShortVideosPlayer };
5
- export type { IShortVideosPlayerLocalization };
8
+ export type { IShortVideosPlayerLocalization, IMediaCenterDataProvider, IPlayerItemsProvider };
6
9
  /**
7
- * Opens the short videos player modal with the specified provider or by fetching videos by IDs.
10
+ * Opens the short videos player modal.
8
11
  *
9
- * You can use either a ready-made provider, or simply pass a list of video IDs and a GraphQL endpoint to fetch them.
12
+ * Two overloads (mutually exclusive):
13
+ * - Provider mode: openShortVideosPlayer({ shortVideosProvider, mediaCenterDataProvider?, ...common })
14
+ * - IDs mode: openShortVideosPlayer({ ids, initiator, graphqlOrigin?, initialId?, mediaPageId?, ...common })
10
15
  *
11
- * @param init - Configuration options.
16
+ * @param init Configuration options.
12
17
  *
13
- * @param {PlayerItemsProvider<ShortVideoViewerModel>} [init.shortVideosProvider]
14
- * The provider instance supplying short video items to the player.
15
- * **Use this if you already have your own provider implementation.**
16
- *
17
- * @param {string[]} [init.ids]
18
- * List of short video IDs to display in the player.
19
- * **Use this if you want the player to fetch and show specific videos.**
20
- *
21
- * @param {string} [init.graphqlUrl]
22
- * The GraphQL endpoint to use when fetching videos by IDs.
23
- * **Required if you use `ids`.**
18
+ * Provider mode (overload 1)
19
+ * @param {IPlayerItemsProvider<ShortVideoViewerModel>} init.shortVideosProvider
20
+ * Provider that supplies short-video items to the player.
21
+ * @param {IMediaCenterDataProvider} [init.mediaCenterDataProvider]
22
+ * Optional media-center data provider.
24
23
  *
24
+ * IDs mode (overload 2)
25
+ * @param {string[]} init.ids
26
+ * List of short-video IDs to display.
27
+ * @param {string} init.initiator
28
+ * Identifier of the initiator (used for tracking/analytics and GraphQL).
29
+ * @param {string} [init.graphqlOrigin]
30
+ * Optional GraphQL origin (base URL). If omitted, the default origin is determined internally.
25
31
  * @param {string} [init.initialId]
26
- * The ID of the video that should be shown first.
27
- * **Optional. Only used when using `ids`.**
32
+ * ID of the video to open first (optional).
33
+ * @param {string} [init.mediaPageId]
34
+ * Optional media page ID used to construct an internal media-center data provider.
28
35
  *
29
- * @param {IShortVideosPlayerLocalization} [init.localization]
30
- * Optional localization settings for the player UI.
36
+ * Common settings
37
+ * @param {IPostSocialInteractionsHandler} [init.socialInteractionsHandler]
38
+ * Handler for social interactions (like, share, etc.).
39
+ * @param {IShortVideosPlayerLocalization | Locale} [init.localization]
40
+ * Localization for the player UI. If omitted, 'en' is used.
41
+ * @param {boolean} [init.disableBackground]
42
+ * If true, hides the player's background image.
43
+ * @param {boolean} [init.showStreamsCloudWatermark]
44
+ * If true, shows the StreamsCloud watermark.
31
45
  *
32
- * @param {object} [init.on]
46
+ * Events
47
+ * @param {{ playerClosed?: () => void; videoActivated?: (id: string) => void }} [init.on]
33
48
  * Optional event handlers.
34
49
  * @param {() => void} [init.on.playerClosed]
35
- * Called when the player is closed.
50
+ * Called after the player is fully closed (after unmount and removal from the DOM).
51
+ * @param {(id: string) => void} [init.on.videoActivated]
52
+ * Called when a video becomes active (receives the video's id).
36
53
  *
37
- * @example <caption>Using a custom provider</caption>
54
+ * @returns {void}
55
+ *
56
+ * @example <caption>Provider mode</caption>
38
57
  * ```ts
39
58
  * import { openShortVideosPlayer } from '@streamscloud/embeddable/short-videos-player';
40
59
  *
41
60
  * openShortVideosPlayer({
42
61
  * shortVideosProvider: myShortVideosProvider,
43
- * localization: {
44
- * next: 'Next',
45
- * previous: 'Previous'
62
+ * mediaCenterDataProvider: myMediaCenterDataProvider,
63
+ * localization: { next: 'Next', previous: 'Previous' },
64
+ * showStreamsCloudWatermark: true,
65
+ * on: {
66
+ * playerClosed: () => console.log('Player closed'),
67
+ * videoActivated: (id) => console.log('Activated', id)
46
68
  * }
47
69
  * });
48
70
  * ```
49
71
  *
50
- * @example <caption>Using a list of IDs</caption>
72
+ * @example <caption>IDs mode</caption>
51
73
  * ```ts
52
74
  * import { openShortVideosPlayer } from '@streamscloud/embeddable/short-videos-player';
53
75
  *
54
76
  * openShortVideosPlayer({
55
77
  * ids: ['id1', 'id2', 'id3'],
56
- * graphqlOrigin: 'https://api.example.com',
78
+ * initiator: 'marketing-campaign',
79
+ * graphqlOrigin: 'https://graphql.example.com',
57
80
  * initialId: 'id2',
58
- * localization: {
59
- * next: 'Next',
60
- * previous: 'Previous'
61
- * },
81
+ * mediaPageId: 'media-page-123',
82
+ * localization: { next: 'Next', previous: 'Previous' },
62
83
  * on: {
63
- * playerClosed: () => {
64
- * console.log('Player was closed');
65
- * }
84
+ * playerClosed: () => console.log('Player closed'),
85
+ * videoActivated: (id) => console.log('Activated', id)
66
86
  * }
67
87
  * });
68
88
  * ```
69
89
  */
70
- export declare const openShortVideosPlayer: (init: OpenShortVideosPlayerInit) => Promise<void>;
90
+ export declare function openShortVideosPlayer(init: PlayerSettings & {
91
+ shortVideosProvider: IPlayerItemsProvider<ShortVideoViewerModel>;
92
+ mediaCenterDataProvider?: IMediaCenterDataProvider;
93
+ }): void;
94
+ export declare function openShortVideosPlayer(init: PlayerSettings & {
95
+ ids: string[];
96
+ initiator: string;
97
+ graphqlOrigin?: string;
98
+ initialId?: string;
99
+ mediaPageId?: string;
100
+ }): void;
@@ -1,120 +1,56 @@
1
- import { getLocale } from '../../core/locale';
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
5
  import { default as ShortVideosPlayer } from './cmp.short-videos-player.svelte';
4
- import { default as ShortVideosPlayerView } from './short-videos-player-view.svelte';
5
- import { isIdsInit, isShortVideosProviderInit } from './types';
6
+ import { InternalShortVideoPlayerProvider } from './internal-short-video-player-provider';
7
+ import {} from './types';
6
8
  import { mount, unmount } from 'svelte';
7
9
  export { ShortVideosPlayer };
8
- /**
9
- * Opens the short videos player modal with the specified provider or by fetching videos by IDs.
10
- *
11
- * You can use either a ready-made provider, or simply pass a list of video IDs and a GraphQL endpoint to fetch them.
12
- *
13
- * @param init - Configuration options.
14
- *
15
- * @param {PlayerItemsProvider<ShortVideoViewerModel>} [init.shortVideosProvider]
16
- * The provider instance supplying short video items to the player.
17
- * **Use this if you already have your own provider implementation.**
18
- *
19
- * @param {string[]} [init.ids]
20
- * List of short video IDs to display in the player.
21
- * **Use this if you want the player to fetch and show specific videos.**
22
- *
23
- * @param {string} [init.graphqlUrl]
24
- * The GraphQL endpoint to use when fetching videos by IDs.
25
- * **Required if you use `ids`.**
26
- *
27
- * @param {string} [init.initialId]
28
- * The ID of the video that should be shown first.
29
- * **Optional. Only used when using `ids`.**
30
- *
31
- * @param {IShortVideosPlayerLocalization} [init.localization]
32
- * Optional localization settings for the player UI.
33
- *
34
- * @param {object} [init.on]
35
- * Optional event handlers.
36
- * @param {() => void} [init.on.playerClosed]
37
- * Called when the player is closed.
38
- *
39
- * @example <caption>Using a custom provider</caption>
40
- * ```ts
41
- * import { openShortVideosPlayer } from '@streamscloud/embeddable/short-videos-player';
42
- *
43
- * openShortVideosPlayer({
44
- * shortVideosProvider: myShortVideosProvider,
45
- * localization: {
46
- * next: 'Next',
47
- * previous: 'Previous'
48
- * }
49
- * });
50
- * ```
51
- *
52
- * @example <caption>Using a list of IDs</caption>
53
- * ```ts
54
- * import { openShortVideosPlayer } from '@streamscloud/embeddable/short-videos-player';
55
- *
56
- * openShortVideosPlayer({
57
- * ids: ['id1', 'id2', 'id3'],
58
- * graphqlOrigin: 'https://api.example.com',
59
- * initialId: 'id2',
60
- * localization: {
61
- * next: 'Next',
62
- * previous: 'Previous'
63
- * },
64
- * on: {
65
- * playerClosed: () => {
66
- * console.log('Player was closed');
67
- * }
68
- * }
69
- * });
70
- * ```
71
- */
72
- export const openShortVideosPlayer = async (init) => {
73
- let input = null;
74
- if (isShortVideosProviderInit(init)) {
75
- input = {
76
- type: 'provider',
77
- provider: init.shortVideosProvider
78
- };
10
+ export function openShortVideosPlayer(init) {
11
+ const { shortVideosProvider, ids, graphqlOrigin, initialId, initiator, socialInteractionsHandler, disableBackground, localization, showStreamsCloudWatermark } = init;
12
+ let dataProvider = shortVideosProvider;
13
+ if (!dataProvider && ids) {
14
+ dataProvider = new InternalShortVideoPlayerProvider({ ids, graphqlOrigin, initialId, initiator });
79
15
  }
80
- else if (isIdsInit(init)) {
81
- input = {
82
- type: 'ids',
83
- ids: init.ids,
84
- initialId: init.initialId,
85
- graphqlOrigin: init.graphqlOrigin,
86
- initiator: init.initiator
87
- };
88
- }
89
- else {
90
- input = null;
91
- }
92
- if (!input) {
16
+ if (!dataProvider) {
17
+ toastrWarning('Data provider is not specified.');
93
18
  return;
94
19
  }
20
+ let mediaCenterDataProvider = init.mediaCenterDataProvider;
21
+ if (!mediaCenterDataProvider && init.mediaPageId) {
22
+ mediaCenterDataProvider = new InternalMediaCenterDataProvider(init.mediaPageId, graphqlOrigin);
23
+ }
95
24
  const shadowHost = new ModalShadowHost();
96
- const mounted = mount(ShortVideosPlayerView, {
25
+ const mounted = mount(MediaCenter, {
97
26
  target: shadowHost.shadowRoot,
98
27
  props: {
99
- input,
100
- socialInteractionsHandler: init.socialInteractionsHandler,
101
- localization: getLocale(init.localization),
102
- showStreamsCloudWatermark: init.showStreamsCloudWatermark,
103
- on: {
104
- closePlayer: async () => {
105
- if (init.on?.playerClosed) {
106
- init.on.playerClosed();
107
- }
108
- await unmount(mounted);
109
- shadowHost.remove();
110
- },
111
- videoActivated: (id) => {
112
- if (init.on?.videoActivated) {
113
- init.on.videoActivated(id);
28
+ dataProvider: mediaCenterDataProvider || null,
29
+ playerProps: {
30
+ type: MediaCenterMode.ShortVideos,
31
+ props: {
32
+ dataProvider,
33
+ socialInteractionsHandler,
34
+ disableBackground,
35
+ localization,
36
+ showStreamsCloudWatermark,
37
+ on: {
38
+ playerClosed: async () => {
39
+ await unmount(mounted);
40
+ shadowHost.remove();
41
+ if (init.on?.playerClosed) {
42
+ init.on.playerClosed();
43
+ }
44
+ },
45
+ videoActivated: (id) => {
46
+ if (init.on?.videoActivated) {
47
+ init.on.videoActivated(id);
48
+ }
49
+ }
114
50
  }
115
51
  }
116
52
  }
117
53
  }
118
54
  });
119
55
  shadowHost.attachToBody();
120
- };
56
+ }
@@ -0,0 +1,17 @@
1
+ import { type ShortVideoViewerModel } from '../short-video-viewer';
2
+ import type { IPlayerItemsProvider } from '../../ui/player';
3
+ export declare class InternalShortVideoPlayerProvider implements IPlayerItemsProvider<ShortVideoViewerModel> {
4
+ initialData: IPlayerItemsProvider<ShortVideoViewerModel>['initialData'];
5
+ private ids;
6
+ private initialId?;
7
+ private graphql;
8
+ private dataLoader;
9
+ constructor(input: {
10
+ ids: string[];
11
+ initiator?: string;
12
+ graphqlOrigin?: string;
13
+ initialId?: string;
14
+ });
15
+ loadMore: () => Promise<ShortVideoViewerModel[]>;
16
+ prefetch: () => Promise<void>;
17
+ }
@@ -0,0 +1,59 @@
1
+ import { ImageScale } from '../..';
2
+ import { ContinuationToken } from '../../core/continuation-token';
3
+ import { CursorDataLoader } from '../../core/data-loaders';
4
+ import { createLocalGQLClient } from '../../core/graphql';
5
+ import { mapToShortVideoViewerModel } from '../short-video-viewer';
6
+ import { GetShortVideosDocument } from './operations.generated';
7
+ export class InternalShortVideoPlayerProvider {
8
+ initialData;
9
+ ids;
10
+ initialId;
11
+ graphql;
12
+ dataLoader = new CursorDataLoader({
13
+ loadPage: async (continuationToken) => {
14
+ try {
15
+ const payload = await this.graphql
16
+ .query(GetShortVideosDocument, {
17
+ input: {
18
+ limit: 20,
19
+ continuationToken,
20
+ filter: {
21
+ ids: this.ids
22
+ }
23
+ },
24
+ image_scale: ImageScale.OriginalEncoded
25
+ })
26
+ .toPromise();
27
+ const data = payload.data?.shortVideos;
28
+ if (!data) {
29
+ return null;
30
+ }
31
+ return {
32
+ items: data.items.map(mapToShortVideoViewerModel),
33
+ continuationToken: ContinuationToken.fromPayload(data.continuationToken)
34
+ };
35
+ }
36
+ catch {
37
+ return null;
38
+ }
39
+ }
40
+ });
41
+ constructor(input) {
42
+ const { ids, graphqlOrigin, initiator, initialId } = input;
43
+ this.graphql = createLocalGQLClient(graphqlOrigin, initiator ? { 'x-initiator': initiator } : undefined);
44
+ this.ids = ids;
45
+ this.initialId = initialId;
46
+ this.initialData = { prefetchedItems: [], startIndex: 0 };
47
+ }
48
+ loadMore = () => this.dataLoader.loadMore();
49
+ prefetch = async () => {
50
+ const items = await this.loadMore();
51
+ if (this.initialId && items.length) {
52
+ const initialIndex = items.findIndex((i) => i.id === this.initialId);
53
+ this.initialData = { prefetchedItems: items, startIndex: initialIndex >= 0 ? initialIndex : 0 };
54
+ }
55
+ else {
56
+ this.initialData = { prefetchedItems: items, startIndex: 0 };
57
+ }
58
+ };
59
+ }
@@ -6,6 +6,7 @@ export type GetShortVideosQueryVariables = SchemaTypes.Exact<{
6
6
  }>;
7
7
  export type GetShortVideosQuery = {
8
8
  shortVideos: {
9
+ continuationToken: string | null;
9
10
  items: Array<{
10
11
  id: string;
11
12
  enableSocialInteractions: boolean;
@@ -36,7 +36,8 @@ export const GetShortVideosDocument = {
36
36
  kind: 'SelectionSet',
37
37
  selections: [{ kind: 'FragmentSpread', name: { kind: 'Name', value: 'ShortVideoViewerPayloadFragment' } }]
38
38
  }
39
- }
39
+ },
40
+ { kind: 'Field', name: { kind: 'Name', value: 'continuationToken' } }
40
41
  ]
41
42
  }
42
43
  }
@@ -4,5 +4,6 @@ query GetShortVideos($input: EmbedPostsInput!, $image_scale: ImageScale = ORIGIN
4
4
  items {
5
5
  ...ShortVideoViewerPayloadFragment
6
6
  }
7
+ continuationToken
7
8
  }
8
9
  }