@tivio/sdk-react 3.5.0 → 3.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. package/README.md +3 -0
  2. package/README.md.bak +3 -0
  3. package/dist/components/ContextProvider.d.ts +7 -0
  4. package/dist/components/PlayerProvider.d.ts +19 -0
  5. package/dist/components/TivioProvider.d.ts +16 -0
  6. package/dist/components/TivioWidget.d.ts +7 -0
  7. package/dist/components/TivioWidgetError.d.ts +10 -0
  8. package/dist/components/TivioWidgetLoader.d.ts +6 -0
  9. package/dist/components/TvTivioProvider.d.ts +7 -0
  10. package/dist/components/context/ChannelsContext.d.ts +6 -0
  11. package/dist/components/context/RowItemsContext.d.ts +7 -0
  12. package/dist/components/context/ScreensContext.d.ts +6 -0
  13. package/dist/components/context/SectionsContext.d.ts +6 -0
  14. package/dist/components/context/VideosContext.d.ts +6 -0
  15. package/dist/components/context/index.d.ts +5 -0
  16. package/dist/components/context/types.d.ts +27 -0
  17. package/dist/components/hooks/contentHooks.d.ts +68 -0
  18. package/dist/components/hooks/index.d.ts +22 -0
  19. package/dist/components/hooks/playerHooks.d.ts +28 -0
  20. package/dist/components/hooks/useApplyInviteCode.d.ts +17 -0
  21. package/dist/components/hooks/useCancelSubscription.d.ts +2 -0
  22. package/dist/components/hooks/useError.d.ts +9 -0
  23. package/dist/components/hooks/useFreePurchase.d.ts +4 -0
  24. package/dist/components/hooks/useIsMonetizationPurchased.d.ts +3 -0
  25. package/dist/components/hooks/useItemsInRow.d.ts +11 -0
  26. package/dist/components/hooks/useLastVideoByWidgetId.d.ts +5 -0
  27. package/dist/components/hooks/useOrganizationSubscriptions.d.ts +3 -0
  28. package/dist/components/hooks/usePurchaseRecovery.d.ts +14 -0
  29. package/dist/components/hooks/usePurchaseSubscription.d.ts +4 -0
  30. package/dist/components/hooks/usePurchasesWithVideos.d.ts +7 -0
  31. package/dist/components/hooks/useRowsInScreen.d.ts +6 -0
  32. package/dist/components/hooks/useScreen.d.ts +10 -0
  33. package/dist/components/hooks/useScreens.d.ts +5 -0
  34. package/dist/components/hooks/useSearch.d.ts +8 -0
  35. package/dist/components/hooks/useTaggedVideos.d.ts +11 -0
  36. package/dist/components/hooks/useTivio.d.ts +3 -0
  37. package/dist/components/hooks/useTransactionPayment.d.ts +5 -0
  38. package/dist/components/hooks/useUser.d.ts +5 -0
  39. package/dist/components/hooks/useVoucher.d.ts +42 -0
  40. package/dist/components/hooks/useWatchWithoutAdsOffer.d.ts +4 -0
  41. package/dist/config.d.ts +20 -0
  42. package/dist/index.d.ts +21 -1279
  43. package/dist/index.js +1 -1
  44. package/dist/info.d.ts +2 -0
  45. package/dist/services/bundleLoader.d.ts +15 -0
  46. package/dist/services/bundlePromise.d.ts +7 -0
  47. package/dist/services/dependencyResolver.d.ts +24 -0
  48. package/dist/services/gdpr.d.ts +1 -0
  49. package/dist/services/localFetch/coreReactDomDist.d.ts +1 -0
  50. package/dist/services/localFetch/none.d.ts +1 -0
  51. package/dist/services/logger.d.ts +26 -0
  52. package/dist/services/login.d.ts +9 -0
  53. package/dist/services/packageLoader.d.ts +6 -0
  54. package/dist/services/pubSub.d.ts +13 -0
  55. package/dist/services/sentry.d.ts +4 -0
  56. package/dist/services/settings.d.ts +13 -0
  57. package/dist/types/bundle.types.d.ts +444 -0
  58. package/dist/types/common.d.ts +6 -0
  59. package/dist/types/config.types.d.ts +0 -0
  60. package/dist/types/customPlayer.types.d.ts +171 -0
  61. package/dist/types/types.d.ts +174 -0
  62. package/package.json +6 -9
@@ -0,0 +1,171 @@
1
+ import { Empty } from './common';
2
+ export declare type ChannelSource = {
3
+ new (uri: string, originalOptions: Record<string, any>, channelName: string, programName: string, programDescription: string, from: Date, to: Date): ChannelSource;
4
+ description: string;
5
+ name: string;
6
+ uri: string;
7
+ from: Date;
8
+ channelName: string;
9
+ to: Date;
10
+ type: 'channel';
11
+ watchWithoutAdsRecommendation: {
12
+ showPurchaseDialog: () => void;
13
+ } | null;
14
+ };
15
+ export declare type AdSource = {
16
+ new (uri: string, name: string, description: string, skipDelayMs: number | null, adDurationMs: number, trackingContext?: any, // internal Tivio types
17
+ adMarker?: any, // internal Tivio types
18
+ packInfo?: any, // internal Tivio types
19
+ provider?: any): AdSource;
20
+ description: string;
21
+ name: string;
22
+ uri: string;
23
+ durationMs: number;
24
+ skipDelayMs: number | null;
25
+ type: 'ad';
26
+ /**
27
+ * true if is skippable and skip countdown has passed
28
+ */
29
+ canSkip: boolean;
30
+ /**
31
+ * true ad if is skippable after some skipDelayMs (if it is skippable, skipDelayMs is defined)
32
+ */
33
+ isSkippable: boolean;
34
+ /**
35
+ * Skip ad. Only works when canSkip is true
36
+ */
37
+ skip: () => void;
38
+ /**
39
+ * Order in ad break (ad break is a group of ads played right after each other)
40
+ */
41
+ order: number;
42
+ /**
43
+ * Total number of ads in ad break (ad break is a group of ads played right after each other)
44
+ */
45
+ totalCount: number;
46
+ secondsToEnd: number;
47
+ secondsToSkippable: number | null;
48
+ };
49
+ export declare type VodTivioSource = {
50
+ new (uri: string, videoId: string, name: string, description: string, adMonetizationId?: string): VodTivioSource;
51
+ type: 'vod_tivio';
52
+ description: string;
53
+ name: string;
54
+ uri: string;
55
+ };
56
+ export declare type VodExternalSource = {
57
+ new (uri: string, monetizationId: string, name: string, description: string, originalOptions: Record<string, any>): VodTivioSource;
58
+ type: 'vod_external';
59
+ description: string;
60
+ name: string;
61
+ uri: string;
62
+ };
63
+ export declare type InputSource = AdSource | ChannelSource | VodTivioSource | VodExternalSource;
64
+ declare type PlayerState = 'playing' | 'paused' | 'idle';
65
+ export interface PlayerInterface {
66
+ pause: () => void;
67
+ /**
68
+ * unpause
69
+ */
70
+ play: () => void;
71
+ /**
72
+ * @param {number} ms - milliseconds relative to start of video (relative to 0 ms)
73
+ * or in case of TV programs relative to start of the program (relative to source.from ms)
74
+ */
75
+ seekTo: (ms: number) => void;
76
+ /**
77
+ * Source to be passed to player.
78
+ *
79
+ * Depending on autoplay settings it should either start playing
80
+ * immediately or just be loaded by player and stay paused.
81
+ */
82
+ setSource: (source: InputSource | null) => void;
83
+ /**
84
+ * volume in [0,1]
85
+ */
86
+ setVolume?: (volume: number) => void;
87
+ mute?: () => void;
88
+ /**
89
+ * restore volume to previous value
90
+ */
91
+ unmute?: () => void;
92
+ }
93
+ export declare type PlayerWrapper = {
94
+ /**
95
+ * Report that playback of video has finished
96
+ */
97
+ onPlaybackEnded: () => void;
98
+ /**
99
+ * Report video progress in milliseconds
100
+ */
101
+ onTimeChanged: (ms: number) => void;
102
+ /**
103
+ * Report that video state changed
104
+ */
105
+ onStateChanged: (state: PlayerState) => void;
106
+ /**
107
+ * Send source to Tivio
108
+ */
109
+ onSourceChanged: (source: InputSource | null) => void;
110
+ /**
111
+ * Report that video failed to load (never started playing)
112
+ */
113
+ onLoadError: (error: Error) => void;
114
+ /**
115
+ * Report that video failed during playback (successfully loaded and then failed, e.g. part of stream is invalid)
116
+ */
117
+ onError: (error: Error) => void;
118
+ /**
119
+ * Unpause video
120
+ */
121
+ play: () => void;
122
+ /**
123
+ * Pause video
124
+ */
125
+ pause: () => void;
126
+ /**
127
+ * Currently playing source
128
+ */
129
+ source: InputSource | null;
130
+ events: {
131
+ isSupported: (even: string) => boolean;
132
+ addListener: <T = any>(event: string, cb: (value: T) => Empty) => void;
133
+ removeListener: <T = any>(event: string, cb: (value: T) => Empty) => void;
134
+ removeAllListeners: () => void;
135
+ };
136
+ /**
137
+ * Register a low level player that implements player methods, like play video, change volume, etc.
138
+ */
139
+ register: (playerInterface: PlayerInterface) => void;
140
+ /**
141
+ * duration of current source in ms (both setter and getter)
142
+ */
143
+ durationMs: number | null;
144
+ isPlaybackStarted: boolean;
145
+ isPaused: boolean;
146
+ isPlaying: boolean;
147
+ isIdle: boolean;
148
+ error: Error | null;
149
+ /**
150
+ * Replay the video that finished playback
151
+ */
152
+ replay: () => void;
153
+ /**
154
+ * Retry to play a video that failed to start playing (e.g. due to a network error)
155
+ */
156
+ retry: () => void;
157
+ togglePlayPause: () => void;
158
+ seekTo: (ms: number) => void;
159
+ /**
160
+ * set volume to value between 0,1
161
+ */
162
+ setVolume: (volume: number) => void;
163
+ /**
164
+ * change volume by value between -1,1
165
+ */
166
+ changeVolumeBy: (volume: number) => void;
167
+ setMuted: (muted: boolean) => void;
168
+ toggleMuted: () => void;
169
+ };
170
+ export declare type UsePlayerEvent = <T = any>(eventName: string) => T | null;
171
+ export {};
@@ -0,0 +1,174 @@
1
+ /**
2
+ * Copyright (c) 2021, nangu.TV, a.s. All rights reserved.
3
+ * nangu.TV, a.s PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
4
+ */
5
+ /**
6
+ * Export public client side API
7
+ */
8
+ import type { Monetization, Video, User } from '@tivio/common';
9
+ import type React from 'react';
10
+ declare type RemoteProviderProps = {
11
+ disableUnmounting?: boolean;
12
+ language?: string;
13
+ };
14
+ declare enum LangCode {
15
+ CS = "cs",
16
+ DE = "de",
17
+ EN = "en",
18
+ FR = "fr",
19
+ PL = "pl",
20
+ SK = "sk",
21
+ SP = "sp"
22
+ }
23
+ declare type Widget = {
24
+ id: string;
25
+ channels: Channel[];
26
+ isEnabled: boolean | null;
27
+ name: string | null;
28
+ recentVideos: Video[] | null;
29
+ widgetId: string | null;
30
+ lastVideo: Video | null;
31
+ };
32
+ declare type Channel = {
33
+ id: string;
34
+ name: string;
35
+ header: string;
36
+ headerLogo: string;
37
+ recentVideos: Video[];
38
+ };
39
+ declare type Section = {
40
+ id: string;
41
+ name: string;
42
+ channel: Channel;
43
+ videos: Video[];
44
+ };
45
+ declare type Chapter = any;
46
+ declare type Purchase = {
47
+ isPurchased: boolean;
48
+ monetizationId: string;
49
+ videoId: string;
50
+ status: string;
51
+ video: Video | null;
52
+ };
53
+ declare type Marker = {
54
+ id: string;
55
+ type: string;
56
+ from: Date;
57
+ to: Date;
58
+ count?: number;
59
+ fromMs?: number;
60
+ toMs?: number;
61
+ };
62
+ declare type BetOffer = {
63
+ betService: string;
64
+ league: string;
65
+ odds: {
66
+ winner: string;
67
+ rate: number;
68
+ }[];
69
+ sport: string;
70
+ opponent1: string;
71
+ opponent2: string;
72
+ time: Date;
73
+ };
74
+ export interface TivioWidgetProps {
75
+ id: string;
76
+ ref: React.MutableRefObject<TivioWidgetRef>;
77
+ onEnabled?: (enabled: boolean) => any;
78
+ onBlur?: (event: {
79
+ key: string;
80
+ width: number;
81
+ x: number;
82
+ }) => any;
83
+ }
84
+ export interface TivioWidgetRef {
85
+ focus: (args: {
86
+ x?: number;
87
+ }) => void;
88
+ handleKey: (key: string) => ({
89
+ handled: boolean;
90
+ x: number;
91
+ });
92
+ unfocus: () => ({
93
+ x: number;
94
+ });
95
+ }
96
+ interface VodTivioSourcePojo {
97
+ type: 'VodTivioSource';
98
+ description: string;
99
+ path: string;
100
+ name: string;
101
+ uri: string;
102
+ poster?: string;
103
+ adMonetizationId?: string;
104
+ }
105
+ interface ChannelSourcePojo {
106
+ type: 'ChannelSource';
107
+ uri: string;
108
+ originalOptions: any;
109
+ channelName: string;
110
+ programName: string;
111
+ programDescription: string;
112
+ from: Date;
113
+ to: Date;
114
+ poster?: string;
115
+ }
116
+ declare type VideoPath = string;
117
+ interface WebPlayerProps {
118
+ id: string;
119
+ source?: VodTivioSourcePojo | ChannelSourcePojo | VideoPath | null;
120
+ onEnded?: () => any;
121
+ /**
122
+ * If this function is specified, then "Back" button is shown in top right corner.
123
+ */
124
+ onBack?: () => void;
125
+ className?: string;
126
+ /**
127
+ * default false
128
+ *
129
+ * If you choose `autoplay` make sure that autoplay is allowed in the specific situation.
130
+ * In some cases it may not be allowed, e.g. before the user interacted with the site, and the video
131
+ * will stay paused.
132
+ *
133
+ * Source: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide
134
+ */
135
+ autoplay?: boolean;
136
+ /**
137
+ * default false
138
+ */
139
+ canReplay?: boolean;
140
+ /**
141
+ * default false
142
+ */
143
+ showMarkers?: boolean;
144
+ /**
145
+ * number[] is array of keyboard event.which numeric codes
146
+ * (see https://keycode.info/)
147
+ */
148
+ customShortcuts?: Partial<{
149
+ toggleFullscreen: number[];
150
+ togglePause: number[];
151
+ toggleMute: number[];
152
+ jumpForward: number[];
153
+ jumpBack: number[];
154
+ volumeUp: number[];
155
+ volumeDown: number[];
156
+ }>;
157
+ /**
158
+ * default true
159
+ */
160
+ enableKeyboardShortcuts?: boolean;
161
+ onProgress?: (event: React.ChangeEvent<HTMLVideoElement>) => void;
162
+ /**
163
+ * @deprecated this callback is never called. Will be removed in @tivio/sdk-react version 4
164
+ */
165
+ onPlayerControllerCreated?: (playerController: any) => void;
166
+ }
167
+ declare type TivioSources = {
168
+ AdSource: any;
169
+ ChannelSource: any;
170
+ VodExternalSource: any;
171
+ VodTivioSource: any;
172
+ };
173
+ export type { RemoteProviderProps, WebPlayerProps, Marker, BetOffer, Purchase, Chapter, Widget, Channel, Section, Video, TivioSources, User, Monetization, VodTivioSourcePojo, ChannelSourcePojo, };
174
+ export { LangCode };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tivio/sdk-react",
3
- "version": "3.5.0",
3
+ "version": "3.5.1",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "source": "src/index.ts",
@@ -9,17 +9,16 @@
9
9
  "access": "public"
10
10
  },
11
11
  "scripts": {
12
- "build": "bash ./scripts/build_prod.sh && yarn typesRollup",
13
- "build:dev": "bash ./scripts/build_dev.sh && yarn typesRollup",
14
- "build:local": "bash ./scripts/build_with_local_bundle.sh && yarn typesRollup",
12
+ "build": "bash ./scripts/build_prod.sh",
13
+ "build:dev": "bash ./scripts/build_dev.sh",
14
+ "build:local": "bash ./scripts/build_with_local_bundle.sh",
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
18
  "prepublishOnly": "yarn && yarn run build && yarn ts-node ./scripts/prepublish.ts",
19
19
  "postpublish": "yarn ts-node ./scripts/postpublish.ts",
20
20
  "publish:alpha": "npm publish --tag alpha",
21
- "check:cycles": "npx madge --circular src/**/*",
22
- "typesRollup": "yarn ts-node ./scripts/typesRollup.ts"
21
+ "check:cycles": "npx madge --circular src/**/*"
23
22
  },
24
23
  "peerDependencies": {
25
24
  "react": "^17.0.0",
@@ -29,7 +28,7 @@
29
28
  "@material-ui/core": "^4.11.2",
30
29
  "@material-ui/icons": "^4.11.2",
31
30
  "@sentry/browser": "^6.1.0",
32
- "@tivio/common": "1.1.87",
31
+ "@tivio/common": "1.1.88",
33
32
  "dayjs": "^1.11.0",
34
33
  "es7-object-polyfill": "^1.0.1",
35
34
  "firebase": "^8.2.3",
@@ -46,12 +45,10 @@
46
45
  "yup": "^0.32.9"
47
46
  },
48
47
  "devDependencies": {
49
- "@microsoft/api-extractor": "^7.23.0",
50
48
  "@testing-library/jest-dom": "^5.11.9",
51
49
  "@testing-library/react": "^11.2.3",
52
50
  "@testing-library/react-hooks": "^5.0.3",
53
51
  "@testing-library/user-event": "^12.1.10",
54
- "@tivio/types": "*",
55
52
  "@types/jest": "^26.0.15",
56
53
  "@types/node": "^12.0.0",
57
54
  "@types/node-fetch": "^2.5.8",