@tivio/sdk-react 4.4.1 → 5.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tivio/sdk-react",
3
- "version": "4.4.1",
3
+ "version": "5.0.0",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "source": "src/index.ts",
@@ -13,24 +13,27 @@
13
13
  "build:dev": "cat ./.env.dev > ./.env && yarn build --config=webpack.config.dev.js && yarn typesRollup",
14
14
  "build:prod": "cat ./.env.prod > ./.env && yarn build --config=webpack.config.prod.js && yarn typesRollup",
15
15
  "build:local": "bash ./scripts/build_with_local_bundle.sh && yarn typesRollup",
16
+ "release": "ts-node ./scripts/release.ts -p=sdk-react",
17
+ "release:patch": "yarn release -r=patch",
18
+ "release:minor": "yarn release -r=minor",
19
+ "release:major": "yarn release -r=major",
16
20
  "start": "yarn ts-node ./scripts/start.ts",
17
21
  "test": "jest --config=./jest.config.js --coverage",
18
22
  "clean": "rm -rf dist",
19
23
  "prepublishOnly": "yarn && yarn build:prod && yarn ts-node ./scripts/prepublish.ts",
20
24
  "postpublish": "yarn ts-node ./scripts/postpublish.ts",
21
25
  "publish:alpha": "npm publish --tag alpha",
22
- "check:cycles": "npx madge --circular src/**/*",
23
26
  "typesRollup": "yarn ts-node ./scripts/typesRollup.ts"
24
27
  },
25
28
  "peerDependencies": {
26
- "react": "^17.0.0",
27
- "react-dom": "^17.0.0"
29
+ "react": "17.x || 18.x",
30
+ "react-dom": "17.x || 18.x"
28
31
  },
29
32
  "dependencies": {
30
33
  "@material-ui/core": "^4.11.2",
31
34
  "@material-ui/icons": "^4.11.2",
32
35
  "@sentry/browser": "^6.1.0",
33
- "@tivio/common": "1.1.101",
36
+ "@tivio/common": "*",
34
37
  "dayjs": "^1.11.0",
35
38
  "es7-object-polyfill": "^1.0.1",
36
39
  "firebase": "8.10.1",
@@ -39,7 +42,7 @@
39
42
  "mobx": "^6.0.4",
40
43
  "mobx-react": "^7.1.0",
41
44
  "react-i18next": "^9.0.10",
42
- "react-router-dom": "^5.2.0",
45
+ "react-router-dom": "^5.3.4",
43
46
  "react-spring": "^9.2.4",
44
47
  "react-virtualized": "^9.22.3",
45
48
  "styled-components": "^5.2.1",
@@ -53,30 +56,30 @@
53
56
  "@testing-library/react-hooks": "^5.0.3",
54
57
  "@testing-library/user-event": "^12.1.10",
55
58
  "@tivio/types": "*",
56
- "@types/jest": "^26.0.15",
59
+ "@types/jest": "^26.0.24",
57
60
  "@types/node": "^12.0.0",
58
61
  "@types/node-fetch": "^2.5.8",
59
- "@types/react": "^17.0.13",
60
- "@types/react-dom": "^17.0.2",
62
+ "@types/react": "^18.0.28",
63
+ "@types/react-dom": "^18.0.11",
61
64
  "@types/react-router-dom": "^5.1.6",
62
- "@types/react-virtualized": "^9.21.13",
65
+ "@types/react-virtualized": "^9.21.21",
63
66
  "@types/styled-components": "^5.1.7",
64
- "@typescript-eslint/eslint-plugin": "^4.14.0",
65
- "@typescript-eslint/parser": "^4.14.2",
67
+ "@typescript-eslint/eslint-plugin": "^5.30.5",
68
+ "@typescript-eslint/parser": "^5.30.5",
69
+ "circular-dependency-plugin": "^5.2.2",
66
70
  "dotenv": "^9.0.0",
67
71
  "eslint": "^7.19.0",
68
72
  "fork-ts-checker-webpack-plugin": "^7.0.0",
69
- "jest": "^27.0.1",
70
- "jest-cli": "^26.6.3",
73
+ "jest": "^26.6.0",
74
+ "jest-cli": "^26.6.0",
71
75
  "jest-fetch-mock": "^3.0.3",
72
- "madge": "^5.0.1",
73
76
  "node-fetch": "^2.6.1",
74
- "react": "^17.0.2",
75
- "react-dom": "^17.0.2",
77
+ "react": "^18.2.0",
78
+ "react-dom": "^18.2.0",
76
79
  "stream-browserify": "^3.0.0",
77
80
  "timers-browserify": "^2.0.12",
78
- "ts-jest": "^26.4.4",
79
- "typescript": "^4.1.3",
81
+ "ts-jest": "^26.5.6",
82
+ "typescript": "^4.9.4",
80
83
  "web-vitals": "^1.0.1",
81
84
  "yargs": "17"
82
85
  }
package/README.md.bak DELETED
@@ -1,483 +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
- * v4.4.1
10
- * patch: added waitForTags param in useSearch hook for videos
11
-
12
- * v4.4.0
13
- * minor: PrimaryButton component props type set to any for now
14
- * patch: isPurchasableAsVoucher added to PurchasableMonetization
15
- * patch: voucherPurchase flag added to purchase overlays
16
- * patch: item added to MonetizationsSelectOverlayData
17
- * minor: added hungarian language to `LangCode` enum
18
-
19
- * v4.3.0:
20
- * minor: add GetPurchaseInfoResponse and PurchaseEndpointPayload to exported types
21
- * minor: support for disabling purchase of specified subscriptions (new param in useOrganizationSubscriptions hook)
22
- * minor: more specific PurchasableMonetization type usage instead of Monetization
23
- * minor: monetization property deleted from Video type
24
- * minor: monetization now has originalPrice and promotion properties available
25
- * patch: remove not used OrganizationSubscriptionsContext, **this change requires bundle 3.20.0 or newer**
26
-
27
- * v4.2.0:
28
- * minor: fix useSearch loading type
29
- * patch: added italian language to `LangCode` enum
30
-
31
- * v4.1.0
32
- * patch: added italian language to `LangCode` enum
33
- * minor: fixed spanish language code in `LangCode` enum (`sp` -> `es`)
34
- * minor: other misc type changes
35
-
36
- * v4.0.1
37
- * patch: added setBundleVersion setter to bundle type
38
- * patch: added setStorageManager setter to bundle type
39
- * patch: `Purchase.isPurchased` is deprecated
40
- * patch: fill `useSearch` field `hasNextPage` with proper value
41
-
42
- * v4.0.0
43
- * minor: Types cleanup
44
- * MAJOR: Remove deprecated and unused stuff
45
- * auth
46
- * changePassword
47
- * changeUserPhoto
48
- * removeUserPhoto
49
- * getPurchasedVodsWithInitializedVideos
50
- * initializeUser
51
- * createFreePurchase
52
- * components
53
- * VideoAdBanner
54
- * getters
55
- * getExportedConfig
56
- * getChannelById
57
- * getSectionById
58
- * getWidgetById
59
- * hooks
60
- * useLastVideoByWidgetId
61
- * useScreen
62
- * useFreePurchase
63
- * useWidget
64
- * useChannel
65
- * useSection
66
- * useVideosInSection
67
- * useSectionsInChannel
68
- * useChannelsInWidget
69
- * subscriptions
70
- * subscribeToWidget
71
- * subscribeToChannel
72
- * subscribeToSection
73
- * subscribeToVideosInSection
74
- * subscribeToSectionsInChannel
75
- * subscribeToChannelsInWidget
76
- * subscribeToScreen
77
- ---
78
- _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)_
79
-
80
- * v3.7.0
81
- * minor: purchase contains created and updated
82
-
83
- * v3.6.3
84
- * patch: improve README.md
85
-
86
- * v3.6.2
87
- * patch: Fix types
88
-
89
- * v3.6.1
90
- * patch: Fix README
91
-
92
- * v3.6.0
93
- * minor: Update types
94
-
95
- * v3.5.2
96
- * patch: All types are available again.
97
-
98
- * v3.5.1
99
- * patch: remove incorrect dependency (@tivio/types)
100
-
101
- * v3.5.0
102
- * minor: Types change - Video.price and Video.detailedPrice can be null
103
- * minor: Types change - Video.cover is marked as deprecated
104
-
105
- * v3.4.0
106
- * minor: more precise type for errors in usePurchaseRecovery and usePurchaseRecovery
107
- * patch: jsdocs for usePurchaseRecovery and usePurchaseRecovery
108
- * minor: inviteCodeReset in useApplyInviteCode
109
- * minor: Reset forgotten password
110
- * minor: Consolidating monetization logic
111
- * v3.3.2
112
- * patch: Adding new optional parameters (where, orderBy) to useTaggedVideos hook
113
- * v3.3.1
114
- * patch: Fixed types of `setUser`
115
- * v3.3.0
116
- * minor: Add getPlayerCapabilities to getters.
117
- * patch: Added option to log out via `setUser(null)`, requires @tivio/core-react-dom@2.17.9
118
- * v3.2.5
119
- * patch: added recovery flag to QerkoPaymentInfo type
120
- * patch: bundle.types changes - internal.components.WebVideoScreen
121
- * patch: types changes - add new onBack prop to WebPlayerProps
122
- * patch: Refactor useVideo hook, now uses hook from core-react
123
- * v3.2.4
124
- * minor: added useApplyInviteCode
125
- * minor: better errors from useVoucher
126
- * v3.2.3
127
- * minor: added usePurchaseRecovery hook
128
- * patch: deprecated `useLastVideoByWidgetId`
129
- * v3.2.2
130
- * minor: useRowsInScreen, useItemsInRow, useTaggedVideos - hasNextPage and loading added to pagination
131
- * minor: useRowsInScreen, useItemsInRow, useTaggedVideos - implementation moved to remote bundle
132
- * patch: Fixed Tivio startup on Tizen 6
133
- * minor: Added `forceCloudFnResolver` option
134
- * v3.2.1
135
- * patch: fix of @tivio/common version
136
- * v3.2.0
137
- * minor: Added `capabilitiesOptions` for finer configuration of device capabilities
138
- * minor: tag names are returned in correct language (the one from tivio config); language value should be one from enum "LangCode"
139
- * v3.1.3
140
- * patch: Hotfix made sure disabled Tivio does not break React Native
141
- * v3.1.2
142
- * patch: Allow `conf` prop of `TivioProvider` to be `null` or `undefined` in order to turn off Tivio
143
- * v3.1.1
144
- * patch: fixed `setUser()` crash when bundle fails to load
145
- * v3.1.0
146
- * patch: `useAdSegment()` now returns null if no monetization is configured, ad segments are not managed in that situation
147
- * minor: enriched `AdSegment` type from `useAdSegment()`
148
- * minor: Added `setUser()` function for login and logout
149
- * v3.0.0
150
- * minor: Added hook `useWatchWithoutAdsOffer` to trigger purchase dialog to "watch without ads", if available
151
- * patch: fix peerDependency declaration for react, react-dom
152
- * major: TivioProvider requires deviceCapabilities
153
- * major: TivioProvider requires currency
154
- * minor: add voucher support (see usePurchaseSubscription and useTransactionPayment hooks)
155
- * minor: device limit support
156
- * minor: drm (Widevine, PlayReady) support
157
- * minor: watermarking support
158
- * minor: add useSearch hook
159
- * patch: price on video is 0 when purchased
160
- * v2.4.2
161
- * patch: added back changelog
162
- * v2.4.1
163
- * patch: improved doc about player wrapper
164
- * v2.4.0
165
- * patch: improved Player wrapper types
166
- * minor: added Tivio DOM events `tivio_key_input_handling_change`, `tivio_context_switch` and `tivio_request_goto`
167
- * 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)
168
- * patch: added support for browsers that do not implement [indexedDB API](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API)
169
- * v2.3.4
170
- * patch: fix of usePurchaseSubscription not reactive
171
- * v2.3.3
172
- * patch: fix of useUser not updating
173
- * v2.3.2
174
- * patch: next app doesn't fail anymore due to "self is not defined"
175
- * v2.3.1
176
- * patch: fix of @tivio/common dependency
177
- * v2.3.0
178
- * minor: add useTaggedVideos that allows to fetch videos with given tags
179
- * minor: add option to fetch tags (on hook useItemsInRow), useVideo always fetching videos tags
180
- * v2.2.1
181
- * patch: disable Sentry when no config is supplied to `TivioProvider`
182
- * v2.2.0
183
- * patch: reduced bundle size
184
- * 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 }`
185
- * v2.1.5
186
- * patch fix of `useVideosInSection` hook (fetching video's monetizations)
187
- * v2.1.4
188
- * patch: fix re-rendering of `useAd` during non-skippable ads (requires core-react-dom@2.1.9)
189
- * v2.1.3
190
- * patch: fix changelog
191
- * v2.1.2
192
- * patch: Fixed exported types
193
- * v2.1.1
194
- * patch: TivioWidget now correctly reports `false` via `onEnabled` callback when in invalid internal state
195
- * v2.1.0
196
- * patch: fix of useItemsInRow hook
197
- * patch: fix of useScreen hook
198
- * add: useRowsInScreen hook
199
- * v2.0.3
200
- * patch: fix of useItemsInRow hook
201
- * v2.0.2
202
- * patch: screen and row IDs fixed
203
- * `TivioBundle.subscriptions.subscribeToItemsInRow` now accepts user-defined ID via studio.tiv.io
204
- * `TivioBundle.subscriptions.subscribeToScreen` now accepts user-defined ID via studio.tiv.io
205
- * `Screen` and `Row` types returned by `useScreen()` return their user-defined IDs (`.id`) correctly
206
- * v2.0.1
207
- * no changes
208
- * v2.0.0
209
- * major: video.channelId can now be `string | null` used to be `string`
210
- * minor: added data API and hooks for screens (screens, rows of screen and row items)
211
- * hooks: `useScreen()`, `useItemsInRow()`
212
- * api: `TivioBundle.subscriptions.subscribeToScreen`, `TivioBundle.subscriptions.subscribeToItemsInRow`
213
- * v1.3.6
214
- * ?
215
- * v1.3.5
216
- * minor: added WebPlayer props (canReplay, showMarkers, customShortcuts, enableKeyboardShortcuts, source.poster)
217
- * v1.3.4
218
- * ...
219
-
220
-
221
- ## Installation
222
-
223
- Install @tivio/sdk-react along with its peer dependencies
224
- ```sh
225
- npm i react@17 react-dom@17 @tivio/sdk-react
226
- # or
227
- yarn add react@17 react-dom@17 @tivio/sdk-react
228
- ```
229
-
230
- ## Initialization
231
-
232
- Put Tivio Provider at the top level of your application:
233
-
234
- ``` javascript
235
- import { TivioProvider } from '@tivio/sdk-react'
236
-
237
- const config = {
238
- secret: 'XXXXXXXXXX',
239
- }
240
-
241
- function App({children}) {
242
- return (
243
- <TivioProvider conf={config}>
244
- {children}
245
- </TivioProvider>
246
- )
247
- }
248
- ```
249
-
250
- ## Authentication
251
-
252
- A logged-in user can access more features, such as making purchases. In order to authenticate a user with Tivio, use the `setUser()` method.
253
-
254
- Verification of the user against 3rd party auth servers is implemented per customer.
255
-
256
- ```typescript
257
- import { setUser } from '@tivio/sdk-react'
258
-
259
- // Log in
260
-
261
- // Payload is specific per customer
262
- // A common use-case is sending an auth token inside the payload, which Tivio can use to verify the user
263
- await setUser('userId', { token: 'xxx'})
264
-
265
- // Log out
266
- await setUser(null)
267
- ```
268
-
269
- ## Player
270
-
271
- You can choose whether you will use complete player component provided by Tivio or you will wrap your existing player
272
- with the Tivio Player Wrapper.
273
-
274
- ### Tivio Player component
275
-
276
- ```javascript
277
- import { useTivioData } from '@tivio/sdk-react'
278
-
279
- const PlayerExample = () => {
280
- const bundle = useTivioData()
281
-
282
- if (!bundle?.components?.WebPlayer) {
283
- return <p>Loading...</p>
284
- }
285
-
286
- return (
287
- <>
288
- <div
289
- style={{
290
- height: 720,
291
- width: 1280,
292
- }}
293
- >
294
- <bundle.components.WebPlayer
295
- id="player1"
296
- className="web-player"
297
- source="/videos/xxxxxxxxxxxxxxxxxxxx" // dynamically change this based on video you want to play
298
- />
299
- </div>
300
- </>
301
- )
302
- }
303
- ```
304
-
305
- ### Player wrapper
306
-
307
- Player wrapper is the way how you can enhance your video player with Tivio features, such Tivio Ads. In order to start
308
- using Tivio player wrapper, wrap your player methods with PlayerWrapper, start using PlayerWrapper's methods
309
- instead of them to control your playback and start sending player events to Tivio PlayerWrapper.
310
-
311
- #### Wrap your player methods with Tivio player wrapper
312
-
313
- ```javascript
314
- import { useTivioReadyData } from '@tivio/sdk-react'
315
-
316
- function CustomPlayer() {
317
- const tivioData = useTivioReadyData()
318
-
319
- useEffect(() => {
320
- if (tivioData) {
321
- // If your app uses multiple player instances, use different Tivio player wrapper for each
322
- // distinguished by playerWrapperId
323
- const playerWrapper = tivio.getPlayerWrapper({ playerWrapperId: 'PLAYER_1' })
324
-
325
- // Pass your player methods to Tivio player wrapper
326
- playerWrapper.register({
327
- play: () => {
328
- // Un-pause your player
329
- },
330
- pause: () => {
331
- // Pause your player
332
- },
333
- seekTo: (ms: number) => {
334
- // Seek to position in milliseconds using your player
335
- },
336
- setSource: (videoSource: InputSource) => {
337
- // Send this video source to your player to load it
338
- },
339
- })
340
- }
341
- }, [tivioData])
342
- }
343
- ```
344
-
345
- #### Start using Tivio player wrapper methods to control playback
346
-
347
- ```javascript
348
- // Channel source metadata, such as channel name, epg start and epg end are necessary
349
- // for TV ad segment detection and application of ad strategies
350
- const source = new ChannelSource(
351
- 'https://channel_prima_hd.m3u8',
352
- {
353
- // here put any additional metadata, for your use.
354
- // This object will not be touched by Tivio
355
- },
356
- // channel name
357
- // can also be prima hd, prima_hd, prima, Prima, PRIMA, etc.
358
- // we will normalize it to snake case and add '_hd' if necessary
359
- 'Prima HD',
360
- // program name
361
- 'Dr. House',
362
- // description (optional)
363
- 'Episode about Dr. House being awesome',
364
- // EPG start
365
- new Date('2021-12-10T12:00:00'),
366
- // EPG end
367
- new Date('2021-12-10T13:40:00'),
368
- )
369
-
370
- // Send source to player
371
- playerWrapper.onSourceChanged(source)
372
-
373
- // Un-pause player
374
- playerWrapper.play()
375
-
376
- // Pause player
377
- playerWrapper.pause()
378
- }
379
- ```
380
-
381
- #### Start reporting player events to Tivio
382
-
383
- ```javascript
384
- // Report that source is playing
385
- playerWrapper.onStateChanged('playing')
386
-
387
- // Report that source is paused
388
- playerWrapper.onStateChanged('paused')
389
-
390
- // Report that source stopped playing
391
- playerWrapper.onPlaybackEnded()
392
- playerWrapper.onStateChanged('idle')
393
-
394
- // Report video progress
395
- playerWrapper.onTimeChanged(ms)
396
- }
397
- ```
398
-
399
- #### Start reporting playback-related errors to Tivio
400
-
401
- ```javascript
402
- // Report that video failed to load (e.g. due to a wrong URI)
403
- playerWrapper.onLoadError(new Error('video failed to load'))
404
-
405
- // Report that video failed during playback (e.g. due to bad connection, corrupted chunks of stream video etc.)
406
- // This type of error may be auto-recoverable
407
- playerWrapper.onError(new Error('playback error'))
408
- }
409
- ```
410
-
411
- ## Data hooks
412
-
413
- ### useUser hook
414
- Gets information about current user.
415
-
416
- ```ts
417
- useUser: () => {
418
- user: User | null
419
- error: string | null
420
- isInitialized: boolean
421
- }
422
- ```
423
-
424
- ### useRowsInScreen hook
425
- Gets array of Rows objects of specific screen and subscribes to its changes.
426
-
427
- ```ts
428
- /**
429
- * Use rows in screen
430
- * @param screenId - screen id (from studio.tiv.io)
431
- * @param options - subscription options
432
- */
433
- useRowsInScreen: (screenId: string, options?: PaginationOptions) => {
434
- pagination: PaginationInterface<Row> | null
435
- error: Error | null
436
- }
437
- ```
438
-
439
- ### useItemsInRow hook
440
- Gets array of row items objects of specific row and subscribes to its changes.
441
-
442
- ```ts
443
- /**
444
- * Use row items
445
- * @param rowId - row ID
446
- * @param options - subscription options
447
- */
448
- useItemsInRow: (rowId: string, options?: SubscribeToItemsInRowOptions) => {
449
- pagination: PaginationInterface<ItemsInRow> | null
450
- error: Error | null
451
- }
452
- ```
453
-
454
- ### useVideo hook
455
-
456
- Gets Video object and subscribes to its changes.
457
-
458
- ```ts
459
- /**
460
- * Use video
461
- * @param videoId - video id
462
- */
463
- useVideo: (videoId: string) => {
464
- error: string | null;
465
- data: Video | null;
466
- }
467
- ```
468
-
469
- ### useTaggedVideos hook
470
- Gets videos with given tag IDs.
471
-
472
- ```ts
473
- /**
474
- * Use tagged videos
475
- * @param tagIds - tag ids
476
- * @param options - subscription options
477
- * @public
478
- */
479
- useTaggedVideos: (tagIds: string[], options?: SubscribeToItemsInRowOptions) => {
480
- pagination: PaginationInterface<Video> | null
481
- error: Error | null
482
- }
483
- ```