@streamscloud/embeddable 3.4.2 → 5.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.
- package/dist/ads/ad-card/cmp.ad-card.svelte +220 -0
- package/dist/{short-videos/short-video-viewer/cmp.ad.svelte.d.ts → ads/ad-card/cmp.ad-card.svelte.d.ts} +3 -2
- package/dist/ads/ad-card/index.d.ts +3 -0
- package/dist/ads/ad-card/index.js +2 -0
- package/dist/ads/ad-card/mapper.d.ts +3 -0
- package/dist/ads/ad-card/mapper.js +14 -0
- package/dist/ads/ad-card/operations.generated.d.ts +24 -0
- package/dist/ads/ad-card/operations.generated.js +48 -0
- package/dist/ads/ad-card/operations.graphql +21 -0
- package/dist/ads/ad-card/types.d.ts +18 -0
- package/dist/ads/ad-card/types.js +1 -0
- package/dist/core/locale.d.ts +3 -0
- package/dist/products/price-helper.d.ts +18 -3
- package/dist/products/price-helper.js +9 -6
- package/dist/products/product-card/cmp.product-card.svelte +219 -0
- package/dist/products/product-card/cmp.product-card.svelte.d.ts +15 -0
- package/dist/products/product-card/index.d.ts +4 -0
- package/dist/products/product-card/index.js +2 -0
- package/dist/products/product-card/mapper.d.ts +3 -0
- package/dist/products/product-card/mapper.js +22 -0
- package/dist/products/product-card/operations.generated.d.ts +26 -0
- package/dist/products/product-card/operations.generated.js +59 -0
- package/dist/products/product-card/operations.graphql +23 -0
- package/dist/products/product-card/product-card-localization.d.ts +8 -0
- package/dist/{short-videos/short-video-viewer/short-video-product-localization.js → products/product-card/product-card-localization.js} +1 -1
- package/dist/products/product-card/types.d.ts +12 -0
- package/dist/products/product-card/types.js +1 -0
- package/dist/short-videos/short-video-viewer/cmp.attachments.svelte +12 -40
- package/dist/short-videos/short-video-viewer/cmp.attachments.svelte.d.ts +1 -1
- package/dist/short-videos/short-video-viewer/cmp.short-video-controls.svelte +145 -0
- package/dist/short-videos/short-video-viewer/cmp.short-video-controls.svelte.d.ts +19 -0
- package/dist/short-videos/short-video-viewer/cmp.short-video-viewer.svelte +46 -20
- package/dist/short-videos/short-video-viewer/cmp.short-video-viewer.svelte.d.ts +4 -2
- package/dist/short-videos/short-video-viewer/index.d.ts +3 -7
- package/dist/short-videos/short-video-viewer/index.js +2 -5
- package/dist/short-videos/short-video-viewer/mapper.d.ts +1 -1
- package/dist/short-videos/short-video-viewer/mapper.js +25 -22
- package/dist/short-videos/short-video-viewer/operations.generated.d.ts +6 -8
- package/dist/short-videos/short-video-viewer/operations.generated.js +10 -17
- package/dist/short-videos/short-video-viewer/operations.graphql +8 -10
- package/dist/short-videos/short-video-viewer/short-video-attachments-localization.d.ts +3 -7
- package/dist/short-videos/short-video-viewer/short-video-attachments-localization.js +0 -14
- package/dist/short-videos/short-video-viewer/short-video-viewer-localization.d.ts +3 -3
- package/dist/short-videos/short-video-viewer/types.d.ts +23 -13
- package/dist/short-videos/short-video-viewer/ui-manager.svelte.d.ts +5 -0
- package/dist/short-videos/short-video-viewer/ui-manager.svelte.js +15 -2
- package/dist/short-videos/short-videos-player/cmp.short-videos-player.svelte +25 -163
- package/dist/short-videos/short-videos-player/cmp.short-videos-player.svelte.d.ts +7 -2
- package/dist/short-videos/short-videos-player/controls.svelte +125 -125
- package/dist/short-videos/short-videos-player/controls.svelte.d.ts +4 -2
- package/dist/short-videos/short-videos-player/index.d.ts +2 -0
- package/dist/short-videos/short-videos-player/index.js +12 -3
- package/dist/short-videos/short-videos-player/operations.generated.d.ts +6 -8
- package/dist/short-videos/short-videos-player/operations.generated.js +10 -17
- package/dist/short-videos/short-videos-player/short-videos-player-localization.d.ts +1 -3
- package/dist/short-videos/short-videos-player/short-videos-player-localization.js +0 -2
- package/dist/short-videos/short-videos-player/short-videos-player-view.svelte +211 -0
- package/dist/short-videos/short-videos-player/short-videos-player-view.svelte.d.ts +18 -0
- package/dist/short-videos/short-videos-player/types.d.ts +10 -8
- package/dist/short-videos/short-videos-player/ui-manager.svelte.d.ts +4 -3
- package/dist/short-videos/short-videos-player/ui-manager.svelte.js +9 -8
- package/dist/streams/layout/element-views/price-element-view.svelte +5 -4
- package/dist/streams/layout/models/mapper.js +10 -18
- package/dist/streams/layout/models/stream-layout-short-video-model.d.ts +1 -0
- package/dist/streams/stream-player/cmp.stream-player.svelte +23 -8
- package/dist/streams/stream-player/cmp.stream-player.svelte.d.ts +3 -1
- package/dist/streams/stream-player/controls.svelte +87 -74
- package/dist/streams/stream-player/controls.svelte.d.ts +2 -0
- package/dist/streams/stream-player/index.d.ts +2 -0
- package/dist/streams/stream-player/index.js +4 -3
- package/dist/streams/stream-player/mapper.d.ts +1 -1
- package/dist/streams/stream-player/mapper.js +1 -1
- package/dist/streams/stream-player/stream-overview.svelte +12 -1
- package/dist/streams/stream-player/stream-overview.svelte.d.ts +1 -0
- package/dist/streams/stream-player/stream-player-localization.d.ts +1 -3
- package/dist/streams/stream-player/stream-player-localization.js +0 -2
- package/dist/streams/stream-player/ui-manager.svelte.d.ts +4 -2
- package/dist/streams/stream-player/ui-manager.svelte.js +10 -5
- package/dist/ui/button/resources/button-theme.svelte +1 -0
- package/dist/ui/line-clamp/cmp.line-clamp.svelte +35 -13
- package/dist/ui/player/cmp.player-slider.svelte +74 -9
- package/dist/ui/progress/cmp.progress.svelte +4 -1
- package/dist/ui/seek-bar/cmp.seek-bar.svelte +112 -28
- package/dist/ui/seek-bar/cmp.seek-bar.svelte.d.ts +3 -0
- package/dist/ui/shadow-dom/index.d.ts +2 -1
- package/dist/ui/shadow-dom/index.js +2 -1
- package/dist/ui/shadow-dom/{shadow-host.d.ts → modal-shadow-host.d.ts} +1 -1
- package/dist/ui/shadow-dom/modal-shadow-host.js +21 -0
- package/dist/ui/shadow-dom/shadow-root-service.d.ts +1 -0
- package/dist/ui/shadow-dom/shadow-root-service.js +23 -0
- package/dist/ui/video/cmp.video.svelte +46 -38
- package/dist/ui/video/cmp.video.svelte.d.ts +3 -0
- package/dist/ui/video/index.d.ts +1 -0
- package/dist/ui/video/index.js +1 -0
- package/dist/ui/video/types.d.ts +4 -0
- package/dist/ui/video/types.js +5 -0
- package/package.json +5 -1
- package/dist/short-videos/short-video-viewer/cmp.ad.svelte +0 -140
- package/dist/short-videos/short-video-viewer/cmp.product.svelte +0 -168
- package/dist/short-videos/short-video-viewer/cmp.product.svelte.d.ts +0 -14
- package/dist/short-videos/short-video-viewer/cmp.short-video-details.svelte +0 -125
- package/dist/short-videos/short-video-viewer/cmp.short-video-details.svelte.d.ts +0 -14
- package/dist/short-videos/short-video-viewer/cmp.social-interactions.svelte +0 -69
- package/dist/short-videos/short-video-viewer/cmp.social-interactions.svelte.d.ts +0 -10
- package/dist/short-videos/short-video-viewer/description.svelte +0 -53
- package/dist/short-videos/short-video-viewer/description.svelte.d.ts +0 -9
- package/dist/short-videos/short-video-viewer/short-video-details-localization.d.ts +0 -14
- package/dist/short-videos/short-video-viewer/short-video-details-localization.js +0 -17
- package/dist/short-videos/short-video-viewer/short-video-product-localization.d.ts +0 -8
- package/dist/short-videos/short-videos-player/action-button.svelte +0 -38
- package/dist/short-videos/short-videos-player/action-button.svelte.d.ts +0 -10
- package/dist/ui/shadow-dom/shadow-host.js +0 -32
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MediaType } from '../../core/enums';
|
|
2
2
|
import { getMediaItemImageUrl } from '../../core/media';
|
|
3
3
|
import { shouldUseSalePrice } from '../../products/price-helper';
|
|
4
|
-
export const
|
|
4
|
+
export const mapToShortVideoViewerModel = (payload) => {
|
|
5
5
|
const mediaBlob = payload.postData.media[0];
|
|
6
6
|
return {
|
|
7
7
|
id: payload.id,
|
|
@@ -13,25 +13,20 @@ export const mapShortVideoViewerModel = (payload) => {
|
|
|
13
13
|
thumbnailUrl: mediaBlob.thumbnailUrl
|
|
14
14
|
},
|
|
15
15
|
text: payload.postData.shortVideoData.text,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
viewsCount: payload.postHeading.postViewsCount
|
|
21
|
-
},
|
|
22
|
-
ad: payload.ad ? mapToShortVideoViewerAdModel(payload.ad) : null,
|
|
23
|
-
products: payload.allProducts.map(mapToShortVideoViewerProductModel)
|
|
16
|
+
enableSocialInteractions: payload.enableSocialInteractions,
|
|
17
|
+
heading: null,
|
|
18
|
+
ad: payload.ad ? mapToShortVideoAdCardModel(payload.ad) : null,
|
|
19
|
+
products: payload.allProducts.map((x) => mapToShortVideoProductCard(x))
|
|
24
20
|
// uncomment if you want to test many products behavior
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
])*/
|
|
21
|
+
// .flatMap(x =>
|
|
22
|
+
// Array.from({ length: 20 }, (_, i) => ({
|
|
23
|
+
// ...x,
|
|
24
|
+
// id: x.id + String(i + 1)
|
|
25
|
+
// }))
|
|
26
|
+
// )
|
|
32
27
|
};
|
|
33
28
|
};
|
|
34
|
-
const
|
|
29
|
+
const mapToShortVideoAdCardModel = (payload) => {
|
|
35
30
|
return {
|
|
36
31
|
id: payload.id,
|
|
37
32
|
type: payload.type,
|
|
@@ -39,20 +34,28 @@ const mapToShortVideoViewerAdModel = (payload) => {
|
|
|
39
34
|
title: payload.title,
|
|
40
35
|
description: payload.description,
|
|
41
36
|
price: payload.price,
|
|
37
|
+
priceInfoLabel: payload.priceInfo,
|
|
42
38
|
currency: payload.currency,
|
|
43
39
|
ctaButton: payload.ctaButton
|
|
44
40
|
};
|
|
45
41
|
};
|
|
46
|
-
const
|
|
47
|
-
const effectiveSalePrice = payload.priceAndAvailability.productSalePrices?.find((x) => shouldUseSalePrice(
|
|
42
|
+
const mapToShortVideoProductCard = (payload, referenceDate) => {
|
|
43
|
+
const effectiveSalePrice = payload.priceAndAvailability.productSalePrices?.find((x) => shouldUseSalePrice({
|
|
44
|
+
price: payload.priceAndAvailability.price,
|
|
45
|
+
salePrice: x.salePrice,
|
|
46
|
+
effectiveDateFrom: x.salePriceEffectiveDateFrom,
|
|
47
|
+
effectiveDateTo: x.salePriceEffectiveDateTo,
|
|
48
|
+
referenceDate
|
|
49
|
+
}));
|
|
48
50
|
return {
|
|
49
51
|
id: payload.id,
|
|
50
52
|
title: payload.title,
|
|
51
|
-
|
|
53
|
+
shortDescription: payload.shortDescription,
|
|
52
54
|
link: payload.link,
|
|
55
|
+
brandName: payload.brand?.name || null,
|
|
56
|
+
image: getMediaItemImageUrl(payload.media[0]),
|
|
53
57
|
currency: payload.priceAndAvailability.currency,
|
|
54
58
|
price: payload.priceAndAvailability.price,
|
|
55
|
-
salePrice: effectiveSalePrice?.salePrice ?? null
|
|
56
|
-
shortDescription: payload.shortDescription ?? null
|
|
59
|
+
salePrice: effectiveSalePrice?.salePrice ?? null
|
|
57
60
|
};
|
|
58
61
|
};
|
|
@@ -3,22 +3,19 @@ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-
|
|
|
3
3
|
export type ShortVideoViewerPayloadFragment = {
|
|
4
4
|
id: string;
|
|
5
5
|
enableSocialInteractions: boolean;
|
|
6
|
-
postHeading: {
|
|
7
|
-
sourceImage: string | null;
|
|
8
|
-
sourceName: string;
|
|
9
|
-
postDisplayDate: any;
|
|
10
|
-
postViewsCount: number;
|
|
11
|
-
};
|
|
12
6
|
allProducts: Array<{
|
|
13
|
-
title: string;
|
|
14
7
|
id: string;
|
|
15
|
-
|
|
8
|
+
title: string;
|
|
16
9
|
shortDescription: string | null;
|
|
10
|
+
link: string | null;
|
|
17
11
|
media: Array<{
|
|
18
12
|
url: string;
|
|
19
13
|
thumbnailUrl: string | null;
|
|
20
14
|
type: SchemaTypes.MediaType;
|
|
21
15
|
}>;
|
|
16
|
+
brand: {
|
|
17
|
+
name: string;
|
|
18
|
+
} | null;
|
|
22
19
|
priceAndAvailability: {
|
|
23
20
|
currency: SchemaTypes.Currency;
|
|
24
21
|
price: number;
|
|
@@ -34,6 +31,7 @@ export type ShortVideoViewerPayloadFragment = {
|
|
|
34
31
|
title: string;
|
|
35
32
|
description: string | null;
|
|
36
33
|
price: number | null;
|
|
34
|
+
priceInfo: string | null;
|
|
37
35
|
currency: SchemaTypes.Currency | null;
|
|
38
36
|
type: SchemaTypes.AdType;
|
|
39
37
|
ctaButton: {
|
|
@@ -10,25 +10,16 @@ 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
16
|
selectionSet: {
|
|
30
17
|
kind: 'SelectionSet',
|
|
31
18
|
selections: [
|
|
19
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
|
|
20
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'title' } },
|
|
21
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'shortDescription' } },
|
|
22
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'link' } },
|
|
32
23
|
{
|
|
33
24
|
kind: 'Field',
|
|
34
25
|
name: { kind: 'Name', value: 'media' },
|
|
@@ -41,10 +32,11 @@ export const ShortVideoViewerPayloadFragmentDoc = {
|
|
|
41
32
|
]
|
|
42
33
|
}
|
|
43
34
|
},
|
|
44
|
-
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
35
|
+
{
|
|
36
|
+
kind: 'Field',
|
|
37
|
+
name: { kind: 'Name', value: 'brand' },
|
|
38
|
+
selectionSet: { kind: 'SelectionSet', selections: [{ kind: 'Field', name: { kind: 'Name', value: 'name' } }] }
|
|
39
|
+
},
|
|
48
40
|
{
|
|
49
41
|
kind: 'Field',
|
|
50
42
|
name: { kind: 'Name', value: 'priceAndAvailability' },
|
|
@@ -81,6 +73,7 @@ export const ShortVideoViewerPayloadFragmentDoc = {
|
|
|
81
73
|
{ kind: 'Field', name: { kind: 'Name', value: 'title' } },
|
|
82
74
|
{ kind: 'Field', name: { kind: 'Name', value: 'description' } },
|
|
83
75
|
{ kind: 'Field', name: { kind: 'Name', value: 'price' } },
|
|
76
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'priceInfo' } },
|
|
84
77
|
{ kind: 'Field', name: { kind: 'Name', value: 'currency' } },
|
|
85
78
|
{
|
|
86
79
|
kind: 'Field',
|
|
@@ -1,22 +1,19 @@
|
|
|
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 {
|
|
5
|
+
id
|
|
6
|
+
title
|
|
7
|
+
shortDescription
|
|
8
|
+
link
|
|
11
9
|
media {
|
|
12
10
|
url
|
|
13
11
|
thumbnailUrl
|
|
14
12
|
type
|
|
15
13
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
shortDescription
|
|
14
|
+
brand {
|
|
15
|
+
name
|
|
16
|
+
}
|
|
20
17
|
priceAndAvailability {
|
|
21
18
|
currency
|
|
22
19
|
price
|
|
@@ -32,6 +29,7 @@ fragment ShortVideoViewerPayloadFragment on Post {
|
|
|
32
29
|
title
|
|
33
30
|
description
|
|
34
31
|
price
|
|
32
|
+
priceInfo
|
|
35
33
|
currency
|
|
36
34
|
ctaButton {
|
|
37
35
|
background
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { type Locale } from '../../core/locale';
|
|
2
|
-
import type {
|
|
2
|
+
import type { IProductCardLocalization } from '../../products/product-card/product-card-localization';
|
|
3
3
|
export interface IShortVideoAttachmentsLocalization {
|
|
4
|
-
|
|
5
|
-
offersSection?: string;
|
|
6
|
-
productLocalization?: IShortVideoProductLocalization;
|
|
4
|
+
productLocalization?: IProductCardLocalization | Locale;
|
|
7
5
|
}
|
|
8
6
|
export declare class ShortVideoAttachmentsLocalization {
|
|
9
|
-
|
|
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?:
|
|
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:
|
|
12
|
+
productLocalization: IProductCardLocalization | Locale;
|
|
13
13
|
constructor(init: IShortVideoViewerLocalization | Locale);
|
|
14
14
|
}
|
|
@@ -11,8 +11,9 @@ export type ShortVideoViewerModel = {
|
|
|
11
11
|
};
|
|
12
12
|
text?: string | null;
|
|
13
13
|
heading: ShortVideoViewerHeadingModel | null;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
enableSocialInteractions: boolean;
|
|
15
|
+
products: ShortVideoProductCardModel[];
|
|
16
|
+
ad: ShortVideoAdCardModel | null;
|
|
16
17
|
};
|
|
17
18
|
export type ShortVideoViewerHeadingModel = {
|
|
18
19
|
image: string | null;
|
|
@@ -20,13 +21,32 @@ export type ShortVideoViewerHeadingModel = {
|
|
|
20
21
|
displayDate: string;
|
|
21
22
|
viewsCount: number;
|
|
22
23
|
};
|
|
23
|
-
export type
|
|
24
|
+
export type ShortVideoSocialInteractionsHanlder = {
|
|
25
|
+
isLiked: (shortVideoId: string) => Promise<{
|
|
26
|
+
readonly isLiked: boolean;
|
|
27
|
+
}>;
|
|
28
|
+
onToggleLike: (shortVideoId: string) => void;
|
|
29
|
+
onShare: (shortVideoId: string) => void;
|
|
30
|
+
};
|
|
31
|
+
export type ShortVideoProductCardModel = {
|
|
32
|
+
id: string;
|
|
33
|
+
title: string;
|
|
34
|
+
shortDescription?: string | null;
|
|
35
|
+
link: string | null;
|
|
36
|
+
image: string | null;
|
|
37
|
+
brandName: string | null;
|
|
38
|
+
price: number;
|
|
39
|
+
currency: Currency;
|
|
40
|
+
salePrice: number | null;
|
|
41
|
+
};
|
|
42
|
+
export type ShortVideoAdCardModel = {
|
|
24
43
|
id: string;
|
|
25
44
|
type: AdType;
|
|
26
45
|
image: string | null;
|
|
27
46
|
title: string;
|
|
28
47
|
description: string | null;
|
|
29
48
|
price: number | null;
|
|
49
|
+
priceInfoLabel: string | null;
|
|
30
50
|
currency: Currency | null;
|
|
31
51
|
ctaButton: {
|
|
32
52
|
background: string;
|
|
@@ -36,13 +56,3 @@ export type ShortVideoViewerAdModel = {
|
|
|
36
56
|
border: string;
|
|
37
57
|
} | null;
|
|
38
58
|
};
|
|
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;
|
|
48
|
-
};
|
|
@@ -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
|
|
16
|
-
|
|
19
|
+
canShowControls = $state(false);
|
|
20
|
+
// is provided from the calling side
|
|
21
|
+
canShowAttachments = $state(false);
|
|
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,30 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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, socialInteractionsHandler, localization, showStreamsCloudWatermark, disableBackground, on } = $props();
|
|
7
|
+
const initHost = (node) => {
|
|
8
|
+
const shadowRoot = createShadowRoot(node);
|
|
9
|
+
const mounted = mount(ShortVideosPlayerView, {
|
|
10
|
+
target: shadowRoot,
|
|
11
|
+
props: {
|
|
12
|
+
input,
|
|
13
|
+
socialInteractionsHandler,
|
|
14
|
+
localization,
|
|
15
|
+
showStreamsCloudWatermark,
|
|
16
|
+
disableBackground,
|
|
17
|
+
on
|
|
18
|
+
}
|
|
8
19
|
});
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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);
|
|
20
|
+
return {
|
|
21
|
+
destroy: () => {
|
|
22
|
+
unmount(mounted);
|
|
23
|
+
}
|
|
83
24
|
};
|
|
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
25
|
};
|
|
99
26
|
</script>
|
|
100
27
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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>
|
|
28
|
+
{#key input}
|
|
29
|
+
<div class="short-videos-player-host" use:initHost></div>
|
|
30
|
+
{/key}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Locale } from '../../core/locale';
|
|
2
|
+
import type { ShortVideoSocialInteractionsHanlder } from '../short-video-viewer';
|
|
2
3
|
import { type IShortVideosPlayerLocalization } from './short-videos-player-localization';
|
|
3
4
|
import type { PlayerInput } from './types';
|
|
4
5
|
type Props = {
|
|
5
6
|
input: PlayerInput;
|
|
6
|
-
|
|
7
|
+
socialInteractionsHandler?: ShortVideoSocialInteractionsHanlder;
|
|
8
|
+
localization?: IShortVideosPlayerLocalization | Locale;
|
|
9
|
+
showStreamsCloudWatermark?: boolean;
|
|
10
|
+
disableBackground?: boolean;
|
|
7
11
|
on?: {
|
|
8
12
|
closePlayer?: () => void;
|
|
13
|
+
videoActivated?: (id: string) => void;
|
|
9
14
|
};
|
|
10
15
|
};
|
|
11
16
|
declare const Cmp: import("svelte").Component<Props, {}, "">;
|