@tivio/sdk-react 9.2.0-alpha.1 → 9.2.0-alpha.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tivio/sdk-react",
3
- "version": "9.2.0-alpha.1",
3
+ "version": "9.2.0-alpha.2",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "source": "src/index.ts",
package/README.bak.md DELETED
@@ -1,578 +0,0 @@
1
- # @tivio/sdk-react
2
-
3
- @tivio/sdk-react provides everything which is necessary (components, data hooks etc.) to build a custom React application
4
- above Tivio Studio. You can comfortably manage all you videos, settings such as application's screens and rows and also monetization
5
- settings in the administration of Tivio Studio while having the freedom to build your own application.
6
-
7
- ## Changelog
8
- * 9.2.0-alpha.1
9
- * minor: add renderWebPlayer method for rendering outside of React
10
- * minor: "expose createTivio"
11
-
12
- * 9.1.7
13
- * patch: update remote controller component API
14
-
15
- * 9.1.6
16
- * minor: add remote controller
17
-
18
- * 9.1.5
19
- * patch: expose purchase loyalty points through types
20
- * patch: enable setUser check
21
-
22
- * 9.1.4
23
- * patch: disable setUser check
24
- * patch: rollback "add renderWebPlayer method for rendering outside of React"
25
- * patch: rollback "expose createTivio"
26
-
27
- * 9.1.3
28
- * patch: add renderWebPlayer method for rendering outside of React
29
- * patch: expose createTivio
30
-
31
- * 9.1.4
32
- * patch: disable setUser check
33
-
34
- * 9.1.3
35
- * minor: add renderWebPlayer method for rendering outside of React
36
- * minor: expose createTivio
37
-
38
- * 9.1.2
39
- * patch: update PurchaseEndpointPayload type (cityName, externalId, geoPoint)
40
-
41
- * 9.1.1
42
- * patch: fix changelog
43
-
44
- * 9.1.0
45
- * patch: add gateway to Purchase type
46
- * minor: add QerkoPaymentWebhookByApiKeyRequest to exported types
47
-
48
- * 9.0.0
49
- * patch: remove i18next and react-i18next from externals and dependencies
50
- * patch: do not send react-spring to core-react-dom bundle, remove react-spring from dependencies
51
- * patch: clean-up externals in webpack config
52
- * patch: send only required dependencies to the bundle
53
- * major: change purchase statuses lifecycle
54
- * minor: add originalPurchaseId to PurchaseEndpointPayload
55
-
56
- * 8.0.0
57
- * major: deprecated usePurchasesWithVideos hook removed
58
- * patch: add id to user type
59
- * patch: add @types/react to peerDependencies
60
-
61
- * 7.1.0
62
- * minor: export useTvChannelHook
63
- * patch: bump "react-i18next", "i18next" versions.
64
-
65
- * 7.0.1
66
- * patch: fix dependency to @tivio/common
67
-
68
- * 7.0.0
69
- * major: delete deprecated useWatchWithoutAdsOffer hook
70
- * major: consolidate duplicated source types
71
- * patch: add new properties to PlayerInterface
72
- * patch: expose getSeekingMatrixPreviewByTime in Video interface
73
- * major: delete deprecated useBetOffer hook
74
- * major: rework of source types
75
- * major: make useChannelSource deprecated
76
-
77
- * 6.0.1
78
- * patch: fix dependency to @tivio/common
79
-
80
- * 6.0.0
81
- * major: delete usePlayerEvent hook
82
- * major: replace uri attributes in types with url
83
- * major: delete uri attributes from types
84
- * minor: add purchase expiration to PurchaseEndpointPayload
85
- * minor: add optional videoId parameter to useOrganizationSubscription hook
86
-
87
- * 5.0.2
88
- * patch: export hook useChannelSource
89
-
90
- * 5.0.1
91
- * patch: move changelog
92
-
93
- * 5.0.0
94
- * major: upgrade to React 18, change react and react-dom peer dependencies to 17.x || 18.x
95
- * major: fix typing for useReferralInfo, now correctly showing that `null` can be returned
96
- * major: fix typing for `WebRowProps.onTileClick`, now correctly showing that `null` can be accepted
97
- * minor: add analytics
98
- * minor: add getSourceUrl function to video and tv channel types
99
- * minor: add uri property to tv channel type
100
- * minor: add useChannelSource to hooks
101
-
102
- * 4.5.0
103
- * minor: extend PurchaseEndpointPayload type with purchase previousStatus and newStatus fields
104
-
105
- * 4.4.1
106
- * patch: added waitForTags param in useSearch hook for videos
107
-
108
- * 4.4.0
109
- * minor: PrimaryButton component props type set to any for now
110
- * patch: isPurchasableAsVoucher added to PurchasableMonetization
111
- * patch: voucherPurchase flag added to purchase overlays
112
- * patch: item added to MonetizationsSelectOverlayData
113
- * minor: added hungarian language to `LangCode` enum
114
-
115
- * 4.3.0:
116
- * minor: add GetPurchaseInfoResponse and PurchaseEndpointPayload to exported types
117
- * minor: support for disabling purchase of specified subscriptions (new param in useOrganizationSubscriptions hook)
118
- * minor: more specific PurchasableMonetization type usage instead of Monetization
119
- * minor: monetization property deleted from Video type
120
- * minor: monetization now has originalPrice and promotion properties available
121
- * patch: remove not used OrganizationSubscriptionsContext, **this change requires bundle 3.20.0 or newer**
122
-
123
- * 4.2.0:
124
- * minor: fix useSearch loading type
125
- * patch: added italian language to `LangCode` enum
126
-
127
- * 4.1.0
128
- * patch: added italian language to `LangCode` enum
129
- * minor: fixed spanish language code in `LangCode` enum (`sp` -> `es`)
130
- * minor: other misc type changes
131
-
132
- * 4.0.1
133
- * patch: added setBundleVersion setter to bundle type
134
- * patch: added setStorageManager setter to bundle type
135
- * patch: `Purchase.isPurchased` is deprecated
136
- * patch: fill `useSearch` field `hasNextPage` with proper value
137
-
138
- * 4.0.0
139
- * minor: Types cleanup
140
- * MAJOR: Remove deprecated and unused stuff
141
- * auth
142
- * changePassword
143
- * changeUserPhoto
144
- * removeUserPhoto
145
- * getPurchasedVodsWithInitializedVideos
146
- * initializeUser
147
- * createFreePurchase
148
- * components
149
- * videoAdBanner
150
- * getters
151
- * getExportedConfig
152
- * getChannelById
153
- * getSectionById
154
- * getWidgetById
155
- * hooks
156
- * useLastVideoByWidgetId
157
- * useScreen
158
- * useFreePurchase
159
- * useWidget
160
- * useChannel
161
- * useSection
162
- * useVideosInSection
163
- * useSectionsInChannel
164
- * useChannelsInWidget
165
- * subscriptions
166
- * subscribeToWidget
167
- * subscribeToChannel
168
- * subscribeToSection
169
- * subscribeToVideosInSection
170
- * subscribeToSectionsInChannel
171
- * subscribeToChannelsInWidget
172
- * subscribeToScreen
173
- ---
174
- _Versions <= v3.7.0 requires core-react-dom bundle < v3.0.0 (because sdk-react used some sdk API deleted in core-react-dom@4.0.0)_
175
-
176
- * 3.7.0
177
- * minor: purchase contains created and updated
178
-
179
- * 3.6.3
180
- * patch: improve README.md
181
-
182
- * 3.6.2
183
- * patch: Fix types
184
-
185
- * 3.6.1
186
- * patch: Fix README
187
-
188
- * 3.6.0
189
- * minor: Update types
190
-
191
- * 3.5.2
192
- * patch: All types are available again.
193
-
194
- * 3.5.1
195
- * patch: remove incorrect dependency (@tivio/types)
196
-
197
- * 3.5.0
198
- * minor: Types change - Video.price and Video.detailedPrice can be null
199
- * minor: Types change - Video.cover is marked as deprecated
200
-
201
- * 3.4.0
202
- * minor: more precise type for errors in usePurchaseRecovery and usePurchaseRecovery
203
- * patch: jsdocs for usePurchaseRecovery and usePurchaseRecovery
204
- * minor: inviteCodeReset in useApplyInviteCode
205
- * minor: Reset forgotten password
206
- * minor: Consolidating monetization logic
207
- * 3.3.2
208
- * patch: Adding new optional parameters (where, orderBy) to useTaggedVideos hook
209
- * 3.3.1
210
- * patch: Fixed types of `setUser`
211
- * 3.3.0
212
- * minor: Add getPlayerCapabilities to getters.
213
- * patch: Added option to log out via `setUser(null)`, requires @tivio/core-react-dom@2.17.9
214
- * 3.2.5
215
- * patch: added recovery flag to QerkoPaymentInfo type
216
- * patch: bundle.types changes - internal.components.WebVideoScreen
217
- * patch: types changes - add new onBack prop to WebPlayerProps
218
- * patch: Refactor useVideo hook, now uses hook from core-react
219
- * 3.2.4
220
- * minor: added useApplyInviteCode
221
- * minor: better errors from useVoucher
222
- * 3.2.3
223
- * minor: added usePurchaseRecovery hook
224
- * patch: deprecated `useLastVideoByWidgetId`
225
- * 3.2.2
226
- * minor: useRowsInScreen, useItemsInRow, useTaggedVideos - hasNextPage and loading added to pagination
227
- * minor: useRowsInScreen, useItemsInRow, useTaggedVideos - implementation moved to remote bundle
228
- * patch: Fixed Tivio startup on Tizen 6
229
- * minor: Added `forceCloudFnResolver` option
230
- * 3.2.1
231
- * patch: fix of @tivio/common version
232
- * 3.2.0
233
- * minor: Added `capabilitiesOptions` for finer configuration of device capabilities
234
- * minor: tag names are returned in correct language (the one from tivio config); language value should be one from enum "LangCode"
235
- * 3.1.3
236
- * patch: Hotfix made sure disabled Tivio does not break React Native
237
- * 3.1.2
238
- * patch: Allow `conf` prop of `TivioProvider` to be `null` or `undefined` in order to turn off Tivio
239
- * 3.1.1
240
- * patch: fixed `setUser()` crash when bundle fails to load
241
- * 3.1.0
242
- * patch: `useAdSegment()` now returns null if no monetization is configured, ad segments are not managed in that situation
243
- * minor: enriched `AdSegment` type from `useAdSegment()`
244
- * minor: Added `setUser()` function for login and logout
245
- * 3.0.0
246
- * minor: Added hook `useWatchWithoutAdsOffer` to trigger purchase dialog to "watch without ads", if available
247
- * patch: fix peerDependency declaration for react, react-dom
248
- * major: TivioProvider requires deviceCapabilities
249
- * major: TivioProvider requires currency
250
- * minor: add voucher support (see usePurchaseSubscription and useTransactionPayment hooks)
251
- * minor: device limit support
252
- * minor: drm (Widevine, PlayReady) support
253
- * minor: watermarking support
254
- * minor: add useSearch hook
255
- * patch: price on video is 0 when purchased
256
- * 2.4.2
257
- * patch: added back changelog
258
- * 2.4.1
259
- * patch: improved doc about player wrapper
260
- * 2.4.0
261
- * patch: improved Player wrapper types
262
- * minor: added Tivio DOM events `tivio_key_input_handling_change`, `tivio_context_switch` and `tivio_request_goto`
263
- * 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)
264
- * patch: added support for browsers that do not implement [indexedDB API](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API)
265
- * 2.3.4
266
- * patch: fix of usePurchaseSubscription not reactive
267
- * 2.3.3
268
- * patch: fix of useUser not updating
269
- * 2.3.2
270
- * patch: next app doesn't fail anymore due to "self is not defined"
271
- * 2.3.1
272
- * patch: fix of @tivio/common dependency
273
- * 2.3.0
274
- * minor: add useTaggedVideos that allows to fetch videos with given tags
275
- * minor: add option to fetch tags (on hook useItemsInRow), useVideo always fetching videos tags
276
- * 2.2.1
277
- * patch: disable Sentry when no config is supplied to `TivioProvider`
278
- * 2.2.0
279
- * patch: reduced bundle size
280
- * 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 }`
281
- * 2.1.5
282
- * patch fix of `useVideosInSection` hook (fetching video's monetizations)
283
- * 2.1.4
284
- * patch: fix re-rendering of `useAd` during non-skippable ads (requires core-react-dom@2.1.9)
285
- * 2.1.3
286
- * patch: fix changelog
287
- * 2.1.2
288
- * patch: Fixed exported types
289
- * 2.1.1
290
- * patch: TivioWidget now correctly reports `false` via `onEnabled` callback when in invalid internal state
291
- * 2.1.0
292
- * patch: fix of useItemsInRow hook
293
- * patch: fix of useScreen hook
294
- * add: useRowsInScreen hook
295
- * 2.0.3
296
- * patch: fix of useItemsInRow hook
297
- * 2.0.2
298
- * patch: screen and row IDs fixed
299
- * `TivioBundle.subscriptions.subscribeToItemsInRow` now accepts user-defined ID via studio.tiv.io
300
- * `TivioBundle.subscriptions.subscribeToScreen` now accepts user-defined ID via studio.tiv.io
301
- * `Screen` and `Row` types returned by `useScreen()` return their user-defined IDs (`.id`) correctly
302
- * 2.0.1
303
- * no changes
304
- * 2.0.0
305
- * major: video.channelId can now be `string | null` used to be `string`
306
- * minor: added data API and hooks for screens (screens, rows of screen and row items)
307
- * hooks: `useScreen()`, `useItemsInRow()`
308
- * api: `TivioBundle.subscriptions.subscribeToScreen`, `TivioBundle.subscriptions.subscribeToItemsInRow`
309
- * 1.3.6
310
- * ?
311
- * 1.3.5
312
- * minor: added WebPlayer props (canReplay, showMarkers, customShortcuts, enableKeyboardShortcuts, source.poster)
313
- * 1.3.4
314
- * ...
315
-
316
- ## Installation
317
-
318
- Install @tivio/sdk-react along with its peer dependencies
319
- ```sh
320
- npm i react@17 react-dom@17 @tivio/sdk-react
321
- # or
322
- yarn add react@17 react-dom@17 @tivio/sdk-react
323
- ```
324
-
325
- ## Initialization
326
-
327
- Put Tivio Provider at the top level of your application:
328
-
329
- ``` javascript
330
- import { TivioProvider } from '@tivio/sdk-react'
331
-
332
- const config = {
333
- secret: 'XXXXXXXXXX',
334
- }
335
-
336
- function App({children}) {
337
- return (
338
- <TivioProvider conf={config}>
339
- {children}
340
- </TivioProvider>
341
- )
342
- }
343
- ```
344
-
345
- ## Authentication
346
-
347
- A logged-in user can access more features, such as making purchases. In order to authenticate a user with Tivio, use the `setUser()` method.
348
-
349
- Verification of the user against 3rd party auth servers is implemented per customer.
350
-
351
- ```typescript
352
- import { setUser } from '@tivio/sdk-react'
353
-
354
- // Log in
355
-
356
- // Payload is specific per customer
357
- // A common use-case is sending an auth token inside the payload, which Tivio can use to verify the user
358
- await setUser('userId', { token: 'xxx'})
359
-
360
- // Log out
361
- await setUser(null)
362
- ```
363
-
364
- ## Player
365
-
366
- You can choose whether you will use complete player component provided by Tivio or you will wrap your existing player
367
- with the Tivio Player Wrapper.
368
-
369
- ### Tivio Player component
370
-
371
- ```javascript
372
- import { useTivioData } from '@tivio/sdk-react'
373
-
374
- const PlayerExample = () => {
375
- const bundle = useTivioData()
376
-
377
- if (!bundle?.components?.WebPlayer) {
378
- return <p>Loading...</p>
379
- }
380
-
381
- return (
382
- <>
383
- <div
384
- style={{
385
- height: 720,
386
- width: 1280,
387
- }}
388
- >
389
- <bundle.components.WebPlayer
390
- id="player1"
391
- className="web-player"
392
- source="/videos/xxxxxxxxxxxxxxxxxxxx" // dynamically change this based on video you want to play
393
- />
394
- </div>
395
- </>
396
- )
397
- }
398
- ```
399
-
400
- ### Player wrapper
401
-
402
- Player wrapper is the way how you can enhance your video player with Tivio features, such Tivio Ads. In order to start
403
- using Tivio player wrapper, wrap your player methods with PlayerWrapper, start using PlayerWrapper's methods
404
- instead of them to control your playback and start sending player events to Tivio PlayerWrapper.
405
-
406
- #### Wrap your player methods with Tivio player wrapper
407
-
408
- ```javascript
409
- import { useTivioReadyData } from '@tivio/sdk-react'
410
-
411
- function CustomPlayer() {
412
- const tivioData = useTivioReadyData()
413
-
414
- useEffect(() => {
415
- if (tivioData) {
416
- // If your app uses multiple player instances, use different Tivio player wrapper for each
417
- // distinguished by playerWrapperId
418
- const playerWrapper = tivio.getPlayerWrapper({ playerWrapperId: 'PLAYER_1' })
419
-
420
- // Pass your player methods to Tivio player wrapper
421
- playerWrapper.register({
422
- play: () => {
423
- // Un-pause your player
424
- },
425
- pause: () => {
426
- // Pause your player
427
- },
428
- seekTo: (ms: number) => {
429
- // Seek to position in milliseconds using your player
430
- },
431
- setSource: (videoSource: InputSource) => {
432
- // Send this video source to your player to load it
433
- },
434
- })
435
- }
436
- }, [tivioData])
437
- }
438
- ```
439
-
440
- #### Start using Tivio player wrapper methods to control playback
441
-
442
- ```javascript
443
- // Channel source metadata, such as channel name, epg start and epg end are necessary
444
- // for TV ad segment detection and application of ad strategies
445
- const source = new ChannelSource(
446
- 'https://channel_prima_hd.m3u8',
447
- {
448
- // here put any additional metadata, for your use.
449
- // This object will not be touched by Tivio
450
- },
451
- // channel name
452
- // can also be prima hd, prima_hd, prima, Prima, PRIMA, etc.
453
- // we will normalize it to snake case and add '_hd' if necessary
454
- 'Prima HD',
455
- // program name
456
- 'Dr. House',
457
- // description (optional)
458
- 'Episode about Dr. House being awesome',
459
- // EPG start
460
- new Date('2021-12-10T12:00:00'),
461
- // EPG end
462
- new Date('2021-12-10T13:40:00'),
463
- )
464
-
465
- // Send source to player
466
- playerWrapper.onSourceChanged(source)
467
-
468
- // Un-pause player
469
- playerWrapper.play()
470
-
471
- // Pause player
472
- playerWrapper.pause()
473
- }
474
- ```
475
-
476
- #### Start reporting player events to Tivio
477
-
478
- ```javascript
479
- // Report that source is playing
480
- playerWrapper.onStateChanged('playing')
481
-
482
- // Report that source is paused
483
- playerWrapper.onStateChanged('paused')
484
-
485
- // Report that source stopped playing
486
- playerWrapper.onPlaybackEnded()
487
- playerWrapper.onStateChanged('idle')
488
-
489
- // Report video progress
490
- playerWrapper.onTimeChanged(ms)
491
- }
492
- ```
493
-
494
- #### Start reporting playback-related errors to Tivio
495
-
496
- ```javascript
497
- // Report that video failed to load (e.g. due to a wrong URI)
498
- playerWrapper.onLoadError(new Error('video failed to load'))
499
-
500
- // Report that video failed during playback (e.g. due to bad connection, corrupted chunks of stream video etc.)
501
- // This type of error may be auto-recoverable
502
- playerWrapper.onError(new Error('playback error'))
503
- }
504
- ```
505
-
506
- ## Data hooks
507
-
508
- ### useUser hook
509
- Gets information about current user.
510
-
511
- ```ts
512
- useUser: () => {
513
- user: User | null
514
- error: string | null
515
- isInitialized: boolean
516
- }
517
- ```
518
-
519
- ### useRowsInScreen hook
520
- Gets array of Rows objects of specific screen and subscribes to its changes.
521
-
522
- ```ts
523
- /**
524
- * Use rows in screen
525
- * @param screenId - screen id (from studio.tiv.io)
526
- * @param options - subscription options
527
- */
528
- useRowsInScreen: (screenId: string, options?: PaginationOptions) => {
529
- pagination: PaginationInterface<Row> | null
530
- error: Error | null
531
- }
532
- ```
533
-
534
- ### useItemsInRow hook
535
- Gets array of row items objects of specific row and subscribes to its changes.
536
-
537
- ```ts
538
- /**
539
- * Use row items
540
- * @param rowId - row ID
541
- * @param options - subscription options
542
- */
543
- useItemsInRow: (rowId: string, options?: SubscribeToItemsInRowOptions) => {
544
- pagination: PaginationInterface<ItemInRow> | null
545
- error: Error | null
546
- }
547
- ```
548
-
549
- ### useVideo hook
550
-
551
- Gets Video object and subscribes to its changes.
552
-
553
- ```ts
554
- /**
555
- * Use video
556
- * @param videoId - video id
557
- */
558
- useVideo: (videoId: string) => {
559
- error: string | null;
560
- data: Video | null;
561
- }
562
- ```
563
-
564
- ### useTaggedVideos hook
565
- Gets videos with given tag IDs.
566
-
567
- ```ts
568
- /**
569
- * Use tagged videos
570
- * @param tagIds - tag ids
571
- * @param options - subscription options
572
- * @public
573
- */
574
- useTaggedVideos: (tagIds: string[], options?: SubscribeToItemsInRowOptions) => {
575
- pagination: PaginationInterface<Video> | null
576
- error: Error | null
577
- }
578
- ```