@tivio/sdk-react 3.2.4 → 3.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 | undefined) => 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>;
@@ -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
@@ -322,7 +331,7 @@ declare type TivioBundle = {
322
331
  }) => Promise<QerkoPaymentInfo>;
323
332
  cancelSubscriptionWithQerko: (subscriptionId: string) => Promise<QerkoCancellationInfo>;
324
333
  setLanguage: (language: Language) => void;
325
- setUser: (userId: string, userPayload: UserPayload | null) => Promise<void>;
334
+ setUser: (userId: string | null, userPayload?: UserPayload) => Promise<void>;
326
335
  sources: TivioSources;
327
336
  subscriptions: TivioSubscriptions;
328
337
  internal: {
@@ -334,6 +343,9 @@ declare type TivioBundle = {
334
343
  declare type TivioInternalComponents = {
335
344
  CustomButton: React.ComponentType;
336
345
  WebLandingScreen: React.ComponentType;
346
+ WebVideoScreen: React.ComponentType<{
347
+ videoId: string;
348
+ }>;
337
349
  };
338
350
  declare type TivioInternalHooks = {
339
351
  useAuthOverlay: () => AuthOverlayState;
@@ -353,7 +365,11 @@ declare type TivioInternalHooks = {
353
365
  declare type TivioInternalProviders = {
354
366
  AppThemeProvider: React.ComponentType;
355
367
  AuthOverlayContextProvider: React.ComponentType;
356
- CustomerProvider: React.ComponentType;
368
+ CustomerProvider: React.ComponentType<{
369
+ customer: CUSTOMER_BUILD;
370
+ platform: PLATFORM;
371
+ children: any;
372
+ }>;
357
373
  ConfigProvider: React.ComponentType;
358
374
  UserContextProvider: React.ComponentType;
359
375
  SubscriptionOverlayContextProvider: React.ComponentType;
@@ -398,4 +414,10 @@ declare type RemoteBundleState = {
398
414
  settings: Settings;
399
415
  state: 'loading' | 'error' | 'ready';
400
416
  } & Nullable<TivioBundle>;
401
- 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.4",
3
+ "version": "3.3.1",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "source": "src/index.ts",
@@ -28,7 +28,7 @@
28
28
  "@material-ui/core": "^4.11.2",
29
29
  "@material-ui/icons": "^4.11.2",
30
30
  "@sentry/browser": "^6.1.0",
31
- "@tivio/common": "1.1.80",
31
+ "@tivio/common": "1.1.83",
32
32
  "es7-object-polyfill": "^1.0.1",
33
33
  "firebase": "^8.2.3",
34
34
  "formik": "^2.2.7",