@streamscloud/embeddable 3.4.2 → 4.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 (98) hide show
  1. package/dist/ads/ad-card/cmp.ad-card.svelte +193 -0
  2. package/dist/{short-videos/short-video-viewer/cmp.ad.svelte.d.ts → ads/ad-card/cmp.ad-card.svelte.d.ts} +3 -2
  3. package/dist/ads/ad-card/index.d.ts +3 -0
  4. package/dist/ads/ad-card/index.js +2 -0
  5. package/dist/ads/ad-card/mapper.d.ts +3 -0
  6. package/dist/ads/ad-card/mapper.js +13 -0
  7. package/dist/ads/ad-card/operations.generated.d.ts +23 -0
  8. package/dist/ads/ad-card/operations.generated.js +47 -0
  9. package/dist/ads/ad-card/operations.graphql +20 -0
  10. package/dist/ads/ad-card/types.d.ts +17 -0
  11. package/dist/ads/ad-card/types.js +1 -0
  12. package/dist/core/locale.d.ts +3 -0
  13. package/dist/products/price-helper.d.ts +18 -3
  14. package/dist/products/price-helper.js +9 -6
  15. package/dist/products/product-card/cmp.product-card.svelte +218 -0
  16. package/dist/products/product-card/cmp.product-card.svelte.d.ts +15 -0
  17. package/dist/products/product-card/index.d.ts +4 -0
  18. package/dist/products/product-card/index.js +2 -0
  19. package/dist/products/product-card/mapper.d.ts +3 -0
  20. package/dist/products/product-card/mapper.js +22 -0
  21. package/dist/products/product-card/operations.generated.d.ts +26 -0
  22. package/dist/products/product-card/operations.generated.js +59 -0
  23. package/dist/products/product-card/operations.graphql +23 -0
  24. package/dist/products/product-card/product-card-localization.d.ts +8 -0
  25. package/dist/{short-videos/short-video-viewer/short-video-product-localization.js → products/product-card/product-card-localization.js} +1 -1
  26. package/dist/products/product-card/types.d.ts +12 -0
  27. package/dist/products/product-card/types.js +1 -0
  28. package/dist/short-videos/short-video-viewer/cmp.attachments.svelte +12 -40
  29. package/dist/short-videos/short-video-viewer/cmp.attachments.svelte.d.ts +1 -1
  30. package/dist/short-videos/short-video-viewer/cmp.short-video-controls.svelte +134 -0
  31. package/dist/short-videos/short-video-viewer/cmp.short-video-controls.svelte.d.ts +19 -0
  32. package/dist/short-videos/short-video-viewer/cmp.short-video-viewer.svelte +45 -20
  33. package/dist/short-videos/short-video-viewer/cmp.short-video-viewer.svelte.d.ts +1 -0
  34. package/dist/short-videos/short-video-viewer/index.d.ts +2 -6
  35. package/dist/short-videos/short-video-viewer/index.js +1 -4
  36. package/dist/short-videos/short-video-viewer/mapper.js +12 -42
  37. package/dist/short-videos/short-video-viewer/operations.generated.d.ts +5 -8
  38. package/dist/short-videos/short-video-viewer/operations.generated.js +98 -94
  39. package/dist/short-videos/short-video-viewer/operations.graphql +2 -42
  40. package/dist/short-videos/short-video-viewer/short-video-attachments-localization.d.ts +3 -7
  41. package/dist/short-videos/short-video-viewer/short-video-attachments-localization.js +0 -14
  42. package/dist/short-videos/short-video-viewer/short-video-viewer-localization.d.ts +3 -3
  43. package/dist/short-videos/short-video-viewer/types.d.ts +9 -28
  44. package/dist/short-videos/short-video-viewer/types.js +1 -1
  45. package/dist/short-videos/short-video-viewer/ui-manager.svelte.d.ts +5 -0
  46. package/dist/short-videos/short-video-viewer/ui-manager.svelte.js +14 -1
  47. package/dist/short-videos/short-videos-player/cmp.short-videos-player.svelte +23 -163
  48. package/dist/short-videos/short-videos-player/cmp.short-videos-player.svelte.d.ts +3 -2
  49. package/dist/short-videos/short-videos-player/controls.svelte +110 -127
  50. package/dist/short-videos/short-videos-player/controls.svelte.d.ts +2 -1
  51. package/dist/short-videos/short-videos-player/index.d.ts +2 -0
  52. package/dist/short-videos/short-videos-player/index.js +6 -3
  53. package/dist/short-videos/short-videos-player/operations.generated.d.ts +5 -8
  54. package/dist/short-videos/short-videos-player/operations.generated.js +77 -73
  55. package/dist/short-videos/short-videos-player/short-videos-player-localization.d.ts +1 -3
  56. package/dist/short-videos/short-videos-player/short-videos-player-localization.js +0 -2
  57. package/dist/short-videos/short-videos-player/short-videos-player-view.svelte +198 -0
  58. package/dist/short-videos/short-videos-player/short-videos-player-view.svelte.d.ts +14 -0
  59. package/dist/short-videos/short-videos-player/types.d.ts +2 -0
  60. package/dist/short-videos/short-videos-player/ui-manager.svelte.d.ts +3 -3
  61. package/dist/short-videos/short-videos-player/ui-manager.svelte.js +8 -8
  62. package/dist/streams/layout/element-views/price-element-view.svelte +5 -4
  63. package/dist/streams/layout/models/mapper.js +8 -17
  64. package/dist/streams/stream-player/cmp.stream-player.svelte +18 -5
  65. package/dist/streams/stream-player/cmp.stream-player.svelte.d.ts +1 -1
  66. package/dist/streams/stream-player/controls.svelte +66 -73
  67. package/dist/streams/stream-player/index.js +2 -2
  68. package/dist/streams/stream-player/stream-overview.svelte +12 -1
  69. package/dist/streams/stream-player/stream-overview.svelte.d.ts +1 -0
  70. package/dist/streams/stream-player/stream-player-localization.d.ts +1 -3
  71. package/dist/streams/stream-player/stream-player-localization.js +0 -2
  72. package/dist/streams/stream-player/ui-manager.svelte.d.ts +3 -2
  73. package/dist/streams/stream-player/ui-manager.svelte.js +9 -5
  74. package/dist/ui/button/resources/button-theme.svelte +1 -0
  75. package/dist/ui/shadow-dom/index.d.ts +2 -1
  76. package/dist/ui/shadow-dom/index.js +2 -1
  77. package/dist/ui/shadow-dom/{shadow-host.d.ts → modal-shadow-host.d.ts} +1 -1
  78. package/dist/ui/shadow-dom/modal-shadow-host.js +21 -0
  79. package/dist/ui/shadow-dom/shadow-root-service.d.ts +1 -0
  80. package/dist/ui/shadow-dom/shadow-root-service.js +23 -0
  81. package/dist/ui/video/cmp.video.svelte +2 -2
  82. package/dist/ui/video/cmp.video.svelte.d.ts +1 -0
  83. package/package.json +1 -1
  84. package/dist/short-videos/short-video-viewer/cmp.ad.svelte +0 -140
  85. package/dist/short-videos/short-video-viewer/cmp.product.svelte +0 -168
  86. package/dist/short-videos/short-video-viewer/cmp.product.svelte.d.ts +0 -14
  87. package/dist/short-videos/short-video-viewer/cmp.short-video-details.svelte +0 -125
  88. package/dist/short-videos/short-video-viewer/cmp.short-video-details.svelte.d.ts +0 -14
  89. package/dist/short-videos/short-video-viewer/cmp.social-interactions.svelte +0 -69
  90. package/dist/short-videos/short-video-viewer/cmp.social-interactions.svelte.d.ts +0 -10
  91. package/dist/short-videos/short-video-viewer/description.svelte +0 -53
  92. package/dist/short-videos/short-video-viewer/description.svelte.d.ts +0 -9
  93. package/dist/short-videos/short-video-viewer/short-video-details-localization.d.ts +0 -14
  94. package/dist/short-videos/short-video-viewer/short-video-details-localization.js +0 -17
  95. package/dist/short-videos/short-video-viewer/short-video-product-localization.d.ts +0 -8
  96. package/dist/short-videos/short-videos-player/action-button.svelte +0 -38
  97. package/dist/short-videos/short-videos-player/action-button.svelte.d.ts +0 -10
  98. package/dist/ui/shadow-dom/shadow-host.js +0 -32
@@ -10,107 +10,15 @@ export const ShortVideoViewerPayloadFragmentDoc = {
10
10
  selections: [
11
11
  { kind: 'Field', name: { kind: 'Name', value: 'id' } },
12
12
  { kind: 'Field', name: { kind: 'Name', value: 'enableSocialInteractions' } },
13
- {
14
- kind: 'Field',
15
- name: { kind: 'Name', value: 'postHeading' },
16
- selectionSet: {
17
- kind: 'SelectionSet',
18
- selections: [
19
- { kind: 'Field', name: { kind: 'Name', value: 'sourceImage' } },
20
- { kind: 'Field', name: { kind: 'Name', value: 'sourceName' } },
21
- { kind: 'Field', name: { kind: 'Name', value: 'postDisplayDate' } },
22
- { kind: 'Field', name: { kind: 'Name', value: 'postViewsCount' } }
23
- ]
24
- }
25
- },
26
13
  {
27
14
  kind: 'Field',
28
15
  name: { kind: 'Name', value: 'allProducts' },
29
- selectionSet: {
30
- kind: 'SelectionSet',
31
- selections: [
32
- {
33
- kind: 'Field',
34
- name: { kind: 'Name', value: 'media' },
35
- selectionSet: {
36
- kind: 'SelectionSet',
37
- selections: [
38
- { kind: 'Field', name: { kind: 'Name', value: 'url' } },
39
- { kind: 'Field', name: { kind: 'Name', value: 'thumbnailUrl' } },
40
- { kind: 'Field', name: { kind: 'Name', value: 'type' } }
41
- ]
42
- }
43
- },
44
- { kind: 'Field', name: { kind: 'Name', value: 'title' } },
45
- { kind: 'Field', name: { kind: 'Name', value: 'id' } },
46
- { kind: 'Field', name: { kind: 'Name', value: 'link' } },
47
- { kind: 'Field', name: { kind: 'Name', value: 'shortDescription' } },
48
- {
49
- kind: 'Field',
50
- name: { kind: 'Name', value: 'priceAndAvailability' },
51
- selectionSet: {
52
- kind: 'SelectionSet',
53
- selections: [
54
- { kind: 'Field', name: { kind: 'Name', value: 'currency' } },
55
- { kind: 'Field', name: { kind: 'Name', value: 'price' } },
56
- {
57
- kind: 'Field',
58
- name: { kind: 'Name', value: 'productSalePrices' },
59
- selectionSet: {
60
- kind: 'SelectionSet',
61
- selections: [
62
- { kind: 'Field', name: { kind: 'Name', value: 'salePrice' } },
63
- { kind: 'Field', name: { kind: 'Name', value: 'salePriceEffectiveDateFrom' } },
64
- { kind: 'Field', name: { kind: 'Name', value: 'salePriceEffectiveDateTo' } }
65
- ]
66
- }
67
- }
68
- ]
69
- }
70
- }
71
- ]
72
- }
16
+ selectionSet: { kind: 'SelectionSet', selections: [{ kind: 'FragmentSpread', name: { kind: 'Name', value: 'ProductCardPayloadFragment' } }] }
73
17
  },
74
18
  {
75
19
  kind: 'Field',
76
20
  name: { kind: 'Name', value: 'ad' },
77
- selectionSet: {
78
- kind: 'SelectionSet',
79
- selections: [
80
- { kind: 'Field', name: { kind: 'Name', value: 'id' } },
81
- { kind: 'Field', name: { kind: 'Name', value: 'title' } },
82
- { kind: 'Field', name: { kind: 'Name', value: 'description' } },
83
- { kind: 'Field', name: { kind: 'Name', value: 'price' } },
84
- { kind: 'Field', name: { kind: 'Name', value: 'currency' } },
85
- {
86
- kind: 'Field',
87
- name: { kind: 'Name', value: 'ctaButton' },
88
- selectionSet: {
89
- kind: 'SelectionSet',
90
- selections: [
91
- { kind: 'Field', name: { kind: 'Name', value: 'background' } },
92
- { kind: 'Field', name: { kind: 'Name', value: 'textColor' } },
93
- { kind: 'Field', name: { kind: 'Name', value: 'text' } },
94
- { kind: 'Field', name: { kind: 'Name', value: 'url' } },
95
- { kind: 'Field', name: { kind: 'Name', value: 'border' } }
96
- ]
97
- }
98
- },
99
- { kind: 'Field', name: { kind: 'Name', value: 'type' } },
100
- {
101
- kind: 'Field',
102
- name: { kind: 'Name', value: 'media' },
103
- selectionSet: {
104
- kind: 'SelectionSet',
105
- selections: [
106
- { kind: 'Field', name: { kind: 'Name', value: 'url' } },
107
- { kind: 'Field', name: { kind: 'Name', value: 'thumbnailUrl' } },
108
- { kind: 'Field', name: { kind: 'Name', value: 'type' } }
109
- ]
110
- }
111
- }
112
- ]
113
- }
21
+ selectionSet: { kind: 'SelectionSet', selections: [{ kind: 'FragmentSpread', name: { kind: 'Name', value: 'AdCardPayloadFragment' } }] }
114
22
  },
115
23
  {
116
24
  kind: 'Field',
@@ -160,6 +68,102 @@ export const ShortVideoViewerPayloadFragmentDoc = {
160
68
  }
161
69
  ]
162
70
  }
71
+ },
72
+ {
73
+ kind: 'FragmentDefinition',
74
+ name: { kind: 'Name', value: 'ProductCardPayloadFragment' },
75
+ typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Product' } },
76
+ selectionSet: {
77
+ kind: 'SelectionSet',
78
+ selections: [
79
+ { kind: 'Field', name: { kind: 'Name', value: 'id' } },
80
+ { kind: 'Field', name: { kind: 'Name', value: 'title' } },
81
+ { kind: 'Field', name: { kind: 'Name', value: 'shortDescription' } },
82
+ { kind: 'Field', name: { kind: 'Name', value: 'link' } },
83
+ {
84
+ kind: 'Field',
85
+ name: { kind: 'Name', value: 'media' },
86
+ selectionSet: {
87
+ kind: 'SelectionSet',
88
+ selections: [
89
+ { kind: 'Field', name: { kind: 'Name', value: 'url' } },
90
+ { kind: 'Field', name: { kind: 'Name', value: 'thumbnailUrl' } },
91
+ { kind: 'Field', name: { kind: 'Name', value: 'type' } }
92
+ ]
93
+ }
94
+ },
95
+ {
96
+ kind: 'Field',
97
+ name: { kind: 'Name', value: 'brand' },
98
+ selectionSet: { kind: 'SelectionSet', selections: [{ kind: 'Field', name: { kind: 'Name', value: 'name' } }] }
99
+ },
100
+ {
101
+ kind: 'Field',
102
+ name: { kind: 'Name', value: 'priceAndAvailability' },
103
+ selectionSet: {
104
+ kind: 'SelectionSet',
105
+ selections: [
106
+ { kind: 'Field', name: { kind: 'Name', value: 'currency' } },
107
+ { kind: 'Field', name: { kind: 'Name', value: 'price' } },
108
+ {
109
+ kind: 'Field',
110
+ name: { kind: 'Name', value: 'productSalePrices' },
111
+ selectionSet: {
112
+ kind: 'SelectionSet',
113
+ selections: [
114
+ { kind: 'Field', name: { kind: 'Name', value: 'salePrice' } },
115
+ { kind: 'Field', name: { kind: 'Name', value: 'salePriceEffectiveDateFrom' } },
116
+ { kind: 'Field', name: { kind: 'Name', value: 'salePriceEffectiveDateTo' } }
117
+ ]
118
+ }
119
+ }
120
+ ]
121
+ }
122
+ }
123
+ ]
124
+ }
125
+ },
126
+ {
127
+ kind: 'FragmentDefinition',
128
+ name: { kind: 'Name', value: 'AdCardPayloadFragment' },
129
+ typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Ad' } },
130
+ selectionSet: {
131
+ kind: 'SelectionSet',
132
+ selections: [
133
+ { kind: 'Field', name: { kind: 'Name', value: 'id' } },
134
+ { kind: 'Field', name: { kind: 'Name', value: 'title' } },
135
+ { kind: 'Field', name: { kind: 'Name', value: 'description' } },
136
+ { kind: 'Field', name: { kind: 'Name', value: 'price' } },
137
+ { kind: 'Field', name: { kind: 'Name', value: 'currency' } },
138
+ {
139
+ kind: 'Field',
140
+ name: { kind: 'Name', value: 'ctaButton' },
141
+ selectionSet: {
142
+ kind: 'SelectionSet',
143
+ selections: [
144
+ { kind: 'Field', name: { kind: 'Name', value: 'background' } },
145
+ { kind: 'Field', name: { kind: 'Name', value: 'textColor' } },
146
+ { kind: 'Field', name: { kind: 'Name', value: 'text' } },
147
+ { kind: 'Field', name: { kind: 'Name', value: 'url' } },
148
+ { kind: 'Field', name: { kind: 'Name', value: 'border' } }
149
+ ]
150
+ }
151
+ },
152
+ { kind: 'Field', name: { kind: 'Name', value: 'type' } },
153
+ {
154
+ kind: 'Field',
155
+ name: { kind: 'Name', value: 'media' },
156
+ selectionSet: {
157
+ kind: 'SelectionSet',
158
+ selections: [
159
+ { kind: 'Field', name: { kind: 'Name', value: 'url' } },
160
+ { kind: 'Field', name: { kind: 'Name', value: 'thumbnailUrl' } },
161
+ { kind: 'Field', name: { kind: 'Name', value: 'type' } }
162
+ ]
163
+ }
164
+ }
165
+ ]
166
+ }
163
167
  }
164
168
  ]
165
169
  };
@@ -1,51 +1,11 @@
1
1
  fragment ShortVideoViewerPayloadFragment on Post {
2
2
  id
3
3
  enableSocialInteractions
4
- postHeading {
5
- sourceImage
6
- sourceName
7
- postDisplayDate
8
- postViewsCount
9
- }
10
4
  allProducts {
11
- media {
12
- url
13
- thumbnailUrl
14
- type
15
- }
16
- title
17
- id
18
- link
19
- shortDescription
20
- priceAndAvailability {
21
- currency
22
- price
23
- productSalePrices {
24
- salePrice
25
- salePriceEffectiveDateFrom
26
- salePriceEffectiveDateTo
27
- }
28
- }
5
+ ...ProductCardPayloadFragment
29
6
  }
30
7
  ad {
31
- id
32
- title
33
- description
34
- price
35
- currency
36
- ctaButton {
37
- background
38
- textColor
39
- text
40
- url
41
- border
42
- }
43
- type
44
- media {
45
- url
46
- thumbnailUrl
47
- type
48
- }
8
+ ...AdCardPayloadFragment
49
9
  }
50
10
  postData {
51
11
  media {
@@ -1,13 +1,9 @@
1
1
  import { type Locale } from '../../core/locale';
2
- import type { IShortVideoProductLocalization } from './short-video-product-localization';
2
+ import type { IProductCardLocalization } from '../../products/product-card/product-card-localization';
3
3
  export interface IShortVideoAttachmentsLocalization {
4
- productsSection?: string;
5
- offersSection?: string;
6
- productLocalization?: IShortVideoProductLocalization;
4
+ productLocalization?: IProductCardLocalization | Locale;
7
5
  }
8
6
  export declare class ShortVideoAttachmentsLocalization {
9
- productsSection: string;
10
- offersSection: string;
11
- productLocalization: IShortVideoProductLocalization | Locale;
7
+ productLocalization: IProductCardLocalization | Locale;
12
8
  constructor(init: IShortVideoAttachmentsLocalization | Locale);
13
9
  }
@@ -1,21 +1,7 @@
1
1
  import { isLocale } from '../../core/locale';
2
2
  export class ShortVideoAttachmentsLocalization {
3
- productsSection;
4
- offersSection;
5
3
  productLocalization;
6
4
  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
5
  this.productLocalization = isLocale(init) ? init : init.productLocalization || 'en';
10
6
  }
11
7
  }
12
- const loc = {
13
- productsSection: {
14
- en: 'Products',
15
- no: 'Produkter'
16
- },
17
- offersSection: {
18
- en: 'Offers',
19
- no: 'Tilbud'
20
- }
21
- };
@@ -1,14 +1,14 @@
1
1
  import { type Locale } from '../../core/locale';
2
+ import type { IProductCardLocalization } from '../../products/product-card/product-card-localization';
2
3
  import type { ITimeAgoLocalization } from '../../ui/time-ago';
3
- import type { IShortVideoProductLocalization } from './short-video-product-localization';
4
4
  export interface IShortVideoViewerLocalization {
5
5
  viewsCount?: (count: number) => string;
6
6
  timeAgoLocalization?: ITimeAgoLocalization | Locale;
7
- productLocalization?: IShortVideoProductLocalization | Locale;
7
+ productLocalization?: IProductCardLocalization | Locale;
8
8
  }
9
9
  export declare class ShortVideoViewerLocalization {
10
10
  viewsCount: (count: number) => string;
11
11
  timeAgoLocalization: ITimeAgoLocalization | Locale;
12
- productLocalization: IShortVideoProductLocalization | Locale;
12
+ productLocalization: IProductCardLocalization | Locale;
13
13
  constructor(init: IShortVideoViewerLocalization | Locale);
14
14
  }
@@ -1,4 +1,5 @@
1
- import { AdType, type Currency } from '../../core/enums';
1
+ import type { AdCardModel } from '../../ads/ad-card';
2
+ import type { ProductCardModel } from '../../products/product-card';
2
3
  export type ShortVideoViewerModel = {
3
4
  id: string;
4
5
  media: {
@@ -11,8 +12,9 @@ export type ShortVideoViewerModel = {
11
12
  };
12
13
  text?: string | null;
13
14
  heading: ShortVideoViewerHeadingModel | null;
14
- products: ShortVideoViewerProductModel[];
15
- ad: ShortVideoViewerAdModel | null;
15
+ enableSocialInteractions: boolean;
16
+ products: ProductCardModel[];
17
+ ad: AdCardModel | null;
16
18
  };
17
19
  export type ShortVideoViewerHeadingModel = {
18
20
  image: string | null;
@@ -20,29 +22,8 @@ export type ShortVideoViewerHeadingModel = {
20
22
  displayDate: string;
21
23
  viewsCount: number;
22
24
  };
23
- export type ShortVideoViewerAdModel = {
24
- id: string;
25
- type: AdType;
26
- image: string | null;
27
- title: string;
28
- description: string | null;
29
- price: number | null;
30
- currency: Currency | null;
31
- ctaButton: {
32
- background: string;
33
- textColor: string;
34
- text: string;
35
- url: string;
36
- border: string;
37
- } | null;
38
- };
39
- export type ShortVideoViewerProductModel = {
40
- id: string;
41
- title: string;
42
- image: string | null;
43
- link: string | null;
44
- price: number;
45
- currency: Currency;
46
- salePrice: number | null;
47
- shortDescription?: string | null;
25
+ export type ShortVideoSocialInteractions = {
26
+ isLiked: (shortVideoId: string) => boolean;
27
+ onToggleLike: (shortVideoId: string) => void;
28
+ onShare: (shortVideoId: string) => void;
48
29
  };
@@ -1 +1 @@
1
- import { AdType } from '../../core/enums';
1
+ export {};
@@ -2,11 +2,16 @@ export declare class ShortVideoViewerUiManager {
2
2
  readonly globalCssVariables: string;
3
3
  readonly showActionsInsideFrame: boolean;
4
4
  readonly showAttachments: boolean;
5
+ readonly showControls: boolean;
5
6
  private readonly buttonSize;
6
7
  private actionsPanelWidth;
7
8
  private availableSideSpace;
9
+ private canShowControls;
8
10
  private canShowAttachments;
11
+ private enableAttachments;
9
12
  updateActionsPanelWidth: (value: number) => void;
10
13
  updateAvailableSideSpace: (value: number) => void;
11
14
  updateCanShowAttachments: (value: boolean) => void;
15
+ updateCanShowControls: (value: boolean) => void;
16
+ toggleEnableAttachments: () => void;
12
17
  }
@@ -7,13 +7,20 @@ export class ShortVideoViewerUiManager {
7
7
  return this.actionsPanelWidth + 40 > this.availableSideSpace;
8
8
  });
9
9
  showAttachments = $derived.by(() => {
10
- return this.canShowAttachments;
10
+ return this.canShowAttachments && this.enableAttachments;
11
+ });
12
+ showControls = $derived.by(() => {
13
+ return this.canShowControls;
11
14
  });
12
15
  buttonSize = 40;
13
16
  actionsPanelWidth = $state(0);
14
17
  availableSideSpace = $state(0);
15
18
  // is provided from the calling side
19
+ canShowControls = $state(true);
20
+ // is provided from the calling side
16
21
  canShowAttachments = $state(true);
22
+ // managed internally by component
23
+ enableAttachments = $state(true);
17
24
  updateActionsPanelWidth = (value) => {
18
25
  this.actionsPanelWidth = value;
19
26
  };
@@ -23,4 +30,10 @@ export class ShortVideoViewerUiManager {
23
30
  updateCanShowAttachments = (value) => {
24
31
  this.canShowAttachments = value;
25
32
  };
33
+ updateCanShowControls = (value) => {
34
+ this.canShowControls = value;
35
+ };
36
+ toggleEnableAttachments = () => {
37
+ this.enableAttachments = !this.enableAttachments;
38
+ };
26
39
  }
@@ -1,168 +1,28 @@
1
- <script lang="ts">var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
1
+ <script lang="ts">import {} from '../../core/locale';
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
+ import { mount, unmount } from 'svelte';
6
+ let { input, localization, showStreamsCloudWatermark, on } = $props();
7
+ const initHost = (node) => {
8
+ const shadowRoot = createShadowRoot(node);
9
+ const mounted = mount(ShortVideosPlayerView, {
10
+ target: shadowRoot,
11
+ props: {
12
+ input,
13
+ localization,
14
+ showStreamsCloudWatermark,
15
+ on
16
+ }
8
17
  });
9
- };
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';
14
- import { PlayerBuffer, PlayerSlider } from '../../ui/player';
15
- import { SpotlightLayout } from '../../ui/spotlight-layout';
16
- import { SwipeIndicator } from '../../ui/swipe-indicator';
17
- import { default as Controls } from './controls.svelte';
18
- import { GetShortVideosDocument } from './operations.generated';
19
- import { ShortVideosPlayerLocalization } from './short-videos-player-localization';
20
- import { ShortVideosPlayerUiManager } from './ui-manager.svelte';
21
- import { onMount, untrack } from 'svelte';
22
- let { input, localization: localizationInit, on } = $props();
23
- const localization = $derived(new ShortVideosPlayerLocalization(localizationInit));
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
- });
72
- const uiManager = new ShortVideosPlayerUiManager();
73
- onMount(() => __awaiter(void 0, void 0, void 0, function* () {
74
- uiManager.detailsCollapsed = window && window.innerWidth < window.innerHeight;
75
- }));
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);
18
+ return {
19
+ destroy: () => {
20
+ unmount(mounted);
21
+ }
83
22
  };
84
- node.addEventListener('touchstart', markAsTouched);
85
- node.addEventListener('wheel', markAsTouched);
86
- node.addEventListener('click', markAsTouched);
87
- node.addEventListener('keypress', markAsTouched);
88
- };
89
- const handleDimensionsChanged = (dimensions) => {
90
- uiManager.updateDimensions({
91
- mainViewColumnWidth: dimensions.mainSceneWidth,
92
- viewTotalWidth: dimensions.totalWidth
93
- });
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
23
  };
99
24
  </script>
100
25
 
101
- <svelte:document onkeydown={(e) => handleEsc(e, onPlayerClose)} />
102
-
103
- <div class="short-videos-player-container">
104
- <div class="short-videos-player" style={uiManager.globalCssVariables}>
105
- {#if buffer}
106
- <SpotlightLayout ratio={9 / 16} on={{ dimensionsChanged: handleDimensionsChanged }}>
107
- <div class="short-videos-player__content" use:contentMounted>
108
- <PlayerSlider buffer={buffer}>
109
- {#snippet children({ item })}
110
- <ShortVideoViewer
111
- model={item}
112
- autoplay="on-appearance"
113
- showAttachments={uiManager.showShortVideoOverlay}
114
- localization={localization.shortVideoViewerLocalization} />
115
- {/snippet}
116
- </PlayerSlider>
117
- {#if uiManager.isMobileView && buffer.loaded.length > 1 && !everTouched}
118
- <SwipeIndicator localization={localization.swipeIndicatorLocalization} />
119
- {/if}
120
- </div>
121
- </SpotlightLayout>
122
- <Controls buffer={buffer} uiManager={uiManager} localization={localization} on={{ closePlayer: () => onPlayerClose() }} />
123
- {:else}
124
- <Loading positionFixedCenter={true} timeout={1000} />
125
- {/if}
126
- </div>
127
- </div>
128
-
129
- <style>@keyframes fadeIn {
130
- 0% {
131
- opacity: 1;
132
- }
133
- 50% {
134
- opacity: 0.4;
135
- }
136
- 100% {
137
- opacity: 1;
138
- }
139
- }
140
- .short-videos-player-container {
141
- width: 100%;
142
- min-width: 100%;
143
- max-width: 100%;
144
- height: 100%;
145
- min-height: 100%;
146
- max-height: 100%;
147
- container-type: inline-size;
148
- display: flex;
149
- position: relative;
150
- background: #000000;
151
- }
152
-
153
- .short-videos-player {
154
- display: flex;
155
- flex: 1;
156
- padding: 0.625rem 0;
157
- /* Set 'container-type: inline-size;' to reference container*/
158
- }
159
- @container (width < 576px) {
160
- .short-videos-player {
161
- padding: 0;
162
- }
163
- }
164
- .short-videos-player__content {
165
- width: 100%;
166
- height: 100%;
167
- --short-video-viewer--actions-panel--bottom: 5rem;
168
- }</style>
26
+ {#key input}
27
+ <div class="short-videos-player-host" use:initHost></div>
28
+ {/key}
@@ -1,9 +1,10 @@
1
- import type { Locale } from '../../core/locale';
1
+ import { type Locale } from '../../core/locale';
2
2
  import { type IShortVideosPlayerLocalization } from './short-videos-player-localization';
3
3
  import type { PlayerInput } from './types';
4
4
  type Props = {
5
5
  input: PlayerInput;
6
- localization: IShortVideosPlayerLocalization | Locale;
6
+ localization?: IShortVideosPlayerLocalization | Locale;
7
+ showStreamsCloudWatermark?: boolean;
7
8
  on?: {
8
9
  closePlayer?: () => void;
9
10
  };