@applicaster/zapp-react-native-utils 13.0.0-alpha.7138263059 → 13.0.0-alpha.7193146510

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 (65) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +126 -6
  2. package/actionsExecutor/consts.ts +4 -0
  3. package/appUtils/HooksManager/Hook.ts +4 -0
  4. package/appUtils/HooksManager/index.ts +2 -0
  5. package/appUtils/__tests__/__snapshots__/localizationsHelper.test.ts.snap +151 -0
  6. package/appUtils/__tests__/allZappLocales.ts +79 -0
  7. package/appUtils/__tests__/{localizationsHelper.test.js → localizationsHelper.test.ts} +11 -0
  8. package/appUtils/contextKeysManager/contextResolver.ts +18 -12
  9. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +2 -0
  10. package/appUtils/focusManager/index.ios.ts +14 -4
  11. package/appUtils/focusManager/index.ts +14 -10
  12. package/appUtils/focusManager/utils/__tests__/findChild.test.ts +35 -0
  13. package/appUtils/focusManager/utils/index.ts +5 -0
  14. package/appUtils/localizationsHelper.ts +31 -0
  15. package/appUtils/orientationHelper.ts +11 -13
  16. package/appUtils/playerManager/player.ts +24 -12
  17. package/appUtils/playerManager/playerHooks/usePlayerCurrentTime.tsx +11 -7
  18. package/appUtils/playerManager/playerNative.ts +18 -3
  19. package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +7 -1
  20. package/cellUtils/index.ts +9 -5
  21. package/componentsUtils/__tests__/isFirstComponentGallery.test.ts +33 -0
  22. package/componentsUtils/__tests__/isFirstComponentScreenPicker.test.ts +33 -0
  23. package/componentsUtils/__tests__/isGallery.test.ts +33 -0
  24. package/componentsUtils/__tests__/isScreenPicker.test.ts +33 -0
  25. package/componentsUtils/index.ts +39 -0
  26. package/dateUtils/index.ts +19 -0
  27. package/focusManager/FocusManager.ts +3 -1
  28. package/focusManager/index.ts +3 -21
  29. package/functionUtils/index.ts +25 -0
  30. package/index.d.ts +0 -12
  31. package/localizationUtils/index.ts +8 -13
  32. package/manifestUtils/defaultManifestConfigurations/generalContent.js +13 -0
  33. package/manifestUtils/defaultManifestConfigurations/player.js +9 -3
  34. package/manifestUtils/fonts/index.js +5 -6
  35. package/manifestUtils/keys.js +27 -2
  36. package/modalState/__tests__/index.test.ts +51 -0
  37. package/modalState/index.ts +32 -2
  38. package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +1 -0
  39. package/navigationUtils/index.ts +3 -1
  40. package/numberUtils/__tests__/toPositiveNumberWithDefault.test.ts +23 -3
  41. package/numberUtils/index.ts +4 -0
  42. package/package.json +2 -6
  43. package/playerUtils/configurationGenerator.ts +9 -11
  44. package/reactHooks/advertising/index.ts +5 -5
  45. package/reactHooks/feed/useBatchLoading.ts +10 -12
  46. package/reactHooks/feed/useFeedLoader.tsx +17 -8
  47. package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +39 -0
  48. package/reactHooks/navigation/__tests__/index.test.tsx +6 -17
  49. package/reactHooks/navigation/index.ts +6 -4
  50. package/reactHooks/navigation/useGetBottomTabBarHeight.ts +14 -2
  51. package/reactHooks/navigation/useRoute.ts +4 -6
  52. package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +69 -0
  53. package/reactHooks/screen/useScreenBackgroundColor.ts +3 -15
  54. package/reactHooks/useListenEventBusEvent.ts +1 -1
  55. package/reactUtils/index.ts +9 -0
  56. package/services/js2native.ts +673 -0
  57. package/time/BackgroundTimer.ts +55 -0
  58. package/time/Timer.ts +6 -6
  59. package/utils/README.md +30 -0
  60. package/utils/chunk.ts +5 -0
  61. package/utils/index.ts +5 -0
  62. package/utils/times.ts +5 -0
  63. package/zappFrameworkUtils/localStorageHelper.ts +6 -0
  64. package/zappFrameworkUtils/loginPluginUtils.ts +6 -2
  65. package/zappFrameworkUtils/types.ts +11 -0
@@ -1,12 +1,24 @@
1
1
  import { useGetNavBarTopBorderWidth } from "./useGetNavBarTopBorderWidth";
2
2
  import { useGetTabBarHeight } from "./useGetTabBarHeight";
3
- import { MenuTypes, useNavigationType } from "./useNavigationType";
3
+ import { useNavigation } from "./useNavigation";
4
+ import { MenuTypes } from "./useNavigationType";
4
5
 
5
6
  export const useGetBottomTabBarHeight = (): number => {
7
+ const { activeRiver } = useNavigation();
8
+
9
+ const navigations = activeRiver?.targetScreen
10
+ ? (activeRiver.targetScreen as ZappRiver).navigations
11
+ : (activeRiver as ZappRiver).navigations;
12
+
13
+ const navigationMenu = navigations?.find(
14
+ ({ category }) => category === "menu"
15
+ );
16
+
6
17
  const topBorderWidth = useGetNavBarTopBorderWidth();
7
18
  const tabBarHeight = useGetTabBarHeight();
8
19
 
9
- const isBottomBarNavigation = useNavigationType() === MenuTypes.bottomTabBar;
20
+ const isBottomBarNavigation =
21
+ navigationMenu.navigation_type === MenuTypes.bottomTabBar;
10
22
 
11
23
  return !isBottomBarNavigation ? 0 : tabBarHeight + topBorderWidth;
12
24
  };
@@ -7,12 +7,11 @@ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
7
7
 
8
8
  import { legacyScreenData } from "@applicaster/quick-brick-core/App/NavigationProvider/utils";
9
9
 
10
- import { useZappHooksModalState } from "@applicaster/zapp-react-dom-ui-components/Components/ZappHooksModal/hooks/useZappHooksModalState";
11
-
12
10
  import { getTargetScreenData } from "../screen/useTargetScreenData";
11
+ import { useHookModalScreenData } from "../hookModal/hooks/useHookModalScreenData";
13
12
 
14
13
  import { useNavigation } from "./useNavigation";
15
- import { useModalStore } from "../../modalState";
14
+ import { useModalStoreState } from "../../modalState";
16
15
  import { ScreenDataContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
17
16
  import { usePathname } from "./usePathname";
18
17
 
@@ -44,12 +43,11 @@ export const useRoute = (): {
44
43
  "contentTypes",
45
44
  ]);
46
45
 
47
- const { modalState } = useModalStore();
48
- const hookModalState = useZappHooksModalState();
46
+ const modalState = useModalStoreState();
49
47
 
50
48
  const modalScreenData = modalState.screen;
51
49
 
52
- const hookModalScreenData = hookModalState.state.screenData?.payload;
50
+ const hookModalScreenData = useHookModalScreenData();
53
51
 
54
52
  const videoModalScreenData =
55
53
  navigator?.videoModalState?.item &&
@@ -0,0 +1,69 @@
1
+ import { renderHook } from "@testing-library/react-hooks";
2
+
3
+ jest.mock(
4
+ "@applicaster/zapp-react-native-ui-components/Components/River/useScreenConfiguration",
5
+ () => ({
6
+ useScreenConfiguration: jest.fn(),
7
+ })
8
+ );
9
+
10
+ const {
11
+ useScreenConfiguration,
12
+ } = require("@applicaster/zapp-react-native-ui-components/Components/River/useScreenConfiguration");
13
+
14
+ const { useScreenBackgroundColor } = require("../useScreenBackgroundColor");
15
+
16
+ describe("useScreenBackgroundColor", () => {
17
+ afterEach(() => {
18
+ jest.clearAllMocks();
19
+ });
20
+
21
+ it("should return the background color from screen configuration", () => {
22
+ useScreenConfiguration.mockReturnValue({
23
+ backgroundColor: "#FF0000",
24
+ });
25
+
26
+ // Render the hook with a screen ID
27
+ const { result } = renderHook(() =>
28
+ useScreenBackgroundColor("test-screen-id")
29
+ );
30
+
31
+ expect(result.current).toBe("#FF0000");
32
+
33
+ expect(useScreenConfiguration).toHaveBeenCalledWith("test-screen-id");
34
+ });
35
+
36
+ it("should return 'transparent' when background color is empty", () => {
37
+ useScreenConfiguration.mockReturnValue({
38
+ backgroundColor: "",
39
+ });
40
+
41
+ const { result } = renderHook(() =>
42
+ useScreenBackgroundColor("test-screen-id")
43
+ );
44
+
45
+ expect(result.current).toBe("transparent");
46
+ });
47
+
48
+ it("should return 'transparent' when background color is null", () => {
49
+ useScreenConfiguration.mockReturnValue({
50
+ backgroundColor: null,
51
+ });
52
+
53
+ const { result } = renderHook(() =>
54
+ useScreenBackgroundColor("test-screen-id")
55
+ );
56
+
57
+ expect(result.current).toBe("transparent");
58
+ });
59
+
60
+ it("should return 'transparent' when background color is undefined", () => {
61
+ useScreenConfiguration.mockReturnValue({});
62
+
63
+ const { result } = renderHook(() =>
64
+ useScreenBackgroundColor("test-screen-id")
65
+ );
66
+
67
+ expect(result.current).toBe("transparent");
68
+ });
69
+ });
@@ -1,23 +1,11 @@
1
- import * as React from "react";
2
- import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
3
1
  import { useScreenConfiguration } from "@applicaster/zapp-react-native-ui-components/Components/River/useScreenConfiguration";
4
2
  import { ifEmptyUseFallback } from "@applicaster/zapp-react-native-utils/cellUtils";
5
3
 
4
+ const DEFAULT_BACKGROUND_FALLBACK = "transparent";
5
+
6
6
  export const useScreenBackgroundColor = (screenId: string): string => {
7
7
  const { backgroundColor: screenBackgroundColor } =
8
8
  useScreenConfiguration(screenId);
9
9
 
10
- const theme = useTheme();
11
-
12
- const themeBackgroundColor = React.useMemo(
13
- () => theme.app_background_color,
14
- [theme.app_background_color]
15
- );
16
-
17
- const backgroundColor = ifEmptyUseFallback(
18
- screenBackgroundColor,
19
- themeBackgroundColor
20
- );
21
-
22
- return backgroundColor;
10
+ return ifEmptyUseFallback(screenBackgroundColor, DEFAULT_BACKGROUND_FALLBACK);
23
11
  };
@@ -23,5 +23,5 @@ export const useListenEventBusEvent = (
23
23
  sub.remove(); // stop listening to DeviceEventEmitter
24
24
  };
25
25
  }
26
- }, []);
26
+ }, [handler, subscriptionID, source, events]);
27
27
  };
@@ -187,3 +187,12 @@ export const hasVizioAPIs = () => {
187
187
 
188
188
  return hasAPIs;
189
189
  };
190
+
191
+ /**
192
+ * Checks if the Android version is at least the expected version
193
+ * @param expectedVersion The version to compare against
194
+ * @returns True if the current Android version is at least the expected version, false otherwise
195
+ */
196
+ export const isAndroidVersionAtLeast = (expectedVersion: number) => {
197
+ return parseFloat(Platform.Version.toString()) >= expectedVersion;
198
+ };