@tivio/sdk-react 2.3.4-beta.1 → 2.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/README.md +39 -0
- package/dist/components/ContextProvider.d.ts +3 -0
- package/dist/components/PlayerProvider.d.ts +19 -0
- package/dist/components/TivioProvider.d.ts +17 -0
- package/dist/components/TivioWidget.d.ts +7 -0
- package/dist/components/TivioWidgetError.d.ts +10 -0
- package/dist/components/TivioWidgetLoader.d.ts +6 -0
- package/dist/components/TvTivioProvider.d.ts +7 -0
- package/dist/components/context/ChannelsContext.d.ts +6 -0
- package/dist/components/context/OrganizationSubscriptionsContext.d.ts +9 -0
- package/dist/components/context/PurchasesWithVideosContext.d.ts +9 -0
- package/dist/components/context/RowItemsContext.d.ts +7 -0
- package/dist/components/context/ScreensContext.d.ts +6 -0
- package/dist/components/context/SectionsContext.d.ts +6 -0
- package/dist/components/context/UserContext.d.ts +9 -0
- package/dist/components/context/VideosContext.d.ts +6 -0
- package/dist/components/context/index.d.ts +8 -0
- package/dist/components/context/types.d.ts +27 -0
- package/dist/components/hooks/contentHooks.d.ts +68 -0
- package/dist/components/hooks/index.d.ts +18 -0
- package/dist/components/hooks/playerHooks.d.ts +23 -0
- package/dist/components/hooks/useCancelSubscription.d.ts +2 -0
- package/dist/components/hooks/useError.d.ts +9 -0
- package/dist/components/hooks/useFreePurchase.d.ts +4 -0
- package/dist/components/hooks/useItemsInRow.d.ts +11 -0
- package/dist/components/hooks/useOrganizationSubscriptions.d.ts +4 -0
- package/dist/components/hooks/useOverlay.d.ts +13 -0
- package/dist/components/hooks/usePurchaseSubscription.d.ts +3 -0
- package/dist/components/hooks/usePurchasesWithVideos.d.ts +7 -0
- package/dist/components/hooks/useRowsInScreen.d.ts +6 -0
- package/dist/components/hooks/useScreen.d.ts +12 -0
- package/dist/components/hooks/useScreens.d.ts +5 -0
- package/dist/components/hooks/useSearch.d.ts +8 -0
- package/dist/components/hooks/useTaggedVideos.d.ts +11 -0
- package/dist/components/hooks/useTivio.d.ts +3 -0
- package/dist/components/hooks/useTransactionPayment.d.ts +3 -0
- package/dist/components/hooks/useUser.d.ts +5 -0
- package/dist/components/hooks/useWatchWithoutAds.d.ts +5 -0
- package/dist/config.d.ts +17 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +1 -0
- package/dist/services/bundleLoader.d.ts +16 -0
- package/dist/services/bundlePromise.d.ts +4 -0
- package/dist/services/dependencyResolver.d.ts +23 -0
- package/dist/services/localFetch/coreReactDomDist.d.ts +1 -0
- package/dist/services/localFetch/none.d.ts +1 -0
- package/dist/services/logger.d.ts +26 -0
- package/dist/services/packageLoader.d.ts +6 -0
- package/dist/services/pubSub.d.ts +13 -0
- package/dist/services/sentry.d.ts +4 -0
- package/dist/services/settings.d.ts +13 -0
- package/dist/types/bundle.types.d.ts +220 -0
- package/dist/types/common.d.ts +6 -0
- package/dist/types/config.types.d.ts +0 -0
- package/dist/types/customPlayer.types.d.ts +171 -0
- package/dist/types/types.d.ts +176 -0
- package/package.json +8 -6
@@ -0,0 +1,220 @@
|
|
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
|
+
/**
|
19
|
+
* @private URL of resolver. Resolver is a script used to fetch remove code bundle
|
20
|
+
*/
|
21
|
+
resolverUrl: string;
|
22
|
+
/**
|
23
|
+
* @private URL of remote code bundle to be fetched directly (without using resolver)
|
24
|
+
*/
|
25
|
+
bundleUrlOverride?: string;
|
26
|
+
disableUnmounting?: boolean;
|
27
|
+
logger?: Logger | null;
|
28
|
+
fetchPackage: FetchPackage;
|
29
|
+
pubSub: PubSub;
|
30
|
+
LoaderComponent?: ComponentType;
|
31
|
+
ErrorComponent?: ComponentType<{
|
32
|
+
error: string | null;
|
33
|
+
}>;
|
34
|
+
language?: string;
|
35
|
+
sdkVersion: string;
|
36
|
+
enableSentry?: boolean;
|
37
|
+
};
|
38
|
+
declare type Events = {
|
39
|
+
'on-ready': RemoteBundleState;
|
40
|
+
'on-error': Error;
|
41
|
+
};
|
42
|
+
interface PubSub {
|
43
|
+
publish: <K extends keyof Events>(triggerName: K, payload: Events[K]) => Empty;
|
44
|
+
subscribe: <K extends keyof Events>(triggerName: K, onMessage: (data: Events[K]) => Empty) => Disposer;
|
45
|
+
}
|
46
|
+
declare type Config = Pick<InternalConfig, 'enable' | 'secret' | 'verbose' | 'logger' | 'disableUnmounting' | 'bundleUrlOverride' | 'LoaderComponent' | 'ErrorComponent' | 'language' | 'enableSentry'>;
|
47
|
+
declare type TivioSubscriptions = {
|
48
|
+
subscribeToUser: (cb: (error: string | null, user: User | null) => void) => void;
|
49
|
+
/**
|
50
|
+
* Listen to widget changes.
|
51
|
+
* @param widgetId - widget id
|
52
|
+
* @param cb - callback on widget updates or on error
|
53
|
+
*/
|
54
|
+
subscribeToWidget: (widgetId: string, cb: (error: Error | null, data: Widget | null, disposer?: Disposer) => void) => void;
|
55
|
+
/**
|
56
|
+
* Listen to channel changes.
|
57
|
+
* @param channelId - channel id
|
58
|
+
* @param cb - callback on channel updates or on error
|
59
|
+
*/
|
60
|
+
subscribeToChannel: (channelId: string, cb: (error: Error | null, data: Channel | null) => void) => void;
|
61
|
+
/**
|
62
|
+
* Listen to section changes.
|
63
|
+
* @param sectionId - section id
|
64
|
+
* @param cb - callback on section updates or on error
|
65
|
+
*/
|
66
|
+
subscribeToSection: (sectionId: string, cb: (error: Error | null, data: Section | null) => void) => void;
|
67
|
+
/**
|
68
|
+
* Listen to video changes.
|
69
|
+
* @param videoId - video id
|
70
|
+
* @param cb - callback on video updates or on error
|
71
|
+
*/
|
72
|
+
subscribeToVideo: (videoId: string, cb: (error: Error | null, data: Video | null, disposer?: Disposer) => void) => void;
|
73
|
+
/**
|
74
|
+
* Listen to videos in section changes.
|
75
|
+
* @param sectionId - section id
|
76
|
+
* @param cb - callback on videos change or error
|
77
|
+
* @param limit - videos count
|
78
|
+
*/
|
79
|
+
subscribeToVideosInSection: (sectionId: string, cb: (error: null | Error, data: null | {
|
80
|
+
videos: Video[];
|
81
|
+
hasNextPage: boolean;
|
82
|
+
}, fetchMore: null | ((count?: number) => void), isLoading: boolean) => void, limit?: number) => void;
|
83
|
+
/**
|
84
|
+
* Listen to section in channel changes
|
85
|
+
* @param channelId - channel id
|
86
|
+
* @param cb - callback on sections change or error
|
87
|
+
* @param limit - sections count
|
88
|
+
*/
|
89
|
+
subscribeToSectionsInChannel: (channelId: string, cb: (error: null | Error, data: null | {
|
90
|
+
sections: Section[];
|
91
|
+
hasNextPage: boolean;
|
92
|
+
}, fetchMore: null | ((count?: number) => void), isLoading: boolean) => void, limit?: number) => void;
|
93
|
+
/**
|
94
|
+
* Listen to channels in widget changes
|
95
|
+
* @param widgetId - widget id
|
96
|
+
* @param cb - callback on channels change or error
|
97
|
+
* @param limit - channels count
|
98
|
+
*/
|
99
|
+
subscribeToChannelsInWidget: (widgetId: string, cb: (error: null | Error, data: null | {
|
100
|
+
channels: Channel[];
|
101
|
+
hasNextPage: boolean;
|
102
|
+
}, fetchMore: null | ((count?: number) => void), isLoading: boolean) => void, limit?: number) => void;
|
103
|
+
subscribeToScreen: SubscribeToScreen;
|
104
|
+
subscribeToItemsInRow: SubscribeToItemsInRow;
|
105
|
+
subscribeToRowsInScreen: SubscribeToRowsInScreen;
|
106
|
+
subscribeToTaggedVideos: SubscribeToTaggedVideos;
|
107
|
+
registerOverlayCallbacks: (callbacks: {
|
108
|
+
onShow: () => void;
|
109
|
+
onHide: () => void;
|
110
|
+
}) => void;
|
111
|
+
};
|
112
|
+
declare type TivioGetters = {
|
113
|
+
isTivioLoaded: (cb: (isLoaded: boolean) => void) => boolean;
|
114
|
+
isSignedIn: () => boolean;
|
115
|
+
/**
|
116
|
+
* Get channel by its id.
|
117
|
+
* @param channelId - channel id
|
118
|
+
* @returns {Promise<Channel | null>} channel or null if channel does not exists
|
119
|
+
*/
|
120
|
+
getChannelById: (channelId: string) => Promise<Channel | null>;
|
121
|
+
/**
|
122
|
+
* Get (or create) player wrapper instance
|
123
|
+
* @param opt - player getter options
|
124
|
+
* @returns {PlayerWrapper} player wrapper instance
|
125
|
+
*/
|
126
|
+
getPlayerWrapper: (opt: {
|
127
|
+
playerWrapperId?: string;
|
128
|
+
}) => PlayerWrapper;
|
129
|
+
getOrganizationScreens: () => Promise<Screen[]>;
|
130
|
+
getOrganizationSubscriptions: () => Promise<Monetization[] | undefined>;
|
131
|
+
/**
|
132
|
+
* Get section by its id.
|
133
|
+
* @param sectionId - section id
|
134
|
+
* @returns {Promise<{section: Section, channel: Channel} | null>} section and channel or null if channel or section does not exists
|
135
|
+
*/
|
136
|
+
getSectionById: (sectionId: string) => Promise<Section | null>;
|
137
|
+
/**
|
138
|
+
* Get video by its id.
|
139
|
+
* @param videoId - video id
|
140
|
+
* @returns {Promise<Video | null>} video or null if video does not exists
|
141
|
+
*/
|
142
|
+
getVideoById: (videoId: string) => Promise<Video | null>;
|
143
|
+
/**
|
144
|
+
* Get widget by its id.
|
145
|
+
* @param widgetId - widget id
|
146
|
+
* @returns {Promise<Widget | null>} widget or null if widget does not exists
|
147
|
+
*/
|
148
|
+
getWidgetById: (widgetId: string) => Promise<Widget | null>;
|
149
|
+
};
|
150
|
+
interface TivioAuth {
|
151
|
+
changePassword: (newPassword: string) => Promise<void>;
|
152
|
+
changeUserPhoto(file: File): Promise<void>;
|
153
|
+
removeUserPhoto(): Promise<void>;
|
154
|
+
getPurchasedVodsWithInitializedVideos: () => Promise<Purchase[]>;
|
155
|
+
/**
|
156
|
+
* @param email
|
157
|
+
* @param password
|
158
|
+
*/
|
159
|
+
createUserWithEmailAndPassword: (email: string, password: string, userData?: UserData) => Promise<void>;
|
160
|
+
/**
|
161
|
+
* Sign in the user and starts listening on his purchases
|
162
|
+
* @param email
|
163
|
+
* @param password
|
164
|
+
*/
|
165
|
+
signInWithEmailAndPassword: (email: string, password: string) => Promise<void>;
|
166
|
+
initializeUser: () => Promise<void>;
|
167
|
+
signOut: () => Promise<void>;
|
168
|
+
createFreePurchase: (monetizationId: string) => Promise<void>;
|
169
|
+
}
|
170
|
+
declare type TivioComponents = {
|
171
|
+
AdIndicationButtonWeb: React.ReactNode;
|
172
|
+
Markers: React.ReactNode;
|
173
|
+
PlayerDataContext: React.ReactNode;
|
174
|
+
Provider: React.ComponentType<RemoteProviderProps>;
|
175
|
+
Recommendation: React.ReactNode;
|
176
|
+
SkipButtonWeb: React.ReactNode;
|
177
|
+
VideoAdBanner: React.ReactNode;
|
178
|
+
WebPlayer: React.ComponentType<WebPlayerProps>;
|
179
|
+
Widget: React.ComponentType<TivioWidgetProps>;
|
180
|
+
TvPlayer: React.ComponentType<WebPlayerProps>;
|
181
|
+
PlayerDataContextProvider: React.ComponentType<{
|
182
|
+
id: string;
|
183
|
+
}>;
|
184
|
+
SkipButtonTv: React.ComponentType<{
|
185
|
+
Button: React.ComponentType;
|
186
|
+
Label: React.ComponentType;
|
187
|
+
Container: React.ComponentType;
|
188
|
+
onStarted?: () => any;
|
189
|
+
onEnded?: () => any;
|
190
|
+
}>;
|
191
|
+
TvApp: React.ComponentType<TvAppProps>;
|
192
|
+
};
|
193
|
+
declare type TivioHooks = {
|
194
|
+
useAd: () => [(AdSource | null)];
|
195
|
+
useCancelSubscription: UseCancelSubscription;
|
196
|
+
useSearch: UseSearch;
|
197
|
+
};
|
198
|
+
declare type TivioBundle = {
|
199
|
+
components: TivioComponents;
|
200
|
+
getters: TivioGetters;
|
201
|
+
auth: TivioAuth;
|
202
|
+
hooks: TivioHooks;
|
203
|
+
init: (config: Config) => void | Promise<void>;
|
204
|
+
purchaseVideoWithQerko: (videoId: string, monetizationId: string) => Promise<QerkoPaymentInfo>;
|
205
|
+
purchaseSubscriptionWithQerko: (monetizationId: string) => Promise<QerkoPaymentInfo>;
|
206
|
+
setLanguage: (language: Language) => void;
|
207
|
+
setUser: (userId: string, userPayload?: unknown) => void;
|
208
|
+
sources: TivioSources;
|
209
|
+
subscriptions: TivioSubscriptions;
|
210
|
+
};
|
211
|
+
declare type TivioBundleFile = {
|
212
|
+
Tivio: TivioBundle;
|
213
|
+
};
|
214
|
+
declare type RemoteBundleState = {
|
215
|
+
config: InternalConfig;
|
216
|
+
error: string | null;
|
217
|
+
settings: Settings;
|
218
|
+
state: 'loading' | 'error' | 'ready';
|
219
|
+
} & Nullable<TivioBundle>;
|
220
|
+
export type { RemoteBundleState, Config, Settings, InternalConfig, TivioBundle, TivioBundleFile, TivioHooks, TivioComponents, TivioAuth, TivioGetters, TivioSubscriptions, Events, PubSub, };
|
File without changes
|
@@ -0,0 +1,171 @@
|
|
1
|
+
import { Empty } from './common';
|
2
|
+
export declare type ChannelSource = {
|
3
|
+
new (uri: string, originalOptions: Record<string, any>, channelName: string, programName: string, programDescription: string, from: Date, to: Date): ChannelSource;
|
4
|
+
description: string;
|
5
|
+
name: string;
|
6
|
+
uri: string;
|
7
|
+
from: Date;
|
8
|
+
channelName: string;
|
9
|
+
to: Date;
|
10
|
+
type: 'channel';
|
11
|
+
watchWithoutAdsRecommendation: {
|
12
|
+
purchase: () => void;
|
13
|
+
} | null;
|
14
|
+
};
|
15
|
+
export declare type AdSource = {
|
16
|
+
new (uri: string, name: string, description: string, skipDelayMs: number | null, adDurationMs: number, trackingContext?: any, // internal Tivio types
|
17
|
+
adMarker?: any, // internal Tivio types
|
18
|
+
packInfo?: any, // internal Tivio types
|
19
|
+
provider?: any): AdSource;
|
20
|
+
description: string;
|
21
|
+
name: string;
|
22
|
+
uri: string;
|
23
|
+
durationMs: number;
|
24
|
+
skipDelayMs: number | null;
|
25
|
+
type: 'ad';
|
26
|
+
/**
|
27
|
+
* true if is skippable and skip countdown has passed
|
28
|
+
*/
|
29
|
+
canSkip: boolean;
|
30
|
+
/**
|
31
|
+
* true ad if is skippable after some skipDelayMs (if it is skippable, skipDelayMs is defined)
|
32
|
+
*/
|
33
|
+
isSkippable: boolean;
|
34
|
+
/**
|
35
|
+
* Skip ad. Only works when canSkip is true
|
36
|
+
*/
|
37
|
+
skip: () => void;
|
38
|
+
/**
|
39
|
+
* Order in ad break (ad break is a group of ads played right after each other)
|
40
|
+
*/
|
41
|
+
order: number;
|
42
|
+
/**
|
43
|
+
* Total number of ads in ad break (ad break is a group of ads played right after each other)
|
44
|
+
*/
|
45
|
+
totalCount: number;
|
46
|
+
secondsToEnd: number;
|
47
|
+
secondsToSkippable: number | null;
|
48
|
+
};
|
49
|
+
export declare type VodTivioSource = {
|
50
|
+
new (uri: string, videoId: string, name: string, description: string, adMonetizationId?: string): VodTivioSource;
|
51
|
+
type: 'vod_tivio';
|
52
|
+
description: string;
|
53
|
+
name: string;
|
54
|
+
uri: string;
|
55
|
+
};
|
56
|
+
export declare type VodExternalSource = {
|
57
|
+
new (uri: string, monetizationId: string, name: string, description: string, originalOptions: Record<string, any>): VodTivioSource;
|
58
|
+
type: 'vod_external';
|
59
|
+
description: string;
|
60
|
+
name: string;
|
61
|
+
uri: string;
|
62
|
+
};
|
63
|
+
export declare type InputSource = AdSource | ChannelSource | VodTivioSource | VodExternalSource;
|
64
|
+
declare type PlayerState = 'playing' | 'paused' | 'idle';
|
65
|
+
export interface PlayerInterface {
|
66
|
+
pause: () => void;
|
67
|
+
/**
|
68
|
+
* unpause
|
69
|
+
*/
|
70
|
+
play: () => void;
|
71
|
+
/**
|
72
|
+
* @param {number} ms - milliseconds relative to start of video (relative to 0 ms)
|
73
|
+
* or in case of TV programs relative to start of the program (relative to source.from ms)
|
74
|
+
*/
|
75
|
+
seekTo: (ms: number) => void;
|
76
|
+
/**
|
77
|
+
* Source to be passed to player.
|
78
|
+
*
|
79
|
+
* Depending on autoplay settings it should either start playing
|
80
|
+
* immediately or just be loaded by player and stay paused.
|
81
|
+
*/
|
82
|
+
setSource: (source: InputSource | null) => void;
|
83
|
+
/**
|
84
|
+
* volume in [0,1]
|
85
|
+
*/
|
86
|
+
setVolume?: (volume: number) => void;
|
87
|
+
mute?: () => void;
|
88
|
+
/**
|
89
|
+
* restore volume to previous value
|
90
|
+
*/
|
91
|
+
unmute?: () => void;
|
92
|
+
}
|
93
|
+
export declare type PlayerWrapper = {
|
94
|
+
/**
|
95
|
+
* Report that playback of video has finished
|
96
|
+
*/
|
97
|
+
onPlaybackEnded: () => void;
|
98
|
+
/**
|
99
|
+
* Report video progress in milliseconds
|
100
|
+
*/
|
101
|
+
onTimeChanged: (ms: number) => void;
|
102
|
+
/**
|
103
|
+
* Report that video state changed
|
104
|
+
*/
|
105
|
+
onStateChanged: (state: PlayerState) => void;
|
106
|
+
/**
|
107
|
+
* Send source to Tivio
|
108
|
+
*/
|
109
|
+
onSourceChanged: (source: InputSource | null) => void;
|
110
|
+
/**
|
111
|
+
* Report that video failed to load (never started playing)
|
112
|
+
*/
|
113
|
+
onLoadError: (error: Error) => void;
|
114
|
+
/**
|
115
|
+
* Report that video failed during playback (successfully loaded and then failed, e.g. part of stream is invalid)
|
116
|
+
*/
|
117
|
+
onError: (error: Error) => void;
|
118
|
+
/**
|
119
|
+
* Unpause video
|
120
|
+
*/
|
121
|
+
play: () => void;
|
122
|
+
/**
|
123
|
+
* Pause video
|
124
|
+
*/
|
125
|
+
pause: () => void;
|
126
|
+
/**
|
127
|
+
* Currently playing source
|
128
|
+
*/
|
129
|
+
source: InputSource | null;
|
130
|
+
events: {
|
131
|
+
isSupported: (even: string) => boolean;
|
132
|
+
addListener: <T = any>(event: string, cb: (value: T) => Empty) => void;
|
133
|
+
removeListener: <T = any>(event: string, cb: (value: T) => Empty) => void;
|
134
|
+
removeAllListeners: () => void;
|
135
|
+
};
|
136
|
+
/**
|
137
|
+
* Register a low level player that implements player methods, like play video, change volume, etc.
|
138
|
+
*/
|
139
|
+
register: (playerInterface: PlayerInterface) => void;
|
140
|
+
/**
|
141
|
+
* duration of current source in ms (both setter and getter)
|
142
|
+
*/
|
143
|
+
durationMs: number | null;
|
144
|
+
isPlaybackStarted: boolean;
|
145
|
+
isPaused: boolean;
|
146
|
+
isPlaying: boolean;
|
147
|
+
isIdle: boolean;
|
148
|
+
error: Error | null;
|
149
|
+
/**
|
150
|
+
* Replay the video that finished playback
|
151
|
+
*/
|
152
|
+
replay: () => void;
|
153
|
+
/**
|
154
|
+
* Retry to play a video that failed to start playing (e.g. due to a network error)
|
155
|
+
*/
|
156
|
+
retry: () => void;
|
157
|
+
togglePlayPause: () => void;
|
158
|
+
seekTo: (ms: number) => void;
|
159
|
+
/**
|
160
|
+
* set volume to value between 0,1
|
161
|
+
*/
|
162
|
+
setVolume: (volume: number) => void;
|
163
|
+
/**
|
164
|
+
* change volume by value between -1,1
|
165
|
+
*/
|
166
|
+
changeVolumeBy: (volume: number) => void;
|
167
|
+
setMuted: (muted: boolean) => void;
|
168
|
+
toggleMuted: () => void;
|
169
|
+
};
|
170
|
+
export declare type UsePlayerEvent = <T = any>(eventName: string) => T | null;
|
171
|
+
export {};
|
@@ -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 = any;
|
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 VodTivioSourcePojo {
|
106
|
+
type: 'VodTivioSource';
|
107
|
+
description: string;
|
108
|
+
path: string;
|
109
|
+
name: string;
|
110
|
+
uri: string;
|
111
|
+
poster?: string;
|
112
|
+
adMonetizationId?: string;
|
113
|
+
}
|
114
|
+
interface ChannelSourcePojo {
|
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?: VodTivioSourcePojo | ChannelSourcePojo | 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, VodTivioSourcePojo, ChannelSourcePojo, };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tivio/sdk-react",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.4.0",
|
4
4
|
"main": "dist/index.js",
|
5
5
|
"typings": "dist/index.d.ts",
|
6
6
|
"source": "src/index.ts",
|
@@ -11,9 +11,10 @@
|
|
11
11
|
"scripts": {
|
12
12
|
"build": "bash ./scripts/build_prod.sh",
|
13
13
|
"build:dev": "bash ./scripts/build_dev.sh",
|
14
|
-
"start": "
|
14
|
+
"start": "yarn ts-node ./scripts/start.ts",
|
15
15
|
"test": "jest --config=./jest.config.js --coverage",
|
16
16
|
"clean": "rm -rf dist",
|
17
|
+
"prepublishOnly": "yarn && yarn ts-node ./scripts/prepublish.ts && yarn run build",
|
17
18
|
"postpublish": "yarn ts-node ./scripts/postpublish.ts",
|
18
19
|
"publish:alpha": "npm publish --tag alpha",
|
19
20
|
"check:cycles ": "npx madge --circular src/**/*"
|
@@ -26,18 +27,18 @@
|
|
26
27
|
"@material-ui/core": "^4.11.2",
|
27
28
|
"@material-ui/icons": "^4.11.2",
|
28
29
|
"@sentry/browser": "^6.1.0",
|
29
|
-
"@tivio/common": "1.1.
|
30
|
+
"@tivio/common": "1.1.61",
|
30
31
|
"firebase": "^8.2.3",
|
31
32
|
"formik": "^2.2.7",
|
32
33
|
"i18next": "^19.8.4",
|
33
|
-
"mobx": "^6.0.4",
|
34
34
|
"mobx-react": "^7.1.0",
|
35
|
-
"
|
35
|
+
"mobx": "^6.0.4",
|
36
36
|
"react-dom": "^17.0.2",
|
37
37
|
"react-i18next": "^9.0.10",
|
38
38
|
"react-router-dom": "^5.2.0",
|
39
39
|
"react-spring": "^9.2.4",
|
40
40
|
"react-virtualized": "^9.22.3",
|
41
|
+
"react": "^17.0.2",
|
41
42
|
"styled-components": "^5.2.1",
|
42
43
|
"yup": "^0.32.9"
|
43
44
|
},
|
@@ -70,6 +71,7 @@
|
|
70
71
|
"web-vitals": "^1.0.1",
|
71
72
|
"webpack": "^5.15.0",
|
72
73
|
"webpack-cli": "^4.4.0",
|
73
|
-
"webpack-merge": "^5.7.3"
|
74
|
+
"webpack-merge": "^5.7.3",
|
75
|
+
"yargs": "17"
|
74
76
|
}
|
75
77
|
}
|