@applicaster/zapp-react-native-utils 12.0.0-alpha.7725319213 → 12.0.0-alpha.7855034103
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/actionsExecutor/ActionExecutorContext.tsx +16 -8
- package/analyticsUtils/AnalyticsEvents/index.ts +6 -0
- package/analyticsUtils/AnalyticsEvents/searchEvents.ts +21 -0
- package/analyticsUtils/__tests__/analyticsManager.test.js +75 -73
- package/analyticsUtils/analyticsPlugins.ts +25 -0
- package/analyticsUtils/events.ts +6 -0
- package/analyticsUtils/helpers/hooks.ts +1 -1
- package/analyticsUtils/index.tsx +6 -0
- package/appUtils/HooksManager/index.js +3 -1
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +12 -3
- package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +1 -1
- package/appUtils/keyCodes/__tests__/keyCodes.test.js +80 -85
- package/appUtils/keyCodes/keys.web.js +1 -0
- package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +53 -0
- package/appUtils/playerManager/conts.ts +5 -0
- package/appUtils/playerManager/index.ts +1 -0
- package/appUtils/playerManager/player.ts +47 -6
- package/appUtils/playerManager/playerFactory.ts +12 -10
- package/appUtils/playerManager/playerNative.ts +32 -0
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +6 -1
- package/appUtils/playerManager/usePlayerState.tsx +13 -1
- package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +50 -0
- package/cellUtils/__tests__/cellUtils.test.ts +48 -0
- package/cellUtils/__tests__/fixtures.ts +13 -0
- package/cellUtils/index.ts +27 -2
- package/dateUtils/index.ts +11 -0
- package/focusManager/index.ts +1 -1
- package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +2 -2
- package/functionUtils/__tests__/functionUtils.test.js +244 -248
- package/headersUtils/index.ts +1 -0
- package/inflatedUrlUtils/index.ts +4 -4
- package/localizationUtils/__tests__/localizationUtils.test.ts +78 -55
- package/localizationUtils/index.ts +13 -19
- package/logger/index.ts +1 -1
- package/manifestUtils/defaultManifestConfigurations/generalContent.js +6 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +10 -1
- package/manifestUtils/index.js +5 -1
- package/manifestUtils/secondaryImage/index.js +18 -15
- package/modalState/index.ts +57 -0
- package/navigationUtils/index.ts +56 -7
- package/numberUtils/index.ts +4 -0
- package/package.json +3 -2
- package/playerUtils/configurationGenerator.ts +11 -1
- package/pluginUtils/index.ts +2 -2
- package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +2 -0
- package/reactHooks/autoscrolling/__tests__/{useTrackedView.test.ts → useTrackedView.test.tsx} +18 -1
- package/reactHooks/cell-click/__tests__/index.test.js +5 -0
- package/reactHooks/cell-click/index.ts +2 -2
- package/reactHooks/feed/__tests__/useInflatedUrl.test.ts +18 -3
- package/reactHooks/feed/useInflatedUrl.ts +44 -15
- package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +16 -9
- package/reactHooks/index.ts +2 -0
- package/reactHooks/layout/__tests__/{index.test.js → index.test.tsx} +66 -59
- package/reactHooks/layout/getDeviceInfo/index.ts +4 -2
- package/reactHooks/layout/types/index.ts +2 -0
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +11 -16
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +12 -14
- package/reactHooks/layout/useDimensions/useDimensions.ts +13 -7
- package/reactHooks/navigation/__mocks__/index.ts +15 -0
- package/reactHooks/navigation/__mocks__/useNavigation.ts +7 -0
- package/reactHooks/navigation/__tests__/index.test.tsx +240 -81
- package/reactHooks/navigation/index.ts +208 -86
- package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +3 -1
- package/reactHooks/screen/__mocks__/useScreenContext.ts +3 -1
- package/reactHooks/screen/index.ts +2 -0
- package/reactHooks/screen/useScreenContext.ts +5 -4
- package/reactHooks/screen/useScreenData.ts +1 -1
- package/reactHooks/state/useRivers.ts +3 -1
- package/reactHooks/useListenEventBusEvent.ts +1 -4
- package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +10 -9
- package/riverComponetsMeasurementProvider/index.tsx +2 -2
- package/stringUtils/index.ts +5 -0
- package/testUtils/getByTestId.ts +14 -0
- package/testUtils/index.tsx +38 -23
- package/types.ts +4 -0
|
@@ -41,6 +41,11 @@ export type ChapterMarkerEvent = {
|
|
|
41
41
|
actions: ActionChapter[];
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
export type TitleSummaryEvent = {
|
|
45
|
+
title: string | number;
|
|
46
|
+
summary: string | number;
|
|
47
|
+
};
|
|
48
|
+
|
|
44
49
|
type ChapterMarkersObserverProps = {
|
|
45
50
|
player: Player;
|
|
46
51
|
};
|
|
@@ -60,6 +65,11 @@ export type PlayNextState = PlayNextConfig & {
|
|
|
60
65
|
export class OverlaysObserver {
|
|
61
66
|
readonly chapterSubject: BehaviorSubject<ChapterMarkerEvent>;
|
|
62
67
|
private playNextSubject: BehaviorSubject<PlayNextState>;
|
|
68
|
+
private titleSummarySubject: BehaviorSubject<TitleSummaryEvent>;
|
|
69
|
+
private feedUrl: string;
|
|
70
|
+
private reloadData: () => void;
|
|
71
|
+
private updateTitleAndDescription: (data: any) => void;
|
|
72
|
+
private feedDataInterval: any;
|
|
63
73
|
private releasePlayerObserver?: () => void;
|
|
64
74
|
readonly entry: ZappEntry;
|
|
65
75
|
private chapterMarkerEvents: ChapterMarkerEvent[];
|
|
@@ -70,14 +80,55 @@ export class OverlaysObserver {
|
|
|
70
80
|
constructor({ player }: ChapterMarkersObserverProps) {
|
|
71
81
|
this.chapterSubject = new BehaviorSubject(null);
|
|
72
82
|
this.playNextSubject = new BehaviorSubject(null);
|
|
83
|
+
|
|
84
|
+
this.titleSummarySubject = new BehaviorSubject<TitleSummaryEvent>({
|
|
85
|
+
title: player.getEntry()?.title || "",
|
|
86
|
+
summary: player.getEntry()?.summary || "",
|
|
87
|
+
});
|
|
88
|
+
|
|
73
89
|
this.entry = player.getEntry();
|
|
74
90
|
this.player = player;
|
|
75
91
|
|
|
76
92
|
this.chapterMarkerEvents = this.prepareChapterMarkers();
|
|
77
93
|
this.releasePlayerObserver = this.subscribeToPlayerEvents();
|
|
94
|
+
this.feedUrl = "";
|
|
95
|
+
this.reloadData = () => {};
|
|
96
|
+
this.updateTitleAndDescription = () => {};
|
|
97
|
+
this.feedDataInterval = null;
|
|
78
98
|
void this.preparePlayNext();
|
|
79
99
|
}
|
|
80
100
|
|
|
101
|
+
private setupFeedDataInterval(interval: number) {
|
|
102
|
+
if (this.feedUrl && this.reloadData && this.updateTitleAndDescription) {
|
|
103
|
+
this.feedDataInterval = setInterval(() => {
|
|
104
|
+
this.reloadData();
|
|
105
|
+
}, interval * 1000);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
public clearFeedDataInterval() {
|
|
110
|
+
if (this.feedDataInterval) {
|
|
111
|
+
clearInterval(this.feedDataInterval);
|
|
112
|
+
this.feedDataInterval = null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public setFeedDataHandlers(
|
|
117
|
+
feedUrl: string,
|
|
118
|
+
reloadData: () => void,
|
|
119
|
+
interval: number,
|
|
120
|
+
updateTitleAndDescription: (data: any) => void
|
|
121
|
+
) {
|
|
122
|
+
this.feedUrl = feedUrl;
|
|
123
|
+
this.reloadData = reloadData;
|
|
124
|
+
this.updateTitleAndDescription = updateTitleAndDescription;
|
|
125
|
+
this.setupFeedDataInterval(interval);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
public getTitleSummaryObservable(): Observable<TitleSummaryEvent> {
|
|
129
|
+
return this.titleSummarySubject.asObservable().pipe(distinctUntilChanged());
|
|
130
|
+
}
|
|
131
|
+
|
|
81
132
|
handleUserCancelPlayNext = () => {
|
|
82
133
|
this.isCanceledByUser = true;
|
|
83
134
|
this.playNextSubject.next(null);
|
|
@@ -281,7 +332,9 @@ export class OverlaysObserver {
|
|
|
281
332
|
onPlayerClose = () => {
|
|
282
333
|
this.chapterSubject.complete();
|
|
283
334
|
this.playNextSubject.complete();
|
|
335
|
+
this.titleSummarySubject.complete();
|
|
284
336
|
this.releasePlayerObserver?.();
|
|
337
|
+
this.clearFeedDataInterval();
|
|
285
338
|
this.releasePlayerObserver = null;
|
|
286
339
|
};
|
|
287
340
|
|
|
@@ -20,6 +20,11 @@ export enum SharedPlayerCallBacksKeys {
|
|
|
20
20
|
OnPlayerMute = "onPlayerMute",
|
|
21
21
|
OnPlayerUnmute = "onPlayerUnmute",
|
|
22
22
|
|
|
23
|
+
onVideoFullscreenPlayerDidDismiss = "onVideoFullscreenPlayerDidDismiss",
|
|
24
|
+
onVideoFullscreenPlayerDidPresent = "onVideoFullscreenPlayerDidPresent",
|
|
25
|
+
onVideoFullscreenPlayerWillDismiss = "onVideoFullscreenPlayerWillDismiss",
|
|
26
|
+
onVideoFullscreenPlayerWillPresent = "onVideoFullscreenPlayerWillPresent",
|
|
27
|
+
|
|
23
28
|
OnAdBegin = "onAdBegin",
|
|
24
29
|
OnAdBreakBegin = "onAdBreakBegin",
|
|
25
30
|
OnAdBreakEnd = "onAdBreakEnd",
|
|
@@ -42,7 +42,7 @@ export class Player {
|
|
|
42
42
|
|
|
43
43
|
protected startPosition?: number | null;
|
|
44
44
|
readonly playerRole: PlayerRole = PlayerRole.Unspecified;
|
|
45
|
-
private
|
|
45
|
+
private overlaysObserver?: OverlaysObserver | null;
|
|
46
46
|
private entryObservable?: BehaviorSubject<ZappEntry> | null;
|
|
47
47
|
|
|
48
48
|
protected listeners: {
|
|
@@ -77,7 +77,7 @@ export class Player {
|
|
|
77
77
|
audioTracks: [],
|
|
78
78
|
audioTrackId: null,
|
|
79
79
|
textTrackId: null,
|
|
80
|
-
}
|
|
80
|
+
},
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
this.playerId = props.playerId || "error, no player id";
|
|
@@ -95,11 +95,11 @@ export class Player {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
getOverlayObservable = () => {
|
|
98
|
-
if (!this.
|
|
99
|
-
this.
|
|
98
|
+
if (!this.overlaysObserver) {
|
|
99
|
+
this.overlaysObserver = new OverlaysObserver({ player: this });
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
return this.
|
|
102
|
+
return this.overlaysObserver;
|
|
103
103
|
};
|
|
104
104
|
|
|
105
105
|
getEntryObservable = (): BehaviorSubject<ZappEntry | null> => {
|
|
@@ -278,6 +278,10 @@ export class Player {
|
|
|
278
278
|
return this.playerState.isBuffering;
|
|
279
279
|
};
|
|
280
280
|
|
|
281
|
+
isReadyToPlay = (): boolean => {
|
|
282
|
+
return this.playerState.isReadyToPlay;
|
|
283
|
+
};
|
|
284
|
+
|
|
281
285
|
// Methods to call actions on the player
|
|
282
286
|
seekTo = (_position: number) => {};
|
|
283
287
|
|
|
@@ -410,6 +414,32 @@ export class Player {
|
|
|
410
414
|
});
|
|
411
415
|
};
|
|
412
416
|
|
|
417
|
+
onVideoFullscreenPlayerWillDismiss = () => {
|
|
418
|
+
this.invokeListenersUpdate({
|
|
419
|
+
callbackName:
|
|
420
|
+
SharedPlayerCallBacksKeys.onVideoFullscreenPlayerWillDismiss,
|
|
421
|
+
});
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
onVideoFullscreenPlayerDidDismiss = () => {
|
|
425
|
+
this.invokeListenersUpdate({
|
|
426
|
+
callbackName: SharedPlayerCallBacksKeys.onVideoFullscreenPlayerDidDismiss,
|
|
427
|
+
});
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
onVideoFullscreenPlayerWillPresent = () => {
|
|
431
|
+
this.invokeListenersUpdate({
|
|
432
|
+
callbackName:
|
|
433
|
+
SharedPlayerCallBacksKeys.onVideoFullscreenPlayerWillPresent,
|
|
434
|
+
});
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
onVideoFullscreenPlayerDidPresent = () => {
|
|
438
|
+
this.invokeListenersUpdate({
|
|
439
|
+
callbackName: SharedPlayerCallBacksKeys.onVideoFullscreenPlayerDidPresent,
|
|
440
|
+
});
|
|
441
|
+
};
|
|
442
|
+
|
|
413
443
|
public invokeListenersUpdate = ({
|
|
414
444
|
callbackName,
|
|
415
445
|
event = {},
|
|
@@ -630,6 +660,12 @@ export class Player {
|
|
|
630
660
|
onBufferStart: this.onBufferStart,
|
|
631
661
|
onBufferComplete: this.onBufferComplete,
|
|
632
662
|
|
|
663
|
+
onPlayerClose: this.onPlayerClose,
|
|
664
|
+
onVideoFullscreenPlayerWillPresent: this.onVideoFullscreenPlayerWillPresent,
|
|
665
|
+
onVideoFullscreenPlayerDidPresent: this.onVideoFullscreenPlayerDidPresent,
|
|
666
|
+
onVideoFullscreenPlayerWillDismiss: this.onVideoFullscreenPlayerWillDismiss,
|
|
667
|
+
onVideoFullscreenPlayerDidDismiss: this.onVideoFullscreenPlayerDidDismiss,
|
|
668
|
+
|
|
633
669
|
// Ads Callbacks:
|
|
634
670
|
onAdBegin: this.onAdBegin,
|
|
635
671
|
onAdBreakBegin: this.onAdBreakBegin,
|
|
@@ -652,6 +688,10 @@ export class Player {
|
|
|
652
688
|
_selected?: QuickBrickPlayer.TextTrack | QuickBrickPlayer.AudioTrack
|
|
653
689
|
) => {};
|
|
654
690
|
|
|
691
|
+
setPlaybackRate = (_rate) => {};
|
|
692
|
+
startSleepTimer = (_timestamp) => {};
|
|
693
|
+
cancelSleepTimer = () => {};
|
|
694
|
+
|
|
655
695
|
getPluginConfiguration = () => null;
|
|
656
696
|
appStateChange = (_appState, _previousAppState) => {};
|
|
657
697
|
|
|
@@ -686,5 +726,6 @@ export class Player {
|
|
|
686
726
|
return true;
|
|
687
727
|
}
|
|
688
728
|
|
|
689
|
-
public supportsNativeControls = ():boolean => false
|
|
729
|
+
public supportsNativeControls = (): boolean => false;
|
|
730
|
+
public supportNativeCast = (): boolean => false;
|
|
690
731
|
}
|
|
@@ -9,21 +9,23 @@ type PlayerFactoryItem = {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
type PlayerFactoryProps = {
|
|
12
|
-
player: any
|
|
13
|
-
playerId: string
|
|
14
|
-
autoplay: boolean
|
|
15
|
-
entry: ZappEntry
|
|
16
|
-
muted: boolean
|
|
17
|
-
playerPluginId: string
|
|
18
|
-
screenConfig: Record<string, any
|
|
19
|
-
playerRole: PlayerRole
|
|
20
|
-
}
|
|
12
|
+
player: any;
|
|
13
|
+
playerId: string;
|
|
14
|
+
autoplay: boolean;
|
|
15
|
+
entry: ZappEntry;
|
|
16
|
+
muted: boolean;
|
|
17
|
+
playerPluginId: string;
|
|
18
|
+
screenConfig: Record<string, any>;
|
|
19
|
+
playerRole: PlayerRole;
|
|
20
|
+
};
|
|
21
21
|
|
|
22
22
|
interface PlayerConstructor {
|
|
23
23
|
new (params: any): Player;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export const playerFactory = (
|
|
26
|
+
export const playerFactory = (
|
|
27
|
+
config: PlayerFactoryProps
|
|
28
|
+
): PlayerFactoryItem | null => {
|
|
27
29
|
const IDENTIFIER = config?.playerPluginId;
|
|
28
30
|
|
|
29
31
|
if (!IDENTIFIER) {
|
|
@@ -42,6 +42,9 @@ const PlayerModuleFuncNames = {
|
|
|
42
42
|
rewind: "rewind",
|
|
43
43
|
play: "play",
|
|
44
44
|
pause: "pause",
|
|
45
|
+
startSleepTimer: "startSleepTimer",
|
|
46
|
+
cancelSleepTimer: "cancelSleepTimer",
|
|
47
|
+
getSleepTimerEnd: "getSleepTimerEnd",
|
|
45
48
|
};
|
|
46
49
|
|
|
47
50
|
export class PlayerNative extends Player {
|
|
@@ -173,6 +176,25 @@ export class PlayerNative extends Player {
|
|
|
173
176
|
}
|
|
174
177
|
};
|
|
175
178
|
|
|
179
|
+
startSleepTimer = (sleepTimestamp: number) => {
|
|
180
|
+
if (
|
|
181
|
+
!this.invokeNativeFunction(
|
|
182
|
+
PlayerModuleFuncNames.startSleepTimer,
|
|
183
|
+
sleepTimestamp
|
|
184
|
+
)
|
|
185
|
+
) {
|
|
186
|
+
this.currentPlayerComponent()?.["startSleepTimer"](sleepTimestamp);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
cancelSleepTimer = () => {
|
|
191
|
+
if (!this.invokeNativeFunction(PlayerModuleFuncNames.cancelSleepTimer)) {
|
|
192
|
+
this.currentPlayerComponent()?.[
|
|
193
|
+
PlayerModuleFuncNames.cancelSleepTimer
|
|
194
|
+
]?.();
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
176
198
|
disableBufferAnimation = (): boolean => false;
|
|
177
199
|
|
|
178
200
|
setLanguage = (
|
|
@@ -181,6 +203,10 @@ export class PlayerNative extends Player {
|
|
|
181
203
|
this.currentPlayerComponent()?.["setLanguage"]?.(selected);
|
|
182
204
|
};
|
|
183
205
|
|
|
206
|
+
setPlaybackRate = (rate: number) => {
|
|
207
|
+
this.currentPlayerComponent()?.["setPlaybackRate"]?.(rate);
|
|
208
|
+
};
|
|
209
|
+
|
|
184
210
|
getPluginConfiguration = () => {
|
|
185
211
|
return (this.currentPlayerComponent() as any)?.props?.pluginConfiguration;
|
|
186
212
|
};
|
|
@@ -195,6 +221,7 @@ export class PlayerNative extends Player {
|
|
|
195
221
|
};
|
|
196
222
|
|
|
197
223
|
closeNativePlayer = () => {
|
|
224
|
+
RNPlayerManager?.[this.playerPluginId]?.stopBackgroundPlayback?.();
|
|
198
225
|
// TODO: Delete does not work
|
|
199
226
|
this.currentPlayerComponent()?.["closeNativePlayer"]?.();
|
|
200
227
|
};
|
|
@@ -269,4 +296,9 @@ export class PlayerNative extends Player {
|
|
|
269
296
|
|
|
270
297
|
supportsNativeControls = (): boolean =>
|
|
271
298
|
toBooleanWithDefaultFalse(this.getConfig()?.["supports_native_controls"]);
|
|
299
|
+
|
|
300
|
+
supportNativeCast = (): boolean =>
|
|
301
|
+
toBooleanWithDefaultFalse(
|
|
302
|
+
this.playerPluginId === "quick-brick-player-brightcove"
|
|
303
|
+
);
|
|
272
304
|
}
|
|
@@ -4,6 +4,7 @@ import { useEffect } from "react";
|
|
|
4
4
|
import { playerManager } from "./index";
|
|
5
5
|
import { useValidatePlayerConfig } from "../../playerUtils/useValidatePlayerConfig";
|
|
6
6
|
import { PlayerRole } from "./conts";
|
|
7
|
+
import { isAppleTV } from "@applicaster/zapp-react-native-ui-components/Helpers/Platform";
|
|
7
8
|
|
|
8
9
|
// TODO: Rename to ControllerType
|
|
9
10
|
export const usePlayerControllerSetup = ({
|
|
@@ -34,10 +35,14 @@ export const usePlayerControllerSetup = ({
|
|
|
34
35
|
useValidatePlayerConfig(config);
|
|
35
36
|
|
|
36
37
|
useEffect(() => {
|
|
38
|
+
const newConfig = isAppleTV()
|
|
39
|
+
? { supports_native_controls: true, ...config }
|
|
40
|
+
: config;
|
|
41
|
+
|
|
37
42
|
const newPlayerController = new ControllerType({
|
|
38
43
|
player: ref,
|
|
39
44
|
listener: props as any,
|
|
40
|
-
config,
|
|
45
|
+
config: newConfig,
|
|
41
46
|
playerId,
|
|
42
47
|
entry,
|
|
43
48
|
playerPluginId: pluginId,
|
|
@@ -9,6 +9,7 @@ type PlayerState = {
|
|
|
9
9
|
isLive: boolean;
|
|
10
10
|
isPaused: boolean;
|
|
11
11
|
isBuffering: boolean;
|
|
12
|
+
isReadyToPlay: boolean;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
export const usePlayerState = (
|
|
@@ -20,12 +21,14 @@ export const usePlayerState = (
|
|
|
20
21
|
const [seekableDuration, setSeekableDuration] = React.useState<number>(null);
|
|
21
22
|
const [isLive, setIsLive] = React.useState<boolean>(null);
|
|
22
23
|
const [isBuffering, setIsBuffering] = React.useState<boolean>(false);
|
|
24
|
+
const [isReadyToPlay, setIsReadyToPlay] = React.useState<boolean>(false);
|
|
23
25
|
const [isPaused, setIsPaused] = React.useState<boolean>(false);
|
|
24
26
|
|
|
25
27
|
const player: Player = usePlayer(playerId);
|
|
26
28
|
|
|
27
29
|
const onPlayerChangeState = React.useCallback(() => {
|
|
28
30
|
setIsBuffering(player.isBuffering());
|
|
31
|
+
setIsReadyToPlay(player.isReadyToPlay);
|
|
29
32
|
setCurrentTime(player.getContentPosition());
|
|
30
33
|
setDuration(player.getDuration());
|
|
31
34
|
setSeekableDuration(player.getSeekableDuration());
|
|
@@ -60,7 +63,16 @@ export const usePlayerState = (
|
|
|
60
63
|
isLive,
|
|
61
64
|
isPaused,
|
|
62
65
|
isBuffering,
|
|
66
|
+
isReadyToPlay,
|
|
63
67
|
}),
|
|
64
|
-
[
|
|
68
|
+
[
|
|
69
|
+
currentTime,
|
|
70
|
+
duration,
|
|
71
|
+
seekableDuration,
|
|
72
|
+
isLive,
|
|
73
|
+
isPaused,
|
|
74
|
+
isBuffering,
|
|
75
|
+
isReadyToPlay,
|
|
76
|
+
]
|
|
65
77
|
);
|
|
66
78
|
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { OverlaysObserver } from "./OverlayObserver/OverlaysObserver";
|
|
3
|
+
import { useFeedLoader } from "../../reactHooks";
|
|
4
|
+
import { usePlayer } from "./usePlayer";
|
|
5
|
+
|
|
6
|
+
export const useTitleSummaryOverlay = (
|
|
7
|
+
feedUrl,
|
|
8
|
+
entry,
|
|
9
|
+
isLive = false,
|
|
10
|
+
interval: number
|
|
11
|
+
) => {
|
|
12
|
+
const player = usePlayer();
|
|
13
|
+
const [title, setTitle] = useState<string | number>(entry?.title || "");
|
|
14
|
+
const [summary, setSummary] = useState<string | number>(entry?.summary || "");
|
|
15
|
+
|
|
16
|
+
// Hook to load feed data
|
|
17
|
+
const { data: feedData, reloadData } = useFeedLoader({ feedUrl });
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (player && feedUrl && isLive) {
|
|
21
|
+
const observer = new OverlaysObserver({ player });
|
|
22
|
+
|
|
23
|
+
observer.setFeedDataHandlers(feedUrl, reloadData, interval, (entry) => {
|
|
24
|
+
setTitle(entry?.title || "");
|
|
25
|
+
setSummary(entry?.summary || "");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const subscription = observer
|
|
29
|
+
.getTitleSummaryObservable()
|
|
30
|
+
.subscribe(({ title, summary }) => {
|
|
31
|
+
setTitle(title);
|
|
32
|
+
setSummary(summary);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return () => {
|
|
36
|
+
subscription.unsubscribe();
|
|
37
|
+
observer.clearFeedDataInterval();
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}, [player, feedUrl, reloadData, isLive]);
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (isLive && feedData?.entry?.[0]) {
|
|
44
|
+
setTitle(feedData.entry[0].title || "");
|
|
45
|
+
setSummary(feedData.entry[0].summary || "");
|
|
46
|
+
}
|
|
47
|
+
}, [feedData]);
|
|
48
|
+
|
|
49
|
+
return { title, summary };
|
|
50
|
+
};
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
castAndFallbackColor,
|
|
15
15
|
compact,
|
|
16
16
|
getValue,
|
|
17
|
+
getColorFromData,
|
|
17
18
|
} from "../";
|
|
18
19
|
|
|
19
20
|
import {
|
|
@@ -388,3 +389,50 @@ describe("getValue", () => {
|
|
|
388
389
|
expect(getValue({ value })(value)).toBeNull();
|
|
389
390
|
});
|
|
390
391
|
});
|
|
392
|
+
|
|
393
|
+
describe("getColorFromData", () => {
|
|
394
|
+
it("should return value directly if valid color", () => {
|
|
395
|
+
const result = getColorFromData({
|
|
396
|
+
data: entry,
|
|
397
|
+
valueFromLayout: "#123456",
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
expect(result).toBe("#123456");
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
it("should return valid rgba color name", () => {
|
|
404
|
+
const result = getColorFromData({
|
|
405
|
+
data: entry,
|
|
406
|
+
valueFromLayout: "rgba(255, 255, 255, 0)",
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
expect(result).toBe("rgba(255, 255, 255, 0)");
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
it("should return path value if path value is set and is valid color", () => {
|
|
413
|
+
const result = getColorFromData({
|
|
414
|
+
data: entry,
|
|
415
|
+
valueFromLayout: "background_color",
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
expect(result).toBe("#123456");
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
it("should return path value if path value is set, nested and is valid color", () => {
|
|
422
|
+
const result = getColorFromData({
|
|
423
|
+
data: entry,
|
|
424
|
+
valueFromLayout: "extensions.background_color",
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
expect(result).toBe("#123456");
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
it("should return valueFromLayout if path does not exist", () => {
|
|
431
|
+
const result = getColorFromData({
|
|
432
|
+
data: entry,
|
|
433
|
+
valueFromLayout: "invalid_color",
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
expect(result).toBe("invalid_color");
|
|
437
|
+
});
|
|
438
|
+
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
|
|
3
|
+
export const defaultColor = "#ffffff";
|
|
4
|
+
|
|
3
5
|
export const entry = {
|
|
4
6
|
type: {
|
|
5
7
|
value: "video",
|
|
@@ -26,7 +28,9 @@ export const entry = {
|
|
|
26
28
|
type: "video/mp4",
|
|
27
29
|
src: "https://wino-feed.s3.amazonaws.com/movieFeed/Ford+v+Ferrari.mp4",
|
|
28
30
|
},
|
|
31
|
+
background_color: "#123456",
|
|
29
32
|
extensions: {
|
|
33
|
+
background_color: "#123456",
|
|
30
34
|
free: false,
|
|
31
35
|
duration: 9000,
|
|
32
36
|
section: "New Releases",
|
|
@@ -46,7 +50,11 @@ export const componentStyle = {
|
|
|
46
50
|
horizontal_list_cell_width: "400",
|
|
47
51
|
cell_plugin_configuration_id: "267bd05a-08bd-4675-bdd3-9b73899773f0",
|
|
48
52
|
horizontal_list_scaled_switch: false,
|
|
53
|
+
background_color: "#123456",
|
|
49
54
|
component_background_color: "rgba(255, 255, 255, 0)",
|
|
55
|
+
background_color_1: "extensions.background_color",
|
|
56
|
+
background_color_2: "invalidColorKey",
|
|
57
|
+
background_color_3: "extensions.invalidColorKeyPath",
|
|
50
58
|
component_padding_left: "",
|
|
51
59
|
horizontal_list_next_offset: 20,
|
|
52
60
|
component_margin_bottom: "",
|
|
@@ -93,6 +101,11 @@ export const VAL = {
|
|
|
93
101
|
upper: "STRING",
|
|
94
102
|
width: 400,
|
|
95
103
|
height: 225,
|
|
104
|
+
colorKey: "background_color",
|
|
105
|
+
colorKeyRgba: "component_background_color",
|
|
106
|
+
colorKeyPath: "background_color_1",
|
|
107
|
+
invalidColorKey: "background_color_2",
|
|
108
|
+
invalidColorKeyPath: "background_color_3",
|
|
96
109
|
};
|
|
97
110
|
|
|
98
111
|
export const TRANSFORM = {
|
package/cellUtils/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
|
+
import validateColor from "validate-color";
|
|
3
4
|
|
|
4
5
|
import { toNumberWithDefault, toNumberWithDefaultZero } from "../numberUtils";
|
|
5
6
|
import { transformColorCode as fixColorHexCode } from "../transform";
|
|
@@ -181,8 +182,8 @@ export const getHeight = (width, aspectRatio) => {
|
|
|
181
182
|
* @returns {string} duration
|
|
182
183
|
*/
|
|
183
184
|
|
|
184
|
-
export const getDurationInMinutes = (seconds
|
|
185
|
-
if (seconds
|
|
185
|
+
export const getDurationInMinutes = (seconds?: number): string => {
|
|
186
|
+
if (!seconds) return "00:00";
|
|
186
187
|
const minutes = Math.floor(Number(seconds) / 60);
|
|
187
188
|
const secondsReminder = Math.floor(Number(seconds)) % 60;
|
|
188
189
|
const pad = (num: number): string => `${num < 10 ? "0" : ""}${num}`;
|
|
@@ -443,3 +444,27 @@ export const toResizeMode = (
|
|
|
443
444
|
resizeMode: "contain",
|
|
444
445
|
};
|
|
445
446
|
};
|
|
447
|
+
|
|
448
|
+
type GetColorFromData = {
|
|
449
|
+
data: Record<string, any>;
|
|
450
|
+
valueFromLayout: string;
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
export const getColorFromData = ({
|
|
454
|
+
data,
|
|
455
|
+
valueFromLayout,
|
|
456
|
+
}: GetColorFromData): string => {
|
|
457
|
+
// Temporary hack to fix color validation when alpha is floating point number
|
|
458
|
+
// https://github.com/dreamyguy/validate-color/issues/44
|
|
459
|
+
if (validateColor(valueFromLayout.replace(".00", ""))) {
|
|
460
|
+
return valueFromLayout;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
const pathValue = R.path(valueFromLayout.split("."), data);
|
|
464
|
+
|
|
465
|
+
if (pathValue && validateColor(pathValue)) {
|
|
466
|
+
return pathValue;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
return valueFromLayout;
|
|
470
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import utc from "dayjs/plugin/utc";
|
|
3
|
+
import timezone from "dayjs/plugin/timezone";
|
|
4
|
+
import isoWeek from "dayjs/plugin/isoWeek";
|
|
5
|
+
|
|
6
|
+
// Extend dayjs with plugins
|
|
7
|
+
dayjs.extend(utc);
|
|
8
|
+
dayjs.extend(timezone);
|
|
9
|
+
dayjs.extend(isoWeek);
|
|
10
|
+
|
|
11
|
+
export { dayjs };
|
package/focusManager/index.ts
CHANGED
|
@@ -86,7 +86,7 @@ export const isFocusable = (component: ZappEntry | ZappUIComponent | any) =>
|
|
|
86
86
|
|
|
87
87
|
type Props = {
|
|
88
88
|
component: ZappUIComponent;
|
|
89
|
-
zappPipesData
|
|
89
|
+
zappPipesData?: ZappPipesData;
|
|
90
90
|
} & Record<string, any>;
|
|
91
91
|
|
|
92
92
|
export const useIsFocusable = (props: Props): void => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`subscriber can be invoked without args 1`] = `
|
|
3
|
+
exports[`functionUtils subscriber can be invoked without args 1`] = `
|
|
4
4
|
Object {
|
|
5
5
|
"handlers": Object {},
|
|
6
6
|
"invokeHandler": [Function],
|
|
@@ -9,7 +9,7 @@ Object {
|
|
|
9
9
|
}
|
|
10
10
|
`;
|
|
11
11
|
|
|
12
|
-
exports[`subscriber returns the original object with additional methods 1`] = `
|
|
12
|
+
exports[`functionUtils subscriber returns the original object with additional methods 1`] = `
|
|
13
13
|
Object {
|
|
14
14
|
"foo": "bar",
|
|
15
15
|
"handlers": Object {},
|