@applicaster/zapp-react-native-utils 13.0.0-rc.13 → 13.0.0-rc.130

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 (173) hide show
  1. package/README.md +0 -10
  2. package/actionsExecutor/ActionExecutor.ts +16 -9
  3. package/actionsExecutor/ActionExecutorContext.tsx +229 -17
  4. package/actionsExecutor/consts.ts +4 -0
  5. package/alertUtils/alert.ts +148 -0
  6. package/alertUtils/index.ts +1 -148
  7. package/analyticsUtils/AnalyticPlayerListener.ts +18 -1
  8. package/analyticsUtils/__tests__/__snapshots__/analyticsManagerNoModule.test.js.snap +9 -9
  9. package/analyticsUtils/currentScreenProperities.ts +6 -4
  10. package/analyticsUtils/helpers/hooks.ts +1 -1
  11. package/appUtils/HooksManager/Hook.ts +6 -2
  12. package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +7 -7
  13. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +186 -186
  14. package/appUtils/HooksManager/index.ts +3 -1
  15. package/appUtils/HooksManager/types.ts +5 -2
  16. package/appUtils/__tests__/__snapshots__/localizationsHelper.test.ts.snap +151 -0
  17. package/appUtils/__tests__/allZappLocales.ts +79 -0
  18. package/appUtils/__tests__/{localizationsHelper.test.js → localizationsHelper.test.ts} +11 -0
  19. package/appUtils/accessibilityManager/const.ts +18 -0
  20. package/appUtils/accessibilityManager/index.ts +42 -1
  21. package/appUtils/contextKeysManager/contextResolver.ts +66 -0
  22. package/appUtils/contextKeysManager/index.ts +2 -2
  23. package/appUtils/contextKeysManager/utils/index.ts +2 -1
  24. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +9 -6
  25. package/appUtils/focusManager/index.ios.ts +14 -4
  26. package/appUtils/focusManager/index.ts +108 -69
  27. package/appUtils/focusManager/treeDataStructure/Tree/index.js +23 -0
  28. package/appUtils/focusManager/utils/__tests__/findChild.test.ts +35 -0
  29. package/appUtils/focusManager/utils/enums.ts +4 -0
  30. package/appUtils/focusManager/utils/index.ts +5 -0
  31. package/appUtils/focusManagerAux/utils/index.ts +4 -3
  32. package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +2 -2
  33. package/appUtils/keyCodes/__tests__/keyCodes.test.js +1 -1
  34. package/appUtils/keyCodes/index.ts +11 -7
  35. package/appUtils/keyCodes/keys/keysByPlatform.ts +4 -0
  36. package/appUtils/keyInputHandler/KeyInputHandler.ts +68 -0
  37. package/appUtils/localizationsHelper.ts +31 -0
  38. package/appUtils/orientationHelper.ts +11 -13
  39. package/appUtils/platform/const.ts +14 -0
  40. package/appUtils/platform/platformUtils.ts +47 -4
  41. package/appUtils/playerManager/index.ts +1 -1
  42. package/appUtils/playerManager/player.ts +42 -18
  43. package/appUtils/playerManager/playerHooks/usePlayerCurrentTime.tsx +11 -7
  44. package/appUtils/playerManager/playerNative.ts +18 -2
  45. package/appUtils/playerManager/usePlayerControllerSetup.tsx +3 -3
  46. package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +7 -1
  47. package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
  48. package/cellUtils/index.ts +9 -5
  49. package/componentsUtils/__tests__/isFirstComponentGallery.test.ts +33 -0
  50. package/componentsUtils/__tests__/isFirstComponentScreenPicker.test.ts +33 -0
  51. package/componentsUtils/__tests__/isGallery.test.ts +33 -0
  52. package/componentsUtils/__tests__/isScreenPicker.test.ts +33 -0
  53. package/componentsUtils/index.ts +39 -0
  54. package/dateUtils/index.ts +19 -0
  55. package/equalUtils/__tests__/isEqual/combination.test.ts +263 -0
  56. package/equalUtils/index.ts +49 -30
  57. package/focusManager/FocusManager.ts +14 -2
  58. package/focusManager/index.ts +23 -4
  59. package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
  60. package/functionUtils/index.ts +46 -8
  61. package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
  62. package/idleUtils/index.ts +1 -1
  63. package/idleUtils/withTimeout.ts +15 -2
  64. package/index.d.ts +0 -12
  65. package/localizationUtils/index.ts +8 -13
  66. package/logger/const.ts +9 -67
  67. package/manifestUtils/__tests__/createConfig.test.js +16 -16
  68. package/manifestUtils/defaultManifestConfigurations/generalContent.js +13 -0
  69. package/manifestUtils/defaultManifestConfigurations/player.js +9 -3
  70. package/manifestUtils/fonts/index.js +5 -6
  71. package/manifestUtils/index.js +2 -0
  72. package/manifestUtils/keys.js +27 -2
  73. package/manifestUtils/sharedConfiguration/screenPicker/__tests__/utils.test.js +304 -0
  74. package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +875 -0
  75. package/manifestUtils/sharedConfiguration/screenPicker/utils.js +130 -0
  76. package/modalState/__tests__/index.test.ts +51 -0
  77. package/modalState/index.ts +32 -2
  78. package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +7 -6
  79. package/navigationUtils/__tests__/itemTypes.test.js +2 -2
  80. package/navigationUtils/__tests__/navigationUtils.test.js +2 -2
  81. package/navigationUtils/index.ts +6 -4
  82. package/numberUtils/__tests__/toPositiveNumberWithDefault.test.ts +23 -3
  83. package/numberUtils/index.ts +11 -5
  84. package/package.json +5 -10
  85. package/playerUtils/configurationGenerator.ts +9 -11
  86. package/playerUtils/index.ts +17 -0
  87. package/reactHooks/advertising/index.ts +5 -5
  88. package/reactHooks/app/useAppState.ts +2 -2
  89. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  90. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +6 -8
  91. package/reactHooks/autoscrolling/useTrackedView.ts +12 -1
  92. package/reactHooks/cell-click/__tests__/index.test.js +10 -2
  93. package/reactHooks/cell-click/index.ts +7 -1
  94. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +4 -4
  95. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +10 -11
  96. package/reactHooks/feed/useBatchLoading.ts +10 -12
  97. package/reactHooks/feed/useFeedLoader.tsx +18 -9
  98. package/reactHooks/feed/usePipesCacheReset.ts +5 -5
  99. package/reactHooks/flatList/__tests__/index.test.tsx +30 -21
  100. package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +39 -0
  101. package/reactHooks/layout/__tests__/index.test.tsx +10 -10
  102. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +14 -28
  103. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +1 -1
  104. package/reactHooks/layout/useDimensions/useDimensions.ts +8 -0
  105. package/reactHooks/navigation/__mocks__/useNavigation.ts +3 -0
  106. package/reactHooks/navigation/__tests__/index.test.tsx +6 -21
  107. package/reactHooks/navigation/getTabBarHeight.ts +10 -0
  108. package/reactHooks/navigation/index.ts +34 -236
  109. package/reactHooks/navigation/useGetBottomTabBarHeight.ts +19 -0
  110. package/reactHooks/navigation/useGetNavBarTopBorderWidth.ts +14 -0
  111. package/reactHooks/navigation/useIsScreenActive.ts +17 -0
  112. package/reactHooks/navigation/useNavigationPluginData.ts +19 -0
  113. package/reactHooks/navigation/useNavigationType.ts +17 -0
  114. package/reactHooks/navigation/usePathname.ts +4 -0
  115. package/reactHooks/navigation/useProfilerLogging.ts +15 -0
  116. package/reactHooks/navigation/useRoute.ts +98 -0
  117. package/reactHooks/navigation/useUniqueRouteSuffix.ts +41 -0
  118. package/reactHooks/player/TVSeekControlller/ISeekController.ts +32 -0
  119. package/reactHooks/player/TVSeekControlller/LongPressSeekController.ts +71 -0
  120. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +258 -0
  121. package/reactHooks/player/TVSeekControlller/TapSeekController.ts +53 -0
  122. package/reactHooks/player/__tests__/{useAutoSeek.test.tsx → useAutoSeek._test.tsx} +2 -3
  123. package/reactHooks/player/const.ts +0 -4
  124. package/reactHooks/player/index.ts +0 -6
  125. package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +69 -0
  126. package/reactHooks/screen/useScreenBackgroundColor.ts +3 -15
  127. package/reactHooks/state/README.md +79 -0
  128. package/reactHooks/state/ZStoreProvider.tsx +71 -0
  129. package/reactHooks/state/__tests__/ZStoreProvider.test.tsx +66 -0
  130. package/reactHooks/state/index.ts +2 -0
  131. package/reactHooks/state/useRefWithInitialValue.ts +14 -0
  132. package/reactHooks/state/useStateFromSubscribe.ts +23 -0
  133. package/reactHooks/useListenEventBusEvent.ts +1 -1
  134. package/reactHooks/usePluginConfiguration.ts +1 -1
  135. package/reactHooks/useSubscriberFor.ts +4 -3
  136. package/reactUtils/__tests__/__snapshots__/reactUtilsHelpers.test.js.snap +16 -4
  137. package/reactUtils/__tests__/reactUtils.test.js +1 -37
  138. package/reactUtils/__tests__/reactUtilsHelpers.test.js +72 -71
  139. package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +13 -79
  140. package/reactUtils/createContext/__tests__/__snapshots__/{index.test.js.snap → index.test.ts.snap} +2 -2
  141. package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -28
  142. package/reactUtils/createContext/__tests__/__snapshots__/withConsumer.test.js.snap +3 -4
  143. package/reactUtils/createContext/__tests__/__snapshots__/withProvider.test.js.snap +7 -3
  144. package/reactUtils/createContext/__tests__/helpers.test.js +107 -121
  145. package/reactUtils/createContext/__tests__/{index.test.js → index.test.ts} +2 -2
  146. package/reactUtils/createContext/__tests__/provider.test.js +4 -6
  147. package/reactUtils/createContext/__tests__/withConsumer.test.js +12 -12
  148. package/reactUtils/createContext/__tests__/withProvider.test.js +4 -4
  149. package/reactUtils/createContext/helpers.ts +6 -1
  150. package/reactUtils/createContext/index.ts +11 -25
  151. package/reactUtils/index.ts +9 -11
  152. package/screenState/index.ts +24 -10
  153. package/services/js2native.ts +673 -0
  154. package/testUtils/index.tsx +0 -10
  155. package/theme/__mocks__/index.ts +4 -0
  156. package/theme/index.ts +1 -1
  157. package/time/BackgroundTimer.ts +55 -0
  158. package/time/Timer.ts +9 -6
  159. package/typeGuards/index.ts +3 -0
  160. package/types.ts +1 -0
  161. package/utils/README.md +30 -0
  162. package/utils/chunk.ts +5 -0
  163. package/utils/index.ts +5 -0
  164. package/utils/times.ts +5 -0
  165. package/zappFrameworkUtils/localStorageHelper.ts +38 -10
  166. package/zappFrameworkUtils/loginPluginUtils.ts +6 -2
  167. package/zappFrameworkUtils/presentPluginOneTime.ts +2 -3
  168. package/zappFrameworkUtils/types.ts +11 -0
  169. package/reactHooks/player/useAutoSeek.tsx +0 -87
  170. package/reactHooks/player/useSeek.tsx +0 -66
  171. package/reactHooks/player/useTapSeek.tsx +0 -58
  172. package/reactUtils/createContext/__tests__/index-no-react.test.js +0 -27
  173. /package/reactHooks/player/__tests__/{useTapSeek.test.ts → useTapSeek._test.ts} +0 -0
@@ -5,14 +5,14 @@ import { ActionExecutorContext } from "@applicaster/zapp-react-native-utils/acti
5
5
 
6
6
  import { waitFor } from "@testing-library/react-native";
7
7
 
8
- const navigator = {
8
+ const mockNavigator = {
9
9
  getPathname: () => "pathnameMock",
10
10
  push: jest.fn(),
11
11
  data: {},
12
12
  };
13
13
 
14
14
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
15
- useNavigation: () => navigator,
15
+ useNavigation: () => mockNavigator,
16
16
  useRoute: () => ({ pathname: "pathnameMock" }),
17
17
  useProfilerLogging: () => {
18
18
  return jest.fn();
@@ -25,7 +25,15 @@ jest.mock("@applicaster/zapp-react-native-utils/analyticsUtils/", () => ({
25
25
  }),
26
26
  }));
27
27
 
28
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
29
+ useTargetScreenData: jest.fn(() => ({})),
30
+ useCurrentScreenData: jest.fn(() => ({})),
31
+ }));
32
+
28
33
  jest.mock("@applicaster/zapp-react-native-ui-components/Contexts", () => ({
34
+ ...jest.requireActual(
35
+ "@applicaster/zapp-react-native-ui-components/Contexts"
36
+ ),
29
37
  ZappPipesEntryContext: {
30
38
  useZappPipesContext: jest.fn(() => [undefined, jest.fn()]),
31
39
  },
@@ -16,6 +16,7 @@ import { ActionExecutorContext } from "@applicaster/zapp-react-native-utils/acti
16
16
  import { isFunction, noop } from "../../functionUtils";
17
17
  import { useSendAnalyticsOnPress } from "../analytics";
18
18
  import { logOnPress, warnEmptyContentType } from "./helpers";
19
+ import { useCurrentScreenData } from "../screen";
19
20
 
20
21
  /**
21
22
  * If onCellTap is defined execute the function and
@@ -44,6 +45,7 @@ export const useCellClick = ({
44
45
 
45
46
  const onCellTap: Option<Function> = React.useContext(CellTapContext);
46
47
  const actionExecutor = React.useContext(ActionExecutorContext);
48
+ const screenData = useCurrentScreenData();
47
49
 
48
50
  const cellSelectable = toBooleanWithDefaultTrue(
49
51
  component?.rules?.component_cells_selectable
@@ -78,7 +80,10 @@ export const useCellClick = ({
78
80
  logOnPress(selectedItem, pathname, component, onCellTap);
79
81
 
80
82
  if (selectedItem) {
81
- await actionExecutor?.handleEntryActions(selectedItem);
83
+ await actionExecutor?.handleEntryActions(selectedItem, {
84
+ component,
85
+ screenData,
86
+ });
82
87
  }
83
88
 
84
89
  if (selectedItem?.type?.value === "action") {
@@ -111,6 +116,7 @@ export const useCellClick = ({
111
116
  pathname,
112
117
  push,
113
118
  sendAnalyticsOnPress,
119
+ screenData,
114
120
  ]
115
121
  );
116
122
 
@@ -7,12 +7,12 @@ const appData = {
7
7
  sdk_version: "2.0.0",
8
8
  };
9
9
 
10
- let INFLATED_URL;
10
+ const mockUseInflatedUrl = jest.fn();
11
11
 
12
12
  jest.mock(
13
13
  "@applicaster/zapp-react-native-utils/reactHooks/feed/useInflatedUrl",
14
14
  () => ({
15
- useInflatedUrl: () => INFLATED_URL,
15
+ useInflatedUrl: mockUseInflatedUrl,
16
16
  })
17
17
  );
18
18
 
@@ -20,7 +20,7 @@ const { useBuildPipesUrl } = require("../useBuildPipesUrl");
20
20
 
21
21
  describe("useBuildPipesUrl", () => {
22
22
  it("returns the proper url", async () => {
23
- INFLATED_URL = "http://foo.com/show/show-1";
23
+ mockUseInflatedUrl.mockReturnValue("http://foo.com/show/show-1");
24
24
  const url = "http://foo.com/show/{{showId}}";
25
25
 
26
26
  const mapping = {
@@ -65,7 +65,7 @@ describe("useBuildPipesUrl", () => {
65
65
  });
66
66
 
67
67
  it("returns empty object if url is not in endpoints", async () => {
68
- INFLATED_URL = "http://foobar.com/show-1";
68
+ mockUseInflatedUrl.mockReturnValue("http://foobar.com/show-1");
69
69
  const url = "http://foobar.com/{{showId}}";
70
70
 
71
71
  const mapping = {
@@ -6,42 +6,41 @@ import { Provider } from "react-redux";
6
6
  import * as React from "react";
7
7
  import configureStore from "redux-mock-store";
8
8
  import thunk from "redux-thunk";
9
- import * as navigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
9
+ import * as useRouteHook from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute";
10
10
  import * as useNavigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
11
+ import { useFeedLoader } from "../useFeedLoader";
11
12
 
12
13
  const mockStore = configureStore([thunk]);
13
14
 
14
- jest.useFakeTimers();
15
+ jest.useFakeTimers({ legacyFakeTimers: true });
15
16
 
16
- const logger = {
17
+ const mockLogger = {
17
18
  warning: jest.fn(),
18
19
  log: jest.fn(),
19
20
  info: jest.fn(),
20
21
  };
21
22
 
22
- const navigator = {
23
+ const mockNavigator: any = {
23
24
  currentRoute: "/river/A1234",
24
25
  getStack: jest.fn(() => []),
25
26
  };
26
27
 
27
- const routeData = {
28
+ const mockRouteData: any = {
28
29
  screenData: {},
29
30
  pathname: "/river/A1234",
30
31
  };
31
32
 
32
- jest.mock("../../logger", () => ({
33
+ jest.doMock("../../logger", () => ({
33
34
  reactHooksLogger: {
34
- addSubsystem: jest.fn(() => logger),
35
+ addSubsystem: jest.fn(() => mockLogger),
35
36
  },
36
37
  }));
37
38
 
38
39
  jest
39
40
  .spyOn(useNavigationHooks, "useNavigation")
40
- .mockImplementation(() => navigator);
41
+ .mockImplementation(() => mockNavigator);
41
42
 
42
- jest.spyOn(navigationHooks, "useRoute").mockImplementation(() => routeData);
43
-
44
- const { useFeedLoader } = require("../useFeedLoader");
43
+ jest.spyOn(useRouteHook, "useRoute").mockImplementation(() => mockRouteData);
45
44
 
46
45
  const mockZappPipesData = {
47
46
  data: {
@@ -1,7 +1,7 @@
1
- import { isNil, complement, compose, map, min, prop, take, uniq } from "ramda";
1
+ import { complement, compose, isNil, map, min, prop, take, uniq } from "ramda";
2
2
  import { useDispatch } from "react-redux";
3
3
  import * as React from "react";
4
- import { useZappPipesFeeds } from "@applicaster/zapp-react-native-redux/hooks/useZappPipesFeeds";
4
+ import { useZappPipesFeeds } from "@applicaster/zapp-react-native-redux/hooks";
5
5
  import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
6
6
  import { isNilOrEmpty } from "../../reactUtils/helpers";
7
7
  import { ZappPipesSearchContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
@@ -9,6 +9,7 @@ import {
9
9
  getInflatedDataSourceUrl,
10
10
  getSearchContext,
11
11
  } from "@applicaster/zapp-react-native-utils/reactHooks";
12
+ import { isGallery } from "@applicaster/zapp-react-native-utils/componentsUtils";
12
13
  import { useScreenContext } from "../screen/useScreenContext";
13
14
 
14
15
  type Options = {
@@ -46,9 +47,7 @@ const filterEmptyData = (data) => {
46
47
  };
47
48
 
48
49
  const getData = (rawData) =>
49
- rawData.component_type === "gallery-qb"
50
- ? rawData.ui_components[0].data
51
- : rawData.data;
50
+ isGallery(rawData) ? rawData.ui_components[0].data : rawData.data;
52
51
 
53
52
  const extractData = compose(uniq, map(getData));
54
53
 
@@ -70,13 +69,12 @@ export const useBatchLoading = (
70
69
  const [hasEverBeenReady, setHasEverBeenReady] = React.useState(false);
71
70
 
72
71
  // if first component is gallery-qb, take only one component for initial load
73
- const takeSize =
74
- componentsToRender?.[0]?.component_type === "gallery-qb"
75
- ? 1
76
- : min(
77
- options.initialBatchSize ?? DEFAULT_BATCH_SIZE,
78
- componentsToRender.length
79
- );
72
+ const takeSize = isGallery(componentsToRender?.[0])
73
+ ? 1
74
+ : min(
75
+ options.initialBatchSize ?? DEFAULT_BATCH_SIZE,
76
+ componentsToRender.length
77
+ );
80
78
 
81
79
  const takeBatchSize = React.useCallback(take(takeSize), [takeSize]);
82
80
 
@@ -5,7 +5,7 @@ import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
5
5
  import { useZappPipesFeed } from "@applicaster/zapp-react-native-redux/hooks";
6
6
 
7
7
  import { reactHooksLogger } from "../logger";
8
- import { useIsInitialRender, shouldDispatchData } from "../utils";
8
+ import { shouldDispatchData, useIsInitialRender } from "../utils";
9
9
  import { useInflatedUrl } from "./useInflatedUrl";
10
10
  import { useRoute } from "../navigation";
11
11
 
@@ -20,6 +20,7 @@ type Props = {
20
20
  silentRefresh?: boolean;
21
21
  method?: "get" | "post";
22
22
  bodyParams?: Record<string, unknown>;
23
+ skipLoading?: boolean;
23
24
  };
24
25
  };
25
26
 
@@ -55,7 +56,9 @@ export const useFeedLoader = ({
55
56
 
56
57
  const currentFeed = useZappPipesFeed(callableFeedUrl);
57
58
 
58
- const riverId = screenData?.id;
59
+ const riverId =
60
+ (screenData as LegacyNavigationScreenData)?.targetScreen?.id ??
61
+ screenData?.id;
59
62
 
60
63
  const reloadData = React.useCallback<ReloadDataFunction>(
61
64
  (silentRefresh = true, callback) => {
@@ -87,13 +90,13 @@ export const useFeedLoader = ({
87
90
  );
88
91
  }
89
92
  }
90
- }, [callableFeedUrl, currentFeed?.data]);
93
+ }, [callableFeedUrl, currentFeed?.data?.next]);
91
94
 
92
95
  useEffect(() => {
93
96
  if (
94
97
  shouldDispatchData(callableFeedUrl, currentFeed, pipesOptions.clearCache)
95
98
  ) {
96
- if (callableFeedUrl) {
99
+ if (callableFeedUrl && !pipesOptions.skipLoading) {
97
100
  dispatch(
98
101
  loadPipesData(callableFeedUrl, {
99
102
  ...pipesOptions,
@@ -101,26 +104,33 @@ export const useFeedLoader = ({
101
104
  riverId,
102
105
  })
103
106
  );
104
- } else {
107
+ } else if (!callableFeedUrl) {
105
108
  logger.info({
106
109
  message:
107
110
  "Feed is not defined or not inflated, skipping loading. \nMake sure you have correct feedUrl and mapping.",
108
111
  jsOnly: true,
109
112
  });
113
+ } else {
114
+ logger.info({
115
+ message:
116
+ "Loading skipped as per pipesOptions.skipLoading configuration.",
117
+ data: { url: callableFeedUrl },
118
+ jsOnly: true,
119
+ });
110
120
  }
111
121
  } else {
112
122
  logger.info({
113
123
  message:
114
- "Feed already exist, skipping loading. \nCall reloadData() if you want to refresh data.",
124
+ "Feed already exists, skipping loading. \nCall reloadData() if you want to refresh data.",
115
125
  data: { url: callableFeedUrl },
116
126
  jsOnly: true,
117
127
  });
118
128
  }
119
129
  }, []);
120
130
 
121
- // Reload feed when feedUrl changes
131
+ // Reload feed when feedUrl changes, unless skipLoading is true
122
132
  useEffect(() => {
123
- if (!isInitialRender && callableFeedUrl) {
133
+ if (!isInitialRender && callableFeedUrl && !pipesOptions.skipLoading) {
124
134
  dispatch(loadPipesData(callableFeedUrl, { ...pipesOptions, riverId }));
125
135
  }
126
136
  }, [callableFeedUrl]);
@@ -156,7 +166,6 @@ export const useFeedLoader = ({
156
166
  currentFeed?.data,
157
167
  currentFeed?.error,
158
168
  currentFeed?.loading,
159
-
160
169
  reloadData,
161
170
  loadNext,
162
171
  ]);
@@ -1,12 +1,12 @@
1
1
  import React from "react";
2
2
  import { useDispatch } from "react-redux";
3
- import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
4
- import {
5
- getDatasourceUrl,
6
- usePipesContexts,
7
- } from "@applicaster/zapp-react-native-ui-components/Decorators/RiverFeedLoader/utils";
3
+
4
+ import { getDatasourceUrl } from "@applicaster/zapp-react-native-ui-components/Decorators/RiverFeedLoader/utils/getDatasourceUrl";
5
+ import { usePipesContexts } from "@applicaster/zapp-react-native-ui-components/Decorators/RiverFeedLoader/utils/usePipesContexts";
8
6
  import { clearPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
9
7
 
8
+ import { useRoute } from "../navigation/useRoute";
9
+
10
10
  /**
11
11
  * reset river components cache when screen is unmounted
12
12
  * @param {string} riverId screen id
@@ -1,6 +1,5 @@
1
1
  import * as React from "react";
2
- import { renderHook, act } from "@testing-library/react-hooks";
3
- import { render } from "@testing-library/react-native";
2
+ import { renderHook, render, act } from "@testing-library/react-native";
4
3
  import { View } from "react-native";
5
4
 
6
5
  import { useSequentialLoader, useSequentialRenderItem } from "..";
@@ -66,26 +65,28 @@ describe("flatList hooks", () => {
66
65
 
67
66
  expect(result.current.allLoaded).toBe(false);
68
67
 
69
- result.current.renderItem(
70
- ({ onLoadFinished }) => {
71
- onLoadFinished();
72
- },
73
- { index: 1 }
74
- );
68
+ act(() => {
69
+ result.current.renderItem(
70
+ ({ onLoadFinished }) => {
71
+ onLoadFinished();
72
+ },
73
+ { index: 1 }
74
+ );
75
+ });
75
76
 
76
77
  expect(result.current.allLoaded).toBe(true);
77
78
  });
78
79
  });
79
80
 
80
81
  describe("Rendering wrapper", () => {
81
- it("wraps the elements in the View with display: none style", () => {
82
+ it("wraps the elements in the View with display: none style", async () => {
82
83
  const element1 = { id: 1 };
83
84
  const element2 = { id: 2 };
84
85
  const mockData = [element1, element2];
85
86
 
86
87
  const { result } = renderHook(() => useSequentialRenderItem(mockData));
87
88
 
88
- const { getByTestId } = render(
89
+ const res = render(
89
90
  result.current.renderItem(
90
91
  () => {
91
92
  return <View testID={"test"} />;
@@ -94,7 +95,9 @@ describe("flatList hooks", () => {
94
95
  )
95
96
  );
96
97
 
97
- const element = getByTestId("sequential-river-wrapper-1");
98
+ const element = res.root.findByProps({
99
+ testID: "sequential-river-wrapper-1",
100
+ });
98
101
 
99
102
  expect(element.props.style.display).toEqual("none");
100
103
  });
@@ -106,14 +109,16 @@ describe("flatList hooks", () => {
106
109
 
107
110
  const { result } = renderHook(() => useSequentialRenderItem(mockData));
108
111
 
109
- result.current.renderItem(
110
- ({ onLoadFinished }) => {
111
- onLoadFinished();
112
- },
113
- { item: element1, index: 0 }
114
- );
112
+ act(() => {
113
+ result.current.renderItem(
114
+ ({ onLoadFinished }) => {
115
+ onLoadFinished();
116
+ },
117
+ { item: element1, index: 0 }
118
+ );
119
+ });
115
120
 
116
- const { getByTestId } = render(
121
+ const { root } = render(
117
122
  result.current.renderItem(
118
123
  ({ onLoadFinished }) => {
119
124
  onLoadFinished();
@@ -124,7 +129,9 @@ describe("flatList hooks", () => {
124
129
  )
125
130
  );
126
131
 
127
- const element = getByTestId("sequential-river-wrapper-1");
132
+ const element = root.findByProps({
133
+ testID: "sequential-river-wrapper-1",
134
+ });
128
135
 
129
136
  expect(element.props.style.display).toEqual("flex");
130
137
  });
@@ -136,7 +143,7 @@ describe("flatList hooks", () => {
136
143
 
137
144
  const { result } = renderHook(() => useSequentialRenderItem(mockData));
138
145
 
139
- const { getByTestId } = render(
146
+ const { root } = render(
140
147
  result.current.renderItem(
141
148
  ({ onLoadFinished }) => {
142
149
  onLoadFinished();
@@ -147,7 +154,9 @@ describe("flatList hooks", () => {
147
154
  )
148
155
  );
149
156
 
150
- const element = getByTestId("sequential-river-wrapper-1");
157
+ const element = root.findByProps({
158
+ testID: "sequential-river-wrapper-1",
159
+ });
151
160
 
152
161
  expect(element.props.style.display).toEqual("none");
153
162
  });
@@ -0,0 +1,39 @@
1
+ import { reactHooksLogger } from "../../logger";
2
+ import { useZappHooksModalState } from "@applicaster/zapp-react-dom-ui-components/Components/ZappHooksModal/hooks/useZappHooksModalState";
3
+
4
+ const logger = reactHooksLogger.addSubsystem("useHookModalScreenData");
5
+
6
+ type VariousScreenData = LegacyNavigationScreenData | ZappRiver | ZappEntry;
7
+
8
+ export const useHookModalScreenData = (): VariousScreenData | undefined => {
9
+ const hookModalState = useZappHooksModalState();
10
+
11
+ if (!hookModalState.state?.screenData) {
12
+ return;
13
+ }
14
+
15
+ try {
16
+ const screenData = hookModalState.state.screenData?.payload;
17
+ const hookPlugin = hookModalState.state.screenData.hookPlugin;
18
+
19
+ if (hookPlugin?.screen_id) {
20
+ return {
21
+ ...screenData,
22
+ targetScreen: hookPlugin,
23
+ };
24
+ }
25
+
26
+ return hookModalState.state.screenData?.payload;
27
+ } catch (error) {
28
+ logger.error({
29
+ message: "Hook modal screen data creation failed",
30
+ data: {
31
+ error,
32
+ hookModalState,
33
+ },
34
+ jsOnly: true,
35
+ });
36
+
37
+ return hookModalState.state.screenData?.payload;
38
+ }
39
+ };
@@ -14,10 +14,10 @@ const mocked_return_value = (tv) => ({
14
14
  });
15
15
 
16
16
  const platform = "android";
17
- let tv_flag = false;
17
+ let mock_tv_flag = false;
18
18
 
19
19
  ReactNative.Dimensions.get = jest.fn(
20
- (context) => mocked_return_value(tv_flag)[context]
20
+ (context) => mocked_return_value(mock_tv_flag)[context]
21
21
  );
22
22
 
23
23
  const mockRemoveFn = jest.fn();
@@ -43,7 +43,7 @@ jest.mock("react-native-safe-area-context", () => ({
43
43
 
44
44
  jest.mock("../../../reactUtils", () => ({
45
45
  platformSelect: jest.fn((specs) => specs[platform] || specs.default),
46
- isTV: jest.fn(() => tv_flag),
46
+ isTV: jest.fn(() => mock_tv_flag),
47
47
  }));
48
48
 
49
49
  jest.mock("../../navigation", () => ({
@@ -134,20 +134,20 @@ describe("useDimensions", () => {
134
134
 
135
135
  describe("it applies the scale to the width & height if needed", () => {
136
136
  it("applies the scale on TV, and screen context", () => {
137
- tv_flag = true;
138
- const { screen } = mocked_return_value(tv_flag);
137
+ mock_tv_flag = true;
138
+ const { screen } = mocked_return_value(mock_tv_flag);
139
139
  const { dimensions } = testHook("screen");
140
140
 
141
141
  expect(dimensions).toHaveProperty("height", screen.height * screen.scale);
142
142
  expect(dimensions).toHaveProperty("width", screen.width * screen.scale);
143
143
  expect(dimensions).toHaveProperty("scale", 1);
144
144
 
145
- tv_flag = false;
145
+ mock_tv_flag = false;
146
146
  });
147
147
 
148
148
  it("doesn't apply the scale on mobile with screen context", () => {
149
- tv_flag = false;
150
- const { screen } = mocked_return_value(tv_flag);
149
+ mock_tv_flag = false;
150
+ const { screen } = mocked_return_value(mock_tv_flag);
151
151
  const { dimensions } = testHook("screen");
152
152
 
153
153
  expect(dimensions).toHaveProperty("height", screen.height);
@@ -156,8 +156,8 @@ describe("useDimensions", () => {
156
156
  });
157
157
 
158
158
  it("doesn't apply the scale on TV with window context", () => {
159
- tv_flag = true;
160
- const { window } = mocked_return_value(tv_flag);
159
+ mock_tv_flag = true;
160
+ const { window } = mocked_return_value(mock_tv_flag);
161
161
  const { dimensions } = testHook("window");
162
162
 
163
163
  expect(dimensions).toHaveProperty("height", window.height);
@@ -1,25 +1,14 @@
1
1
  import * as ReactNative from "react-native";
2
+ import NativeDeviceInfo from "react-native/Libraries/Utilities/NativeDeviceInfo";
2
3
 
3
- const mockDimensionsGet = jest.fn(
4
- (type) =>
5
- ({
6
- window: { width: 1, height: 1 },
7
- screen: { width: 360, height: 540 },
8
- }[type])
9
- );
4
+ const mockDimensions = {
5
+ window: { width: 1, height: 1 },
6
+ screen: { width: 360, height: 540 },
7
+ };
10
8
 
11
- ReactNative.Dimensions.get = mockDimensionsGet;
12
-
13
- const mockGetConstants = jest.fn().mockReturnValue({
14
- Dimensions: {
15
- window: { width: 360, height: 540 },
16
- screen: { width: 360, height: 540 },
17
- },
18
- });
9
+ const mockDimensionsGet = jest.fn((type) => mockDimensions[type]);
19
10
 
20
- jest.mock("react-native/Libraries/Utilities/NativeDeviceInfo", () => ({
21
- getConstants: mockGetConstants,
22
- }));
11
+ ReactNative.Dimensions.get = mockDimensionsGet;
23
12
 
24
13
  const { Platform, Dimensions } = ReactNative;
25
14
 
@@ -34,27 +23,24 @@ describe("useDimensions > helpers ( native )", () => {
34
23
 
35
24
  it("should call Dimensions.get for window context", () => {
36
25
  getInitialDimensions("window");
37
- expect(Dimensions.get).toBeCalled();
26
+ expect(Dimensions.get).toHaveBeenCalled();
38
27
  });
39
28
 
40
29
  it("should call Dimensions.get for screen context", () => {
41
30
  getInitialDimensions("screen");
42
- expect(Dimensions.get).toBeCalled();
31
+ expect(Dimensions.get).toHaveBeenCalled();
43
32
  });
44
33
 
45
34
  it("should call NativeDeviceInfo.getConstants for ios when width === height", () => {
46
35
  Platform.OS = "ios";
47
36
 
48
- jest.fn().mockReturnValue({
49
- Dimensions: {
50
- window: { width: 1, height: 1 },
51
- screen: { width: 360, height: 540 },
52
- },
53
- });
37
+ const mockGetConstants = jest
38
+ .spyOn(NativeDeviceInfo, "getConstants")
39
+ .mockReturnValue({ Dimensions: mockDimensions });
54
40
 
55
41
  getInitialDimensions("window");
56
42
 
57
- expect(Dimensions.get).toBeCalled();
58
- expect(mockGetConstants).toBeCalled();
43
+ expect(Dimensions.get).toHaveBeenCalled();
44
+ expect(mockGetConstants).toHaveBeenCalled();
59
45
  });
60
46
  });
@@ -5,7 +5,7 @@ const mockDimensionsGet = jest.fn(
5
5
  ({
6
6
  window: { width: 1, height: 1 },
7
7
  screen: { width: 360, height: 540 },
8
- }[type])
8
+ })[type]
9
9
  );
10
10
 
11
11
  ReactNative.Dimensions.get = mockDimensionsGet;
@@ -52,6 +52,14 @@ export const useDimensions: UseDimensions = (
52
52
  ? { fullDimensions }
53
53
  : { ...fullDimensions };
54
54
 
55
+ if (options.updateForInactiveScreens === undefined) {
56
+ options.updateForInactiveScreens = true;
57
+ }
58
+
59
+ if (options.fullDimensions === undefined) {
60
+ options.fullDimensions = false;
61
+ }
62
+
55
63
  const [dimensions, setDimensions] = useState(getInitialDimensions(context));
56
64
  const deviceInfo = useRef(getDeviceInfo(dimensions, appData));
57
65
 
@@ -3,5 +3,8 @@ export const useNavigation = jest.fn(() => ({
3
3
  screenData: {
4
4
  name: "someName",
5
5
  },
6
+ videoModalState: {
7
+ visible: false,
8
+ },
6
9
  currentRoute: "someRoute",
7
10
  }));