@applicaster/zapp-react-native-utils 14.0.7-rc.0 → 14.0.7-rc.2
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/navigationUtils/index.ts
CHANGED
|
@@ -5,7 +5,8 @@ import { layoutV2TypeMatcher } from "./layoutV2TypeMatcher";
|
|
|
5
5
|
import { HOOKS_EVENTS } from "../appUtils/HooksManager/constants";
|
|
6
6
|
import { HooksManager } from "../appUtils/HooksManager";
|
|
7
7
|
import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
import { zappHookModalStore } from "@applicaster/zapp-react-native-ui-components/Contexts/ZappHookModalContext";
|
|
9
10
|
import { logger } from "@applicaster/zapp-react-native-utils/logger";
|
|
10
11
|
import {
|
|
11
12
|
isGeneralPlugin,
|
|
@@ -15,6 +16,8 @@ import {
|
|
|
15
16
|
} from "./itemTypeMatchers";
|
|
16
17
|
import { RootState } from "@applicaster/zapp-react-native-redux/store";
|
|
17
18
|
|
|
19
|
+
import { pick } from "@applicaster/zapp-react-native-utils/utils";
|
|
20
|
+
|
|
18
21
|
type PathAttribute = {
|
|
19
22
|
screenType: string;
|
|
20
23
|
screenId: string;
|
|
@@ -403,15 +406,22 @@ export const mapContentTypesToRivers = (
|
|
|
403
406
|
};
|
|
404
407
|
|
|
405
408
|
export const runZappHooksForEntry = async (
|
|
406
|
-
entry: HookPluginProps["payload"]
|
|
407
|
-
|
|
409
|
+
entry: HookPluginProps["payload"]
|
|
410
|
+
): Promise<{ success: boolean; payload: ZappEntry }> => {
|
|
411
|
+
const {
|
|
408
412
|
setState,
|
|
409
413
|
resetState,
|
|
410
414
|
setIsHooksExecutionInProgress,
|
|
411
415
|
setIsPresentingFullScreen,
|
|
412
416
|
setIsRunningInBackground,
|
|
413
|
-
}
|
|
414
|
-
|
|
417
|
+
} = pick(zappHookModalStore.getState(), [
|
|
418
|
+
"setState",
|
|
419
|
+
"resetState",
|
|
420
|
+
"setIsHooksExecutionInProgress",
|
|
421
|
+
"setIsPresentingFullScreen",
|
|
422
|
+
"setIsRunningInBackground",
|
|
423
|
+
]);
|
|
424
|
+
|
|
415
425
|
resetState?.();
|
|
416
426
|
|
|
417
427
|
let success;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "14.0.7-rc.
|
|
3
|
+
"version": "14.0.7-rc.2",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@applicaster/applicaster-types": "14.0.7-rc.
|
|
30
|
+
"@applicaster/applicaster-types": "14.0.7-rc.2",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { reactHooksLogger } from "../../logger";
|
|
2
|
-
import {
|
|
2
|
+
import { useZappHookModalStore } from "@applicaster/zapp-react-native-ui-components/Contexts/ZappHookModalContext";
|
|
3
3
|
|
|
4
4
|
const logger = reactHooksLogger.addSubsystem("useHookModalScreenData");
|
|
5
5
|
|
|
6
6
|
type VariousScreenData = LegacyNavigationScreenData | ZappRiver | ZappEntry;
|
|
7
7
|
|
|
8
|
-
export const useHookModalScreenData = (
|
|
9
|
-
|
|
8
|
+
export const useHookModalScreenData = (
|
|
9
|
+
skipSubscription: boolean
|
|
10
|
+
): VariousScreenData | undefined => {
|
|
11
|
+
const hookModalState = useZappHookModalStore((state) =>
|
|
12
|
+
skipSubscription ? undefined : state.state
|
|
13
|
+
);
|
|
10
14
|
|
|
11
|
-
if (!hookModalState
|
|
15
|
+
if (!hookModalState?.screenData) {
|
|
12
16
|
return;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
try {
|
|
16
|
-
const screenData = hookModalState.
|
|
17
|
-
const hookPlugin = hookModalState.
|
|
20
|
+
const screenData = hookModalState.screenData?.payload;
|
|
21
|
+
const hookPlugin = hookModalState.screenData.hookPlugin;
|
|
18
22
|
|
|
19
23
|
if (hookPlugin?.screen_id) {
|
|
20
24
|
return {
|
|
@@ -23,7 +27,7 @@ export const useHookModalScreenData = (): VariousScreenData | undefined => {
|
|
|
23
27
|
};
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
return hookModalState.
|
|
30
|
+
return hookModalState.screenData?.payload;
|
|
27
31
|
} catch (error) {
|
|
28
32
|
logger.error({
|
|
29
33
|
message: "Hook modal screen data creation failed",
|
|
@@ -34,6 +38,6 @@ export const useHookModalScreenData = (): VariousScreenData | undefined => {
|
|
|
34
38
|
jsOnly: true,
|
|
35
39
|
});
|
|
36
40
|
|
|
37
|
-
return hookModalState.
|
|
41
|
+
return hookModalState.screenData?.payload;
|
|
38
42
|
}
|
|
39
43
|
};
|
|
@@ -5,7 +5,6 @@ import { isNavBarVisible, useRoute } from "../";
|
|
|
5
5
|
import { Provider } from "react-redux";
|
|
6
6
|
import configureMockStore from "redux-mock-store";
|
|
7
7
|
import { NavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NavigationContext";
|
|
8
|
-
import { ZappHookModalContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
|
|
9
8
|
import { ROUTE_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/routeTypes";
|
|
10
9
|
import { ScreenDataContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
|
|
11
10
|
|
|
@@ -83,9 +82,45 @@ const hookModalContextState = {
|
|
|
83
82
|
},
|
|
84
83
|
setState: jest.fn(),
|
|
85
84
|
resetState: jest.fn(),
|
|
85
|
+
hookPresentationMode: null,
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
const hooksModalPathname = `${ROUTE_TYPES.HOOKS_MODAL}/${hookModalContextState.state.screenData.payload.id}`;
|
|
89
|
+
|
|
90
|
+
jest.mock(
|
|
91
|
+
"@applicaster/zapp-react-native-ui-components/Contexts/ZappHookModalContext",
|
|
92
|
+
() => {
|
|
93
|
+
// Define state inside mock factory to avoid hoisting issues
|
|
94
|
+
const mockState = {
|
|
95
|
+
isRunningInBackground: false,
|
|
96
|
+
setIsRunningInBackground: jest.fn(),
|
|
97
|
+
setIsPresentingFullScreen: jest.fn(),
|
|
98
|
+
isPresentationFullScreen: true,
|
|
99
|
+
isHooksExecutionInProgress: true,
|
|
100
|
+
setIsHooksExecutionInProgress: jest.fn(),
|
|
101
|
+
state: {
|
|
102
|
+
path: "/home",
|
|
103
|
+
screenData: { payload: { id: "hookExecutedInModal" } },
|
|
104
|
+
},
|
|
105
|
+
setState: jest.fn(),
|
|
106
|
+
resetState: jest.fn(),
|
|
107
|
+
hookPresentationMode: null,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const mockHook = jest.fn((selector) => {
|
|
111
|
+
return selector ? selector(mockState) : mockState;
|
|
112
|
+
}) as jest.MockedFunction<any> & { getState: () => typeof mockState };
|
|
113
|
+
|
|
114
|
+
// Add getState method to the mock hook (Zustand stores have this)
|
|
115
|
+
mockHook.getState = jest.fn(() => mockState);
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
useZappHookModalStore: mockHook,
|
|
119
|
+
zappHookModalStore: mockHook,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
|
|
89
124
|
const videoModalPathname = `${ROUTE_TYPES.VIDEO_MODAL}/${videoModalNavigator.videoModalState.item.id}`;
|
|
90
125
|
const mockStore = configureMockStore();
|
|
91
126
|
|
|
@@ -125,13 +160,11 @@ const videoModalWrapper = ({ children }) => (
|
|
|
125
160
|
|
|
126
161
|
const hookModalWrapper = ({ children }) => (
|
|
127
162
|
<Provider store={store}>
|
|
128
|
-
<
|
|
129
|
-
<
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
</NavigationContext.Provider>
|
|
134
|
-
</ZappHookModalContext.ReactContext.Provider>
|
|
163
|
+
<NavigationContext.Provider value={hookModalNavigator}>
|
|
164
|
+
<PathnameContext.Provider value={hooksModalPathname}>
|
|
165
|
+
{children}
|
|
166
|
+
</PathnameContext.Provider>
|
|
167
|
+
</NavigationContext.Provider>
|
|
135
168
|
</Provider>
|
|
136
169
|
);
|
|
137
170
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
2
2
|
import { BackHandler } from "react-native";
|
|
3
|
+
import { shallow } from "zustand/shallow";
|
|
3
4
|
|
|
4
5
|
import {
|
|
5
6
|
useContentTypes,
|
|
@@ -8,13 +9,13 @@ import {
|
|
|
8
9
|
import { HooksManager } from "@applicaster/zapp-react-native-utils/appUtils/HooksManager";
|
|
9
10
|
|
|
10
11
|
import { LONG_KEY_PRESS_TIMEOUT } from "@applicaster/quick-brick-core/const";
|
|
11
|
-
import {
|
|
12
|
-
import { HookModalContextT } from "@applicaster/zapp-react-native-ui-components/Contexts/ZappHookModalContext";
|
|
12
|
+
import { useZappHookModalStore } from "@applicaster/zapp-react-native-ui-components/Contexts/ZappHookModalContext";
|
|
13
13
|
import { HOOKS_EVENTS } from "../../appUtils/HooksManager/constants";
|
|
14
14
|
import { getRiverFromRoute, getTargetRoute } from "../../navigationUtils";
|
|
15
15
|
import { useConnectionInfo } from "../connection";
|
|
16
16
|
|
|
17
17
|
import { isTV, isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
18
|
+
import { pick } from "@applicaster/zapp-react-native-utils/utils";
|
|
18
19
|
import { useNavbarState } from "../screen";
|
|
19
20
|
|
|
20
21
|
export { useNavigation } from "./useNavigation";
|
|
@@ -166,7 +167,17 @@ export const useZappHooksForEntry = (
|
|
|
166
167
|
setIsHooksExecutionInProgress,
|
|
167
168
|
setIsPresentingFullScreen,
|
|
168
169
|
setIsRunningInBackground,
|
|
169
|
-
}
|
|
170
|
+
} = useZappHookModalStore(
|
|
171
|
+
(state) =>
|
|
172
|
+
pick(state, [
|
|
173
|
+
"setState",
|
|
174
|
+
"resetState",
|
|
175
|
+
"setIsHooksExecutionInProgress",
|
|
176
|
+
"setIsPresentingFullScreen",
|
|
177
|
+
"setIsRunningInBackground",
|
|
178
|
+
]),
|
|
179
|
+
shallow
|
|
180
|
+
);
|
|
170
181
|
|
|
171
182
|
const {
|
|
172
183
|
appData: { layoutVersion },
|
|
@@ -52,7 +52,9 @@ export const useRoute = (
|
|
|
52
52
|
|
|
53
53
|
const modalScreenData = modalState.screen;
|
|
54
54
|
|
|
55
|
-
const hookModalScreenData = useHookModalScreenData(
|
|
55
|
+
const hookModalScreenData = useHookModalScreenData(
|
|
56
|
+
!isHookModalPathname(pathname)
|
|
57
|
+
);
|
|
56
58
|
|
|
57
59
|
const videoModalScreenData =
|
|
58
60
|
navigator?.videoModalState?.item &&
|