@applicaster/zapp-react-native-utils 14.0.0-alpha.1054425138 → 14.0.0-alpha.1118824347

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 (69) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +82 -53
  2. package/analyticsUtils/AnalyticsEvents/helper.ts +81 -0
  3. package/analyticsUtils/AnalyticsEvents/sendOnClickEvent.ts +14 -4
  4. package/analyticsUtils/__tests__/analyticsUtils.test.js +14 -0
  5. package/analyticsUtils/events.ts +8 -0
  6. package/appUtils/HooksManager/Hook.ts +4 -4
  7. package/appUtils/HooksManager/index.ts +11 -1
  8. package/appUtils/accessibilityManager/index.ts +5 -2
  9. package/appUtils/contextKeysManager/contextResolver.ts +1 -15
  10. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +4 -0
  11. package/appUtils/focusManager/__tests__/focusManager.test.js +1 -1
  12. package/appUtils/focusManager/index.ts +81 -9
  13. package/appUtils/focusManagerAux/utils/index.ts +48 -2
  14. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +0 -15
  15. package/appUtils/playerManager/useChapterMarker.tsx +0 -1
  16. package/appUtils/playerManager/usePlayerControllerSetup.tsx +16 -0
  17. package/arrayUtils/__tests__/isEmptyArray.test.ts +63 -0
  18. package/arrayUtils/__tests__/isFilledArray.test.ts +1 -1
  19. package/arrayUtils/index.ts +8 -3
  20. package/audioPlayerUtils/__tests__/getArtworkImage.test.ts +144 -0
  21. package/audioPlayerUtils/__tests__/getBackgroundImage.test.ts +72 -0
  22. package/audioPlayerUtils/__tests__/getImageFromEntry.test.ts +110 -0
  23. package/audioPlayerUtils/assets/index.ts +2 -0
  24. package/audioPlayerUtils/index.ts +242 -0
  25. package/componentsUtils/__tests__/isTabsScreen.test.ts +38 -0
  26. package/componentsUtils/index.ts +4 -1
  27. package/conf/player/__tests__/selectors.test.ts +34 -0
  28. package/conf/player/selectors.ts +10 -0
  29. package/configurationUtils/__tests__/configurationUtils.test.js +0 -31
  30. package/configurationUtils/__tests__/getMediaItems.test.ts +65 -0
  31. package/configurationUtils/__tests__/imageSrcFromMediaItem.test.ts +34 -0
  32. package/configurationUtils/__tests__/manifestKeyParser.test.ts +547 -0
  33. package/configurationUtils/index.ts +63 -34
  34. package/configurationUtils/manifestKeyParser.ts +57 -32
  35. package/focusManager/FocusManager.ts +26 -16
  36. package/focusManager/Tree.ts +25 -21
  37. package/focusManager/__tests__/FocusManager.test.ts +50 -8
  38. package/manifestUtils/_internals/getDefaultConfiguration.js +28 -0
  39. package/manifestUtils/{_internals.js → _internals/index.js} +2 -25
  40. package/manifestUtils/createConfig.js +4 -1
  41. package/manifestUtils/defaultManifestConfigurations/player.js +1239 -200
  42. package/manifestUtils/progressBar/__tests__/mobileProgressBar.test.js +0 -30
  43. package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +1 -2
  44. package/package.json +2 -2
  45. package/playerUtils/__tests__/configurationUtils.test.ts +1 -65
  46. package/playerUtils/__tests__/getPlayerActionButtons.test.ts +54 -0
  47. package/playerUtils/_internals/__tests__/utils.test.ts +71 -0
  48. package/playerUtils/_internals/index.ts +1 -0
  49. package/playerUtils/_internals/utils.ts +31 -0
  50. package/playerUtils/configurationUtils.ts +0 -44
  51. package/playerUtils/getPlayerActionButtons.ts +17 -0
  52. package/playerUtils/index.ts +59 -0
  53. package/playerUtils/useValidatePlayerConfig.tsx +22 -19
  54. package/reactHooks/cell-click/index.ts +1 -5
  55. package/reactHooks/feed/useBatchLoading.ts +3 -3
  56. package/reactHooks/feed/useFeedLoader.tsx +6 -13
  57. package/reactHooks/feed/usePipesCacheReset.ts +1 -1
  58. package/reactHooks/layout/isTablet/index.ts +12 -5
  59. package/reactHooks/navigation/index.ts +7 -3
  60. package/reactHooks/navigation/useIsScreenActive.ts +9 -5
  61. package/reactHooks/screen/useScreenContext.ts +1 -1
  62. package/reactHooks/state/__tests__/ZStoreProvider.test.tsx +2 -1
  63. package/riverComponetsMeasurementProvider/index.tsx +1 -1
  64. package/services/js2native.ts +1 -0
  65. package/time/BackgroundTimer.ts +5 -3
  66. package/utils/index.ts +16 -1
  67. package/actionsExecutor/ScreenActions.ts +0 -90
  68. package/actionsExecutor/StorageActions.ts +0 -110
  69. package/playerUtils/configurationGenerator.ts +0 -2572
@@ -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,10 +127,14 @@ export function isNavBarVisible(
127
127
 
128
128
  export const useBackHandler = (cb: () => boolean) => {
129
129
  useEffect(() => {
130
- BackHandler.addEventListener("hardwareBackPress", cb);
130
+ if (!isWeb()) {
131
+ BackHandler.addEventListener("hardwareBackPress", cb);
132
+ }
131
133
 
132
134
  return () => {
133
- BackHandler.removeEventListener("hardwareBackPress", cb);
135
+ if (!isWeb()) {
136
+ BackHandler.removeEventListener("hardwareBackPress", cb);
137
+ }
134
138
  };
135
139
  }, [cb]);
136
140
  };
@@ -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;
@@ -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 {
@@ -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)) {
@@ -13,13 +13,15 @@ class BackgroundTimer {
13
13
 
14
14
  const EventEmitter = 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,19 @@ 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
+ map,
18
+ trim,
19
+ toString,
20
+ } from "lodash";
@@ -1,90 +0,0 @@
1
- // import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
2
-
3
- import { log_error, log_info } from "./ActionExecutorContext";
4
- import { ActionResult } from "./ActionExecutor";
5
- import { get } from "lodash";
6
-
7
- import { ScreenMultiSelectProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/ScreenStateMultiSelectProvider";
8
- import { onMaxTagsReached } from "./StorageActions";
9
-
10
- export const screenSetVariable = (
11
- _screenRoute: string,
12
- _key: string,
13
- _value: string
14
- ) => {};
15
-
16
- export const screenToggleFlag = async (
17
- screenRoute: string,
18
- context: Record<string, any>,
19
- action: ActionType
20
- ) => {
21
- if (!context) {
22
- log_error("handleAction: localStorageToggleFlag action missing context");
23
-
24
- return ActionResult.Error;
25
- }
26
-
27
- const entry = context?.entry as ZappEntry;
28
-
29
- if (!entry) {
30
- log_error(
31
- "handleAction: localStorageToggleFlag action missing entry. Entry is required to get the tag."
32
- );
33
-
34
- return ActionResult.Error;
35
- }
36
-
37
- const tag = action.options?.selector
38
- ? get(entry, action.options.selector)
39
- : (entry.extensions?.tag ?? entry.id);
40
-
41
- const keyNamespace = action.options?.key;
42
-
43
- if (keyNamespace && tag) {
44
- const multiSelectProvider = ScreenMultiSelectProvider.getProvider(
45
- keyNamespace,
46
- screenRoute
47
- );
48
-
49
- const selectedItems = await multiSelectProvider.getSelectedAsync();
50
- const isTagInSelectedItems = selectedItems.includes(tag);
51
-
52
- log_info(
53
- `handleAction: screenToggleFlag event will ${
54
- isTagInSelectedItems ? "remove" : "add"
55
- } tag: ${tag} for keyNamespace: ${keyNamespace}, current selectedItems: ${selectedItems}`
56
- );
57
-
58
- if (selectedItems.includes(tag)) {
59
- await multiSelectProvider.removeItem(tag);
60
- } else {
61
- const maxItems = action.options?.max_items;
62
-
63
- if (maxItems && selectedItems.length >= maxItems) {
64
- log_info(
65
- `handleAction: screenToggleFlag event reached max items limit: ${maxItems}, cannot add tag: ${tag}`
66
- );
67
-
68
- await onMaxTagsReached({
69
- selectedItems,
70
- maxItems,
71
- tag,
72
- keyNamespace,
73
- });
74
-
75
- return ActionResult.Cancel;
76
- }
77
-
78
- await multiSelectProvider.addItem(tag);
79
- }
80
- } else {
81
- log_error(
82
- "handleAction: screenToggleFlag event missing keyNamespace or tag",
83
- { keyNamespace, tag }
84
- );
85
-
86
- return ActionResult.Error;
87
- }
88
-
89
- return ActionResult.Success;
90
- };
@@ -1,110 +0,0 @@
1
- import { ActionResult } from "./ActionExecutor";
2
- import { get } from "lodash";
3
- import { StorageMultiSelectProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/StorageMultiSelectProvider";
4
- import { log_error, log_info } from "./ActionExecutorContext";
5
- import { postEvent } from "../reactHooks/useSubscriberFor";
6
- import { TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT } from "./consts";
7
- import { StorageType } from "../appUtils/contextKeysManager/consts";
8
-
9
- // send all data just in case (like for message string formatting)
10
- // Type is not exported for now
11
- type MaxTagsReachedEvent = {
12
- selectedItems: string[];
13
- maxItems: number;
14
- tag: string;
15
- keyNamespace: string;
16
- };
17
-
18
- export async function onMaxTagsReached(data: MaxTagsReachedEvent) {
19
- postEvent(TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT, [data]);
20
- }
21
-
22
- export async function storageToggleFlag(
23
- context: Record<string, any>,
24
- action: ActionType,
25
- storageType: StorageType
26
- ) {
27
- if (!context) {
28
- log_error("handleAction: localStorageToggleFlag action missing context");
29
-
30
- return ActionResult.Error;
31
- }
32
-
33
- const entry = context?.entry as ZappEntry;
34
-
35
- if (!entry) {
36
- log_error(
37
- "handleAction: localStorageToggleFlag action missing entry. Entry is required to get the tag."
38
- );
39
-
40
- return ActionResult.Error;
41
- }
42
-
43
- const tag = action.options?.selector
44
- ? get(entry, action.options.selector)
45
- : (entry.extensions?.tag ?? entry.id);
46
-
47
- const keyNamespace = action.options?.key;
48
-
49
- if (keyNamespace && tag) {
50
- const multiSelectProvider = StorageMultiSelectProvider.getProvider(
51
- keyNamespace,
52
- storageType
53
- );
54
-
55
- const selectedItems = await multiSelectProvider.getSelectedAsync();
56
- const isTagInSelectedItems = selectedItems.includes(tag);
57
-
58
- log_info(
59
- `handleAction: localStorageToggleFlag event will ${
60
- isTagInSelectedItems ? "remove" : "add"
61
- } tag: ${tag} for keyNamespace: ${keyNamespace}, current selectedItems: ${selectedItems}`
62
- );
63
-
64
- if (selectedItems.includes(tag)) {
65
- await multiSelectProvider.removeItem(tag);
66
- } else {
67
- const maxItems = action.options?.max_items;
68
-
69
- if (maxItems && selectedItems.length >= maxItems) {
70
- log_info(
71
- `handleAction: localStorageToggleFlag event reached max items limit: ${maxItems}, cannot add tag: ${tag}`
72
- );
73
-
74
- await onMaxTagsReached({
75
- selectedItems,
76
- maxItems,
77
- tag,
78
- keyNamespace,
79
- });
80
-
81
- return ActionResult.Cancel;
82
- }
83
-
84
- await multiSelectProvider.addItem(tag);
85
- }
86
- } else {
87
- log_error(
88
- "handleAction: localStorageToggleFlag event missing keyNamespace or tag",
89
- { keyNamespace, tag }
90
- );
91
-
92
- return ActionResult.Error;
93
- }
94
-
95
- return ActionResult.Success;
96
- }
97
-
98
- export async function sessionStorageToggleFlag(
99
- context: Record<string, any>,
100
- action: ActionType
101
- ) {
102
- return storageToggleFlag(context, action, StorageType.session);
103
- }
104
-
105
- export async function localStorageToggleFlag(
106
- context: Record<string, any>,
107
- action: ActionType
108
- ) {
109
- return storageToggleFlag(context, action, StorageType.local);
110
- }