@streamscloud/embeddable 3.2.4 → 3.2.5

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 (179) hide show
  1. package/dist/core/analytics.profile-id.d.ts +5 -0
  2. package/dist/core/analytics.profile-id.js +17 -0
  3. package/dist/core/document.event-handlers.d.ts +1 -0
  4. package/dist/core/document.event-handlers.js +5 -0
  5. package/dist/core/enums.d.ts +0 -2
  6. package/dist/core/enums.js +0 -2
  7. package/dist/core/graphql.d.ts +3 -1
  8. package/dist/core/graphql.js +12 -3
  9. package/dist/core/locale.d.ts +6 -0
  10. package/dist/core/locale.js +24 -0
  11. package/dist/core/utils/html-helper.d.ts +1 -0
  12. package/dist/core/utils/html-helper.js +4 -0
  13. package/dist/products/price-helper.js +1 -1
  14. package/dist/short-videos/short-video-viewer/cmp.ad.svelte +103 -37
  15. package/dist/short-videos/short-video-viewer/cmp.attachments-inline.svelte +2 -2
  16. package/dist/short-videos/short-video-viewer/cmp.attachments.svelte +2 -2
  17. package/dist/short-videos/short-video-viewer/cmp.attachments.svelte.d.ts +3 -2
  18. package/dist/short-videos/short-video-viewer/cmp.product.svelte +1 -1
  19. package/dist/short-videos/short-video-viewer/cmp.product.svelte.d.ts +3 -2
  20. package/dist/short-videos/short-video-viewer/cmp.short-video-details.svelte +1 -1
  21. package/dist/short-videos/short-video-viewer/cmp.short-video-details.svelte.d.ts +3 -2
  22. package/dist/short-videos/short-video-viewer/cmp.short-video-heading.svelte +6 -2
  23. package/dist/short-videos/short-video-viewer/cmp.short-video-heading.svelte.d.ts +1 -1
  24. package/dist/short-videos/short-video-viewer/cmp.short-video-viewer.svelte +1 -1
  25. package/dist/short-videos/short-video-viewer/cmp.short-video-viewer.svelte.d.ts +3 -2
  26. package/dist/short-videos/short-video-viewer/description.svelte +5 -0
  27. package/dist/short-videos/short-video-viewer/description.svelte.d.ts +1 -1
  28. package/dist/short-videos/short-video-viewer/index.d.ts +4 -2
  29. package/dist/short-videos/short-video-viewer/index.js +1 -0
  30. package/dist/short-videos/short-video-viewer/mapper.js +5 -4
  31. package/dist/short-videos/short-video-viewer/operations.generated.d.ts +10 -3
  32. package/dist/short-videos/short-video-viewer/operations.generated.js +17 -3
  33. package/dist/short-videos/short-video-viewer/operations.graphql +10 -3
  34. package/dist/short-videos/short-video-viewer/{short-video-attachments-localization.svelte.d.ts → short-video-attachments-localization.d.ts} +5 -4
  35. package/dist/short-videos/short-video-viewer/short-video-attachments-localization.js +21 -0
  36. package/dist/short-videos/short-video-viewer/{short-video-details-localization.svelte.d.ts → short-video-details-localization.d.ts} +7 -6
  37. package/dist/short-videos/short-video-viewer/short-video-details-localization.js +17 -0
  38. package/dist/short-videos/short-video-viewer/{short-video-product-localization.svelte.d.ts → short-video-product-localization.d.ts} +2 -1
  39. package/dist/short-videos/short-video-viewer/short-video-product-localization.js +13 -0
  40. package/dist/short-videos/short-video-viewer/short-video-viewer-localization.d.ts +14 -0
  41. package/dist/short-videos/short-video-viewer/short-video-viewer-localization.js +17 -0
  42. package/dist/short-videos/short-video-viewer/types.d.ts +10 -3
  43. package/dist/short-videos/short-videos-player/cmp.short-videos-player.svelte +88 -11
  44. package/dist/short-videos/short-videos-player/cmp.short-videos-player.svelte.d.ts +5 -5
  45. package/dist/short-videos/short-videos-player/controls.svelte +2 -2
  46. package/dist/short-videos/short-videos-player/controls.svelte.d.ts +1 -1
  47. package/dist/short-videos/short-videos-player/index.d.ts +51 -14
  48. package/dist/short-videos/short-videos-player/index.js +83 -12
  49. package/dist/short-videos/short-videos-player/operations.generated.d.ts +71 -0
  50. package/dist/short-videos/short-videos-player/operations.generated.js +207 -0
  51. package/dist/short-videos/short-videos-player/operations.graphql +8 -0
  52. package/dist/short-videos/short-videos-player/short-videos-player-localization.d.ts +16 -0
  53. package/dist/short-videos/short-videos-player/short-videos-player-localization.js +13 -0
  54. package/dist/short-videos/short-videos-player/types.d.ts +36 -0
  55. package/dist/short-videos/short-videos-player/types.js +6 -0
  56. package/dist/streams/layout/cmp.layout.svelte.d.ts +4 -2
  57. package/dist/streams/layout/cmp.slot-content.svelte +4 -4
  58. package/dist/streams/layout/cmp.slot-content.svelte.d.ts +2 -1
  59. package/dist/streams/layout/cmp.slot.svelte.d.ts +7 -2
  60. package/dist/streams/layout/component.d.ts +2 -0
  61. package/dist/streams/layout/element-views/cmp.annotation-stream-element.svelte +16 -0
  62. package/dist/streams/layout/element-views/cmp.annotation-stream-element.svelte.d.ts +7 -0
  63. package/dist/streams/layout/element-views/cmp.container-stream-element.svelte +1 -1
  64. package/dist/streams/layout/element-views/cmp.container-stream-element.svelte.d.ts +4 -3
  65. package/dist/streams/layout/element-views/cmp.image-ref-stream-element.svelte +15 -2
  66. package/dist/streams/layout/element-views/cmp.image-ref-stream-element.svelte.d.ts +7 -3
  67. package/dist/streams/layout/element-views/cmp.images-stream-element.svelte +2 -2
  68. package/dist/streams/layout/element-views/cmp.price-stream-element.svelte +15 -89
  69. package/dist/streams/layout/element-views/cmp.price-stream-element.svelte.d.ts +5 -4
  70. package/dist/streams/layout/element-views/cmp.short-video-stream-element.svelte +4 -2
  71. package/dist/streams/layout/element-views/cmp.short-video-stream-element.svelte.d.ts +3 -0
  72. package/dist/streams/layout/element-views/cmp.stock-stream-element.svelte +74 -0
  73. package/dist/streams/layout/element-views/cmp.stock-stream-element.svelte.d.ts +11 -0
  74. package/dist/streams/layout/element-views/cmp.stream-element.svelte +24 -17
  75. package/dist/streams/layout/element-views/cmp.stream-element.svelte.d.ts +4 -3
  76. package/dist/streams/layout/element-views/cmp.text-ref-stream-element.svelte.d.ts +2 -2
  77. package/dist/streams/layout/element-views/cmp.text-stream-element.svelte +6 -2
  78. package/dist/streams/layout/element-views/cmp.text-stream-element.svelte.d.ts +2 -0
  79. package/dist/streams/layout/element-views/cmp.web-view-stream-element.svelte +37 -0
  80. package/dist/streams/layout/element-views/cmp.web-view-stream-element.svelte.d.ts +7 -0
  81. package/dist/streams/layout/element-views/data-by-key-accessor.d.ts +3 -3
  82. package/dist/streams/layout/element-views/index.d.ts +16 -11
  83. package/dist/streams/layout/element-views/index.js +12 -9
  84. package/dist/streams/layout/element-views/price-element-view.svelte +168 -0
  85. package/dist/streams/layout/element-views/price-element-view.svelte.d.ts +15 -0
  86. package/dist/streams/layout/element-views/price-stream-element-localization.d.ts +13 -0
  87. package/dist/streams/layout/element-views/price-stream-element-localization.js +21 -0
  88. package/dist/streams/layout/element-views/short-video-stream-element-localization.d.ts +9 -0
  89. package/dist/streams/layout/element-views/short-video-stream-element-localization.js +7 -0
  90. package/dist/streams/layout/element-views/stock-stream-element-localization.d.ts +8 -0
  91. package/dist/streams/layout/element-views/stock-stream-element-localization.js +26 -0
  92. package/dist/streams/layout/element-views/stream-element-localization.d.ts +15 -0
  93. package/dist/streams/layout/element-views/stream-element-localization.js +11 -0
  94. package/dist/streams/layout/elements.d.ts +47 -12
  95. package/dist/streams/layout/elements.js +1 -1
  96. package/dist/streams/layout/enums.d.ts +34 -3
  97. package/dist/streams/layout/enums.js +46 -7
  98. package/dist/streams/layout/index.d.ts +3 -10
  99. package/dist/streams/layout/index.js +3 -2
  100. package/dist/streams/layout/layout.d.ts +2 -1
  101. package/dist/streams/layout/models/index.d.ts +1 -1
  102. package/dist/streams/layout/models/mapper.js +5 -4
  103. package/dist/streams/layout/models/stream-layout-media-item-model.d.ts +1 -1
  104. package/dist/streams/layout/models/stream-layout-media-item-model.js +1 -1
  105. package/dist/streams/layout/models/stream-layout-post-header-model.d.ts +1 -1
  106. package/dist/streams/layout/models/stream-layout-product-model.d.ts +1 -2
  107. package/dist/streams/layout/models/stream-layout-short-video-model.d.ts +13 -3
  108. package/dist/streams/layout/serializer.svelte.d.ts +29 -0
  109. package/dist/streams/layout/serializer.svelte.js +93 -0
  110. package/dist/streams/layout/slot-data-ref.d.ts +13 -0
  111. package/dist/streams/layout/slot-data-ref.js +1 -0
  112. package/dist/streams/layout/slot.d.ts +2 -0
  113. package/dist/streams/layout/styles-transformer.d.ts +3 -2
  114. package/dist/streams/layout/styles-transformer.js +54 -30
  115. package/dist/streams/layout/styles.d.ts +24 -14
  116. package/dist/streams/layout/svg-attributes.d.ts +7 -0
  117. package/dist/streams/layout/svg-attributes.js +8 -0
  118. package/dist/streams/layout/type-guards.d.ts +31 -0
  119. package/dist/streams/layout/type-guards.js +13 -1
  120. package/dist/streams/stream-page-viewer/cmp.stream-page-viewer.svelte +4 -2
  121. package/dist/streams/stream-page-viewer/cmp.stream-page-viewer.svelte.d.ts +3 -0
  122. package/dist/streams/stream-page-viewer/index.d.ts +1 -0
  123. package/dist/streams/stream-page-viewer/stream-page-viewer-localization.d.ts +9 -0
  124. package/dist/streams/stream-page-viewer/stream-page-viewer-localization.js +7 -0
  125. package/dist/streams/stream-player/cmp.stream-player.svelte +47 -7
  126. package/dist/streams/stream-player/cmp.stream-player.svelte.d.ts +6 -4
  127. package/dist/streams/stream-player/controls.svelte +46 -3
  128. package/dist/streams/stream-player/controls.svelte.d.ts +1 -1
  129. package/dist/streams/stream-player/index.d.ts +6 -4
  130. package/dist/streams/stream-player/index.js +15 -28
  131. package/dist/streams/stream-player/operations.generated.d.ts +1 -1
  132. package/dist/streams/stream-player/operations.generated.js +5 -3
  133. package/dist/streams/stream-player/operations.graphql +3 -3
  134. package/dist/streams/stream-player/stream-overview.svelte +2 -2
  135. package/dist/streams/stream-player/stream-overview.svelte.d.ts +1 -1
  136. package/dist/streams/stream-player/stream-player-buffer.svelte.js +2 -2
  137. package/dist/streams/stream-player/stream-player-localization.d.ts +26 -0
  138. package/dist/streams/stream-player/stream-player-localization.js +31 -0
  139. package/dist/ui/icon/cmp.icon.svelte +13 -26
  140. package/dist/ui/line-clamp/cmp.line-clamp.svelte +2 -2
  141. package/dist/ui/line-clamp/cmp.line-clamp.svelte.d.ts +3 -2
  142. package/dist/ui/line-clamp/index.d.ts +1 -1
  143. package/dist/ui/line-clamp/index.js +1 -1
  144. package/dist/ui/line-clamp/{line-clamp-localization.svelte.d.ts → line-clamp-localization.d.ts} +2 -1
  145. package/dist/ui/line-clamp/line-clamp-localization.js +19 -0
  146. package/dist/ui/shadow-dom/shadow-host.d.ts +1 -5
  147. package/dist/ui/shadow-dom/shadow-host.js +1 -14
  148. package/dist/ui/swipe-indicator/cmp.swipe-indicator.svelte +125 -0
  149. package/dist/ui/swipe-indicator/cmp.swipe-indicator.svelte.d.ts +9 -0
  150. package/dist/ui/swipe-indicator/index.d.ts +2 -0
  151. package/dist/ui/swipe-indicator/index.js +1 -0
  152. package/dist/ui/swipe-indicator/swipe-indicator-localization.d.ts +8 -0
  153. package/dist/ui/swipe-indicator/swipe-indicator-localization.js +13 -0
  154. package/dist/ui/time-ago/cmp.time-ago.svelte +1 -1
  155. package/dist/ui/time-ago/cmp.time-ago.svelte.d.ts +3 -2
  156. package/dist/ui/time-ago/index.d.ts +1 -1
  157. package/dist/ui/time-ago/{time-ago-localization.svelte.d.ts → time-ago-localization.d.ts} +2 -1
  158. package/dist/ui/time-ago/time-ago-localization.js +55 -0
  159. package/dist/ui/video/cmp.video.svelte +42 -18
  160. package/package.json +1 -1
  161. package/dist/short-videos/short-video-viewer/short-video-attachments-localization.svelte.js +0 -10
  162. package/dist/short-videos/short-video-viewer/short-video-details-localization.svelte.js +0 -10
  163. package/dist/short-videos/short-video-viewer/short-video-product-localization.svelte.js +0 -11
  164. package/dist/short-videos/short-video-viewer/short-video-viewer-localization.svelte.d.ts +0 -13
  165. package/dist/short-videos/short-video-viewer/short-video-viewer-localization.svelte.js +0 -10
  166. package/dist/short-videos/short-videos-player/short-videos-player-localization.svelte.d.ts +0 -8
  167. package/dist/short-videos/short-videos-player/short-videos-player-localization.svelte.js +0 -6
  168. package/dist/streams/layout/element-views/price-stream-element-localization.svelte.d.ts +0 -9
  169. package/dist/streams/layout/element-views/price-stream-element-localization.svelte.js +0 -8
  170. package/dist/streams/layout/element-views/stream-element-localization.svelte.d.ts +0 -8
  171. package/dist/streams/layout/element-views/stream-element-localization.svelte.js +0 -6
  172. package/dist/streams/layout/serializer.d.ts +0 -3
  173. package/dist/streams/layout/serializer.js +0 -6
  174. package/dist/streams/stream-page-viewer/stream-page-viewer-localization.svelte.d.ts +0 -13
  175. package/dist/streams/stream-page-viewer/stream-page-viewer-localization.svelte.js +0 -10
  176. package/dist/streams/stream-player/stream-player-localization.svelte.d.ts +0 -12
  177. package/dist/streams/stream-player/stream-player-localization.svelte.js +0 -10
  178. package/dist/ui/line-clamp/line-clamp-localization.svelte.js +0 -15
  179. package/dist/ui/time-ago/time-ago-localization.svelte.js +0 -39
@@ -16,6 +16,7 @@ fragment ShortVideoViewerPayloadFragment on Post {
16
16
  title
17
17
  id
18
18
  link
19
+ shortDescription
19
20
  priceAndAvailability {
20
21
  currency
21
22
  price
@@ -30,9 +31,15 @@ fragment ShortVideoViewerPayloadFragment on Post {
30
31
  id
31
32
  title
32
33
  description
33
- buttonText
34
- buttonUrl
35
- openLinkInNewWindow
34
+ price
35
+ currency
36
+ ctaButton {
37
+ background
38
+ textColor
39
+ text
40
+ url
41
+ border
42
+ }
36
43
  type
37
44
  media {
38
45
  url
@@ -1,12 +1,13 @@
1
- import type { IShortVideoProductLocalization } from './short-video-product-localization.svelte';
1
+ import { type Locale } from '../../core/locale';
2
+ import type { IShortVideoProductLocalization } from './short-video-product-localization';
2
3
  export interface IShortVideoAttachmentsLocalization {
3
4
  productsSection?: string;
4
5
  offersSection?: string;
5
6
  productLocalization?: IShortVideoProductLocalization;
6
7
  }
7
- export declare class ShortVideoAttachmentsLocalizationSvelte {
8
+ export declare class ShortVideoAttachmentsLocalization {
8
9
  productsSection: string;
9
10
  offersSection: string;
10
- productLocalization: IShortVideoProductLocalization | undefined;
11
- constructor(init?: IShortVideoAttachmentsLocalization);
11
+ productLocalization: IShortVideoProductLocalization | Locale;
12
+ constructor(init: IShortVideoAttachmentsLocalization | Locale);
12
13
  }
@@ -0,0 +1,21 @@
1
+ import { isLocale } from '../../core/locale';
2
+ export class ShortVideoAttachmentsLocalization {
3
+ productsSection;
4
+ offersSection;
5
+ productLocalization;
6
+ constructor(init) {
7
+ this.productsSection = isLocale(init) ? loc.productsSection[init] : init.productsSection || loc.productsSection.en;
8
+ this.offersSection = isLocale(init) ? loc.offersSection[init] : init.offersSection || loc.offersSection.en;
9
+ this.productLocalization = isLocale(init) ? init : init.productLocalization || 'en';
10
+ }
11
+ }
12
+ const loc = {
13
+ productsSection: {
14
+ en: 'Products',
15
+ no: 'Produkter'
16
+ },
17
+ offersSection: {
18
+ en: 'Offers',
19
+ no: 'Tilbud'
20
+ }
21
+ };
@@ -1,13 +1,14 @@
1
+ import { type Locale } from '../../core/locale';
1
2
  import type { ITimeAgoLocalization } from '../../ui/time-ago';
2
- import type { IShortVideoAttachmentsLocalization } from './short-video-attachments-localization.svelte';
3
+ import type { IShortVideoAttachmentsLocalization } from './short-video-attachments-localization';
3
4
  export interface IShortVideoDetailsLocalization {
4
5
  viewsCount?: (count: number) => string;
5
- timeAgoLocalization?: ITimeAgoLocalization;
6
- attachmentsLocalization?: IShortVideoAttachmentsLocalization;
6
+ timeAgoLocalization?: ITimeAgoLocalization | Locale;
7
+ attachmentsLocalization?: IShortVideoAttachmentsLocalization | Locale;
7
8
  }
8
9
  export declare class ShortVideoDetailsLocalization {
9
10
  viewsCount: (count: number) => string;
10
- timeAgoLocalization: ITimeAgoLocalization | undefined;
11
- attachmentsLocalization: IShortVideoAttachmentsLocalization | undefined;
12
- constructor(init?: IShortVideoDetailsLocalization);
11
+ timeAgoLocalization: ITimeAgoLocalization | Locale;
12
+ attachmentsLocalization: IShortVideoAttachmentsLocalization | Locale;
13
+ constructor(init: IShortVideoDetailsLocalization | Locale);
13
14
  }
@@ -0,0 +1,17 @@
1
+ import { isLocale } from '../../core/locale';
2
+ export class ShortVideoDetailsLocalization {
3
+ viewsCount;
4
+ timeAgoLocalization;
5
+ attachmentsLocalization;
6
+ constructor(init) {
7
+ this.viewsCount = isLocale(init) ? loc.viewsCount[init] : init.viewsCount || loc.viewsCount.en;
8
+ this.timeAgoLocalization = isLocale(init) ? init : init.timeAgoLocalization || 'en';
9
+ this.attachmentsLocalization = isLocale(init) ? init : init.attachmentsLocalization || 'en';
10
+ }
11
+ }
12
+ const loc = {
13
+ viewsCount: {
14
+ en: (count) => (count === 1 ? '1 view' : `${count} views`),
15
+ no: (count) => (count === 1 ? '1 visning' : `${count} visninger`)
16
+ }
17
+ };
@@ -1,7 +1,8 @@
1
+ import { type Locale } from '../../core/locale';
1
2
  export interface IShortVideoProductLocalization {
2
3
  beforeNowPrefix?: string | null;
3
4
  }
4
5
  export declare class ShortVideoProductLocalization {
5
6
  beforeNowPrefix: string | null;
6
- constructor(init?: IShortVideoProductLocalization);
7
+ constructor(init: IShortVideoProductLocalization | Locale);
7
8
  }
@@ -0,0 +1,13 @@
1
+ import { isLocale } from '../../core/locale';
2
+ export class ShortVideoProductLocalization {
3
+ beforeNowPrefix;
4
+ constructor(init) {
5
+ this.beforeNowPrefix = isLocale(init) ? loc.beforeNowPrefix[init] : init?.beforeNowPrefix || loc.beforeNowPrefix.en;
6
+ }
7
+ }
8
+ const loc = {
9
+ beforeNowPrefix: {
10
+ en: 'Before',
11
+ no: 'Før'
12
+ }
13
+ };
@@ -0,0 +1,14 @@
1
+ import { type Locale } from '../../core/locale';
2
+ import type { ITimeAgoLocalization } from '../../ui/time-ago';
3
+ import type { IShortVideoProductLocalization } from './short-video-product-localization';
4
+ export interface IShortVideoViewerLocalization {
5
+ viewsCount?: (count: number) => string;
6
+ timeAgoLocalization?: ITimeAgoLocalization | Locale;
7
+ productLocalization?: IShortVideoProductLocalization | Locale;
8
+ }
9
+ export declare class ShortVideoViewerLocalization {
10
+ viewsCount: (count: number) => string;
11
+ timeAgoLocalization: ITimeAgoLocalization | Locale;
12
+ productLocalization: IShortVideoProductLocalization | Locale;
13
+ constructor(init: IShortVideoViewerLocalization | Locale);
14
+ }
@@ -0,0 +1,17 @@
1
+ import { isLocale } from '../../core/locale';
2
+ export class ShortVideoViewerLocalization {
3
+ viewsCount;
4
+ timeAgoLocalization;
5
+ productLocalization;
6
+ constructor(init) {
7
+ this.viewsCount = isLocale(init) ? loc.viewsCount[init] : init.viewsCount || loc.viewsCount.en;
8
+ this.timeAgoLocalization = isLocale(init) ? init : init.timeAgoLocalization || 'en';
9
+ this.productLocalization = isLocale(init) ? init : init.productLocalization || 'en';
10
+ }
11
+ }
12
+ const loc = {
13
+ viewsCount: {
14
+ en: (count) => (count === 1 ? '1 view' : `${count} views`),
15
+ no: (count) => (count === 1 ? '1 visning' : `${count} visninger`)
16
+ }
17
+ };
@@ -25,9 +25,15 @@ export type ShortVideoViewerAdModel = {
25
25
  image: string | null;
26
26
  title: string;
27
27
  description: string | null;
28
- buttonText: string | null;
29
- buttonUrl: string | null;
30
- openLinkInNewWindow: boolean | null;
28
+ price: number | null;
29
+ currency: Currency | null;
30
+ ctaButton: {
31
+ background: string;
32
+ textColor: string;
33
+ text: string;
34
+ url: string;
35
+ border: string;
36
+ } | null;
31
37
  };
32
38
  export type ShortVideoViewerProductModel = {
33
39
  id: string;
@@ -37,4 +43,5 @@ export type ShortVideoViewerProductModel = {
37
43
  price: number;
38
44
  currency: Currency;
39
45
  salePrice: number | null;
46
+ shortDescription?: string | null;
40
47
  };
@@ -7,44 +7,121 @@
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { ShortVideoViewer } from '../short-video-viewer';
10
+ import { handleEsc } from '../../core/document.event-handlers';
11
+ import { createLocalGQLClient } from '../../core/graphql';
12
+ import { mapShortVideoViewerModel, ShortVideoViewer } from '../short-video-viewer';
13
+ import { Loading } from '../../ui/loading';
11
14
  import { PlayerBuffer, PlayerSlider } from '../../ui/player';
12
15
  import { SpotlightLayout } from '../../ui/spotlight-layout';
16
+ import { SwipeIndicator } from '../../ui/swipe-indicator';
13
17
  import { default as Controls } from './controls.svelte';
14
- import { ShortVideosPlayerLocalization } from './short-videos-player-localization.svelte';
18
+ import { GetShortVideosDocument } from './operations.generated';
19
+ import { ShortVideosPlayerLocalization } from './short-videos-player-localization';
15
20
  import { ShortVideosPlayerUiManager } from './ui-manager.svelte';
16
- import { onDestroy, onMount } from 'svelte';
17
- let { shortVideosProvider, localization: localizationInit, on } = $props();
21
+ import { onMount, untrack } from 'svelte';
22
+ let { input, localization: localizationInit, on } = $props();
18
23
  const localization = $derived(new ShortVideosPlayerLocalization(localizationInit));
19
- const buffer = $derived(new PlayerBuffer(shortVideosProvider));
24
+ let everTouched = $state(false);
25
+ let buffer = $state(input.type === 'provider' ? new PlayerBuffer(input.provider) : null);
26
+ $effect(() => {
27
+ if (input.type !== 'ids') {
28
+ return;
29
+ }
30
+ untrack(() => {
31
+ initBuffer(input);
32
+ });
33
+ });
34
+ const initBuffer = (input) => __awaiter(void 0, void 0, void 0, function* () {
35
+ var _a, _b;
36
+ try {
37
+ const { graphqlOrigin, ids, initialId } = input;
38
+ const graphql = createLocalGQLClient(graphqlOrigin, { 'x-initiator': input.initiator || 'player/short-videos' });
39
+ const payload = yield graphql
40
+ .query(GetShortVideosDocument, {
41
+ input: {
42
+ filter: {
43
+ ids
44
+ }
45
+ }
46
+ })
47
+ .toPromise();
48
+ const posts = ((_b = (_a = payload.data) === null || _a === void 0 ? void 0 : _a.shortVideos) === null || _b === void 0 ? void 0 : _b.items) || [];
49
+ const idOrder = new Map(ids.map((id, index) => [id, index]));
50
+ posts.sort((a, b) => {
51
+ var _a, _b;
52
+ return ((_a = idOrder.get(a.id)) !== null && _a !== void 0 ? _a : Infinity) - ((_b = idOrder.get(b.id)) !== null && _b !== void 0 ? _b : Infinity);
53
+ });
54
+ const index = initialId ? posts.findIndex((p) => p.id === initialId) : 0;
55
+ const provider = {
56
+ initialData: {
57
+ prefetchedItems: posts.map(mapShortVideoViewerModel),
58
+ startIndex: index
59
+ },
60
+ loadMore: () => __awaiter(void 0, void 0, void 0, function* () {
61
+ // No more items to load, as all are already prefetched
62
+ return [];
63
+ })
64
+ };
65
+ buffer = new PlayerBuffer(provider);
66
+ }
67
+ catch (_c) {
68
+ console.error('Failed to load short videos by IDs:', input.ids);
69
+ buffer = null; // Reset buffer on error
70
+ }
71
+ });
20
72
  const uiManager = new ShortVideosPlayerUiManager();
21
73
  onMount(() => __awaiter(void 0, void 0, void 0, function* () {
22
74
  uiManager.detailsCollapsed = window && window.innerWidth < window.innerHeight;
23
75
  }));
24
- onDestroy(() => {
25
- // end tracking the short video
26
- });
76
+ const contentMounted = (node) => {
77
+ const markAsTouched = () => {
78
+ everTouched = true;
79
+ node.removeEventListener('touchstart', markAsTouched);
80
+ node.removeEventListener('wheel', markAsTouched);
81
+ node.removeEventListener('click', markAsTouched);
82
+ node.removeEventListener('keypress', markAsTouched);
83
+ };
84
+ node.addEventListener('touchstart', markAsTouched);
85
+ node.addEventListener('wheel', markAsTouched);
86
+ node.addEventListener('click', markAsTouched);
87
+ node.addEventListener('keypress', markAsTouched);
88
+ };
27
89
  const handleDimensionsChanged = (dimensions) => {
28
90
  uiManager.updateDimensions({
29
91
  mainViewColumnWidth: dimensions.mainSceneWidth,
30
92
  viewTotalWidth: dimensions.totalWidth
31
93
  });
32
94
  };
95
+ const onPlayerClose = () => {
96
+ var _a;
97
+ (_a = on === null || on === void 0 ? void 0 : on.closePlayer) === null || _a === void 0 ? void 0 : _a.call(on);
98
+ };
33
99
  </script>
34
100
 
101
+ <svelte:document onkeydown={(e) => handleEsc(e, onPlayerClose)} />
102
+
35
103
  <div class="short-videos-player-container">
36
104
  <div class="short-videos-player" style={uiManager.globalCssVariables}>
37
105
  {#if buffer}
38
106
  <SpotlightLayout ratio={9 / 16} on={{ dimensionsChanged: handleDimensionsChanged }}>
39
- <div class="short-videos-player__content">
107
+ <div class="short-videos-player__content" use:contentMounted>
40
108
  <PlayerSlider buffer={buffer}>
41
109
  {#snippet children({ item })}
42
- <ShortVideoViewer model={item} autoplay="on-appearance" showAttachments={uiManager.showShortVideoOverlay} />
110
+ <ShortVideoViewer
111
+ model={item}
112
+ autoplay="on-appearance"
113
+ showAttachments={uiManager.showShortVideoOverlay}
114
+ localization={localization.shortVideoViewerLocalization} />
43
115
  {/snippet}
44
116
  </PlayerSlider>
117
+ {#if uiManager.isMobileView && buffer.loaded.length > 1 && !everTouched}
118
+ <SwipeIndicator localization={localization.swipeIndicatorLocalization} />
119
+ {/if}
45
120
  </div>
46
121
  </SpotlightLayout>
47
- <Controls buffer={buffer} uiManager={uiManager} localization={localization} on={{ closePlayer: () => on?.closePlayer?.() }} />
122
+ <Controls buffer={buffer} uiManager={uiManager} localization={localization} on={{ closePlayer: () => onPlayerClose() }} />
123
+ {:else}
124
+ <Loading positionFixedCenter={true} timeout={1000} />
48
125
  {/if}
49
126
  </div>
50
127
  </div>
@@ -1,9 +1,9 @@
1
- import { type ShortVideoViewerModel } from '../short-video-viewer';
2
- import { type PlayerItemsProvider } from '../../ui/player';
3
- import { type IShortVideosPlayerLocalization } from './short-videos-player-localization.svelte';
1
+ import type { Locale } from '../../core/locale';
2
+ import { type IShortVideosPlayerLocalization } from './short-videos-player-localization';
3
+ import type { PlayerInput } from './types';
4
4
  type Props = {
5
- shortVideosProvider: PlayerItemsProvider<ShortVideoViewerModel>;
6
- localization?: IShortVideosPlayerLocalization;
5
+ input: PlayerInput;
6
+ localization: IShortVideosPlayerLocalization | Locale;
7
7
  on?: {
8
8
  closePlayer?: () => void;
9
9
  };
@@ -2,7 +2,7 @@
2
2
  import { Icon } from '../../ui/icon';
3
3
  import { MediaVolumeManager } from '../../ui/media-playback';
4
4
  import { default as ActionButton } from './action-button.svelte';
5
- import { ShortVideosPlayerLocalization } from './short-videos-player-localization.svelte.js';
5
+ import { ShortVideosPlayerLocalization } from './short-videos-player-localization';
6
6
  import IconChevronDown from '@fluentui/svg-icons/icons/chevron_down_20_regular.svg?raw';
7
7
  import IconChevronUp from '@fluentui/svg-icons/icons/chevron_up_20_regular.svg?raw';
8
8
  import IconDismiss from '@fluentui/svg-icons/icons/dismiss_20_regular.svg?raw';
@@ -37,7 +37,7 @@ const shortVideo = $derived(buffer.current);
37
37
  <div class="short-videos-player-controls__right">
38
38
  {#if shortVideo}
39
39
  <div class="short-videos-player-controls__short-video-attachments">
40
- <ShortVideoViewerAttachments shortVideo={shortVideo} localization={localization.shortVideoDetailsLocalization?.attachmentsLocalization} />
40
+ <ShortVideoViewerAttachments shortVideo={shortVideo} localization={localization.shortVideoAttachmentsLocalization} />
41
41
  </div>
42
42
  {/if}
43
43
  <div class="short-videos-player-controls__controls">
@@ -1,6 +1,6 @@
1
1
  import { type ShortVideoViewerModel } from '../short-video-viewer';
2
2
  import type { IPlayerBuffer } from '../../ui/player';
3
- import { ShortVideosPlayerLocalization } from './short-videos-player-localization.svelte.js';
3
+ import { ShortVideosPlayerLocalization } from './short-videos-player-localization';
4
4
  import type { ShortVideosPlayerUiManager } from './ui-manager.svelte';
5
5
  type Props = {
6
6
  buffer: IPlayerBuffer<ShortVideoViewerModel>;
@@ -1,15 +1,38 @@
1
- import type { ShortVideoViewerModel } from '../short-video-viewer';
2
- import type { PlayerItemsProvider } from '../../ui/player';
3
- import type { IShortVideosPlayerLocalization } from './short-videos-player-localization.svelte';
1
+ import type { IShortVideosPlayerLocalization } from './short-videos-player-localization';
2
+ import { type OpenShortVideosPlayerInit } from './types';
4
3
  export type { IShortVideosPlayerLocalization };
5
4
  /**
6
- * Opens the short videos player modal with the specified provider and optional localization.
5
+ * Opens the short videos player modal with the specified provider or by fetching videos by IDs.
6
+ *
7
+ * You can use either a ready-made provider, or simply pass a list of video IDs and a GraphQL endpoint to fetch them.
7
8
  *
8
9
  * @param init - Configuration options.
9
- * @param {PlayerItemsProvider<ShortVideoViewerModel>} init.shortVideosProvider - The provider instance supplying short video items to the player.
10
- * @param {IShortVideosPlayerLocalization} [init.localization] - Optional localization settings for the player UI.
11
10
  *
12
- * @example
11
+ * @param {PlayerItemsProvider<ShortVideoViewerModel>} [init.shortVideosProvider]
12
+ * The provider instance supplying short video items to the player.
13
+ * **Use this if you already have your own provider implementation.**
14
+ *
15
+ * @param {string[]} [init.ids]
16
+ * List of short video IDs to display in the player.
17
+ * **Use this if you want the player to fetch and show specific videos.**
18
+ *
19
+ * @param {string} [init.graphqlUrl]
20
+ * The GraphQL endpoint to use when fetching videos by IDs.
21
+ * **Required if you use `ids`.**
22
+ *
23
+ * @param {string} [init.initialId]
24
+ * The ID of the video that should be shown first.
25
+ * **Optional. Only used when using `ids`.**
26
+ *
27
+ * @param {IShortVideosPlayerLocalization} [init.localization]
28
+ * Optional localization settings for the player UI.
29
+ *
30
+ * @param {object} [init.on]
31
+ * Optional event handlers.
32
+ * @param {() => void} [init.on.playerClosed]
33
+ * Called when the player is closed.
34
+ *
35
+ * @example <caption>Using a custom provider</caption>
13
36
  * ```ts
14
37
  * import { openShortVideosPlayer } from '@streamscloud/embeddable/short-videos-player';
15
38
  *
@@ -21,11 +44,25 @@ export type { IShortVideosPlayerLocalization };
21
44
  * }
22
45
  * });
23
46
  * ```
47
+ *
48
+ * @example <caption>Using a list of IDs</caption>
49
+ * ```ts
50
+ * import { openShortVideosPlayer } from '@streamscloud/embeddable/short-videos-player';
51
+ *
52
+ * openShortVideosPlayer({
53
+ * ids: ['id1', 'id2', 'id3'],
54
+ * graphqlOrigin: 'https://api.example.com',
55
+ * initialId: 'id2',
56
+ * localization: {
57
+ * next: 'Next',
58
+ * previous: 'Previous'
59
+ * },
60
+ * on: {
61
+ * playerClosed: () => {
62
+ * console.log('Player was closed');
63
+ * }
64
+ * }
65
+ * });
66
+ * ```
24
67
  */
25
- export declare const openShortVideosPlayer: (init: {
26
- shortVideosProvider: PlayerItemsProvider<ShortVideoViewerModel>;
27
- localization?: IShortVideosPlayerLocalization;
28
- on?: {
29
- playerClosed?: () => void;
30
- };
31
- }) => void;
68
+ export declare const openShortVideosPlayer: (init: OpenShortVideosPlayerInit) => Promise<void>;
@@ -1,14 +1,40 @@
1
+ import { getLocale } from '../../core/locale';
1
2
  import { ShadowHost } from '../../ui/shadow-dom';
2
3
  import { default as ShortVideosPlayer } from './cmp.short-videos-player.svelte';
3
- import { mount } from 'svelte';
4
+ import { isIdsInit, isShortVideosProviderInit } from './types';
5
+ import { mount, unmount } from 'svelte';
4
6
  /**
5
- * Opens the short videos player modal with the specified provider and optional localization.
7
+ * Opens the short videos player modal with the specified provider or by fetching videos by IDs.
8
+ *
9
+ * You can use either a ready-made provider, or simply pass a list of video IDs and a GraphQL endpoint to fetch them.
6
10
  *
7
11
  * @param init - Configuration options.
8
- * @param {PlayerItemsProvider<ShortVideoViewerModel>} init.shortVideosProvider - The provider instance supplying short video items to the player.
9
- * @param {IShortVideosPlayerLocalization} [init.localization] - Optional localization settings for the player UI.
10
12
  *
11
- * @example
13
+ * @param {PlayerItemsProvider<ShortVideoViewerModel>} [init.shortVideosProvider]
14
+ * The provider instance supplying short video items to the player.
15
+ * **Use this if you already have your own provider implementation.**
16
+ *
17
+ * @param {string[]} [init.ids]
18
+ * List of short video IDs to display in the player.
19
+ * **Use this if you want the player to fetch and show specific videos.**
20
+ *
21
+ * @param {string} [init.graphqlUrl]
22
+ * The GraphQL endpoint to use when fetching videos by IDs.
23
+ * **Required if you use `ids`.**
24
+ *
25
+ * @param {string} [init.initialId]
26
+ * The ID of the video that should be shown first.
27
+ * **Optional. Only used when using `ids`.**
28
+ *
29
+ * @param {IShortVideosPlayerLocalization} [init.localization]
30
+ * Optional localization settings for the player UI.
31
+ *
32
+ * @param {object} [init.on]
33
+ * Optional event handlers.
34
+ * @param {() => void} [init.on.playerClosed]
35
+ * Called when the player is closed.
36
+ *
37
+ * @example <caption>Using a custom provider</caption>
12
38
  * ```ts
13
39
  * import { openShortVideosPlayer } from '@streamscloud/embeddable/short-videos-player';
14
40
  *
@@ -20,17 +46,62 @@ import { mount } from 'svelte';
20
46
  * }
21
47
  * });
22
48
  * ```
49
+ *
50
+ * @example <caption>Using a list of IDs</caption>
51
+ * ```ts
52
+ * import { openShortVideosPlayer } from '@streamscloud/embeddable/short-videos-player';
53
+ *
54
+ * openShortVideosPlayer({
55
+ * ids: ['id1', 'id2', 'id3'],
56
+ * graphqlOrigin: 'https://api.example.com',
57
+ * initialId: 'id2',
58
+ * localization: {
59
+ * next: 'Next',
60
+ * previous: 'Previous'
61
+ * },
62
+ * on: {
63
+ * playerClosed: () => {
64
+ * console.log('Player was closed');
65
+ * }
66
+ * }
67
+ * });
68
+ * ```
23
69
  */
24
- export const openShortVideosPlayer = (init) => {
25
- const { shortVideosProvider, localization } = init;
26
- const shadowHost = new ShadowHost({ onClosed: () => init.on?.playerClosed?.() });
27
- mount(ShortVideosPlayer, {
70
+ export const openShortVideosPlayer = async (init) => {
71
+ let input = null;
72
+ if (isShortVideosProviderInit(init)) {
73
+ input = {
74
+ type: 'provider',
75
+ provider: init.shortVideosProvider
76
+ };
77
+ }
78
+ else if (isIdsInit(init)) {
79
+ input = {
80
+ type: 'ids',
81
+ ids: init.ids,
82
+ initialId: init.initialId,
83
+ graphqlOrigin: init.graphqlOrigin,
84
+ initiator: init.initiator
85
+ };
86
+ }
87
+ else {
88
+ input = null;
89
+ }
90
+ if (!input) {
91
+ return;
92
+ }
93
+ const shadowHost = new ShadowHost();
94
+ const mounted = mount(ShortVideosPlayer, {
28
95
  target: shadowHost.shadowRoot,
29
96
  props: {
30
- shortVideosProvider,
31
- localization,
97
+ input,
98
+ localization: getLocale(init.localization),
32
99
  on: {
33
- closePlayer: () => {
100
+ closePlayer: async () => {
101
+ if (init.on?.playerClosed) {
102
+ init.on.playerClosed();
103
+ }
104
+ await unmount(mounted);
34
105
  shadowHost.remove();
35
106
  }
36
107
  }
@@ -0,0 +1,71 @@
1
+ import type * as SchemaTypes from '../../../gql/types';
2
+ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
3
+ export type GetShortVideosQueryVariables = SchemaTypes.Exact<{
4
+ input: SchemaTypes.EmbedPostsInput;
5
+ image_scale?: SchemaTypes.InputMaybe<SchemaTypes.ImageScale>;
6
+ }>;
7
+ export type GetShortVideosQuery = {
8
+ shortVideos: {
9
+ items: Array<{
10
+ id: string;
11
+ enableSocialInteractions: boolean;
12
+ postHeading: {
13
+ sourceImage: string | null;
14
+ sourceName: string;
15
+ postDisplayDate: any;
16
+ postViewsCount: number;
17
+ };
18
+ allProducts: Array<{
19
+ title: string;
20
+ id: string;
21
+ link: string | null;
22
+ shortDescription: string | null;
23
+ media: Array<{
24
+ url: string;
25
+ thumbnailUrl: string | null;
26
+ type: SchemaTypes.MediaType;
27
+ }>;
28
+ priceAndAvailability: {
29
+ currency: SchemaTypes.Currency;
30
+ price: number;
31
+ productSalePrices: Array<{
32
+ salePrice: number;
33
+ salePriceEffectiveDateFrom: any | null;
34
+ salePriceEffectiveDateTo: any | null;
35
+ }> | null;
36
+ };
37
+ }>;
38
+ ad: {
39
+ id: string;
40
+ title: string;
41
+ description: string | null;
42
+ price: number | null;
43
+ currency: SchemaTypes.Currency | null;
44
+ type: SchemaTypes.AdType;
45
+ ctaButton: {
46
+ background: string;
47
+ textColor: string;
48
+ text: string;
49
+ url: string;
50
+ border: string;
51
+ } | null;
52
+ media: Array<{
53
+ url: string;
54
+ thumbnailUrl: string | null;
55
+ type: SchemaTypes.MediaType;
56
+ }>;
57
+ } | null;
58
+ postData: {
59
+ media: Array<{
60
+ url: string;
61
+ thumbnailUrl: string | null;
62
+ type: SchemaTypes.MediaType;
63
+ }>;
64
+ shortVideoData: {
65
+ text: string | null;
66
+ } | null;
67
+ };
68
+ }>;
69
+ };
70
+ };
71
+ export declare const GetShortVideosDocument: DocumentNode<GetShortVideosQuery, GetShortVideosQueryVariables>;