@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
@@ -0,0 +1,26 @@
1
+ import { ContinuationToken } from '../../core/continuation-token';
2
+ import { CursorDataLoader } from '../../core/data-loaders';
3
+ export const makeShortVideosProvider = (data) => {
4
+ const { dataProvider, categoryId, prefetchedItems = [] } = data;
5
+ const loader = new CursorDataLoader({
6
+ loadPage: async (continuationToken) => {
7
+ const result = await dataProvider.getShortVideosCursor({
8
+ filter: { categoryId, excludeIds: prefetchedItems.length ? prefetchedItems.map((i) => i.id) : undefined },
9
+ continuationToken: continuationToken.toRawFormat(),
10
+ limit: 20
11
+ });
12
+ const items = result.items;
13
+ return {
14
+ items: items,
15
+ continuationToken: ContinuationToken.fromPayload(result.continuationToken)
16
+ };
17
+ }
18
+ });
19
+ return {
20
+ initialData: {
21
+ prefetchedItems,
22
+ startIndex: prefetchedItems.length ? 0 : -1
23
+ },
24
+ loadMore: loader.loadMore
25
+ };
26
+ };
@@ -0,0 +1,10 @@
1
+ import type { ProductCardModel } from '../../products/product-card';
2
+ import type { ShortVideoViewerModel } from '../../short-videos/short-video-viewer';
3
+ export declare enum MediaCenterMode {
4
+ ShortVideos = "short-videos",
5
+ Stream = "stream"
6
+ }
7
+ export type OverviewData = {
8
+ shortVideos: ShortVideoViewerModel[];
9
+ products: ProductCardModel[];
10
+ };
@@ -0,0 +1,5 @@
1
+ export var MediaCenterMode;
2
+ (function (MediaCenterMode) {
3
+ MediaCenterMode["ShortVideos"] = "short-videos";
4
+ MediaCenterMode["Stream"] = "stream";
5
+ })(MediaCenterMode || (MediaCenterMode = {}));
@@ -7,14 +7,14 @@ let { product, includeBeforeNowPrefix, inert = false, localization: localization
7
7
  const localization = $derived(new ProductCardLocalization(localizationInit));
8
8
  const showDescriptionPresented = $derived(product.shortDescription && product.shortDescription.length > 0);
9
9
  const onProductClicked = (event) => {
10
- if (!product.link) {
11
- return;
12
- }
13
10
  event.preventDefault();
14
11
  event.stopPropagation();
15
12
  if (on === null || on === void 0 ? void 0 : on.productClick) {
16
13
  on.productClick(product.id);
17
14
  }
15
+ if (!product.link) {
16
+ return;
17
+ }
18
18
  window.open(product.link, '_blank', 'noopener noreferrer');
19
19
  };
20
20
  </script>
@@ -49,7 +49,7 @@ const onProductClicked = (event) => {
49
49
  </div>
50
50
  </div>
51
51
 
52
- {#if product.link}
52
+ {#if product.link || on?.productClick}
53
53
  <a href={product.link} onclick={onProductClicked} target="_blank" rel="noopener noreferrer" class="product-card__link" aria-label="none">&nbsp;</a>
54
54
  {/if}
55
55
  </div>
@@ -66,6 +66,8 @@ const onProductClicked = (event) => {
66
66
  }
67
67
  }
68
68
  .product-card {
69
+ --_product-card--aspect-ratio: var(--product-card--aspect-ratio, 10/16);
70
+ --_product-card--border-radius: var(--product-card--border-radius, 0.5rem);
69
71
  --image--border-radius: 0.25rem;
70
72
  --image--object-fit: fit;
71
73
  --image--width: auto;
@@ -76,11 +78,11 @@ const onProductClicked = (event) => {
76
78
  flex-direction: column;
77
79
  position: relative;
78
80
  container-type: inline-size;
79
- aspect-ratio: 10/16;
81
+ aspect-ratio: var(--_product-card--aspect-ratio);
80
82
  color: #000000;
81
83
  background-color: rgba(255, 255, 255, 0.9);
82
84
  border: 0.038125rem solid #f2f2f3;
83
- border-radius: 0.5rem;
85
+ border-radius: var(--_product-card--border-radius);
84
86
  padding: 0.75rem 0.75rem 1.125rem;
85
87
  justify-content: space-between;
86
88
  /* Set 'container-type: inline-size;' to reference container*/
@@ -144,6 +146,9 @@ const onProductClicked = (event) => {
144
146
  min-height: 1.375rem;
145
147
  /* Set 'container-type: inline-size;' to reference container*/
146
148
  }
149
+ :global([data-theme="dark"]) .product-card__description {
150
+ color: #d1d5db;
151
+ }
147
152
  @container (width < 230px) {
148
153
  .product-card__description {
149
154
  font-size: 0.625rem;
@@ -1,8 +1,8 @@
1
1
  import { getMediaItemImageUrl } from '../../core/media';
2
2
  import { shouldUseSalePrice } from '../price-helper';
3
3
  export const mapToProductCard = (payload, referenceDate) => {
4
- const effectiveSalePrice = payload.priceAndAvailability?.productSalePrices?.find((x) => shouldUseSalePrice({
5
- price: payload.priceAndAvailability?.price,
4
+ const effectiveSalePrice = payload.priceAndAvailability.productSalePrices?.find((x) => shouldUseSalePrice({
5
+ price: payload.priceAndAvailability.price,
6
6
  salePrice: x.salePrice,
7
7
  effectiveDateFrom: x.salePriceEffectiveDateFrom,
8
8
  effectiveDateTo: x.salePriceEffectiveDateTo,
@@ -14,7 +14,7 @@ export const mapToProductCard = (payload, referenceDate) => {
14
14
  shortDescription: payload.shortDescription,
15
15
  link: payload.link,
16
16
  brandName: payload.brand?.name || null,
17
- image: getMediaItemImageUrl(payload.media?.[0]),
17
+ image: payload.media.length ? getMediaItemImageUrl(payload.media[0]) : null,
18
18
  currency: payload.priceAndAvailability.currency,
19
19
  price: payload.priceAndAvailability.price,
20
20
  salePrice: effectiveSalePrice?.salePrice ?? null
@@ -0,0 +1,118 @@
1
+ <script lang="ts">import { Icon } from '../../ui/icon';
2
+ import { ImageRounded } from '../../ui/image';
3
+ import { LineClamp } from '../../ui/line-clamp';
4
+ import { ProportionalContainer } from '../../ui/proportional-container';
5
+ import IconPhone from '@fluentui/svg-icons/icons/phone_20_regular.svg?raw';
6
+ let { shortVideo, aspectRatio = 9 / 16, on } = $props();
7
+ </script>
8
+
9
+ <div class="short-video-card">
10
+ <div class="short-video-card__media">
11
+ <ProportionalContainer ratio={aspectRatio}>
12
+ <ImageRounded src={shortVideo.cover} alt="" noBorders={true} />
13
+ </ProportionalContainer>
14
+
15
+ <div class="short-video-card__media-icons">
16
+ <Icon src={IconPhone}></Icon>
17
+ </div>
18
+
19
+ <div class="short-video-card__gradient-overlay"></div>
20
+ </div>
21
+
22
+ {#if shortVideo.text}
23
+ <div class="short-video-card__text">
24
+ <div class="short-video-card__text-value">
25
+ <LineClamp value={shortVideo.text} maxLines={2} enableShowMore={false} />
26
+ </div>
27
+ </div>
28
+ {/if}
29
+
30
+ {#if on?.click}
31
+ <button type="button" onclick={on.click} class="short-video-card__link" aria-label="none">&nbsp;</button>
32
+ {/if}
33
+ </div>
34
+
35
+ <style>@keyframes fadeIn {
36
+ 0% {
37
+ opacity: 1;
38
+ }
39
+ 50% {
40
+ opacity: 0.4;
41
+ }
42
+ 100% {
43
+ opacity: 1;
44
+ }
45
+ }
46
+ .short-video-card {
47
+ position: relative;
48
+ overflow: hidden;
49
+ container-type: inline-size;
50
+ width: 100%;
51
+ border-radius: 0.375rem;
52
+ }
53
+ .short-video-card__media {
54
+ display: flex;
55
+ align-items: center;
56
+ justify-content: center;
57
+ --image--rounded--outer--border-radius: 1%;
58
+ }
59
+ .short-video-card__gradient-overlay {
60
+ /* Set 'container-type: inline-size;' to reference container*/
61
+ }
62
+ @container (width < 350px) {
63
+ .short-video-card__gradient-overlay {
64
+ position: absolute;
65
+ bottom: 0;
66
+ left: 0;
67
+ right: 0;
68
+ height: 80px;
69
+ background: linear-gradient(0deg, #000000 0%, rgba(0, 0, 0, 0) 100%);
70
+ pointer-events: none;
71
+ }
72
+ }
73
+ .short-video-card__media-icons {
74
+ position: absolute;
75
+ top: 0.625em;
76
+ right: 0.625em;
77
+ display: flex;
78
+ align-items: center;
79
+ gap: 0.3125em;
80
+ --icon--size: 1.25em;
81
+ --icon--color: #ffffff;
82
+ }
83
+ .short-video-card__text {
84
+ font-weight: 500;
85
+ white-space: pre-line;
86
+ word-break: break-word;
87
+ display: -webkit-box;
88
+ overflow: hidden;
89
+ -webkit-box-orient: vertical;
90
+ line-clamp: 3;
91
+ -webkit-line-clamp: 3;
92
+ /* Set 'container-type: inline-size;' to reference container*/
93
+ }
94
+ .short-video-card__text-value {
95
+ font-size: 0.9375em;
96
+ line-height: 1.2;
97
+ }
98
+ @container (width < 350px) {
99
+ .short-video-card__text {
100
+ position: absolute;
101
+ bottom: 0;
102
+ left: 0;
103
+ right: 0;
104
+ background: linear-gradient(0deg, #000 0%, rgba(0, 0, 0, 0) 100%);
105
+ color: #ffffff;
106
+ font-size: 0.9375rem;
107
+ font-weight: 400;
108
+ padding: 0.78125rem 1rem;
109
+ padding-top: 2.5rem;
110
+ }
111
+ }
112
+ .short-video-card__link {
113
+ position: absolute;
114
+ top: 0;
115
+ left: 0;
116
+ width: 100%;
117
+ height: 100%;
118
+ }</style>
@@ -0,0 +1,11 @@
1
+ import type { ShortVideoCardModel } from './types';
2
+ type Props = {
3
+ shortVideo: ShortVideoCardModel;
4
+ aspectRatio?: number;
5
+ on?: {
6
+ click?: () => void;
7
+ };
8
+ };
9
+ declare const Cmp: import("svelte").Component<Props, {}, "">;
10
+ type Cmp = ReturnType<typeof Cmp>;
11
+ export default Cmp;
@@ -0,0 +1,2 @@
1
+ export { default as ShortVideoCard } from './cmp.short-video-card.svelte';
2
+ export type { ShortVideoCardModel } from './types';
@@ -0,0 +1 @@
1
+ export { default as ShortVideoCard } from './cmp.short-video-card.svelte';
@@ -0,0 +1,5 @@
1
+ export type ShortVideoCardModel = {
2
+ id: string;
3
+ text: string | null;
4
+ cover: string;
5
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -49,19 +49,19 @@ const onLikeClicked = () => __awaiter(void 0, void 0, void 0, function* () {
49
49
  if (!socialInteractionsHandler) {
50
50
  return;
51
51
  }
52
- yield socialInteractionsHandler.onToggleLike(model.id);
52
+ yield socialInteractionsHandler.toggleLike(model.id);
53
53
  });
54
54
  const onShareClicked = () => __awaiter(void 0, void 0, void 0, function* () {
55
55
  if (!socialInteractionsHandler) {
56
56
  return;
57
57
  }
58
- yield socialInteractionsHandler.onShare(model.id);
58
+ yield socialInteractionsHandler.share(model.id);
59
59
  });
60
60
  const refreshIsLiked = () => __awaiter(void 0, void 0, void 0, function* () {
61
61
  if (!socialInteractionsHandler) {
62
62
  return;
63
63
  }
64
- isLikedStore = yield socialInteractionsHandler.isLiked(model.id);
64
+ isLikedStore = yield socialInteractionsHandler.getIsLiked(model.id);
65
65
  });
66
66
  </script>
67
67
 
@@ -1,4 +1,4 @@
1
- import type { ShortVideoSocialInteractionsHandler } from './types';
1
+ import type { IPostSocialInteractionsHandler } from './types';
2
2
  type Props = {
3
3
  model: {
4
4
  id: string;
@@ -9,7 +9,7 @@ type Props = {
9
9
  isImage: boolean;
10
10
  };
11
11
  };
12
- socialInteractionsHandler?: ShortVideoSocialInteractionsHandler;
12
+ socialInteractionsHandler?: IPostSocialInteractionsHandler;
13
13
  on?: {
14
14
  attachmentsClicked?: () => void;
15
15
  };
@@ -6,26 +6,9 @@ import { default as ShortVideoControls } from './cmp.short-video-controls.svelte
6
6
  import { default as ShortVideoHeading } from './cmp.short-video-heading.svelte';
7
7
  import { ShortVideoViewerLocalization } from './short-video-viewer-localization';
8
8
  import { ShortVideoViewerUiManager } from './ui-manager.svelte';
9
- let { model, socialInteractionsHandler, availableSideSpace = 0, showAttachments = true, showControls = true, autoplay = 'on-appearance', localization: localizationInit = 'en', on } = $props();
9
+ let { model, socialInteractionsHandler, showAttachments = true, showControls = true, autoplay = 'on-appearance', localization: localizationInit = 'en', on } = $props();
10
10
  const localization = $derived(new ShortVideoViewerLocalization(localizationInit));
11
- let actionsPanelRef = $state.raw(null);
12
11
  const uiManager = new ShortVideoViewerUiManager();
13
- $effect(() => {
14
- if (actionsPanelRef) {
15
- const resizeObserver = new ResizeObserver(() => {
16
- if (actionsPanelRef) {
17
- uiManager.updateActionsPanelWidth(actionsPanelRef.clientWidth);
18
- }
19
- });
20
- resizeObserver.observe(actionsPanelRef);
21
- return () => {
22
- resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
23
- };
24
- }
25
- });
26
- $effect(() => {
27
- uiManager.updateAvailableSideSpace(availableSideSpace);
28
- });
29
12
  $effect(() => {
30
13
  uiManager.updateCanShowAttachments(showAttachments);
31
14
  uiManager.updateCanShowControls(showControls);
@@ -51,10 +34,7 @@ $effect(() => {
51
34
  {/if}
52
35
  </div>
53
36
 
54
- <div
55
- class="short-video-viewer__actions-panel"
56
- class:short-video-viewer__actions-panel--inside-frame={uiManager.showActionsInsideFrame}
57
- bind:this={actionsPanelRef}>
37
+ <div class="short-video-viewer__actions-panel" class:short-video-viewer__actions-panel--inside-frame={true}>
58
38
  {#if uiManager.showAttachments}
59
39
  <AttachmentsInline model={model} />
60
40
  {/if}
@@ -88,8 +68,6 @@ $effect(() => {
88
68
  }
89
69
  }
90
70
  .short-video-viewer {
91
- --_short-video-viewer--actions-panel--top: var(--short-video-viewer--actions-panel--top, 0.9375rem);
92
- --_short-video-viewer--actions-panel--bottom: var(--short-video-viewer--actions-panel--bottom, 0.9375rem);
93
71
  --video--media-fit: cover;
94
72
  width: 100%;
95
73
  min-width: 100%;
@@ -116,8 +94,8 @@ $effect(() => {
116
94
  .short-video-viewer__actions-panel {
117
95
  position: absolute;
118
96
  left: calc(100% + 0.625rem);
119
- top: var(--_short-video-viewer--actions-panel--top);
120
- bottom: var(--_short-video-viewer--actions-panel--bottom);
97
+ top: 0.9375rem;
98
+ bottom: 0.9375rem;
121
99
  gap: 2.5rem;
122
100
  display: flex;
123
101
  flex-direction: column;
@@ -128,12 +106,16 @@ $effect(() => {
128
106
  .short-video-viewer__actions-panel {
129
107
  left: auto;
130
108
  right: 0.625rem;
109
+ top: 5rem;
110
+ bottom: 5rem;
131
111
  align-items: flex-end;
132
112
  }
133
113
  }
134
114
  .short-video-viewer__actions-panel--inside-frame {
135
115
  left: auto;
136
116
  right: 0.625rem;
117
+ top: 5rem;
118
+ bottom: 5rem;
137
119
  align-items: flex-end;
138
120
  }
139
121
  .short-video-viewer__description {
@@ -1,10 +1,9 @@
1
1
  import type { Locale } from '../../core/locale';
2
2
  import { type IShortVideoViewerLocalization } from './short-video-viewer-localization';
3
- import type { ShortVideoSocialInteractionsHandler, ShortVideoViewerModel } from './types';
3
+ import type { IPostSocialInteractionsHandler, ShortVideoViewerModel } from './types';
4
4
  type Props = {
5
5
  model: ShortVideoViewerModel;
6
- socialInteractionsHandler?: ShortVideoSocialInteractionsHandler;
7
- availableSideSpace?: number;
6
+ socialInteractionsHandler?: IPostSocialInteractionsHandler;
8
7
  showAttachments?: boolean;
9
8
  showControls?: boolean;
10
9
  autoplay?: true | false | 'on-appearance';
@@ -2,7 +2,7 @@ export { default as ShortVideoViewer } from './cmp.short-video-viewer.svelte';
2
2
  export { default as ShortVideoControls } from './cmp.short-video-controls.svelte';
3
3
  export { default as ShortVideoViewerAttachments } from './cmp.attachments.svelte';
4
4
  export { default as ShortVideoViewerAttachmentsInline } from './cmp.attachments-inline.svelte';
5
- export type { ShortVideoViewerModel, ShortVideoSocialInteractionsHandler, ShortVideoAdCardModel, ShortVideoProductCardModel } from './types';
5
+ export type { ShortVideoViewerModel, IPostSocialInteractionsHandler, ShortVideoAdCardModel, ShortVideoProductCardModel } from './types';
6
6
  export type { IShortVideoViewerLocalization } from './short-video-viewer-localization';
7
7
  export type { IShortVideoAttachmentsLocalization } from './short-video-attachments-localization';
8
8
  export { mapToShortVideoViewerModel } from './mapper';
@@ -3,6 +3,9 @@ import { getMediaItemImageUrl } from '../../core/media';
3
3
  import { shouldUseSalePrice } from '../../products/price-helper';
4
4
  export const mapToShortVideoViewerModel = (payload) => {
5
5
  const mediaBlob = payload.postData.media[0];
6
+ if (!mediaBlob) {
7
+ console.warn('Short video media is missing. Unexpected behavior.');
8
+ }
6
9
  return {
7
10
  id: payload.id,
8
11
  media: mediaBlob.type === MediaType.Image
@@ -18,7 +21,7 @@ export const mapToShortVideoViewerModel = (payload) => {
18
21
  ad: payload.ad ? mapToShortVideoAdCardModel(payload.ad) : null,
19
22
  products: payload.allProducts.map((x) => mapToShortVideoProductCard(x))
20
23
  // uncomment if you want to test many products behavior
21
- // .flatMap(x =>
24
+ // .flatMap((x) =>
22
25
  // Array.from({ length: 20 }, (_, i) => ({
23
26
  // ...x,
24
27
  // id: x.id + String(i + 1)
@@ -30,7 +33,7 @@ const mapToShortVideoAdCardModel = (payload) => {
30
33
  return {
31
34
  id: payload.id,
32
35
  type: payload.type,
33
- image: getMediaItemImageUrl(payload.media[0]),
36
+ image: payload.media.length ? getMediaItemImageUrl(payload.media[0]) : null,
34
37
  title: payload.title,
35
38
  description: payload.description,
36
39
  price: payload.price,
@@ -53,7 +56,7 @@ const mapToShortVideoProductCard = (payload, referenceDate) => {
53
56
  shortDescription: payload.shortDescription,
54
57
  link: payload.link,
55
58
  brandName: payload.brand?.name || null,
56
- image: payload.media?.length ? getMediaItemImageUrl(payload.media[0]) : null,
59
+ image: payload.media.length ? getMediaItemImageUrl(payload.media[0]) : null,
57
60
  currency: payload.priceAndAvailability.currency,
58
61
  price: payload.priceAndAvailability.price,
59
62
  salePrice: effectiveSalePrice?.salePrice ?? null
@@ -9,7 +9,7 @@ export type ShortVideoViewerModel = {
9
9
  url: string;
10
10
  thumbnailUrl: string;
11
11
  };
12
- text?: string | null;
12
+ text: string | null;
13
13
  heading: ShortVideoViewerHeadingModel | null;
14
14
  enableSocialInteractions: boolean;
15
15
  products: ShortVideoProductCardModel[];
@@ -21,13 +21,14 @@ export type ShortVideoViewerHeadingModel = {
21
21
  displayDate: string;
22
22
  viewsCount: number;
23
23
  };
24
- export type ShortVideoSocialInteractionsHandler = {
25
- isLiked: (shortVideoId: string) => Promise<{
24
+ export interface IPostSocialInteractionsHandler {
25
+ getIsLiked: (shortVideoId: string) => PromiseLike<{
26
26
  readonly isLiked: boolean;
27
27
  }>;
28
- onToggleLike: (shortVideoId: string) => void;
29
- onShare: (shortVideoId: string) => void;
30
- };
28
+ toggleLike: (shortVideoId: string) => PromiseLike<void>;
29
+ share: (shortVideoId: string) => PromiseLike<void>;
30
+ }
31
+ type PromiseLike<T> = T | Promise<T>;
31
32
  export type ShortVideoProductCardModel = {
32
33
  id: string;
33
34
  title: string;
@@ -56,3 +57,4 @@ export type ShortVideoAdCardModel = {
56
57
  border: string;
57
58
  } | null;
58
59
  };
60
+ export {};
@@ -1,16 +1,11 @@
1
1
  export declare class ShortVideoViewerUiManager {
2
2
  readonly globalCssVariables: string;
3
- readonly showActionsInsideFrame: boolean;
4
3
  readonly showAttachments: boolean;
5
4
  readonly showControls: boolean;
6
5
  private readonly buttonSize;
7
- private actionsPanelWidth;
8
- private availableSideSpace;
9
6
  private canShowControls;
10
7
  private canShowAttachments;
11
8
  private enableAttachments;
12
- updateActionsPanelWidth: (value: number) => void;
13
- updateAvailableSideSpace: (value: number) => void;
14
9
  updateCanShowAttachments: (value: boolean) => void;
15
10
  updateCanShowControls: (value: boolean) => void;
16
11
  toggleEnableAttachments: () => void;
@@ -3,9 +3,6 @@ export class ShortVideoViewerUiManager {
3
3
  const values = [`--_short-video-viewer--button--size: ${this.buttonSize}px`];
4
4
  return values.join(';');
5
5
  });
6
- showActionsInsideFrame = $derived.by(() => {
7
- return this.actionsPanelWidth + 40 > this.availableSideSpace;
8
- });
9
6
  showAttachments = $derived.by(() => {
10
7
  return this.canShowAttachments && this.enableAttachments;
11
8
  });
@@ -13,20 +10,12 @@ export class ShortVideoViewerUiManager {
13
10
  return this.canShowControls;
14
11
  });
15
12
  buttonSize = 40;
16
- actionsPanelWidth = $state(0);
17
- availableSideSpace = $state(0);
18
13
  // is provided from the calling side
19
14
  canShowControls = $state(false);
20
15
  // is provided from the calling side
21
16
  canShowAttachments = $state(false);
22
17
  // managed internally by component
23
18
  enableAttachments = $state(true);
24
- updateActionsPanelWidth = (value) => {
25
- this.actionsPanelWidth = value;
26
- };
27
- updateAvailableSideSpace = (value) => {
28
- this.availableSideSpace = value;
29
- };
30
19
  updateCanShowAttachments = (value) => {
31
20
  this.canShowAttachments = value;
32
21
  };
@@ -1,20 +1,24 @@
1
- <script lang="ts">import {} from '../../core/locale';
1
+ <script lang="ts">import { MediaCenter, MediaCenterMode } from '../../media-center/media-center';
2
2
  import { createShadowRoot } from '../../ui/shadow-dom';
3
- import {} from './short-videos-player-localization';
4
- import { default as ShortVideosPlayerView } from './short-videos-player-view.svelte';
5
3
  import { mount, unmount } from 'svelte';
6
- let { input, socialInteractionsHandler, localization, showStreamsCloudWatermark, disableBackground, on } = $props();
4
+ let { dataProvider, socialInteractionsHandler, localization, showStreamsCloudWatermark, disableBackground, on, mediaCenterDataProvider } = $props();
7
5
  const initHost = (node) => {
8
6
  const shadowRoot = createShadowRoot(node);
9
- const mounted = mount(ShortVideosPlayerView, {
7
+ const mounted = mount(MediaCenter, {
10
8
  target: shadowRoot,
11
9
  props: {
12
- input,
13
- socialInteractionsHandler,
14
- localization,
15
- showStreamsCloudWatermark,
16
- disableBackground,
17
- on
10
+ dataProvider: mediaCenterDataProvider || null,
11
+ playerProps: {
12
+ type: MediaCenterMode.ShortVideos,
13
+ props: {
14
+ dataProvider,
15
+ socialInteractionsHandler,
16
+ disableBackground,
17
+ localization,
18
+ showStreamsCloudWatermark,
19
+ on
20
+ }
21
+ }
18
22
  }
19
23
  });
20
24
  return {
@@ -25,6 +29,6 @@ const initHost = (node) => {
25
29
  };
26
30
  </script>
27
31
 
28
- {#key input}
32
+ {#key dataProvider}
29
33
  <div class="short-videos-player-host" use:initHost></div>
30
34
  {/key}
@@ -1,18 +1,8 @@
1
- import { type Locale } from '../../core/locale';
2
- import type { ShortVideoSocialInteractionsHandler } from '../short-video-viewer';
3
- import { type IShortVideosPlayerLocalization } from './short-videos-player-localization';
4
- import type { PlayerInput } from './types';
5
- type Props = {
6
- input: PlayerInput;
7
- socialInteractionsHandler?: ShortVideoSocialInteractionsHandler;
8
- localization?: IShortVideosPlayerLocalization | Locale;
9
- showStreamsCloudWatermark?: boolean;
10
- disableBackground?: boolean;
11
- on?: {
12
- closePlayer?: () => void;
13
- videoActivated?: (id: string) => void;
14
- };
1
+ import type { IMediaCenterDataProvider } from '../../media-center/data-provider';
2
+ import type { ShortVideoPlayerProps } from './types';
3
+ type $$ComponentProps = ShortVideoPlayerProps & {
4
+ mediaCenterDataProvider?: IMediaCenterDataProvider;
15
5
  };
16
- declare const Cmp: import("svelte").Component<Props, {}, "">;
6
+ declare const Cmp: import("svelte").Component<$$ComponentProps, {}, "">;
17
7
  type Cmp = ReturnType<typeof Cmp>;
18
8
  export default Cmp;