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

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
@@ -1,148 +1 @@
1
- import { Alert } from "react-native";
2
- import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
3
- import { confirmationDialogStore } from "@applicaster/zapp-react-native-ui-components/Contexts/ConfirmDialogState";
4
-
5
- // #region "Alert Dialog"
6
-
7
- const globalAny: any = global;
8
-
9
- const showWebAlertDialog = ({ message, completion }: AlertWebDialog) => {
10
- globalAny?.alert?.(message);
11
- completion?.();
12
- };
13
-
14
- const showNativeAlertDialog = ({
15
- title,
16
- message,
17
- okButtonText,
18
- completion,
19
- }: AlertDialogType) => {
20
- Alert.alert(title, message, [
21
- {
22
- text: okButtonText,
23
- onPress: completion,
24
- },
25
- ]);
26
- };
27
-
28
- export const showAlertDialog = ({
29
- title,
30
- message,
31
- okButtonText,
32
- completion,
33
- }: AlertDialogType) => {
34
- if (isWeb()) {
35
- showWebAlertDialog({ message, completion });
36
- } else {
37
- showNativeAlertDialog({
38
- title,
39
- message,
40
- okButtonText,
41
- completion,
42
- });
43
- }
44
- };
45
-
46
- // #endregion "Alert Dialog"
47
-
48
- // #region "Confirmation Dialog"
49
-
50
- const showWebDialog = ({
51
- message,
52
- confirmCompletion,
53
- cancelCompletion,
54
- }: WebConfirmationDialog) => {
55
- const isConfirmed = globalAny?.confirm?.(message);
56
-
57
- if (isConfirmed) {
58
- confirmCompletion?.();
59
- } else {
60
- cancelCompletion?.();
61
- }
62
- };
63
-
64
- const showNativeDialog = ({
65
- title,
66
- message,
67
- okButtonText,
68
- cancelButtonText,
69
- confirmCompletion,
70
- cancelCompletion,
71
- }: ConfirmationDialog) => {
72
- Alert.alert(title, message, [
73
- {
74
- text: cancelButtonText,
75
- onPress: cancelCompletion,
76
- },
77
- {
78
- text: okButtonText,
79
- style: "destructive",
80
- onPress: confirmCompletion,
81
- },
82
- ]);
83
- };
84
-
85
- const handleCustomDialog = (data) => {
86
- const {
87
- showDialog,
88
- hideDialog,
89
- setConfirmAction,
90
- setCancelAction,
91
- setMessages,
92
- } = confirmationDialogStore.getState();
93
-
94
- setMessages(data.messages);
95
-
96
- if (data?.cancelCompletion) {
97
- setCancelAction(() => {
98
- data.cancelCompletion();
99
- hideDialog();
100
- });
101
- }
102
-
103
- if (data?.confirmCompletion) {
104
- setConfirmAction(() => {
105
- data.confirmCompletion();
106
- hideDialog();
107
- });
108
- }
109
-
110
- showDialog();
111
- };
112
-
113
- export const showConfirmationDialog = ({
114
- title,
115
- message,
116
- okButtonText,
117
- cancelButtonText,
118
- confirmCompletion,
119
- cancelCompletion,
120
- }: CustomConfirmationDialog): void => {
121
- if (isWeb()) {
122
- if (cancelCompletion) {
123
- handleCustomDialog({
124
- messages: {
125
- title,
126
- message,
127
- okButtonText,
128
- cancelButtonText,
129
- },
130
- confirmCompletion,
131
- cancelCompletion,
132
- });
133
- } else {
134
- showWebDialog({ message, confirmCompletion, cancelCompletion });
135
- }
136
- } else {
137
- showNativeDialog({
138
- title,
139
- message,
140
- okButtonText,
141
- cancelButtonText,
142
- confirmCompletion,
143
- cancelCompletion,
144
- });
145
- }
146
- };
147
-
148
- // #endregion "Confirmation Dialog"
1
+ export { showAlertDialog, showConfirmationDialog } from "./alert";
@@ -14,7 +14,7 @@ export class AnalyticPlayerListener
14
14
  static analyticsListenerID = "analytics-listener";
15
15
  private analyticsTracker: PlayerAnalyticsTracker;
16
16
  private player: Player;
17
-
17
+ private isSeeking: boolean = false;
18
18
  private onVideoLoadCalled; // android only
19
19
 
20
20
  constructor(props: Props) {
@@ -40,10 +40,27 @@ export class AnalyticPlayerListener
40
40
  };
41
41
 
42
42
  onPlayerPause = (event) => {
43
+ if (this.player?.seekController?.isSeeking()) {
44
+ this.isSeeking = true;
45
+
46
+ return;
47
+ }
48
+
43
49
  this.handleAnalyticEvent(PLAYBACK_EVENT.pause, event);
44
50
  };
45
51
 
46
52
  onPlayerResume = (event) => {
53
+ if (this.player?.seekController?.isSeeking()) {
54
+ return;
55
+ }
56
+
57
+ if (this.isSeeking) {
58
+ // Fallback due to player resume event been async and arriving with delays
59
+ this.isSeeking = false;
60
+
61
+ return;
62
+ }
63
+
47
64
  this.handleAnalyticEvent(PLAYBACK_EVENT.play, event);
48
65
  };
49
66
 
@@ -1,24 +1,24 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`AnalyticsManager - with undefined Native Module doesn't crash when calling the methods 1`] = `
4
- Array [
5
- Array [
6
- Object {
4
+ [
5
+ [
6
+ {
7
7
  "message": "Analytics Bridge is missing - no event will be sent",
8
8
  },
9
9
  ],
10
- Array [
11
- Object {
10
+ [
11
+ {
12
12
  "message": "Analytics Bridge is missing - no event will be sent",
13
13
  },
14
14
  ],
15
- Array [
16
- Object {
15
+ [
16
+ {
17
17
  "message": "Analytics Bridge is missing - no event will be sent",
18
18
  },
19
19
  ],
20
- Array [
21
- Object {
20
+ [
21
+ {
22
22
  "message": "Analytics Bridge is missing - no event will be sent",
23
23
  },
24
24
  ],
@@ -72,12 +72,14 @@ const mappedScreenPropertiesScreen = (
72
72
  screenData
73
73
  ): AnalyticsScreenProperties => {
74
74
  return {
75
- screen_name: screenData?.targetScreen?.name,
75
+ screen_name: screenData?.targetScreen?.name || screenData?.name,
76
76
  screen_entry_title: screenData?.title,
77
77
  screen_entry_id: R.isNil(screenData?.type) ? null : screenData?.id,
78
- screen_layout_id: screenData?.targetScreen?.id,
79
- screen_type: screenData?.targetScreen?.type,
80
- home_screen: screenData?.targetScreen?.home,
78
+ screen_layout_id: screenData?.targetScreen?.id || screenData?.id,
79
+ screen_type: screenData?.targetScreen?.type || screenData?.type,
80
+ home_screen: !R.isNil(screenData?.targetScreen?.home)
81
+ ? screenData?.targetScreen?.home
82
+ : screenData?.home,
81
83
  };
82
84
  };
83
85
 
@@ -2,7 +2,7 @@ import * as R from "ramda";
2
2
  import * as React from "react";
3
3
 
4
4
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
5
- import { useScreenContext } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
5
+ import { useScreenContext } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
6
6
 
7
7
  import { getAnalyticsScreenPropertiesFromScreenData } from "@applicaster/zapp-react-native-utils/analyticsUtils/currentScreenProperities";
8
8
  import { useAnalytics } from "@applicaster/zapp-react-native-utils/analyticsUtils";
@@ -16,7 +16,7 @@ const BASE_HOOK_PROPERTIES = ["screen_id", "identifier", "weight"];
16
16
  * @returns {number} index
17
17
  */
18
18
  const hookState: (
19
- arg0: typeof HOOKS_EVENTS[keyof typeof HOOKS_EVENTS]
19
+ arg0: (typeof HOOKS_EVENTS)[keyof typeof HOOKS_EVENTS]
20
20
  ) => number = R.indexOf(R.__, R.values(HOOKS_EVENTS));
21
21
 
22
22
  /**
@@ -62,9 +62,13 @@ export class Hook implements HookInterface {
62
62
  * @param {Array<Any>} args variadic arguments to invoke the handler with
63
63
  */
64
64
  setStateAndNotify(
65
- event: typeof HOOKS_EVENTS[keyof typeof HOOKS_EVENTS],
65
+ event: (typeof HOOKS_EVENTS)[keyof typeof HOOKS_EVENTS],
66
66
  ...args
67
67
  ) {
68
+ if (this.state === hookState(HOOKS_EVENTS.CANCEL)) {
69
+ return;
70
+ }
71
+
68
72
  this.state = hookState(event);
69
73
  this.manager.subscriber.invokeHandler(event, ...args);
70
74
  }
@@ -2,27 +2,27 @@
2
2
 
3
3
  exports[`Hook Hook Properties has all the hook properties 1`] = `
4
4
  Hook {
5
- "advertising": Object {},
6
- "general": Object {
5
+ "advertising": {},
6
+ "general": {
7
7
  "allow_screen_plugin_presentation": true,
8
8
  "is_flow_blocker": true,
9
9
  },
10
- "hooks": Array [],
10
+ "hooks": [],
11
11
  "id": "A1234",
12
12
  "identifier": "hook_screen",
13
13
  "lastHook": true,
14
- "manager": Object {
14
+ "manager": {
15
15
  "executeHook": [MockFunction],
16
16
  "presentScreenHook": [MockFunction],
17
- "subscriber": Object {
17
+ "subscriber": {
18
18
  "invokeHandler": [MockFunction],
19
19
  },
20
20
  },
21
21
  "name": "Hook Screen",
22
- "navigations": Array [],
22
+ "navigations": [],
23
23
  "screen_id": "A1234",
24
24
  "state": 0,
25
- "styles": Object {},
25
+ "styles": {},
26
26
  "type": "hook_screen",
27
27
  "weight": 1,
28
28
  }