@tivio/sdk-react 2.3.4-beta.1 → 2.3.4-beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. package/dist/components/ContextProvider.d.ts +3 -0
  2. package/dist/components/PlayerProvider.d.ts +19 -0
  3. package/dist/components/TivioProvider.d.ts +17 -0
  4. package/dist/components/TivioWidget.d.ts +7 -0
  5. package/dist/components/TivioWidgetError.d.ts +10 -0
  6. package/dist/components/TivioWidgetLoader.d.ts +6 -0
  7. package/dist/components/TvTivioProvider.d.ts +7 -0
  8. package/dist/components/context/ChannelsContext.d.ts +6 -0
  9. package/dist/components/context/OrganizationSubscriptionsContext.d.ts +9 -0
  10. package/dist/components/context/PurchasesWithVideosContext.d.ts +9 -0
  11. package/dist/components/context/RowItemsContext.d.ts +7 -0
  12. package/dist/components/context/ScreensContext.d.ts +6 -0
  13. package/dist/components/context/SectionsContext.d.ts +6 -0
  14. package/dist/components/context/UserContext.d.ts +9 -0
  15. package/dist/components/context/VideosContext.d.ts +6 -0
  16. package/dist/components/context/index.d.ts +8 -0
  17. package/dist/components/context/types.d.ts +27 -0
  18. package/dist/components/hooks/contentHooks.d.ts +68 -0
  19. package/dist/components/hooks/index.d.ts +16 -0
  20. package/dist/components/hooks/playerHooks.d.ts +23 -0
  21. package/dist/components/hooks/useCancelSubscription.d.ts +2 -0
  22. package/dist/components/hooks/useError.d.ts +9 -0
  23. package/dist/components/hooks/useFreePurchase.d.ts +4 -0
  24. package/dist/components/hooks/useItemsInRow.d.ts +11 -0
  25. package/dist/components/hooks/useOrganizationSubscriptions.d.ts +4 -0
  26. package/dist/components/hooks/usePurchaseSubscription.d.ts +3 -0
  27. package/dist/components/hooks/usePurchasesWithVideos.d.ts +7 -0
  28. package/dist/components/hooks/useRowsInScreen.d.ts +6 -0
  29. package/dist/components/hooks/useScreen.d.ts +12 -0
  30. package/dist/components/hooks/useScreens.d.ts +5 -0
  31. package/dist/components/hooks/useSearch.d.ts +8 -0
  32. package/dist/components/hooks/useTaggedVideos.d.ts +11 -0
  33. package/dist/components/hooks/useTivio.d.ts +3 -0
  34. package/dist/components/hooks/useTransactionPayment.d.ts +3 -0
  35. package/dist/components/hooks/useUser.d.ts +5 -0
  36. package/dist/config.d.ts +17 -0
  37. package/dist/index.d.ts +23 -0
  38. package/dist/index.js +1 -0
  39. package/dist/services/bundleLoader.d.ts +13 -0
  40. package/dist/services/bundlePromise.d.ts +4 -0
  41. package/dist/services/dependencyResolver.d.ts +23 -0
  42. package/dist/services/logger.d.ts +26 -0
  43. package/dist/services/packageLoader.d.ts +6 -0
  44. package/dist/services/pubSub.d.ts +13 -0
  45. package/dist/services/sentry.d.ts +4 -0
  46. package/dist/services/settings.d.ts +13 -0
  47. package/dist/types/bundle.types.d.ts +206 -0
  48. package/dist/types/common.d.ts +6 -0
  49. package/dist/types/config.types.d.ts +0 -0
  50. package/dist/types/customPlayer.types.d.ts +38 -0
  51. package/dist/types/types.d.ts +176 -0
  52. package/package.json +1 -1
@@ -0,0 +1,206 @@
1
+ import { SubscribeToTaggedVideos, UseCancelSubscription } from '@tivio/common';
2
+ import { ComponentType } from 'react';
3
+ import { Logger } from '../services/logger';
4
+ import { FetchPackage } from '../services/packageLoader';
5
+ import { Disposer, Empty, Nullable } from './common';
6
+ import { Channel, Language, RemoteProviderProps, Section, TivioSources, TivioWidgetProps, UserData, WebPlayerProps, Widget } from './types';
7
+ import type { AdSource, PlayerWrapper } from './customPlayer.types';
8
+ import type { Monetization, QerkoPaymentInfo, Screen, SubscribeToItemsInRow, SubscribeToRowsInScreen, SubscribeToScreen, TvAppProps, Video, User, Purchase, UseSearch } from '@tivio/common';
9
+ import type React from 'react';
10
+ declare type Settings = {
11
+ onSetUser: (handler: (userId: string, userPayload: unknown) => void) => void;
12
+ setUser: (userId: string, userPayload: unknown) => void;
13
+ };
14
+ declare type InternalConfig = {
15
+ enable?: boolean;
16
+ secret: string | null;
17
+ verbose?: boolean;
18
+ resolverUrl: string;
19
+ bundleUrlOverride?: string;
20
+ disableUnmounting?: boolean;
21
+ logger?: Logger | null;
22
+ fetchPackage: FetchPackage;
23
+ pubSub: PubSub;
24
+ LoaderComponent?: ComponentType;
25
+ ErrorComponent?: ComponentType<{
26
+ error: string | null;
27
+ }>;
28
+ language?: string;
29
+ sdkVersion: string;
30
+ enableSentry?: boolean;
31
+ };
32
+ declare type Events = {
33
+ 'on-ready': RemoteBundleState;
34
+ 'on-error': Error;
35
+ };
36
+ interface PubSub {
37
+ publish: <K extends keyof Events>(triggerName: K, payload: Events[K]) => Empty;
38
+ subscribe: <K extends keyof Events>(triggerName: K, onMessage: (data: Events[K]) => Empty) => Disposer;
39
+ }
40
+ declare type Config = Pick<InternalConfig, 'enable' | 'secret' | 'verbose' | 'logger' | 'disableUnmounting' | 'bundleUrlOverride' | 'LoaderComponent' | 'ErrorComponent' | 'language' | 'enableSentry'>;
41
+ declare type TivioSubscriptions = {
42
+ subscribeToUser: (cb: (error: string | null, user: User | null) => void) => void;
43
+ /**
44
+ * Listen to widget changes.
45
+ * @param widgetId - widget id
46
+ * @param cb - callback on widget updates or on error
47
+ */
48
+ subscribeToWidget: (widgetId: string, cb: (error: Error | null, data: Widget | null, disposer?: Disposer) => void) => void;
49
+ /**
50
+ * Listen to channel changes.
51
+ * @param channelId - channel id
52
+ * @param cb - callback on channel updates or on error
53
+ */
54
+ subscribeToChannel: (channelId: string, cb: (error: Error | null, data: Channel | null) => void) => void;
55
+ /**
56
+ * Listen to section changes.
57
+ * @param sectionId - section id
58
+ * @param cb - callback on section updates or on error
59
+ */
60
+ subscribeToSection: (sectionId: string, cb: (error: Error | null, data: Section | null) => void) => void;
61
+ /**
62
+ * Listen to video changes.
63
+ * @param videoId - video id
64
+ * @param cb - callback on video updates or on error
65
+ */
66
+ subscribeToVideo: (videoId: string, cb: (error: Error | null, data: Video | null, disposer?: Disposer) => void) => void;
67
+ /**
68
+ * Listen to videos in section changes.
69
+ * @param sectionId - section id
70
+ * @param cb - callback on videos change or error
71
+ * @param limit - videos count
72
+ */
73
+ subscribeToVideosInSection: (sectionId: string, cb: (error: null | Error, data: null | {
74
+ videos: Video[];
75
+ hasNextPage: boolean;
76
+ }, fetchMore: null | ((count?: number) => void), isLoading: boolean) => void, limit?: number) => void;
77
+ /**
78
+ * Listen to section in channel changes
79
+ * @param channelId - channel id
80
+ * @param cb - callback on sections change or error
81
+ * @param limit - sections count
82
+ */
83
+ subscribeToSectionsInChannel: (channelId: string, cb: (error: null | Error, data: null | {
84
+ sections: Section[];
85
+ hasNextPage: boolean;
86
+ }, fetchMore: null | ((count?: number) => void), isLoading: boolean) => void, limit?: number) => void;
87
+ /**
88
+ * Listen to channels in widget changes
89
+ * @param widgetId - widget id
90
+ * @param cb - callback on channels change or error
91
+ * @param limit - channels count
92
+ */
93
+ subscribeToChannelsInWidget: (widgetId: string, cb: (error: null | Error, data: null | {
94
+ channels: Channel[];
95
+ hasNextPage: boolean;
96
+ }, fetchMore: null | ((count?: number) => void), isLoading: boolean) => void, limit?: number) => void;
97
+ subscribeToScreen: SubscribeToScreen;
98
+ subscribeToItemsInRow: SubscribeToItemsInRow;
99
+ subscribeToRowsInScreen: SubscribeToRowsInScreen;
100
+ subscribeToTaggedVideos: SubscribeToTaggedVideos;
101
+ };
102
+ declare type TivioGetters = {
103
+ isTivioLoaded: (cb: (isLoaded: boolean) => void) => boolean;
104
+ isSignedIn: () => boolean;
105
+ /**
106
+ * Get channel by its id.
107
+ * @param channelId - channel id
108
+ * @returns {Promise<Channel | null>} channel or null if channel does not exists
109
+ */
110
+ getChannelById: (channelId: string) => Promise<Channel | null>;
111
+ /**
112
+ * Get (or create) player wrapper instance
113
+ * @param opt - player getter options
114
+ * @returns {PlayerWrapper} player wrapper instance
115
+ */
116
+ getPlayerWrapper: (opt: {
117
+ playerWrapperId?: string;
118
+ }) => PlayerWrapper;
119
+ getOrganizationScreens: () => Promise<Screen[]>;
120
+ getOrganizationSubscriptions: () => Promise<Monetization[] | undefined>;
121
+ /**
122
+ * Get section by its id.
123
+ * @param sectionId - section id
124
+ * @returns {Promise<{section: Section, channel: Channel} | null>} section and channel or null if channel or section does not exists
125
+ */
126
+ getSectionById: (sectionId: string) => Promise<Section | null>;
127
+ /**
128
+ * Get video by its id.
129
+ * @param videoId - video id
130
+ * @returns {Promise<Video | null>} video or null if video does not exists
131
+ */
132
+ getVideoById: (videoId: string) => Promise<Video | null>;
133
+ /**
134
+ * Get widget by its id.
135
+ * @param widgetId - widget id
136
+ * @returns {Promise<Widget | null>} widget or null if widget does not exists
137
+ */
138
+ getWidgetById: (widgetId: string) => Promise<Widget | null>;
139
+ };
140
+ interface TivioAuth {
141
+ changePassword: (newPassword: string) => Promise<void>;
142
+ changeUserPhoto(file: File): Promise<void>;
143
+ removeUserPhoto(): Promise<void>;
144
+ getPurchasedVodsWithInitializedVideos: () => Promise<Purchase[]>;
145
+ /**
146
+ * @param email
147
+ * @param password
148
+ */
149
+ createUserWithEmailAndPassword: (email: string, password: string, userData?: UserData) => Promise<void>;
150
+ /**
151
+ * Sign in the user and starts listening on his purchases
152
+ * @param email
153
+ * @param password
154
+ */
155
+ signInWithEmailAndPassword: (email: string, password: string) => Promise<void>;
156
+ initializeUser: () => Promise<void>;
157
+ signOut: () => Promise<void>;
158
+ createFreePurchase: (monetizationId: string) => Promise<void>;
159
+ }
160
+ declare type TivioComponents = {
161
+ AdIndicationButtonWeb: React.ReactNode;
162
+ Markers: React.ReactNode;
163
+ PlayerDataContext: React.ReactNode;
164
+ Provider: React.ComponentType<RemoteProviderProps>;
165
+ SkipButtonWeb: React.ReactNode;
166
+ VideoAdBanner: React.ReactNode;
167
+ WebPlayer: React.ComponentType<WebPlayerProps>;
168
+ Widget: React.ComponentType<TivioWidgetProps>;
169
+ TvPlayer: React.ComponentType<WebPlayerProps>;
170
+ PlayerDataContextProvider: React.ComponentType<{
171
+ id: string;
172
+ }>;
173
+ SkipButtonTv: React.ComponentType<{
174
+ Button: React.ComponentType;
175
+ Label: React.ComponentType;
176
+ Container: React.ComponentType;
177
+ onStarted?: () => any;
178
+ onEnded?: () => any;
179
+ }>;
180
+ TvApp: React.ComponentType<TvAppProps>;
181
+ };
182
+ declare type TivioHooks = {
183
+ useAd: () => [(AdSource | null)];
184
+ useCancelSubscription: UseCancelSubscription;
185
+ useSearch: UseSearch;
186
+ };
187
+ declare type TivioBundle = {
188
+ components: TivioComponents;
189
+ getters: TivioGetters;
190
+ auth: TivioAuth;
191
+ hooks: TivioHooks;
192
+ init: (config: Config) => void | Promise<void>;
193
+ purchaseVideoWithQerko: (videoId: string, monetizationId: string) => Promise<QerkoPaymentInfo>;
194
+ purchaseSubscriptionWithQerko: (monetizationId: string) => Promise<QerkoPaymentInfo>;
195
+ setLanguage: (language: Language) => void;
196
+ setUser: (userId: string, userPayload?: unknown) => void;
197
+ sources: TivioSources;
198
+ subscriptions: TivioSubscriptions;
199
+ };
200
+ declare type RemoteBundleState = {
201
+ config: InternalConfig;
202
+ error: string | null;
203
+ settings: Settings;
204
+ state: 'loading' | 'error' | 'ready';
205
+ } & Nullable<TivioBundle>;
206
+ export type { RemoteBundleState, Config, Settings, InternalConfig, TivioBundle, TivioHooks, TivioComponents, TivioAuth, TivioGetters, TivioSubscriptions, Events, PubSub, };
@@ -0,0 +1,6 @@
1
+ declare type Nullable<T> = {
2
+ [P in keyof T]: T[P] | null;
3
+ };
4
+ declare type Empty = void | Promise<void> | undefined | Promise<undefined>;
5
+ declare type Disposer = () => void;
6
+ export { Disposer, Empty, Nullable, };
File without changes
@@ -0,0 +1,38 @@
1
+ import { Empty } from './common';
2
+ export interface BasicSource {
3
+ description: string;
4
+ name: string;
5
+ uri: string;
6
+ type: 'AD' | 'VOD' | 'CHANNEL';
7
+ }
8
+ export interface ChannelSource extends BasicSource {
9
+ from: Date;
10
+ channelName: string;
11
+ to: Date;
12
+ type: 'CHANNEL';
13
+ }
14
+ export interface AdSource extends BasicSource {
15
+ durationMs: number;
16
+ skipDelayMs: number | null;
17
+ type: 'AD';
18
+ canSkip?: boolean;
19
+ skip?: () => void;
20
+ }
21
+ export interface VodSource extends BasicSource {
22
+ type: 'VOD';
23
+ }
24
+ export declare type InputSource = AdSource | ChannelSource | VodSource;
25
+ export declare type PlayerInterface = {
26
+ play: () => Empty;
27
+ pause: () => Empty;
28
+ seekTo: (positionMs: number) => Empty;
29
+ setSource: (source: InputSource | null) => Empty;
30
+ setVolume: (volume: number) => Empty;
31
+ };
32
+ export declare type PlayerWrapper = {
33
+ events: {
34
+ addListener: <T = any>(event: string, cb: (value: T) => Empty) => Empty;
35
+ removeAllListeners: () => Empty;
36
+ };
37
+ };
38
+ export declare type UsePlayerEvent = <T = any>(eventName: string) => T | null;
@@ -0,0 +1,176 @@
1
+ /**
2
+ * Copyright (c) 2021, nangu.TV, a.s. All rights reserved.
3
+ * nangu.TV, a.s PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
4
+ */
5
+ /**
6
+ * Export public client side API
7
+ */
8
+ import { USER_TYPE } from '@tivio/common';
9
+ import type { Monetization, Video } from '@tivio/common';
10
+ import type React from 'react';
11
+ declare type RemoteProviderProps = {
12
+ disableUnmounting?: boolean;
13
+ language?: string;
14
+ };
15
+ declare type Language = 'cs' | 'en' | 'sk' | 'de' | 'pl';
16
+ declare type User = {
17
+ purchases: Purchase[];
18
+ purchasedVods: Purchase[];
19
+ purchasedSubscriptions: Purchase[];
20
+ getPurchasedVodsWithInitializedVideos: () => Promise<Purchase[]>;
21
+ isPurchasesInitialized: boolean;
22
+ isSignedIn: boolean;
23
+ email: string;
24
+ type?: USER_TYPE;
25
+ photoURL: string | null;
26
+ name?: string;
27
+ authUserId?: string;
28
+ };
29
+ interface UserData {
30
+ name?: string;
31
+ }
32
+ declare type Widget = {
33
+ id: string;
34
+ channels: Channel[];
35
+ isEnabled: boolean | null;
36
+ name: string | null;
37
+ recentVideos: Video[] | null;
38
+ widgetId: string | null;
39
+ lastVideo: Video | null;
40
+ };
41
+ declare type Channel = {
42
+ id: string;
43
+ name: string;
44
+ header: string;
45
+ headerLogo: string;
46
+ recentVideos: Video[];
47
+ };
48
+ declare type Section = {
49
+ id: string;
50
+ name: string;
51
+ channel: Channel;
52
+ videos: Video[];
53
+ };
54
+ declare type Chapter = object;
55
+ declare type Purchase = {
56
+ isPurchased: boolean;
57
+ monetizationId: string;
58
+ videoId: string;
59
+ status: string;
60
+ video: Video | null;
61
+ };
62
+ declare type Marker = {
63
+ id: string;
64
+ type: string;
65
+ from: Date;
66
+ to: Date;
67
+ count?: number;
68
+ fromMs?: number;
69
+ toMs?: number;
70
+ };
71
+ declare type BetOffer = {
72
+ betService: string;
73
+ league: string;
74
+ odds: {
75
+ winner: string;
76
+ rate: number;
77
+ }[];
78
+ sport: string;
79
+ opponent1: string;
80
+ opponent2: string;
81
+ time: Date;
82
+ };
83
+ export interface TivioWidgetProps {
84
+ id: string;
85
+ ref: React.MutableRefObject<TivioWidgetRef>;
86
+ onEnabled?: (enabled: boolean) => any;
87
+ onBlur?: (event: {
88
+ key: string;
89
+ width: number;
90
+ x: number;
91
+ }) => any;
92
+ }
93
+ export interface TivioWidgetRef {
94
+ focus: (args: {
95
+ x?: number;
96
+ }) => void;
97
+ handleKey: (key: string) => ({
98
+ handled: boolean;
99
+ x: number;
100
+ });
101
+ unfocus: () => ({
102
+ x: number;
103
+ });
104
+ }
105
+ interface VodTivioSource {
106
+ type: 'VodTivioSource';
107
+ description: string;
108
+ path: string;
109
+ name: string;
110
+ uri: string;
111
+ poster?: string;
112
+ adMonetizationId?: string;
113
+ }
114
+ interface ChannelSource {
115
+ type: 'ChannelSource';
116
+ uri: string;
117
+ originalOptions: any;
118
+ channelName: string;
119
+ programName: string;
120
+ programDescription: string;
121
+ from: Date;
122
+ to: Date;
123
+ poster?: string;
124
+ }
125
+ declare type VideoPath = string;
126
+ interface WebPlayerProps {
127
+ id: string;
128
+ source?: VodTivioSource | ChannelSource | VideoPath | null;
129
+ onEnded?: () => any;
130
+ className?: string;
131
+ /**
132
+ * default false
133
+ *
134
+ * If you choose `autoplay` make sure that autoplay is allowed in the specific situation.
135
+ * In some cases it may not be allowed, e.g. before the user interacted with the site, and the video
136
+ * will stay paused.
137
+ *
138
+ * Source: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide
139
+ */
140
+ autoplay?: boolean;
141
+ /**
142
+ * default false
143
+ */
144
+ canReplay?: boolean;
145
+ /**
146
+ * default false
147
+ */
148
+ showMarkers?: boolean;
149
+ /**
150
+ * number[] is array of keyboard event.which numeric codes
151
+ * (see https://keycode.info/)
152
+ */
153
+ customShortcuts?: Partial<{
154
+ toggleFullscreen: number[];
155
+ togglePause: number[];
156
+ toggleMute: number[];
157
+ jumpForward: number[];
158
+ jumpBack: number[];
159
+ volumeUp: number[];
160
+ volumeDown: number[];
161
+ }>;
162
+ /**
163
+ * default true
164
+ */
165
+ enableKeyboardShortcuts?: boolean;
166
+ onProgress?: (event: React.ChangeEvent<HTMLVideoElement>) => void;
167
+ onLoadedMetadata?: (event: React.ChangeEvent<HTMLVideoElement>) => void;
168
+ onPlayerControllerCreated?: (playerController: any) => void;
169
+ }
170
+ declare type TivioSources = {
171
+ AdSource: any;
172
+ ChannelSource: any;
173
+ VodExternalSource: any;
174
+ VodTivioSource: any;
175
+ };
176
+ export type { RemoteProviderProps, WebPlayerProps, Marker, BetOffer, Purchase, Chapter, Language, Widget, Channel, Section, Video, TivioSources, UserData, User, Monetization, VodTivioSource, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tivio/sdk-react",
3
- "version": "2.3.4-beta.1",
3
+ "version": "2.3.4-beta.2",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "source": "src/index.ts",