@applicaster/zapp-react-native-utils 13.0.0-alpha.5033140607 → 13.0.0-alpha.5049772260
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/README.md +0 -10
- package/actionsExecutor/ActionExecutor.ts +16 -9
- package/actionsExecutor/ActionExecutorContext.tsx +196 -11
- package/actionsExecutor/consts.ts +4 -0
- package/alertUtils/alert.ts +148 -0
- package/alertUtils/index.ts +1 -148
- package/analyticsUtils/AnalyticPlayerListener.ts +18 -1
- package/analyticsUtils/__tests__/__snapshots__/analyticsManagerNoModule.test.js.snap +9 -9
- package/analyticsUtils/currentScreenProperities.ts +6 -4
- package/analyticsUtils/helpers/hooks.ts +1 -1
- package/appUtils/HooksManager/{Hook.js → Hook.ts} +39 -23
- package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +10 -8
- package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +693 -0
- package/appUtils/HooksManager/__tests__/hook.test.js +196 -184
- package/appUtils/HooksManager/__tests__/hooksManager.test.js +96 -99
- package/appUtils/HooksManager/{constants.js → constants.ts} +1 -1
- package/appUtils/HooksManager/{index.js → index.ts} +124 -113
- package/appUtils/HooksManager/types.ts +119 -0
- package/appUtils/RiverFocusManager/index.js +17 -12
- package/appUtils/accessibilityManager/index.ts +42 -1
- package/appUtils/contextKeysManager/contextResolver.ts +66 -0
- package/appUtils/contextKeysManager/index.ts +2 -2
- package/appUtils/contextKeysManager/utils/index.ts +2 -1
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +8 -6
- package/appUtils/focusManager/index.ts +108 -69
- package/appUtils/focusManager/treeDataStructure/Tree/index.js +25 -3
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +1 -3
- package/appUtils/focusManager/utils/enums.ts +4 -0
- package/appUtils/focusManagerAux/utils/index.ts +4 -3
- package/appUtils/{index.js → index.ts} +1 -1
- package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +2 -2
- package/appUtils/keyCodes/__tests__/keyCodes.test.js +4 -4
- package/appUtils/keyCodes/{index.js → index.ts} +13 -7
- package/appUtils/keyCodes/keys/index.ts +3 -0
- package/appUtils/keyCodes/{keys.android.js → keys/keyEventMapper.ts} +0 -19
- package/appUtils/keyCodes/keys/keys.android.ts +18 -0
- package/appUtils/keyCodes/keys/keys.ios.ts +25 -0
- package/appUtils/keyCodes/keys/keys.ts +15 -0
- package/appUtils/keyCodes/{keysByPlatform.js → keys/keysByPlatform.ts} +4 -0
- package/appUtils/keyCodes/keysByPlatform.ts +8 -0
- package/appUtils/keyInputHandler/KeyInputHandler.ts +68 -0
- package/appUtils/{localizationsHelper.js → localizationsHelper.ts} +23 -0
- package/appUtils/orientationHelper.ts +11 -13
- package/appUtils/platform/const.ts +14 -0
- package/appUtils/platform/platformUtils.ts +47 -18
- package/appUtils/playerManager/index.ts +1 -1
- package/appUtils/playerManager/player.ts +42 -18
- package/appUtils/playerManager/playerNative.ts +18 -2
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +3 -3
- package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +7 -1
- package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
- package/componentsUtils/__tests__/isFirstComponentGallery.test.ts +33 -0
- package/componentsUtils/__tests__/isFirstComponentScreenPicker.test.ts +33 -0
- package/componentsUtils/__tests__/isGallery.test.ts +33 -0
- package/componentsUtils/__tests__/isScreenPicker.test.ts +33 -0
- package/componentsUtils/index.ts +32 -0
- package/dateUtils/index.ts +19 -0
- package/domUtils/{cookieManager.js → cookieManager.ts} +1 -2
- package/equalUtils/__tests__/isEqual/combination.test.ts +263 -0
- package/equalUtils/index.ts +49 -30
- package/focusManager/FocusManager.ts +14 -2
- package/focusManager/index.ts +23 -4
- package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
- package/functionUtils/index.ts +61 -19
- package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
- package/idleUtils/index.ts +1 -1
- package/idleUtils/withTimeout.ts +15 -2
- package/index.d.ts +0 -12
- package/localizationUtils/index.ts +5 -10
- package/logger/const.ts +9 -67
- package/manifestUtils/__tests__/createConfig.test.js +16 -16
- package/manifestUtils/defaultManifestConfigurations/generalContent.js +13 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +14 -0
- package/manifestUtils/fonts/index.js +5 -6
- package/manifestUtils/sharedConfiguration/screenPicker/__tests__/utils.test.js +304 -0
- package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +875 -0
- package/manifestUtils/sharedConfiguration/screenPicker/utils.js +130 -0
- package/modalState/__tests__/index.test.ts +51 -0
- package/modalState/index.ts +33 -7
- package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +7 -6
- package/navigationUtils/__tests__/itemTypes.test.js +2 -2
- package/navigationUtils/__tests__/navigationUtils.test.js +2 -2
- package/navigationUtils/index.ts +20 -9
- package/numberUtils/__tests__/toPositiveNumberWithDefault.test.ts +23 -3
- package/numberUtils/index.ts +11 -5
- package/package.json +5 -10
- package/playerUtils/configurationGenerator.ts +14 -0
- package/reactHooks/advertising/index.ts +5 -5
- package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
- package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +6 -8
- package/reactHooks/autoscrolling/useTrackedView.ts +12 -1
- package/reactHooks/cell-click/__tests__/index.test.js +10 -2
- package/reactHooks/cell-click/index.ts +7 -1
- package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +4 -4
- package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +10 -11
- package/reactHooks/feed/useFeedLoader.tsx +18 -9
- package/reactHooks/feed/usePipesCacheReset.ts +5 -5
- package/reactHooks/flatList/__tests__/index.test.tsx +30 -21
- package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +39 -0
- package/reactHooks/layout/__tests__/index.test.tsx +10 -10
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +14 -28
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +1 -1
- package/reactHooks/layout/useDimensions/useDimensions.ts +8 -0
- package/reactHooks/navigation/__mocks__/useNavigation.ts +3 -0
- package/reactHooks/navigation/__tests__/index.test.tsx +6 -21
- package/reactHooks/navigation/index.ts +41 -240
- package/reactHooks/navigation/useGetBottomTabBarHeight.ts +12 -0
- package/reactHooks/navigation/useGetNavBarTopBorderWidth.ts +14 -0
- package/reactHooks/navigation/useGetTabBarHeight.ts +10 -0
- package/reactHooks/navigation/useIsScreenActive.ts +17 -0
- package/reactHooks/navigation/useNavigationPluginData.ts +15 -0
- package/reactHooks/navigation/useNavigationType.ts +15 -0
- package/reactHooks/navigation/usePathname.ts +4 -0
- package/reactHooks/navigation/useProfilerLogging.ts +15 -0
- package/reactHooks/navigation/useRoute.ts +98 -0
- package/reactHooks/navigation/useUniqueRouteSuffix.ts +41 -0
- package/reactHooks/player/TVSeekControlller/ISeekController.ts +32 -0
- package/reactHooks/player/TVSeekControlller/LongPressSeekController.ts +71 -0
- package/reactHooks/player/TVSeekControlller/TVSeekController.ts +258 -0
- package/reactHooks/player/TVSeekControlller/TapSeekController.ts +53 -0
- package/reactHooks/player/__tests__/{useAutoSeek.test.tsx → useAutoSeek._test.tsx} +2 -3
- package/reactHooks/player/const.ts +0 -4
- package/reactHooks/player/index.ts +0 -6
- package/reactHooks/state/useRefWithInitialValue.ts +14 -0
- package/reactHooks/state/useStateFromSubscribe.ts +23 -0
- package/reactHooks/useListenEventBusEvent.ts +1 -1
- package/reactHooks/usePluginConfiguration.ts +1 -1
- package/reactHooks/useSubscriberFor.ts +4 -3
- package/reactUtils/__tests__/__snapshots__/reactUtilsHelpers.test.js.snap +16 -4
- package/reactUtils/__tests__/reactUtils.test.js +1 -37
- package/reactUtils/__tests__/reactUtilsHelpers.test.js +72 -71
- package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +13 -79
- package/reactUtils/createContext/__tests__/__snapshots__/{index.test.js.snap → index.test.ts.snap} +2 -2
- package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -28
- package/reactUtils/createContext/__tests__/__snapshots__/withConsumer.test.js.snap +3 -4
- package/reactUtils/createContext/__tests__/__snapshots__/withProvider.test.js.snap +7 -3
- package/reactUtils/createContext/__tests__/helpers.test.js +107 -121
- package/reactUtils/createContext/__tests__/{index.test.js → index.test.ts} +2 -2
- package/reactUtils/createContext/__tests__/provider.test.js +4 -6
- package/reactUtils/createContext/__tests__/withConsumer.test.js +12 -12
- package/reactUtils/createContext/__tests__/withProvider.test.js +4 -4
- package/reactUtils/createContext/helpers.ts +6 -1
- package/reactUtils/createContext/index.ts +11 -25
- package/reactUtils/index.ts +0 -25
- package/screenState/index.ts +24 -10
- package/services/js2native.ts +673 -0
- package/testUtils/index.tsx +0 -10
- package/theme/__mocks__/index.ts +4 -0
- package/theme/index.ts +1 -1
- package/time/BackgroundTimer.ts +55 -0
- package/time/Timer.ts +9 -6
- package/types.ts +1 -0
- package/utils/README.md +30 -0
- package/utils/chunk.ts +5 -0
- package/utils/index.ts +5 -0
- package/utils/times.ts +5 -0
- package/zappFrameworkUtils/localStorageHelper.ts +6 -0
- package/zappFrameworkUtils/loginPluginUtils.ts +6 -2
- package/zappFrameworkUtils/presentPluginOneTime.ts +2 -3
- package/zappFrameworkUtils/types.ts +11 -0
- package/appUtils/keyCodes/keys.ios.js +0 -46
- package/reactHooks/player/useAutoSeek.tsx +0 -87
- package/reactHooks/player/useSeek.tsx +0 -66
- package/reactHooks/player/useTapSeek.tsx +0 -58
- package/reactUtils/createContext/__tests__/index-no-react.test.js +0 -27
- /package/appUtils/HooksManager/{logger.js → logger.ts} +0 -0
- /package/appUtils/{directionHelper.js → directionHelper.ts} +0 -0
- /package/appUtils/keyCodes/{androidTVKeys.js → androidTVKeys.ts} +0 -0
- /package/appUtils/keyCodes/{keys.web.js → keys/keys.web.ts} +0 -0
- /package/domUtils/{logger.js → logger.ts} +0 -0
- /package/reactHooks/player/__tests__/{useTapSeek.test.ts → useTapSeek._test.ts} +0 -0
|
@@ -5,6 +5,7 @@ import { createLogger, utilsLogger } from "../../logger";
|
|
|
5
5
|
import { getBoolFromConfigValue } from "../../configurationUtils";
|
|
6
6
|
import { PlayerRole, SharedPlayerCallBacksKeys } from "./conts";
|
|
7
7
|
import { OverlaysObserver } from "./OverlayObserver/OverlaysObserver";
|
|
8
|
+
import { TVSeekController } from "../../reactHooks/player/TVSeekControlller/TVSeekController";
|
|
8
9
|
|
|
9
10
|
const logger = createLogger({
|
|
10
11
|
category: "PlayerController",
|
|
@@ -49,6 +50,8 @@ export class Player {
|
|
|
49
50
|
[key: string]: QuickBrickPlayer.SharedPlayerCallBacks;
|
|
50
51
|
} = {};
|
|
51
52
|
|
|
53
|
+
public seekController?: TVSeekController | null;
|
|
54
|
+
|
|
52
55
|
get entry(): ZappEntry | null {
|
|
53
56
|
return this._entry;
|
|
54
57
|
}
|
|
@@ -59,6 +62,8 @@ export class Player {
|
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
constructor(props) {
|
|
65
|
+
this.seekController = null;
|
|
66
|
+
|
|
62
67
|
this.playerState = {
|
|
63
68
|
// We want isLive null by default to be able not to show controls if we do not know type
|
|
64
69
|
isLive: null,
|
|
@@ -91,6 +96,8 @@ export class Player {
|
|
|
91
96
|
this.onVideoProgress = this.onVideoProgress.bind(this);
|
|
92
97
|
this.onVideoLoad = this.onVideoLoad.bind(this);
|
|
93
98
|
this.isFullScreenSupported = this.isFullScreenSupported.bind(this);
|
|
99
|
+
this.onPlayerSeekComplete = this.onPlayerSeekComplete.bind(this);
|
|
100
|
+
this.onAdBreakEnd = this.onAdBreakEnd.bind(this);
|
|
94
101
|
this.entryObservable = null;
|
|
95
102
|
}
|
|
96
103
|
|
|
@@ -147,8 +154,8 @@ export class Player {
|
|
|
147
154
|
this.isSeeking()
|
|
148
155
|
? this.playerState.seekPosition
|
|
149
156
|
: this.playerState.adState
|
|
150
|
-
|
|
151
|
-
|
|
157
|
+
? this.playerState.adState.adPosition
|
|
158
|
+
: this.playerState.contentPosition;
|
|
152
159
|
|
|
153
160
|
getEntry = (): ZappEntry | null => this.entry;
|
|
154
161
|
|
|
@@ -194,17 +201,25 @@ export class Player {
|
|
|
194
201
|
adPosition: currentTime,
|
|
195
202
|
};
|
|
196
203
|
} else {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
204
|
+
this.updateContentDuration({ seekableDuration, duration, currentTime });
|
|
205
|
+
}
|
|
206
|
+
};
|
|
200
207
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
208
|
+
protected updateContentDuration = ({
|
|
209
|
+
seekableDuration = null,
|
|
210
|
+
duration = null,
|
|
211
|
+
currentTime = null,
|
|
212
|
+
}) => {
|
|
213
|
+
if (!isEmptyOrNil(seekableDuration) && seekableDuration >= 0) {
|
|
214
|
+
this.playerState.seekableDuration = seekableDuration;
|
|
215
|
+
}
|
|
204
216
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
217
|
+
if (!isEmptyOrNil(duration) && duration >= 0) {
|
|
218
|
+
this.playerState.contentDuration = duration;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (!isEmptyOrNil(currentTime) && currentTime >= 0) {
|
|
222
|
+
this.playerState.contentPosition = currentTime;
|
|
208
223
|
}
|
|
209
224
|
};
|
|
210
225
|
|
|
@@ -321,7 +336,7 @@ export class Player {
|
|
|
321
336
|
* You should use dispatchPlayerEvent at PlayerContainer or call playerManager.invokeHandler directly
|
|
322
337
|
* This allows you to use one method for everything.
|
|
323
338
|
*/
|
|
324
|
-
|
|
339
|
+
onPlayerSeekStart = (event: QuickBrickPlayer.OnSeekStartEvent) => {
|
|
325
340
|
const { isLive, seekableDuration, currentTime, duration, seekTime } = event;
|
|
326
341
|
|
|
327
342
|
this.setPlaybackState({ currentTime, duration, seekableDuration, isLive });
|
|
@@ -336,10 +351,11 @@ export class Player {
|
|
|
336
351
|
});
|
|
337
352
|
};
|
|
338
353
|
|
|
339
|
-
|
|
354
|
+
onPlayerSeekComplete = (event: QuickBrickPlayer.OnSeekCompleteEvent) => {
|
|
340
355
|
const { isLive, seekableDuration, currentTime, duration } = event;
|
|
341
356
|
|
|
342
357
|
this.setPlaybackState({ currentTime, duration, seekableDuration, isLive });
|
|
358
|
+
|
|
343
359
|
this.playerState.seekPosition = null;
|
|
344
360
|
|
|
345
361
|
if (!isLive) {
|
|
@@ -551,7 +567,7 @@ export class Player {
|
|
|
551
567
|
});
|
|
552
568
|
};
|
|
553
569
|
|
|
554
|
-
onAdBreakEnd
|
|
570
|
+
onAdBreakEnd(event) {
|
|
555
571
|
this.playerState.adState = null;
|
|
556
572
|
this.playerState.isInAdBreak = false;
|
|
557
573
|
|
|
@@ -559,7 +575,7 @@ export class Player {
|
|
|
559
575
|
callbackName: SharedPlayerCallBacksKeys.OnAdBreakEnd,
|
|
560
576
|
event,
|
|
561
577
|
});
|
|
562
|
-
}
|
|
578
|
+
}
|
|
563
579
|
|
|
564
580
|
onAdEnd = (event) => {
|
|
565
581
|
this.playerState.adState = null;
|
|
@@ -620,14 +636,18 @@ export class Player {
|
|
|
620
636
|
selectTrack = (_track) => {};
|
|
621
637
|
|
|
622
638
|
protected notifyPlayHeadPositionUpdate = () => {
|
|
639
|
+
const currentTime = this.getPosition();
|
|
640
|
+
|
|
623
641
|
const event = {
|
|
624
|
-
currentTime
|
|
642
|
+
currentTime,
|
|
625
643
|
duration: this.getDuration(),
|
|
626
644
|
item: this.getEntry(),
|
|
627
645
|
seekableDuration: this.playerState.seekableDuration,
|
|
628
646
|
isLive: this.isLive(),
|
|
629
647
|
};
|
|
630
648
|
|
|
649
|
+
this.seekController?.onVideoProgress(currentTime);
|
|
650
|
+
|
|
631
651
|
this.invokeListenersUpdate({
|
|
632
652
|
callbackName: SharedPlayerCallBacksKeys.OnVideoProgress,
|
|
633
653
|
event,
|
|
@@ -653,8 +673,8 @@ export class Player {
|
|
|
653
673
|
};
|
|
654
674
|
|
|
655
675
|
public getListener = (): QuickBrickPlayer.SharedPlayerCallBacks => ({
|
|
656
|
-
onPlayerSeekStart: this.
|
|
657
|
-
onPlayerSeekComplete: this.
|
|
676
|
+
onPlayerSeekStart: this.onPlayerSeekStart,
|
|
677
|
+
onPlayerSeekComplete: this.onPlayerSeekComplete,
|
|
658
678
|
onVideoEnd: this.onVideoEnd,
|
|
659
679
|
onError: this.onError,
|
|
660
680
|
onVideoError: this.onVideoError,
|
|
@@ -724,6 +744,10 @@ export class Player {
|
|
|
724
744
|
return null;
|
|
725
745
|
};
|
|
726
746
|
|
|
747
|
+
public hasResumePosition() {
|
|
748
|
+
return false;
|
|
749
|
+
}
|
|
750
|
+
|
|
727
751
|
public getConfig = () => this.config;
|
|
728
752
|
|
|
729
753
|
// TODO: replace with enum of supported orientations
|
|
@@ -54,11 +54,15 @@ export class PlayerNative extends Player {
|
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
public hasResumePosition() {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
57
61
|
getContentPosition = () => {
|
|
58
62
|
return this.playerState.contentPosition;
|
|
59
63
|
};
|
|
60
64
|
|
|
61
|
-
currentPlayerComponent = (): ReactComponent<
|
|
65
|
+
currentPlayerComponent = (): ReactComponent<PlayerRefProps> =>
|
|
62
66
|
this.playerComponent?.current;
|
|
63
67
|
|
|
64
68
|
getState = () => this.playerState;
|
|
@@ -221,8 +225,11 @@ export class PlayerNative extends Player {
|
|
|
221
225
|
};
|
|
222
226
|
|
|
223
227
|
onVideoLoad = (event) => {
|
|
224
|
-
|
|
228
|
+
this.updateContentDuration(event);
|
|
229
|
+
|
|
230
|
+
if (this.startPosition && !this.playerState.isInAdBreak) {
|
|
225
231
|
super.onVideoLoad({ ...event, ignoreContinueWatching: true });
|
|
232
|
+
|
|
226
233
|
this.seekTo(this.startPosition);
|
|
227
234
|
this.startPosition = null;
|
|
228
235
|
} else {
|
|
@@ -248,6 +255,15 @@ export class PlayerNative extends Player {
|
|
|
248
255
|
}
|
|
249
256
|
};
|
|
250
257
|
|
|
258
|
+
onAdBreakEnd = (event) => {
|
|
259
|
+
super.onAdBreakEnd(event);
|
|
260
|
+
|
|
261
|
+
if (this.startPosition) {
|
|
262
|
+
this.seekTo(this.startPosition);
|
|
263
|
+
this.startPosition = null;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
251
267
|
// This function is called when native player used directly without wrapped component,
|
|
252
268
|
// Since event from native comes with wrapped in NativeEvent property
|
|
253
269
|
getNativeViewListener = (): QuickBrickPlayer.SharedPlayerCallBacks => {
|
|
@@ -39,7 +39,7 @@ export const usePlayerControllerSetup = ({
|
|
|
39
39
|
? { supports_native_controls: true, ...config }
|
|
40
40
|
: config;
|
|
41
41
|
|
|
42
|
-
const
|
|
42
|
+
const combinedProps = {
|
|
43
43
|
player: ref,
|
|
44
44
|
listener: props as any,
|
|
45
45
|
config: newConfig,
|
|
@@ -47,9 +47,9 @@ export const usePlayerControllerSetup = ({
|
|
|
47
47
|
entry,
|
|
48
48
|
playerPluginId: pluginId,
|
|
49
49
|
playerRole: PlayerRole.Primary,
|
|
50
|
-
}
|
|
50
|
+
};
|
|
51
51
|
|
|
52
|
-
setPlayerController(
|
|
52
|
+
setPlayerController(new ControllerType(combinedProps));
|
|
53
53
|
}, [playerId, entry?.id]);
|
|
54
54
|
|
|
55
55
|
React.useEffect(() => {
|
|
@@ -3,12 +3,18 @@ import { OverlaysObserver } from "./OverlayObserver/OverlaysObserver";
|
|
|
3
3
|
import { useFeedLoader } from "../../reactHooks";
|
|
4
4
|
import { usePlayer } from "./usePlayer";
|
|
5
5
|
|
|
6
|
+
const getLiveUrl = (url: string) => {
|
|
7
|
+
// Use the replace method with a regular expression to replace all instances of subClass with livePage
|
|
8
|
+
return url.replace(new RegExp("subClass", "g"), "livePage");
|
|
9
|
+
};
|
|
10
|
+
|
|
6
11
|
export const useTitleSummaryOverlay = (
|
|
7
|
-
feedUrl,
|
|
8
12
|
entry,
|
|
9
13
|
isLive = false,
|
|
10
14
|
interval: number
|
|
11
15
|
) => {
|
|
16
|
+
// TODO: Have generic place for live url from configuration. Currently its hardcoded for client.
|
|
17
|
+
const feedUrl = getLiveUrl(entry?.extensions?.live?.channel_src ?? "");
|
|
12
18
|
const player = usePlayer();
|
|
13
19
|
const [title, setTitle] = useState<string | number>(entry?.title || "");
|
|
14
20
|
const [summary, setSummary] = useState<string | number>(entry?.summary || "");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`shiftArray shifts the n first items from the head to the tail of the array with a positive offset 1`] = `
|
|
4
|
-
|
|
4
|
+
[
|
|
5
5
|
"bar",
|
|
6
6
|
"baz",
|
|
7
7
|
42,
|
|
@@ -10,7 +10,7 @@ Array [
|
|
|
10
10
|
`;
|
|
11
11
|
|
|
12
12
|
exports[`shiftArray shifts the n first items from the head to the tail of the array with a positive offset 2`] = `
|
|
13
|
-
|
|
13
|
+
[
|
|
14
14
|
"baz",
|
|
15
15
|
42,
|
|
16
16
|
"foo",
|
|
@@ -19,7 +19,7 @@ Array [
|
|
|
19
19
|
`;
|
|
20
20
|
|
|
21
21
|
exports[`shiftArray shifts the n last items from the tail to the head of the array with a negative offset 1`] = `
|
|
22
|
-
|
|
22
|
+
[
|
|
23
23
|
42,
|
|
24
24
|
"foo",
|
|
25
25
|
"bar",
|
|
@@ -28,7 +28,7 @@ Array [
|
|
|
28
28
|
`;
|
|
29
29
|
|
|
30
30
|
exports[`shiftArray shifts the n last items from the tail to the head of the array with a negative offset 2`] = `
|
|
31
|
-
|
|
31
|
+
[
|
|
32
32
|
"baz",
|
|
33
33
|
42,
|
|
34
34
|
"foo",
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isFirstComponentGallery } from "../index";
|
|
2
|
+
|
|
3
|
+
describe("isFirstComponentGallery", () => {
|
|
4
|
+
it("should return true if the first component is a gallery", () => {
|
|
5
|
+
const components = [
|
|
6
|
+
{ component_type: "gallery-qb" },
|
|
7
|
+
{ component_type: "other-component" },
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
expect(isFirstComponentGallery(components)).toBe(true);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("should return false if the first component is not a gallery", () => {
|
|
14
|
+
const components = [
|
|
15
|
+
{ component_type: "other-component" },
|
|
16
|
+
{ component_type: "gallery-qb" },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
expect(isFirstComponentGallery(components)).toBe(false);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("should return false if the components array is empty", () => {
|
|
23
|
+
const components = [];
|
|
24
|
+
|
|
25
|
+
expect(isFirstComponentGallery(components)).toBe(false);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should return false if the components array is undefined", () => {
|
|
29
|
+
const components = undefined;
|
|
30
|
+
|
|
31
|
+
expect(isFirstComponentGallery(components)).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isFirstComponentScreenPicker } from "..";
|
|
2
|
+
|
|
3
|
+
describe("isFirstComponentScreenPicker", () => {
|
|
4
|
+
it("should return true if the first component screen-picker", () => {
|
|
5
|
+
const items = [{ component_type: "screen-picker-qb-tv" }];
|
|
6
|
+
expect(isFirstComponentScreenPicker(items)).toBe(true);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("should return false if the first component type is not screen-picker", () => {
|
|
10
|
+
const items = [{ component_type: "other-component" }];
|
|
11
|
+
expect(isFirstComponentScreenPicker(items)).toBe(false);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("should return false if the component type is undefined", () => {
|
|
15
|
+
const items = [{ component_type: undefined }];
|
|
16
|
+
expect(isFirstComponentScreenPicker(items)).toBe(false);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("should return false if the item is null", () => {
|
|
20
|
+
const items = null;
|
|
21
|
+
expect(isFirstComponentScreenPicker(items)).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("should return false if the item is undefined", () => {
|
|
25
|
+
const items = undefined;
|
|
26
|
+
expect(isFirstComponentScreenPicker(items)).toBe(false);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("should return false if the item is an empty object", () => {
|
|
30
|
+
const items = {};
|
|
31
|
+
expect(isFirstComponentScreenPicker(items)).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isGallery } from "..";
|
|
2
|
+
|
|
3
|
+
describe("isGallery", () => {
|
|
4
|
+
it("should return true if the component type is 'gallery-qb'", () => {
|
|
5
|
+
const item = { component_type: "gallery-qb" };
|
|
6
|
+
expect(isGallery(item)).toBe(true);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("should return false if the component type is not 'gallery-qb'", () => {
|
|
10
|
+
const item = { component_type: "other-component" };
|
|
11
|
+
expect(isGallery(item)).toBe(false);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("should return false if the component type is undefined", () => {
|
|
15
|
+
const item = { component_type: undefined };
|
|
16
|
+
expect(isGallery(item)).toBe(false);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("should return false if the item is null", () => {
|
|
20
|
+
const item = null;
|
|
21
|
+
expect(isGallery(item)).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("should return false if the item is undefined", () => {
|
|
25
|
+
const item = undefined;
|
|
26
|
+
expect(isGallery(item)).toBe(false);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("should return false if the item is an empty object", () => {
|
|
30
|
+
const item = {};
|
|
31
|
+
expect(isGallery(item)).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isScreenPicker } from "..";
|
|
2
|
+
|
|
3
|
+
describe("isScreenPicker", () => {
|
|
4
|
+
it("should return true if the component type is 'screen-picker-qb-tv'", () => {
|
|
5
|
+
const item = { component_type: "screen-picker-qb-tv" };
|
|
6
|
+
expect(isScreenPicker(item)).toBe(true);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("should return false if the component type is not 'screen-picker-qb-tv'", () => {
|
|
10
|
+
const item = { component_type: "other-component" };
|
|
11
|
+
expect(isScreenPicker(item)).toBe(false);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("should return false if the component type is undefined", () => {
|
|
15
|
+
const item = { component_type: undefined };
|
|
16
|
+
expect(isScreenPicker(item)).toBe(false);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("should return false if the item is null", () => {
|
|
20
|
+
const item = null;
|
|
21
|
+
expect(isScreenPicker(item)).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("should return false if the item is undefined", () => {
|
|
25
|
+
const item = undefined;
|
|
26
|
+
expect(isScreenPicker(item)).toBe(false);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("should return false if the item is an empty object", () => {
|
|
30
|
+
const item = {};
|
|
31
|
+
expect(isScreenPicker(item)).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const GROUP = "group-qb";
|
|
2
|
+
const GROUP_INFO = "group-info-qb";
|
|
3
|
+
const EMPTY_GROUP_COMPONENT = "empty_group_component";
|
|
4
|
+
|
|
5
|
+
const GALLERY = "gallery-qb";
|
|
6
|
+
|
|
7
|
+
const SCREEN_PICKER = "screen-picker-qb-tv";
|
|
8
|
+
|
|
9
|
+
export const isGallery = (item): boolean => item?.component_type === GALLERY;
|
|
10
|
+
|
|
11
|
+
export const isScreenPicker = (item): boolean =>
|
|
12
|
+
item?.component_type === SCREEN_PICKER;
|
|
13
|
+
|
|
14
|
+
export const isFirstComponentScreenPicker = (
|
|
15
|
+
components: ZappUIComponent[]
|
|
16
|
+
): boolean => {
|
|
17
|
+
return isScreenPicker(components?.[0]);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const isFirstComponentGallery = (
|
|
21
|
+
components: ZappUIComponent[]
|
|
22
|
+
): boolean => {
|
|
23
|
+
return isGallery(components?.[0]);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const isGroup = (item): boolean => item?.component_type === GROUP;
|
|
27
|
+
|
|
28
|
+
export const isEmptyGroup = (item): boolean =>
|
|
29
|
+
item?.component_type === EMPTY_GROUP_COMPONENT;
|
|
30
|
+
|
|
31
|
+
export const isGroupInfo = (item): boolean =>
|
|
32
|
+
item?.component_type === GROUP_INFO;
|
package/dateUtils/index.ts
CHANGED
|
@@ -2,10 +2,29 @@ import dayjs from "dayjs";
|
|
|
2
2
|
import utc from "dayjs/plugin/utc";
|
|
3
3
|
import timezone from "dayjs/plugin/timezone";
|
|
4
4
|
import isoWeek from "dayjs/plugin/isoWeek";
|
|
5
|
+
import duration from "dayjs/plugin/duration";
|
|
6
|
+
import relativeTime from "dayjs/plugin/relativeTime";
|
|
5
7
|
|
|
6
8
|
// Extend dayjs with plugins
|
|
7
9
|
dayjs.extend(utc);
|
|
8
10
|
dayjs.extend(timezone);
|
|
9
11
|
dayjs.extend(isoWeek);
|
|
12
|
+
dayjs.extend(duration);
|
|
13
|
+
|
|
14
|
+
dayjs.extend(relativeTime, {
|
|
15
|
+
thresholds: [
|
|
16
|
+
{ l: "s", r: 1 },
|
|
17
|
+
{ l: "m", r: 1 },
|
|
18
|
+
{ l: "mm", r: 59, d: "minute" },
|
|
19
|
+
{ l: "h", r: 1 },
|
|
20
|
+
{ l: "hh", r: 23, d: "hour" },
|
|
21
|
+
{ l: "d", r: 1 },
|
|
22
|
+
{ l: "dd", r: 29, d: "day" },
|
|
23
|
+
{ l: "M", r: 1 },
|
|
24
|
+
{ l: "MM", r: 11, d: "month" },
|
|
25
|
+
{ l: "y", r: 1 },
|
|
26
|
+
{ l: "yy", d: "year" },
|
|
27
|
+
],
|
|
28
|
+
});
|
|
10
29
|
|
|
11
30
|
export { dayjs };
|
|
@@ -2,7 +2,6 @@ import { domUtilsLogger } from "./logger";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Gets an object of cookies and sets them on the DOM.
|
|
5
|
-
* @param {Object} cookies selected data key for label.
|
|
6
5
|
*/
|
|
7
6
|
export function setCookies(cookies): void {
|
|
8
7
|
const cookieKeys = Object.keys(cookies);
|
|
@@ -25,7 +24,7 @@ export function setCookies(cookies): void {
|
|
|
25
24
|
/**
|
|
26
25
|
* Gets cookies set on DOM
|
|
27
26
|
*/
|
|
28
|
-
export function getCookies():
|
|
27
|
+
export function getCookies(): typeof document.cookie {
|
|
29
28
|
try {
|
|
30
29
|
if (document) {
|
|
31
30
|
return document.cookie;
|