@streamscloud/embeddable 8.3.0 → 10.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 (137) hide show
  1. package/dist/content-player/cmp.content-player.svelte +1 -1
  2. package/dist/content-player/content-player-config.svelte.d.ts +4 -4
  3. package/dist/content-player/controls-and-attachments.svelte +1 -1
  4. package/dist/content-player/header.svelte +1 -1
  5. package/dist/core/document.event-handlers.d.ts +1 -0
  6. package/dist/core/document.event-handlers.js +3 -0
  7. package/dist/media-center/config/internal-media-center-analytics-handler.d.ts +4 -3
  8. package/dist/media-center/config/internal-media-center-analytics-handler.js +1 -0
  9. package/dist/media-center/config/internal-media-center-config.d.ts +1 -1
  10. package/dist/media-center/config/internal-media-center-config.js +38 -48
  11. package/dist/media-center/config/operations.generated.d.ts +0 -104
  12. package/dist/media-center/config/operations.generated.js +0 -323
  13. package/dist/media-center/config/operations.graphql +0 -24
  14. package/dist/media-center/config/types.d.ts +14 -14
  15. package/dist/media-center/config/types.js +1 -1
  16. package/dist/media-center/media-center/cmp.media-center.svelte +101 -24
  17. package/dist/media-center/media-center/cmp.media-center.svelte.d.ts +5 -5
  18. package/dist/media-center/media-center/discover-panel-handler.svelte.d.ts +5 -4
  19. package/dist/media-center/media-center/discover-panel-handler.svelte.js +2 -1
  20. package/dist/media-center/media-center/discover-panel.svelte +1 -1
  21. package/dist/media-center/media-center/discover-panel.svelte.d.ts +4 -3
  22. package/dist/media-center/media-center/post-player-provider-generator.d.ts +8 -0
  23. package/dist/media-center/media-center/{short-video-resources-generator.js → post-player-provider-generator.js} +9 -3
  24. package/dist/media-center/media-center/streams-in-category-panel-handler.svelte.d.ts +5 -2
  25. package/dist/media-center/media-center/streams-in-category-panel-handler.svelte.js +5 -0
  26. package/dist/media-center/media-center/streams-in-category-panel.svelte +2 -2
  27. package/dist/media-center/media-center/streams-in-category-panel.svelte.d.ts +3 -2
  28. package/dist/media-center/media-center/streams-player-provider-generator.d.ts +8 -0
  29. package/dist/media-center/media-center/streams-player-provider-generator.js +36 -0
  30. package/dist/media-center/media-center/types.d.ts +1 -7
  31. package/dist/posts/controls/cmp.controls.svelte +1 -1
  32. package/dist/posts/data-loaders/index.d.ts +1 -0
  33. package/dist/posts/data-loaders/index.js +1 -0
  34. package/dist/posts/data-loaders/mapper.d.ts +3 -0
  35. package/dist/{short-videos/short-videos-player → posts/data-loaders}/mapper.js +2 -2
  36. package/dist/{short-videos/short-videos-player → posts/data-loaders}/operations.generated.d.ts +6 -6
  37. package/dist/{short-videos/short-videos-player → posts/data-loaders}/operations.generated.js +7 -10
  38. package/dist/posts/data-loaders/operations.graphql +17 -0
  39. package/dist/posts/data-loaders/posts-loader.d.ts +19 -0
  40. package/dist/posts/data-loaders/posts-loader.js +28 -0
  41. package/dist/posts/handlers/index.d.ts +1 -0
  42. package/dist/posts/handlers/index.js +1 -0
  43. package/dist/{short-videos/short-videos-player/internal-short-video-analytics-handler.d.ts → posts/handlers/internal-post-analytics-handler.d.ts} +3 -2
  44. package/dist/{short-videos/short-videos-player/internal-short-video-analytics-handler.js → posts/handlers/internal-post-analytics-handler.js} +2 -1
  45. package/dist/{short-videos/short-videos-player/cmp.short-videos-player.svelte → posts/posts-player/cmp.posts-player.svelte} +3 -3
  46. package/dist/posts/posts-player/cmp.posts-player.svelte.d.ts +4 -0
  47. package/dist/posts/posts-player/index.d.ts +55 -20
  48. package/dist/posts/posts-player/index.js +48 -32
  49. package/dist/posts/posts-player/posts-player-view.svelte +65 -15
  50. package/dist/posts/posts-player/posts-player-view.svelte.d.ts +5 -1
  51. package/dist/posts/posts-player/types.d.ts +9 -3
  52. package/dist/short-videos/data-providers/index.d.ts +1 -0
  53. package/dist/short-videos/data-providers/index.js +1 -0
  54. package/dist/short-videos/data-providers/internal-short-video-player-items-provider.d.ts +17 -0
  55. package/dist/short-videos/{short-videos-player/internal-short-video-player-provider.js → data-providers/internal-short-video-player-items-provider.js} +13 -33
  56. package/dist/short-videos/short-videos-player/index.d.ts +14 -64
  57. package/dist/short-videos/short-videos-player/index.js +77 -31
  58. package/dist/streams/data-loaders/index.d.ts +2 -0
  59. package/dist/streams/data-loaders/index.js +2 -0
  60. package/dist/streams/{stream-player → data-loaders}/mapper.d.ts +1 -1
  61. package/dist/streams/{stream-player → data-loaders}/operations.generated.d.ts +27 -24
  62. package/dist/streams/{stream-player → data-loaders}/operations.generated.js +18 -17
  63. package/dist/streams/{stream-player → data-loaders}/operations.graphql +6 -3
  64. package/dist/streams/data-loaders/stream-pages-loader.d.ts +10 -0
  65. package/dist/streams/data-loaders/stream-pages-loader.js +33 -0
  66. package/dist/streams/data-loaders/streams-loader.d.ts +19 -0
  67. package/dist/streams/data-loaders/streams-loader.js +28 -0
  68. package/dist/streams/{stream-player → streams-player}/index.d.ts +21 -22
  69. package/dist/streams/{stream-player → streams-player}/index.js +9 -7
  70. package/dist/streams/streams-player/internal-streams-player-data-provider.d.ts +16 -0
  71. package/dist/streams/streams-player/internal-streams-player-data-provider.js +55 -0
  72. package/dist/streams/{stream-player → streams-player}/stream-overview.svelte +18 -15
  73. package/dist/streams/{stream-player → streams-player}/stream-overview.svelte.d.ts +2 -2
  74. package/dist/streams/streams-player/streams-player-buffer.svelte.d.ts +8 -0
  75. package/dist/streams/streams-player/streams-player-buffer.svelte.js +15 -0
  76. package/dist/streams/{stream-player/stream-player-view.svelte → streams-player/streams-player-view.svelte} +69 -55
  77. package/dist/streams/streams-player/streams-player-view.svelte.d.ts +8 -0
  78. package/dist/streams/{stream-player → streams-player}/types.d.ts +9 -7
  79. package/dist/ui/{player-button → player/button}/cmp.player-button.svelte +1 -1
  80. package/dist/ui/{player-button → player/button}/cmp.player-button.svelte.d.ts +1 -1
  81. package/dist/ui/{player-button → player/button}/cmp.player-buttons-group.svelte +1 -1
  82. package/dist/ui/{player-button → player/button}/types.d.ts +1 -1
  83. package/dist/ui/player/button/types.js +1 -0
  84. package/dist/ui/player/providers/chunks-player-buffer/index.d.ts +2 -0
  85. package/dist/ui/player/providers/chunks-player-buffer/index.js +2 -0
  86. package/dist/ui/player/providers/chunks-player-buffer/player-chunk-item.svelte.d.ts +11 -0
  87. package/dist/ui/player/providers/chunks-player-buffer/player-chunk-item.svelte.js +11 -0
  88. package/dist/ui/player/providers/chunks-player-buffer/player-chunk.svelte.d.ts +31 -0
  89. package/dist/ui/player/providers/chunks-player-buffer/player-chunk.svelte.js +67 -0
  90. package/dist/ui/player/providers/chunks-player-buffer/player-chunks-manager.svelte.d.ts +23 -0
  91. package/dist/ui/player/providers/chunks-player-buffer/player-chunks-manager.svelte.js +119 -0
  92. package/dist/ui/player/providers/default-chunks-player-buffer.svelte.d.ts +20 -0
  93. package/dist/ui/player/providers/default-chunks-player-buffer.svelte.js +47 -0
  94. package/dist/ui/player/providers/default-feed-player-buffer.svelte.d.ts +27 -0
  95. package/dist/ui/player/providers/default-feed-player-buffer.svelte.js +78 -0
  96. package/dist/ui/player/providers/index.d.ts +3 -0
  97. package/dist/ui/player/providers/index.js +2 -0
  98. package/dist/ui/player/providers/types.d.ts +49 -0
  99. package/dist/ui/{player-slider → player/slider}/cmp.player-slider.svelte +7 -20
  100. package/dist/ui/{player-slider → player/slider}/cmp.player-slider.svelte.d.ts +4 -4
  101. package/dist/ui/{player-slider → player/slider}/index.d.ts +0 -2
  102. package/dist/ui/{player-slider → player/slider}/index.js +0 -1
  103. package/dist/ui/player/slider/types.d.ts +16 -0
  104. package/dist/ui/swipe-indicator/cmp.swipe-indicator.svelte +7 -8
  105. package/package.json +4 -4
  106. package/dist/media-center/media-center/short-video-resources-generator.d.ts +0 -8
  107. package/dist/short-videos/short-videos-player/cmp.short-videos-player.svelte.d.ts +0 -4
  108. package/dist/short-videos/short-videos-player/internal-short-video-player-provider.d.ts +0 -18
  109. package/dist/short-videos/short-videos-player/mapper.d.ts +0 -3
  110. package/dist/short-videos/short-videos-player/operations.graphql +0 -17
  111. package/dist/short-videos/short-videos-player/short-videos-player-view.svelte +0 -82
  112. package/dist/short-videos/short-videos-player/short-videos-player-view.svelte.d.ts +0 -8
  113. package/dist/short-videos/short-videos-player/types.d.ts +0 -26
  114. package/dist/streams/stream-player/internal-stream-player-data-provider.d.ts +0 -12
  115. package/dist/streams/stream-player/internal-stream-player-data-provider.js +0 -48
  116. package/dist/streams/stream-player/stream-player-buffer.svelte.d.ts +0 -28
  117. package/dist/streams/stream-player/stream-player-buffer.svelte.js +0 -79
  118. package/dist/streams/stream-player/stream-player-view.svelte.d.ts +0 -8
  119. package/dist/ui/player-button/types.js +0 -1
  120. package/dist/ui/player-slider/player-buffer.svelte.d.ts +0 -31
  121. package/dist/ui/player-slider/player-buffer.svelte.js +0 -76
  122. package/dist/ui/player-slider/types.d.ts +0 -26
  123. /package/dist/streams/{stream-player → data-loaders}/mapper.js +0 -0
  124. /package/dist/streams/{stream-player → streams-player}/internal-stream-analytics-handler.d.ts +0 -0
  125. /package/dist/streams/{stream-player → streams-player}/internal-stream-analytics-handler.js +0 -0
  126. /package/dist/streams/{stream-player → streams-player}/stream-player-localization.d.ts +0 -0
  127. /package/dist/streams/{stream-player → streams-player}/stream-player-localization.js +0 -0
  128. /package/dist/{short-videos/short-videos-player → streams/streams-player}/types.js +0 -0
  129. /package/dist/ui/{player-button → player/button}/cmp.player-buttons-group.svelte.d.ts +0 -0
  130. /package/dist/ui/{player-button → player/button}/index.d.ts +0 -0
  131. /package/dist/ui/{player-button → player/button}/index.js +0 -0
  132. /package/dist/{streams/stream-player → ui/player/providers}/types.js +0 -0
  133. /package/dist/ui/{player-slider → player/slider}/prevent-slider-scroll.d.ts +0 -0
  134. /package/dist/ui/{player-slider → player/slider}/prevent-slider-scroll.js +0 -0
  135. /package/dist/ui/{player-slider → player/slider}/types.js +0 -0
  136. /package/dist/ui/{player-slider → player/slider}/wheel-gestures-adapter.d.ts +0 -0
  137. /package/dist/ui/{player-slider → player/slider}/wheel-gestures-adapter.js +0 -0
@@ -0,0 +1 @@
1
+ export { InternalShortVideoPlayerItemsProvider } from './internal-short-video-player-items-provider';
@@ -0,0 +1 @@
1
+ export { InternalShortVideoPlayerItemsProvider } from './internal-short-video-player-items-provider';
@@ -0,0 +1,17 @@
1
+ import { type PostPlayerModel } from '../../posts/posts-player';
2
+ import type { IFeedPlayerDataProvider } from '../../ui/player/providers';
3
+ export declare class InternalShortVideoPlayerItemsProvider implements IFeedPlayerDataProvider<PostPlayerModel> {
4
+ readonly kind = "feed";
5
+ readonly initialData: IFeedPlayerDataProvider<PostPlayerModel>['initialData'];
6
+ private ids;
7
+ private idOrder;
8
+ private graphql;
9
+ private dataLoader;
10
+ constructor(input: {
11
+ ids: string[];
12
+ initiator?: string;
13
+ graphqlOrigin?: string;
14
+ initialId?: string;
15
+ });
16
+ loadMore: IFeedPlayerDataProvider<PostPlayerModel>['loadMore'];
17
+ }
@@ -1,15 +1,15 @@
1
- import { ImageScale } from '../..';
1
+ import { PostType } from '../..';
2
2
  import { ContinuationToken } from '../../core/continuation-token';
3
3
  import { CursorDataLoader } from '../../core/data-loaders';
4
4
  import { createLocalGQLClient } from '../../core/graphql';
5
- import { mapToShortVideoPlayerModel } from './mapper';
6
- import { GetShortVideosDocument } from './operations.generated';
5
+ import { getPostsCursor } from '../../posts/data-loaders';
6
+ import {} from '../../posts/posts-player';
7
7
  const CHUNK_SIZE = 20;
8
- export class InternalShortVideoPlayerProvider {
8
+ export class InternalShortVideoPlayerItemsProvider {
9
+ kind = 'feed';
9
10
  initialData;
10
11
  ids;
11
12
  idOrder = new Map();
12
- initialId;
13
13
  graphql;
14
14
  dataLoader = new CursorDataLoader({
15
15
  loadPage: async (continuationToken) => {
@@ -17,22 +17,12 @@ export class InternalShortVideoPlayerProvider {
17
17
  const endIdIndex = Math.min(startIdIndex + CHUNK_SIZE, this.ids.length);
18
18
  const idsChunk = this.ids.slice(startIdIndex, endIdIndex);
19
19
  try {
20
- const payload = await this.graphql
21
- .query(GetShortVideosDocument, {
22
- input: {
23
- limit: idsChunk.length,
24
- filter: {
25
- ids: idsChunk
26
- }
27
- },
28
- image_scale: ImageScale.OriginalEncoded
29
- })
30
- .toPromise();
31
- const data = payload.data?.shortVideos;
32
- if (!data) {
33
- return null;
34
- }
35
- const items = data.items.map(mapToShortVideoPlayerModel).sort((a, b) => {
20
+ const posts = await getPostsCursor({
21
+ filter: { ids: idsChunk, types: [PostType.ShortVideo] },
22
+ limit: idsChunk.length,
23
+ graphql: this.graphql
24
+ });
25
+ const items = posts.items.sort((a, b) => {
36
26
  const ia = this.idOrder.get(a.id) ?? Number.MAX_SAFE_INTEGER;
37
27
  const ib = this.idOrder.get(b.id) ?? Number.MAX_SAFE_INTEGER;
38
28
  return ia - ib;
@@ -52,18 +42,8 @@ export class InternalShortVideoPlayerProvider {
52
42
  this.graphql = createLocalGQLClient(graphqlOrigin, initiator ? { 'x-initiator': initiator } : undefined);
53
43
  this.ids = ids;
54
44
  ids.forEach((id, idx) => this.idOrder.set(id, idx));
55
- this.initialId = initialId;
56
- this.initialData = { prefetchedItems: [], startIndex: 0 };
45
+ const startIndex = initialId ? ids.indexOf(initialId) : 0;
46
+ this.initialData = { prefetchedItems: [], startIndex };
57
47
  }
58
48
  loadMore = () => this.dataLoader.loadMore();
59
- prefetch = async () => {
60
- const items = await this.loadMore();
61
- if (this.initialId && items.length) {
62
- const initialIndex = items.findIndex((i) => i.id === this.initialId);
63
- this.initialData = { prefetchedItems: items, startIndex: initialIndex >= 0 ? initialIndex : 0 };
64
- }
65
- else {
66
- this.initialData = { prefetchedItems: items, startIndex: 0 };
67
- }
68
- };
69
49
  }
@@ -1,27 +1,11 @@
1
+ import type { Locale } from '../../core/locale';
1
2
  import { type IMediaCenterConfig } from '../../media-center/config/types';
2
- import type { IPostSocialInteractionsHandler } from '../../posts/social-interactions';
3
- import type { IPlayerItemsProvider } from '../../ui/player-slider';
4
- import { default as ShortVideosPlayer } from './cmp.short-videos-player.svelte';
5
- import { mapToShortVideoPlayerModel } from './mapper';
6
- import type { IShortVideoAnalyticsHandler, ShortVideoPlayerModel, ShortVideoPlayerSettings } from './types';
7
- export { ShortVideosPlayer, type ShortVideoPlayerModel };
8
- export type { IMediaCenterConfig, IPlayerItemsProvider, IShortVideoAnalyticsHandler };
9
- export { mapToShortVideoPlayerModel };
3
+ export type { IMediaCenterConfig };
10
4
  /**
11
5
  * Opens the short videos player modal.
12
6
  *
13
- * Two overloads (mutually exclusive):
14
- * - Provider mode: openShortVideosPlayer({ shortVideosProvider, mediaCenterConfig?, ...common })
15
- * - IDs mode: openShortVideosPlayer({ ids, initiator, graphqlOrigin?, initialId?, mediaPageId?, ...common })
16
- *
17
7
  * @param init Configuration options.
18
8
  *
19
- * Provider mode (overload 1)
20
- * @param {IPlayerItemsProvider<ShortVideoPlayerModel>} init.shortVideosProvider
21
- * Provider that supplies short-video items to the player.
22
- * @param {IMediaCenterConfig} [init.mediaCenterConfig]
23
- * Optional media-center config.
24
- *
25
9
  * IDs mode (overload 2)
26
10
  * @param {string[]} init.ids
27
11
  * List of short-video IDs to display.
@@ -34,22 +18,18 @@ export { mapToShortVideoPlayerModel };
34
18
  * @param {string} [init.mediaPageId]
35
19
  * Optional media page ID used to construct an internal media-center config.
36
20
  *
37
- * Common settings
21
+ * Player settings
38
22
  * @param {IPostSocialInteractionsHandler} [init.socialInteractionsHandler]
39
23
  * Handler for social interactions (like, share, etc.).
40
- * @param {ContentPlayerSettings} [init.playerSettings]
24
+ * @param [init.playerSettings]
41
25
  * Player UI and behavior settings.
42
26
  *
43
27
  * Fields of ContentPlayerSettings:
44
- * - {boolean} [disableBackground]
45
- * If true, hides the player's background image.
46
28
  * - {boolean} [hideCloseButton]
47
29
  * If true, hides the close button.
48
30
  * - {Locale} [locale='en']
49
31
  * Localization for the player UI. Supported values: 'en' | 'no'.
50
32
  * If omitted, the default locale 'en' is used.
51
- * - {boolean} [showStreamsCloudWatermark]
52
- * If true, shows the StreamsCloud watermark.
53
33
  *
54
34
  * Events
55
35
  * @param {{ playerClosed?: () => void; videoActivated?: (id: string) => void }} [init.on]
@@ -61,70 +41,40 @@ export { mapToShortVideoPlayerModel };
61
41
  *
62
42
  * @returns {void}
63
43
  *
64
- * @example <caption>Provider mode</caption>
65
- * ```ts
66
- * import { openShortVideosPlayer } from '@streamscloud/embeddable/short-videos-player';
67
- *
68
- * openShortVideosPlayer({
69
- * shortVideosProvider: myShortVideosProvider,
70
- * mediaCenterConfig: mymediaCenterConfig,
71
- * playerSettings: {
72
- * // Locale is 'en' by default; set 'no' to switch to Norwegian:
73
- * locale: 'no',
74
- * disableBackground: false,
75
- * hideCloseButton: false,
76
- * showStreamsCloudWatermark: true,
77
- * },
78
- * on: {
79
- * playerClosed: () => console.log('Player closed'),
80
- * videoActivated: (id) => console.log('Activated', id)
81
- * }
82
- * });
83
- * ```
84
- *
85
44
  * @example <caption>IDs mode</caption>
86
45
  * ```ts
87
46
  * import { openShortVideosPlayer } from '@streamscloud/embeddable/short-videos-player';
88
47
  *
89
48
  * openShortVideosPlayer({
90
49
  * ids: ['id1', 'id2', 'id3'],
91
- * initiator: 'marketing-campaign',
50
+ * initiator: 'campaign-autumn',
92
51
  * graphqlOrigin: 'https://graphql.example.com',
93
52
  * initialId: 'id2',
94
53
  * mediaPageId: 'media-page-123',
95
54
  * playerSettings: {
96
- * locale: 'en',
97
- * disableBackground: true,
55
+ * // Default locale is 'en'; set 'no' to switch to Norwegian:
56
+ * locale: 'no',
57
+ * disableBackground: false,
98
58
  * hideCloseButton: false,
99
- * showStreamsCloudWatermark: false,
59
+ * showStreamsCloudWatermark: true,
100
60
  * },
101
61
  * on: {
102
62
  * playerClosed: () => console.log('Player closed'),
103
- * videoActivated: (id) => console.log('Activated', id)
104
63
  * }
105
64
  * });
106
65
  * ```
107
66
  */
108
- export declare function openShortVideosPlayer(init: {
109
- shortVideosProvider: IPlayerItemsProvider<ShortVideoPlayerModel>;
110
- mediaCenterConfig?: IMediaCenterConfig;
111
- analyticsHandler?: IShortVideoAnalyticsHandler;
112
- socialInteractionsHandler?: IPostSocialInteractionsHandler;
113
- playerSettings?: ShortVideoPlayerSettings;
114
- on?: {
115
- playerClosed?: () => void;
116
- videoActivated?: (id: string) => void;
117
- };
118
- }): void;
119
67
  export declare function openShortVideosPlayer(init: {
120
68
  ids: string[];
121
69
  initiator: string;
122
70
  graphqlOrigin?: string;
123
71
  initialId?: string;
124
72
  mediaPageId?: string;
125
- playerSettings?: ShortVideoPlayerSettings;
73
+ playerSettings?: {
74
+ hideCloseButton?: boolean;
75
+ locale?: Locale;
76
+ };
126
77
  on?: {
127
78
  playerClosed?: () => void;
128
- videoActivated?: (id: string) => void;
129
79
  };
130
- }): void;
80
+ }): Promise<void>;
@@ -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
- export { ShortVideosPlayer };
12
- export { mapToShortVideoPlayerModel };
13
- export function openShortVideosPlayer(init) {
14
- const { shortVideosProvider, ids, graphqlOrigin, initialId, initiator, socialInteractionsHandler, playerSettings, on } = init;
15
- let dataProvider = shortVideosProvider;
16
- if (!dataProvider && ids) {
17
- dataProvider = new InternalShortVideoPlayerProvider({ ids, graphqlOrigin, initialId, initiator });
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
- }
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
+ */
71
+ export async function openShortVideosPlayer(init) {
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: 'short-videos',
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
  }
@@ -0,0 +1,2 @@
1
+ export { getStreamsCursor } from './streams-loader';
2
+ export { getStreamPagesCursor } from './stream-pages-loader';
@@ -0,0 +1,2 @@
1
+ export { getStreamsCursor } from './streams-loader';
2
+ export { getStreamPagesCursor } from './stream-pages-loader';
@@ -1,3 +1,3 @@
1
+ import type { StreamPlayerModel } from '../streams-player/types';
1
2
  import type { StreamPlayerPayloadFragment } from './operations.generated';
2
- import type { StreamPlayerModel } from './types';
3
3
  export declare const mapToStreamPlayerModel: (payload: StreamPlayerPayloadFragment) => StreamPlayerModel;
@@ -1,30 +1,33 @@
1
1
  import type * as SchemaTypes from '../../../gql/types';
2
2
  import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
3
- export type GetStreamQueryVariables = SchemaTypes.Exact<{
4
- id: SchemaTypes.Scalars['String']['input'];
3
+ export type GetStreamsQueryVariables = SchemaTypes.Exact<{
4
+ input: SchemaTypes.EmbedStreamsInput;
5
5
  }>;
6
- export type GetStreamQuery = {
7
- stream: {
8
- id: string;
9
- title: string;
10
- subTitle: string | null;
11
- createdAt: any;
12
- publishedAt: any | null;
13
- pagesCount: number;
14
- cover: {
15
- url: string;
16
- } | null;
17
- ownerProfile: {
18
- image: string | null;
19
- name: string;
6
+ export type GetStreamsQuery = {
7
+ streams: {
8
+ continuationToken: string | null;
9
+ items: Array<{
20
10
  id: string;
21
- type: SchemaTypes.ProfileType;
22
- };
23
- availableFrom: {
24
- image: string;
25
- name: string;
26
- } | null;
27
- } | null;
11
+ title: string;
12
+ subTitle: string | null;
13
+ createdAt: any;
14
+ publishedAt: any | null;
15
+ pagesCount: number;
16
+ cover: {
17
+ url: string;
18
+ } | null;
19
+ ownerProfile: {
20
+ image: string | null;
21
+ name: string;
22
+ id: string;
23
+ type: SchemaTypes.ProfileType;
24
+ };
25
+ availableFrom: {
26
+ image: string;
27
+ name: string;
28
+ } | null;
29
+ }>;
30
+ };
28
31
  };
29
32
  export type GetStreamPagesQueryVariables = SchemaTypes.Exact<{
30
33
  input: SchemaTypes.EmbedStreamPagesInput;
@@ -65,5 +68,5 @@ export type StreamPlayerPayloadFragment = {
65
68
  } | null;
66
69
  };
67
70
  export declare const StreamPlayerPayloadFragmentDoc: DocumentNode<StreamPlayerPayloadFragment, unknown>;
68
- export declare const GetStreamDocument: DocumentNode<GetStreamQuery, GetStreamQueryVariables>;
71
+ export declare const GetStreamsDocument: DocumentNode<GetStreamsQuery, GetStreamsQueryVariables>;
69
72
  export declare const GetStreamPagesDocument: DocumentNode<GetStreamPagesQuery, GetStreamPagesQueryVariables>;
@@ -48,18 +48,18 @@ export const StreamPlayerPayloadFragmentDoc = {
48
48
  }
49
49
  ]
50
50
  };
51
- export const GetStreamDocument = {
51
+ export const GetStreamsDocument = {
52
52
  kind: 'Document',
53
53
  definitions: [
54
54
  {
55
55
  kind: 'OperationDefinition',
56
56
  operation: 'query',
57
- name: { kind: 'Name', value: 'GetStream' },
57
+ name: { kind: 'Name', value: 'GetStreams' },
58
58
  variableDefinitions: [
59
59
  {
60
60
  kind: 'VariableDefinition',
61
- variable: { kind: 'Variable', name: { kind: 'Name', value: 'id' } },
62
- type: { kind: 'NonNullType', type: { kind: 'NamedType', name: { kind: 'Name', value: 'String' } } }
61
+ variable: { kind: 'Variable', name: { kind: 'Name', value: 'input' } },
62
+ type: { kind: 'NonNullType', type: { kind: 'NamedType', name: { kind: 'Name', value: 'EmbedStreamsInput' } } }
63
63
  }
64
64
  ],
65
65
  selectionSet: {
@@ -67,19 +67,20 @@ export const GetStreamDocument = {
67
67
  selections: [
68
68
  {
69
69
  kind: 'Field',
70
- alias: { kind: 'Name', value: 'stream' },
71
- name: { kind: 'Name', value: 'embedStream' },
72
- arguments: [
73
- {
74
- kind: 'Argument',
75
- name: { kind: 'Name', value: 'input' },
76
- value: {
77
- kind: 'ObjectValue',
78
- fields: [{ kind: 'ObjectField', name: { kind: 'Name', value: 'id' }, value: { kind: 'Variable', name: { kind: 'Name', value: 'id' } } }]
79
- }
80
- }
81
- ],
82
- selectionSet: { kind: 'SelectionSet', selections: [{ kind: 'FragmentSpread', name: { kind: 'Name', value: 'StreamPlayerPayloadFragment' } }] }
70
+ alias: { kind: 'Name', value: 'streams' },
71
+ name: { kind: 'Name', value: 'embedStreams' },
72
+ arguments: [{ kind: 'Argument', name: { kind: 'Name', value: 'input' }, value: { kind: 'Variable', name: { kind: 'Name', value: 'input' } } }],
73
+ selectionSet: {
74
+ kind: 'SelectionSet',
75
+ selections: [
76
+ {
77
+ kind: 'Field',
78
+ name: { kind: 'Name', value: 'items' },
79
+ selectionSet: { kind: 'SelectionSet', selections: [{ kind: 'FragmentSpread', name: { kind: 'Name', value: 'StreamPlayerPayloadFragment' } }] }
80
+ },
81
+ { kind: 'Field', name: { kind: 'Name', value: 'continuationToken' } }
82
+ ]
83
+ }
83
84
  }
84
85
  ]
85
86
  }
@@ -1,6 +1,9 @@
1
- query GetStream($id: String!) {
2
- stream: embedStream(input: { id: $id }) {
3
- ...StreamPlayerPayloadFragment
1
+ query GetStreams($input: EmbedStreamsInput!) {
2
+ streams: embedStreams(input: $input) {
3
+ items {
4
+ ...StreamPlayerPayloadFragment
5
+ }
6
+ continuationToken
4
7
  }
5
8
  }
6
9
 
@@ -0,0 +1,10 @@
1
+ import { type StreamPageViewerModel } from '../stream-page-viewer';
2
+ import type { Client } from '@urql/core';
3
+ export declare const getStreamPagesCursor: (input: {
4
+ streamId: string;
5
+ continuationToken: string | null | undefined;
6
+ graphql: Client;
7
+ }) => Promise<{
8
+ items: StreamPageViewerModel[];
9
+ continuationToken: string | null;
10
+ }>;
@@ -0,0 +1,33 @@
1
+ import { ImageScale } from '../..';
2
+ import { mapToStreamPageViewerModel } from '../stream-page-viewer';
3
+ import { GetStreamPagesDocument } from './operations.generated';
4
+ export const getStreamPagesCursor = async (input) => {
5
+ const { streamId, continuationToken, graphql } = input;
6
+ const emptyResult = { items: [], continuationToken: null };
7
+ if (continuationToken === null) {
8
+ return emptyResult;
9
+ }
10
+ try {
11
+ const payload = await graphql
12
+ .query(GetStreamPagesDocument, {
13
+ input: {
14
+ limit: 10,
15
+ continuationToken,
16
+ filter: { streamId }
17
+ },
18
+ image_scale: ImageScale.OriginalEncoded
19
+ })
20
+ .toPromise();
21
+ const data = payload.data?.streamPages;
22
+ if (!data) {
23
+ return emptyResult;
24
+ }
25
+ return {
26
+ items: data.items.map(mapToStreamPageViewerModel),
27
+ continuationToken: data.continuationToken
28
+ };
29
+ }
30
+ catch {
31
+ return emptyResult;
32
+ }
33
+ };
@@ -0,0 +1,19 @@
1
+ import { StreamStatus } from '../../core/enums';
2
+ import type { StreamPlayerModel } from '../streams-player/types';
3
+ import type { Client } from '@urql/core';
4
+ export declare const getStreamsCursor: (input: {
5
+ filter: {
6
+ ids?: string[];
7
+ categoryId?: string;
8
+ excludeIds?: string[];
9
+ mediaPageId?: string;
10
+ statuses?: StreamStatus[];
11
+ showInFeed?: boolean;
12
+ };
13
+ limit: number;
14
+ continuationToken?: string | null;
15
+ graphql: Client;
16
+ }) => Promise<{
17
+ items: StreamPlayerModel[];
18
+ continuationToken: string | null;
19
+ }>;
@@ -0,0 +1,28 @@
1
+ import { StreamStatus } from '../../core/enums';
2
+ import { mapToStreamPlayerModel } from './mapper';
3
+ import { GetStreamsDocument } from './operations.generated';
4
+ export const getStreamsCursor = async (input) => {
5
+ const { filter, limit, continuationToken, graphql } = input;
6
+ const { mediaPageId, ids, categoryId, excludeIds, statuses, showInFeed } = filter;
7
+ const payload = await graphql
8
+ .query(GetStreamsDocument, {
9
+ input: {
10
+ filter: {
11
+ ids,
12
+ mediaPageId,
13
+ categoryId,
14
+ excludeIds,
15
+ statuses,
16
+ showInFeed
17
+ },
18
+ limit,
19
+ continuationToken
20
+ }
21
+ })
22
+ .toPromise();
23
+ const streams = payload.data?.streams.items ?? [];
24
+ return {
25
+ items: streams.map(mapToStreamPlayerModel),
26
+ continuationToken: payload.data?.streams?.continuationToken ?? null
27
+ };
28
+ };