@applicaster/zapp-react-native-utils 15.0.0-rc.99 → 15.1.0-alpha.1852552014

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 (170) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +51 -5
  2. package/actionsExecutor/feedDecorator.ts +6 -6
  3. package/adsUtils/index.ts +2 -2
  4. package/analyticsUtils/AnalyticsEvents/sendMenuClickEvent.ts +2 -2
  5. package/analyticsUtils/PlayerAnalyticsManager.ts +11 -1
  6. package/analyticsUtils/README.md +1 -1
  7. package/analyticsUtils/__tests__/analyticsMapper.test.ts +35 -0
  8. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testACP_events.json +1 -1
  9. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testBlockUnlistedParams_rules.json +1 -1
  10. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEmptyRenameKeepsName_events.json +4 -0
  11. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEmptyRenameKeepsName_rules.json +6 -0
  12. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEventRegex_events.json +3 -9
  13. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testIgnoreOrdering_events.json +18 -0
  14. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testIgnoreOrdering_rules.json +16 -0
  15. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexEventNoFallback_events.json +4 -0
  16. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexEventNoFallback_rules.json +6 -0
  17. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexMultiGroupRename_events.json +4 -0
  18. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexMultiGroupRename_rules.json +6 -0
  19. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexNonNamedFullMatch_events.json +4 -0
  20. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexNonNamedFullMatch_rules.json +6 -0
  21. package/analyticsUtils/__tests__/fixtures/index.js +20 -0
  22. package/analyticsUtils/analyticsMapper.ts +4 -1
  23. package/analyticsUtils/playerAnalyticsTracker.ts +26 -3
  24. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +188 -0
  25. package/appUtils/HooksManager/__tests__/hooksManager.test.js +2 -16
  26. package/appUtils/HooksManager/index.ts +47 -17
  27. package/appUtils/RiverFocusManager/{index.ts → index.js} +18 -25
  28. package/appUtils/accessibilityManager/const.ts +0 -4
  29. package/appUtils/accessibilityManager/utils.ts +1 -0
  30. package/appUtils/contextKeysManager/__tests__/getKeys/failure.test.ts +2 -7
  31. package/appUtils/contextKeysManager/__tests__/getKeys/success.test.ts +0 -48
  32. package/appUtils/contextKeysManager/contextResolver.ts +22 -51
  33. package/appUtils/contextKeysManager/index.ts +10 -65
  34. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +0 -3
  35. package/appUtils/focusManager/index.ios.ts +4 -43
  36. package/appUtils/focusManagerAux/utils/index.ts +3 -5
  37. package/appUtils/focusManagerAux/utils/utils.ios.ts +3 -199
  38. package/appUtils/keyCodes/keys/keys.web.ts +4 -1
  39. package/appUtils/localizationsHelper.ts +4 -0
  40. package/appUtils/orientationHelper.ts +4 -2
  41. package/appUtils/platform/platformUtils.ts +1 -1
  42. package/appUtils/playerManager/__tests__/playerFactory.test.ts +150 -0
  43. package/appUtils/playerManager/index.ts +9 -0
  44. package/appUtils/playerManager/player.ts +1 -5
  45. package/appUtils/playerManager/playerFactory.ts +17 -34
  46. package/appUtils/playerManager/playerNative.ts +22 -30
  47. package/appUtils/playerManager/usePlayer.tsx +5 -3
  48. package/appUtils/playerManager/usePlayerState.tsx +2 -14
  49. package/cellUtils/__tests__/cellUtils.test.ts +39 -0
  50. package/cellUtils/index.ts +14 -6
  51. package/cloudEventsUtils/index.ts +1 -65
  52. package/colorUtils/__tests__/isTransparentColor.test.ts +76 -0
  53. package/colorUtils/__tests__/isValidColor.test.ts +70 -0
  54. package/colorUtils/index.ts +50 -0
  55. package/configurationUtils/__tests__/manifestKeyParser.test.ts +26 -26
  56. package/dateUtils/__tests__/dayjs.test.ts +0 -3
  57. package/dateUtils/index.ts +2 -0
  58. package/focusManager/aux/index.ts +1 -1
  59. package/headersUtils/__tests__/headersUtils.test.js +1 -11
  60. package/headersUtils/index.ts +1 -2
  61. package/manifestUtils/defaultManifestConfigurations/player.js +7 -75
  62. package/manifestUtils/keys.js +1 -0
  63. package/manifestUtils/platformIsTV.js +1 -0
  64. package/manifestUtils/tvAction/container/index.js +1 -1
  65. package/numberUtils/__tests__/toNumber.test.ts +0 -12
  66. package/numberUtils/index.ts +1 -19
  67. package/package.json +4 -4
  68. package/pipesUtils/__tests__/buildUrlWithQuery.test.ts +33 -0
  69. package/pipesUtils/__tests__/withPipesEndpoint.test.tsx +56 -0
  70. package/pipesUtils/index.ts +1 -0
  71. package/pipesUtils/withPipesEndpoint.tsx +54 -0
  72. package/playerUtils/index.ts +24 -2
  73. package/pluginUtils/index.ts +4 -9
  74. package/reactHooks/advertising/index.ts +2 -2
  75. package/reactHooks/app/__tests__/useAppState.test.ts +1 -1
  76. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  77. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +2 -1
  78. package/reactHooks/casting/index.ts +1 -0
  79. package/reactHooks/casting/useIsCasting.tsx +57 -0
  80. package/reactHooks/cell-click/__tests__/index.test.js +3 -1
  81. package/reactHooks/componentsMap/index.ts +55 -0
  82. package/reactHooks/configuration/__tests__/index.test.tsx +1 -1
  83. package/reactHooks/connection/__tests__/index.test.js +1 -1
  84. package/reactHooks/debugging/__tests__/index.test.js +4 -4
  85. package/reactHooks/device/useIsTablet.tsx +19 -14
  86. package/reactHooks/device/useMemoizedIsTablet.ts +3 -3
  87. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +23 -32
  88. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +19 -19
  89. package/reactHooks/feed/__tests__/useEntryScreenId.test.tsx +1 -4
  90. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +30 -42
  91. package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +1 -1
  92. package/reactHooks/feed/__tests__/useInflatedUrl.test.tsx +1 -1
  93. package/reactHooks/feed/useBatchLoading.ts +1 -7
  94. package/reactHooks/feed/useEntryScreenId.ts +2 -2
  95. package/reactHooks/feed/useInflatedUrl.ts +1 -1
  96. package/reactHooks/feed/usePipesCacheReset.ts +1 -3
  97. package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +16 -13
  98. package/reactHooks/layout/__tests__/index.test.tsx +1 -1
  99. package/reactHooks/layout/__tests__/useLayoutVersion.test.tsx +1 -1
  100. package/reactHooks/layout/useDimensions/__tests__/{useDimensions.test.tsx → useDimensions.test.ts} +25 -105
  101. package/reactHooks/layout/useDimensions/useDimensions.ts +2 -2
  102. package/reactHooks/navigation/__tests__/index.test.tsx +4 -2
  103. package/reactHooks/navigation/index.ts +6 -7
  104. package/reactHooks/navigation/useRoute.ts +6 -8
  105. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +10 -27
  106. package/reactHooks/player/__tests__/useAutoSeek._test.tsx +1 -1
  107. package/reactHooks/player/__tests__/useTapSeek._test.ts +1 -1
  108. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +1 -1
  109. package/reactHooks/resolvers/__tests__/useComponentResolver.test.tsx +1 -1
  110. package/reactHooks/resolvers/useCellResolver.ts +2 -6
  111. package/reactHooks/resolvers/useComponentResolver.ts +13 -9
  112. package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +2 -2
  113. package/reactHooks/screen/__tests__/useCurrentScreenIsHook.test.ts +103 -0
  114. package/reactHooks/screen/__tests__/useCurrentScreenIsStartupHook.test.ts +94 -0
  115. package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +1 -1
  116. package/reactHooks/screen/__tests__/useScreenData.test.tsx +1 -1
  117. package/reactHooks/screen/__tests__/useTargetScreenData.test.tsx +4 -12
  118. package/reactHooks/screen/index.ts +6 -0
  119. package/reactHooks/screen/useCurrentScreenIsHook.ts +9 -0
  120. package/reactHooks/screen/useCurrentScreenIsStartupHook.ts +8 -0
  121. package/reactHooks/screen/useIsStandaloneFullscreen.ts +12 -0
  122. package/reactHooks/screen/useTargetScreenData.ts +2 -4
  123. package/reactHooks/state/__tests__/useComponentScreenState.test.ts +246 -0
  124. package/reactHooks/state/index.ts +2 -0
  125. package/reactHooks/state/useComponentScreenState.ts +45 -0
  126. package/reactHooks/state/useRivers.ts +1 -1
  127. package/reactHooks/usePluginConfiguration.ts +2 -2
  128. package/reactHooks/utils/__tests__/index.test.js +1 -1
  129. package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +22 -4
  130. package/rectUtils/index.ts +2 -2
  131. package/riverComponetsMeasurementProvider/index.tsx +12 -8
  132. package/screenPickerUtils/index.ts +5 -0
  133. package/screenState/__tests__/index.test.ts +1 -1
  134. package/stringUtils/index.ts +1 -1
  135. package/testUtils/index.tsx +21 -30
  136. package/typeGuards/index.ts +0 -4
  137. package/utils/__tests__/clone.test.ts +158 -0
  138. package/utils/clone.ts +7 -0
  139. package/utils/index.ts +1 -13
  140. package/utils/path.ts +3 -6
  141. package/utils/pathOr.ts +1 -5
  142. package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +2 -2
  143. package/zappFrameworkUtils/HookCallback/hookCallbackManifestExtensions.config.js +1 -1
  144. package/zappFrameworkUtils/loginPluginUtils.ts +1 -1
  145. package/adsUtils/__tests__/createVMAP.test.ts +0 -419
  146. package/appDataUtils/__tests__/urlScheme.test.ts +0 -678
  147. package/appUtils/focusManagerAux/utils/index.ios.ts +0 -122
  148. package/cloudEventsUtils/__tests__/index.test.ts +0 -529
  149. package/enumUtils/__tests__/getEnumKeyByEnumValue.test.ts +0 -207
  150. package/errorUtils/__tests__/GeneralError.test.ts +0 -97
  151. package/errorUtils/__tests__/HttpStatusCode.test.ts +0 -344
  152. package/errorUtils/__tests__/MissingPluginError.test.ts +0 -113
  153. package/errorUtils/__tests__/NetworkError.test.ts +0 -202
  154. package/errorUtils/__tests__/getParsedResponse.test.ts +0 -188
  155. package/errorUtils/__tests__/invariant.test.ts +0 -112
  156. package/numberUtils/__tests__/toPositiveNumber.test.ts +0 -165
  157. package/reactHooks/analytics/__tests__/useSendAnalyticsOnPress.test.ts +0 -537
  158. package/reactHooks/dev/__tests__/useReRenderLog.test.ts +0 -188
  159. package/reactHooks/ui/__tests__/useFadeOutWhenBlurred.test.ts +0 -580
  160. package/rectUtils/__tests__/index.test.ts +0 -549
  161. package/screenPickerUtils/__tests__/index.test.ts +0 -333
  162. package/searchUtils/const.ts +0 -7
  163. package/searchUtils/index.ts +0 -3
  164. package/time/__tests__/BackgroundTimer.test.ts +0 -156
  165. package/time/__tests__/Timer.test.ts +0 -236
  166. package/typeGuards/__tests__/isString.test.ts +0 -21
  167. package/utils/__tests__/mergeRight.test.ts +0 -48
  168. package/utils/__tests__/selectors.test.ts +0 -124
  169. package/utils/mergeRight.ts +0 -5
  170. package/utils/selectors.ts +0 -46
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { View } from "react-native";
3
- import { cleanup, renderHook } from "@testing-library/react-native";
3
+ import { cleanup, renderHook } from "@testing-library/react-hooks";
4
4
  import configureStore from "redux-mock-store";
5
5
  import { Provider } from "react-redux";
6
6
 
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { renderHook, cleanup } from "@testing-library/react-native";
2
+ import { renderHook, cleanup } from "@testing-library/react-hooks";
3
3
  import configureStore from "redux-mock-store";
4
4
  import { Provider } from "react-redux";
5
5
 
@@ -3,10 +3,7 @@ import memoizee from "memoizee";
3
3
  import * as R from "ramda";
4
4
 
5
5
  import { CellRendererResolver } from "@applicaster/zapp-react-native-ui-components/Components/CellRendererResolver";
6
- import {
7
- usePlugins,
8
- useCellStyles,
9
- } from "@applicaster/zapp-react-native-redux";
6
+ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
10
7
  import { useDimensions } from "../layout";
11
8
  import { useIsRTL } from "../../localizationUtils";
12
9
 
@@ -56,8 +53,7 @@ export function useCellResolver({
56
53
  updateForInactiveScreens: false,
57
54
  });
58
55
 
59
- const plugins = usePlugins();
60
- const cellStyles = useCellStyles();
56
+ const { plugins, cellStyles } = usePickFromState(["plugins", "cellStyles"]);
61
57
  const isRTL = useIsRTL();
62
58
 
63
59
  const options = {
@@ -1,12 +1,10 @@
1
1
  /// <reference types="@applicaster/applicaster-types" />
2
2
  import * as React from "react";
3
3
 
4
+ import { coreLogger } from "@applicaster/zapp-react-native-utils/logger";
5
+
4
6
  import { findComponentByType } from "@applicaster/zapp-react-native-utils/pluginUtils";
5
- import {
6
- usePlugins,
7
- useAppSelector,
8
- selectComponents,
9
- } from "@applicaster/zapp-react-native-redux";
7
+ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
10
8
 
11
9
  type Decorator = (component: React.Component<any>) => React.Component<any>;
12
10
  type Watcher = Array<any>;
@@ -19,11 +17,9 @@ export function useComponentResolver(
19
17
  { componentType, decorators }: Props,
20
18
  watchers?: Watcher
21
19
  ): React.ComponentType<any> {
22
- const plugins = usePlugins();
23
-
24
- const components = useAppSelector(selectComponents);
20
+ const { plugins, components } = usePickFromState(["plugins", "components"]);
25
21
 
26
- return React.useMemo(
22
+ const component = React.useMemo(
27
23
  () =>
28
24
  findComponentByType({
29
25
  components,
@@ -33,4 +29,12 @@ export function useComponentResolver(
33
29
  }),
34
30
  watchers
35
31
  );
32
+
33
+ if (!component) {
34
+ coreLogger.warn({
35
+ message: `useComponentResolver: Component of type ${componentType} not found`,
36
+ });
37
+ }
38
+
39
+ return component;
36
40
  }
@@ -1,8 +1,8 @@
1
1
  import * as React from "react";
2
2
  import { Provider } from "react-redux";
3
- import { renderHook } from "@testing-library/react-native";
3
+ import { renderHook } from "@testing-library/react-hooks";
4
4
  import configureStore from "redux-mock-store";
5
- import { thunk } from "redux-thunk";
5
+ import thunk from "redux-thunk";
6
6
 
7
7
  const mockStore = configureStore([thunk]);
8
8
 
@@ -0,0 +1,103 @@
1
+ import { renderHook } from "@testing-library/react-native";
2
+ import { useCurrentScreenIsHook } from "../useCurrentScreenIsHook";
3
+
4
+ import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
5
+ import { last } from "@applicaster/zapp-react-native-utils/utils";
6
+ import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
7
+
8
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks");
9
+ jest.mock("@applicaster/zapp-react-native-utils/utils");
10
+ jest.mock("@applicaster/zapp-react-native-utils/booleanUtils");
11
+
12
+ const mockUseNavigation = useNavigation as jest.Mock;
13
+ const mockLast = last as jest.Mock;
14
+ const mockToBoolean = toBooleanWithDefaultFalse as jest.Mock;
15
+
16
+ describe("useCurrentScreenIsHook", () => {
17
+ beforeEach(() => {
18
+ jest.clearAllMocks();
19
+
20
+ // sensible defaults
21
+ mockUseNavigation.mockReturnValue({ mainStack: [] });
22
+ mockLast.mockReturnValue(undefined);
23
+ mockToBoolean.mockReturnValue(false);
24
+ });
25
+
26
+ it("returns true when last route includes 'hook'", () => {
27
+ const stack = [{ route: "some-hook-screen" }];
28
+
29
+ mockUseNavigation.mockReturnValue({ mainStack: stack });
30
+ mockLast.mockReturnValue(stack[0]);
31
+ mockToBoolean.mockReturnValue(true);
32
+
33
+ const { result } = renderHook(() => useCurrentScreenIsHook());
34
+
35
+ expect(mockLast).toHaveBeenCalledWith(stack);
36
+ expect(mockToBoolean).toHaveBeenCalledWith(true);
37
+ expect(result.current).toBe(true);
38
+ });
39
+
40
+ it("returns false when last route does not include 'hook'", () => {
41
+ const stack = [{ route: "home-screen" }];
42
+
43
+ mockUseNavigation.mockReturnValue({ mainStack: stack });
44
+ mockLast.mockReturnValue(stack[0]);
45
+ mockToBoolean.mockReturnValue(false);
46
+
47
+ const { result } = renderHook(() => useCurrentScreenIsHook());
48
+
49
+ expect(mockToBoolean).toHaveBeenCalledWith(false);
50
+ expect(result.current).toBe(false);
51
+ });
52
+
53
+ it("returns false when route is undefined", () => {
54
+ const stack = [{}];
55
+
56
+ mockUseNavigation.mockReturnValue({ mainStack: stack });
57
+ mockLast.mockReturnValue(stack[0]);
58
+ mockToBoolean.mockReturnValue(false);
59
+
60
+ const { result } = renderHook(() => useCurrentScreenIsHook());
61
+
62
+ expect(mockToBoolean).toHaveBeenCalledWith(undefined);
63
+ expect(result.current).toBe(false);
64
+ });
65
+
66
+ it("returns false when last(mainStack) is undefined (empty stack)", () => {
67
+ mockUseNavigation.mockReturnValue({ mainStack: [] });
68
+ mockLast.mockReturnValue(undefined);
69
+ mockToBoolean.mockReturnValue(false);
70
+
71
+ const { result } = renderHook(() => useCurrentScreenIsHook());
72
+
73
+ expect(mockLast).toHaveBeenCalledWith([]);
74
+ expect(mockToBoolean).toHaveBeenCalledWith(undefined);
75
+ expect(result.current).toBe(false);
76
+ });
77
+
78
+ it("uses default empty array when mainStack is undefined", () => {
79
+ mockUseNavigation.mockReturnValue({});
80
+ mockLast.mockReturnValue(undefined);
81
+ mockToBoolean.mockReturnValue(false);
82
+
83
+ const { result } = renderHook(() => useCurrentScreenIsHook());
84
+
85
+ expect(mockLast).toHaveBeenCalledWith([]);
86
+ expect(result.current).toBe(false);
87
+ });
88
+
89
+ it("passes correct boolean result from includes('hook')", () => {
90
+ const stack = [{ route: "hook" }];
91
+
92
+ mockUseNavigation.mockReturnValue({ mainStack: stack });
93
+ mockLast.mockReturnValue(stack[0]);
94
+
95
+ // simulate actual includes result flowing through
96
+ mockToBoolean.mockImplementation((val) => Boolean(val));
97
+
98
+ const { result } = renderHook(() => useCurrentScreenIsHook());
99
+
100
+ expect(mockToBoolean).toHaveBeenCalledWith(true);
101
+ expect(result.current).toBe(true);
102
+ });
103
+ });
@@ -0,0 +1,94 @@
1
+ import { renderHook } from "@testing-library/react-native";
2
+ import { useCurrentScreenIsStartupHook } from "../useCurrentScreenIsStartupHook";
3
+
4
+ import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
5
+ import { isFilledArray } from "@applicaster/zapp-react-native-utils/arrayUtils";
6
+
7
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks");
8
+ jest.mock("@applicaster/zapp-react-native-utils/arrayUtils");
9
+
10
+ const mockUseNavigation = useNavigation as jest.Mock;
11
+ const mockIsFilledArray = isFilledArray as jest.Mock;
12
+
13
+ describe("useCurrentScreenIsStartupHook", () => {
14
+ beforeEach(() => {
15
+ jest.clearAllMocks();
16
+ });
17
+
18
+ it("returns true when startUpHooks is a filled array", () => {
19
+ mockUseNavigation.mockReturnValue({
20
+ startUpHooks: ["hook1"],
21
+ });
22
+
23
+ mockIsFilledArray.mockReturnValue(true);
24
+
25
+ const { result } = renderHook(() => useCurrentScreenIsStartupHook());
26
+
27
+ expect(result.current).toBe(true);
28
+ expect(mockIsFilledArray).toHaveBeenCalledWith(["hook1"]);
29
+ });
30
+
31
+ it('returns true when startUpHooks is "in_process"', () => {
32
+ mockUseNavigation.mockReturnValue({
33
+ startUpHooks: "in_process",
34
+ });
35
+
36
+ mockIsFilledArray.mockReturnValue(false);
37
+
38
+ const { result } = renderHook(() => useCurrentScreenIsStartupHook());
39
+
40
+ expect(result.current).toBe(true);
41
+ expect(mockIsFilledArray).toHaveBeenCalledWith("in_process");
42
+ });
43
+
44
+ it("returns false when startUpHooks is empty array", () => {
45
+ mockUseNavigation.mockReturnValue({
46
+ startUpHooks: [],
47
+ });
48
+
49
+ mockIsFilledArray.mockReturnValue(false);
50
+
51
+ const { result } = renderHook(() => useCurrentScreenIsStartupHook());
52
+
53
+ expect(result.current).toBe(false);
54
+ expect(mockIsFilledArray).toHaveBeenCalledWith([]);
55
+ });
56
+
57
+ it("returns false when startUpHooks is undefined", () => {
58
+ mockUseNavigation.mockReturnValue({
59
+ startUpHooks: undefined,
60
+ });
61
+
62
+ mockIsFilledArray.mockReturnValue(false);
63
+
64
+ const { result } = renderHook(() => useCurrentScreenIsStartupHook());
65
+
66
+ expect(result.current).toBe(false);
67
+ expect(mockIsFilledArray).toHaveBeenCalledWith(undefined);
68
+ });
69
+
70
+ it("returns false when startUpHooks is null", () => {
71
+ mockUseNavigation.mockReturnValue({
72
+ startUpHooks: null,
73
+ });
74
+
75
+ mockIsFilledArray.mockReturnValue(false);
76
+
77
+ const { result } = renderHook(() => useCurrentScreenIsStartupHook());
78
+
79
+ expect(result.current).toBe(false);
80
+ expect(mockIsFilledArray).toHaveBeenCalledWith(null);
81
+ });
82
+
83
+ it("prioritizes filled array over string comparison", () => {
84
+ mockUseNavigation.mockReturnValue({
85
+ startUpHooks: ["hook1"],
86
+ });
87
+
88
+ mockIsFilledArray.mockReturnValue(true);
89
+
90
+ const { result } = renderHook(() => useCurrentScreenIsStartupHook());
91
+
92
+ expect(result.current).toBe(true);
93
+ });
94
+ });
@@ -1,4 +1,4 @@
1
- import { renderHook } from "@testing-library/react-native";
1
+ import { renderHook } from "@testing-library/react-hooks";
2
2
 
3
3
  jest.mock(
4
4
  "@applicaster/zapp-react-native-ui-components/Components/River/useScreenConfiguration",
@@ -1,4 +1,4 @@
1
- import { renderHook } from "@testing-library/react-native";
1
+ import { renderHook } from "@testing-library/react-hooks";
2
2
  import configureStore from "redux-mock-store";
3
3
 
4
4
  const mockStore = configureStore();
@@ -1,24 +1,16 @@
1
1
  import * as React from "react";
2
2
  import { Provider } from "react-redux";
3
- import { renderHook } from "@testing-library/react-native";
3
+ import { renderHook } from "@testing-library/react-hooks";
4
4
  import configureStore from "redux-mock-store";
5
- import { thunk } from "redux-thunk";
5
+ import thunk from "redux-thunk";
6
6
 
7
7
  const mockStore = configureStore([thunk]);
8
8
 
9
9
  import { useTargetScreenData } from "../useTargetScreenData";
10
10
 
11
11
  describe("useTargetScreenData", function () {
12
- const river_id_2 = {
13
- id: "river_id_2",
14
- type: "any",
15
- };
16
-
17
- const river_id_1 = {
18
- id: "river_id_1",
19
- type: "any",
20
- };
21
-
12
+ const river_id_2 = {};
13
+ const river_id_1 = {};
22
14
  const screenId = "river_id_2";
23
15
  const entry = { id: "test", type: { value: "video" } };
24
16
 
@@ -12,3 +12,9 @@ export {
12
12
  } from "./useScreenContext";
13
13
 
14
14
  export { useScreenBackgroundColor } from "./useScreenBackgroundColor";
15
+
16
+ export { useCurrentScreenIsHook } from "./useCurrentScreenIsHook";
17
+
18
+ export { useCurrentScreenIsStartupHook } from "./useCurrentScreenIsStartupHook";
19
+
20
+ export { useIsStandaloneFullscreen } from "./useIsStandaloneFullscreen";
@@ -0,0 +1,9 @@
1
+ import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
2
+ import { last } from "@applicaster/zapp-react-native-utils/utils";
3
+ import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
4
+
5
+ export const useCurrentScreenIsHook = (): boolean => {
6
+ const { mainStack = [] } = useNavigation();
7
+
8
+ return toBooleanWithDefaultFalse(last(mainStack)?.route?.includes("hook"));
9
+ };
@@ -0,0 +1,8 @@
1
+ import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
2
+ import { isFilledArray } from "@applicaster/zapp-react-native-utils/arrayUtils";
3
+
4
+ export const useCurrentScreenIsStartupHook = (): boolean => {
5
+ const { startUpHooks } = useNavigation();
6
+
7
+ return isFilledArray(startUpHooks) || startUpHooks === "in_process";
8
+ };
@@ -0,0 +1,12 @@
1
+ import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
2
+ import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
3
+
4
+ export const useIsStandaloneFullscreen = (): boolean => {
5
+ const navigator = useNavigation();
6
+
7
+ return toBooleanWithDefaultFalse(
8
+ !navigator?.canGoBack() &&
9
+ // @ts-ignore
10
+ navigator?.screenData?.general?.allow_screen_plugin_presentation
11
+ );
12
+ };
@@ -1,8 +1,7 @@
1
1
  import React from "react";
2
- import { useContentTypes } from "@applicaster/zapp-react-native-redux/hooks";
2
+ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
3
3
  import * as R from "ramda";
4
4
  import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
5
- import { useRivers } from "../state";
6
5
 
7
6
  export function getTargetScreenData(
8
7
  entry: ZappEntry,
@@ -44,8 +43,7 @@ export function getTargetScreenDataFromEntry(entry: ZappEntry): ZappRiver {
44
43
  }
45
44
 
46
45
  export const useTargetScreenData = (entry: ZappEntry) => {
47
- const rivers = useRivers();
48
- const contentTypes = useContentTypes();
46
+ const { rivers, contentTypes } = usePickFromState(["rivers", "contentTypes"]);
49
47
 
50
48
  return React.useMemo(
51
49
  () => getTargetScreenData(entry, rivers, contentTypes),
@@ -0,0 +1,246 @@
1
+ import { renderHook, act } from "@testing-library/react-native";
2
+ import { useComponentScreenState } from "../useComponentScreenState";
3
+ import { useScreenContextV2 } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
4
+
5
+ import { create } from "zustand";
6
+
7
+ const createMockStore = () => create(() => ({}));
8
+
9
+ // Mock the external dependencies
10
+ jest.mock(
11
+ "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext",
12
+ () => ({
13
+ useScreenContextV2: jest.fn(),
14
+ })
15
+ );
16
+
17
+ const mockUseScreenContextV2 = useScreenContextV2 as jest.MockedFunction<
18
+ typeof useScreenContextV2
19
+ >;
20
+
21
+ describe("useComponentScreenState", () => {
22
+ beforeEach(() => {
23
+ jest.clearAllMocks();
24
+ });
25
+
26
+ it("should return initial value when no state exists for componentId", () => {
27
+ const mockStore = createMockStore();
28
+
29
+ mockUseScreenContextV2.mockReturnValue({
30
+ _componentStateStore: mockStore,
31
+ } as any);
32
+
33
+ const initialValue = "default-value";
34
+ const componentId = "test-component";
35
+
36
+ const { result } = renderHook(() =>
37
+ useComponentScreenState(componentId, initialValue)
38
+ );
39
+
40
+ expect(result.current[0]).toBe(initialValue);
41
+ });
42
+
43
+ it("should return stored value when state exists for componentId", () => {
44
+ const mockStore = createMockStore();
45
+ mockStore.setState({ "existing-component": "stored-value" });
46
+
47
+ mockUseScreenContextV2.mockReturnValue({
48
+ _componentStateStore: mockStore,
49
+ } as any);
50
+
51
+ const { result } = renderHook(() =>
52
+ useComponentScreenState("existing-component", "default")
53
+ );
54
+
55
+ expect(result.current[0]).toBe("stored-value");
56
+ });
57
+
58
+ it("should update state when setter is called", () => {
59
+ const mockStore = createMockStore();
60
+
61
+ mockUseScreenContextV2.mockReturnValue({
62
+ _componentStateStore: mockStore,
63
+ } as any);
64
+
65
+ const { result } = renderHook(() =>
66
+ useComponentScreenState("update-test", "initial")
67
+ );
68
+
69
+ // Verify initial value
70
+ expect(result.current[0]).toBe("initial");
71
+
72
+ // Update the value
73
+ act(() => {
74
+ result.current[1]("updated-value");
75
+ });
76
+
77
+ // Verify updated value
78
+ expect(result.current[0]).toBe("updated-value");
79
+ });
80
+
81
+ it("should handle different data types correctly", () => {
82
+ const mockStore = createMockStore();
83
+
84
+ mockUseScreenContextV2.mockReturnValue({
85
+ _componentStateStore: mockStore,
86
+ } as any);
87
+
88
+ // Test with number
89
+ const { result: numberResult } = renderHook(() =>
90
+ useComponentScreenState<number>("number-test", 42)
91
+ );
92
+
93
+ expect(numberResult.current[0]).toBe(42);
94
+
95
+ // Test with boolean
96
+ const { result: boolResult } = renderHook(() =>
97
+ useComponentScreenState<boolean>("bool-test", true)
98
+ );
99
+
100
+ expect(boolResult.current[0]).toBe(true);
101
+
102
+ // Test with object
103
+ const testObj = { key: "value" };
104
+
105
+ const { result: objResult } = renderHook(() =>
106
+ useComponentScreenState<{ key: string }>("obj-test", testObj)
107
+ );
108
+
109
+ expect(objResult.current[0]).toEqual(testObj);
110
+ });
111
+
112
+ it("should maintain separate states for different componentIds", () => {
113
+ const mockStore = createMockStore();
114
+
115
+ mockUseScreenContextV2.mockReturnValue({
116
+ _componentStateStore: mockStore,
117
+ } as any);
118
+
119
+ const { result: firstResult } = renderHook(() =>
120
+ useComponentScreenState("first", "first-initial")
121
+ );
122
+
123
+ const { result: secondResult } = renderHook(() =>
124
+ useComponentScreenState("second", "second-initial")
125
+ );
126
+
127
+ // Verify initial values are separate
128
+ expect(firstResult.current[0]).toBe("first-initial");
129
+ expect(secondResult.current[0]).toBe("second-initial");
130
+
131
+ // Update first component's state
132
+ act(() => {
133
+ firstResult.current[1]("first-updated");
134
+ });
135
+
136
+ // Verify only first component's state changed
137
+ expect(firstResult.current[0]).toBe("first-updated");
138
+ expect(secondResult.current[0]).toBe("second-initial");
139
+ });
140
+
141
+ it("should return a memoized setter function", () => {
142
+ const mockStore = createMockStore();
143
+
144
+ mockUseScreenContextV2.mockReturnValue({
145
+ _componentStateStore: mockStore,
146
+ } as any);
147
+
148
+ const { result, rerender } = renderHook(
149
+ ({ id, initial }) => useComponentScreenState(id, initial),
150
+ {
151
+ initialProps: { id: "memo-test", initial: "initial" },
152
+ }
153
+ );
154
+
155
+ const firstSetter = result.current[1];
156
+
157
+ // Rerender with same props
158
+ rerender({ id: "memo-test", initial: "initial" });
159
+
160
+ const secondSetter = result.current[1];
161
+
162
+ // Setter should be the same instance due to useCallback
163
+ expect(firstSetter).toBe(secondSetter);
164
+ });
165
+
166
+ it("should update setter when componentId changes", () => {
167
+ const mockStore = createMockStore();
168
+
169
+ mockUseScreenContextV2.mockReturnValue({
170
+ _componentStateStore: mockStore,
171
+ } as any);
172
+
173
+ const { result, rerender } = renderHook(
174
+ ({ id, initial }) => useComponentScreenState(id, initial),
175
+ {
176
+ initialProps: { id: "old-id", initial: "initial" },
177
+ }
178
+ );
179
+
180
+ const firstSetter = result.current[1];
181
+
182
+ // Rerender with different componentId
183
+ rerender({ id: "new-id", initial: "initial" });
184
+
185
+ const secondSetter = result.current[1];
186
+
187
+ // Setter should be different because componentId changed
188
+ expect(firstSetter).not.toBe(secondSetter);
189
+ });
190
+
191
+ it("should call store.setState with correct parameters", () => {
192
+ const mockStore = createMockStore();
193
+ const setStateSpy = jest.spyOn(mockStore, "setState");
194
+
195
+ mockUseScreenContextV2.mockReturnValue({
196
+ _componentStateStore: mockStore,
197
+ } as any);
198
+
199
+ const { result } = renderHook(() =>
200
+ useComponentScreenState("state-test", "initial")
201
+ );
202
+
203
+ const newValue = "new-value";
204
+
205
+ act(() => {
206
+ result.current[1](newValue);
207
+ });
208
+
209
+ expect(setStateSpy).toHaveBeenCalledWith({
210
+ "state-test": newValue,
211
+ });
212
+ });
213
+
214
+ it("should handle falsy initial values correctly", () => {
215
+ const mockStore = createMockStore();
216
+
217
+ mockUseScreenContextV2.mockReturnValue({
218
+ _componentStateStore: mockStore,
219
+ } as any);
220
+
221
+ // Test with falsy values
222
+ const { result: nullResult } = renderHook(() =>
223
+ useComponentScreenState("null-test", null)
224
+ );
225
+
226
+ expect(nullResult.current[0]).toBeNull();
227
+
228
+ const { result: falseResult } = renderHook(() =>
229
+ useComponentScreenState("false-test", false)
230
+ );
231
+
232
+ expect(falseResult.current[0]).toBe(false);
233
+
234
+ const { result: zeroResult } = renderHook(() =>
235
+ useComponentScreenState("zero-test", 0)
236
+ );
237
+
238
+ expect(zeroResult.current[0]).toBe(0);
239
+
240
+ const { result: emptyStrResult } = renderHook(() =>
241
+ useComponentScreenState("empty-test", "")
242
+ );
243
+
244
+ expect(emptyStrResult.current[0]).toBe("");
245
+ });
246
+ });
@@ -3,3 +3,5 @@ export { useRivers } from "./useRivers";
3
3
  export { useHomeRiver, getHomeRiver } from "./useHomeRiver";
4
4
 
5
5
  export { ZStoreProvider, useZStore } from "./ZStoreProvider";
6
+
7
+ export { useComponentScreenState } from "./useComponentScreenState";