@applicaster/zapp-react-native-utils 13.0.0-rc.12 → 13.0.0-rc.13
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.
- package/appUtils/HooksManager/{Hook.js → Hook.ts} +35 -23
- package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +4 -2
- package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +693 -0
- package/appUtils/HooksManager/__tests__/hook.test.js +196 -184
- package/appUtils/HooksManager/__tests__/hooksManager.test.js +96 -99
- package/appUtils/HooksManager/{constants.js → constants.ts} +1 -1
- package/appUtils/HooksManager/{index.js → index.ts} +121 -112
- package/appUtils/HooksManager/types.ts +116 -0
- package/appUtils/RiverFocusManager/index.js +17 -12
- package/appUtils/focusManager/treeDataStructure/Tree/index.js +2 -3
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +1 -3
- package/appUtils/{index.js → index.ts} +1 -1
- package/appUtils/keyCodes/__tests__/keyCodes.test.js +3 -3
- package/appUtils/keyCodes/{index.js → index.ts} +2 -0
- package/appUtils/keyCodes/keys/index.ts +3 -0
- package/appUtils/keyCodes/{keys.android.js → keys/keyEventMapper.ts} +0 -19
- package/appUtils/keyCodes/keys/keys.android.ts +18 -0
- package/appUtils/keyCodes/keys/keys.ios.ts +25 -0
- package/appUtils/keyCodes/keys/keys.ts +15 -0
- package/appUtils/keyCodes/keysByPlatform.ts +8 -0
- package/appUtils/platform/platformUtils.ts +0 -14
- package/domUtils/{cookieManager.js → cookieManager.ts} +1 -2
- package/functionUtils/index.ts +15 -11
- package/modalState/index.ts +1 -5
- package/navigationUtils/index.ts +14 -5
- package/package.json +2 -2
- package/reactHooks/navigation/index.ts +7 -4
- package/reactUtils/index.ts +0 -14
- package/appUtils/keyCodes/keys.ios.js +0 -46
- /package/appUtils/HooksManager/{logger.js → logger.ts} +0 -0
- /package/appUtils/{directionHelper.js → directionHelper.ts} +0 -0
- /package/appUtils/keyCodes/{androidTVKeys.js → androidTVKeys.ts} +0 -0
- /package/appUtils/keyCodes/{keys.web.js → keys/keys.web.ts} +0 -0
- /package/appUtils/keyCodes/{keysByPlatform.js → keys/keysByPlatform.ts} +0 -0
- /package/appUtils/{localizationsHelper.js → localizationsHelper.ts} +0 -0
- /package/domUtils/{logger.js → logger.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
|
|
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
|
|
34
|
+
* Representation of a hook plugin
|
|
32
35
|
*/
|
|
33
|
-
export class Hook {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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(
|
|
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
|
|
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
|
|
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,6 +1,6 @@
|
|
|
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
5
|
"advertising": Object {},
|
|
6
6
|
"general": Object {
|
|
@@ -13,8 +13,10 @@ Hook {
|
|
|
13
13
|
"lastHook": true,
|
|
14
14
|
"manager": Object {
|
|
15
15
|
"executeHook": [MockFunction],
|
|
16
|
-
"invokeHandler": [MockFunction],
|
|
17
16
|
"presentScreenHook": [MockFunction],
|
|
17
|
+
"subscriber": Object {
|
|
18
|
+
"invokeHandler": [MockFunction],
|
|
19
|
+
},
|
|
18
20
|
},
|
|
19
21
|
"name": "Hook Screen",
|
|
20
22
|
"navigations": Array [],
|