@applicaster/zapp-react-native-utils 15.0.0-alpha.3642255793 → 15.0.0-alpha.3842304615

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 (78) hide show
  1. package/README.md +0 -6
  2. package/actionUtils/index.ts +7 -0
  3. package/actionsExecutor/ActionExecutorContext.tsx +83 -6
  4. package/appUtils/HooksManager/index.ts +35 -0
  5. package/appUtils/focusManager/treeDataStructure/Tree/__tests__/Tree.test.js +46 -0
  6. package/appUtils/focusManager/treeDataStructure/Tree/index.js +18 -18
  7. package/appUtils/focusManagerAux/utils/index.ts +12 -6
  8. package/appUtils/focusManagerAux/utils/utils.ios.ts +6 -3
  9. package/appUtils/localizationsHelper.ts +4 -0
  10. package/appUtils/playerManager/index.ts +9 -0
  11. package/appUtils/playerManager/player.ts +1 -1
  12. package/appUtils/playerManager/playerNative.ts +2 -1
  13. package/appUtils/playerManager/usePlayer.tsx +5 -3
  14. package/cellUtils/__tests__/cellUtils.test.ts +39 -0
  15. package/cellUtils/index.ts +11 -1
  16. package/componentsUtils/index.ts +8 -0
  17. package/dateUtils/__tests__/dayjs.test.ts +0 -3
  18. package/dateUtils/index.ts +2 -0
  19. package/manifestUtils/_internals/__tests__/index.test.js +41 -0
  20. package/manifestUtils/_internals/index.js +33 -0
  21. package/manifestUtils/defaultManifestConfigurations/player.js +6 -16
  22. package/manifestUtils/fieldUtils/__tests__/fieldUtils.test.js +49 -0
  23. package/manifestUtils/fieldUtils/index.js +54 -0
  24. package/manifestUtils/index.js +2 -0
  25. package/manifestUtils/keys.js +228 -0
  26. package/manifestUtils/mobileAction/button/__tests__/mobileActionButton.test.js +168 -0
  27. package/manifestUtils/mobileAction/button/index.js +140 -0
  28. package/manifestUtils/mobileAction/container/__tests__/mobileActionButtonsContainer.test.js +102 -0
  29. package/manifestUtils/mobileAction/container/index.js +73 -0
  30. package/manifestUtils/mobileAction/groups/__tests__/buildMobileActionButtonGroups.test.js +127 -0
  31. package/manifestUtils/mobileAction/groups/defaults.js +76 -0
  32. package/manifestUtils/mobileAction/groups/index.js +80 -0
  33. package/manifestUtils/platformIsTV.js +13 -0
  34. package/numberUtils/__tests__/toNumber.test.ts +27 -12
  35. package/numberUtils/__tests__/toPositiveNumber.test.ts +32 -4
  36. package/numberUtils/index.ts +5 -1
  37. package/package.json +3 -3
  38. package/pluginUtils/index.ts +4 -5
  39. package/reactHooks/analytics/__tests__/useSendAnalyticsOnPress.test.ts +537 -0
  40. package/reactHooks/casting/index.ts +1 -0
  41. package/reactHooks/casting/useIsCasting.tsx +57 -0
  42. package/reactHooks/cell-click/index.ts +2 -1
  43. package/reactHooks/dev/__tests__/useReRenderLog.test.ts +188 -0
  44. package/reactHooks/device/useIsTablet.tsx +14 -19
  45. package/reactHooks/events/index.ts +20 -0
  46. package/reactHooks/feed/index.ts +0 -2
  47. package/reactHooks/feed/useInflatedUrl.ts +1 -1
  48. package/reactHooks/index.ts +2 -0
  49. package/reactHooks/resolvers/useComponentResolver.ts +13 -3
  50. package/reactHooks/screen/__tests__/useCurrentScreenIsHook.test.ts +103 -0
  51. package/reactHooks/screen/__tests__/useCurrentScreenIsStartupHook.test.ts +94 -0
  52. package/reactHooks/screen/index.ts +4 -0
  53. package/reactHooks/screen/useCurrentScreenIsHook.ts +9 -0
  54. package/reactHooks/screen/useCurrentScreenIsStartupHook.ts +8 -0
  55. package/reactHooks/state/__tests__/useComponentScreenState.test.ts +246 -0
  56. package/reactHooks/state/index.ts +2 -0
  57. package/reactHooks/state/useComponentScreenState.ts +45 -0
  58. package/reactHooks/ui/__tests__/useFadeOutWhenBlurred.test.ts +580 -0
  59. package/rectUtils/__tests__/index.test.ts +549 -0
  60. package/rectUtils/index.ts +2 -2
  61. package/refreshUtils/RefreshCoordinator/__tests__/refreshCoordinator.test.ts +206 -0
  62. package/refreshUtils/RefreshCoordinator/index.ts +245 -0
  63. package/refreshUtils/RefreshCoordinator/utils/__tests__/getDataRefreshConfig.test.ts +104 -0
  64. package/refreshUtils/RefreshCoordinator/utils/index.ts +29 -0
  65. package/screenPickerUtils/__tests__/index.test.ts +333 -0
  66. package/screenPickerUtils/index.ts +5 -0
  67. package/screenUtils/index.ts +3 -0
  68. package/time/__tests__/BackgroundTimer.test.ts +156 -0
  69. package/time/__tests__/Timer.test.ts +236 -0
  70. package/typeGuards/__tests__/isString.test.ts +21 -0
  71. package/typeGuards/index.ts +4 -0
  72. package/utils/__tests__/clone.test.ts +158 -0
  73. package/utils/__tests__/path.test.ts +7 -0
  74. package/utils/clone.ts +7 -0
  75. package/utils/index.ts +2 -1
  76. package/reactHooks/componentsMap/index.ts +0 -55
  77. package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +0 -75
  78. package/reactHooks/feed/useFeedRefresh.tsx +0 -65
@@ -54,7 +54,7 @@ export const useCellClick = ({
54
54
  component?.rules?.component_cells_selectable
55
55
  );
56
56
 
57
- const [__, setEntryContext] =
57
+ const [entryContext, setEntryContext] =
58
58
  ZappPipesEntryContext.useZappPipesContext(pathname);
59
59
 
60
60
  const logTimestamp = useProfilerLogging();
@@ -89,6 +89,7 @@ export const useCellClick = ({
89
89
  screenState,
90
90
  screenRoute: pathname,
91
91
  screenStateStore,
92
+ entryContext,
92
93
  });
93
94
  }
94
95
 
@@ -0,0 +1,188 @@
1
+ import { renderHook } from "@testing-library/react-native";
2
+ import { useReRenderLog } from "../index";
3
+
4
+ describe("useReRenderLog", () => {
5
+ let consoleLogSpy: jest.SpyInstance;
6
+
7
+ beforeEach(() => {
8
+ consoleLogSpy = jest.spyOn(console, "log").mockImplementation();
9
+ });
10
+
11
+ afterEach(() => {
12
+ consoleLogSpy.mockRestore();
13
+ });
14
+
15
+ it("should log on initial render", () => {
16
+ const message = "Test Component";
17
+
18
+ renderHook(() => useReRenderLog(message));
19
+
20
+ expect(consoleLogSpy).toHaveBeenCalledWith(
21
+ expect.stringContaining("<<RE-RENDERED>>")
22
+ );
23
+
24
+ expect(consoleLogSpy).toHaveBeenCalledWith(
25
+ expect.stringContaining("<<COUNT: 1>>")
26
+ );
27
+
28
+ expect(consoleLogSpy).toHaveBeenCalledWith(
29
+ expect.stringContaining(message)
30
+ );
31
+ });
32
+
33
+ it("should increment count on each re-render", () => {
34
+ const message = "Counter Test";
35
+
36
+ const { rerender } = renderHook(() => useReRenderLog(message));
37
+
38
+ expect(consoleLogSpy).toHaveBeenCalledWith(
39
+ expect.stringContaining("<<COUNT: 1>>")
40
+ );
41
+
42
+ rerender();
43
+
44
+ expect(consoleLogSpy).toHaveBeenCalledWith(
45
+ expect.stringContaining("<<COUNT: 2>>")
46
+ );
47
+
48
+ rerender();
49
+
50
+ expect(consoleLogSpy).toHaveBeenCalledWith(
51
+ expect.stringContaining("<<COUNT: 3>>")
52
+ );
53
+ });
54
+
55
+ it("should log correct message format", () => {
56
+ const message = "MyComponent";
57
+
58
+ renderHook(() => useReRenderLog(message));
59
+
60
+ expect(consoleLogSpy).toHaveBeenCalledWith(
61
+ "<<RE-RENDERED>><<COUNT: 1>>: MyComponent"
62
+ );
63
+ });
64
+
65
+ it("should track renders independently for different hook instances", () => {
66
+ const message1 = "Component1";
67
+ const message2 = "Component2";
68
+
69
+ const { rerender: rerender1 } = renderHook(() => useReRenderLog(message1));
70
+
71
+ const { rerender: rerender2 } = renderHook(() => useReRenderLog(message2));
72
+
73
+ consoleLogSpy.mockClear();
74
+
75
+ rerender1();
76
+
77
+ expect(consoleLogSpy).toHaveBeenLastCalledWith(
78
+ expect.stringContaining("Component1")
79
+ );
80
+
81
+ rerender2();
82
+
83
+ expect(consoleLogSpy).toHaveBeenLastCalledWith(
84
+ expect.stringContaining("Component2")
85
+ );
86
+ });
87
+
88
+ it("should handle empty string message", () => {
89
+ renderHook(() => useReRenderLog(""));
90
+
91
+ expect(consoleLogSpy).toHaveBeenCalledWith("<<RE-RENDERED>><<COUNT: 1>>: ");
92
+ });
93
+
94
+ it("should handle message with special characters", () => {
95
+ const message = "Test!@#$%^&*()";
96
+
97
+ renderHook(() => useReRenderLog(message));
98
+
99
+ expect(consoleLogSpy).toHaveBeenCalledWith(
100
+ expect.stringContaining(message)
101
+ );
102
+ });
103
+
104
+ it("should handle long messages", () => {
105
+ const message = "A".repeat(1000);
106
+
107
+ renderHook(() => useReRenderLog(message));
108
+
109
+ expect(consoleLogSpy).toHaveBeenCalledWith(
110
+ expect.stringContaining(message)
111
+ );
112
+ });
113
+
114
+ it("should persist count across multiple re-renders", () => {
115
+ const message = "Persistence Test";
116
+
117
+ const { rerender } = renderHook(() => useReRenderLog(message));
118
+
119
+ for (let i = 2; i <= 10; i++) {
120
+ rerender();
121
+
122
+ expect(consoleLogSpy).toHaveBeenLastCalledWith(
123
+ expect.stringContaining(`<<COUNT: ${i}>>`)
124
+ );
125
+ }
126
+ });
127
+
128
+ it("should log on every render without dependencies", () => {
129
+ const message = "Every Render";
130
+
131
+ const { rerender } = renderHook(() => useReRenderLog(message));
132
+
133
+ const initialCallCount = consoleLogSpy.mock.calls.length;
134
+
135
+ rerender();
136
+ rerender();
137
+ rerender();
138
+
139
+ // Should have 4 total calls (initial + 3 rerenders)
140
+ expect(consoleLogSpy).toHaveBeenCalledTimes(initialCallCount + 3);
141
+ });
142
+
143
+ it("should handle numeric messages", () => {
144
+ renderHook(() => useReRenderLog(123 as any));
145
+
146
+ expect(consoleLogSpy).toHaveBeenCalledWith(expect.stringContaining("123"));
147
+ });
148
+
149
+ it("should handle object messages", () => {
150
+ const obj = { key: "value" };
151
+
152
+ renderHook(() => useReRenderLog(obj as any));
153
+
154
+ expect(consoleLogSpy).toHaveBeenCalled();
155
+ });
156
+
157
+ it("should maintain separate refs for each instance", () => {
158
+ const { rerender: rerender1 } = renderHook(() =>
159
+ useReRenderLog("Instance1")
160
+ );
161
+
162
+ const { rerender: rerender2 } = renderHook(() =>
163
+ useReRenderLog("Instance2")
164
+ );
165
+
166
+ consoleLogSpy.mockClear();
167
+
168
+ // Render instance 1 twice more
169
+ rerender1();
170
+ rerender1();
171
+
172
+ // Render instance 2 once more
173
+ rerender2();
174
+
175
+ const calls = consoleLogSpy.mock.calls;
176
+
177
+ // Instance 1 should be at count 2 and 3
178
+ expect(calls[0][0]).toContain("Instance1");
179
+ expect(calls[0][0]).toContain("<<COUNT: 2>>");
180
+
181
+ expect(calls[1][0]).toContain("Instance1");
182
+ expect(calls[1][0]).toContain("<<COUNT: 3>>");
183
+
184
+ // Instance 2 should be at count 2
185
+ expect(calls[2][0]).toContain("Instance2");
186
+ expect(calls[2][0]).toContain("<<COUNT: 2>>");
187
+ });
188
+ });
@@ -1,28 +1,23 @@
1
1
  /* eslint react-native/split-platform-components: off */
2
2
 
3
3
  import { Platform, PlatformIOSStatic, NativeModules } from "react-native";
4
- import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
5
- import { F as alwaysFalse } from "ramda";
6
4
  import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
7
5
 
8
- const useIsTabletIos = (): boolean => {
9
- const { isPad } = Platform as PlatformIOSStatic;
6
+ export const useIsTablet = (): boolean => {
7
+ const platform = Platform.OS;
10
8
 
11
- return isPad;
12
- };
9
+ if (platform === "ios") {
10
+ const { isPad } = Platform as PlatformIOSStatic;
13
11
 
14
- const useIsTabletAndroid = (): boolean => {
15
- const { initialProps } = NativeModules.QuickBrickCommunicationModule;
12
+ return Boolean(isPad);
13
+ }
16
14
 
17
- return toBooleanWithDefaultFalse(initialProps?.is_tablet);
18
- };
15
+ if (platform === "android") {
16
+ const initialProps =
17
+ NativeModules.QuickBrickCommunicationModule?.initialProps;
19
18
 
20
- export const useIsTablet = platformSelect({
21
- ios: useIsTabletIos,
22
- android: useIsTabletAndroid,
23
- lg_tv: alwaysFalse,
24
- samsung_tv: alwaysFalse,
25
- android_tv: alwaysFalse,
26
- tvos: alwaysFalse,
27
- default: alwaysFalse,
28
- });
19
+ return toBooleanWithDefaultFalse(initialProps?.is_tablet);
20
+ }
21
+
22
+ return false;
23
+ };
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+ import { scrollEndReached$ } from "@applicaster/zapp-react-native-ui-components/events";
3
+ import { filter } from "rxjs/operators";
4
+
5
+ /**
6
+ * Subscribe to scroll-end-reached and call loadNextData only when this item is last in the river.
7
+ * Use in Grid/List so they load next page when the user scrolls to the end (river or tabs scroll container).
8
+ */
9
+ export function useScrollEndReachedLoadNext(
10
+ isLast: boolean,
11
+ loadNextData: () => void
12
+ ): void {
13
+ React.useEffect(() => {
14
+ const sub = scrollEndReached$.pipe(filter(() => isLast)).subscribe(() => {
15
+ loadNextData();
16
+ });
17
+
18
+ return () => sub.unsubscribe();
19
+ }, [isLast, loadNextData]);
20
+ }
@@ -1,5 +1,3 @@
1
- export { useFeedRefresh, feedRefreshLogger } from "./useFeedRefresh";
2
-
3
1
  export { useFeedLoader } from "./useFeedLoader";
4
2
 
5
3
  export { getSearchContext, getInflatedDataSourceUrl } from "./useInflatedUrl";
@@ -45,7 +45,7 @@ interface GetInflatedDataSourceUrl {
45
45
  (properties: {
46
46
  source?: string;
47
47
  contexts: {
48
- entry?: ZappEntry;
48
+ entry?: ZappEntry & { parent?: ZappEntry };
49
49
  screen?: ZappRiver;
50
50
  search?: object | string;
51
51
  };
@@ -15,3 +15,5 @@ export * from "./device";
15
15
  export * from "./screen";
16
16
 
17
17
  export * from "./state";
18
+
19
+ export * from "./events";
@@ -1,11 +1,13 @@
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
7
  import {
6
- usePlugins,
7
- useAppSelector,
8
8
  selectComponents,
9
+ useAppSelector,
10
+ usePlugins,
9
11
  } from "@applicaster/zapp-react-native-redux";
10
12
 
11
13
  type Decorator = (component: React.Component<any>) => React.Component<any>;
@@ -23,7 +25,7 @@ export function useComponentResolver(
23
25
 
24
26
  const components = useAppSelector(selectComponents);
25
27
 
26
- return React.useMemo(
28
+ const component = React.useMemo(
27
29
  () =>
28
30
  findComponentByType({
29
31
  components,
@@ -33,4 +35,12 @@ export function useComponentResolver(
33
35
  }),
34
36
  watchers
35
37
  );
38
+
39
+ if (!component) {
40
+ coreLogger.warn({
41
+ message: `useComponentResolver: Component of type ${componentType} not found`,
42
+ });
43
+ }
44
+
45
+ return component;
36
46
  }
@@ -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
+ });
@@ -12,3 +12,7 @@ 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";
@@ -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
+ };