@applicaster/zapp-react-native-utils 13.0.0-alpha.7120331332 → 13.0.0-alpha.7122212380

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.
Files changed (47) hide show
  1. package/actionsExecutor/ActionExecutor.ts +16 -9
  2. package/actionsExecutor/ActionExecutorContext.tsx +59 -8
  3. package/alertUtils/alert.ts +148 -0
  4. package/alertUtils/index.ts +1 -148
  5. package/analyticsUtils/AnalyticPlayerListener.ts +18 -1
  6. package/appUtils/HooksManager/Hook.ts +2 -2
  7. package/appUtils/HooksManager/types.ts +5 -2
  8. package/appUtils/accessibilityManager/index.ts +42 -1
  9. package/appUtils/contextKeysManager/contextResolver.ts +77 -0
  10. package/appUtils/focusManager/index.ts +91 -65
  11. package/appUtils/focusManager/treeDataStructure/Tree/index.js +23 -0
  12. package/appUtils/focusManager/utils/enums.ts +4 -0
  13. package/appUtils/focusManagerAux/utils/index.ts +4 -3
  14. package/appUtils/keyCodes/keys/keysByPlatform.ts +4 -0
  15. package/appUtils/keyInputHandler/KeyInputHandler.ts +68 -0
  16. package/appUtils/platform/const.ts +14 -0
  17. package/appUtils/platform/platformUtils.ts +17 -1
  18. package/appUtils/playerManager/player.ts +19 -7
  19. package/appUtils/playerManager/playerNative.ts +2 -1
  20. package/appUtils/playerManager/usePlayerControllerSetup.tsx +3 -3
  21. package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
  22. package/idleUtils/index.ts +1 -1
  23. package/idleUtils/withTimeout.ts +15 -2
  24. package/logger/const.ts +9 -67
  25. package/navigationUtils/index.ts +3 -3
  26. package/package.json +3 -2
  27. package/reactHooks/cell-click/__tests__/index.test.js +5 -0
  28. package/reactHooks/cell-click/index.ts +7 -1
  29. package/reactHooks/feed/useFeedLoader.tsx +1 -1
  30. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +1 -1
  31. package/reactHooks/player/TVSeekControlller/ISeekController.ts +32 -0
  32. package/reactHooks/player/TVSeekControlller/LongPressSeekController.ts +71 -0
  33. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +258 -0
  34. package/reactHooks/player/TVSeekControlller/TapSeekController.ts +53 -0
  35. package/reactHooks/player/const.ts +0 -4
  36. package/reactHooks/player/index.ts +0 -6
  37. package/reactHooks/usePluginConfiguration.ts +1 -1
  38. package/reactHooks/useSubscriberFor.ts +4 -3
  39. package/theme/index.ts +1 -1
  40. package/time/Timer.ts +5 -2
  41. package/types.ts +1 -0
  42. package/zappFrameworkUtils/presentPluginOneTime.ts +2 -3
  43. package/reactHooks/player/useAutoSeek.tsx +0 -87
  44. package/reactHooks/player/useSeek.tsx +0 -66
  45. package/reactHooks/player/useTapSeek.tsx +0 -58
  46. /package/reactHooks/player/__tests__/{useAutoSeek.test.tsx → useAutoSeek._test.tsx} +0 -0
  47. /package/reactHooks/player/__tests__/{useTapSeek.test.ts → useTapSeek._test.ts} +0 -0
package/types.ts CHANGED
@@ -8,4 +8,5 @@ export type ManifestField<T> = {
8
8
 
9
9
  export enum ENDPOINT_TAGS {
10
10
  allow_missing_keys = "allow_missing_keys",
11
+ observe_storage = "observe_storage",
11
12
  }
@@ -92,9 +92,8 @@ export const PresentHookPluginOneTime = (
92
92
  const presentOneTimeVersionName =
93
93
  await getLatestWatchedVersionNumberFromStorage(storageKey, namespace);
94
94
 
95
- const applicationVersionName = await sessionStorage.getItem(
96
- versionNameKey
97
- );
95
+ const applicationVersionName =
96
+ await sessionStorage.getItem(versionNameKey);
98
97
 
99
98
  if (!presentOneTimeVersionName || !applicationVersionName) {
100
99
  log_info(
@@ -1,87 +0,0 @@
1
- import React, { useEffect, useState } from "react";
2
- import { usePrevious } from "@applicaster/zapp-react-native-utils/reactHooks/utils";
3
- import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils/playerManager";
4
- import {
5
- MAX_SEEK_TIME,
6
- ON_HOLD_INTERVAL,
7
- SEEK_TYPE,
8
- SKIP_TIME_BASE,
9
- } from "./const";
10
- import { noop } from "../../functionUtils";
11
-
12
- export const useAutoSeek = (resetHUDTimer = noop) => {
13
- const [isRunning, setIsRunning] = useState<boolean>(false);
14
- const [direction, setDirection] = useState<Nullable<SEEK_TYPE>>(null);
15
- const [multiplier, setMultiplier] = useState(1);
16
- const intervalTimer = React.useRef(null);
17
- const prevRunning = usePrevious(isRunning);
18
-
19
- const clearIntervalTimer = () => {
20
- try {
21
- clearInterval(intervalTimer.current);
22
- } catch (err) {
23
- intervalTimer.current = null;
24
- }
25
- };
26
-
27
- const setIntervalTimer = (cb) => {
28
- clearIntervalTimer();
29
- intervalTimer.current = setInterval(cb, ON_HOLD_INTERVAL);
30
- };
31
-
32
- const resetState = () => {
33
- setIsRunning(false);
34
- setDirection(null);
35
- setMultiplier(1);
36
- clearIntervalTimer();
37
- };
38
-
39
- useEffect(() => {
40
- const player = playerManager.getInstanceController();
41
-
42
- if (!player) return;
43
-
44
- if (direction) {
45
- player[direction](Math.min(MAX_SEEK_TIME, SKIP_TIME_BASE * multiplier));
46
- resetHUDTimer();
47
- }
48
- }, [multiplier, direction]);
49
-
50
- useEffect(() => {
51
- if (isRunning && isRunning !== prevRunning) {
52
- setIntervalTimer(() => {
53
- setMultiplier((prev) => {
54
- return prev + 1;
55
- });
56
- });
57
- } else if (!isRunning && isRunning !== prevRunning) {
58
- resetState();
59
- }
60
-
61
- return () => {
62
- clearIntervalTimer();
63
- };
64
- }, [isRunning, direction]);
65
-
66
- const autoSeekStop = React.useCallback(() => {
67
- resetState();
68
- }, []);
69
-
70
- const autoSeekStart = React.useCallback(
71
- (eventType: SEEK_TYPE) => {
72
- // Check if there is another session running
73
- if (isRunning) {
74
- autoSeekStop();
75
- }
76
-
77
- setDirection(eventType);
78
- setIsRunning(true);
79
- },
80
- [isRunning]
81
- );
82
-
83
- return React.useMemo(
84
- () => ({ autoSeekStart, autoSeekStop }),
85
- [autoSeekStart, autoSeekStop]
86
- );
87
- };
@@ -1,66 +0,0 @@
1
- import React from "react";
2
- import { SEEK_TYPE } from "./const";
3
- import { useTapSeek } from "./useTapSeek";
4
- import { useAutoSeek } from "./useAutoSeek";
5
- import { noop } from "../../functionUtils";
6
-
7
- export const useSeek = (resetHUDTimer = noop) => {
8
- const handlePressEvent = useTapSeek();
9
- const { autoSeekStart, autoSeekStop } = useAutoSeek(resetHUDTimer);
10
-
11
- const onForwardPress = () => {
12
- handlePressEvent(SEEK_TYPE.FORWARD);
13
- };
14
-
15
- const onRewindPress = () => {
16
- handlePressEvent(SEEK_TYPE.REWIND);
17
- };
18
-
19
- const onForwardPressIn = () => {
20
- autoSeekStart(SEEK_TYPE.FORWARD);
21
- };
22
-
23
- const onForwardPressOut = () => {
24
- autoSeekStop();
25
- };
26
-
27
- const onRewindPressIn = () => {
28
- autoSeekStart(SEEK_TYPE.REWIND);
29
- };
30
-
31
- const onRewindLongPress = () => {
32
- autoSeekStart(SEEK_TYPE.REWIND);
33
- };
34
-
35
- const onForwardLongPress = () => {
36
- autoSeekStart(SEEK_TYPE.FORWARD);
37
- };
38
-
39
- const onRewindPressOut = () => {
40
- autoSeekStop();
41
- };
42
-
43
- return React.useMemo(
44
- () => ({
45
- onForwardPress,
46
- onRewindPress,
47
- onForwardPressIn,
48
- onForwardPressOut,
49
- onRewindPressIn,
50
- onRewindPressOut,
51
- onRewindLongPress,
52
- onForwardLongPress,
53
- }),
54
- [handlePressEvent, autoSeekStart]
55
- );
56
- };
57
-
58
- export const withUseSeek = (Component) =>
59
- Object.assign(
60
- (props) => {
61
- const seekMethods = useSeek(props?.resetHUDTimer);
62
-
63
- return <Component {...props} seekMethods={seekMethods} />;
64
- },
65
- { displayName: "WithUseSeek" }
66
- );
@@ -1,58 +0,0 @@
1
- import { useCallback, useRef } from "react";
2
- import * as R from "ramda";
3
- import {
4
- MAX_SEEK_TIME,
5
- ON_PRESS_RESET_DURATION,
6
- SEEK_TYPE,
7
- SKIP_TIME_BASE,
8
- } from "./const";
9
- import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
10
-
11
- type SeekType = SEEK_TYPE | null;
12
-
13
- const getSkipTime = (multiplier) => {
14
- const skipTime = R.min(MAX_SEEK_TIME, SKIP_TIME_BASE * multiplier);
15
-
16
- return skipTime;
17
- };
18
-
19
- export const useTapSeek = () => {
20
- const onPressMultiplier = useRef(1);
21
- const lastPressTime = useRef(0);
22
- const currentOnPressEventType = useRef<SeekType>(null);
23
-
24
- const resetMultiplier = useCallback(() => {
25
- onPressMultiplier.current = 1;
26
- }, []);
27
-
28
- const handlePressEvent = useCallback(
29
- (eventType) => {
30
- const player = playerManager.getInstanceController();
31
- if (!player) return;
32
-
33
- const now = Date.now();
34
- const timeSinceLastPress = now - lastPressTime.current;
35
- const isSameEventType = eventType === currentOnPressEventType.current;
36
-
37
- const isWithinResetDuration =
38
- timeSinceLastPress <= ON_PRESS_RESET_DURATION;
39
-
40
- const shouldIncreaseMultiplier = isSameEventType && isWithinResetDuration;
41
-
42
- if (shouldIncreaseMultiplier) {
43
- onPressMultiplier.current += 1;
44
- } else {
45
- resetMultiplier();
46
- }
47
-
48
- const seekTime = getSkipTime(onPressMultiplier.current);
49
- player[eventType](seekTime);
50
-
51
- lastPressTime.current = now;
52
- currentOnPressEventType.current = eventType;
53
- },
54
- [resetMultiplier]
55
- );
56
-
57
- return handlePressEvent;
58
- };