@streamscloud/embeddable 6.3.11 → 6.4.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/core/enums.d.ts +3 -0
- package/dist/core/enums.js +4 -0
- package/dist/media-center/data-provider/internal-media-center-data-provider.svelte.js +2 -2
- package/dist/media-center/data-provider/operations.generated.d.ts +1 -0
- package/dist/media-center/data-provider/operations.generated.js +23 -6
- package/dist/media-center/data-provider/operations.graphql +1 -1
- package/dist/media-center/data-provider/types.d.ts +2 -2
- package/dist/media-center/media-center/overview.svelte.d.ts +2 -2
- package/dist/media-center/media-center/short-video-resources-generator.d.ts +3 -3
- package/dist/media-center/media-center/types.d.ts +2 -2
- package/dist/short-videos/short-video-viewer/cmp.attachments-inline.svelte +1 -1
- package/dist/short-videos/short-video-viewer/mapper.js +0 -1
- package/dist/short-videos/short-video-viewer/operations.generated.d.ts +0 -3
- package/dist/short-videos/short-video-viewer/operations.generated.js +0 -5
- package/dist/short-videos/short-video-viewer/operations.graphql +0 -3
- package/dist/short-videos/short-video-viewer/types.d.ts +0 -1
- package/dist/short-videos/short-videos-player/controls.svelte.d.ts +3 -2
- package/dist/short-videos/short-videos-player/index.d.ts +5 -7
- package/dist/short-videos/short-videos-player/internal-short-video-analytics-handler.js +4 -12
- package/dist/short-videos/short-videos-player/internal-short-video-player-provider.d.ts +4 -4
- package/dist/short-videos/short-videos-player/internal-short-video-player-provider.js +2 -2
- package/dist/short-videos/short-videos-player/mapper.d.ts +3 -0
- package/dist/short-videos/short-videos-player/mapper.js +9 -0
- package/dist/short-videos/short-videos-player/operations.generated.d.ts +64 -0
- package/dist/short-videos/short-videos-player/operations.generated.js +219 -6
- package/dist/short-videos/short-videos-player/operations.graphql +9 -1
- package/dist/short-videos/short-videos-player/short-videos-player-view.svelte +6 -4
- package/dist/short-videos/short-videos-player/types.d.ts +4 -1
- package/dist/streams/layout/models/mapper.js +0 -1
- package/dist/streams/layout/models/stream-layout-short-video-model.d.ts +0 -1
- package/dist/streams/stream-player/mapper.js +2 -1
- package/dist/streams/stream-player/operations.generated.d.ts +2 -0
- package/dist/streams/stream-player/operations.generated.js +4 -2
- package/dist/streams/stream-player/operations.graphql +1 -0
- package/dist/streams/stream-player/stream-player-buffer.svelte.d.ts +4 -1
- package/dist/streams/stream-player/stream-player-buffer.svelte.js +19 -9
- package/dist/streams/stream-player/stream-player.svelte +58 -28
- package/dist/streams/stream-player/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/core/enums.d.ts
CHANGED
package/dist/core/enums.js
CHANGED
|
@@ -35,6 +35,10 @@ export var ImageScale;
|
|
|
35
35
|
ImageScale["OriginalEncoded"] = "ORIGINAL_ENCODED";
|
|
36
36
|
ImageScale["Small"] = "SMALL";
|
|
37
37
|
})(ImageScale || (ImageScale = {}));
|
|
38
|
+
export var ProfileType;
|
|
39
|
+
(function (ProfileType) {
|
|
40
|
+
ProfileType["Organization"] = "ORGANIZATION";
|
|
41
|
+
})(ProfileType || (ProfileType = {}));
|
|
38
42
|
export var PostType;
|
|
39
43
|
(function (PostType) {
|
|
40
44
|
PostType["ShortVideo"] = "SHORT_VIDEO";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PostType, Status } from '../../core/enums';
|
|
2
2
|
import { createLocalGQLClient } from '../../core/graphql';
|
|
3
|
-
import {
|
|
3
|
+
import { mapToShortVideosPlayerModel } from '../../short-videos/short-videos-player/mapper';
|
|
4
4
|
import { GetMediaPageConfigDocument, GetShortVideosDocument } from './operations.generated';
|
|
5
5
|
export class InternalMediaCenterDataProvider {
|
|
6
6
|
mediaPageId;
|
|
@@ -39,7 +39,7 @@ export class InternalMediaCenterDataProvider {
|
|
|
39
39
|
.toPromise();
|
|
40
40
|
const posts = payload.data?.shortVideos?.items || [];
|
|
41
41
|
return {
|
|
42
|
-
items: posts.map(
|
|
42
|
+
items: posts.map(mapToShortVideosPlayerModel),
|
|
43
43
|
continuationToken: payload.data?.shortVideos?.continuationToken || null
|
|
44
44
|
};
|
|
45
45
|
};
|
|
@@ -108,7 +108,7 @@ export const GetShortVideosDocument = {
|
|
|
108
108
|
name: { kind: 'Name', value: 'items' },
|
|
109
109
|
selectionSet: {
|
|
110
110
|
kind: 'SelectionSet',
|
|
111
|
-
selections: [{ kind: 'FragmentSpread', name: { kind: 'Name', value: '
|
|
111
|
+
selections: [{ kind: 'FragmentSpread', name: { kind: 'Name', value: 'ShortVideosPlayerPayloadFragment' } }]
|
|
112
112
|
}
|
|
113
113
|
},
|
|
114
114
|
{ kind: 'Field', name: { kind: 'Name', value: 'continuationToken' } }
|
|
@@ -127,11 +127,6 @@ export const GetShortVideosDocument = {
|
|
|
127
127
|
selections: [
|
|
128
128
|
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
|
|
129
129
|
{ kind: 'Field', name: { kind: 'Name', value: 'enableSocialInteractions' } },
|
|
130
|
-
{
|
|
131
|
-
kind: 'Field',
|
|
132
|
-
name: { kind: 'Name', value: 'ownerProfile' },
|
|
133
|
-
selectionSet: { kind: 'SelectionSet', selections: [{ kind: 'Field', name: { kind: 'Name', value: 'id' } }] }
|
|
134
|
-
},
|
|
135
130
|
{
|
|
136
131
|
kind: 'Field',
|
|
137
132
|
name: { kind: 'Name', value: 'allProducts' },
|
|
@@ -291,6 +286,28 @@ export const GetShortVideosDocument = {
|
|
|
291
286
|
}
|
|
292
287
|
]
|
|
293
288
|
}
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
kind: 'FragmentDefinition',
|
|
292
|
+
name: { kind: 'Name', value: 'ShortVideosPlayerPayloadFragment' },
|
|
293
|
+
typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Post' } },
|
|
294
|
+
selectionSet: {
|
|
295
|
+
kind: 'SelectionSet',
|
|
296
|
+
selections: [
|
|
297
|
+
{ kind: 'FragmentSpread', name: { kind: 'Name', value: 'ShortVideoViewerPayloadFragment' } },
|
|
298
|
+
{
|
|
299
|
+
kind: 'Field',
|
|
300
|
+
name: { kind: 'Name', value: 'ownerProfile' },
|
|
301
|
+
selectionSet: {
|
|
302
|
+
kind: 'SelectionSet',
|
|
303
|
+
selections: [
|
|
304
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
|
|
305
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'type' } }
|
|
306
|
+
]
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
]
|
|
310
|
+
}
|
|
294
311
|
}
|
|
295
312
|
]
|
|
296
313
|
};
|
|
@@ -18,7 +18,7 @@ query GetMediaPageConfig($mediaPageId: String!) {
|
|
|
18
18
|
query GetShortVideos($input: EmbedPostsInput!, $image_scale: ImageScale = ORIGINAL_ENCODED) {
|
|
19
19
|
shortVideos: embedPosts(input: $input) {
|
|
20
20
|
items {
|
|
21
|
-
...
|
|
21
|
+
...ShortVideosPlayerPayloadFragment
|
|
22
22
|
}
|
|
23
23
|
continuationToken
|
|
24
24
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ShortVideoPlayerModel } from '../../short-videos/short-videos-player/types';
|
|
2
2
|
export interface IMediaCenterDataProvider {
|
|
3
3
|
getConfig: () => Promise<MediaCenterConfig | null>;
|
|
4
4
|
getShortVideosCursor: (input: {
|
|
@@ -9,7 +9,7 @@ export interface IMediaCenterDataProvider {
|
|
|
9
9
|
limit: number;
|
|
10
10
|
continuationToken?: string | null;
|
|
11
11
|
}) => Promise<{
|
|
12
|
-
items:
|
|
12
|
+
items: ShortVideoPlayerModel[];
|
|
13
13
|
continuationToken: string | null;
|
|
14
14
|
}>;
|
|
15
15
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ShortVideoPlayerModel } from '../../short-videos/short-videos-player';
|
|
2
2
|
import { MediaCenterLocalization } from './media-center-localization';
|
|
3
3
|
import type { OverviewData } from './types';
|
|
4
4
|
type Props = {
|
|
5
5
|
data: OverviewData;
|
|
6
6
|
localization: MediaCenterLocalization;
|
|
7
7
|
on: {
|
|
8
|
-
shortVideoSelected: (shortVideo:
|
|
8
|
+
shortVideoSelected: (shortVideo: ShortVideoPlayerModel) => void;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
declare const Overview: import("svelte").Component<Props, {}, "">;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ShortVideoPlayerModel } from '../../short-videos/short-videos-player';
|
|
2
2
|
import type { IPlayerItemsProvider } from '../../ui/player';
|
|
3
3
|
import type { IMediaCenterDataProvider } from '../data-provider';
|
|
4
4
|
export declare const makeShortVideosProvider: (data: {
|
|
5
5
|
dataProvider: IMediaCenterDataProvider;
|
|
6
6
|
categoryId?: string;
|
|
7
|
-
prefetchedItems?:
|
|
8
|
-
}) => IPlayerItemsProvider<
|
|
7
|
+
prefetchedItems?: ShortVideoPlayerModel[];
|
|
8
|
+
}) => IPlayerItemsProvider<ShortVideoPlayerModel>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ProductCardModel } from '../../products/product-card';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ShortVideoPlayerModel } from '../../short-videos/short-videos-player';
|
|
3
3
|
export declare enum MediaCenterMode {
|
|
4
4
|
ShortVideos = "short-videos",
|
|
5
5
|
Stream = "stream"
|
|
6
6
|
}
|
|
7
7
|
export type OverviewData = {
|
|
8
|
-
shortVideos:
|
|
8
|
+
shortVideos: ShortVideoPlayerModel[];
|
|
9
9
|
products: ProductCardModel[];
|
|
10
10
|
};
|
|
@@ -33,7 +33,7 @@ const handleAttachmentClick = (attachment) => {
|
|
|
33
33
|
window.open(attachment.link, '_blank');
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
-
let attachmentElements = {};
|
|
36
|
+
let attachmentElements = $state({});
|
|
37
37
|
let observer = null;
|
|
38
38
|
$effect(() => {
|
|
39
39
|
if ((on === null || on === void 0 ? void 0 : on.productImpression) && Object.keys(attachmentElements).length > 0) {
|
|
@@ -3,9 +3,6 @@ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-
|
|
|
3
3
|
export type ShortVideoViewerPayloadFragment = {
|
|
4
4
|
id: string;
|
|
5
5
|
enableSocialInteractions: boolean;
|
|
6
|
-
ownerProfile: {
|
|
7
|
-
id: string;
|
|
8
|
-
};
|
|
9
6
|
allProducts: Array<{
|
|
10
7
|
id: string;
|
|
11
8
|
title: string;
|
|
@@ -10,11 +10,6 @@ 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: 'ownerProfile' },
|
|
16
|
-
selectionSet: { kind: 'SelectionSet', selections: [{ kind: 'Field', name: { kind: 'Name', value: 'id' } }] }
|
|
17
|
-
},
|
|
18
13
|
{
|
|
19
14
|
kind: 'Field',
|
|
20
15
|
name: { kind: 'Name', value: 'allProducts' },
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { type IPostSocialInteractionsHandler
|
|
1
|
+
import { type IPostSocialInteractionsHandler } from '../short-video-viewer';
|
|
2
2
|
import type { IPlayerBuffer } from '../../ui/player';
|
|
3
3
|
import { ShortVideosPlayerLocalization } from './short-videos-player-localization';
|
|
4
|
+
import type { ShortVideoPlayerModel } from './types';
|
|
4
5
|
import type { ShortVideosPlayerUiManager } from './ui-manager.svelte';
|
|
5
6
|
type Props = {
|
|
6
|
-
buffer: IPlayerBuffer<
|
|
7
|
+
buffer: IPlayerBuffer<ShortVideoPlayerModel>;
|
|
7
8
|
uiManager: ShortVideosPlayerUiManager;
|
|
8
9
|
localization: ShortVideosPlayerLocalization;
|
|
9
10
|
socialInteractionsHandler?: IPostSocialInteractionsHandler;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { type IMediaCenterDataProvider } from '../../media-center/data-provider';
|
|
2
|
-
import type { ShortVideoViewerModel } from '../short-video-viewer';
|
|
3
2
|
import type { IPlayerItemsProvider } from '../../ui/player';
|
|
4
3
|
import { default as ShortVideosPlayer } from './cmp.short-videos-player.svelte';
|
|
5
|
-
import { InternalShortVideoAnalyticsHandler } from './internal-short-video-analytics-handler';
|
|
6
4
|
import type { IShortVideosPlayerLocalization } from './short-videos-player-localization';
|
|
7
|
-
import { type PlayerSettings, type IShortVideoAnalyticsHandler } from './types';
|
|
8
|
-
export { ShortVideosPlayer };
|
|
9
|
-
export type { IShortVideosPlayerLocalization, IMediaCenterDataProvider, IPlayerItemsProvider, IShortVideoAnalyticsHandler
|
|
5
|
+
import { type PlayerSettings, type IShortVideoAnalyticsHandler, type ShortVideoPlayerModel } from './types';
|
|
6
|
+
export { ShortVideosPlayer, type ShortVideoPlayerModel };
|
|
7
|
+
export type { IShortVideosPlayerLocalization, IMediaCenterDataProvider, IPlayerItemsProvider, IShortVideoAnalyticsHandler };
|
|
10
8
|
/**
|
|
11
9
|
* Opens the short videos player modal.
|
|
12
10
|
*
|
|
@@ -17,7 +15,7 @@ export type { IShortVideosPlayerLocalization, IMediaCenterDataProvider, IPlayerI
|
|
|
17
15
|
* @param init Configuration options.
|
|
18
16
|
*
|
|
19
17
|
* Provider mode (overload 1)
|
|
20
|
-
* @param {IPlayerItemsProvider<
|
|
18
|
+
* @param {IPlayerItemsProvider<ShortVideoPlayerModel>} init.shortVideosProvider
|
|
21
19
|
* Provider that supplies short-video items to the player.
|
|
22
20
|
* @param {IMediaCenterDataProvider} [init.mediaCenterDataProvider]
|
|
23
21
|
* Optional media-center data provider.
|
|
@@ -89,7 +87,7 @@ export type { IShortVideosPlayerLocalization, IMediaCenterDataProvider, IPlayerI
|
|
|
89
87
|
* ```
|
|
90
88
|
*/
|
|
91
89
|
export declare function openShortVideosPlayer(init: PlayerSettings & {
|
|
92
|
-
shortVideosProvider: IPlayerItemsProvider<
|
|
90
|
+
shortVideosProvider: IPlayerItemsProvider<ShortVideoPlayerModel>;
|
|
93
91
|
mediaCenterDataProvider?: IMediaCenterDataProvider;
|
|
94
92
|
}): void;
|
|
95
93
|
export declare function openShortVideosPlayer(init: PlayerSettings & {
|
|
@@ -6,16 +6,8 @@ export class InternalShortVideoAnalyticsHandler {
|
|
|
6
6
|
AppEventsTracker.setEndpoint(constructGraphQLUrl(graphqlOrigin));
|
|
7
7
|
AppEventsTracker.setProfileId(getOrCreateProfileId());
|
|
8
8
|
}
|
|
9
|
-
setOrganizationId = (organizationId) =>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
AppEventsTracker.trackShortVideoView(videoId);
|
|
14
|
-
};
|
|
15
|
-
trackShortVideoProductImpression = (productId, videoId) => {
|
|
16
|
-
AppEventsTracker.trackShortVideoProductImpression(productId, videoId);
|
|
17
|
-
};
|
|
18
|
-
trackShortVideoProductClick = (productId, videoId) => {
|
|
19
|
-
AppEventsTracker.trackShortVideoProductClick(productId, videoId);
|
|
20
|
-
};
|
|
9
|
+
setOrganizationId = (organizationId) => AppEventsTracker.setOrganizationId(organizationId);
|
|
10
|
+
trackShortVideoView = (videoId) => AppEventsTracker.trackShortVideoView(videoId);
|
|
11
|
+
trackShortVideoProductImpression = (productId, videoId) => AppEventsTracker.trackShortVideoProductImpression(productId, videoId);
|
|
12
|
+
trackShortVideoProductClick = (productId, videoId) => AppEventsTracker.trackShortVideoProductClick(productId, videoId);
|
|
21
13
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type ShortVideoViewerModel } from '../short-video-viewer';
|
|
2
1
|
import type { IPlayerItemsProvider } from '../../ui/player';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type { ShortVideoPlayerModel } from './types';
|
|
3
|
+
export declare class InternalShortVideoPlayerProvider implements IPlayerItemsProvider<ShortVideoPlayerModel> {
|
|
4
|
+
initialData: IPlayerItemsProvider<ShortVideoPlayerModel>['initialData'];
|
|
5
5
|
private ids;
|
|
6
6
|
private idOrder;
|
|
7
7
|
private initialId?;
|
|
@@ -13,6 +13,6 @@ export declare class InternalShortVideoPlayerProvider implements IPlayerItemsPro
|
|
|
13
13
|
graphqlOrigin?: string;
|
|
14
14
|
initialId?: string;
|
|
15
15
|
});
|
|
16
|
-
loadMore: () => Promise<
|
|
16
|
+
loadMore: () => Promise<ShortVideoPlayerModel[]>;
|
|
17
17
|
prefetch: () => Promise<void>;
|
|
18
18
|
}
|
|
@@ -2,7 +2,7 @@ import { ImageScale } from '../..';
|
|
|
2
2
|
import { ContinuationToken } from '../../core/continuation-token';
|
|
3
3
|
import { CursorDataLoader } from '../../core/data-loaders';
|
|
4
4
|
import { createLocalGQLClient } from '../../core/graphql';
|
|
5
|
-
import {
|
|
5
|
+
import { mapToShortVideosPlayerModel } from './mapper';
|
|
6
6
|
import { GetShortVideosDocument } from './operations.generated';
|
|
7
7
|
const CHUNK_SIZE = 20;
|
|
8
8
|
export class InternalShortVideoPlayerProvider {
|
|
@@ -32,7 +32,7 @@ export class InternalShortVideoPlayerProvider {
|
|
|
32
32
|
if (!data) {
|
|
33
33
|
return null;
|
|
34
34
|
}
|
|
35
|
-
const items = data.items.map(
|
|
35
|
+
const items = data.items.map(mapToShortVideosPlayerModel).sort((a, b) => {
|
|
36
36
|
const ia = this.idOrder.get(a.id) ?? Number.MAX_SAFE_INTEGER;
|
|
37
37
|
const ib = this.idOrder.get(b.id) ?? Number.MAX_SAFE_INTEGER;
|
|
38
38
|
return ia - ib;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ProfileType } from '../../core/enums';
|
|
2
|
+
import { mapToShortVideoViewerModel } from '../short-video-viewer';
|
|
3
|
+
export const mapToShortVideosPlayerModel = (payload) => {
|
|
4
|
+
const viewerModel = mapToShortVideoViewerModel(payload);
|
|
5
|
+
return {
|
|
6
|
+
...viewerModel,
|
|
7
|
+
analyticsOrganizationId: payload.ownerProfile.type === ProfileType.Organization ? payload.ownerProfile.id : null
|
|
8
|
+
};
|
|
9
|
+
};
|
|
@@ -12,6 +12,7 @@ export type GetShortVideosQuery = {
|
|
|
12
12
|
enableSocialInteractions: boolean;
|
|
13
13
|
ownerProfile: {
|
|
14
14
|
id: string;
|
|
15
|
+
type: SchemaTypes.ProfileType;
|
|
15
16
|
};
|
|
16
17
|
allProducts: Array<{
|
|
17
18
|
id: string;
|
|
@@ -70,4 +71,67 @@ export type GetShortVideosQuery = {
|
|
|
70
71
|
}>;
|
|
71
72
|
};
|
|
72
73
|
};
|
|
74
|
+
export type ShortVideosPlayerPayloadFragment = {
|
|
75
|
+
id: string;
|
|
76
|
+
enableSocialInteractions: boolean;
|
|
77
|
+
ownerProfile: {
|
|
78
|
+
id: string;
|
|
79
|
+
type: SchemaTypes.ProfileType;
|
|
80
|
+
};
|
|
81
|
+
allProducts: Array<{
|
|
82
|
+
id: string;
|
|
83
|
+
title: string;
|
|
84
|
+
shortDescription: string | null;
|
|
85
|
+
link: string | null;
|
|
86
|
+
media: Array<{
|
|
87
|
+
url: string;
|
|
88
|
+
thumbnailUrl: string | null;
|
|
89
|
+
type: SchemaTypes.MediaType;
|
|
90
|
+
}>;
|
|
91
|
+
brand: {
|
|
92
|
+
name: string;
|
|
93
|
+
} | null;
|
|
94
|
+
priceAndAvailability: {
|
|
95
|
+
currency: SchemaTypes.Currency;
|
|
96
|
+
price: number;
|
|
97
|
+
productSalePrices: Array<{
|
|
98
|
+
salePrice: number;
|
|
99
|
+
salePriceEffectiveDateFrom: any | null;
|
|
100
|
+
salePriceEffectiveDateTo: any | null;
|
|
101
|
+
}> | null;
|
|
102
|
+
};
|
|
103
|
+
}>;
|
|
104
|
+
ad: {
|
|
105
|
+
id: string;
|
|
106
|
+
title: string;
|
|
107
|
+
description: string | null;
|
|
108
|
+
price: number | null;
|
|
109
|
+
priceInfo: string | null;
|
|
110
|
+
currency: SchemaTypes.Currency | null;
|
|
111
|
+
type: SchemaTypes.AdType;
|
|
112
|
+
ctaButton: {
|
|
113
|
+
background: string;
|
|
114
|
+
textColor: string;
|
|
115
|
+
text: string;
|
|
116
|
+
url: string;
|
|
117
|
+
border: string;
|
|
118
|
+
} | null;
|
|
119
|
+
media: Array<{
|
|
120
|
+
url: string;
|
|
121
|
+
thumbnailUrl: string | null;
|
|
122
|
+
type: SchemaTypes.MediaType;
|
|
123
|
+
}>;
|
|
124
|
+
} | null;
|
|
125
|
+
postData: {
|
|
126
|
+
media: Array<{
|
|
127
|
+
url: string;
|
|
128
|
+
thumbnailUrl: string | null;
|
|
129
|
+
type: SchemaTypes.MediaType;
|
|
130
|
+
}>;
|
|
131
|
+
shortVideoData: {
|
|
132
|
+
text: string | null;
|
|
133
|
+
} | null;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
export declare const ShortVideosPlayerPayloadFragmentDoc: DocumentNode<ShortVideosPlayerPayloadFragment, unknown>;
|
|
73
137
|
export declare const GetShortVideosDocument: DocumentNode<GetShortVideosQuery, GetShortVideosQueryVariables>;
|
|
@@ -1,3 +1,199 @@
|
|
|
1
|
+
export const ShortVideosPlayerPayloadFragmentDoc = {
|
|
2
|
+
kind: 'Document',
|
|
3
|
+
definitions: [
|
|
4
|
+
{
|
|
5
|
+
kind: 'FragmentDefinition',
|
|
6
|
+
name: { kind: 'Name', value: 'ShortVideosPlayerPayloadFragment' },
|
|
7
|
+
typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Post' } },
|
|
8
|
+
selectionSet: {
|
|
9
|
+
kind: 'SelectionSet',
|
|
10
|
+
selections: [
|
|
11
|
+
{ kind: 'FragmentSpread', name: { kind: 'Name', value: 'ShortVideoViewerPayloadFragment' } },
|
|
12
|
+
{
|
|
13
|
+
kind: 'Field',
|
|
14
|
+
name: { kind: 'Name', value: 'ownerProfile' },
|
|
15
|
+
selectionSet: {
|
|
16
|
+
kind: 'SelectionSet',
|
|
17
|
+
selections: [
|
|
18
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
|
|
19
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'type' } }
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
kind: 'FragmentDefinition',
|
|
28
|
+
name: { kind: 'Name', value: 'ShortVideoViewerPayloadFragment' },
|
|
29
|
+
typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Post' } },
|
|
30
|
+
selectionSet: {
|
|
31
|
+
kind: 'SelectionSet',
|
|
32
|
+
selections: [
|
|
33
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
|
|
34
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'enableSocialInteractions' } },
|
|
35
|
+
{
|
|
36
|
+
kind: 'Field',
|
|
37
|
+
name: { kind: 'Name', value: 'allProducts' },
|
|
38
|
+
selectionSet: {
|
|
39
|
+
kind: 'SelectionSet',
|
|
40
|
+
selections: [
|
|
41
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
|
|
42
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'title' } },
|
|
43
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'shortDescription' } },
|
|
44
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'link' } },
|
|
45
|
+
{
|
|
46
|
+
kind: 'Field',
|
|
47
|
+
name: { kind: 'Name', value: 'media' },
|
|
48
|
+
selectionSet: {
|
|
49
|
+
kind: 'SelectionSet',
|
|
50
|
+
selections: [
|
|
51
|
+
{
|
|
52
|
+
kind: 'Field',
|
|
53
|
+
name: { kind: 'Name', value: 'url' },
|
|
54
|
+
arguments: [{ kind: 'Argument', name: { kind: 'Name', value: 'scale' }, value: { kind: 'EnumValue', value: 'SMALL' } }]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
kind: 'Field',
|
|
58
|
+
name: { kind: 'Name', value: 'thumbnailUrl' },
|
|
59
|
+
arguments: [{ kind: 'Argument', name: { kind: 'Name', value: 'scale' }, value: { kind: 'EnumValue', value: 'SMALL' } }]
|
|
60
|
+
},
|
|
61
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'type' } }
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
kind: 'Field',
|
|
67
|
+
name: { kind: 'Name', value: 'brand' },
|
|
68
|
+
selectionSet: { kind: 'SelectionSet', selections: [{ kind: 'Field', name: { kind: 'Name', value: 'name' } }] }
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
kind: 'Field',
|
|
72
|
+
name: { kind: 'Name', value: 'priceAndAvailability' },
|
|
73
|
+
selectionSet: {
|
|
74
|
+
kind: 'SelectionSet',
|
|
75
|
+
selections: [
|
|
76
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'currency' } },
|
|
77
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'price' } },
|
|
78
|
+
{
|
|
79
|
+
kind: 'Field',
|
|
80
|
+
name: { kind: 'Name', value: 'productSalePrices' },
|
|
81
|
+
selectionSet: {
|
|
82
|
+
kind: 'SelectionSet',
|
|
83
|
+
selections: [
|
|
84
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'salePrice' } },
|
|
85
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'salePriceEffectiveDateFrom' } },
|
|
86
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'salePriceEffectiveDateTo' } }
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
kind: 'Field',
|
|
98
|
+
name: { kind: 'Name', value: 'ad' },
|
|
99
|
+
selectionSet: {
|
|
100
|
+
kind: 'SelectionSet',
|
|
101
|
+
selections: [
|
|
102
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
|
|
103
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'title' } },
|
|
104
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'description' } },
|
|
105
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'price' } },
|
|
106
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'priceInfo' } },
|
|
107
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'currency' } },
|
|
108
|
+
{
|
|
109
|
+
kind: 'Field',
|
|
110
|
+
name: { kind: 'Name', value: 'ctaButton' },
|
|
111
|
+
selectionSet: {
|
|
112
|
+
kind: 'SelectionSet',
|
|
113
|
+
selections: [
|
|
114
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'background' } },
|
|
115
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'textColor' } },
|
|
116
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'text' } },
|
|
117
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'url' } },
|
|
118
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'border' } }
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'type' } },
|
|
123
|
+
{
|
|
124
|
+
kind: 'Field',
|
|
125
|
+
name: { kind: 'Name', value: 'media' },
|
|
126
|
+
selectionSet: {
|
|
127
|
+
kind: 'SelectionSet',
|
|
128
|
+
selections: [
|
|
129
|
+
{
|
|
130
|
+
kind: 'Field',
|
|
131
|
+
name: { kind: 'Name', value: 'url' },
|
|
132
|
+
arguments: [{ kind: 'Argument', name: { kind: 'Name', value: 'scale' }, value: { kind: 'EnumValue', value: 'SMALL' } }]
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
kind: 'Field',
|
|
136
|
+
name: { kind: 'Name', value: 'thumbnailUrl' },
|
|
137
|
+
arguments: [{ kind: 'Argument', name: { kind: 'Name', value: 'scale' }, value: { kind: 'EnumValue', value: 'SMALL' } }]
|
|
138
|
+
},
|
|
139
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'type' } }
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
kind: 'Field',
|
|
148
|
+
name: { kind: 'Name', value: 'postData' },
|
|
149
|
+
selectionSet: {
|
|
150
|
+
kind: 'SelectionSet',
|
|
151
|
+
selections: [
|
|
152
|
+
{
|
|
153
|
+
kind: 'Field',
|
|
154
|
+
name: { kind: 'Name', value: 'media' },
|
|
155
|
+
selectionSet: {
|
|
156
|
+
kind: 'SelectionSet',
|
|
157
|
+
selections: [
|
|
158
|
+
{
|
|
159
|
+
kind: 'Field',
|
|
160
|
+
name: { kind: 'Name', value: 'url' },
|
|
161
|
+
arguments: [
|
|
162
|
+
{
|
|
163
|
+
kind: 'Argument',
|
|
164
|
+
name: { kind: 'Name', value: 'scale' },
|
|
165
|
+
value: { kind: 'Variable', name: { kind: 'Name', value: 'image_scale' } }
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
kind: 'Field',
|
|
171
|
+
name: { kind: 'Name', value: 'thumbnailUrl' },
|
|
172
|
+
arguments: [
|
|
173
|
+
{
|
|
174
|
+
kind: 'Argument',
|
|
175
|
+
name: { kind: 'Name', value: 'scale' },
|
|
176
|
+
value: { kind: 'Variable', name: { kind: 'Name', value: 'image_scale' } }
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'type' } }
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
kind: 'Field',
|
|
186
|
+
name: { kind: 'Name', value: 'shortVideoData' },
|
|
187
|
+
selectionSet: { kind: 'SelectionSet', selections: [{ kind: 'Field', name: { kind: 'Name', value: 'text' } }] }
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
]
|
|
196
|
+
};
|
|
1
197
|
export const GetShortVideosDocument = {
|
|
2
198
|
kind: 'Document',
|
|
3
199
|
definitions: [
|
|
@@ -34,7 +230,7 @@ export const GetShortVideosDocument = {
|
|
|
34
230
|
name: { kind: 'Name', value: 'items' },
|
|
35
231
|
selectionSet: {
|
|
36
232
|
kind: 'SelectionSet',
|
|
37
|
-
selections: [{ kind: 'FragmentSpread', name: { kind: 'Name', value: '
|
|
233
|
+
selections: [{ kind: 'FragmentSpread', name: { kind: 'Name', value: 'ShortVideosPlayerPayloadFragment' } }]
|
|
38
234
|
}
|
|
39
235
|
},
|
|
40
236
|
{ kind: 'Field', name: { kind: 'Name', value: 'continuationToken' } }
|
|
@@ -53,11 +249,6 @@ export const GetShortVideosDocument = {
|
|
|
53
249
|
selections: [
|
|
54
250
|
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
|
|
55
251
|
{ kind: 'Field', name: { kind: 'Name', value: 'enableSocialInteractions' } },
|
|
56
|
-
{
|
|
57
|
-
kind: 'Field',
|
|
58
|
-
name: { kind: 'Name', value: 'ownerProfile' },
|
|
59
|
-
selectionSet: { kind: 'SelectionSet', selections: [{ kind: 'Field', name: { kind: 'Name', value: 'id' } }] }
|
|
60
|
-
},
|
|
61
252
|
{
|
|
62
253
|
kind: 'Field',
|
|
63
254
|
name: { kind: 'Name', value: 'allProducts' },
|
|
@@ -217,6 +408,28 @@ export const GetShortVideosDocument = {
|
|
|
217
408
|
}
|
|
218
409
|
]
|
|
219
410
|
}
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
kind: 'FragmentDefinition',
|
|
414
|
+
name: { kind: 'Name', value: 'ShortVideosPlayerPayloadFragment' },
|
|
415
|
+
typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Post' } },
|
|
416
|
+
selectionSet: {
|
|
417
|
+
kind: 'SelectionSet',
|
|
418
|
+
selections: [
|
|
419
|
+
{ kind: 'FragmentSpread', name: { kind: 'Name', value: 'ShortVideoViewerPayloadFragment' } },
|
|
420
|
+
{
|
|
421
|
+
kind: 'Field',
|
|
422
|
+
name: { kind: 'Name', value: 'ownerProfile' },
|
|
423
|
+
selectionSet: {
|
|
424
|
+
kind: 'SelectionSet',
|
|
425
|
+
selections: [
|
|
426
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
|
|
427
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'type' } }
|
|
428
|
+
]
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
]
|
|
432
|
+
}
|
|
220
433
|
}
|
|
221
434
|
]
|
|
222
435
|
};
|
|
@@ -2,8 +2,16 @@
|
|
|
2
2
|
query GetShortVideos($input: EmbedPostsInput!, $image_scale: ImageScale = ORIGINAL_ENCODED) {
|
|
3
3
|
shortVideos: embedPosts(input: $input) {
|
|
4
4
|
items {
|
|
5
|
-
...
|
|
5
|
+
...ShortVideosPlayerPayloadFragment
|
|
6
6
|
}
|
|
7
7
|
continuationToken
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
+
|
|
11
|
+
fragment ShortVideosPlayerPayloadFragment on Post {
|
|
12
|
+
...ShortVideoViewerPayloadFragment
|
|
13
|
+
ownerProfile {
|
|
14
|
+
id
|
|
15
|
+
type
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -56,7 +56,9 @@ const onItemActivated = (id) => {
|
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
background = resolveVideoCover(shortVideo);
|
|
59
|
-
|
|
59
|
+
if (shortVideo.analyticsOrganizationId) {
|
|
60
|
+
analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.setOrganizationId(shortVideo.analyticsOrganizationId);
|
|
61
|
+
}
|
|
60
62
|
analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackShortVideoView(id);
|
|
61
63
|
(_a = on === null || on === void 0 ? void 0 : on.videoActivated) === null || _a === void 0 ? void 0 : _a.call(on, id);
|
|
62
64
|
};
|
|
@@ -137,8 +139,8 @@ const onShortVideoProductImpression = (productId, videoId) => {
|
|
|
137
139
|
showControls={uiManager.showShortVideoOverlay}
|
|
138
140
|
localization={localization.shortVideoViewerLocalization}
|
|
139
141
|
on={{
|
|
140
|
-
productClick: (productId
|
|
141
|
-
productImpression: (productId
|
|
142
|
+
productClick: (productId) => onShortVideoProductClick(productId, item.id),
|
|
143
|
+
productImpression: (productId, videoId) => onShortVideoProductImpression(productId, videoId)
|
|
142
144
|
}} />
|
|
143
145
|
{/snippet}
|
|
144
146
|
</PlayerSlider>
|
|
@@ -155,7 +157,7 @@ const onShortVideoProductImpression = (productId, videoId) => {
|
|
|
155
157
|
playerLogo={playerLogo}
|
|
156
158
|
on={{
|
|
157
159
|
closePlayer: on?.playerClosed,
|
|
158
|
-
productClick: (productId
|
|
160
|
+
productClick: (productId) => onShortVideoProductClick(productId, buffer?.current?.id || ''),
|
|
159
161
|
productImpression: onShortVideoProductImpression
|
|
160
162
|
}} />
|
|
161
163
|
{:else}
|
|
@@ -8,8 +8,11 @@ export interface IShortVideoAnalyticsHandler {
|
|
|
8
8
|
trackShortVideoProductImpression: (productId: string, videoId: string) => void;
|
|
9
9
|
trackShortVideoProductClick: (productId: string, videoId: string) => void;
|
|
10
10
|
}
|
|
11
|
+
export type ShortVideoPlayerModel = ShortVideoViewerModel & {
|
|
12
|
+
analyticsOrganizationId: string | null;
|
|
13
|
+
};
|
|
11
14
|
export type ShortVideoPlayerProps = PlayerSettings & {
|
|
12
|
-
dataProvider: IPlayerItemsProvider<
|
|
15
|
+
dataProvider: IPlayerItemsProvider<ShortVideoPlayerModel>;
|
|
13
16
|
analyticsHandler?: IShortVideoAnalyticsHandler;
|
|
14
17
|
};
|
|
15
18
|
export type PlayerSettings = {
|
|
@@ -3,7 +3,6 @@ import type { StreamLayoutMediaItemModel } from './stream-layout-media-item-mode
|
|
|
3
3
|
import type { StreamLayoutPostHeaderModel } from './stream-layout-post-header-model';
|
|
4
4
|
export type StreamLayoutShortVideoModel = {
|
|
5
5
|
id: string;
|
|
6
|
-
organizationId: string;
|
|
7
6
|
media: StreamLayoutMediaItemModel;
|
|
8
7
|
text: string | null;
|
|
9
8
|
header: StreamLayoutPostHeaderModel | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ProfileType } from '../../core/enums';
|
|
1
2
|
export const mapToStreamPlayerModel = (payload) => {
|
|
2
3
|
const headerDataProvider = payload.availableFrom ?? payload.ownerProfile;
|
|
3
4
|
return {
|
|
@@ -7,7 +8,7 @@ export const mapToStreamPlayerModel = (payload) => {
|
|
|
7
8
|
cover: payload.cover?.url || null,
|
|
8
9
|
createdAt: payload.createdAt,
|
|
9
10
|
publishedAt: payload.publishedAt,
|
|
10
|
-
organizationId: payload.ownerProfile.id,
|
|
11
|
+
organizationId: payload.ownerProfile.type === ProfileType.Organization ? payload.ownerProfile.id : null,
|
|
11
12
|
header: {
|
|
12
13
|
name: headerDataProvider.name,
|
|
13
14
|
image: headerDataProvider.image
|
|
@@ -18,6 +18,7 @@ export type GetStreamQuery = {
|
|
|
18
18
|
image: string | null;
|
|
19
19
|
name: string;
|
|
20
20
|
id: string;
|
|
21
|
+
type: SchemaTypes.ProfileType;
|
|
21
22
|
};
|
|
22
23
|
availableFrom: {
|
|
23
24
|
image: string;
|
|
@@ -56,6 +57,7 @@ export type StreamPlayerPayloadFragment = {
|
|
|
56
57
|
image: string | null;
|
|
57
58
|
name: string;
|
|
58
59
|
id: string;
|
|
60
|
+
type: SchemaTypes.ProfileType;
|
|
59
61
|
};
|
|
60
62
|
availableFrom: {
|
|
61
63
|
image: string;
|
|
@@ -26,7 +26,8 @@ export const StreamPlayerPayloadFragmentDoc = {
|
|
|
26
26
|
selections: [
|
|
27
27
|
{ kind: 'Field', name: { kind: 'Name', value: 'image' } },
|
|
28
28
|
{ kind: 'Field', name: { kind: 'Name', value: 'name' } },
|
|
29
|
-
{ kind: 'Field', name: { kind: 'Name', value: 'id' } }
|
|
29
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
|
|
30
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'type' } }
|
|
30
31
|
]
|
|
31
32
|
}
|
|
32
33
|
},
|
|
@@ -108,7 +109,8 @@ export const GetStreamDocument = {
|
|
|
108
109
|
selections: [
|
|
109
110
|
{ kind: 'Field', name: { kind: 'Name', value: 'image' } },
|
|
110
111
|
{ kind: 'Field', name: { kind: 'Name', value: 'name' } },
|
|
111
|
-
{ kind: 'Field', name: { kind: 'Name', value: 'id' } }
|
|
112
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
|
|
113
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'type' } }
|
|
112
114
|
]
|
|
113
115
|
}
|
|
114
116
|
},
|
|
@@ -15,11 +15,14 @@ export declare class StreamPlayerBuffer implements IPlayerBuffer<StreamPageViewe
|
|
|
15
15
|
constructor(init: {
|
|
16
16
|
streamId: string;
|
|
17
17
|
dataProvider: IStreamPlayerDataProvider;
|
|
18
|
+
on?: {
|
|
19
|
+
preloaded?: (self: StreamPlayerBuffer) => void;
|
|
20
|
+
};
|
|
18
21
|
});
|
|
19
22
|
loadMore: () => Promise<StreamPageViewerModel[]>;
|
|
20
23
|
loadNext: () => Promise<void>;
|
|
21
24
|
loadPrevious: () => Promise<void>;
|
|
22
25
|
setIndex: (index: number) => void;
|
|
23
|
-
reset: () => Promise<void>;
|
|
26
|
+
reset: (onPreloaded?: (self: StreamPlayerBuffer) => void) => Promise<void>;
|
|
24
27
|
private warmUpBuffer;
|
|
25
28
|
}
|
|
@@ -14,7 +14,7 @@ export class StreamPlayerBuffer {
|
|
|
14
14
|
_loaded = $state.raw([]);
|
|
15
15
|
_pagesLoader;
|
|
16
16
|
constructor(init) {
|
|
17
|
-
const { streamId, dataProvider } = init;
|
|
17
|
+
const { streamId, dataProvider, on } = init;
|
|
18
18
|
this._pagesLoader = new CursorDataLoader({
|
|
19
19
|
loadPage: async (continuationToken) => {
|
|
20
20
|
const result = await dataProvider.getStreamPages(streamId, continuationToken.toNextChunkString());
|
|
@@ -26,7 +26,7 @@ export class StreamPlayerBuffer {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
|
-
this.warmUpBuffer();
|
|
29
|
+
this.warmUpBuffer(on?.preloaded);
|
|
30
30
|
this.loadNext = Utils.throttle(this.loadNext, this.animationDuration);
|
|
31
31
|
this.loadPrevious = Utils.throttle(this.loadPrevious, this.animationDuration);
|
|
32
32
|
}
|
|
@@ -48,21 +48,31 @@ export class StreamPlayerBuffer {
|
|
|
48
48
|
this._currentIndex = index;
|
|
49
49
|
this.warmUpBuffer();
|
|
50
50
|
};
|
|
51
|
-
reset = async () => {
|
|
51
|
+
reset = async (onPreloaded) => {
|
|
52
52
|
this._loaded = [];
|
|
53
53
|
this._currentIndex = -1;
|
|
54
54
|
await this._pagesLoader.reset();
|
|
55
|
-
this.warmUpBuffer();
|
|
55
|
+
this.warmUpBuffer(onPreloaded);
|
|
56
56
|
};
|
|
57
|
-
warmUpBuffer = async () => {
|
|
57
|
+
warmUpBuffer = async (onPreloaded) => {
|
|
58
58
|
const bufferSize = 2;
|
|
59
59
|
if (this.loaded.length >= this.currentIndex + bufferSize) {
|
|
60
|
+
if (onPreloaded) {
|
|
61
|
+
onPreloaded(this);
|
|
62
|
+
}
|
|
60
63
|
return;
|
|
61
64
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (this.
|
|
65
|
-
this.
|
|
65
|
+
try {
|
|
66
|
+
await this.loadMore();
|
|
67
|
+
if (this._currentIndex < 0) {
|
|
68
|
+
if (this.loaded.length > 0) {
|
|
69
|
+
this._currentIndex = 0;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
if (onPreloaded) {
|
|
75
|
+
onPreloaded(this);
|
|
66
76
|
}
|
|
67
77
|
}
|
|
68
78
|
};
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { handleEsc } from '../../core/document.event-handlers';
|
|
11
|
+
import { preloadImage } from '../../core/image-preloader';
|
|
11
12
|
import { toastrWarning } from '../../core/toastr';
|
|
12
13
|
import { ShortVideoViewer } from '../../short-videos/short-video-viewer';
|
|
13
14
|
import { mapToShortVideoViewerModel } from '../layout/models';
|
|
@@ -21,12 +22,12 @@ import { default as Overview } from './stream-overview.svelte';
|
|
|
21
22
|
import { StreamPlayerBuffer } from './stream-player-buffer.svelte';
|
|
22
23
|
import { StreamPlayerLocalization } from './stream-player-localization';
|
|
23
24
|
import { StreamPlayerUiManager } from './ui-manager.svelte';
|
|
24
|
-
import { onMount } from 'svelte';
|
|
25
|
+
import { onMount, untrack } from 'svelte';
|
|
25
26
|
let { streamId, dataProvider, analyticsHandler, localization: localizationInit = 'en', showStreamsCloudWatermark, postSocialInteractionsHandler, on } = $props();
|
|
26
27
|
const localization = $derived(new StreamPlayerLocalization(localizationInit));
|
|
27
28
|
let model = $state(null);
|
|
28
29
|
let buffer = $state.raw(null);
|
|
29
|
-
let
|
|
30
|
+
let bufferIsLoading = $state(false);
|
|
30
31
|
let activePageId = $derived.by(() => { var _a, _b; return (_b = (_a = buffer === null || buffer === void 0 ? void 0 : buffer.current) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : ''; });
|
|
31
32
|
let everTouched = $state(false);
|
|
32
33
|
let totalEngagementTimeSeconds = 0;
|
|
@@ -48,27 +49,49 @@ const resetInactivityTimer = () => {
|
|
|
48
49
|
isActive = false;
|
|
49
50
|
}, inactiveTimeSeconds * 1000);
|
|
50
51
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
buffer = new StreamPlayerBuffer({ streamId, dataProvider: dataProvider });
|
|
66
|
-
analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackStreamView(stream.id);
|
|
67
|
-
startActivityTracking();
|
|
52
|
+
$effect(() => {
|
|
53
|
+
void dataProvider;
|
|
54
|
+
untrack(() => {
|
|
55
|
+
initBuffer(dataProvider);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
const initBuffer = (dataProvider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
var _a;
|
|
60
|
+
bufferIsLoading = true;
|
|
61
|
+
const stream = yield dataProvider.getStream(streamId);
|
|
62
|
+
if (!stream) {
|
|
63
|
+
toastrWarning(localization.streamNotFound);
|
|
64
|
+
onPlayerClose();
|
|
65
|
+
return;
|
|
68
66
|
}
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
if (stream.organizationId) {
|
|
68
|
+
analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.setOrganizationId(stream.organizationId);
|
|
71
69
|
}
|
|
70
|
+
(_a = on === null || on === void 0 ? void 0 : on.streamActivated) === null || _a === void 0 ? void 0 : _a.call(on, { title: stream.title, image: stream.cover });
|
|
71
|
+
// start tracking the stream
|
|
72
|
+
model = stream;
|
|
73
|
+
buffer = new StreamPlayerBuffer({
|
|
74
|
+
streamId,
|
|
75
|
+
dataProvider: dataProvider,
|
|
76
|
+
on: {
|
|
77
|
+
preloaded: (instance) => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
if (instance.loaded.length) {
|
|
79
|
+
const coverUrl = instance.loaded[0].cover;
|
|
80
|
+
if (coverUrl) {
|
|
81
|
+
yield preloadImage(coverUrl);
|
|
82
|
+
}
|
|
83
|
+
background = coverUrl;
|
|
84
|
+
}
|
|
85
|
+
buffer = instance;
|
|
86
|
+
bufferIsLoading = false;
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackStreamView(stream.id);
|
|
91
|
+
startActivityTracking();
|
|
92
|
+
});
|
|
93
|
+
onMount(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
+
uiManager.overviewCollapsed = window && window.innerWidth < window.innerHeight;
|
|
72
95
|
}));
|
|
73
96
|
const startActivityTracking = () => {
|
|
74
97
|
trackingInterval = setInterval(() => {
|
|
@@ -175,10 +198,10 @@ const onProgress = (pageId, videoId, progress) => {
|
|
|
175
198
|
|
|
176
199
|
<svelte:document onkeydown={(e) => handleEsc(e, onPlayerClose)} />
|
|
177
200
|
|
|
178
|
-
<div
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
{
|
|
201
|
+
<div
|
|
202
|
+
class="stream-player-container"
|
|
203
|
+
class:stream-player-container--background-loading={!background}
|
|
204
|
+
style={background ? `--background-image: url(${background})` : null}>
|
|
182
205
|
<div class="stream-player" style={uiManager.globalCssVariables}>
|
|
183
206
|
{#if showStreamsCloudWatermark}
|
|
184
207
|
<div class="stream-player__watermark">
|
|
@@ -187,7 +210,7 @@ const onProgress = (pageId, videoId, progress) => {
|
|
|
187
210
|
</a>
|
|
188
211
|
</div>
|
|
189
212
|
{/if}
|
|
190
|
-
{#if buffer && model}
|
|
213
|
+
{#if buffer && model && !bufferIsLoading}
|
|
191
214
|
<SpotlightLayout ratio={9 / 16} on={{ dimensionsChanged: handleDimensionsChanged }}>
|
|
192
215
|
<div class="stream-player__content" use:contentMounted>
|
|
193
216
|
<PlayerSlider
|
|
@@ -211,8 +234,8 @@ const onProgress = (pageId, videoId, progress) => {
|
|
|
211
234
|
model={mapToShortVideoViewerModel(item.shortVideo)}
|
|
212
235
|
on={{
|
|
213
236
|
progress: (progress) => onProgress(item.id, item.shortVideo.id, progress),
|
|
214
|
-
productClick: (productId
|
|
215
|
-
productImpression: (productId
|
|
237
|
+
productClick: (productId) => onShortVideoProductClick(productId, item.shortVideo.id),
|
|
238
|
+
productImpression: (productId, videoId) => onShortVideoProductImpression(productId, videoId)
|
|
216
239
|
}}
|
|
217
240
|
autoplay="on-appearance"
|
|
218
241
|
socialInteractionsHandler={postSocialInteractionsHandler}
|
|
@@ -249,6 +272,8 @@ const onProgress = (pageId, videoId, progress) => {
|
|
|
249
272
|
productClick: (productId: String) => onProductCardClick(productId),
|
|
250
273
|
productImpression: (productId: String) => onStreamProductImpression(productId)
|
|
251
274
|
}} />
|
|
275
|
+
{:else}
|
|
276
|
+
<Loading positionFixedCenter={true} timeout={1000} />
|
|
252
277
|
{/if}
|
|
253
278
|
</div>
|
|
254
279
|
</div>
|
|
@@ -274,11 +299,16 @@ const onProgress = (pageId, videoId, progress) => {
|
|
|
274
299
|
container-type: inline-size;
|
|
275
300
|
display: flex;
|
|
276
301
|
position: relative;
|
|
302
|
+
}
|
|
303
|
+
.stream-player-container {
|
|
277
304
|
background-color: #c1c1c1;
|
|
278
305
|
background-image: var(--background-image);
|
|
279
306
|
background-size: cover;
|
|
280
307
|
background-blend-mode: multiply;
|
|
281
308
|
}
|
|
309
|
+
.stream-player-container--background-loading {
|
|
310
|
+
background-color: transparent;
|
|
311
|
+
}
|
|
282
312
|
|
|
283
313
|
.stream-player {
|
|
284
314
|
display: flex;
|