@tivio/sdk-react 3.0.0-alpha4 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
package/README.md.bak ADDED
@@ -0,0 +1,512 @@
1
+ # @tivio/sdk-react
2
+
3
+ ## Changelog
4
+
5
+ * UNRELEASED
6
+ * v3.1.2
7
+ * patch: Allow `conf` prop of `TivioProvider` to be `null` or `undefined` in order to turn off Tivio
8
+ * internal: Added `runFeatureSupportCheck` to `TivioProvider`
9
+ * v3.1.1
10
+ * patch: fixed `setUser()` crash when bundle fails to load
11
+ * v3.1.0
12
+ * internal: refactored `useAd`, `useAdSegment`
13
+ * patch: `useAdSegment()` now returns null if no monetization is configured, ad segments are not managed in that situation
14
+ * internal: fixed refactored `setUser()`
15
+ * minor: enriched `AdSegment` type from `useAdSegment()`
16
+ * minor: Added `setUser()` function for login and logout
17
+ * v3.0.0
18
+ * minor: Added hook `useWatchWithoutAdsOffer` to trigger purchase dialog to "watch without ads", if available
19
+ * patch: fix peerDependency declaration for react, react-dom
20
+ * major: TivioProvider requires deviceCapabilities
21
+ * major: TivioProvider requires currency
22
+ * minor: add voucher support (see usePurchaseSubscription and useTransactionPayment hooks)
23
+ * minor: device limit support
24
+ * minor: drm (Widevine, PlayReady) support
25
+ * minor: watermarking support
26
+ * minor: add useSearch hook
27
+ * patch: price on video is 0 when purchased
28
+ * v2.4.2
29
+ * patch: added back changelog
30
+ * v2.4.1
31
+ * patch: improved doc about player wrapper
32
+ * v2.4.0
33
+ * patch: improved Player wrapper types
34
+ * minor: added Tivio DOM events `tivio_key_input_handling_change`, `tivio_context_switch` and `tivio_request_goto`
35
+ * patch: added support for remote code on browsers that do not implement [indexedDB API](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API)
36
+ * patch: added support for browsers that do not implement [indexedDB API](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API)
37
+ * v2.3.4
38
+ * patch: fix of usePurchaseSubscription not reactive
39
+ * v2.3.3
40
+ * patch: fix of useUser not updating
41
+ * v2.3.2
42
+ * patch: next app doesn't fail anymore due to "self is not defined"
43
+ * v2.3.1
44
+ * patch: fix of @tivio/common dependency
45
+ * v2.3.0
46
+ * minor: add useTaggedVideos that allows to fetch videos with given tags
47
+ * minor: add option to fetch tags (on hook useItemsInRow), useVideo always fetching videos tags
48
+ * v2.2.1
49
+ * patch: disable Sentry when no config is supplied to `TivioProvider`
50
+ * v2.2.0
51
+ * patch: reduced bundle size
52
+ * minor: disable Sentry when no config is supplied to `TivioProvider` or when Tivio is disabled `{ enable: false }`, or when Sentry is disabled via config `{ enableSentry: false }`
53
+ * v2.1.5
54
+ * patch fix of `useVideosInSection` hook (fetching video's monetizations)
55
+ * v2.1.4
56
+ * patch: fix re-rendering of `useAd` during non-skippable ads (requires core-react-dom@2.1.9)
57
+ * v2.1.3
58
+ * patch: fix changelog
59
+ * v2.1.2
60
+ * patch: Fixed exported types
61
+ * v2.1.1
62
+ * patch: TivioWidget now correctly reports `false` via `onEnabled` callback when in invalid internal state
63
+ * v2.1.0
64
+ * patch: fix of useItemsInRow hook
65
+ * patch: fix of useScreen hook
66
+ * add: useRowsInScreen hook
67
+ * v2.0.3
68
+ * patch: fix of useItemsInRow hook
69
+ * v2.0.2
70
+ * patch: screen and row IDs fixed
71
+ * `TivioBundle.subscriptions.subscribeToItemsInRow` now accepts user-defined ID via studio.tiv.io
72
+ * `TivioBundle.subscriptions.subscribeToScreen` now accepts user-defined ID via studio.tiv.io
73
+ * `Screen` and `Row` types returned by `useScreen()` return their user-defined IDs (`.id`) correctly
74
+ * v2.0.1
75
+ * no changes
76
+ * v2.0.0
77
+ * major: video.channelId can now be `string | null` used to be `string`
78
+ * minor: added data API and hooks for screens (screens, rows of screen and row items)
79
+ * hooks: `useScreen()`, `useItemsInRow()`
80
+ * api: `TivioBundle.subscriptions.subscribeToScreen`, `TivioBundle.subscriptions.subscribeToItemsInRow`
81
+ * v1.3.6
82
+ * ?
83
+ * v1.3.5
84
+ * minor: added WebPlayer props (canReplay, showMarkers, customShortcuts, enableKeyboardShortcuts, source.poster)
85
+ * v1.3.4
86
+ * ...
87
+
88
+
89
+ ## Installation
90
+
91
+ Install @tivio/sdk-react along with its peer dependencies
92
+ ```sh
93
+ npm i react@17 react-dom@17 @tivio/sdk-react
94
+ # or
95
+ yarn add react@17 react-dom@17 @tivio/sdk-react
96
+ ```
97
+
98
+ ## Initialization
99
+
100
+ Put Tivio Provider at the top level of your application:
101
+
102
+ ``` javascript
103
+ import { TivioProvider } from '@tivio/sdk-react'
104
+
105
+ const config = {
106
+ secret: 'XXXXXXXXXX',
107
+ }
108
+
109
+ function App({children}) {
110
+ return (
111
+ <TivioProvider conf={config}>
112
+ {children}
113
+ </TivioProvider>
114
+ )
115
+ }
116
+ ```
117
+
118
+ ## Authentication
119
+
120
+ A logged-in user can access more features, such as making purchases. In order to authenticate a user with Tivio, use the `setUser()` method.
121
+
122
+ Verification of the user against 3rd party auth servers is implemented per customer.
123
+
124
+ ```typescript
125
+ import { setUser } from '@tivio/sdk-react'
126
+
127
+ // Log in
128
+
129
+ // Payload is specific per customer
130
+ // A common use-case is sending an auth token inside the payload, which Tivio can use to verify the user
131
+ await setUser('userId', { token: 'xxx'})
132
+
133
+ // Log out
134
+ await setUser('userId', null)
135
+ ```
136
+
137
+ ## Tivio widget
138
+
139
+ Tivio widget is the main Tivio component which shows the widget and provides access to its channels, sections and videos.
140
+ Usage is very simple (be sure to set `id` to the widget ID you have configured in [Tivio Studio](https://studio.tiv.io/)):
141
+
142
+ ``` javascript
143
+ import { TivioWidget } from '@tivio/sdk-react'
144
+
145
+ function Screen() {
146
+ return (
147
+ <TivioWidget id="theWidgetId" />
148
+ )
149
+ }
150
+ ```
151
+
152
+ ### Usage with smart TV navigation (focus control)
153
+
154
+ ``` javascript
155
+ import { TivioWidget, TivioWidgetRef } from '@tivio/sdk-react'
156
+
157
+ function Screen() {
158
+ const ref = useRef<TivioWidgetRef>(null)
159
+
160
+ return (
161
+ <TivioWidget id="theWidgetId" ref={ref} onBlur={() => {/* widget lost focus */}}/>
162
+ <div>
163
+ <button onClick={() => ref.current?.focus({ x: 100 })}>Focus</button>
164
+ <button onClick={() => ref.current?.unfocus()}>Unfocus</button>
165
+ </div>
166
+ )
167
+ }
168
+ ```
169
+
170
+ ## Player wrapper
171
+
172
+ Player wrapper is the way how you can enhance your video player with Tivio features, such Tivio Ads. In order to start using Tivio player wrapper, wrap your player methods with PlayerWrapper, start using PlayerWrapper's methods instead of them to control your playback and start sending player events to Tivio PlayerWrapper.
173
+
174
+ ### Wrap your player methods with Tivio player wrapper
175
+
176
+ ``` javascript
177
+ import { useTivioReadyData } from '@tivio/sdk-react'
178
+
179
+ function CustomPlayer() {
180
+ const tivioData = useTivioReadyData()
181
+
182
+ useEffect(() => {
183
+ if (tivioData) {
184
+ // If your app uses multiple player instances, use different Tivio player wrapper for each
185
+ // distinguished by playerWrapperId
186
+ const playerWrapper = tivio.getPlayerWrapper({ playerWrapperId: 'PLAYER_1' })
187
+
188
+ // Pass your player methods to Tivio player wrapper
189
+ playerWrapper.register({
190
+ play: () => {
191
+ // Un-pause your player
192
+ },
193
+ pause: () => {
194
+ // Pause your player
195
+ },
196
+ seekTo: (ms: number) => {
197
+ // Seek to position in milliseconds using your player
198
+ },
199
+ setSource: (videoSource: InputSource) => {
200
+ // Send this video source to your player to load it
201
+ },
202
+ })
203
+ }
204
+ }, [tivioData])
205
+ }
206
+ ```
207
+
208
+ ### Start using Tivio player wrapper methods to control playback
209
+
210
+ ``` javascript
211
+ // Channel source metadata, such as channel name, epg start and epg end are necessary
212
+ // for TV ad segment detection and application of ad strategies
213
+ const source = new ChannelSource(
214
+ 'https://channel_prima_hd.m3u8',
215
+ {
216
+ // here put any additional metadata, for your use.
217
+ // This object will not be touched by Tivio
218
+ },
219
+ // channel name
220
+ // can also be prima hd, prima_hd, prima, Prima, PRIMA, etc.
221
+ // we will normalize it to snake case and add '_hd' if necessary
222
+ 'Prima HD',
223
+ // program name
224
+ 'Dr. House',
225
+ // description (optional)
226
+ 'Episode about Dr. House being awesome',
227
+ // EPG start
228
+ new Date('2021-12-10T12:00:00'),
229
+ // EPG end
230
+ new Date('2021-12-10T13:40:00'),
231
+ )
232
+
233
+ // Send source to player
234
+ playerWrapper.onSourceChanged(source)
235
+
236
+ // Un-pause player
237
+ playerWrapper.play()
238
+
239
+ // Pause player
240
+ playerWrapper.pause()
241
+ }
242
+ ```
243
+
244
+ ### Start reporting player events to Tivio
245
+
246
+ ``` javascript
247
+ // Report that source is playing
248
+ playerWrapper.onStateChanged('playing')
249
+
250
+ // Report that source is paused
251
+ playerWrapper.onStateChanged('paused')
252
+
253
+ // Report that source stopped playing
254
+ playerWrapper.onPlaybackEnded()
255
+ playerWrapper.onStateChanged('idle')
256
+
257
+ // Report video progress
258
+ playerWrapper.onTimeChanged(ms)
259
+ }
260
+ ```
261
+
262
+ ### Start reporting playback-related errors to Tivio
263
+
264
+ ``` javascript
265
+ // Report that video failed to load (e.g. due to a wrong URI)
266
+ playerWrapper.onLoadError(new Error('video failed to load'))
267
+
268
+ // Report that video failed during playback (e.g. due to bad connection, corrupted chunks of stream video etc.)
269
+ // This type of error may be auto-recoverable
270
+ playerWrapper.onError(new Error('playback error'))
271
+ }
272
+ ```
273
+
274
+ ## Tivio DOM events
275
+
276
+ `TivioWidget` triggers these events on `window.document`.
277
+
278
+ 1. To instruct the parent app to navigate to and focus a specific TivioWidget (e.g. after going back from a Tivio screen)
279
+
280
+ ```typescript
281
+ document.addEventListener("tivio_request_goto", e => {
282
+ e.detail.widgetId; // string - Tivio widget ID to go navigate to in UI
283
+ });
284
+ ```
285
+ 2. To notify the parent app about context switch, i.e. where is the user located or what is he focusing
286
+
287
+ ```typescript
288
+ document.addEventListener("tivio_context_switch", e => {
289
+ e.detail.context; // 'tivio' | 'parent' - where is the user located? - in Tivio or in parent app
290
+
291
+ // For context Tivio there are additional fields
292
+ e.detail.context; // 'tivio'
293
+ e.detail.contextLocation; // 'route' | 'overlay' | 'widget' - where in Tivio is the user located?
294
+ // - on a Tivio route, in parent app but looking at a full screen Tivio overlay,
295
+ // or in parent app and focus is on a Tivio widget
296
+
297
+ // For context Tivio contextLocation 'widget' there is an additional field of widget ID
298
+ e.detail.widgetId; // string - which Tivio widget is focused right now
299
+ });
300
+ ```
301
+ 3. To notify the parent app about whether it should be handling key input from RC (TV remote) or not. When inputHandler is 'tivio', the parent app should stop reacting to key input, when inputHandler is 'parent' the parent app should start reacting again.
302
+
303
+ ```typescript
304
+ document.addEventListener("tivio_key_input_handling_change", e => {
305
+ e.detail.inputHandler; // 'tivio' | 'parent' - who should be handling RC input? - Tivio or parent app
306
+ });
307
+ ```
308
+
309
+ ## Data hooks
310
+
311
+ If you don't want to use TivioWidget, you can implement your own UI using React data hooks.
312
+
313
+ ### useWidget hook
314
+
315
+ Gets Widget object and subscribes to its changes.
316
+
317
+ ``` javascript
318
+ /**
319
+ * Use widget
320
+ * @param widgetId - widget id
321
+ */
322
+ useWidget: (widgetId: string) => {
323
+ error: string | null;
324
+ data: Widget | null;
325
+ }
326
+ ```
327
+
328
+ ### useChannel hook
329
+
330
+ Gets Channel object and subscribes to its changes.
331
+
332
+ ``` javascript
333
+ /**
334
+ * Use channel
335
+ * @param channelId - channel id
336
+ */
337
+ useChannel: (channelId: string) => {
338
+ error: string | null;
339
+ data: Channel | null;
340
+ }
341
+ ```
342
+
343
+ ### useSection hook
344
+
345
+ Gets Section object and subscribes to its changes.
346
+
347
+ ``` javascript
348
+ /**
349
+ * Use section
350
+ * @param sectionId - section id
351
+ */
352
+ useSection: (sectionId: string) => {
353
+ error: string | null;
354
+ data: Section | null;
355
+ }
356
+ ```
357
+
358
+ ### useVideo hook
359
+
360
+ Gets Video object and subscribes to its changes.
361
+
362
+ ``` javascript
363
+ /**
364
+ * Use video
365
+ * @param videoId - video id
366
+ */
367
+ useVideo: (videoId: string) => {
368
+ error: string | null;
369
+ data: Video | null;
370
+ }
371
+ ```
372
+
373
+ ### useChannelsInWidget hook
374
+
375
+ Gets array of Channel objects and subscribes to their changes. It is possible to use `hasNextPage` and `fetchMore`
376
+ for pagination (returned in `data` object).
377
+
378
+ ``` javascript
379
+ /**
380
+ * Use channels in widget
381
+ * @param widgetId - widget id
382
+ * @param [limit] - channels count, defaults to 10
383
+ */
384
+ useChannelsInWidget: (widgetId: string, limit?: number) => {
385
+ error: string | null;
386
+ data: PaginationData<Channel> | null;
387
+ }
388
+ ```
389
+
390
+ ### useSectionsInChannel hook
391
+
392
+ Gets array of Section objects and subscribes to their changes. It is possible to use `hasNextPage` and `fetchMore`
393
+ for pagination (returned in `data` object).
394
+
395
+ ``` javascript
396
+ /**
397
+ * Use section in channel
398
+ * @param channelId - channel id
399
+ * @param [limit] - sections count, defaults to 10
400
+ */
401
+ useSectionsInChannel: (channelId: string, limit?: number) => {
402
+ error: string | null;
403
+ data: PaginationData<Section> | null;
404
+ }
405
+ ```
406
+
407
+ ### useVideosInSection hook
408
+
409
+ Gets array of Video objects and subscribes to their changes. It is possible to use `hasNextPage` and `fetchMore`
410
+ for pagination (returned in `data` object).
411
+
412
+ ``` javascript
413
+ /**
414
+ * Use videos in section
415
+ * @param sectionId - section id
416
+ * @param [limit] - videos count, defaults to 10
417
+ */
418
+ useVideosInSection: (sectionId: string, limit?: number) => {
419
+ error: string | null;
420
+ data: PaginationData<Video> | null;
421
+ }
422
+ ```
423
+
424
+ ### useScreen hook
425
+ Gets Screen object and subscribes to its changes.
426
+
427
+ ```ts
428
+ /**
429
+ * Hook to fetch an app screen
430
+ * @param screenId - screen ID configured via studio.tiv.io
431
+ */
432
+ useScreen: (screenId: string) => {
433
+ error: Error | null
434
+ data: Screen | null
435
+ }
436
+
437
+ // Example:
438
+ // Screens with their screenIds are configured via studio.tiv.io
439
+ const screenId = '890sdfvxoi'
440
+ const { error, data } = useScreen(screenId)
441
+
442
+ if (data) {
443
+ const screenName = data.name
444
+ const screenRows = data.rows
445
+ // ...
446
+ }
447
+ ```
448
+
449
+ ### useItemsInRow hook
450
+
451
+ Gets array of Video or Tag objects for a specified row. It is possible to use
452
+ `hasNextPage` and `fetchMore` for pagination (returned in `data` object).
453
+
454
+ *(Note: Does not subscribe to changes in video objects, in order to refresh data it is necessary to reload the app.)*
455
+
456
+ ```ts
457
+ /**
458
+ * Hook to fetch row items for rows received from `useScreen()`
459
+ * @param id - row ID configured via studio.tiv.io
460
+ * @param options.limit - items limit
461
+ * @param options.noLimit - disable/enable pagination (will fetch all items)
462
+ * @param options.fecthTags - disable/enable tags fetching
463
+ */
464
+ useItemsInRow: (id: string, options: {limit?: number, noLimit?: boolean, fecthTags?: boolean}) => {
465
+ error: Error | null
466
+ data: PaginationData<Video | Tag> | null
467
+ isLoading: boolean
468
+ }
469
+
470
+ // Example:
471
+ // Rows and their row ID can be loaded using useScreen() hook
472
+ const Row = ({ id }: { id: string}) => {
473
+ const rowData = useItemsInRow(id, 10)
474
+
475
+ return <div>
476
+ <div>Row id: {id}</div>
477
+ Count: ({rowData.data?.items.length})
478
+ <div>
479
+ {rowData.isLoading && <div>Loading...</div>}
480
+ {rowData.data?.items.map(item => (
481
+ <div>
482
+ <div>{item.name}</div>
483
+ <img src={item.cover} alt={item.name} />
484
+ </div>
485
+ ))}
486
+ </div>
487
+ <button onClick={() => rowData.data?.fetchMore()}>more</button>
488
+ </div>
489
+ }
490
+ ```
491
+
492
+ ### useTaggedItems hook
493
+
494
+ Allows to fetch videos with given tags.
495
+
496
+ ```ts
497
+ /**
498
+ * Hook to fetch row items for rows received from `useScreen()`
499
+ * @param id - row ID configured via studio.tiv.io
500
+ * @param options.limit - items limit
501
+ * @param options.noLimit - disable/enable pagination (will fetch all items)
502
+ * @param options.fecthTags - disable/enable tags fetching
503
+ */
504
+ useTaggedItems: (tagIds: string[], {limit?: number, noLimit?: boolean, fecthTags?: boolean}) => {
505
+ error: Error | null
506
+ data: PaginationData<Video> | null
507
+ }
508
+
509
+
510
+ # Deprecations
511
+ - Video.url will be removed in version 3.0.0, use Video.uri attribute instead
512
+ - Video.cover will be removed in version 3.0.0, use Video.assets attribute instead
@@ -3,11 +3,17 @@
3
3
  * nangu.TV, a.s PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
4
4
  */
5
5
  import React, { FunctionComponentElement } from 'react';
6
+ import type { PlayerWrapper } from '../types/customPlayer.types';
6
7
  export declare type PlayerProviderProps = {
7
8
  children: React.ReactNode;
8
9
  playerWrapperId?: string;
9
10
  };
10
- export declare type Player = any;
11
- export declare const PlayerContext: React.Context<any>;
11
+ /**
12
+ * value
13
+ * - undefined - you are trying to access this context but are not inside <PlayerContext /> that is a bug
14
+ * - null - we are waiting for remote code
15
+ * - Player - player is ready
16
+ */
17
+ export declare const PlayerContext: React.Context<PlayerWrapper | null | undefined>;
12
18
  export declare const PlayerProvider: ({ children, playerWrapperId, }: PlayerProviderProps) => FunctionComponentElement<PlayerProviderProps>;
13
19
  export declare function withPlayerContext(id: string): <P>(WrappedComponent: React.ComponentType<P>) => (props: P) => JSX.Element;
@@ -9,7 +9,7 @@ export declare type TivioProviderProps = {
9
9
  /**
10
10
  * This prop must be set only once and not change value afterwards
11
11
  */
12
- conf: Config;
12
+ conf: Config | undefined | null;
13
13
  children: React.ReactNode;
14
14
  };
15
15
  declare const TivioContext: React.Context<RemoteBundleState | null>;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ /**
3
+ * See device_compatibility.md
4
+ */
5
+ export declare const FeatureSupportCheck: React.FC;
@@ -15,3 +15,5 @@ export * from './useFreePurchase';
15
15
  export * from './useRowsInScreen';
16
16
  export * from './useVoucher';
17
17
  export * from './useTivio';
18
+ export * from './useLastVideoByWidgetId';
19
+ export * from './useWatchWithoutAdsOffer';
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2021, nangu.TV, a.s. All rights reserved.
3
3
  * nangu.TV, a.s PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
4
4
  */
5
- import type { AdSource, UsePlayerEvent } from '../../types/customPlayer.types';
5
+ import type { UsePlayerEvent } from '../../types/customPlayer.types';
6
6
  import type { BetOffer, Marker } from '../../types/types';
7
7
  export declare const usePlayerEvent: UsePlayerEvent;
8
8
  export declare const useMarkers: () => Marker[] | null;
@@ -12,12 +12,17 @@ interface IntroMarker {
12
12
  skip: () => void;
13
13
  }
14
14
  export declare const useIntro: () => IntroMarker | null;
15
- export declare const useAd: () => AdSource | null;
15
+ export declare const useAd: () => import("../../types/customPlayer.types").AdSource | null;
16
16
  export declare const useCurrentMarker: () => Marker | null;
17
17
  export declare const useSeekState: () => boolean | null;
18
- interface AdSegment {
18
+ export declare const useAdSegment: () => {
19
+ id: string;
19
20
  remainingMs: number;
21
+ secondsToEnd: number;
22
+ secondsToSkippable: number | null;
20
23
  canSeek: boolean;
21
- }
22
- export declare const useAdSegment: () => AdSegment | null;
24
+ canSkip: boolean;
25
+ isSkippable: boolean;
26
+ skip: () => any;
27
+ } | null;
23
28
  export {};
@@ -1,11 +1,11 @@
1
- import { PaginationInterface, SubscribeToItemsInRowOptions, Tag, Video } from '@tivio/common';
1
+ import { ItemsInRow, PaginationInterface, SubscribeToItemsInRowOptions } from '@tivio/common';
2
2
  /**
3
3
  * Use row items
4
4
  * @param rowId - row ID
5
5
  * @param options - subscription options
6
6
  */
7
7
  declare const useItemsInRow: (rowId: string, options?: SubscribeToItemsInRowOptions) => {
8
- pagination: PaginationInterface<Video | Tag> | null;
8
+ pagination: PaginationInterface<ItemsInRow> | null;
9
9
  error: Error | null;
10
10
  };
11
11
  export { useItemsInRow, };
@@ -0,0 +1,2 @@
1
+ import { Video } from '@tivio/common';
2
+ export declare function useLastVideoByWidgetId(widgetId: string): Video | null;
@@ -1,4 +1,4 @@
1
1
  import { QerkoTransaction } from '@tivio/common';
2
- import { Voucher } from './useTransactionPayment';
3
- declare const usePurchaseSubscription: (monetizationId: string, voucher?: Voucher | undefined) => QerkoTransaction;
2
+ import { NewVoucher } from './useTransactionPayment';
3
+ declare const usePurchaseSubscription: (monetizationId: string, voucher?: NewVoucher | undefined) => QerkoTransaction;
4
4
  export { usePurchaseSubscription, };
@@ -1,10 +1,10 @@
1
1
  import { QerkoTransaction } from '@tivio/common';
2
- declare type Voucher = {
3
- /**
4
- * Voucher expiration date as a Date object or timestamp in ms.
5
- */
2
+ /**
3
+ * TODO: Duplicate, because we can't import types from core-js.
4
+ */
5
+ declare type NewVoucher = {
6
6
  expirationDate: Date | number;
7
7
  };
8
- declare const useTransactionPayment: (videoId: string, monetizationId: string, voucher?: Voucher | undefined) => QerkoTransaction;
8
+ declare const useTransactionPayment: (videoId: string, monetizationId: string, voucher?: NewVoucher | undefined) => QerkoTransaction;
9
9
  export { useTransactionPayment, };
10
- export type { Voucher, };
10
+ export type { NewVoucher, };
@@ -1,11 +1,15 @@
1
+ /**
2
+ * TODO: Should be in core-js, we can't import types from it, though.
3
+ */
1
4
  declare type Voucher = {
2
5
  activate: () => void;
3
6
  isUsed: boolean;
4
7
  isExpired: boolean;
5
8
  status: 'NEW' | 'USED';
9
+ voucherInfo: any;
6
10
  };
7
11
  declare const useVoucher: (voucherId: string) => {
8
- activate: (() => void) | null;
12
+ activate: (() => Promise<void>) | null;
9
13
  voucher: Voucher | null;
10
14
  error: Error | null;
11
15
  };
@@ -0,0 +1,4 @@
1
+ export declare const useWatchWithoutAdsOffer: () => {
2
+ canPurchaseWatchWithoutAds: boolean;
3
+ showPurchaseDialog: () => void;
4
+ };
package/dist/config.d.ts CHANGED
@@ -3,9 +3,11 @@
3
3
  * nangu.TV, a.s PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
4
4
  */
5
5
  import type { Config as ExternalConfig, InternalConfig } from './types/bundle.types';
6
+ import type { Currency } from '@tivio/common';
6
7
  export declare const defaultConf: {
7
8
  secret: null;
8
9
  resolverUrl: string;
10
+ currency: Currency;
9
11
  disableUnmounting: boolean;
10
12
  fetchPackage: import("./services/packageLoader").FetchPackage;
11
13
  pubSub: import("./types/bundle.types").PubSub;
@@ -14,4 +16,4 @@ export declare const defaultConf: {
14
16
  error: string | null;
15
17
  }>;
16
18
  };
17
- export declare const createInternalConf: (conf: ExternalConfig) => InternalConfig;
19
+ export declare const createInternalConf: (conf: ExternalConfig | undefined | null) => InternalConfig;
package/dist/index.d.ts CHANGED
@@ -23,3 +23,4 @@ export { TivioGetters } from './types/bundle.types';
23
23
  export { TivioSubscriptions } from './types/bundle.types';
24
24
  export { PlayerCapability } from './types/bundle.types';
25
25
  export { Currency } from './types/bundle.types';
26
+ export { setUser } from './services/login';