@tivio/sdk-react 3.2.3 → 3.3.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.
@@ -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 { InternalConfig, RemoteBundleState, TivioBundle } from '../types/bundle.types';
5
+ import type { InternalConfig, RemoteBundleState, TivioBundle } from '../types/bundle.types';
6
6
  /**
7
7
  * @throws if fetch fails
8
8
  */
@@ -13,4 +13,3 @@ declare const fetchBundle: (secret: string, conf: InternalConfig) => Promise<str
13
13
  declare const createRemotePackageLoader: () => (secret: string, conf: InternalConfig) => Promise<TivioBundle>;
14
14
  declare const createUseRemoteBundle: () => (conf: InternalConfig) => RemoteBundleState;
15
15
  export { fetchBundle, createRemotePackageLoader, createUseRemoteBundle, };
16
- export type { RemoteBundleState, };
@@ -1,5 +1,5 @@
1
1
  import { TivioBundle } from '../types/bundle.types';
2
- import type { RemoteBundleState } from './bundleLoader';
2
+ import type { RemoteBundleState } from '../types/bundle.types';
3
3
  export declare let tivioBundle: TivioBundle | null;
4
4
  /**
5
5
  * rejects when bundle is not available
@@ -1,2 +1,9 @@
1
1
  import type { UserPayload } from '../types/bundle.types';
2
- export declare const setUser: (userId: string, payload: UserPayload) => Promise<void>;
2
+ /**
3
+ * Set user to sign in/out.
4
+ *
5
+ * Sign in - setUser('userID', { token: 'xxx' })
6
+ * Sign out - setUser(null)
7
+ */
8
+ declare const setUser: (userId: string | null, payload: UserPayload) => Promise<void>;
9
+ export { setUser };
@@ -1,4 +1,4 @@
1
- import { Currency, ItemsInRow, PaginationInterface, PaginationOptions, QerkoCancellationInfo, Row, ROW_ITEM_TYPES, SubscribeToItemsInRowOptions, SubscribeToTaggedVideos, Tag, TilePropsPartial, UseCancelSubscription } from '@tivio/common';
1
+ import { Currency, ItemsInRow, PaginationInterface, PaginationOptions, QerkoCancellationInfo, Row, ROW_ITEM_TYPES, SubscribeToItemsInRowOptions, SubscribeToTaggedVideos, Tag, TilePropsPartial, UseCancelSubscription, CUSTOMER_BUILD, PLATFORM, WebRowProps } from '@tivio/common';
2
2
  import { ComponentType } from 'react';
3
3
  import { Logger } from '../services/logger';
4
4
  import { FetchPackage } from '../services/packageLoader';
@@ -181,6 +181,11 @@ declare type TivioGetters = {
181
181
  * @returns {Promise<Widget | null>} widget or null if widget does not exists
182
182
  */
183
183
  getWidgetById: (widgetId: string) => Promise<Widget | null>;
184
+ /**
185
+ * Get player capabilities based on user's browser and OS as resolved by Tivio.
186
+ * @returns PlayerCapability[]
187
+ */
188
+ getPlayerCapabilities: () => PlayerCapability[];
184
189
  };
185
190
  interface TivioAuth {
186
191
  changePassword: (newPassword: string) => Promise<void>;
@@ -243,7 +248,7 @@ declare type TivioComponents = {
243
248
  tagId: string;
244
249
  onError?: (error: Error) => void;
245
250
  }>;
246
- WebRow: React.ReactNode;
251
+ WebRow: React.ComponentType<WebRowProps>;
247
252
  WebTile: React.ComponentType<{
248
253
  item?: Video | Tag;
249
254
  } & TilePropsPartial>;
@@ -280,7 +285,7 @@ declare type TivioHooks = {
280
285
  purchaseRecoveryResult?: string;
281
286
  loading: boolean;
282
287
  error?: any;
283
- purchaseRecovery: (monetizationId: string) => Promise<string>;
288
+ purchaseRecovery: (monetizationId: string) => void;
284
289
  };
285
290
  useRowsInScreen: (screenId: string, options: PaginationOptions) => {
286
291
  pagination: PaginationInterface<Row> | null;
@@ -291,6 +296,10 @@ declare type TivioHooks = {
291
296
  error: Error | null;
292
297
  };
293
298
  useSearch: UseSearch;
299
+ useVideo: (videoId: string) => {
300
+ data: Video | null;
301
+ error: string | null;
302
+ };
294
303
  useVoucher: (voucherId: string) => any;
295
304
  /**
296
305
  * @deprecated will be removed in version
@@ -300,6 +309,12 @@ declare type TivioHooks = {
300
309
  canPurchaseWatchWithoutAds: boolean;
301
310
  showPurchaseDialog: () => void;
302
311
  };
312
+ useApplyInviteCode: () => {
313
+ applyInviteCodeResult?: boolean;
314
+ loading: boolean;
315
+ error?: any;
316
+ applyInviteCode: (code: string) => void;
317
+ };
303
318
  };
304
319
  export declare type UserPayload = Record<string, any>;
305
320
  declare type TivioBundle = {
@@ -316,7 +331,7 @@ declare type TivioBundle = {
316
331
  }) => Promise<QerkoPaymentInfo>;
317
332
  cancelSubscriptionWithQerko: (subscriptionId: string) => Promise<QerkoCancellationInfo>;
318
333
  setLanguage: (language: Language) => void;
319
- setUser: (userId: string, userPayload: UserPayload | null) => Promise<void>;
334
+ setUser: (userId: string | null, userPayload: UserPayload) => Promise<void>;
320
335
  sources: TivioSources;
321
336
  subscriptions: TivioSubscriptions;
322
337
  internal: {
@@ -328,6 +343,9 @@ declare type TivioBundle = {
328
343
  declare type TivioInternalComponents = {
329
344
  CustomButton: React.ComponentType;
330
345
  WebLandingScreen: React.ComponentType;
346
+ WebVideoScreen: React.ComponentType<{
347
+ videoId: string;
348
+ }>;
331
349
  };
332
350
  declare type TivioInternalHooks = {
333
351
  useAuthOverlay: () => AuthOverlayState;
@@ -347,7 +365,11 @@ declare type TivioInternalHooks = {
347
365
  declare type TivioInternalProviders = {
348
366
  AppThemeProvider: React.ComponentType;
349
367
  AuthOverlayContextProvider: React.ComponentType;
350
- CustomerProvider: React.ComponentType;
368
+ CustomerProvider: React.ComponentType<{
369
+ customer: CUSTOMER_BUILD;
370
+ platform: PLATFORM;
371
+ children: any;
372
+ }>;
351
373
  ConfigProvider: React.ComponentType;
352
374
  UserContextProvider: React.ComponentType;
353
375
  SubscriptionOverlayContextProvider: React.ComponentType;
@@ -392,4 +414,10 @@ declare type RemoteBundleState = {
392
414
  settings: Settings;
393
415
  state: 'loading' | 'error' | 'ready';
394
416
  } & Nullable<TivioBundle>;
395
- export type { RemoteBundleState, Config, Settings, InternalConfig, TivioBundle, TivioBundleFile, TivioHooks, TivioComponents, TivioAuth, TivioGetters, TivioSubscriptions, TivioInternalComponents, TivioInternalHooks, TivioInternalProviders, Events, PubSub, PlayerCapability, Currency, };
417
+ /**
418
+ * TODO: Duplicate, because we can't import types from core-js.
419
+ */
420
+ declare type NewVoucher = {
421
+ expirationDate: Date | number;
422
+ };
423
+ export type { RemoteBundleState, Config, Settings, InternalConfig, TivioBundle, TivioBundleFile, TivioHooks, TivioComponents, TivioAuth, TivioGetters, TivioSubscriptions, TivioInternalComponents, TivioInternalHooks, TivioInternalProviders, Events, PubSub, PlayerCapability, Currency, AuthOverlayState, AuthOverlayType, SubscriptionOverlayData, SubscriptionOverlayState, QerkoData, QerkoOverlayState, NewVoucher, };
@@ -5,8 +5,7 @@
5
5
  /**
6
6
  * Export public client side API
7
7
  */
8
- import { USER_TYPE } from '@tivio/common';
9
- import type { Monetization, Video } from '@tivio/common';
8
+ import type { Monetization, Video, User } from '@tivio/common';
10
9
  import type React from 'react';
11
10
  declare type RemoteProviderProps = {
12
11
  disableUnmounting?: boolean;
@@ -21,19 +20,6 @@ declare enum Language {
21
20
  SK = "sk",
22
21
  SP = "sp"
23
22
  }
24
- declare type User = {
25
- purchases: Purchase[];
26
- purchasedVods: Purchase[];
27
- purchasedSubscriptions: Purchase[];
28
- getPurchasedVodsWithInitializedVideos: () => Promise<Purchase[]>;
29
- isPurchasesInitialized: boolean;
30
- isSignedIn: boolean;
31
- email: string;
32
- type?: USER_TYPE;
33
- photoURL: string | null;
34
- name?: string;
35
- authUserId?: string;
36
- };
37
23
  interface UserData {
38
24
  name?: string;
39
25
  }
@@ -135,6 +121,10 @@ interface WebPlayerProps {
135
121
  id: string;
136
122
  source?: VodTivioSourcePojo | ChannelSourcePojo | VideoPath | null;
137
123
  onEnded?: () => any;
124
+ /**
125
+ * If this function is specified, then "Back" button is shown in top right corner.
126
+ */
127
+ onBack?: () => void;
138
128
  className?: string;
139
129
  /**
140
130
  * default false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tivio/sdk-react",
3
- "version": "3.2.3",
3
+ "version": "3.3.0",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "source": "src/index.ts",
@@ -15,7 +15,6 @@
15
15
  "start": "yarn ts-node ./scripts/start.ts",
16
16
  "test": "jest --config=./jest.config.js --coverage",
17
17
  "clean": "rm -rf dist",
18
- "prepublishOnly": "yarn && yarn run build && yarn ts-node ./scripts/prepublish.ts",
19
18
  "postpublish": "yarn ts-node ./scripts/postpublish.ts",
20
19
  "publish:alpha": "npm publish --tag alpha",
21
20
  "check:cycles": "npx madge --circular src/**/*"
@@ -28,7 +27,7 @@
28
27
  "@material-ui/core": "^4.11.2",
29
28
  "@material-ui/icons": "^4.11.2",
30
29
  "@sentry/browser": "^6.1.0",
31
- "@tivio/common": "1.1.79",
30
+ "@tivio/common": "1.1.82",
32
31
  "es7-object-polyfill": "^1.0.1",
33
32
  "firebase": "^8.2.3",
34
33
  "formik": "^2.2.7",