@applicaster/zapp-react-native-utils 14.0.7-rc.2 → 14.0.9-alpha.2354002522
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,8 +5,7 @@ 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
|
-
|
|
9
|
-
import { zappHookModalStore } from "@applicaster/zapp-react-native-ui-components/Contexts/ZappHookModalContext";
|
|
8
|
+
import { HookModalContextT } from "@applicaster/zapp-react-native-ui-components/Contexts/ZappHookModalContext";
|
|
10
9
|
import { logger } from "@applicaster/zapp-react-native-utils/logger";
|
|
11
10
|
import {
|
|
12
11
|
isGeneralPlugin,
|
|
@@ -16,8 +15,6 @@ import {
|
|
|
16
15
|
} from "./itemTypeMatchers";
|
|
17
16
|
import { RootState } from "@applicaster/zapp-react-native-redux/store";
|
|
18
17
|
|
|
19
|
-
import { pick } from "@applicaster/zapp-react-native-utils/utils";
|
|
20
|
-
|
|
21
18
|
type PathAttribute = {
|
|
22
19
|
screenType: string;
|
|
23
20
|
screenId: string;
|
|
@@ -406,22 +403,15 @@ export const mapContentTypesToRivers = (
|
|
|
406
403
|
};
|
|
407
404
|
|
|
408
405
|
export const runZappHooksForEntry = async (
|
|
409
|
-
entry: HookPluginProps["payload"]
|
|
410
|
-
|
|
411
|
-
const {
|
|
406
|
+
entry: HookPluginProps["payload"],
|
|
407
|
+
{
|
|
412
408
|
setState,
|
|
413
409
|
resetState,
|
|
414
410
|
setIsHooksExecutionInProgress,
|
|
415
411
|
setIsPresentingFullScreen,
|
|
416
412
|
setIsRunningInBackground,
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
"resetState",
|
|
420
|
-
"setIsHooksExecutionInProgress",
|
|
421
|
-
"setIsPresentingFullScreen",
|
|
422
|
-
"setIsRunningInBackground",
|
|
423
|
-
]);
|
|
424
|
-
|
|
413
|
+
}: Partial<HookModalContextT>
|
|
414
|
+
): Promise<{ success: boolean; payload: ZappEntry }> => {
|
|
425
415
|
resetState?.();
|
|
426
416
|
|
|
427
417
|
let success;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.9-alpha.2354002522",
|
|
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.
|
|
30
|
+
"@applicaster/applicaster-types": "14.0.9-alpha.2354002522",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
import { reactHooksLogger } from "../../logger";
|
|
2
|
-
import {
|
|
2
|
+
import { useZappHooksModalState } from "@applicaster/zapp-react-dom-ui-components/Components/ZappHooksModal/hooks/useZappHooksModalState";
|
|
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
|
-
|
|
10
|
-
): VariousScreenData | undefined => {
|
|
11
|
-
const hookModalState = useZappHookModalStore((state) =>
|
|
12
|
-
skipSubscription ? undefined : state.state
|
|
13
|
-
);
|
|
8
|
+
export const useHookModalScreenData = (): VariousScreenData | undefined => {
|
|
9
|
+
const hookModalState = useZappHooksModalState();
|
|
14
10
|
|
|
15
|
-
if (!hookModalState?.screenData) {
|
|
11
|
+
if (!hookModalState.state?.screenData) {
|
|
16
12
|
return;
|
|
17
13
|
}
|
|
18
14
|
|
|
19
15
|
try {
|
|
20
|
-
const screenData = hookModalState.screenData?.payload;
|
|
21
|
-
const hookPlugin = hookModalState.screenData.hookPlugin;
|
|
16
|
+
const screenData = hookModalState.state.screenData?.payload;
|
|
17
|
+
const hookPlugin = hookModalState.state.screenData.hookPlugin;
|
|
22
18
|
|
|
23
19
|
if (hookPlugin?.screen_id) {
|
|
24
20
|
return {
|
|
@@ -27,7 +23,7 @@ export const useHookModalScreenData = (
|
|
|
27
23
|
};
|
|
28
24
|
}
|
|
29
25
|
|
|
30
|
-
return hookModalState.screenData?.payload;
|
|
26
|
+
return hookModalState.state.screenData?.payload;
|
|
31
27
|
} catch (error) {
|
|
32
28
|
logger.error({
|
|
33
29
|
message: "Hook modal screen data creation failed",
|
|
@@ -38,6 +34,6 @@ export const useHookModalScreenData = (
|
|
|
38
34
|
jsOnly: true,
|
|
39
35
|
});
|
|
40
36
|
|
|
41
|
-
return hookModalState.screenData?.payload;
|
|
37
|
+
return hookModalState.state.screenData?.payload;
|
|
42
38
|
}
|
|
43
39
|
};
|
|
@@ -5,6 +5,7 @@ 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";
|
|
8
9
|
import { ROUTE_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/routeTypes";
|
|
9
10
|
import { ScreenDataContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
|
|
10
11
|
|
|
@@ -82,45 +83,9 @@ const hookModalContextState = {
|
|
|
82
83
|
},
|
|
83
84
|
setState: jest.fn(),
|
|
84
85
|
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
|
-
|
|
124
89
|
const videoModalPathname = `${ROUTE_TYPES.VIDEO_MODAL}/${videoModalNavigator.videoModalState.item.id}`;
|
|
125
90
|
const mockStore = configureMockStore();
|
|
126
91
|
|
|
@@ -160,11 +125,13 @@ const videoModalWrapper = ({ children }) => (
|
|
|
160
125
|
|
|
161
126
|
const hookModalWrapper = ({ children }) => (
|
|
162
127
|
<Provider store={store}>
|
|
163
|
-
<
|
|
164
|
-
<
|
|
165
|
-
{
|
|
166
|
-
|
|
167
|
-
|
|
128
|
+
<ZappHookModalContext.ReactContext.Provider value={hookModalContextState}>
|
|
129
|
+
<NavigationContext.Provider value={hookModalNavigator}>
|
|
130
|
+
<PathnameContext.Provider value={hooksModalPathname}>
|
|
131
|
+
{children}
|
|
132
|
+
</PathnameContext.Provider>
|
|
133
|
+
</NavigationContext.Provider>
|
|
134
|
+
</ZappHookModalContext.ReactContext.Provider>
|
|
168
135
|
</Provider>
|
|
169
136
|
);
|
|
170
137
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { useEffect, useMemo, useRef } from "react";
|
|
1
|
+
import { useContext, useEffect, useMemo, useRef } from "react";
|
|
2
2
|
import { BackHandler } from "react-native";
|
|
3
|
-
import { shallow } from "zustand/shallow";
|
|
4
3
|
|
|
5
4
|
import {
|
|
6
5
|
useContentTypes,
|
|
@@ -9,13 +8,13 @@ import {
|
|
|
9
8
|
import { HooksManager } from "@applicaster/zapp-react-native-utils/appUtils/HooksManager";
|
|
10
9
|
|
|
11
10
|
import { LONG_KEY_PRESS_TIMEOUT } from "@applicaster/quick-brick-core/const";
|
|
12
|
-
import {
|
|
11
|
+
import { ZappHookModalContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
|
|
12
|
+
import { HookModalContextT } 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";
|
|
19
18
|
import { useNavbarState } from "../screen";
|
|
20
19
|
|
|
21
20
|
export { useNavigation } from "./useNavigation";
|
|
@@ -167,17 +166,7 @@ export const useZappHooksForEntry = (
|
|
|
167
166
|
setIsHooksExecutionInProgress,
|
|
168
167
|
setIsPresentingFullScreen,
|
|
169
168
|
setIsRunningInBackground,
|
|
170
|
-
} =
|
|
171
|
-
(state) =>
|
|
172
|
-
pick(state, [
|
|
173
|
-
"setState",
|
|
174
|
-
"resetState",
|
|
175
|
-
"setIsHooksExecutionInProgress",
|
|
176
|
-
"setIsPresentingFullScreen",
|
|
177
|
-
"setIsRunningInBackground",
|
|
178
|
-
]),
|
|
179
|
-
shallow
|
|
180
|
-
);
|
|
169
|
+
}: HookModalContextT = useContext(ZappHookModalContext.ReactContext);
|
|
181
170
|
|
|
182
171
|
const {
|
|
183
172
|
appData: { layoutVersion },
|
|
@@ -52,9 +52,7 @@ export const useRoute = (
|
|
|
52
52
|
|
|
53
53
|
const modalScreenData = modalState.screen;
|
|
54
54
|
|
|
55
|
-
const hookModalScreenData = useHookModalScreenData(
|
|
56
|
-
!isHookModalPathname(pathname)
|
|
57
|
-
);
|
|
55
|
+
const hookModalScreenData = useHookModalScreenData();
|
|
58
56
|
|
|
59
57
|
const videoModalScreenData =
|
|
60
58
|
navigator?.videoModalState?.item &&
|