@applicaster/zapp-react-native-utils 13.0.0-rc.2 → 13.0.0-rc.21

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 (109) hide show
  1. package/actionsExecutor/ActionExecutor.ts +16 -9
  2. package/actionsExecutor/ActionExecutorContext.tsx +74 -9
  3. package/alertUtils/alert.ts +148 -0
  4. package/alertUtils/index.ts +1 -148
  5. package/analyticsUtils/AnalyticPlayerListener.ts +18 -1
  6. package/analyticsUtils/__tests__/__snapshots__/analyticsManagerNoModule.test.js.snap +9 -9
  7. package/analyticsUtils/helpers/hooks.ts +1 -1
  8. package/appUtils/HooksManager/{Hook.js → Hook.ts} +35 -23
  9. package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +10 -8
  10. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +693 -0
  11. package/appUtils/HooksManager/__tests__/hook.test.js +196 -184
  12. package/appUtils/HooksManager/__tests__/hooksManager.test.js +96 -99
  13. package/appUtils/HooksManager/{constants.js → constants.ts} +1 -1
  14. package/appUtils/HooksManager/{index.js → index.ts} +121 -112
  15. package/appUtils/HooksManager/types.ts +119 -0
  16. package/appUtils/RiverFocusManager/index.js +17 -12
  17. package/appUtils/accessibilityManager/index.ts +42 -1
  18. package/appUtils/contextKeysManager/contextResolver.ts +73 -0
  19. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +6 -6
  20. package/appUtils/focusManager/index.ts +90 -63
  21. package/appUtils/focusManager/treeDataStructure/Tree/index.js +25 -3
  22. package/appUtils/focusManager/treeDataStructure/Utils/index.js +1 -3
  23. package/appUtils/focusManager/utils/enums.ts +4 -0
  24. package/appUtils/focusManagerAux/utils/index.ts +4 -3
  25. package/appUtils/{index.js → index.ts} +1 -1
  26. package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +2 -2
  27. package/appUtils/keyCodes/__tests__/keyCodes.test.js +4 -4
  28. package/appUtils/keyCodes/{index.js → index.ts} +2 -0
  29. package/appUtils/keyCodes/keys/index.ts +3 -0
  30. package/appUtils/keyCodes/{keys.android.js → keys/keyEventMapper.ts} +0 -19
  31. package/appUtils/keyCodes/keys/keys.android.ts +18 -0
  32. package/appUtils/keyCodes/keys/keys.ios.ts +25 -0
  33. package/appUtils/keyCodes/keys/keys.ts +15 -0
  34. package/appUtils/keyCodes/{keysByPlatform.js → keys/keysByPlatform.ts} +4 -0
  35. package/appUtils/keyCodes/keysByPlatform.ts +8 -0
  36. package/appUtils/keyInputHandler/KeyInputHandler.ts +68 -0
  37. package/appUtils/orientationHelper.ts +1 -1
  38. package/appUtils/platform/const.ts +14 -0
  39. package/appUtils/platform/platformUtils.ts +17 -15
  40. package/appUtils/playerManager/index.ts +6 -2
  41. package/appUtils/playerManager/player.ts +17 -5
  42. package/appUtils/playerManager/playerFactory.ts +5 -4
  43. package/appUtils/playerManager/playerNative.ts +3 -2
  44. package/appUtils/playerManager/usePlayerControllerSetup.tsx +3 -3
  45. package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
  46. package/domUtils/{cookieManager.js → cookieManager.ts} +1 -2
  47. package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
  48. package/functionUtils/index.ts +15 -11
  49. package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
  50. package/idleUtils/index.ts +1 -1
  51. package/idleUtils/withTimeout.ts +15 -2
  52. package/logger/const.ts +9 -67
  53. package/manifestUtils/__tests__/createConfig.test.js +18 -16
  54. package/modalState/index.ts +1 -5
  55. package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +6 -6
  56. package/navigationUtils/__tests__/itemTypes.test.js +2 -2
  57. package/navigationUtils/__tests__/navigationUtils.test.js +2 -2
  58. package/navigationUtils/index.ts +14 -5
  59. package/package.json +3 -2
  60. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  61. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -1
  62. package/reactHooks/cell-click/__tests__/index.test.js +10 -2
  63. package/reactHooks/cell-click/index.ts +7 -1
  64. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +4 -4
  65. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +20 -13
  66. package/reactHooks/feed/useFeedLoader.tsx +12 -8
  67. package/reactHooks/feed/usePipesCacheReset.ts +5 -5
  68. package/reactHooks/flatList/__tests__/index.test.tsx +30 -21
  69. package/reactHooks/layout/__tests__/index.test.tsx +10 -10
  70. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +14 -28
  71. package/reactHooks/navigation/__tests__/index.test.tsx +0 -4
  72. package/reactHooks/navigation/index.ts +29 -218
  73. package/reactHooks/navigation/useGetBottomTabBarHeight.ts +12 -0
  74. package/reactHooks/navigation/useGetNavBarTopBorderWidth.ts +14 -0
  75. package/reactHooks/navigation/useGetTabBarHeight.ts +12 -0
  76. package/reactHooks/navigation/useIsScreenActive.ts +17 -0
  77. package/reactHooks/navigation/useNavigationPluginData.ts +15 -0
  78. package/reactHooks/navigation/useNavigationType.ts +15 -0
  79. package/reactHooks/navigation/usePathname.ts +4 -0
  80. package/reactHooks/navigation/useRoute.ts +100 -0
  81. package/reactHooks/navigation/useUniqueRouteSuffix.ts +41 -0
  82. package/reactHooks/player/TVSeekControlller/ISeekController.ts +32 -0
  83. package/reactHooks/player/TVSeekControlller/LongPressSeekController.ts +71 -0
  84. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +258 -0
  85. package/reactHooks/player/TVSeekControlller/TapSeekController.ts +53 -0
  86. package/reactHooks/player/__tests__/{useAutoSeek.test.tsx → useAutoSeek._test.tsx} +2 -3
  87. package/reactHooks/player/const.ts +0 -4
  88. package/reactHooks/player/index.ts +0 -6
  89. package/reactHooks/utils/index.ts +13 -0
  90. package/reactUtils/__tests__/reactUtils.test.js +10 -28
  91. package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +19 -19
  92. package/reactUtils/createContext/__tests__/__snapshots__/index.test.js.snap +2 -2
  93. package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -3
  94. package/reactUtils/createContext/__tests__/helpers.test.js +8 -8
  95. package/reactUtils/index.ts +0 -14
  96. package/theme/__mocks__/index.ts +4 -0
  97. package/time/Timer.ts +1 -1
  98. package/types.ts +1 -0
  99. package/appUtils/keyCodes/keys.ios.js +0 -46
  100. package/reactHooks/player/useAutoSeek.tsx +0 -87
  101. package/reactHooks/player/useSeek.tsx +0 -66
  102. package/reactHooks/player/useTapSeek.tsx +0 -58
  103. /package/appUtils/HooksManager/{logger.js → logger.ts} +0 -0
  104. /package/appUtils/{directionHelper.js → directionHelper.ts} +0 -0
  105. /package/appUtils/keyCodes/{androidTVKeys.js → androidTVKeys.ts} +0 -0
  106. /package/appUtils/keyCodes/{keys.web.js → keys/keys.web.ts} +0 -0
  107. /package/appUtils/{localizationsHelper.js → localizationsHelper.ts} +0 -0
  108. /package/domUtils/{logger.js → logger.ts} +0 -0
  109. /package/reactHooks/player/__tests__/{useTapSeek.test.ts → useTapSeek._test.ts} +0 -0
@@ -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,28 @@ 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
+ ) {
59
68
  this.state = hookState(event);
60
- this.manager.invokeHandler(event, ...args);
69
+ this.manager.subscriber.invokeHandler(event, ...args);
61
70
  }
62
71
 
63
72
  /**
64
73
  * returns react component of the the hook modal presenter
65
74
  * @returns {React.ComponentType<any>}
66
75
  */
67
- getModalContainer() {
68
- return this.module && this.module.ModalContainer;
76
+ getModalContainer(): HookInterface["module"]["ModalContainer"] | undefined {
77
+ return this.module ? this.module.ModalContainer : undefined;
69
78
  }
70
79
 
71
80
  /**
72
81
  * tells whether the hook should be presented as a screen
73
82
  * @returns {boolean}
74
83
  */
75
- shouldPresentScreenHook() {
76
- return (
84
+ shouldPresentScreenHook(): boolean {
85
+ return !!(
77
86
  (this.screen_id && this.general?.allow_screen_plugin_presentation) ||
78
87
  (this.module && this.module.presentFullScreen) ||
79
88
  (!this.module?.presentFullScreen &&
@@ -87,7 +96,7 @@ export class Hook {
87
96
  * tells whether the hook should be presented as a modal screen
88
97
  * @returns {boolean}
89
98
  */
90
- isModalHook() {
99
+ isModalHook(): boolean {
91
100
  return (
92
101
  this.screen_id &&
93
102
  this.general?.transition_type === HOOKS_TRANSITION_TYPE.MODAL
@@ -99,7 +108,7 @@ export class Hook {
99
108
  * if it doesn't return success
100
109
  * @returns { boolean}
101
110
  */
102
- isFlowBlocker() {
111
+ isFlowBlocker(): boolean {
103
112
  return (
104
113
  (this.general && this.general.is_flow_blocker) ||
105
114
  (this.module && this.module.isFlowBlocker && this.module.isFlowBlocker())
@@ -111,7 +120,7 @@ export class Hook {
111
120
  * @param {object} payload to pass to the hook
112
121
  * @returns { boolean}
113
122
  */
114
- skipHook(payload) {
123
+ skipHook(payload: object): boolean {
115
124
  const _skipHook = R.compose(
116
125
  R.ifElse(isFunction, R.apply(R.__, [payload]), R.F),
117
126
  R.path(["module", "skipHook"])
@@ -133,7 +142,10 @@ export class Hook {
133
142
  * @param {object} payload to pass to the hook
134
143
  * @param {function} next callback to invoke for processing next hook
135
144
  */
136
- execute(payload, next) {
145
+ execute<T extends object>(
146
+ payload: T,
147
+ next: (arg0: { payload: T; success?: boolean }) => void
148
+ ): void {
137
149
  if (this.skipHook(payload)) {
138
150
  next({ payload, success: true });
139
151
 
@@ -152,7 +164,7 @@ export class Hook {
152
164
 
153
165
  this.setStateAndNotify(HOOKS_EVENTS.START_BACKGROUND_HOOK, this);
154
166
 
155
- this.manager.runInBackground(this, payload, next, (_payload) =>
167
+ this.manager.runInBackground(this, payload, next, (_payload: any) =>
156
168
  this.manager.presentScreenHook(this, _payload || payload, next)
157
169
  );
158
170
  } else if (this.shouldPresentScreenHook()) {
@@ -175,7 +187,7 @@ export class Hook {
175
187
  * - AND next hook has the same weight as the current one
176
188
  * @returns {boolean}
177
189
  */
178
- shouldStartNextHook(nextHook) {
190
+ shouldStartNextHook(nextHook: Hook): boolean {
179
191
  return (
180
192
  nextHook &&
181
193
  !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
  }