@applicaster/zapp-react-native-utils 13.0.0-rc.1 → 13.0.0-rc.100

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 (170) hide show
  1. package/README.md +0 -10
  2. package/actionsExecutor/ActionExecutor.ts +16 -9
  3. package/actionsExecutor/ActionExecutorContext.tsx +174 -11
  4. package/alertUtils/alert.ts +148 -0
  5. package/alertUtils/index.ts +1 -148
  6. package/analyticsUtils/AnalyticPlayerListener.ts +18 -1
  7. package/analyticsUtils/__tests__/__snapshots__/analyticsManagerNoModule.test.js.snap +9 -9
  8. package/analyticsUtils/currentScreenProperities.ts +6 -4
  9. package/analyticsUtils/helpers/hooks.ts +1 -1
  10. package/appUtils/HooksManager/{Hook.js → Hook.ts} +39 -23
  11. package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +10 -8
  12. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +693 -0
  13. package/appUtils/HooksManager/__tests__/hook.test.js +196 -184
  14. package/appUtils/HooksManager/__tests__/hooksManager.test.js +96 -99
  15. package/appUtils/HooksManager/{constants.js → constants.ts} +1 -1
  16. package/appUtils/HooksManager/{index.js → index.ts} +124 -113
  17. package/appUtils/HooksManager/types.ts +119 -0
  18. package/appUtils/RiverFocusManager/index.js +17 -12
  19. package/appUtils/accessibilityManager/index.ts +42 -1
  20. package/appUtils/contextKeysManager/contextResolver.ts +66 -0
  21. package/appUtils/contextKeysManager/index.ts +2 -2
  22. package/appUtils/contextKeysManager/utils/index.ts +2 -1
  23. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +8 -6
  24. package/appUtils/focusManager/index.ts +108 -69
  25. package/appUtils/focusManager/treeDataStructure/Tree/index.js +25 -3
  26. package/appUtils/focusManager/treeDataStructure/Utils/index.js +1 -3
  27. package/appUtils/focusManager/utils/enums.ts +4 -0
  28. package/appUtils/focusManagerAux/utils/index.ts +4 -3
  29. package/appUtils/{index.js → index.ts} +1 -1
  30. package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +2 -2
  31. package/appUtils/keyCodes/__tests__/keyCodes.test.js +4 -4
  32. package/appUtils/keyCodes/{index.js → index.ts} +13 -7
  33. package/appUtils/keyCodes/keys/index.ts +3 -0
  34. package/appUtils/keyCodes/{keys.android.js → keys/keyEventMapper.ts} +0 -19
  35. package/appUtils/keyCodes/keys/keys.android.ts +18 -0
  36. package/appUtils/keyCodes/keys/keys.ios.ts +25 -0
  37. package/appUtils/keyCodes/keys/keys.ts +15 -0
  38. package/appUtils/keyCodes/{keysByPlatform.js → keys/keysByPlatform.ts} +4 -0
  39. package/appUtils/keyCodes/keysByPlatform.ts +8 -0
  40. package/appUtils/keyInputHandler/KeyInputHandler.ts +68 -0
  41. package/appUtils/{localizationsHelper.js → localizationsHelper.ts} +23 -0
  42. package/appUtils/orientationHelper.ts +11 -13
  43. package/appUtils/platform/const.ts +14 -0
  44. package/appUtils/platform/platformUtils.ts +47 -18
  45. package/appUtils/playerManager/index.ts +7 -3
  46. package/appUtils/playerManager/player.ts +42 -18
  47. package/appUtils/playerManager/playerFactory.ts +5 -4
  48. package/appUtils/playerManager/playerNative.ts +18 -2
  49. package/appUtils/playerManager/usePlayerControllerSetup.tsx +3 -3
  50. package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +7 -1
  51. package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
  52. package/componentsUtils/__tests__/isFirstComponentGallery.test.ts +33 -0
  53. package/componentsUtils/__tests__/isFirstComponentScreenPicker.test.ts +33 -0
  54. package/componentsUtils/__tests__/isGallery.test.ts +33 -0
  55. package/componentsUtils/__tests__/isScreenPicker.test.ts +33 -0
  56. package/componentsUtils/index.ts +32 -0
  57. package/dateUtils/index.ts +19 -0
  58. package/domUtils/{cookieManager.js → cookieManager.ts} +1 -2
  59. package/equalUtils/__tests__/isEqual/combination.test.ts +263 -0
  60. package/equalUtils/index.ts +49 -30
  61. package/focusManager/FocusManager.ts +14 -2
  62. package/focusManager/index.ts +23 -4
  63. package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
  64. package/functionUtils/index.ts +61 -19
  65. package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
  66. package/idleUtils/index.ts +1 -1
  67. package/idleUtils/withTimeout.ts +15 -2
  68. package/index.d.ts +0 -12
  69. package/localizationUtils/index.ts +5 -10
  70. package/logger/const.ts +9 -67
  71. package/manifestUtils/__tests__/createConfig.test.js +16 -16
  72. package/manifestUtils/defaultManifestConfigurations/player.js +14 -0
  73. package/manifestUtils/fonts/index.js +5 -6
  74. package/manifestUtils/sharedConfiguration/screenPicker/__tests__/utils.test.js +304 -0
  75. package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +875 -0
  76. package/manifestUtils/sharedConfiguration/screenPicker/utils.js +130 -0
  77. package/modalState/__tests__/index.test.ts +51 -0
  78. package/modalState/index.ts +33 -7
  79. package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +7 -6
  80. package/navigationUtils/__tests__/itemTypes.test.js +2 -2
  81. package/navigationUtils/__tests__/navigationUtils.test.js +2 -2
  82. package/navigationUtils/index.ts +20 -9
  83. package/numberUtils/__tests__/toPositiveNumberWithDefault.test.ts +23 -3
  84. package/numberUtils/index.ts +11 -5
  85. package/package.json +5 -10
  86. package/playerUtils/configurationGenerator.ts +14 -0
  87. package/reactHooks/advertising/index.ts +5 -5
  88. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  89. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +6 -8
  90. package/reactHooks/autoscrolling/useTrackedView.ts +12 -1
  91. package/reactHooks/cell-click/__tests__/index.test.js +10 -2
  92. package/reactHooks/cell-click/index.ts +7 -1
  93. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +4 -4
  94. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +20 -13
  95. package/reactHooks/feed/useFeedLoader.tsx +28 -15
  96. package/reactHooks/feed/usePipesCacheReset.ts +5 -5
  97. package/reactHooks/flatList/__tests__/index.test.tsx +30 -21
  98. package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +39 -0
  99. package/reactHooks/layout/__tests__/index.test.tsx +10 -10
  100. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +14 -28
  101. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +1 -1
  102. package/reactHooks/layout/useDimensions/useDimensions.ts +8 -0
  103. package/reactHooks/navigation/__mocks__/useNavigation.ts +3 -0
  104. package/reactHooks/navigation/__tests__/index.test.tsx +6 -21
  105. package/reactHooks/navigation/index.ts +41 -240
  106. package/reactHooks/navigation/useGetBottomTabBarHeight.ts +12 -0
  107. package/reactHooks/navigation/useGetNavBarTopBorderWidth.ts +14 -0
  108. package/reactHooks/navigation/useGetTabBarHeight.ts +10 -0
  109. package/reactHooks/navigation/useIsScreenActive.ts +17 -0
  110. package/reactHooks/navigation/useNavigationPluginData.ts +15 -0
  111. package/reactHooks/navigation/useNavigationType.ts +15 -0
  112. package/reactHooks/navigation/usePathname.ts +4 -0
  113. package/reactHooks/navigation/useProfilerLogging.ts +15 -0
  114. package/reactHooks/navigation/useRoute.ts +98 -0
  115. package/reactHooks/navigation/useUniqueRouteSuffix.ts +41 -0
  116. package/reactHooks/player/TVSeekControlller/ISeekController.ts +32 -0
  117. package/reactHooks/player/TVSeekControlller/LongPressSeekController.ts +71 -0
  118. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +258 -0
  119. package/reactHooks/player/TVSeekControlller/TapSeekController.ts +53 -0
  120. package/reactHooks/player/__tests__/{useAutoSeek.test.tsx → useAutoSeek._test.tsx} +2 -3
  121. package/reactHooks/player/const.ts +0 -4
  122. package/reactHooks/player/index.ts +0 -6
  123. package/reactHooks/state/useRefWithInitialValue.ts +14 -0
  124. package/reactHooks/state/useStateFromSubscribe.ts +23 -0
  125. package/reactHooks/usePluginConfiguration.ts +1 -1
  126. package/reactHooks/useSubscriberFor.ts +4 -3
  127. package/reactHooks/utils/index.ts +13 -0
  128. package/reactUtils/__tests__/__snapshots__/reactUtilsHelpers.test.js.snap +16 -4
  129. package/reactUtils/__tests__/reactUtils.test.js +1 -37
  130. package/reactUtils/__tests__/reactUtilsHelpers.test.js +72 -71
  131. package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +13 -79
  132. package/reactUtils/createContext/__tests__/__snapshots__/{index.test.js.snap → index.test.ts.snap} +2 -2
  133. package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -28
  134. package/reactUtils/createContext/__tests__/__snapshots__/withConsumer.test.js.snap +3 -4
  135. package/reactUtils/createContext/__tests__/__snapshots__/withProvider.test.js.snap +7 -3
  136. package/reactUtils/createContext/__tests__/helpers.test.js +107 -121
  137. package/reactUtils/createContext/__tests__/{index.test.js → index.test.ts} +2 -2
  138. package/reactUtils/createContext/__tests__/provider.test.js +4 -6
  139. package/reactUtils/createContext/__tests__/withConsumer.test.js +12 -12
  140. package/reactUtils/createContext/__tests__/withProvider.test.js +4 -4
  141. package/reactUtils/createContext/helpers.ts +6 -1
  142. package/reactUtils/createContext/index.ts +11 -25
  143. package/reactUtils/index.ts +0 -25
  144. package/screenState/index.ts +24 -10
  145. package/services/js2native.ts +673 -0
  146. package/testUtils/index.tsx +0 -10
  147. package/theme/__mocks__/index.ts +4 -0
  148. package/theme/index.ts +1 -1
  149. package/time/BackgroundTimer.ts +55 -0
  150. package/time/Timer.ts +9 -6
  151. package/types.ts +1 -0
  152. package/utils/README.md +30 -0
  153. package/utils/chunk.ts +5 -0
  154. package/utils/index.ts +5 -0
  155. package/utils/times.ts +5 -0
  156. package/zappFrameworkUtils/localStorageHelper.ts +6 -0
  157. package/zappFrameworkUtils/loginPluginUtils.ts +6 -2
  158. package/zappFrameworkUtils/presentPluginOneTime.ts +2 -3
  159. package/zappFrameworkUtils/types.ts +11 -0
  160. package/appUtils/keyCodes/keys.ios.js +0 -46
  161. package/reactHooks/player/useAutoSeek.tsx +0 -87
  162. package/reactHooks/player/useSeek.tsx +0 -66
  163. package/reactHooks/player/useTapSeek.tsx +0 -58
  164. package/reactUtils/createContext/__tests__/index-no-react.test.js +0 -27
  165. /package/appUtils/HooksManager/{logger.js → logger.ts} +0 -0
  166. /package/appUtils/{directionHelper.js → directionHelper.ts} +0 -0
  167. /package/appUtils/keyCodes/{androidTVKeys.js → androidTVKeys.ts} +0 -0
  168. /package/appUtils/keyCodes/{keys.web.js → keys/keys.web.ts} +0 -0
  169. /package/domUtils/{logger.js → logger.ts} +0 -0
  170. /package/reactHooks/player/__tests__/{useTapSeek.test.ts → useTapSeek._test.ts} +0 -0
@@ -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";
@@ -4,6 +4,7 @@ import { isFunction } from "../../functionUtils";
4
4
  import { HOOKS_EVENTS, HOOKS_TRANSITION_TYPE } from "./constants";
5
5
 
6
6
  import { hooksManagerLogger } from "./logger";
7
+ import type { Hook as HookInterface, HookIniObj } from "./types";
7
8
 
8
9
  const BASE_HOOK_PROPERTIES = ["screen_id", "identifier", "weight"];
9
10
 
@@ -14,7 +15,9 @@ const BASE_HOOK_PROPERTIES = ["screen_id", "identifier", "weight"];
14
15
  * @param {string} hookEventName
15
16
  * @returns {number} index
16
17
  */
17
- const hookState = R.indexOf(R.__, R.values(HOOKS_EVENTS));
18
+ const hookState: (
19
+ arg0: (typeof HOOKS_EVENTS)[keyof typeof HOOKS_EVENTS]
20
+ ) => number = R.indexOf(R.__, R.values(HOOKS_EVENTS));
18
21
 
19
22
  /**
20
23
  * assigns property to a given context
@@ -28,17 +31,20 @@ function assignProp(context) {
28
31
  }
29
32
 
30
33
  /**
31
- * Representation of a hook plugin with full data
34
+ * Representation of a hook plugin
32
35
  */
33
- export class Hook {
34
- /**
35
- * constructs the hook
36
- * @param {object} Options
37
- * @param {object} Options.hook hook object
38
- * @param {Array<Object>} Options.hooks array of hooks siblings in the current process
39
- * @param {object} manager hook manager to process the hooks
40
- */
41
- constructor({ hook, hooks, manager }) {
36
+ export class Hook implements HookInterface {
37
+ public manager: HookInterface["manager"];
38
+ public lastHook: HookInterface["lastHook"];
39
+ public state: HookInterface["state"];
40
+ public screen_id: HookInterface["screen_id"];
41
+ public identifier: HookInterface["identifier"];
42
+ public module: HookInterface["module"];
43
+ public general: HookInterface["general"];
44
+ public weight: number;
45
+ public configuration: HookInterface["configuration"];
46
+
47
+ constructor({ hook, hooks, manager }: HookIniObj) {
42
48
  R.forEachObjIndexed(assignProp(this), hook);
43
49
  this.manager = manager;
44
50
 
@@ -55,25 +61,32 @@ export class Hook {
55
61
  * @param {string} event name
56
62
  * @param {Array<Any>} args variadic arguments to invoke the handler with
57
63
  */
58
- setStateAndNotify(event, ...args) {
64
+ setStateAndNotify(
65
+ event: (typeof HOOKS_EVENTS)[keyof typeof HOOKS_EVENTS],
66
+ ...args
67
+ ) {
68
+ if (this.state === hookState(HOOKS_EVENTS.CANCEL)) {
69
+ return;
70
+ }
71
+
59
72
  this.state = hookState(event);
60
- this.manager.invokeHandler(event, ...args);
73
+ this.manager.subscriber.invokeHandler(event, ...args);
61
74
  }
62
75
 
63
76
  /**
64
77
  * returns react component of the the hook modal presenter
65
78
  * @returns {React.ComponentType<any>}
66
79
  */
67
- getModalContainer() {
68
- return this.module && this.module.ModalContainer;
80
+ getModalContainer(): HookInterface["module"]["ModalContainer"] | undefined {
81
+ return this.module ? this.module.ModalContainer : undefined;
69
82
  }
70
83
 
71
84
  /**
72
85
  * tells whether the hook should be presented as a screen
73
86
  * @returns {boolean}
74
87
  */
75
- shouldPresentScreenHook() {
76
- return (
88
+ shouldPresentScreenHook(): boolean {
89
+ return !!(
77
90
  (this.screen_id && this.general?.allow_screen_plugin_presentation) ||
78
91
  (this.module && this.module.presentFullScreen) ||
79
92
  (!this.module?.presentFullScreen &&
@@ -87,7 +100,7 @@ export class Hook {
87
100
  * tells whether the hook should be presented as a modal screen
88
101
  * @returns {boolean}
89
102
  */
90
- isModalHook() {
103
+ isModalHook(): boolean {
91
104
  return (
92
105
  this.screen_id &&
93
106
  this.general?.transition_type === HOOKS_TRANSITION_TYPE.MODAL
@@ -99,7 +112,7 @@ export class Hook {
99
112
  * if it doesn't return success
100
113
  * @returns { boolean}
101
114
  */
102
- isFlowBlocker() {
115
+ isFlowBlocker(): boolean {
103
116
  return (
104
117
  (this.general && this.general.is_flow_blocker) ||
105
118
  (this.module && this.module.isFlowBlocker && this.module.isFlowBlocker())
@@ -111,7 +124,7 @@ export class Hook {
111
124
  * @param {object} payload to pass to the hook
112
125
  * @returns { boolean}
113
126
  */
114
- skipHook(payload) {
127
+ skipHook(payload: object): boolean {
115
128
  const _skipHook = R.compose(
116
129
  R.ifElse(isFunction, R.apply(R.__, [payload]), R.F),
117
130
  R.path(["module", "skipHook"])
@@ -133,7 +146,10 @@ export class Hook {
133
146
  * @param {object} payload to pass to the hook
134
147
  * @param {function} next callback to invoke for processing next hook
135
148
  */
136
- execute(payload, next) {
149
+ execute<T extends object>(
150
+ payload: T,
151
+ next: (arg0: { payload: T; success?: boolean }) => void
152
+ ): void {
137
153
  if (this.skipHook(payload)) {
138
154
  next({ payload, success: true });
139
155
 
@@ -152,7 +168,7 @@ export class Hook {
152
168
 
153
169
  this.setStateAndNotify(HOOKS_EVENTS.START_BACKGROUND_HOOK, this);
154
170
 
155
- this.manager.runInBackground(this, payload, next, (_payload) =>
171
+ this.manager.runInBackground(this, payload, next, (_payload: any) =>
156
172
  this.manager.presentScreenHook(this, _payload || payload, next)
157
173
  );
158
174
  } else if (this.shouldPresentScreenHook()) {
@@ -175,7 +191,7 @@ export class Hook {
175
191
  * - AND next hook has the same weight as the current one
176
192
  * @returns {boolean}
177
193
  */
178
- shouldStartNextHook(nextHook) {
194
+ shouldStartNextHook(nextHook: Hook): boolean {
179
195
  return (
180
196
  nextHook &&
181
197
  !this.shouldPresentScreenHook() &&
@@ -1,26 +1,28 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Hook Properties has all the hook properties 1`] = `
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
- "invokeHandler": [MockFunction],
17
16
  "presentScreenHook": [MockFunction],
17
+ "subscriber": {
18
+ "invokeHandler": [MockFunction],
19
+ },
18
20
  },
19
21
  "name": "Hook Screen",
20
- "navigations": Array [],
22
+ "navigations": [],
21
23
  "screen_id": "A1234",
22
24
  "state": 0,
23
- "styles": Object {},
25
+ "styles": {},
24
26
  "type": "hook_screen",
25
27
  "weight": 1,
26
28
  }