@applicaster/zapp-react-native-utils 14.0.0-rc.5 → 14.0.0-rc.50

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 (84) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +1 -1
  2. package/analyticsUtils/AnalyticsEvents/helper.ts +81 -0
  3. package/analyticsUtils/AnalyticsEvents/sendHeaderClickEvent.ts +1 -1
  4. package/analyticsUtils/AnalyticsEvents/sendMenuClickEvent.ts +2 -1
  5. package/analyticsUtils/AnalyticsEvents/sendOnClickEvent.ts +14 -4
  6. package/analyticsUtils/__tests__/analyticsUtils.test.js +14 -0
  7. package/analyticsUtils/events.ts +8 -0
  8. package/analyticsUtils/index.tsx +3 -4
  9. package/analyticsUtils/manager.ts +1 -1
  10. package/appUtils/HooksManager/Hook.ts +4 -4
  11. package/appUtils/HooksManager/index.ts +11 -1
  12. package/appUtils/accessibilityManager/index.ts +7 -4
  13. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +2 -0
  14. package/appUtils/focusManager/index.ios.ts +10 -0
  15. package/appUtils/focusManager/index.ts +11 -0
  16. package/appUtils/focusManager/treeDataStructure/Tree/index.js +1 -1
  17. package/appUtils/focusManagerAux/utils/index.ts +18 -0
  18. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +0 -15
  19. package/appUtils/playerManager/useChapterMarker.tsx +0 -1
  20. package/appUtils/playerManager/usePlayerControllerSetup.tsx +16 -0
  21. package/arrayUtils/__tests__/isEmptyArray.test.ts +63 -0
  22. package/arrayUtils/__tests__/isFilledArray.test.ts +1 -1
  23. package/arrayUtils/index.ts +8 -3
  24. package/audioPlayerUtils/__tests__/getArtworkImage.test.ts +144 -0
  25. package/audioPlayerUtils/__tests__/getBackgroundImage.test.ts +72 -0
  26. package/audioPlayerUtils/__tests__/getImageFromEntry.test.ts +110 -0
  27. package/audioPlayerUtils/assets/index.ts +2 -0
  28. package/audioPlayerUtils/index.ts +242 -0
  29. package/componentsUtils/__tests__/isTabsScreen.test.ts +38 -0
  30. package/componentsUtils/index.ts +4 -1
  31. package/conf/player/__tests__/selectors.test.ts +34 -0
  32. package/conf/player/selectors.ts +10 -0
  33. package/configurationUtils/__tests__/configurationUtils.test.js +0 -31
  34. package/configurationUtils/__tests__/getMediaItems.test.ts +65 -0
  35. package/configurationUtils/__tests__/imageSrcFromMediaItem.test.ts +34 -0
  36. package/configurationUtils/__tests__/manifestKeyParser.test.ts +546 -0
  37. package/configurationUtils/index.ts +63 -34
  38. package/configurationUtils/manifestKeyParser.ts +57 -32
  39. package/focusManager/FocusManager.ts +26 -16
  40. package/focusManager/Tree.ts +25 -21
  41. package/focusManager/__tests__/FocusManager.test.ts +50 -8
  42. package/index.d.ts +0 -9
  43. package/manifestUtils/_internals/getDefaultConfiguration.js +28 -0
  44. package/manifestUtils/{_internals.js → _internals/index.js} +2 -25
  45. package/manifestUtils/createConfig.js +4 -1
  46. package/manifestUtils/defaultManifestConfigurations/player.js +1239 -200
  47. package/manifestUtils/progressBar/__tests__/mobileProgressBar.test.js +0 -30
  48. package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +1 -2
  49. package/navigationUtils/__tests__/mapContentTypesToRivers.test.ts +130 -0
  50. package/navigationUtils/index.ts +6 -4
  51. package/package.json +2 -3
  52. package/playerUtils/__tests__/configurationUtils.test.ts +1 -65
  53. package/playerUtils/__tests__/getPlayerActionButtons.test.ts +54 -0
  54. package/playerUtils/_internals/__tests__/utils.test.ts +71 -0
  55. package/playerUtils/_internals/index.ts +1 -0
  56. package/playerUtils/_internals/utils.ts +31 -0
  57. package/playerUtils/configurationUtils.ts +0 -44
  58. package/playerUtils/getPlayerActionButtons.ts +17 -0
  59. package/playerUtils/index.ts +53 -0
  60. package/playerUtils/useValidatePlayerConfig.tsx +22 -19
  61. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +15 -14
  62. package/reactHooks/debugging/__tests__/index.test.js +0 -1
  63. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +39 -88
  64. package/reactHooks/feed/useBatchLoading.ts +11 -9
  65. package/reactHooks/feed/useFeedLoader.tsx +12 -8
  66. package/reactHooks/feed/usePipesCacheReset.ts +3 -3
  67. package/reactHooks/flatList/useSequentialRenderItem.tsx +3 -3
  68. package/reactHooks/layout/__tests__/index.test.tsx +3 -1
  69. package/reactHooks/layout/isTablet/index.ts +12 -5
  70. package/reactHooks/layout/useDimensions/__tests__/useDimensions.test.ts +34 -36
  71. package/reactHooks/layout/useDimensions/useDimensions.ts +2 -3
  72. package/reactHooks/layout/useLayoutVersion.ts +5 -5
  73. package/reactHooks/navigation/index.ts +7 -5
  74. package/reactHooks/navigation/useIsScreenActive.ts +9 -5
  75. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +4 -0
  76. package/reactHooks/screen/useScreenContext.ts +1 -1
  77. package/reactHooks/state/__tests__/ZStoreProvider.test.tsx +2 -1
  78. package/reactHooks/state/useRivers.ts +7 -8
  79. package/riverComponetsMeasurementProvider/index.tsx +1 -1
  80. package/services/js2native.ts +1 -0
  81. package/testUtils/index.tsx +7 -8
  82. package/time/BackgroundTimer.ts +6 -4
  83. package/utils/index.ts +18 -1
  84. package/playerUtils/configurationGenerator.ts +0 -2572
@@ -10,7 +10,7 @@ import { isTV } from "../../../reactUtils";
10
10
  import { Options, UseDimensions } from "../types";
11
11
  import { getDeviceInfo } from "../getDeviceInfo";
12
12
  import { getInitialDimensions } from "./helpers";
13
- import { useIsScreenActive } from "../../navigation";
13
+ import { useIsScreenActive } from "../../navigation/useIsScreenActive";
14
14
 
15
15
  function compensateForScaleIfNeeded(context) {
16
16
  return function () {
@@ -24,8 +24,6 @@ const applyScaleToDimensions = R.unless(R.propEq("scale", 1), (dimensions) => ({
24
24
  scale: 1,
25
25
  }));
26
26
 
27
- const statusBarHeight = StatusBar?.currentHeight;
28
-
29
27
  /**
30
28
  * Returns React-native Dimensions object and updates it on any dimension change
31
29
  * @param {('screen'|'window')} [context=window] - Dimensions context passed to Dimensions.get method
@@ -37,6 +35,7 @@ export const useDimensions: UseDimensions = (
37
35
  context = "window",
38
36
  fullDimensions = { fullDimensions: false, updateForInactiveScreens: true }
39
37
  ) => {
38
+ const statusBarHeight = StatusBar?.currentHeight;
40
39
  const isActive = useIsScreenActive();
41
40
  const { appData } = usePickFromState(["appData"]);
42
41
 
@@ -1,6 +1,8 @@
1
1
  /* eslint-disable no-redeclare */
2
- import { useSelector } from "react-redux";
3
- import * as R from "ramda";
2
+ import {
3
+ useAppSelector,
4
+ selectLayoutVersion,
5
+ } from "@applicaster/zapp-react-native-redux";
4
6
 
5
7
  export function useLayoutVersion(): ZappLayoutVersions;
6
8
 
@@ -23,9 +25,7 @@ export function useLayoutVersion({
23
25
  isV2?: boolean;
24
26
  isV1?: boolean;
25
27
  } = {}): boolean | ZappLayoutVersions {
26
- const layoutVersion = useSelector<any, ZappLayoutVersions>(
27
- R.path(["appData", "layoutVersion"])
28
- );
28
+ const layoutVersion = useAppSelector(selectLayoutVersion);
29
29
 
30
30
  if (isV2) {
31
31
  return layoutVersion === "v2";
@@ -14,7 +14,7 @@ import { HOOKS_EVENTS } from "../../appUtils/HooksManager/constants";
14
14
  import { getRiverFromRoute, getTargetRoute } from "../../navigationUtils";
15
15
  import { useConnectionInfo } from "../connection";
16
16
 
17
- import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
17
+ import { isTV, isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
18
18
  import { useNavbarState } from "../screen";
19
19
 
20
20
  export { useNavigation } from "./useNavigation";
@@ -127,11 +127,13 @@ export function isNavBarVisible(
127
127
 
128
128
  export const useBackHandler = (cb: () => boolean) => {
129
129
  useEffect(() => {
130
- BackHandler.addEventListener("hardwareBackPress", cb);
130
+ if (!isWeb()) {
131
+ const unsubscribe = BackHandler.addEventListener("hardwareBackPress", cb);
131
132
 
132
- return () => {
133
- BackHandler.removeEventListener("hardwareBackPress", cb);
134
- };
133
+ return () => {
134
+ unsubscribe.remove();
135
+ };
136
+ }
135
137
  }, [cb]);
136
138
  };
137
139
 
@@ -1,3 +1,4 @@
1
+ import { ROUTE_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/routeTypes";
1
2
  import { useNavigation } from "./useNavigation";
2
3
  import { usePathname } from "./usePathname";
3
4
 
@@ -6,11 +7,14 @@ export const useIsScreenActive = () => {
6
7
  const pathname = usePathname();
7
8
  const { currentRoute, videoModalState } = useNavigation();
8
9
 
9
- if (
10
- videoModalState.visible &&
11
- ["FULLSCREEN", "MAXIMIZED", "PIP"].includes(videoModalState.mode)
12
- ) {
13
- return false;
10
+ if (videoModalState.visible) {
11
+ if (pathname.includes(ROUTE_TYPES.VIDEO_MODAL)) {
12
+ return true;
13
+ }
14
+
15
+ if (["FULLSCREEN", "MAXIMIZED", "PIP"].includes(videoModalState.mode)) {
16
+ return false;
17
+ }
14
18
  }
15
19
 
16
20
  return pathname === currentRoute;
@@ -14,6 +14,10 @@ jest.mock("@applicaster/zapp-react-native-utils/localizationUtils", () => ({
14
14
 
15
15
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation");
16
16
 
17
+ jest.mock(
18
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation"
19
+ );
20
+
17
21
  const { useCellResolver } = require("../useCellResolver");
18
22
 
19
23
  describe("cellResolver", () => {
@@ -2,7 +2,7 @@ import { useContext, useMemo } from "react";
2
2
 
3
3
  import { useModalNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ModalNavigationContext";
4
4
  import { useNestedNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NestedNavigationContext";
5
- import { useNavigation } from "../navigation/useNavigation";
5
+ import { useNavigation } from "../navigation";
6
6
 
7
7
  import { ScreenContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenContext";
8
8
  import { ScreenDataContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
@@ -1,7 +1,8 @@
1
+ /* eslint-disable no-console */
1
2
  import React from "react";
2
3
  import { render, screen } from "@testing-library/react-native";
3
4
  import { Text } from "react-native";
4
- import { ZStoreProvider, useZStore } from "../ZStoreProvider";
5
+ import { useZStore, ZStoreProvider } from "../ZStoreProvider";
5
6
  import { useStore } from "zustand";
6
7
 
7
8
  interface TestState {
@@ -1,9 +1,8 @@
1
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
1
+ import {
2
+ useAppSelector,
3
+ selectRivers,
4
+ } from "@applicaster/zapp-react-native-redux";
2
5
 
3
- const riversSelector = ["rivers"];
4
-
5
- export const useRivers = () => {
6
- const { rivers } = usePickFromState(riversSelector as any);
7
-
8
- return rivers;
9
- };
6
+ export function useRivers(): Record<string, ZappRiver> {
7
+ return useAppSelector(selectRivers);
8
+ }
@@ -3,7 +3,7 @@ import { NativeModules, StyleSheet, View } from "react-native";
3
3
  import { getXray } from "@applicaster/zapp-react-native-utils/logger";
4
4
 
5
5
  import { isApplePlatform, isWeb } from "../reactUtils";
6
- import { useRivers } from "../reactHooks/state";
6
+ import { useRivers } from "../reactHooks";
7
7
 
8
8
  const layoutReducer = (state, { payload }) => {
9
9
  return state.map((item, index, _state) => ({
@@ -496,6 +496,7 @@ async function removeStorageListenerHandler(payload: { listenerId?: string }) {
496
496
  function log({ level, messages }) {
497
497
  try {
498
498
  const parsedMessages = parseJsonIfNeeded(messages);
499
+ // eslint-disable-next-line no-console
499
500
  const logFn = console[level] || console.log;
500
501
 
501
502
  if (Array.isArray(parsedMessages)) {
@@ -1,17 +1,16 @@
1
- import * as R from "ramda";
2
-
1
+ import { SafeAreaProvider } from "react-native-safe-area-context";
2
+ import { render } from "@testing-library/react-native";
3
3
  import React, { PropsWithChildren } from "react";
4
- import { View } from "react-native";
5
-
4
+ import configureStore from "redux-mock-store";
6
5
  import { Provider } from "react-redux";
6
+ import { View } from "react-native";
7
7
  import thunk from "redux-thunk";
8
- import configureStore from "redux-mock-store";
9
- import { SafeAreaProvider } from "react-native-safe-area-context";
8
+ import * as R from "ramda";
9
+
10
10
  import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
11
11
 
12
- import { render } from "@testing-library/react-native";
13
- import { AnalyticsProvider } from "../analyticsUtils";
14
12
  import { ThemeContext } from "../theme";
13
+ import { AnalyticsProvider } from "../analyticsUtils";
15
14
 
16
15
  export { getByTestId } from "./getByTestId";
17
16
 
@@ -11,15 +11,17 @@ class BackgroundTimer {
11
11
  this.uniqueId = 0;
12
12
  this.callbacks = {};
13
13
 
14
- const EventEmitter = platformSelect({
14
+ const EventEmitter: typeof DeviceEventEmitter | undefined = platformSelect({
15
15
  android: DeviceEventEmitter,
16
- ios: undefined,
16
+ android_tv: DeviceEventEmitter,
17
+ amazon: DeviceEventEmitter, // probably does not exist and uses android_tv
17
18
  default: undefined,
18
19
  });
19
20
 
20
21
  EventEmitter?.addListener("BackgroundTimer.timer.fired", (id: number) => {
21
- if (this.callbacks[id]) {
22
- const callback = this.callbacks[id];
22
+ const callback = this.callbacks[id];
23
+
24
+ if (callback) {
23
25
  delete this.callbacks[id];
24
26
  callback();
25
27
  }
package/utils/index.ts CHANGED
@@ -2,4 +2,21 @@ export { chunk } from "./chunk";
2
2
 
3
3
  export { times } from "./times";
4
4
 
5
- export { cloneDeep as clone, flatten, drop, size, isNil } from "lodash";
5
+ export {
6
+ cloneDeep as clone,
7
+ flatten,
8
+ drop,
9
+ size,
10
+ isNil,
11
+ isEmpty,
12
+ get,
13
+ has,
14
+ flatMap,
15
+ difference,
16
+ take,
17
+ pick,
18
+ map,
19
+ trim,
20
+ toString,
21
+ last,
22
+ } from "lodash";