@applicaster/quick-brick-core 14.0.0-rc.8 → 15.0.0-rc.1
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/ActionSetters/index.ts +0 -1
- 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/DraggableBottomSheet/index.tsx +2 -2
- package/App/ModalProvider/ModalBottomSheet/ModalBottomSheetFrame.tsx +1 -1
- package/App/ModalProvider/ModalChildrenWrapper/index.tsx +2 -7
- package/App/ModalProvider/ModalPresenter.tsx +2 -1
- package/App/NavigationProvider/NavigationProvider.tsx +29 -9
- package/App/NavigationProvider/navigator/__tests__/__snapshots__/reducer.test.ts.snap +0 -177
- package/App/NavigationProvider/navigator/__tests__/reducer.test.ts +2 -70
- package/App/NavigationProvider/navigator/reducer.ts +30 -101
- package/App/NavigationProvider/navigator/selectors.ts +2 -1
- package/App/NetworkStatusProvider/__tests__/NetworkStatusProvider.test.tsx +11 -15
- package/App/RouterDecorator/__tests__/routerDecorator.test.js +3 -3
- package/App/StoreConnector/__tests__/storeConnector.test.js +6 -9
- package/App/StoreConnector/index.ts +1 -1
- package/App/ThemeManager/index.tsx +9 -1
- package/App/__tests__/createQuickBrickApp.test.js +13 -10
- package/App/appLifeCycleManager/__tests__/appLifeCycleManager.test.tsx +29 -25
- package/App/appLifeCycleManager/index.tsx +5 -6
- package/App/components/ZappAppWrapper.ts +3 -0
- package/App/components/ZappAppWrapper.web.ts +3 -0
- package/App/index.tsx +28 -22
- package/App/remoteContextReloader/__tests__/getRemoteContextData.test.js +11 -12
- package/App/remoteContextReloader/getRemoteContextData/getNativeRemoteContextData.ts +5 -3
- package/README.md +0 -4
- package/const/index.ts +6 -0
- package/createZappApp/__tests__/createZappApp.test.js +11 -0
- package/createZappApp/index.tsx +4 -5
- package/index.d.ts +0 -1
- package/package.json +9 -21
- package/renderZappApp/index.js +2 -1
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
mapKeys,
|
|
9
9
|
partitionByKeys,
|
|
10
10
|
} from "@applicaster/zapp-react-native-utils/objectUtils";
|
|
11
|
+
import { getLocalizations } from "@applicaster/zapp-react-native-utils/appUtils/localizationsHelper";
|
|
11
12
|
|
|
12
13
|
type Props = {
|
|
13
14
|
children: React.ReactNode;
|
|
@@ -23,7 +24,14 @@ function populateTheme(plugin) {
|
|
|
23
24
|
return null;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
const themeLocalizations =
|
|
28
|
+
getLocalizations({
|
|
29
|
+
localizations: plugin?.configuration?.localizations,
|
|
30
|
+
}) || {};
|
|
31
|
+
|
|
32
|
+
const themeProps = getProps(plugin?.configuration || {});
|
|
33
|
+
|
|
34
|
+
return [id, { ...themeProps, ...themeLocalizations }];
|
|
27
35
|
}
|
|
28
36
|
|
|
29
37
|
const TABLET_PREFIX = "tablet_";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable indent */
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import
|
|
3
|
+
import { render } from "@testing-library/react-native";
|
|
4
4
|
import { Provider } from "react-redux";
|
|
5
5
|
import thunk from "redux-thunk";
|
|
6
6
|
import configureStore from "redux-mock-store";
|
|
@@ -42,9 +42,12 @@ jest.mock("../AppStateDecorator", () => ({
|
|
|
42
42
|
withAppManager: (Comp) => Comp,
|
|
43
43
|
}));
|
|
44
44
|
|
|
45
|
-
jest.mock(
|
|
46
|
-
useDimensions
|
|
47
|
-
|
|
45
|
+
jest.mock(
|
|
46
|
+
"@applicaster/zapp-react-native-utils/reactHooks/layout/useDimensions",
|
|
47
|
+
() => ({
|
|
48
|
+
useDimensions: jest.fn(() => ({ width: 375, height: 800 })),
|
|
49
|
+
})
|
|
50
|
+
);
|
|
48
51
|
|
|
49
52
|
jest.mock("react-native", () => {
|
|
50
53
|
const RNMock = jest.genMockFromModule("react-native");
|
|
@@ -172,13 +175,13 @@ describe("createQuickBrickApp", () => {
|
|
|
172
175
|
it("returns a react component and it renders correctly", () => {
|
|
173
176
|
const QuickBrickApp = createQuickBrickApp(options);
|
|
174
177
|
|
|
175
|
-
const
|
|
178
|
+
const { toJSON } = render(
|
|
176
179
|
<Provider store={store}>
|
|
177
180
|
<QuickBrickApp store={store} />
|
|
178
181
|
</Provider>
|
|
179
182
|
);
|
|
180
183
|
|
|
181
|
-
expect(
|
|
184
|
+
expect(toJSON()).toMatchSnapshot();
|
|
182
185
|
});
|
|
183
186
|
|
|
184
187
|
describe("with no InteractionManager", () => {
|
|
@@ -187,13 +190,13 @@ describe("createQuickBrickApp", () => {
|
|
|
187
190
|
const { InteractionManager, ...otherOptions } = options;
|
|
188
191
|
const QuickBrickApp = createQuickBrickApp(otherOptions);
|
|
189
192
|
|
|
190
|
-
const
|
|
193
|
+
const { toJSON } = render(
|
|
191
194
|
<Provider store={store}>
|
|
192
195
|
<QuickBrickApp store={store} />
|
|
193
196
|
</Provider>
|
|
194
197
|
);
|
|
195
198
|
|
|
196
|
-
expect(
|
|
199
|
+
expect(toJSON()).toMatchSnapshot();
|
|
197
200
|
});
|
|
198
201
|
});
|
|
199
202
|
|
|
@@ -203,13 +206,13 @@ describe("createQuickBrickApp", () => {
|
|
|
203
206
|
const { ContextProviders, ...otherOptions } = options;
|
|
204
207
|
const QuickBrickApp = createQuickBrickApp(otherOptions);
|
|
205
208
|
|
|
206
|
-
const
|
|
209
|
+
const { toJSON } = render(
|
|
207
210
|
<Provider store={store}>
|
|
208
211
|
<QuickBrickApp store={store} />
|
|
209
212
|
</Provider>
|
|
210
213
|
);
|
|
211
214
|
|
|
212
|
-
expect(
|
|
215
|
+
expect(toJSON()).toMatchSnapshot();
|
|
213
216
|
});
|
|
214
217
|
});
|
|
215
218
|
});
|
|
@@ -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
|
@@ -31,6 +31,7 @@ import { withActionExecutor } from "@applicaster/zapp-react-native-utils/actions
|
|
|
31
31
|
import { withScreenDataContextProvider } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
|
|
32
32
|
import { LogicAggregatorContainer } from "./LogicAggregatorContainer";
|
|
33
33
|
import { LoadingOverlay } from "./LoadingOverlay";
|
|
34
|
+
import { ZappAppWrapper } from "./components/ZappAppWrapper";
|
|
34
35
|
|
|
35
36
|
interface AppOptions {
|
|
36
37
|
Layout: React.ComponentType;
|
|
@@ -59,28 +60,33 @@ const App = ({
|
|
|
59
60
|
} = props;
|
|
60
61
|
|
|
61
62
|
return (
|
|
62
|
-
<
|
|
63
|
-
<
|
|
64
|
-
<
|
|
65
|
-
<
|
|
66
|
-
<
|
|
67
|
-
<
|
|
68
|
-
<
|
|
69
|
-
<
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
63
|
+
<ZappAppWrapper>
|
|
64
|
+
<ThemeManager plugins={plugins}>
|
|
65
|
+
<SafeAreaProvider initialMetrics={initialWindowMetrics}>
|
|
66
|
+
<AppContainer styles={styles}>
|
|
67
|
+
<ErrorBoundary>
|
|
68
|
+
<URLSchemeListener>
|
|
69
|
+
<SplashLoader>
|
|
70
|
+
<OfflineHandler>
|
|
71
|
+
<Layout>
|
|
72
|
+
<RouteManager />
|
|
73
|
+
</Layout>
|
|
74
|
+
</OfflineHandler>
|
|
75
|
+
</SplashLoader>
|
|
76
|
+
<ModalProvider />
|
|
77
|
+
</URLSchemeListener>
|
|
78
|
+
<LoadingOverlay />
|
|
79
|
+
</ErrorBoundary>
|
|
80
|
+
<LogicAggregatorContainer
|
|
81
|
+
components={React.useMemo(
|
|
82
|
+
() => [InteractionManager, ApplyScreenHooks],
|
|
83
|
+
[InteractionManager, ApplyScreenHooks]
|
|
84
|
+
)}
|
|
85
|
+
/>
|
|
86
|
+
</AppContainer>
|
|
87
|
+
</SafeAreaProvider>
|
|
88
|
+
</ThemeManager>
|
|
89
|
+
</ZappAppWrapper>
|
|
84
90
|
);
|
|
85
91
|
});
|
|
86
92
|
|
|
@@ -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/const/index.ts
CHANGED
|
@@ -38,3 +38,9 @@ export const requiredSessionKeys = [
|
|
|
38
38
|
export const QUICK_BRICK_NAVBAR = "quick-brick-navbar";
|
|
39
39
|
|
|
40
40
|
export const QUICK_BRICK_CONTENT = "quick-brick-content";
|
|
41
|
+
|
|
42
|
+
export const QUICK_BRICK_NAVBAR_SECTIONS = {
|
|
43
|
+
right: "nav-bar-right",
|
|
44
|
+
menu: "navbar-items",
|
|
45
|
+
left: "nav-bar-left",
|
|
46
|
+
};
|
|
@@ -75,6 +75,17 @@ jest.mock("@applicaster/zapp-react-native-bridge/QuickBrick", () => ({
|
|
|
75
75
|
getLegacyInitialProps: jest.fn(() => ({ initialProps: {} })),
|
|
76
76
|
}));
|
|
77
77
|
|
|
78
|
+
jest.mock(
|
|
79
|
+
"@applicaster/zapp-react-native-ui-components/Components/River",
|
|
80
|
+
() => {
|
|
81
|
+
const View = require("react-native").View;
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
River: jest.fn(() => <View testID="mock-river" />),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
|
|
78
89
|
describe("createZappApp", () => {
|
|
79
90
|
it("renders the provided React App", () => {
|
|
80
91
|
const ZappApp = createZappApp({ App });
|
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/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/quick-brick-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0-rc.1",
|
|
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": "
|
|
32
|
-
"@applicaster/quick-brick-core-plugins": "
|
|
33
|
-
"@applicaster/zapp-pipes-v2-client": "
|
|
34
|
-
"@applicaster/zapp-react-native-bridge": "
|
|
35
|
-
"@applicaster/zapp-react-native-redux": "
|
|
36
|
-
"@applicaster/zapp-react-native-ui-components": "
|
|
37
|
-
"@applicaster/zapp-react-native-utils": "
|
|
31
|
+
"@applicaster/applicaster-types": "15.0.0-rc.1",
|
|
32
|
+
"@applicaster/quick-brick-core-plugins": "15.0.0-rc.1",
|
|
33
|
+
"@applicaster/zapp-pipes-v2-client": "15.0.0-rc.1",
|
|
34
|
+
"@applicaster/zapp-react-native-bridge": "15.0.0-rc.1",
|
|
35
|
+
"@applicaster/zapp-react-native-redux": "15.0.0-rc.1",
|
|
36
|
+
"@applicaster/zapp-react-native-ui-components": "15.0.0-rc.1",
|
|
37
|
+
"@applicaster/zapp-react-native-utils": "15.0.0-rc.1",
|
|
38
38
|
"atob": "^2.1.2",
|
|
39
39
|
"axios": "^0.28.0",
|
|
40
40
|
"btoa": "^1.2.1",
|
|
@@ -42,9 +42,6 @@
|
|
|
42
42
|
"md5": "^2.3.0",
|
|
43
43
|
"promise": "^8.3.0",
|
|
44
44
|
"query-string": "7.1.3",
|
|
45
|
-
"react-redux": "^7.2.1",
|
|
46
|
-
"redux": "^4.0.4",
|
|
47
|
-
"reselect": "^4.0.0",
|
|
48
45
|
"url": "^0.11.0",
|
|
49
46
|
"uuid": "3.3.2"
|
|
50
47
|
},
|
|
@@ -56,23 +53,14 @@
|
|
|
56
53
|
"@applicaster/zapp-react-native-tvos-ui-components": "*",
|
|
57
54
|
"@babel/runtime": "*",
|
|
58
55
|
"@react-native-community/netinfo": "*",
|
|
59
|
-
"immer": "*",
|
|
60
56
|
"react": "*",
|
|
61
57
|
"react-native": "*",
|
|
62
58
|
"react-native-fs": "*",
|
|
63
|
-
"react-native-gesture-handler": "*",
|
|
64
59
|
"react-native-linear-gradient": "*",
|
|
65
|
-
"react-native-safe-area-context": "*",
|
|
66
60
|
"react-native-svg": "*",
|
|
67
|
-
"react-native-web": "*",
|
|
68
61
|
"react-native-webview": "*",
|
|
69
62
|
"uglify-js": "*",
|
|
70
63
|
"validate-color": "*",
|
|
71
64
|
"zustand": "*"
|
|
72
|
-
}
|
|
73
|
-
"devDependencies": {
|
|
74
|
-
"nock": "^10.0.0",
|
|
75
|
-
"redux-mock-store": "^1.5.3"
|
|
76
|
-
},
|
|
77
|
-
"gitHead": "a473487564142c55cdb50f02505cf0b60fe75658"
|
|
65
|
+
}
|
|
78
66
|
}
|
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
|
}
|