@applicaster/quick-brick-core 14.0.0-alpha.6242515303 → 14.0.0-alpha.6391068513
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/App/ActionsProvider/__tests__/__snapshots__/ActionsProvider.test.js.snap +2 -2
- package/App/ActionsProvider/index.js +1 -1
- package/App/AppStateDecorator/index.tsx +9 -4
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useOpenSchemeHandler.test.tsx +4 -12
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/usePresentSchemeHandler.test.tsx +34 -41
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useUrlSchemeHandler.test.tsx +1 -1
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/useOpenSchemeHandler/index.ts +7 -2
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/usePresentSchemeHandler.ts +6 -4
- package/App/DeepLinking/URLSchemeHandler/__tests__/URLSchemeHandler.test.tsx +4 -4
- package/App/ErrorBoundary/index.tsx +4 -0
- package/App/ModalProvider/ModalBottomSheet/ModalBottomSheetFrame.tsx +1 -1
- package/App/NavigationProvider/navigator/__tests__/__snapshots__/reducer.test.ts.snap +19 -0
- package/App/NavigationProvider/navigator/reducer.ts +59 -19
- package/App/NavigationProvider/navigator/selectors.ts +2 -1
- package/App/NetworkStatusProvider/__tests__/NetworkStatusProvider.test.tsx +11 -15
- package/App/StoreConnector/__tests__/storeConnector.test.js +6 -9
- package/App/StoreConnector/index.ts +1 -1
- package/App/appLifeCycleManager/__tests__/appLifeCycleManager.test.tsx +29 -25
- package/App/appLifeCycleManager/index.tsx +5 -6
- package/App/index.tsx +4 -1
- package/App/remoteContextReloader/__tests__/getRemoteContextData.test.js +11 -12
- package/App/remoteContextReloader/getRemoteContextData/getNativeRemoteContextData.ts +5 -3
- package/README.md +0 -4
- package/createZappApp/index.tsx +4 -5
- package/package.json +9 -10
- package/renderZappApp/index.js +2 -1
|
@@ -12,18 +12,18 @@ exports[`Actions Provider renders children 1`] = `
|
|
|
12
12
|
"$$typeof": Symbol(react.context),
|
|
13
13
|
"Consumer": {
|
|
14
14
|
"$$typeof": Symbol(react.context),
|
|
15
|
-
"_calculateChangedBits": null,
|
|
16
15
|
"_context": [Circular],
|
|
17
16
|
},
|
|
18
17
|
"Provider": {
|
|
19
18
|
"$$typeof": Symbol(react.provider),
|
|
20
19
|
"_context": [Circular],
|
|
21
20
|
},
|
|
22
|
-
"_calculateChangedBits": null,
|
|
23
21
|
"_currentRenderer": null,
|
|
24
22
|
"_currentRenderer2": {},
|
|
25
23
|
"_currentValue": null,
|
|
26
24
|
"_currentValue2": null,
|
|
25
|
+
"_defaultValue": null,
|
|
26
|
+
"_globalName": null,
|
|
27
27
|
"_threadCount": 0,
|
|
28
28
|
},
|
|
29
29
|
"contextProvider": [Function],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
|
|
4
|
-
import { connectToStore } from "@applicaster/zapp-react-native-redux";
|
|
4
|
+
import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
|
|
5
5
|
|
|
6
6
|
import { ActionsProvider as ActionsProviderComponent } from "./ActionsProvider";
|
|
7
7
|
|
|
@@ -2,9 +2,9 @@ import * as React from "react";
|
|
|
2
2
|
import { AppState, AppStateStatus } from "react-native";
|
|
3
3
|
import * as R from "ramda";
|
|
4
4
|
|
|
5
|
-
import { connectToStore } from "@applicaster/zapp-react-native-redux";
|
|
5
|
+
import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
|
|
6
6
|
import { setAppState } from "@applicaster/zapp-react-native-redux/appState";
|
|
7
|
-
import { Dispatch } from "
|
|
7
|
+
import { Dispatch } from "@reduxjs/toolkit";
|
|
8
8
|
|
|
9
9
|
type Props = {
|
|
10
10
|
Component: () => React.ComponentType<any>;
|
|
@@ -19,6 +19,7 @@ function withAppManagerDecorator(
|
|
|
19
19
|
currentState: AppStateStatus;
|
|
20
20
|
isAvailable: boolean;
|
|
21
21
|
plugins: QuickBrickPlugin[];
|
|
22
|
+
appStateListener: ReturnType<typeof AppState.addEventListener>;
|
|
22
23
|
|
|
23
24
|
constructor(props: Props) {
|
|
24
25
|
super(props);
|
|
@@ -30,11 +31,15 @@ function withAppManagerDecorator(
|
|
|
30
31
|
|
|
31
32
|
componentDidMount() {
|
|
32
33
|
this.plugins = this.getAppStatePlugins();
|
|
33
|
-
|
|
34
|
+
|
|
35
|
+
this.appStateListener = AppState.addEventListener(
|
|
36
|
+
"change",
|
|
37
|
+
this.onChange
|
|
38
|
+
);
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
componentWillUnmount() {
|
|
37
|
-
|
|
42
|
+
this.appStateListener.remove();
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
dispatchAction(nextState: AppStateStatus, eventType) {
|
package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useOpenSchemeHandler.test.tsx
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "../useOpenSchemeHandler/const";
|
|
17
17
|
import { withInitialPlayerState } from "../useOpenSchemeHandler/utils";
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
import { log_warning } from "../../../logger";
|
|
20
20
|
|
|
21
21
|
const rivers: Record<string, Partial<ZappRiver>> = {
|
|
22
22
|
A1234: {
|
|
@@ -53,13 +53,10 @@ const navigator = {
|
|
|
53
53
|
replace: jest.fn(),
|
|
54
54
|
push: jest.fn(),
|
|
55
55
|
goHome: jest.fn(),
|
|
56
|
-
};
|
|
56
|
+
} as any;
|
|
57
57
|
|
|
58
58
|
const mockStore = configureStore();
|
|
59
|
-
|
|
60
|
-
jest
|
|
61
|
-
.spyOn(useNavigationHooks, "useNavigation")
|
|
62
|
-
.mockImplementation(() => navigator);
|
|
59
|
+
jest.spyOn(useNavigationHooks, "useNavigation").mockReturnValue(navigator);
|
|
63
60
|
|
|
64
61
|
const helperSpy = jest.spyOn(helpers, "handlePresentNavigation");
|
|
65
62
|
const feedLoaderSpy = jest.spyOn(feedLoader, "useFeedLoader");
|
|
@@ -72,7 +69,7 @@ jest.doMock("@applicaster/zapp-react-native-ui-components/Contexts", () => ({
|
|
|
72
69
|
},
|
|
73
70
|
}));
|
|
74
71
|
|
|
75
|
-
jest.
|
|
72
|
+
jest.mock("../../../logger", () => ({
|
|
76
73
|
log_info: jest.fn(),
|
|
77
74
|
log_error: jest.fn(),
|
|
78
75
|
log_warning: jest.fn(),
|
|
@@ -80,10 +77,6 @@ jest.doMock("../../../logger", () => ({
|
|
|
80
77
|
log_debug: jest.fn(),
|
|
81
78
|
}));
|
|
82
79
|
|
|
83
|
-
jest.useFakeTimers({
|
|
84
|
-
legacyFakeTimers: true,
|
|
85
|
-
});
|
|
86
|
-
|
|
87
80
|
// to use import instead of require it's required to use jest.mock above
|
|
88
81
|
const { useOpenSchemeHandler } = require("../useOpenSchemeHandler");
|
|
89
82
|
|
|
@@ -192,7 +185,6 @@ describe("useOpenSchemeHandler", () => {
|
|
|
192
185
|
it("doesn't log a warning", async () => {
|
|
193
186
|
const tests = () => {
|
|
194
187
|
expect(log_warning).not.toHaveBeenCalled();
|
|
195
|
-
expect.assertions(1);
|
|
196
188
|
};
|
|
197
189
|
|
|
198
190
|
await testHook({ url, query, tests });
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
import * as R from "ramda";
|
|
3
2
|
import axios from "axios";
|
|
4
|
-
import { renderHook } from "@testing-library/react-
|
|
3
|
+
import { renderHook } from "@testing-library/react-native";
|
|
5
4
|
import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
|
|
6
|
-
import * as zappRedux from "@applicaster/zapp-react-native-redux";
|
|
7
5
|
import * as helpers from "../../../helpers";
|
|
8
6
|
import * as feedLoader from "@applicaster/zapp-react-native-utils/reactHooks/feed/useFeedLoader";
|
|
9
|
-
import
|
|
7
|
+
import { WrappedWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
8
|
+
import { usePresentSchemeHandler } from "../usePresentSchemeHandler";
|
|
10
9
|
|
|
11
|
-
import { Provider } from "react-redux";
|
|
12
10
|
import configureStore from "redux-mock-store";
|
|
13
11
|
|
|
14
12
|
const rivers = {
|
|
@@ -17,26 +15,31 @@ const rivers = {
|
|
|
17
15
|
},
|
|
18
16
|
};
|
|
19
17
|
|
|
20
|
-
const
|
|
18
|
+
const mock_navigator = {
|
|
21
19
|
currentRoute: "/river/A1234",
|
|
22
20
|
replace: jest.fn(),
|
|
23
|
-
|
|
21
|
+
goHome: jest.fn(),
|
|
22
|
+
} as any;
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
jest.mock(
|
|
25
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation",
|
|
26
|
+
() => ({
|
|
27
|
+
useNavigation: jest.fn(() => mock_navigator),
|
|
28
|
+
})
|
|
29
|
+
);
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
.spyOn(useNavigationHooks, "useNavigation")
|
|
29
|
-
.mockImplementation(() => navigator);
|
|
31
|
+
const mockStore = configureStore();
|
|
30
32
|
|
|
31
33
|
const helperSpy = jest.spyOn(helpers, "handlePresentNavigation");
|
|
32
34
|
const feedLoaderSpy = jest.spyOn(feedLoader, "useFeedLoader");
|
|
33
35
|
|
|
34
|
-
const { usePresentSchemeHandler } = require("../usePresentSchemeHandler");
|
|
35
|
-
|
|
36
36
|
const onFinish = jest.fn((cb) => {
|
|
37
37
|
cb();
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
+
const navigator = mock_navigator;
|
|
41
|
+
jest.useFakeTimers();
|
|
42
|
+
|
|
40
43
|
describe("usePresentSchemeHandler", () => {
|
|
41
44
|
beforeEach(() => {
|
|
42
45
|
onFinish.mockClear();
|
|
@@ -44,11 +47,7 @@ describe("usePresentSchemeHandler", () => {
|
|
|
44
47
|
navigator.replace.mockClear();
|
|
45
48
|
});
|
|
46
49
|
|
|
47
|
-
const store =
|
|
48
|
-
|
|
49
|
-
const wrapper: React.FC<any> = ({ children }) => (
|
|
50
|
-
<Provider store={store}>{children}</Provider>
|
|
51
|
-
);
|
|
50
|
+
const store = { test: "test", rivers };
|
|
52
51
|
|
|
53
52
|
describe("loading link url", () => {
|
|
54
53
|
const query = { link_url: "http://applicaster.com" };
|
|
@@ -59,10 +58,11 @@ describe("usePresentSchemeHandler", () => {
|
|
|
59
58
|
|
|
60
59
|
it("opens the link entry", () => {
|
|
61
60
|
renderHook(() => usePresentSchemeHandler({ query, url, onFinish }), {
|
|
62
|
-
wrapper,
|
|
61
|
+
wrapper: WrappedWithProviders,
|
|
62
|
+
initialProps: { store },
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
expect(onFinish).
|
|
65
|
+
expect(onFinish).toHaveBeenCalled();
|
|
66
66
|
|
|
67
67
|
expect(helperSpy).toBeCalledWith(
|
|
68
68
|
expect.objectContaining({
|
|
@@ -96,7 +96,8 @@ describe("usePresentSchemeHandler", () => {
|
|
|
96
96
|
onFinish,
|
|
97
97
|
}),
|
|
98
98
|
{
|
|
99
|
-
wrapper,
|
|
99
|
+
wrapper: WrappedWithProviders,
|
|
100
|
+
initialProps: { store },
|
|
100
101
|
}
|
|
101
102
|
);
|
|
102
103
|
|
|
@@ -123,7 +124,8 @@ describe("usePresentSchemeHandler", () => {
|
|
|
123
124
|
)}&show_nav_bar=true`;
|
|
124
125
|
|
|
125
126
|
renderHook(() => usePresentSchemeHandler({ query, url, onFinish }), {
|
|
126
|
-
wrapper,
|
|
127
|
+
wrapper: WrappedWithProviders,
|
|
128
|
+
initialProps: { store },
|
|
127
129
|
});
|
|
128
130
|
|
|
129
131
|
expect(onFinish).toBeCalled();
|
|
@@ -155,22 +157,22 @@ describe("usePresentSchemeHandler", () => {
|
|
|
155
157
|
)}&screen_id=${screen_id}`;
|
|
156
158
|
|
|
157
159
|
renderHook(() => usePresentSchemeHandler({ query, url, onFinish }), {
|
|
158
|
-
wrapper,
|
|
160
|
+
wrapper: WrappedWithProviders,
|
|
161
|
+
initialProps: { store },
|
|
159
162
|
});
|
|
160
163
|
|
|
161
164
|
expect(onFinish).toBeCalled();
|
|
162
165
|
|
|
163
|
-
expect(helperSpy).
|
|
166
|
+
expect(helperSpy).toHaveBeenCalledWith(
|
|
164
167
|
expect.objectContaining({
|
|
165
168
|
data: {
|
|
166
169
|
id: "url_scheme_entry",
|
|
167
170
|
type: { value: "link" },
|
|
168
|
-
screen_type: screen_id,
|
|
169
171
|
link: { href: query.link_url, type: "text/html" },
|
|
170
172
|
extensions: { showNavBar: false },
|
|
171
173
|
},
|
|
172
|
-
navigator,
|
|
173
|
-
pushScreen:
|
|
174
|
+
navigator: expect.anything(),
|
|
175
|
+
pushScreen: "http://applicaster.com",
|
|
174
176
|
})
|
|
175
177
|
);
|
|
176
178
|
});
|
|
@@ -180,9 +182,7 @@ describe("usePresentSchemeHandler", () => {
|
|
|
180
182
|
it("Re-sets app ready state and calls loadAppContextData with new river and cellStyles data", async () => {
|
|
181
183
|
const store = mockStore({ test: "test" });
|
|
182
184
|
|
|
183
|
-
const wrapper
|
|
184
|
-
<Provider store={store}>{children}</Provider>
|
|
185
|
-
);
|
|
185
|
+
const wrapper = WrappedWithProviders;
|
|
186
186
|
|
|
187
187
|
const query = {
|
|
188
188
|
rivers_configuration_id: "test",
|
|
@@ -190,7 +190,6 @@ describe("usePresentSchemeHandler", () => {
|
|
|
190
190
|
|
|
191
191
|
const storageSpy = jest.spyOn(sessionStorage, "getAllItems");
|
|
192
192
|
const axiosGetSpy = jest.spyOn(axios, "get");
|
|
193
|
-
const zappReduxSpy = jest.spyOn(zappRedux, "loadAppContextData");
|
|
194
193
|
|
|
195
194
|
const getAllItems = jest.fn().mockResolvedValue({
|
|
196
195
|
accountsAccountId: "accountsAccountId",
|
|
@@ -204,7 +203,6 @@ describe("usePresentSchemeHandler", () => {
|
|
|
204
203
|
|
|
205
204
|
storageSpy.mockImplementation(getAllItems);
|
|
206
205
|
axiosGetSpy.mockImplementation(get);
|
|
207
|
-
zappReduxSpy.mockReturnValue(null);
|
|
208
206
|
|
|
209
207
|
renderHook(() => usePresentSchemeHandler({ query, url: "", onFinish }), {
|
|
210
208
|
wrapper,
|
|
@@ -219,11 +217,6 @@ describe("usePresentSchemeHandler", () => {
|
|
|
219
217
|
|
|
220
218
|
expect(actions?.find(R.propEq("type", "SET_APP_READY"))).toBeDefined();
|
|
221
219
|
|
|
222
|
-
expect(zappReduxSpy).toBeCalledWith(expect.any(Function), {
|
|
223
|
-
cellStyles: "url",
|
|
224
|
-
rivers: "url",
|
|
225
|
-
});
|
|
226
|
-
|
|
227
220
|
expect(navigator.replace).toBeCalledWith({});
|
|
228
221
|
};
|
|
229
222
|
});
|
|
@@ -261,7 +254,7 @@ describe("usePresentSchemeHandler", () => {
|
|
|
261
254
|
},
|
|
262
255
|
}),
|
|
263
256
|
{
|
|
264
|
-
wrapper,
|
|
257
|
+
wrapper: WrappedWithProviders,
|
|
265
258
|
}
|
|
266
259
|
);
|
|
267
260
|
|
|
@@ -293,7 +286,7 @@ describe("usePresentSchemeHandler", () => {
|
|
|
293
286
|
},
|
|
294
287
|
}),
|
|
295
288
|
{
|
|
296
|
-
wrapper,
|
|
289
|
+
wrapper: WrappedWithProviders,
|
|
297
290
|
}
|
|
298
291
|
);
|
|
299
292
|
|
|
@@ -325,7 +318,7 @@ describe("usePresentSchemeHandler", () => {
|
|
|
325
318
|
},
|
|
326
319
|
}),
|
|
327
320
|
{
|
|
328
|
-
wrapper,
|
|
321
|
+
wrapper: WrappedWithProviders,
|
|
329
322
|
}
|
|
330
323
|
);
|
|
331
324
|
|
|
@@ -357,7 +350,7 @@ describe("usePresentSchemeHandler", () => {
|
|
|
357
350
|
},
|
|
358
351
|
}),
|
|
359
352
|
{
|
|
360
|
-
wrapper,
|
|
353
|
+
wrapper: WrappedWithProviders,
|
|
361
354
|
}
|
|
362
355
|
);
|
|
363
356
|
|
package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useUrlSchemeHandler.test.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import * as URLHandlersMap from "..";
|
|
|
5
5
|
import { Provider } from "react-redux";
|
|
6
6
|
import configureStore from "redux-mock-store";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import { log_warning } from "../../../logger";
|
|
9
9
|
|
|
10
10
|
const mockStore = configureStore();
|
|
11
11
|
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useAppSelector,
|
|
3
|
+
selectContentTypes,
|
|
4
|
+
selectRivers,
|
|
5
|
+
} from "@applicaster/zapp-react-native-redux";
|
|
2
6
|
import { ZappPipesEntryContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
|
|
3
7
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
4
8
|
import { useEffect } from "react";
|
|
@@ -97,7 +101,8 @@ async function handleQuery({
|
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
export function useOpenSchemeHandler({ query, url, onFinish }) {
|
|
100
|
-
const
|
|
104
|
+
const rivers = useAppSelector(selectRivers);
|
|
105
|
+
const contentTypes = useAppSelector(selectContentTypes);
|
|
101
106
|
const navigator = useNavigation();
|
|
102
107
|
const homeId = getHomeScreenId(rivers);
|
|
103
108
|
const homeRoute = `/river/${homeId}`;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
loadAppContextData,
|
|
3
|
+
useAppDispatch,
|
|
4
|
+
useActions,
|
|
5
|
+
} from "@applicaster/zapp-react-native-redux";
|
|
2
6
|
import * as R from "ramda";
|
|
3
7
|
import * as React from "react";
|
|
4
8
|
import axios from "axios";
|
|
5
|
-
import { useDispatch } from "react-redux";
|
|
6
9
|
|
|
7
10
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
8
11
|
|
|
9
12
|
import { useFeedLoader } from "@applicaster/zapp-react-native-utils/reactHooks/feed/useFeedLoader";
|
|
10
13
|
|
|
11
14
|
import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
|
|
12
|
-
import { loadAppContextData } from "@applicaster/zapp-react-native-redux";
|
|
13
15
|
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
14
16
|
|
|
15
17
|
import {
|
|
@@ -60,7 +62,7 @@ export function usePresentSchemeHandler({
|
|
|
60
62
|
|
|
61
63
|
const rivers = useRivers();
|
|
62
64
|
const screenRiver = findRiver({ screen_id, rivers });
|
|
63
|
-
const dispatch =
|
|
65
|
+
const dispatch = useAppDispatch();
|
|
64
66
|
|
|
65
67
|
const actions = useActions({
|
|
66
68
|
setAppReady,
|
|
@@ -6,16 +6,16 @@ const theme = {
|
|
|
6
6
|
app_background_color: "white",
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
jest.mock(
|
|
10
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation"
|
|
11
|
+
);
|
|
12
12
|
|
|
13
13
|
jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
|
|
14
14
|
useTheme: jest.fn(() => theme),
|
|
15
15
|
}));
|
|
16
16
|
|
|
17
17
|
jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
|
|
18
|
-
usePickFromState: jest.fn(() =>
|
|
18
|
+
usePickFromState: jest.fn(() => ({})),
|
|
19
19
|
}));
|
|
20
20
|
|
|
21
21
|
const { URLSchemeHandler } = require("../URLSchemeHandler");
|
|
@@ -60,6 +60,10 @@ export class ErrorBoundary extends React.Component<Props> {
|
|
|
60
60
|
useErrorStore.getState().setError(error, info, recoverable);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
static getDerivedStateFromError(_error) {
|
|
64
|
+
return { hasError: true };
|
|
65
|
+
}
|
|
66
|
+
|
|
63
67
|
render() {
|
|
64
68
|
return <ErrorBoundaryContent>{this.props.children}</ErrorBoundaryContent>;
|
|
65
69
|
}
|
|
@@ -47,7 +47,7 @@ const getSheetHeight = ({ height, bottomOffset, maxHeight }) => {
|
|
|
47
47
|
ios: height - bottomOffset,
|
|
48
48
|
default:
|
|
49
49
|
(height || maxHeight) -
|
|
50
|
-
(
|
|
50
|
+
(isAndroidPlatform() && !isAndroidVersionAtLeast(35) ? bottomOffset : 0),
|
|
51
51
|
});
|
|
52
52
|
};
|
|
53
53
|
|
|
@@ -44,6 +44,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
44
44
|
"supports_offline": false,
|
|
45
45
|
"type": "general_content",
|
|
46
46
|
},
|
|
47
|
+
"screenStateStore": [Function],
|
|
47
48
|
},
|
|
48
49
|
},
|
|
49
50
|
"options": {
|
|
@@ -79,6 +80,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
79
80
|
"supports_offline": false,
|
|
80
81
|
"type": "general_content",
|
|
81
82
|
},
|
|
83
|
+
"screenStateStore": undefined,
|
|
82
84
|
},
|
|
83
85
|
},
|
|
84
86
|
],
|
|
@@ -114,6 +116,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
114
116
|
"supports_offline": false,
|
|
115
117
|
"type": "general_content",
|
|
116
118
|
},
|
|
119
|
+
"screenStateStore": [Function],
|
|
117
120
|
},
|
|
118
121
|
},
|
|
119
122
|
"options": {
|
|
@@ -149,6 +152,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
149
152
|
"supports_offline": false,
|
|
150
153
|
"type": "general_content",
|
|
151
154
|
},
|
|
155
|
+
"screenStateStore": undefined,
|
|
152
156
|
},
|
|
153
157
|
},
|
|
154
158
|
{
|
|
@@ -180,6 +184,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
180
184
|
"supports_offline": false,
|
|
181
185
|
"type": "general_content",
|
|
182
186
|
},
|
|
187
|
+
"screenStateStore": undefined,
|
|
183
188
|
},
|
|
184
189
|
},
|
|
185
190
|
],
|
|
@@ -215,6 +220,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
215
220
|
"supports_offline": false,
|
|
216
221
|
"type": "general_content",
|
|
217
222
|
},
|
|
223
|
+
"screenStateStore": [Function],
|
|
218
224
|
},
|
|
219
225
|
},
|
|
220
226
|
"options": {
|
|
@@ -250,6 +256,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
250
256
|
"supports_offline": false,
|
|
251
257
|
"type": "general_content",
|
|
252
258
|
},
|
|
259
|
+
"screenStateStore": undefined,
|
|
253
260
|
},
|
|
254
261
|
},
|
|
255
262
|
{
|
|
@@ -281,6 +288,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
281
288
|
"supports_offline": false,
|
|
282
289
|
"type": "general_content",
|
|
283
290
|
},
|
|
291
|
+
"screenStateStore": undefined,
|
|
284
292
|
},
|
|
285
293
|
},
|
|
286
294
|
{
|
|
@@ -312,6 +320,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
312
320
|
"supports_offline": false,
|
|
313
321
|
"type": "general_content",
|
|
314
322
|
},
|
|
323
|
+
"screenStateStore": undefined,
|
|
315
324
|
},
|
|
316
325
|
},
|
|
317
326
|
],
|
|
@@ -348,6 +357,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
348
357
|
"supports_offline": false,
|
|
349
358
|
"type": "general_content",
|
|
350
359
|
},
|
|
360
|
+
"screenStateStore": undefined,
|
|
351
361
|
},
|
|
352
362
|
},
|
|
353
363
|
"options": {
|
|
@@ -383,6 +393,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
383
393
|
"supports_offline": false,
|
|
384
394
|
"type": "general_content",
|
|
385
395
|
},
|
|
396
|
+
"screenStateStore": undefined,
|
|
386
397
|
},
|
|
387
398
|
},
|
|
388
399
|
{
|
|
@@ -414,6 +425,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
414
425
|
"supports_offline": false,
|
|
415
426
|
"type": "general_content",
|
|
416
427
|
},
|
|
428
|
+
"screenStateStore": undefined,
|
|
417
429
|
},
|
|
418
430
|
},
|
|
419
431
|
],
|
|
@@ -449,6 +461,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
449
461
|
"supports_offline": false,
|
|
450
462
|
"type": "general_content",
|
|
451
463
|
},
|
|
464
|
+
"screenStateStore": [Function],
|
|
452
465
|
},
|
|
453
466
|
},
|
|
454
467
|
"options": {
|
|
@@ -484,6 +497,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
484
497
|
"supports_offline": false,
|
|
485
498
|
"type": "general_content",
|
|
486
499
|
},
|
|
500
|
+
"screenStateStore": undefined,
|
|
487
501
|
},
|
|
488
502
|
},
|
|
489
503
|
{
|
|
@@ -515,6 +529,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
515
529
|
"supports_offline": false,
|
|
516
530
|
"type": "general_content",
|
|
517
531
|
},
|
|
532
|
+
"screenStateStore": undefined,
|
|
518
533
|
},
|
|
519
534
|
},
|
|
520
535
|
{
|
|
@@ -546,6 +561,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
546
561
|
"supports_offline": false,
|
|
547
562
|
"type": "general_content",
|
|
548
563
|
},
|
|
564
|
+
"screenStateStore": undefined,
|
|
549
565
|
},
|
|
550
566
|
},
|
|
551
567
|
],
|
|
@@ -582,6 +598,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
582
598
|
"supports_offline": false,
|
|
583
599
|
"type": "general_content",
|
|
584
600
|
},
|
|
601
|
+
"screenStateStore": undefined,
|
|
585
602
|
},
|
|
586
603
|
},
|
|
587
604
|
"options": {
|
|
@@ -617,6 +634,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
617
634
|
"supports_offline": false,
|
|
618
635
|
"type": "general_content",
|
|
619
636
|
},
|
|
637
|
+
"screenStateStore": undefined,
|
|
620
638
|
},
|
|
621
639
|
},
|
|
622
640
|
{
|
|
@@ -648,6 +666,7 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
648
666
|
"supports_offline": false,
|
|
649
667
|
"type": "general_content",
|
|
650
668
|
},
|
|
669
|
+
"screenStateStore": undefined,
|
|
651
670
|
},
|
|
652
671
|
},
|
|
653
672
|
],
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
firstStackEntriesSelector,
|
|
6
6
|
previousStackEntriesSelector,
|
|
7
7
|
} from "./selectors";
|
|
8
|
+
import { create, StoreApi, UseBoundStore } from "zustand";
|
|
8
9
|
|
|
9
10
|
/* initial state */
|
|
10
11
|
|
|
@@ -120,12 +121,12 @@ export const setNestedContent = (
|
|
|
120
121
|
|
|
121
122
|
const navigationEntry = (
|
|
122
123
|
type: ActionValues,
|
|
123
|
-
{ route, screen, entry, key, options }: AnyRecord
|
|
124
|
+
{ route, screen, entry, key, options, screenStateStore }: AnyRecord
|
|
124
125
|
) => ({
|
|
125
126
|
key,
|
|
126
127
|
action: type,
|
|
127
128
|
route,
|
|
128
|
-
state: { screen, entry, options },
|
|
129
|
+
state: { screen, entry, options, screenStateStore },
|
|
129
130
|
});
|
|
130
131
|
|
|
131
132
|
function updatePopActions(state) {
|
|
@@ -274,6 +275,25 @@ function locationReducer(
|
|
|
274
275
|
) {
|
|
275
276
|
const { route, key, screen, entry, options } = payload;
|
|
276
277
|
|
|
278
|
+
const screenStateStore: UseBoundStore<StoreApi<ScreenStateStore>> =
|
|
279
|
+
create<ScreenStateStore>((set) => ({
|
|
280
|
+
data: {},
|
|
281
|
+
setValue: (key, value) =>
|
|
282
|
+
set((state) => ({
|
|
283
|
+
data: {
|
|
284
|
+
...state.data,
|
|
285
|
+
[key]: value,
|
|
286
|
+
},
|
|
287
|
+
})),
|
|
288
|
+
removeValue: (key) =>
|
|
289
|
+
set((state) => {
|
|
290
|
+
const newData = { ...state.data };
|
|
291
|
+
delete newData[key];
|
|
292
|
+
|
|
293
|
+
return { data: newData };
|
|
294
|
+
}),
|
|
295
|
+
}));
|
|
296
|
+
|
|
277
297
|
switch (type) {
|
|
278
298
|
case ACTIONS.BACK:
|
|
279
299
|
// eslint-disable-next-line no-case-declarations
|
|
@@ -294,14 +314,18 @@ function locationReducer(
|
|
|
294
314
|
case ACTIONS.REPLACE:
|
|
295
315
|
case ACTIONS.REPLACE_TOP:
|
|
296
316
|
case ACTIONS.BACK_PLAYER_NESTED_CONTENT:
|
|
297
|
-
return {
|
|
317
|
+
return {
|
|
318
|
+
pathname: route,
|
|
319
|
+
state: { screen, entry, options, screenStateStore },
|
|
320
|
+
key,
|
|
321
|
+
};
|
|
298
322
|
|
|
299
323
|
case ACTIONS.SET_NESTED_CONTENT:
|
|
300
324
|
// eslint-disable-next-line no-case-declarations
|
|
301
|
-
const nestedEntry = navigationEntry(
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
);
|
|
325
|
+
const nestedEntry = navigationEntry(ACTIONS.REPLACE, {
|
|
326
|
+
...payload,
|
|
327
|
+
screenStateStore,
|
|
328
|
+
} as AnyRecord);
|
|
305
329
|
|
|
306
330
|
return R.assocPath(["state", "nested"], nestedEntry.state, state);
|
|
307
331
|
default:
|
|
@@ -405,18 +429,34 @@ export default function navigationReducer(
|
|
|
405
429
|
case ACTIONS.REPLACE:
|
|
406
430
|
case ACTIONS.REPLACE_TOP:
|
|
407
431
|
case ACTIONS.BACK:
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
432
|
+
// eslint-disable-next-line
|
|
433
|
+
case ACTIONS.BACK_PLAYER_NESTED_CONTENT: {
|
|
434
|
+
// TODO: Check this solution with Pawel, does not work without it on tvs
|
|
435
|
+
const screenStateStore: UseBoundStore<StoreApi<ScreenStateStore>> =
|
|
436
|
+
create<ScreenStateStore>((set) => ({
|
|
437
|
+
data: {},
|
|
438
|
+
setValue: (key, value) =>
|
|
439
|
+
set((s) => ({ data: { ...s.data, [key]: value } })),
|
|
440
|
+
removeValue: (key) =>
|
|
441
|
+
set((s) => {
|
|
442
|
+
const data = { ...s.data };
|
|
443
|
+
delete data[key];
|
|
444
|
+
|
|
445
|
+
return { data };
|
|
446
|
+
}),
|
|
447
|
+
}));
|
|
448
|
+
|
|
449
|
+
const actionWithStore = {
|
|
450
|
+
type,
|
|
451
|
+
payload: { ...payload, screenStateStore },
|
|
452
|
+
meta: state,
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
const stack = applyReducer(navigationStackReducer, actionWithStore);
|
|
456
|
+
const location = applyReducer(locationReducer, actionWithStore);
|
|
457
|
+
|
|
458
|
+
return R.evolve({ stack, location }, state);
|
|
459
|
+
}
|
|
420
460
|
|
|
421
461
|
case ACTIONS.SET_NESTED_CONTENT:
|
|
422
462
|
return R.evolve(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
|
-
import { createSelector } from "
|
|
2
|
+
import { createSelector } from "@reduxjs/toolkit";
|
|
3
3
|
|
|
4
4
|
import { getPathAttributes } from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
5
5
|
|
|
@@ -7,6 +7,7 @@ const riverSelector = R.prop("rivers");
|
|
|
7
7
|
const pathnameSelector = R.prop("pathname");
|
|
8
8
|
const navigationStackSelector = R.prop("stack");
|
|
9
9
|
|
|
10
|
+
// @TODO extract to zapp-react-native-redux/selectors, remove ramda
|
|
10
11
|
export const homeRiverSelector = createSelector(
|
|
11
12
|
riverSelector,
|
|
12
13
|
R.compose(R.find(R.propEq("home", true)), R.values)
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
import { renderHook, act } from "@testing-library/react-hooks";
|
|
4
|
-
import configureStore from "redux-mock-store";
|
|
5
|
-
import thunk from "redux-thunk";
|
|
6
4
|
import { NetworkStatusContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NetworkStatusContext";
|
|
7
5
|
import { NetworkStatusProvider } from "../NetworkStatusProvider";
|
|
8
|
-
import {
|
|
6
|
+
import { WrappedWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
9
7
|
import NetInfo from "@react-native-community/netinfo";
|
|
10
8
|
|
|
11
|
-
const mockStore = configureStore([thunk]);
|
|
12
|
-
|
|
13
9
|
const NetInfoMock = {
|
|
14
10
|
type: "cellular",
|
|
15
11
|
details: {
|
|
@@ -24,9 +20,9 @@ const NetInfoMock = {
|
|
|
24
20
|
const getWrapper = (store) => ({
|
|
25
21
|
// eslint-disable-next-line react/prop-types,react/display-name
|
|
26
22
|
wrapper: ({ children }) => (
|
|
27
|
-
<
|
|
23
|
+
<WrappedWithProviders store={store}>
|
|
28
24
|
<NetworkStatusProvider>{children}</NetworkStatusProvider>
|
|
29
|
-
</
|
|
25
|
+
</WrappedWithProviders>
|
|
30
26
|
),
|
|
31
27
|
});
|
|
32
28
|
|
|
@@ -41,9 +37,9 @@ const useNetInfoMock = () => {
|
|
|
41
37
|
|
|
42
38
|
describe("NetworkStatusProvider", function () {
|
|
43
39
|
it("should return netInfoData", function () {
|
|
44
|
-
const store =
|
|
40
|
+
const store = {
|
|
45
41
|
plugins: [{}],
|
|
46
|
-
}
|
|
42
|
+
};
|
|
47
43
|
|
|
48
44
|
// @ts-ignore
|
|
49
45
|
jest.spyOn(NetInfo, "useNetInfo").mockImplementation(useNetInfoMock);
|
|
@@ -59,9 +55,9 @@ describe("NetworkStatusProvider", function () {
|
|
|
59
55
|
it("should call onConnectionLost callback when connection type changes to none", function () {
|
|
60
56
|
const onConnectionLost = jest.fn();
|
|
61
57
|
|
|
62
|
-
const store =
|
|
58
|
+
const store = {
|
|
63
59
|
plugins: [{ module: { networkHooks: { onConnectionLost } } }],
|
|
64
|
-
}
|
|
60
|
+
};
|
|
65
61
|
|
|
66
62
|
// @ts-ignore
|
|
67
63
|
jest.spyOn(NetInfo, "useNetInfo").mockImplementation(useNetInfoMock);
|
|
@@ -86,9 +82,9 @@ describe("NetworkStatusProvider", function () {
|
|
|
86
82
|
it("should call onConnectionRestored callback when connection type switches from none", function () {
|
|
87
83
|
const onConnectionRestored = jest.fn();
|
|
88
84
|
|
|
89
|
-
const store =
|
|
85
|
+
const store = {
|
|
90
86
|
plugins: [{ module: { networkHooks: { onConnectionRestored } } }],
|
|
91
|
-
}
|
|
87
|
+
};
|
|
92
88
|
|
|
93
89
|
// @ts-ignore
|
|
94
90
|
jest.spyOn(NetInfo, "useNetInfo").mockImplementation(useNetInfoMock);
|
|
@@ -123,9 +119,9 @@ describe("NetworkStatusProvider", function () {
|
|
|
123
119
|
it("should call onConnectionTypeChanged callback when connection type changes", function () {
|
|
124
120
|
const onConnectionTypeChanged = jest.fn();
|
|
125
121
|
|
|
126
|
-
const store =
|
|
122
|
+
const store = {
|
|
127
123
|
plugins: [{ module: { networkHooks: { onConnectionTypeChanged } } }],
|
|
128
|
-
}
|
|
124
|
+
};
|
|
129
125
|
|
|
130
126
|
// @ts-ignore
|
|
131
127
|
jest.spyOn(NetInfo, "useNetInfo").mockImplementation(useNetInfoMock);
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as ReactIs from "react-is";
|
|
3
3
|
import { View, Text } from "react-native";
|
|
4
|
-
import {
|
|
5
|
-
import configureStore from "redux-mock-store";
|
|
4
|
+
import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
6
5
|
|
|
7
6
|
import { storeConnector } from "../index";
|
|
8
|
-
import { Provider } from "react-redux";
|
|
9
7
|
|
|
10
8
|
const styles = { foo: "bar" };
|
|
11
9
|
const components = { grid: jest.fn() };
|
|
@@ -18,12 +16,12 @@ const Component = (props) => (
|
|
|
18
16
|
</View>
|
|
19
17
|
);
|
|
20
18
|
|
|
21
|
-
const store =
|
|
19
|
+
const store = {
|
|
22
20
|
styles,
|
|
23
21
|
components,
|
|
24
22
|
rivers,
|
|
25
23
|
appSettings,
|
|
26
|
-
}
|
|
24
|
+
};
|
|
27
25
|
|
|
28
26
|
describe("storeConnector", () => {
|
|
29
27
|
it("returns a Component", () => {
|
|
@@ -41,10 +39,9 @@ describe("storeConnector", () => {
|
|
|
41
39
|
it("passes the props to the component", () => {
|
|
42
40
|
const WrappedComponent = storeConnector(Component);
|
|
43
41
|
|
|
44
|
-
const { getByText, getByTestId } =
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
</Provider>
|
|
42
|
+
const { getByText, getByTestId } = renderWithProviders(
|
|
43
|
+
<WrappedComponent />,
|
|
44
|
+
store
|
|
48
45
|
);
|
|
49
46
|
|
|
50
47
|
expect(getByText("I'm a component")).toBeTruthy();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, Text } from "react-native";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import { waitFor } from "@testing-library/react-native";
|
|
4
|
+
import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
5
|
+
import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
|
|
6
6
|
|
|
7
7
|
let mocked_items: Record<string, any> = {};
|
|
8
8
|
|
|
@@ -10,10 +10,22 @@ import { appLifeCycleManager } from "../";
|
|
|
10
10
|
|
|
11
11
|
const mock_actions = {};
|
|
12
12
|
|
|
13
|
-
jest.mock("@applicaster/zapp-react-native-redux
|
|
14
|
-
|
|
13
|
+
jest.mock("@applicaster/zapp-react-native-redux", () => ({
|
|
14
|
+
...jest.requireActual("@applicaster/zapp-react-native-redux"),
|
|
15
|
+
AppData: {
|
|
16
|
+
loadAppData: jest.fn(() => () => Promise.resolve()),
|
|
17
|
+
},
|
|
15
18
|
}));
|
|
16
19
|
|
|
20
|
+
jest.mock(
|
|
21
|
+
"@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage",
|
|
22
|
+
() => ({
|
|
23
|
+
sessionStorage: {
|
|
24
|
+
getAllItems: jest.fn(() => Promise.resolve(mocked_items)),
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
|
|
17
29
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/actions", () => ({
|
|
18
30
|
useActions: jest.fn(() => ({ actions: mock_actions })),
|
|
19
31
|
}));
|
|
@@ -22,6 +34,9 @@ jest.mock(
|
|
|
22
34
|
"@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage",
|
|
23
35
|
() => ({
|
|
24
36
|
localStorage: {
|
|
37
|
+
...jest.requireActual(
|
|
38
|
+
"@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage"
|
|
39
|
+
).localStorage,
|
|
25
40
|
getAllItems: jest.fn(() => Promise.resolve(mocked_items)),
|
|
26
41
|
setItem: jest.fn((key, value) => {
|
|
27
42
|
mocked_items[key] = JSON.stringify(value);
|
|
@@ -64,12 +79,8 @@ const appLoader = jest.fn((_dispatch, _getState) => {
|
|
|
64
79
|
return Promise.resolve();
|
|
65
80
|
});
|
|
66
81
|
|
|
67
|
-
const store = configureStore([thunk])({});
|
|
68
|
-
const dispatch = store.dispatch;
|
|
69
|
-
|
|
70
82
|
const state = {
|
|
71
|
-
|
|
72
|
-
plugins: {},
|
|
83
|
+
plugins: {} as QuickBrickPlugin[],
|
|
73
84
|
appSettings: { runtimeConfigurationUrls: { rivers: "http://rivers.url" } },
|
|
74
85
|
};
|
|
75
86
|
|
|
@@ -91,19 +102,16 @@ describe("appLifeCycleManager", () => {
|
|
|
91
102
|
it("runs the loaders, then sends quickBrickReady event", async () => {
|
|
92
103
|
const testCallback = jest.fn(() => {});
|
|
93
104
|
|
|
94
|
-
|
|
95
|
-
<DecoratedComponent
|
|
96
|
-
|
|
97
|
-
{...state}
|
|
98
|
-
testCallback={testCallback}
|
|
99
|
-
/>
|
|
105
|
+
renderWithProviders(
|
|
106
|
+
<DecoratedComponent {...state} testCallback={testCallback} />,
|
|
107
|
+
state
|
|
100
108
|
);
|
|
101
109
|
|
|
102
110
|
await waitFor(() => {
|
|
103
111
|
return expect(testCallback).toHaveBeenCalled();
|
|
104
112
|
});
|
|
105
113
|
|
|
106
|
-
const actions =
|
|
114
|
+
const actions = appStore.testStore.getActions();
|
|
107
115
|
|
|
108
116
|
expect(actions[0]).toMatchObject({ type: "SET_APP_READY" });
|
|
109
117
|
|
|
@@ -117,16 +125,12 @@ describe("appLifeCycleManager", () => {
|
|
|
117
125
|
it("sends the quickBrickReady event when a loader doesn't resolves", async () => {
|
|
118
126
|
const testCallback = jest.fn(() => {});
|
|
119
127
|
|
|
120
|
-
|
|
121
|
-
<DecoratedComponent
|
|
122
|
-
|
|
123
|
-
{...state}
|
|
124
|
-
shouldFail
|
|
125
|
-
testCallback={testCallback}
|
|
126
|
-
/>
|
|
128
|
+
renderWithProviders(
|
|
129
|
+
<DecoratedComponent {...state} shouldFail testCallback={testCallback} />,
|
|
130
|
+
state
|
|
127
131
|
);
|
|
128
132
|
|
|
129
|
-
const actions =
|
|
133
|
+
const actions = appStore.testStore.getActions();
|
|
130
134
|
|
|
131
135
|
await waitFor(() => {
|
|
132
136
|
return expect(testCallback).toHaveBeenCalled();
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
|
|
4
4
|
import { sendLaunchEvent } from "@applicaster/zapp-react-native-utils/analyticsUtils";
|
|
5
|
-
import {
|
|
5
|
+
import { AppData, useAppDispatch } from "@applicaster/zapp-react-native-redux";
|
|
6
6
|
import {
|
|
7
7
|
setAppLaunched,
|
|
8
8
|
setAppReady,
|
|
@@ -13,7 +13,6 @@ import { networkStatusReady } from "../NetworkStatusProvider/networkStatusReady"
|
|
|
13
13
|
import { updateSessionNumber } from "../SessionCounter/sessionCounter";
|
|
14
14
|
|
|
15
15
|
import { coreAppLogger } from "../logger";
|
|
16
|
-
import { Dispatch } from "@reduxjs/toolkit";
|
|
17
16
|
import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
|
|
18
17
|
import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
19
18
|
import { requiredSessionKeys } from "../../const";
|
|
@@ -24,7 +23,6 @@ const logger = coreAppLogger.addSubsystem("AppLifeCycleManager");
|
|
|
24
23
|
const isAndroid = isAndroidPlatform();
|
|
25
24
|
|
|
26
25
|
type Props = {
|
|
27
|
-
dispatch: Dispatch;
|
|
28
26
|
testCallback: () => void;
|
|
29
27
|
plugins: QuickBrickPlugin[];
|
|
30
28
|
appSettings: { runtimeConfigurationUrls: { [key in string]: string } };
|
|
@@ -35,6 +33,7 @@ export function appLifeCycleManager(appLoader, QuickBrickManager) {
|
|
|
35
33
|
// this function is not called until React View is mounted to activity(ie quickBrickReady event sent)
|
|
36
34
|
return function AppLifeCycleManagerRenderer(props: Props) {
|
|
37
35
|
const actionsInitialStateSetters = useActionSetters();
|
|
36
|
+
const dispatch = useAppDispatch();
|
|
38
37
|
// using useLayoutEffect to call the loader just after the DOM render to mimic componentDidMount timing
|
|
39
38
|
|
|
40
39
|
async function setUpdateSessionNumber(results: unknown[]) {
|
|
@@ -93,7 +92,7 @@ export function appLifeCycleManager(appLoader, QuickBrickManager) {
|
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
function makeAppReady() {
|
|
96
|
-
const {
|
|
95
|
+
const { testCallback } = props;
|
|
97
96
|
|
|
98
97
|
dispatch(setAppReady());
|
|
99
98
|
dispatch(setAppLaunched());
|
|
@@ -153,14 +152,14 @@ export function appLifeCycleManager(appLoader, QuickBrickManager) {
|
|
|
153
152
|
|
|
154
153
|
const prepareApp = async () => {
|
|
155
154
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
156
|
-
const {
|
|
155
|
+
const { testCallback, ...state } = props;
|
|
157
156
|
|
|
158
157
|
try {
|
|
159
158
|
const getState = () => state;
|
|
160
159
|
|
|
161
160
|
const loaders = [
|
|
162
161
|
appLoader(dispatch, getState),
|
|
163
|
-
dispatch<any>(loadAppData()),
|
|
162
|
+
dispatch<any>(AppData.loadAppData()),
|
|
164
163
|
networkStatusReady(),
|
|
165
164
|
];
|
|
166
165
|
|
package/App/index.tsx
CHANGED
|
@@ -76,7 +76,10 @@ const App = ({
|
|
|
76
76
|
<LoadingOverlay />
|
|
77
77
|
</ErrorBoundary>
|
|
78
78
|
<LogicAggregatorContainer
|
|
79
|
-
components={
|
|
79
|
+
components={React.useMemo(
|
|
80
|
+
() => [InteractionManager, ApplyScreenHooks],
|
|
81
|
+
[InteractionManager, ApplyScreenHooks]
|
|
82
|
+
)}
|
|
80
83
|
/>
|
|
81
84
|
</AppContainer>
|
|
82
85
|
</SafeAreaProvider>
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import * as ReduxModule from "@applicaster/zapp-react-native-redux";
|
|
2
1
|
import nock from "nock";
|
|
3
2
|
|
|
4
3
|
jest.mock("../../AssetCache", () => ({
|
|
5
4
|
cacheAssets: jest.fn((x) => x),
|
|
6
5
|
}));
|
|
7
6
|
|
|
7
|
+
const mockLoadAppContextData = jest.fn(() => ({}));
|
|
8
|
+
|
|
9
|
+
jest.mock("@applicaster/zapp-react-native-redux", () => ({
|
|
10
|
+
...jest.requireActual("@applicaster/zapp-react-native-redux"),
|
|
11
|
+
loadAppContextData: mockLoadAppContextData,
|
|
12
|
+
}));
|
|
13
|
+
|
|
8
14
|
const uuid = "342ee911-03b6-4a16-adde-ece5ef739feb";
|
|
9
15
|
|
|
10
16
|
const { getRemoteContextData } = require("../getRemoteContextData");
|
|
@@ -100,11 +106,12 @@ const failingRuntimeConfigurationUrls = {
|
|
|
100
106
|
remote_configurations_url: "http://zapp.com/failing.json",
|
|
101
107
|
};
|
|
102
108
|
|
|
103
|
-
let reduxLoaderSpy;
|
|
104
109
|
const dispatch = jest.fn();
|
|
105
110
|
|
|
106
111
|
describe("getRemoteContextData", () => {
|
|
107
112
|
beforeEach(() => {
|
|
113
|
+
mockLoadAppContextData.mockClear();
|
|
114
|
+
|
|
108
115
|
nock("http://zapp.com").persist().get("/layout.json").reply(200, layout);
|
|
109
116
|
|
|
110
117
|
nock("http://zapp.com")
|
|
@@ -120,20 +127,12 @@ describe("getRemoteContextData", () => {
|
|
|
120
127
|
nock("http://zapp.com")
|
|
121
128
|
.get("/failing.json")
|
|
122
129
|
.reply(Math.floor(Math.random() * 200 + 400), 0);
|
|
123
|
-
|
|
124
|
-
reduxLoaderSpy = jest
|
|
125
|
-
.spyOn(ReduxModule, "loadAppContextData")
|
|
126
|
-
.mockImplementation(() => ({}));
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
afterEach(() => {
|
|
130
|
-
reduxLoaderSpy.mockRestore();
|
|
131
130
|
});
|
|
132
131
|
|
|
133
132
|
it("returns a map of context data with the result of the matched urls", async () => {
|
|
134
133
|
await getRemoteContextData(dispatch, runtimeConfigurationUrls, plugins);
|
|
135
134
|
|
|
136
|
-
return expect(
|
|
135
|
+
return expect(mockLoadAppContextData).toHaveBeenCalledWith(
|
|
137
136
|
dispatch,
|
|
138
137
|
expect.objectContaining({
|
|
139
138
|
pluginConfigurations,
|
|
@@ -147,7 +146,7 @@ describe("getRemoteContextData", () => {
|
|
|
147
146
|
});
|
|
148
147
|
|
|
149
148
|
it("skips the context data if it cannot be retrieved", async () => {
|
|
150
|
-
expect(
|
|
149
|
+
expect(mockLoadAppContextData).not.toHaveBeenCalled();
|
|
151
150
|
|
|
152
151
|
return expect(
|
|
153
152
|
getRemoteContextData(dispatch, failingRuntimeConfigurationUrls, plugins)
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
import isEmpty from "lodash/isEmpty";
|
|
3
3
|
import { Dimensions, NativeModules } from "react-native";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
loadAppContextData,
|
|
6
|
+
AppData,
|
|
7
|
+
} from "@applicaster/zapp-react-native-redux";
|
|
5
8
|
import { isTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
6
9
|
import { mapPromises } from "@applicaster/zapp-react-native-utils/arrayUtils";
|
|
7
10
|
import { fetchPluginConfiguration, getPromiseForType } from "../helpers";
|
|
8
11
|
import { cacheAssets } from "../../AssetCache";
|
|
9
|
-
import { actions as appDataActions } from "@applicaster/zapp-react-native-redux/AppData";
|
|
10
12
|
import { logger } from "@applicaster/zapp-react-native-utils/logger";
|
|
11
13
|
import { ACTIVE_LAYOUT_ID_STORAGE_KEY } from "../consts";
|
|
12
14
|
const { AppLoaderBridge } = NativeModules;
|
|
@@ -74,7 +76,7 @@ export async function getNativeRemoteContextData(
|
|
|
74
76
|
|
|
75
77
|
const apiVersion = layout?.layout?.["api_version"]; // Taken from remote configuration
|
|
76
78
|
|
|
77
|
-
dispatch(
|
|
79
|
+
dispatch(AppData.actions.merge({ layoutVersion: apiVersion || "v1" }));
|
|
78
80
|
|
|
79
81
|
const resolvedPromises = await mapPromises(getPromiseForType, ["cellStyles"]);
|
|
80
82
|
|
package/README.md
CHANGED
|
@@ -42,10 +42,6 @@ Creates a Zapp App with the provided options :
|
|
|
42
42
|
- `module`: the plugin's callable function / React component
|
|
43
43
|
- `name`: the name of the plugin - should match the `PascalCase`'d identifier of the plugin. If your plugin's identifier is `react-native-article`, the name should be `ReactNativeArticle`
|
|
44
44
|
- `type`: the type of the plugin, as it is defined in the plugin's manifest in Zapp
|
|
45
|
-
- `reduxStoreOptions`: (optional)
|
|
46
|
-
- `additionalReducers`: map of reducers to load in the redux store, on top of the existing ones. See available reducers' names to avoid name collision which would override your own custom reducers
|
|
47
|
-
- `additionalMiddlewares`: array of additional middlewares to load - by default, the ZappApp will have the `thunk` middleware, but others can be added
|
|
48
|
-
- `initialState`: optional initial state for the redux store
|
|
49
45
|
- `pluginConfigurations`: the remote configuration options for plugins, as coming from Zapp
|
|
50
46
|
- `remoteConfigurations`: Zapp's remote configurations
|
|
51
47
|
- `appSettings`: arbitrary app settings which will be stored in the redux store.
|
package/createZappApp/index.tsx
CHANGED
|
@@ -12,9 +12,10 @@ import {
|
|
|
12
12
|
isNotNil,
|
|
13
13
|
} from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
14
14
|
|
|
15
|
+
import { createZappReduxStore } from "@applicaster/zapp-react-native-redux/utils/createZappReduxStore";
|
|
15
16
|
import {
|
|
16
|
-
createZappReduxStore,
|
|
17
17
|
loadAppContextData,
|
|
18
|
+
AppData,
|
|
18
19
|
} from "@applicaster/zapp-react-native-redux";
|
|
19
20
|
|
|
20
21
|
import { coreLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
@@ -26,7 +27,6 @@ import { Provider } from "react-redux";
|
|
|
26
27
|
import { EmptyZappApp } from "../defaults";
|
|
27
28
|
import { mergeUiComponentPlugins } from "../helpers";
|
|
28
29
|
import { isTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
29
|
-
import { actions as appDataActions } from "@applicaster/zapp-react-native-redux/AppData";
|
|
30
30
|
import { remoteDataLoader } from "../App/appRemoteDataLoader/remoteDataLoader";
|
|
31
31
|
import * as QuickBrickManager from "@applicaster/zapp-react-native-bridge/QuickBrick";
|
|
32
32
|
import { isAndroidPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
@@ -51,7 +51,6 @@ export function createZappApp(zappAppConfig: ZappAppConfig) {
|
|
|
51
51
|
remoteConfigurations = {},
|
|
52
52
|
layout = {},
|
|
53
53
|
tabletLayout = {},
|
|
54
|
-
reduxStoreOptions = {},
|
|
55
54
|
appSettings = {},
|
|
56
55
|
ZappApp = EmptyZappApp,
|
|
57
56
|
presetsMapping = {},
|
|
@@ -89,7 +88,7 @@ export function createZappApp(zappAppConfig: ZappAppConfig) {
|
|
|
89
88
|
injectCorePlugins
|
|
90
89
|
)(plugins);
|
|
91
90
|
|
|
92
|
-
const store = createZappReduxStore(
|
|
91
|
+
const store = createZappReduxStore();
|
|
93
92
|
|
|
94
93
|
const appComponents = mergeUiComponentPlugins(components, plugins);
|
|
95
94
|
|
|
@@ -113,7 +112,7 @@ export function createZappApp(zappAppConfig: ZappAppConfig) {
|
|
|
113
112
|
// Handle case when layout is backed in as part of the environment, dev only
|
|
114
113
|
// TODO: Handle it inside getNativeRemoteContextData
|
|
115
114
|
store.dispatch(
|
|
116
|
-
|
|
115
|
+
AppData.actions.merge({
|
|
117
116
|
layoutVersion: layout?.api_version ? layout.api_version : "v1",
|
|
118
117
|
})
|
|
119
118
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/quick-brick-core",
|
|
3
|
-
"version": "14.0.0-alpha.
|
|
3
|
+
"version": "14.0.0-alpha.6391068513",
|
|
4
4
|
"description": "Core package for Applicaster's Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "14.0.0-alpha.
|
|
32
|
-
"@applicaster/quick-brick-core-plugins": "14.0.0-alpha.
|
|
33
|
-
"@applicaster/zapp-pipes-v2-client": "14.0.0-alpha.
|
|
34
|
-
"@applicaster/zapp-react-native-bridge": "14.0.0-alpha.
|
|
35
|
-
"@applicaster/zapp-react-native-redux": "14.0.0-alpha.
|
|
36
|
-
"@applicaster/zapp-react-native-ui-components": "14.0.0-alpha.
|
|
37
|
-
"@applicaster/zapp-react-native-utils": "14.0.0-alpha.
|
|
31
|
+
"@applicaster/applicaster-types": "14.0.0-alpha.6391068513",
|
|
32
|
+
"@applicaster/quick-brick-core-plugins": "14.0.0-alpha.6391068513",
|
|
33
|
+
"@applicaster/zapp-pipes-v2-client": "14.0.0-alpha.6391068513",
|
|
34
|
+
"@applicaster/zapp-react-native-bridge": "14.0.0-alpha.6391068513",
|
|
35
|
+
"@applicaster/zapp-react-native-redux": "14.0.0-alpha.6391068513",
|
|
36
|
+
"@applicaster/zapp-react-native-ui-components": "14.0.0-alpha.6391068513",
|
|
37
|
+
"@applicaster/zapp-react-native-utils": "14.0.0-alpha.6391068513",
|
|
38
38
|
"atob": "^2.1.2",
|
|
39
39
|
"axios": "^0.28.0",
|
|
40
40
|
"btoa": "^1.2.1",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"md5": "^2.3.0",
|
|
43
43
|
"promise": "^8.3.0",
|
|
44
44
|
"query-string": "7.1.3",
|
|
45
|
-
"react-redux": "
|
|
45
|
+
"react-redux": "9.2.0",
|
|
46
46
|
"redux": "^4.0.4",
|
|
47
47
|
"reselect": "^4.0.0",
|
|
48
48
|
"url": "^0.11.0",
|
|
@@ -61,7 +61,6 @@
|
|
|
61
61
|
"react-native": "*",
|
|
62
62
|
"react-native-fs": "*",
|
|
63
63
|
"react-native-linear-gradient": "*",
|
|
64
|
-
"react-native-safe-area-context": "*",
|
|
65
64
|
"react-native-svg": "*",
|
|
66
65
|
"react-native-webview": "*",
|
|
67
66
|
"uglify-js": "*",
|
package/renderZappApp/index.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* @param {React.ComponentType<any>} App component to start
|
|
20
20
|
*/
|
|
21
21
|
export function renderZappApp(options) {
|
|
22
|
-
const { App, AppRegistry, appMountId } = options;
|
|
22
|
+
const { App, AppRegistry, appMountId, mode } = options;
|
|
23
23
|
|
|
24
24
|
if (!App) {
|
|
25
25
|
throw new Error("No App Component provided, nothing to render");
|
|
@@ -37,6 +37,7 @@ export function renderZappApp(options) {
|
|
|
37
37
|
if (appMountId) {
|
|
38
38
|
AppRegistry.runApplication("QuickBrickApp", {
|
|
39
39
|
rootTag: document.getElementById(appMountId),
|
|
40
|
+
mode,
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
43
|
}
|