@streamscloud/embeddable 13.3.0 → 14.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 (145) hide show
  1. package/dist/external-api/data-providers/internal-media-center-data-provider.svelte.js +6 -6
  2. package/dist/external-api/data-providers/mocks/index.d.ts +5 -0
  3. package/dist/external-api/data-providers/mocks/index.js +5 -0
  4. package/dist/{media-center/categories-following → external-api/data-providers/mocks}/mock-categories-following-handler.svelte.d.ts +1 -1
  5. package/dist/external-api/data-providers/mocks/mock-content-management-handler.svelte.d.ts +29 -0
  6. package/dist/external-api/data-providers/mocks/mock-content-management-handler.svelte.js +61 -0
  7. package/dist/{media-center/membership → external-api/data-providers/mocks}/mock-membership-handler.svelte.d.ts +1 -1
  8. package/dist/{media-center/navigation → external-api/data-providers/mocks}/mock-navigation-handler.svelte.d.ts +1 -2
  9. package/dist/{posts/social-interactions → external-api/data-providers/mocks}/mock-post-social-interactions-handler.svelte.d.ts +1 -2
  10. package/dist/{posts/social-interactions → external-api/data-providers/mocks}/mock-post-social-interactions-handler.svelte.js +17 -6
  11. package/dist/external-api/data-providers/mocks/operations.generated.d.ts +115 -0
  12. package/dist/external-api/data-providers/mocks/operations.generated.js +377 -0
  13. package/dist/external-api/data-providers/mocks/operations.graphql +18 -0
  14. package/dist/media-center/config/types.d.ts +7 -1
  15. package/dist/media-center/content-management/index.d.ts +1 -0
  16. package/dist/media-center/content-management/index.js +1 -0
  17. package/dist/media-center/content-management/types.d.ts +24 -0
  18. package/dist/media-center/content-management/types.js +1 -0
  19. package/dist/media-center/index.d.ts +2 -1
  20. package/dist/media-center/media-center/cmp.media-center-proxy.svelte +2 -2
  21. package/dist/media-center/media-center/discover/data-loading.d.ts +3 -0
  22. package/dist/media-center/media-center/discover/data-loading.js +13 -2
  23. package/dist/media-center/media-center/discover/discover-view-handler.svelte.d.ts +23 -0
  24. package/dist/media-center/media-center/discover/discover-view-handler.svelte.js +88 -0
  25. package/dist/media-center/media-center/discover/discover-view.svelte +79 -14
  26. package/dist/media-center/media-center/discover/discover-view.svelte.d.ts +2 -2
  27. package/dist/media-center/media-center/footer/media-center-footer.svelte +1 -1
  28. package/dist/media-center/media-center/handlers/index.d.ts +1 -0
  29. package/dist/media-center/media-center/handlers/index.js +1 -0
  30. package/dist/media-center/media-center/handlers/media-center-content-handler.svelte.d.ts +62 -0
  31. package/dist/media-center/media-center/handlers/media-center-content-handler.svelte.js +144 -0
  32. package/dist/media-center/media-center/header/media-center-header-mobile.svelte +10 -7
  33. package/dist/media-center/media-center/header/media-center-header.svelte +1 -1
  34. package/dist/media-center/media-center/media-center-context.svelte.d.ts +3 -2
  35. package/dist/media-center/media-center/media-center-context.svelte.js +30 -11
  36. package/dist/media-center/media-center/media-center-view.svelte +31 -13
  37. package/dist/media-center/media-center/menu/menu.svelte +13 -2
  38. package/dist/media-center/media-center/menu/menu.svelte.d.ts +1 -0
  39. package/dist/media-center/media-center/menu/popular-streams-panel-handler.svelte.d.ts +7 -0
  40. package/dist/media-center/media-center/menu/popular-streams-panel-handler.svelte.js +23 -8
  41. package/dist/media-center/media-center/moments/moments-feed-handler.svelte.d.ts +19 -2
  42. package/dist/media-center/media-center/moments/moments-feed-handler.svelte.js +51 -6
  43. package/dist/media-center/media-center/moments/moments-state.svelte.d.ts +2 -0
  44. package/dist/media-center/media-center/moments/moments-state.svelte.js +16 -1
  45. package/dist/media-center/media-center/posts-feed/posts-feed-handler.svelte.d.ts +24 -4
  46. package/dist/media-center/media-center/posts-feed/posts-feed-handler.svelte.js +90 -9
  47. package/dist/media-center/media-center/streams-feed/streams-feed-handler.svelte.d.ts +18 -3
  48. package/dist/media-center/media-center/streams-feed/streams-feed-handler.svelte.js +64 -9
  49. package/dist/posts/controls/index.d.ts +2 -1
  50. package/dist/posts/controls/index.js +2 -1
  51. package/dist/posts/controls/post-actions-generator.svelte.d.ts +20 -0
  52. package/dist/posts/controls/post-actions-generator.svelte.js +27 -0
  53. package/dist/posts/controls/post-actions-handler.svelte.d.ts +26 -0
  54. package/dist/posts/controls/post-actions-handler.svelte.js +56 -0
  55. package/dist/posts/index.d.ts +1 -0
  56. package/dist/posts/model/types.d.ts +1 -0
  57. package/dist/posts/post-viewer/cmp.post-viewer.svelte +6 -7
  58. package/dist/posts/post-viewer/cmp.post-viewer.svelte.d.ts +2 -2
  59. package/dist/posts/post-viewer/mapper.js +1 -0
  60. package/dist/posts/posts-player/cmp.posts-player.svelte +2 -1
  61. package/dist/posts/posts-player/cmp.posts-player.svelte.d.ts +2 -0
  62. package/dist/posts/posts-player/index.d.ts +2 -0
  63. package/dist/posts/posts-player/index.js +2 -1
  64. package/dist/posts/posts-player/posts-player-proxy.svelte +2 -1
  65. package/dist/posts/posts-player/posts-player-proxy.svelte.d.ts +3 -1
  66. package/dist/posts/posts-player/posts-player-view.svelte +127 -32
  67. package/dist/posts/posts-player/types.d.ts +8 -0
  68. package/dist/posts/sharing/index.d.ts +1 -0
  69. package/dist/posts/sharing/index.js +1 -0
  70. package/dist/posts/sharing/types.d.ts +5 -0
  71. package/dist/posts/sharing/types.js +1 -0
  72. package/dist/posts/social-interactions/types.d.ts +0 -1
  73. package/dist/streams/controls/index.d.ts +1 -0
  74. package/dist/streams/controls/index.js +1 -0
  75. package/dist/streams/controls/stream-actions-generator.svelte.d.ts +31 -0
  76. package/dist/streams/controls/stream-actions-generator.svelte.js +42 -0
  77. package/dist/streams/index.d.ts +1 -0
  78. package/dist/streams/index.js +1 -0
  79. package/dist/streams/layout/cmp.layout.svelte +4 -1
  80. package/dist/streams/layout/cmp.layout.svelte.d.ts +1 -0
  81. package/dist/streams/layout/element-views/cmp.short-video-stream-element.svelte +1 -0
  82. package/dist/streams/layout/models/mapper.js +1 -0
  83. package/dist/streams/sharing/index.d.ts +1 -0
  84. package/dist/streams/sharing/index.js +1 -0
  85. package/dist/streams/sharing/types.d.ts +5 -0
  86. package/dist/streams/sharing/types.js +1 -0
  87. package/dist/streams/stream-page-viewer/cmp.stream-page-viewer.svelte +43 -1
  88. package/dist/streams/stream-page-viewer/cmp.stream-page-viewer.svelte.d.ts +9 -0
  89. package/dist/streams/streams-player/cmp.streams-player.svelte +2 -1
  90. package/dist/streams/streams-player/cmp.streams-player.svelte.d.ts +2 -0
  91. package/dist/streams/streams-player/index.d.ts +2 -0
  92. package/dist/streams/streams-player/index.js +2 -1
  93. package/dist/streams/streams-player/streams-player-proxy.svelte +2 -1
  94. package/dist/streams/streams-player/streams-player-proxy.svelte.d.ts +2 -0
  95. package/dist/streams/streams-player/streams-player-view.svelte +147 -34
  96. package/dist/streams/streams-player/types.d.ts +7 -0
  97. package/dist/ui/card-actions/card-action-container.d.ts +2 -0
  98. package/dist/ui/card-actions/card-action-container.js +17 -0
  99. package/dist/ui/card-actions/cmp.card-action.svelte +28 -0
  100. package/dist/ui/card-actions/cmp.card-action.svelte.d.ts +10 -0
  101. package/dist/ui/card-actions/cmp.card-actions.svelte +71 -0
  102. package/dist/ui/card-actions/cmp.card-actions.svelte.d.ts +9 -0
  103. package/dist/ui/card-actions/index.d.ts +4 -0
  104. package/dist/ui/card-actions/index.js +3 -0
  105. package/dist/ui/card-actions/types.d.ts +9 -0
  106. package/dist/ui/card-actions/types.js +1 -0
  107. package/dist/ui/player/button/cmp.responsive-player-buttons-group.svelte +53 -0
  108. package/dist/ui/player/button/cmp.responsive-player-buttons-group.svelte.d.ts +10 -0
  109. package/dist/ui/player/button/index.d.ts +1 -0
  110. package/dist/ui/player/button/index.js +1 -0
  111. package/dist/{content-player → ui/player/content-player}/cmp.content-player.svelte +7 -29
  112. package/dist/{content-player → ui/player/content-player}/cmp.content-player.svelte.d.ts +6 -1
  113. package/dist/ui/player/content-player/content-player-config.svelte.d.ts +29 -0
  114. package/dist/ui/player/content-player/content-player-config.svelte.js +27 -0
  115. package/dist/{content-player → ui/player/content-player}/content-player-settings.svelte.d.ts +3 -3
  116. package/dist/{content-player → ui/player/content-player}/content-player-settings.svelte.js +2 -2
  117. package/dist/{content-player → ui/player/content-player}/controls-and-attachments.svelte +18 -65
  118. package/dist/{content-player → ui/player/content-player}/controls-and-attachments.svelte.d.ts +6 -0
  119. package/dist/{content-player → ui/player/content-player}/overview-panel.svelte +1 -1
  120. package/dist/{content-player → ui/player/content-player}/ui-manager.svelte.d.ts +3 -2
  121. package/dist/{content-player → ui/player/content-player}/ui-manager.svelte.js +3 -2
  122. package/dist/ui/player/providers/chunks-player-buffer/player-chunk-item.svelte.d.ts +0 -2
  123. package/dist/ui/player/providers/chunks-player-buffer/player-chunk-item.svelte.js +1 -3
  124. package/dist/ui/player/providers/chunks-player-buffer/player-chunk.svelte.d.ts +3 -2
  125. package/dist/ui/player/providers/chunks-player-buffer/player-chunk.svelte.js +11 -5
  126. package/dist/ui/player/providers/chunks-player-buffer/player-chunks-manager.svelte.d.ts +3 -0
  127. package/dist/ui/player/providers/chunks-player-buffer/player-chunks-manager.svelte.js +74 -8
  128. package/dist/ui/player/providers/default-chunks-player-buffer.svelte.d.ts +2 -0
  129. package/dist/ui/player/providers/default-chunks-player-buffer.svelte.js +15 -4
  130. package/dist/ui/player/providers/default-feed-player-buffer.svelte.d.ts +1 -0
  131. package/dist/ui/player/providers/default-feed-player-buffer.svelte.js +27 -5
  132. package/dist/ui/player/providers/types.d.ts +1 -0
  133. package/dist/ui/shadow-dom/cmp.shadow-root.svelte +9 -4
  134. package/dist/ui/shadow-dom/colors.scss +2 -0
  135. package/package.json +6 -2
  136. package/dist/content-player/content-player-config.svelte.d.ts +0 -51
  137. package/dist/content-player/content-player-config.svelte.js +0 -48
  138. package/dist/posts/controls/cmp.controls.svelte +0 -120
  139. package/dist/posts/controls/cmp.controls.svelte.d.ts +0 -16
  140. /package/dist/{media-center/categories-following → external-api/data-providers/mocks}/mock-categories-following-handler.svelte.js +0 -0
  141. /package/dist/{media-center/membership → external-api/data-providers/mocks}/mock-membership-handler.svelte.js +0 -0
  142. /package/dist/{media-center/navigation → external-api/data-providers/mocks}/mock-navigation-handler.svelte.js +0 -0
  143. /package/dist/{content-player → ui/player/content-player}/index.d.ts +0 -0
  144. /package/dist/{content-player → ui/player/content-player}/index.js +0 -0
  145. /package/dist/{content-player → ui/player/content-player}/overview-panel.svelte.d.ts +0 -0
@@ -1,6 +1,7 @@
1
1
  import type { Locale } from '../../core/locale';
2
2
  import type { ThemeValue } from '../../core/theme';
3
3
  import type { IPostModel } from '..';
4
+ import type { IPostSharingHandler } from '../sharing';
4
5
  import type { IPostSocialInteractionsHandler } from '../social-interactions';
5
6
  import type { ICloseOrchestrator } from '../../ui/player/close-orchestrator';
6
7
  import type { PlayerColors } from '../../ui/player/colors';
@@ -26,7 +27,9 @@ export type PostsPlayerProps = {
26
27
  provider: IPlayerDataProvider<PostPlayerModel>;
27
28
  };
28
29
  socialInteractionsHandler?: IPostSocialInteractionsHandler;
30
+ sharingHandler?: IPostSharingHandler;
29
31
  analyticsHandler?: IPostAnalyticsHandler;
32
+ managementActions?: PostManagementActions;
30
33
  playerSettings?: PostPlayerSettings;
31
34
  closeOrchestrator: ICloseOrchestrator;
32
35
  on?: {
@@ -39,3 +42,8 @@ export type PostPlayerSettings = {
39
42
  showStreamsCloudWatermark?: boolean;
40
43
  playerColors?: Record<ThemeValue, PlayerColors>;
41
44
  };
45
+ export type PostManagementActions = {
46
+ editPost: ((id: string) => void) | null;
47
+ editArticle: ((id: string) => void) | null;
48
+ deletePost: ((id: string) => void) | null;
49
+ };
@@ -0,0 +1 @@
1
+ export type { IPostSharingHandler } from './types';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export interface IPostSharingHandler {
2
+ share: (postId: string) => PromiseLike<void>;
3
+ }
4
+ type PromiseLike<T> = T | Promise<T>;
5
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -3,7 +3,6 @@ export interface IPostSocialInteractionsHandler {
3
3
  readonly isLiked: boolean;
4
4
  }>;
5
5
  toggleLike: (postId: string) => PromiseLike<void>;
6
- share: (postId: string) => PromiseLike<void>;
7
6
  }
8
7
  type PromiseLike<T> = T | Promise<T>;
9
8
  export {};
@@ -0,0 +1 @@
1
+ export { StreamActionsGenerator } from './stream-actions-generator.svelte';
@@ -0,0 +1 @@
1
+ export { StreamActionsGenerator } from './stream-actions-generator.svelte';
@@ -0,0 +1,31 @@
1
+ import { PostActionsHandler } from '../../posts/controls';
2
+ import type { PostModel } from '../../posts/model';
3
+ import type { IPostSocialInteractionsHandler } from '../../posts/social-interactions';
4
+ import type { IStreamSharingHandler } from '../sharing';
5
+ export declare class StreamActionsGenerator {
6
+ private postSocialInteractionsHandler;
7
+ private sharingHandler;
8
+ private callbacks;
9
+ private handlers;
10
+ constructor(init: {
11
+ postSocialInteractionsHandler: IPostSocialInteractionsHandler | undefined;
12
+ sharingHandler: IStreamSharingHandler | undefined;
13
+ on: StreamActionCallbacks;
14
+ });
15
+ getPostActionsHandler: (data: {
16
+ model: PostModel;
17
+ streamId: string;
18
+ streamPageId: string;
19
+ }) => PostActionsHandler;
20
+ getGeneralStreamPageActions: (data: {
21
+ streamId: string;
22
+ streamPageId: string;
23
+ }) => {
24
+ icon: any;
25
+ callback: () => (void | Promise<void>) | undefined;
26
+ }[];
27
+ }
28
+ type StreamActionCallbacks = {
29
+ attachmentClicked: () => void;
30
+ };
31
+ export {};
@@ -0,0 +1,42 @@
1
+ import { PostActionsHandler } from '../../posts/controls';
2
+ import IconShare from '@fluentui/svg-icons/icons/share_48_regular.svg?raw';
3
+ export class StreamActionsGenerator {
4
+ postSocialInteractionsHandler;
5
+ sharingHandler;
6
+ callbacks;
7
+ handlers = new Map();
8
+ constructor(init) {
9
+ this.postSocialInteractionsHandler = init.postSocialInteractionsHandler ?? null;
10
+ this.sharingHandler = init.sharingHandler ?? null;
11
+ this.callbacks = init.on;
12
+ }
13
+ getPostActionsHandler = (data) => {
14
+ const { model, streamId, streamPageId } = data;
15
+ let handler = this.handlers.get(streamPageId);
16
+ if (!handler) {
17
+ handler = new PostActionsHandler({
18
+ post: model,
19
+ socialInteractionsHandler: this.postSocialInteractionsHandler,
20
+ callbacks: {
21
+ attachmentClicked: this.callbacks.attachmentClicked,
22
+ shareClicked: this.sharingHandler ? () => this.sharingHandler?.share(streamId) : undefined
23
+ }
24
+ });
25
+ this.handlers.set(streamPageId, handler);
26
+ }
27
+ return handler;
28
+ };
29
+ getGeneralStreamPageActions = (data) => {
30
+ if (!this.sharingHandler) {
31
+ return [];
32
+ }
33
+ const { streamId, streamPageId } = data;
34
+ void streamPageId;
35
+ return [
36
+ {
37
+ icon: IconShare,
38
+ callback: () => this.sharingHandler?.share(streamId)
39
+ }
40
+ ];
41
+ };
42
+ }
@@ -0,0 +1 @@
1
+ export type { IStreamSharingHandler } from './sharing';
@@ -0,0 +1 @@
1
+ export {};
@@ -1,11 +1,14 @@
1
1
  <script lang="ts">import { ProportionalContainer } from '../../ui/proportional-container';
2
2
  import { generateStreamLayoutStyles } from './styles-transformer';
3
- let { model, children } = $props();
3
+ let { model, children, controls } = $props();
4
4
  </script>
5
5
 
6
6
  <ProportionalContainer ratio={9 / 16}>
7
7
  <div class="stream-page-layout" style={generateStreamLayoutStyles(model.styles)}>
8
8
  {@render children()}
9
+ {#if controls}
10
+ {@render controls()}
11
+ {/if}
9
12
  </div>
10
13
  </ProportionalContainer>
11
14
 
@@ -5,6 +5,7 @@ type Props = {
5
5
  styles: StreamLayoutStyles | null;
6
6
  };
7
7
  children: Snippet;
8
+ controls?: Snippet;
8
9
  };
9
10
  declare const Cmp: import("svelte").Component<Props, {}, "">;
10
11
  type Cmp = ReturnType<typeof Cmp>;
@@ -12,5 +12,6 @@ const localization = $derived(new ShortVideoStreamElementLocalization(locale));
12
12
  trackingParams={trackingParams ? { streamId: trackingParams.streamId, campaignId: trackingParams.campaignId } : false}
13
13
  autoplay={false}
14
14
  enableControls={false}
15
+ controlActions={[]}
15
16
  locale={localization.shortVideoViewerLocale}
16
17
  on={on} />
@@ -22,6 +22,7 @@ export const mapToPostModel = (model) => {
22
22
  viewsCount: model.header.postViewsCount
23
23
  },
24
24
  enableSocialInteractions: model.enableSocialInteractions,
25
+ articleId: null,
25
26
  ads: model.ad ? [mapToAdViewModel(model.ad)] : [],
26
27
  products: model.products.map(mapToProductCardModel)
27
28
  // uncomment if you want to test many products behavior
@@ -0,0 +1 @@
1
+ export type { IStreamSharingHandler } from './types';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export interface IStreamSharingHandler {
2
+ share: (streamId: string) => PromiseLike<void>;
3
+ }
4
+ type PromiseLike<T> = T | Promise<T>;
5
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">import { StreamLayoutSlot, StreamPageLayout, StreamLayoutSlotContent } from '../layout';
2
+ import { ResponsivePlayerButtonsGroup } from '../../ui/player/button';
2
3
  import { StreamPageViewerLocalization } from './stream-page-viewer-localization';
3
- let { page, trackingParams, locale, on } = $props();
4
+ let { page, trackingParams, overlayControls, locale, on } = $props();
4
5
  const localization = $derived(new StreamPageViewerLocalization(locale));
5
6
  </script>
6
7
 
@@ -11,5 +12,46 @@ const localization = $derived(new StreamPageViewerLocalization(locale));
11
12
  <StreamLayoutSlotContent model={slot} trackingParams={trackingParams} on={on} locale={localization.elementsLocale} />
12
13
  </StreamLayoutSlot>
13
14
  {/each}
15
+ {#snippet controls()}
16
+ {#if overlayControls?.enabled && overlayControls.actions.length}
17
+ <div class="controls-panel">
18
+ <ResponsivePlayerButtonsGroup
19
+ actions={overlayControls.actions}
20
+ activeColor={overlayControls.colors?.active ?? null}
21
+ backgroundColor={overlayControls.colors?.inactive ?? null}
22
+ scaleEffect={true} />
23
+ </div>
24
+ {/if}
25
+ {/snippet}
14
26
  </StreamPageLayout>
15
27
  {/if}
28
+
29
+ <style>@keyframes fadeIn {
30
+ 0% {
31
+ opacity: 1;
32
+ }
33
+ 50% {
34
+ opacity: 0.4;
35
+ }
36
+ 100% {
37
+ opacity: 1;
38
+ }
39
+ }
40
+ .controls-panel {
41
+ position: absolute;
42
+ left: auto;
43
+ right: 0;
44
+ bottom: 6.25rem;
45
+ gap: 2.5rem;
46
+ display: flex;
47
+ flex-direction: column;
48
+ justify-content: flex-end;
49
+ align-items: flex-end;
50
+ padding: 0 0.625rem;
51
+ /* Set 'container-type: inline-size;' to reference container*/
52
+ }
53
+ @container (width < 576px) {
54
+ .controls-panel {
55
+ padding-right: 0;
56
+ }
57
+ }</style>
@@ -1,10 +1,19 @@
1
1
  import type { Locale } from '../../core/locale';
2
2
  import { type StreamTrackingParams } from '../layout';
3
+ import { type PlayerButtonDef } from '../../ui/player/button';
3
4
  import type { StreamPageViewerModel } from './types';
4
5
  type Props = {
5
6
  page: StreamPageViewerModel;
6
7
  trackingParams: StreamTrackingParams;
7
8
  locale: Locale;
9
+ overlayControls?: {
10
+ enabled: boolean;
11
+ colors: {
12
+ active: string | null;
13
+ inactive: string | null;
14
+ } | null;
15
+ actions: PlayerButtonDef[];
16
+ };
8
17
  on?: {
9
18
  productClick: (productId: string) => void;
10
19
  productImpression?: (productId: string) => void;
@@ -11,7 +11,7 @@ import { CloseOrchestrator } from '../../ui/player/close-orchestrator';
11
11
  import { createShadowRoot } from '../../ui/shadow-dom';
12
12
  import { default as StreamsPlayerProxy } from './streams-player-proxy.svelte';
13
13
  import { mount, unmount } from 'svelte';
14
- let { dataProvider, postSocialInteractionsHandler, amplificationParameters, playerSettings, analyticsHandler, on } = $props();
14
+ let { dataProvider, postSocialInteractionsHandler, sharingHandler, amplificationParameters, playerSettings, analyticsHandler, on } = $props();
15
15
  const initHost = (node) => {
16
16
  const shadowRoot = createShadowRoot(node);
17
17
  const mounted = mount(StreamsPlayerProxy, {
@@ -19,6 +19,7 @@ const initHost = (node) => {
19
19
  props: {
20
20
  dataProvider,
21
21
  postSocialInteractionsHandler,
22
+ sharingHandler,
22
23
  analyticsHandler,
23
24
  amplificationParameters,
24
25
  playerSettings,
@@ -1,9 +1,11 @@
1
1
  import type { Locale } from '../../core/locale';
2
2
  import type { IPostSocialInteractionsHandler } from '../../posts';
3
+ import type { IStreamSharingHandler } from '../sharing';
3
4
  import type { IStreamAnalyticsHandler, IStreamsPlayerDataProvider, StreamAmplificationParameters } from './types';
4
5
  type Props = {
5
6
  dataProvider: IStreamsPlayerDataProvider;
6
7
  postSocialInteractionsHandler?: IPostSocialInteractionsHandler;
8
+ sharingHandler?: IStreamSharingHandler;
7
9
  analyticsHandler?: IStreamAnalyticsHandler;
8
10
  amplificationParameters?: StreamAmplificationParameters;
9
11
  playerSettings?: {
@@ -1,6 +1,7 @@
1
1
  import type { Locale } from '../../core/locale';
2
2
  import { type IMediaCenterDataProvider } from '../../media-center/config/types';
3
3
  import type { IPostSocialInteractionsHandler } from '../../posts/social-interactions';
4
+ import type { IStreamSharingHandler } from '../sharing';
4
5
  import type { StreamPageViewerModel } from '../stream-page-viewer/types';
5
6
  import type { IStreamAnalyticsHandler, IStreamsPlayerDataProvider, StreamAmplificationParameters, StreamPlayerModel } from './types';
6
7
  export { type StreamPlayerModel, type StreamPageViewerModel };
@@ -75,6 +76,7 @@ export type { IStreamsPlayerDataProvider, IStreamAnalyticsHandler, IMediaCenterD
75
76
  export declare function openStreamsPlayer(init: {
76
77
  dataProvider: IStreamsPlayerDataProvider;
77
78
  postSocialInteractionsHandler?: IPostSocialInteractionsHandler;
79
+ sharingHandler?: IStreamSharingHandler;
78
80
  analyticsHandler?: IStreamAnalyticsHandler;
79
81
  amplificationParameters?: StreamAmplificationParameters;
80
82
  playerSettings?: StreamsPlayerSettings;
@@ -72,7 +72,7 @@ export {};
72
72
  * ```
73
73
  */
74
74
  export function openStreamsPlayer(init) {
75
- const { dataProvider, analyticsHandler, postSocialInteractionsHandler, amplificationParameters, playerSettings, on } = init;
75
+ const { dataProvider, analyticsHandler, postSocialInteractionsHandler, sharingHandler, amplificationParameters, playerSettings, on } = init;
76
76
  const shadowHost = new ModalShadowHost();
77
77
  let mounted = null;
78
78
  const makeCloseOrchestrator = () => new CloseOrchestrator({
@@ -93,6 +93,7 @@ export function openStreamsPlayer(init) {
93
93
  amplificationParameters,
94
94
  playerSettings,
95
95
  postSocialInteractionsHandler,
96
+ sharingHandler,
96
97
  closeOrchestrator: makeCloseOrchestrator(),
97
98
  on: {
98
99
  streamActivated: (data) => {
@@ -3,7 +3,7 @@ import {} from '../../ui/player/close-orchestrator';
3
3
  import { ShadowRoot } from '../../ui/shadow-dom';
4
4
  import { default as StreamsPlayerView } from './streams-player-view.svelte';
5
5
  import { untrack } from 'svelte';
6
- let { dataProvider, postSocialInteractionsHandler, amplificationParameters, closeOrchestrator, playerSettings, analyticsHandler, on } = $props();
6
+ let { dataProvider, postSocialInteractionsHandler, sharingHandler, amplificationParameters, closeOrchestrator, playerSettings, analyticsHandler, on } = $props();
7
7
  let backgroundImageUrl = $state(null);
8
8
  const handleBackgroundImagedLoaded = (url) => {
9
9
  backgroundImageUrl = url;
@@ -21,6 +21,7 @@ $effect(() => {
21
21
  <StreamsPlayerView
22
22
  dataProvider={{ type: 'provider', provider: dataProvider }}
23
23
  postSocialInteractionsHandler={postSocialInteractionsHandler}
24
+ sharingHandler={sharingHandler}
24
25
  analyticsHandler={analyticsHandler}
25
26
  amplificationParameters={amplificationParameters}
26
27
  playerSettings={playerSettings}
@@ -1,10 +1,12 @@
1
1
  import type { Locale } from '../../core/locale';
2
2
  import type { IPostSocialInteractionsHandler } from '../../posts/social-interactions';
3
+ import type { IStreamSharingHandler } from '../sharing';
3
4
  import { type ICloseOrchestrator } from '../../ui/player/close-orchestrator';
4
5
  import type { IStreamsPlayerDataProvider, IStreamAnalyticsHandler, StreamAmplificationParameters } from './types';
5
6
  type Props = {
6
7
  dataProvider: IStreamsPlayerDataProvider;
7
8
  postSocialInteractionsHandler?: IPostSocialInteractionsHandler;
9
+ sharingHandler?: IStreamSharingHandler;
8
10
  analyticsHandler?: IStreamAnalyticsHandler;
9
11
  amplificationParameters?: StreamAmplificationParameters;
10
12
  closeOrchestrator: ICloseOrchestrator;
@@ -8,18 +8,25 @@
8
8
  });
9
9
  };
10
10
  var _a;
11
- import { ContentPlayer, ContentPlayerConfig } from '../../content-player';
12
- import { ContentPlayerSettings } from '../../content-player/content-player-settings.svelte';
13
11
  import { preloadImage } from '../../core/image-preloader';
12
+ import { PostAttachments } from '../../posts/attachments';
13
+ import { PostModel } from '../../posts/model';
14
+ import { PostViewer } from '../../posts/post-viewer';
15
+ import { StreamActionsGenerator } from '../controls';
14
16
  import { mapToPostModel } from '../layout/models';
15
17
  import { StreamPageViewer } from '../stream-page-viewer';
18
+ import { IconColor } from '../../ui/icon';
19
+ import { ContentPlayer, ContentPlayerConfig, ContentPlayerSettings } from '../../ui/player/content-player';
16
20
  import { default as Overview } from './stream-overview.svelte';
17
21
  import { StreamPlayerLocalization } from './stream-player-localization';
18
22
  import { StreamsPlayerBuffer } from './streams-player-buffer.svelte';
23
+ import IconDelete from '@fluentui/svg-icons/icons/delete_32_regular.svg?raw';
24
+ import IconEdit from '@fluentui/svg-icons/icons/edit_32_regular.svg?raw';
19
25
  import { untrack } from 'svelte';
20
- let { dataProvider, analyticsHandler, postSocialInteractionsHandler, amplificationParameters, playerSettings, closeOrchestrator, on } = $props();
26
+ let { dataProvider, analyticsHandler, postSocialInteractionsHandler, sharingHandler, amplificationParameters, managementActions, playerSettings, closeOrchestrator, on } = $props();
21
27
  const localization = $derived(new StreamPlayerLocalization((_a = playerSettings === null || playerSettings === void 0 ? void 0 : playerSettings.locale) !== null && _a !== void 0 ? _a : 'en'));
22
28
  let currentStreamModel = $state(null);
29
+ let mappedPostsCache = new Map();
23
30
  let activePageId = $derived.by(() => { var _a, _b; return (_b = (_a = buffer === null || buffer === void 0 ? void 0 : buffer.current) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : ''; });
24
31
  let buffer = $state(null);
25
32
  let totalEngagementTimeSeconds = 0;
@@ -33,6 +40,7 @@ $effect(() => {
33
40
  untrack(() => {
34
41
  buffer = null;
35
42
  contentPlayerConfig.playerBuffer = null;
43
+ mappedPostsCache = new Map();
36
44
  initPlayerBuffer(dataProvider);
37
45
  });
38
46
  return () => { };
@@ -97,36 +105,8 @@ const initPlayerBuffer = (dataProvider) => __awaiter(void 0, void 0, void 0, fun
97
105
  });
98
106
  const contentPlayerConfig = new ContentPlayerConfig({
99
107
  playerBuffer: null,
100
- mappers: {
101
- postModelFromCurrentItem: (item) => {
102
- if (item.type === 'short-video' && item.shortVideo) {
103
- return mapToPostModel(item.shortVideo);
104
- }
105
- return null;
106
- }
107
- },
108
- socialInteractionsHandler: postSocialInteractionsHandler,
109
108
  settings: new ContentPlayerSettings(playerSettings),
110
109
  closeOrchestrator,
111
- callbacks: {
112
- videoProgress: (pageId, videoId, progress) => {
113
- onProgress(pageId, videoId, progress);
114
- },
115
- productClick: (id, videoId) => {
116
- analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackShortVideoProductClick(id, videoId);
117
- onStreamProductClick(id);
118
- },
119
- productImpression: (id, videoId) => {
120
- analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackShortVideoProductImpression(id, videoId);
121
- onStreamProductImpression(id);
122
- },
123
- adClick: (id) => {
124
- analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackAdClick(id);
125
- },
126
- adImpression: (id) => {
127
- analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackAdImpression(id);
128
- }
129
- },
130
110
  playerSliderCallbacks: {
131
111
  itemActivated: (item) => onPageActivated(item),
132
112
  itemDeactivated: (itemId) => executeWithStreamId((streamId) => {
@@ -134,6 +114,22 @@ const contentPlayerConfig = new ContentPlayerConfig({
134
114
  })
135
115
  }
136
116
  });
117
+ const streamActionsGenerator = new StreamActionsGenerator({
118
+ postSocialInteractionsHandler,
119
+ sharingHandler,
120
+ on: { attachmentClicked: () => (contentPlayerConfig.uiManager.attachmentsCollapsed = !contentPlayerConfig.uiManager.attachmentsCollapsed) }
121
+ });
122
+ const itemAsPostModel = (item) => {
123
+ if (item.type !== 'short-video' || !item.shortVideo) {
124
+ return null;
125
+ }
126
+ if (mappedPostsCache.has(item.shortVideo.id)) {
127
+ return mappedPostsCache.get(item.shortVideo.id);
128
+ }
129
+ const postModel = new PostModel(mapToPostModel(item.shortVideo));
130
+ mappedPostsCache.set(item.shortVideo.id, postModel);
131
+ return postModel;
132
+ };
137
133
  const handleChangePage = (index) => {
138
134
  if (!buffer) {
139
135
  return;
@@ -160,6 +156,23 @@ const onPageActivated = (id) => {
160
156
  }
161
157
  }
162
158
  };
159
+ const onShortVideoProgress = (pageId, videoId, progress) => {
160
+ onProgress(pageId, videoId, progress);
161
+ };
162
+ const onShortVideoProductClick = (id, videoId) => {
163
+ analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackShortVideoProductClick(id, videoId);
164
+ onStreamProductClick(id);
165
+ };
166
+ const onShortVideoProductImpression = (id, videoId) => {
167
+ analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackShortVideoProductImpression(id, videoId);
168
+ onStreamProductImpression(id);
169
+ };
170
+ const onShortVideoAdClick = (id) => {
171
+ analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackAdClick(id);
172
+ };
173
+ const onShortVideoAdImpression = (id) => {
174
+ analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackAdImpression(id);
175
+ };
163
176
  const onStreamProductClick = (productId) => {
164
177
  executeWithStreamId((streamId) => {
165
178
  analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackStreamProductClicked(productId, streamId);
@@ -181,6 +194,45 @@ const executeWithStreamId = (action) => {
181
194
  }
182
195
  action(currentStreamModel.id);
183
196
  };
197
+ const currentItemActions = $derived.by(() => {
198
+ if (!(buffer === null || buffer === void 0 ? void 0 : buffer.current) || !buffer.activeChunk) {
199
+ return [];
200
+ }
201
+ const result = [];
202
+ if (buffer.current.type === 'general') {
203
+ result.push(...streamActionsGenerator.getGeneralStreamPageActions({
204
+ streamId: buffer.activeChunk.model.id,
205
+ streamPageId: buffer.current.id
206
+ }));
207
+ }
208
+ else {
209
+ const postModel = itemAsPostModel(buffer.current);
210
+ const handler = streamActionsGenerator.getPostActionsHandler({
211
+ model: postModel,
212
+ streamId: buffer.activeChunk.model.id,
213
+ streamPageId: buffer.current.id
214
+ });
215
+ result.push(...handler.actions);
216
+ }
217
+ if (managementActions === null || managementActions === void 0 ? void 0 : managementActions.editStream) {
218
+ result.push({
219
+ icon: IconEdit,
220
+ callback: () => __awaiter(void 0, void 0, void 0, function* () {
221
+ yield managementActions.editStream(buffer.activeChunk.model.id);
222
+ })
223
+ });
224
+ }
225
+ if (managementActions === null || managementActions === void 0 ? void 0 : managementActions.deleteStreamPage) {
226
+ result.push({
227
+ icon: IconDelete,
228
+ iconColor: IconColor.Red,
229
+ callback: () => __awaiter(void 0, void 0, void 0, function* () {
230
+ yield managementActions.deleteStreamPage(buffer.current.id);
231
+ })
232
+ });
233
+ }
234
+ return result;
235
+ });
184
236
  //#region Activity Tracking
185
237
  const resetInactivityTimer = () => {
186
238
  if (!isActive) {
@@ -225,22 +277,83 @@ const stopActivityTracking = () => {
225
277
  //#edregion Activity Tracking
226
278
  </script>
227
279
 
228
- <ContentPlayer config={contentPlayerConfig}>
229
- {#snippet nonPostItemView({ item })}
280
+ {#snippet attachmentsView(data: { item: StreamPageViewerModel })}
281
+ {@const postModel = itemAsPostModel(data.item)}
282
+ {#if postModel}
283
+ <PostAttachments
284
+ model={postModel}
285
+ colors={{
286
+ background: contentPlayerConfig.playerColors.cardBackground,
287
+ price: contentPlayerConfig.playerColors.price,
288
+ salePrice: contentPlayerConfig.playerColors.salePrice,
289
+ buttonBackground: contentPlayerConfig.playerColors.cardButton
290
+ }}
291
+ trackingParams={contentPlayerConfig.trackingParams}
292
+ locale={contentPlayerConfig.settings.locale}
293
+ on={{
294
+ productClick: (id) => onShortVideoProductClick(id, postModel.id),
295
+ productImpression: (id) => onShortVideoProductImpression(id, postModel.id),
296
+ adClick: (id) => onShortVideoAdClick(id),
297
+ adImpression: (id) => onShortVideoAdImpression(id)
298
+ }} />
299
+ {/if}
300
+ {/snippet}
301
+ <ContentPlayer
302
+ config={contentPlayerConfig}
303
+ itemActions={currentItemActions}
304
+ attachmentsView={buffer?.current && itemAsPostModel(buffer.current)?.attachments ? attachmentsView : undefined}>
305
+ {#snippet itemView({ item })}
230
306
  {#if item.type === 'general'}
231
307
  <StreamPageViewer
232
308
  page={item}
233
309
  trackingParams={streamTrackingParams}
234
310
  locale={localization.locale}
311
+ overlayControls={{
312
+ enabled: contentPlayerConfig.uiManager.showControlsOverlay,
313
+ colors: {
314
+ active: contentPlayerConfig.playerColors.button,
315
+ inactive: contentPlayerConfig.playerColors.buttonInactive
316
+ },
317
+ actions: buffer?.activeChunk
318
+ ? streamActionsGenerator.getGeneralStreamPageActions({ streamId: buffer.activeChunk.model.id, streamPageId: item.id })
319
+ : []
320
+ }}
235
321
  on={{
236
322
  progress: (videoId, progress) => onProgress(item.id, videoId, progress),
237
323
  productClick: (productId) => onStreamProductClick(productId),
238
324
  productImpression: (productId) => onStreamProductImpression(productId)
239
325
  }} />
326
+ {:else}
327
+ {@const postModel = itemAsPostModel(item)}
328
+ {#if postModel}
329
+ {@const handler = buffer?.activeChunk
330
+ ? streamActionsGenerator.getPostActionsHandler({
331
+ model: postModel,
332
+ streamId: buffer.activeChunk.model.id,
333
+ streamPageId: item.id
334
+ })
335
+ : null}
336
+ <PostViewer
337
+ model={postModel}
338
+ controlsColors={{ active: contentPlayerConfig.playerColors.button, inactive: contentPlayerConfig.playerColors.buttonInactive }}
339
+ trackingParams={contentPlayerConfig.trackingParams}
340
+ enableAttachments={contentPlayerConfig.uiManager.showAttachmentsOverlay}
341
+ enableControls={contentPlayerConfig.uiManager.showControlsOverlay}
342
+ controlActions={handler?.actions ?? []}
343
+ autoplay="on-appearance"
344
+ locale={contentPlayerConfig.settings.locale}
345
+ on={{
346
+ progress: (progress) => onShortVideoProgress(item.id, postModel.id, progress),
347
+ productClick: (productId) => onShortVideoProductClick(productId, postModel.id),
348
+ productImpression: (productId) => onShortVideoProductImpression(productId, postModel.id),
349
+ adClick: (adId) => onShortVideoAdClick(adId),
350
+ adImpression: (adId) => onShortVideoAdImpression(adId)
351
+ }} />
352
+ {/if}
240
353
  {/if}
241
354
  {/snippet}
242
355
  {#snippet overviewPanelContent()}
243
- {#if contentPlayerConfig.playerBuffer && buffer && currentStreamModel}
356
+ {#if buffer}
244
357
  <Overview
245
358
  buffer={buffer}
246
359
  activePageId={activePageId}
@@ -1,6 +1,7 @@
1
1
  import type { Locale } from '../../core/locale';
2
2
  import type { ThemeValue } from '../../core/theme';
3
3
  import type { IPostSocialInteractionsHandler } from '../../posts/social-interactions';
4
+ import type { IStreamSharingHandler } from '../sharing';
4
5
  import type { StreamPageViewerModel } from '../stream-page-viewer';
5
6
  import type { ICloseOrchestrator } from '../../ui/player/close-orchestrator';
6
7
  import type { PlayerColors } from '../../ui/player/colors';
@@ -24,8 +25,10 @@ export type StreamsPlayerProps = {
24
25
  provider: IStreamsPlayerDataProvider;
25
26
  };
26
27
  postSocialInteractionsHandler?: IPostSocialInteractionsHandler;
28
+ sharingHandler?: IStreamSharingHandler;
27
29
  analyticsHandler?: IStreamAnalyticsHandler;
28
30
  amplificationParameters?: StreamAmplificationParameters;
31
+ managementActions?: StreamManagementActions;
29
32
  playerSettings?: StreamsPlayerSettings;
30
33
  closeOrchestrator: ICloseOrchestrator;
31
34
  on?: {
@@ -51,6 +54,10 @@ export type StreamAmplificationParameters = {
51
54
  campaignName: string;
52
55
  source: string;
53
56
  };
57
+ export type StreamManagementActions = {
58
+ editStream: ((id: string) => void) | null;
59
+ deleteStreamPage: ((pageId: string) => void) | null;
60
+ };
54
61
  export interface IStreamsPlayerDataProvider {
55
62
  initialData: {
56
63
  prefetchedStreams: StreamPlayerModel[];
@@ -0,0 +1,2 @@
1
+ import type { Action } from 'svelte/action';
2
+ export declare const cardActionContainer: Action;