@applicaster/zapp-react-native-utils 15.1.0-rc.9 → 16.0.0-alpha.1833861900

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 (146) hide show
  1. package/README.md +0 -6
  2. package/actionUtils/index.ts +7 -0
  3. package/actionsExecutor/ActionExecutorContext.tsx +43 -12
  4. package/actionsExecutor/feedDecorator.ts +6 -6
  5. package/adsUtils/__tests__/createVMAP.test.ts +419 -0
  6. package/adsUtils/index.ts +2 -2
  7. package/analyticsUtils/PlayerAnalyticsManager.ts +11 -1
  8. package/analyticsUtils/README.md +1 -1
  9. package/analyticsUtils/playerAnalyticsTracker.ts +26 -3
  10. package/appDataUtils/__tests__/urlScheme.test.ts +678 -0
  11. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +0 -188
  12. package/appUtils/HooksManager/__tests__/hooksManager.test.js +16 -2
  13. package/appUtils/HooksManager/index.ts +12 -18
  14. package/appUtils/RiverFocusManager/{index.js → index.ts} +25 -18
  15. package/appUtils/accessibilityManager/const.ts +4 -0
  16. package/appUtils/accessibilityManager/utils.ts +0 -1
  17. package/appUtils/contextKeysManager/__tests__/getKeys/failure.test.ts +7 -2
  18. package/appUtils/contextKeysManager/__tests__/getKeys/success.test.ts +48 -0
  19. package/appUtils/contextKeysManager/contextResolver.ts +51 -22
  20. package/appUtils/contextKeysManager/index.ts +65 -10
  21. package/appUtils/contextKeysManager/utils/index.ts +38 -25
  22. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +3 -0
  23. package/appUtils/focusManager/index.ios.ts +43 -4
  24. package/appUtils/focusManager/treeDataStructure/Tree/__tests__/Tree.test.js +46 -0
  25. package/appUtils/focusManager/treeDataStructure/Tree/index.js +18 -18
  26. package/appUtils/focusManagerAux/utils/index.ios.ts +122 -0
  27. package/appUtils/focusManagerAux/utils/index.ts +11 -3
  28. package/appUtils/focusManagerAux/utils/utils.ios.ts +202 -3
  29. package/appUtils/keyCodes/keys/keys.web.ts +1 -4
  30. package/appUtils/orientationHelper.ts +2 -4
  31. package/appUtils/platform/platformUtils.ts +12 -1
  32. package/appUtils/playerManager/player.ts +4 -0
  33. package/appUtils/playerManager/playerNative.ts +30 -21
  34. package/appUtils/playerManager/usePlayerState.tsx +14 -2
  35. package/cloudEventsUtils/__tests__/index.test.ts +529 -0
  36. package/cloudEventsUtils/index.ts +65 -1
  37. package/componentsUtils/index.ts +8 -0
  38. package/configurationUtils/__tests__/manifestKeyParser.test.ts +26 -26
  39. package/enumUtils/__tests__/getEnumKeyByEnumValue.test.ts +207 -0
  40. package/errorUtils/__tests__/GeneralError.test.ts +97 -0
  41. package/errorUtils/__tests__/HttpStatusCode.test.ts +344 -0
  42. package/errorUtils/__tests__/MissingPluginError.test.ts +113 -0
  43. package/errorUtils/__tests__/NetworkError.test.ts +202 -0
  44. package/errorUtils/__tests__/getParsedResponse.test.ts +188 -0
  45. package/errorUtils/__tests__/invariant.test.ts +112 -0
  46. package/focusManager/aux/index.ts +1 -1
  47. package/headersUtils/__tests__/headersUtils.test.js +11 -1
  48. package/headersUtils/index.ts +2 -1
  49. package/manifestUtils/_internals/__tests__/index.test.js +41 -0
  50. package/manifestUtils/_internals/index.js +33 -0
  51. package/manifestUtils/defaultManifestConfigurations/player.js +59 -1
  52. package/manifestUtils/fieldUtils/__tests__/fieldUtils.test.js +49 -0
  53. package/manifestUtils/fieldUtils/index.js +54 -0
  54. package/manifestUtils/index.js +3 -1
  55. package/manifestUtils/keys.js +228 -0
  56. package/manifestUtils/mobileAction/button/__tests__/mobileActionButton.test.js +168 -0
  57. package/manifestUtils/mobileAction/button/index.js +140 -0
  58. package/manifestUtils/mobileAction/container/__tests__/mobileActionButtonsContainer.test.js +102 -0
  59. package/manifestUtils/mobileAction/container/index.js +73 -0
  60. package/manifestUtils/mobileAction/groups/__tests__/buildMobileActionButtonGroups.test.js +127 -0
  61. package/manifestUtils/mobileAction/groups/defaults.js +76 -0
  62. package/manifestUtils/mobileAction/groups/index.js +80 -0
  63. package/manifestUtils/tvAction/container/index.js +1 -1
  64. package/numberUtils/__tests__/toNumber.test.ts +27 -0
  65. package/numberUtils/__tests__/toPositiveNumber.test.ts +193 -0
  66. package/numberUtils/index.ts +23 -1
  67. package/package.json +4 -4
  68. package/pluginUtils/index.ts +4 -0
  69. package/reactHooks/advertising/index.ts +2 -2
  70. package/reactHooks/analytics/__tests__/useSendAnalyticsOnPress.test.ts +537 -0
  71. package/reactHooks/app/__tests__/useAppState.test.ts +1 -1
  72. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  73. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -2
  74. package/reactHooks/cell-click/__tests__/index.test.js +1 -3
  75. package/reactHooks/cell-click/index.ts +2 -1
  76. package/reactHooks/configuration/__tests__/index.test.tsx +1 -1
  77. package/reactHooks/connection/__tests__/index.test.js +1 -1
  78. package/reactHooks/debugging/__tests__/index.test.js +4 -4
  79. package/reactHooks/dev/__tests__/useReRenderLog.test.ts +188 -0
  80. package/reactHooks/device/useIsTablet.tsx +14 -19
  81. package/reactHooks/device/useMemoizedIsTablet.ts +3 -3
  82. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +32 -23
  83. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +19 -19
  84. package/reactHooks/feed/__tests__/useEntryScreenId.test.tsx +4 -1
  85. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +42 -30
  86. package/reactHooks/feed/__tests__/useInflatedUrl.test.tsx +1 -1
  87. package/reactHooks/feed/index.ts +0 -2
  88. package/reactHooks/feed/useBatchLoading.ts +7 -1
  89. package/reactHooks/feed/useEntryScreenId.ts +2 -2
  90. package/reactHooks/feed/usePipesCacheReset.ts +3 -1
  91. package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +13 -16
  92. package/reactHooks/layout/__tests__/index.test.tsx +1 -1
  93. package/reactHooks/layout/__tests__/useLayoutVersion.test.tsx +1 -1
  94. package/reactHooks/layout/useDimensions/__tests__/{useDimensions.test.ts → useDimensions.test.tsx} +105 -25
  95. package/reactHooks/layout/useDimensions/useDimensions.ts +2 -2
  96. package/reactHooks/navigation/__tests__/index.test.tsx +2 -4
  97. package/reactHooks/navigation/index.ts +7 -6
  98. package/reactHooks/navigation/useRoute.ts +8 -6
  99. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +27 -10
  100. package/reactHooks/player/__tests__/useAutoSeek._test.tsx +1 -1
  101. package/reactHooks/player/__tests__/useTapSeek._test.ts +1 -1
  102. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +1 -1
  103. package/reactHooks/resolvers/__tests__/useComponentResolver.test.tsx +1 -1
  104. package/reactHooks/resolvers/useCellResolver.ts +6 -2
  105. package/reactHooks/resolvers/useComponentResolver.ts +8 -2
  106. package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +2 -2
  107. package/reactHooks/screen/__tests__/useIsStandaloneFullscreen.test.ts +114 -0
  108. package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +1 -1
  109. package/reactHooks/screen/__tests__/useScreenData.test.tsx +1 -1
  110. package/reactHooks/screen/__tests__/useTargetScreenData.test.tsx +12 -4
  111. package/reactHooks/screen/useTargetScreenData.ts +4 -2
  112. package/reactHooks/state/useRivers.ts +1 -1
  113. package/reactHooks/ui/__tests__/useFadeOutWhenBlurred.test.ts +580 -0
  114. package/reactHooks/usePluginConfiguration.ts +2 -2
  115. package/reactHooks/utils/__tests__/index.test.js +1 -1
  116. package/rectUtils/__tests__/index.test.ts +549 -0
  117. package/rectUtils/index.ts +2 -2
  118. package/refreshUtils/RefreshCoordinator/__tests__/refreshCoordinator.test.ts +206 -0
  119. package/refreshUtils/RefreshCoordinator/index.ts +245 -0
  120. package/refreshUtils/RefreshCoordinator/utils/__tests__/getDataRefreshConfig.test.ts +104 -0
  121. package/refreshUtils/RefreshCoordinator/utils/index.ts +29 -0
  122. package/screenPickerUtils/__tests__/index.test.ts +333 -0
  123. package/screenState/__tests__/index.test.ts +1 -1
  124. package/screenUtils/index.ts +3 -0
  125. package/searchUtils/const.ts +7 -0
  126. package/searchUtils/index.ts +3 -0
  127. package/stringUtils/index.ts +1 -1
  128. package/testUtils/index.tsx +30 -21
  129. package/time/__tests__/BackgroundTimer.test.ts +156 -0
  130. package/time/__tests__/Timer.test.ts +236 -0
  131. package/typeGuards/__tests__/isString.test.ts +21 -0
  132. package/typeGuards/index.ts +4 -0
  133. package/utils/__tests__/mergeRight.test.ts +48 -0
  134. package/utils/__tests__/path.test.ts +7 -0
  135. package/utils/__tests__/selectors.test.ts +124 -0
  136. package/utils/index.ts +13 -0
  137. package/utils/mergeRight.ts +5 -0
  138. package/utils/path.ts +6 -3
  139. package/utils/pathOr.ts +5 -1
  140. package/utils/selectors.ts +46 -0
  141. package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +1 -1
  142. package/zappFrameworkUtils/HookCallback/hookCallbackManifestExtensions.config.js +1 -1
  143. package/zappFrameworkUtils/loginPluginUtils.ts +1 -1
  144. package/reactHooks/componentsMap/index.ts +0 -55
  145. package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +0 -75
  146. package/reactHooks/feed/useFeedRefresh.tsx +0 -65
@@ -0,0 +1,114 @@
1
+ import { renderHook } from "@testing-library/react-native";
2
+ import { useIsStandaloneFullscreen } from "../useIsStandaloneFullscreen";
3
+
4
+ import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
5
+ import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
6
+
7
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks");
8
+ jest.mock("@applicaster/zapp-react-native-utils/booleanUtils");
9
+
10
+ const mockUseNavigation = useNavigation as jest.Mock;
11
+ const mockToBoolean = toBooleanWithDefaultFalse as jest.Mock;
12
+
13
+ describe("useIsStandaloneFullscreen", () => {
14
+ beforeEach(() => {
15
+ jest.clearAllMocks();
16
+
17
+ mockUseNavigation.mockReturnValue({
18
+ canGoBack: jest.fn().mockReturnValue(false),
19
+ screenData: {
20
+ general: { allow_screen_plugin_presentation: true },
21
+ },
22
+ });
23
+
24
+ mockToBoolean.mockReturnValue(false);
25
+ });
26
+
27
+ it("returns true when cannot go back and screen plugin presentation is allowed", () => {
28
+ mockToBoolean.mockReturnValue(true);
29
+
30
+ const { result } = renderHook(() => useIsStandaloneFullscreen());
31
+
32
+ expect(mockToBoolean).toHaveBeenCalledWith(true);
33
+ expect(result.current).toBe(true);
34
+ });
35
+
36
+ it("returns false when can go back even if screen plugin presentation is allowed", () => {
37
+ mockUseNavigation.mockReturnValue({
38
+ canGoBack: jest.fn().mockReturnValue(true),
39
+ screenData: {
40
+ general: { allow_screen_plugin_presentation: true },
41
+ },
42
+ });
43
+
44
+ mockToBoolean.mockReturnValue(false);
45
+
46
+ const { result } = renderHook(() => useIsStandaloneFullscreen());
47
+
48
+ expect(mockToBoolean).toHaveBeenCalledWith(false);
49
+ expect(result.current).toBe(false);
50
+ });
51
+
52
+ it("returns false when cannot go back but screen plugin presentation is not allowed", () => {
53
+ mockUseNavigation.mockReturnValue({
54
+ canGoBack: jest.fn().mockReturnValue(false),
55
+ screenData: {
56
+ general: { allow_screen_plugin_presentation: false },
57
+ },
58
+ });
59
+
60
+ mockToBoolean.mockReturnValue(false);
61
+
62
+ const { result } = renderHook(() => useIsStandaloneFullscreen());
63
+
64
+ expect(mockToBoolean).toHaveBeenCalledWith(false);
65
+ expect(result.current).toBe(false);
66
+ });
67
+
68
+ it("returns false when screen plugin presentation flag is undefined", () => {
69
+ mockUseNavigation.mockReturnValue({
70
+ canGoBack: jest.fn().mockReturnValue(false),
71
+ screenData: { general: {} },
72
+ });
73
+
74
+ mockToBoolean.mockReturnValue(false);
75
+
76
+ const { result } = renderHook(() => useIsStandaloneFullscreen());
77
+
78
+ expect(mockToBoolean).toHaveBeenCalledWith(undefined);
79
+ expect(result.current).toBe(false);
80
+ });
81
+
82
+ it("returns false when navigator is undefined", () => {
83
+ mockUseNavigation.mockReturnValue(undefined);
84
+ mockToBoolean.mockReturnValue(false);
85
+
86
+ const { result } = renderHook(() => useIsStandaloneFullscreen());
87
+
88
+ expect(mockToBoolean).toHaveBeenCalledWith(undefined);
89
+ expect(result.current).toBe(false);
90
+ });
91
+
92
+ it("returns false when screenData is undefined", () => {
93
+ mockUseNavigation.mockReturnValue({
94
+ canGoBack: jest.fn().mockReturnValue(false),
95
+ screenData: undefined,
96
+ });
97
+
98
+ mockToBoolean.mockReturnValue(false);
99
+
100
+ const { result } = renderHook(() => useIsStandaloneFullscreen());
101
+
102
+ expect(mockToBoolean).toHaveBeenCalledWith(undefined);
103
+ expect(result.current).toBe(false);
104
+ });
105
+
106
+ it("passes the combined condition through toBooleanWithDefaultFalse", () => {
107
+ mockToBoolean.mockImplementation((val) => Boolean(val));
108
+
109
+ const { result } = renderHook(() => useIsStandaloneFullscreen());
110
+
111
+ expect(mockToBoolean).toHaveBeenCalledWith(true);
112
+ expect(result.current).toBe(true);
113
+ });
114
+ });
@@ -1,4 +1,4 @@
1
- import { renderHook } from "@testing-library/react-hooks";
1
+ import { renderHook } from "@testing-library/react-native";
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-hooks";
1
+ import { renderHook } from "@testing-library/react-native";
2
2
  import configureStore from "redux-mock-store";
3
3
 
4
4
  const mockStore = configureStore();
@@ -1,16 +1,24 @@
1
1
  import * as React from "react";
2
2
  import { Provider } from "react-redux";
3
- import { renderHook } from "@testing-library/react-hooks";
3
+ import { renderHook } from "@testing-library/react-native";
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
- const river_id_1 = {};
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
+
14
22
  const screenId = "river_id_2";
15
23
  const entry = { id: "test", type: { value: "video" } };
16
24
 
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
2
+ import { useContentTypes } 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";
5
6
 
6
7
  export function getTargetScreenData(
7
8
  entry: ZappEntry,
@@ -43,7 +44,8 @@ export function getTargetScreenDataFromEntry(entry: ZappEntry): ZappRiver {
43
44
  }
44
45
 
45
46
  export const useTargetScreenData = (entry: ZappEntry) => {
46
- const { rivers, contentTypes } = usePickFromState(["rivers", "contentTypes"]);
47
+ const rivers = useRivers();
48
+ const contentTypes = useContentTypes();
47
49
 
48
50
  return React.useMemo(
49
51
  () => getTargetScreenData(entry, rivers, contentTypes),
@@ -3,6 +3,6 @@ import {
3
3
  selectRivers,
4
4
  } from "@applicaster/zapp-react-native-redux";
5
5
 
6
- export function useRivers(): Record<string, ZappRiver> {
6
+ export function useRivers() {
7
7
  return useAppSelector(selectRivers);
8
8
  }