@applicaster/quick-brick-core 14.0.0-alpha.3126393935 → 14.0.0-alpha.3471443312

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.
@@ -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 "redux";
7
+ import { Dispatch } from "@reduxjs/toolkit";
8
8
 
9
9
  type Props = {
10
10
  Component: () => React.ComponentType<any>;
@@ -3,10 +3,9 @@ import * as R from "ramda";
3
3
  import axios from "axios";
4
4
  import { renderHook } from "@testing-library/react-hooks";
5
5
  import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
6
- import * as zappRedux from "@applicaster/zapp-react-native-redux";
6
+
7
7
  import * as helpers from "../../../helpers";
8
8
  import * as feedLoader from "@applicaster/zapp-react-native-utils/reactHooks/feed/useFeedLoader";
9
- import * as useNavigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
10
9
 
11
10
  import { Provider } from "react-redux";
12
11
  import configureStore from "redux-mock-store";
@@ -17,19 +16,24 @@ const rivers = {
17
16
  },
18
17
  };
19
18
 
20
- const navigator = {
19
+ const mock_navigator = {
21
20
  currentRoute: "/river/A1234",
22
21
  replace: jest.fn(),
23
22
  };
24
23
 
25
- const mockStore = configureStore();
24
+ jest.mock(
25
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation",
26
+ () => ({
27
+ useNavigation: jest.fn(() => mock_navigator),
28
+ })
29
+ );
26
30
 
27
- jest
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");
35
+ const storageSpy = jest.spyOn(sessionStorage, "getAllItems");
36
+ const axiosGetSpy = jest.spyOn(axios, "get");
33
37
 
34
38
  const { usePresentSchemeHandler } = require("../usePresentSchemeHandler");
35
39
 
@@ -37,6 +41,8 @@ const onFinish = jest.fn((cb) => {
37
41
  cb();
38
42
  });
39
43
 
44
+ const navigator = mock_navigator;
45
+
40
46
  describe("usePresentSchemeHandler", () => {
41
47
  beforeEach(() => {
42
48
  onFinish.mockClear();
@@ -188,10 +194,6 @@ describe("usePresentSchemeHandler", () => {
188
194
  rivers_configuration_id: "test",
189
195
  };
190
196
 
191
- const storageSpy = jest.spyOn(sessionStorage, "getAllItems");
192
- const axiosGetSpy = jest.spyOn(axios, "get");
193
- const zappReduxSpy = jest.spyOn(zappRedux, "loadAppContextData");
194
-
195
197
  const getAllItems = jest.fn().mockResolvedValue({
196
198
  accountsAccountId: "accountsAccountId",
197
199
  bundleIdentifier: "bundleIdentifier",
@@ -204,7 +206,6 @@ describe("usePresentSchemeHandler", () => {
204
206
 
205
207
  storageSpy.mockImplementation(getAllItems);
206
208
  axiosGetSpy.mockImplementation(get);
207
- zappReduxSpy.mockReturnValue(null);
208
209
 
209
210
  renderHook(() => usePresentSchemeHandler({ query, url: "", onFinish }), {
210
211
  wrapper,
@@ -219,11 +220,6 @@ describe("usePresentSchemeHandler", () => {
219
220
 
220
221
  expect(actions?.find(R.propEq("type", "SET_APP_READY"))).toBeDefined();
221
222
 
222
- expect(zappReduxSpy).toBeCalledWith(expect.any(Function), {
223
- cellStyles: "url",
224
- rivers: "url",
225
- });
226
-
227
223
  expect(navigator.replace).toBeCalledWith({});
228
224
  };
229
225
  });
@@ -1,4 +1,8 @@
1
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
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 { rivers, contentTypes } = usePickFromState(["rivers", "contentTypes"]);
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 { useActions } from "@applicaster/zapp-react-native-redux/hooks";
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 = useDispatch();
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
- const plugins = [];
10
-
11
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation");
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(() => plugins),
18
+ usePickFromState: jest.fn(() => ({})),
19
19
  }));
20
20
 
21
21
  const { URLSchemeHandler } = require("../URLSchemeHandler");
@@ -44,7 +44,6 @@ 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],
48
47
  },
49
48
  },
50
49
  "options": {
@@ -80,7 +79,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
80
79
  "supports_offline": false,
81
80
  "type": "general_content",
82
81
  },
83
- "screenStateStore": undefined,
84
82
  },
85
83
  },
86
84
  ],
@@ -116,7 +114,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
116
114
  "supports_offline": false,
117
115
  "type": "general_content",
118
116
  },
119
- "screenStateStore": [Function],
120
117
  },
121
118
  },
122
119
  "options": {
@@ -152,7 +149,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
152
149
  "supports_offline": false,
153
150
  "type": "general_content",
154
151
  },
155
- "screenStateStore": undefined,
156
152
  },
157
153
  },
158
154
  {
@@ -184,7 +180,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
184
180
  "supports_offline": false,
185
181
  "type": "general_content",
186
182
  },
187
- "screenStateStore": undefined,
188
183
  },
189
184
  },
190
185
  ],
@@ -220,7 +215,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
220
215
  "supports_offline": false,
221
216
  "type": "general_content",
222
217
  },
223
- "screenStateStore": [Function],
224
218
  },
225
219
  },
226
220
  "options": {
@@ -256,7 +250,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
256
250
  "supports_offline": false,
257
251
  "type": "general_content",
258
252
  },
259
- "screenStateStore": undefined,
260
253
  },
261
254
  },
262
255
  {
@@ -288,7 +281,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
288
281
  "supports_offline": false,
289
282
  "type": "general_content",
290
283
  },
291
- "screenStateStore": undefined,
292
284
  },
293
285
  },
294
286
  {
@@ -320,7 +312,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
320
312
  "supports_offline": false,
321
313
  "type": "general_content",
322
314
  },
323
- "screenStateStore": undefined,
324
315
  },
325
316
  },
326
317
  ],
@@ -357,7 +348,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
357
348
  "supports_offline": false,
358
349
  "type": "general_content",
359
350
  },
360
- "screenStateStore": undefined,
361
351
  },
362
352
  },
363
353
  "options": {
@@ -393,7 +383,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
393
383
  "supports_offline": false,
394
384
  "type": "general_content",
395
385
  },
396
- "screenStateStore": undefined,
397
386
  },
398
387
  },
399
388
  {
@@ -425,7 +414,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
425
414
  "supports_offline": false,
426
415
  "type": "general_content",
427
416
  },
428
- "screenStateStore": undefined,
429
417
  },
430
418
  },
431
419
  ],
@@ -461,7 +449,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
461
449
  "supports_offline": false,
462
450
  "type": "general_content",
463
451
  },
464
- "screenStateStore": [Function],
465
452
  },
466
453
  },
467
454
  "options": {
@@ -497,7 +484,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
497
484
  "supports_offline": false,
498
485
  "type": "general_content",
499
486
  },
500
- "screenStateStore": undefined,
501
487
  },
502
488
  },
503
489
  {
@@ -529,7 +515,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
529
515
  "supports_offline": false,
530
516
  "type": "general_content",
531
517
  },
532
- "screenStateStore": undefined,
533
518
  },
534
519
  },
535
520
  {
@@ -561,7 +546,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
561
546
  "supports_offline": false,
562
547
  "type": "general_content",
563
548
  },
564
- "screenStateStore": undefined,
565
549
  },
566
550
  },
567
551
  ],
@@ -598,7 +582,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
598
582
  "supports_offline": false,
599
583
  "type": "general_content",
600
584
  },
601
- "screenStateStore": undefined,
602
585
  },
603
586
  },
604
587
  "options": {
@@ -634,7 +617,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
634
617
  "supports_offline": false,
635
618
  "type": "general_content",
636
619
  },
637
- "screenStateStore": undefined,
638
620
  },
639
621
  },
640
622
  {
@@ -666,7 +648,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
666
648
  "supports_offline": false,
667
649
  "type": "general_content",
668
650
  },
669
- "screenStateStore": undefined,
670
651
  },
671
652
  },
672
653
  ],
@@ -5,7 +5,6 @@ import {
5
5
  firstStackEntriesSelector,
6
6
  previousStackEntriesSelector,
7
7
  } from "./selectors";
8
- import { create, StoreApi, UseBoundStore } from "zustand";
9
8
 
10
9
  /* initial state */
11
10
 
@@ -121,12 +120,12 @@ export const setNestedContent = (
121
120
 
122
121
  const navigationEntry = (
123
122
  type: ActionValues,
124
- { route, screen, entry, key, options, screenStateStore }: AnyRecord
123
+ { route, screen, entry, key, options }: AnyRecord
125
124
  ) => ({
126
125
  key,
127
126
  action: type,
128
127
  route,
129
- state: { screen, entry, options, screenStateStore },
128
+ state: { screen, entry, options },
130
129
  });
131
130
 
132
131
  function updatePopActions(state) {
@@ -275,25 +274,6 @@ function locationReducer(
275
274
  ) {
276
275
  const { route, key, screen, entry, options } = payload;
277
276
 
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
-
297
277
  switch (type) {
298
278
  case ACTIONS.BACK:
299
279
  // eslint-disable-next-line no-case-declarations
@@ -314,18 +294,14 @@ function locationReducer(
314
294
  case ACTIONS.REPLACE:
315
295
  case ACTIONS.REPLACE_TOP:
316
296
  case ACTIONS.BACK_PLAYER_NESTED_CONTENT:
317
- return {
318
- pathname: route,
319
- state: { screen, entry, options, screenStateStore },
320
- key,
321
- };
297
+ return { pathname: route, state: { screen, entry, options }, key };
322
298
 
323
299
  case ACTIONS.SET_NESTED_CONTENT:
324
300
  // eslint-disable-next-line no-case-declarations
325
- const nestedEntry = navigationEntry(ACTIONS.REPLACE, {
326
- ...payload,
327
- screenStateStore,
328
- } as AnyRecord);
301
+ const nestedEntry = navigationEntry(
302
+ ACTIONS.REPLACE,
303
+ payload as AnyRecord
304
+ );
329
305
 
330
306
  return R.assocPath(["state", "nested"], nestedEntry.state, state);
331
307
  default:
@@ -1,5 +1,5 @@
1
1
  import * as R from "ramda";
2
- import { createSelector } from "reselect";
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,5 +1,5 @@
1
1
  import * as R from "ramda";
2
- import { connectToStore } from "@applicaster/zapp-react-native-redux";
2
+ import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
3
3
 
4
4
  const REDUX_STORE_PROPS = [
5
5
  "components",
@@ -42,9 +42,12 @@ jest.mock("../AppStateDecorator", () => ({
42
42
  withAppManager: (Comp) => Comp,
43
43
  }));
44
44
 
45
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
46
- useDimensions: jest.fn(() => ({ width: 375, height: 800 })),
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");
@@ -1,8 +1,8 @@
1
1
  import * as React from "react";
2
2
  import { View, Text } from "react-native";
3
- import { render, waitFor } from "@testing-library/react-native";
4
- import thunk from "redux-thunk";
5
- import configureStore from "redux-mock-store";
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,8 +10,11 @@ import { appLifeCycleManager } from "../";
10
10
 
11
11
  const mock_actions = {};
12
12
 
13
- jest.mock("@applicaster/zapp-react-native-redux/AppData", () => ({
14
- loadAppData: jest.fn(() => () => Promise.resolve()),
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
 
17
20
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/actions", () => ({
@@ -22,6 +25,9 @@ jest.mock(
22
25
  "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage",
23
26
  () => ({
24
27
  localStorage: {
28
+ ...jest.requireActual(
29
+ "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage"
30
+ ).localStorage,
25
31
  getAllItems: jest.fn(() => Promise.resolve(mocked_items)),
26
32
  setItem: jest.fn((key, value) => {
27
33
  mocked_items[key] = JSON.stringify(value);
@@ -64,12 +70,8 @@ const appLoader = jest.fn((_dispatch, _getState) => {
64
70
  return Promise.resolve();
65
71
  });
66
72
 
67
- const store = configureStore([thunk])({});
68
- const dispatch = store.dispatch;
69
-
70
73
  const state = {
71
- rivers: {},
72
- plugins: {},
74
+ plugins: {} as QuickBrickPlugin[],
73
75
  appSettings: { runtimeConfigurationUrls: { rivers: "http://rivers.url" } },
74
76
  };
75
77
 
@@ -91,19 +93,16 @@ describe("appLifeCycleManager", () => {
91
93
  it("runs the loaders, then sends quickBrickReady event", async () => {
92
94
  const testCallback = jest.fn(() => {});
93
95
 
94
- render(
95
- <DecoratedComponent
96
- dispatch={dispatch}
97
- {...state}
98
- testCallback={testCallback}
99
- />
96
+ renderWithProviders(
97
+ <DecoratedComponent {...state} testCallback={testCallback} />,
98
+ state
100
99
  );
101
100
 
102
101
  await waitFor(() => {
103
102
  return expect(testCallback).toHaveBeenCalled();
104
103
  });
105
104
 
106
- const actions = store.getActions();
105
+ const actions = appStore.testStore.getActions();
107
106
 
108
107
  expect(actions[0]).toMatchObject({ type: "SET_APP_READY" });
109
108
 
@@ -117,16 +116,12 @@ describe("appLifeCycleManager", () => {
117
116
  it("sends the quickBrickReady event when a loader doesn't resolves", async () => {
118
117
  const testCallback = jest.fn(() => {});
119
118
 
120
- render(
121
- <DecoratedComponent
122
- dispatch={dispatch}
123
- {...state}
124
- shouldFail
125
- testCallback={testCallback}
126
- />
119
+ renderWithProviders(
120
+ <DecoratedComponent {...state} shouldFail testCallback={testCallback} />,
121
+ state
127
122
  );
128
123
 
129
- const actions = store.getActions();
124
+ const actions = appStore.testStore.getActions();
130
125
 
131
126
  await waitFor(() => {
132
127
  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 { loadAppData } from "@applicaster/zapp-react-native-redux/AppData";
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 { dispatch, testCallback } = props;
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 { dispatch, testCallback, ...state } = props;
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
 
@@ -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(reduxLoaderSpy).toHaveBeenCalledWith(
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(reduxLoaderSpy).not.toHaveBeenCalled();
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 { loadAppContextData } from "@applicaster/zapp-react-native-redux";
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(appDataActions.merge({ layoutVersion: apiVersion || "v1" }));
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.
@@ -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(reduxStoreOptions);
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
- appDataActions.merge({
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.3126393935",
3
+ "version": "14.0.0-alpha.3471443312",
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.3126393935",
32
- "@applicaster/quick-brick-core-plugins": "14.0.0-alpha.3126393935",
33
- "@applicaster/zapp-pipes-v2-client": "14.0.0-alpha.3126393935",
34
- "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.3126393935",
35
- "@applicaster/zapp-react-native-redux": "14.0.0-alpha.3126393935",
36
- "@applicaster/zapp-react-native-ui-components": "14.0.0-alpha.3126393935",
37
- "@applicaster/zapp-react-native-utils": "14.0.0-alpha.3126393935",
31
+ "@applicaster/applicaster-types": "14.0.0-alpha.3471443312",
32
+ "@applicaster/quick-brick-core-plugins": "14.0.0-alpha.3471443312",
33
+ "@applicaster/zapp-pipes-v2-client": "14.0.0-alpha.3471443312",
34
+ "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.3471443312",
35
+ "@applicaster/zapp-react-native-redux": "14.0.0-alpha.3471443312",
36
+ "@applicaster/zapp-react-native-ui-components": "14.0.0-alpha.3471443312",
37
+ "@applicaster/zapp-react-native-utils": "14.0.0-alpha.3471443312",
38
38
  "atob": "^2.1.2",
39
39
  "axios": "^0.28.0",
40
40
  "btoa": "^1.2.1",
@@ -60,11 +60,9 @@
60
60
  "react": "*",
61
61
  "react-native": "*",
62
62
  "react-native-fs": "*",
63
- "react-native-gesture-handler": "*",
64
63
  "react-native-linear-gradient": "*",
65
64
  "react-native-safe-area-context": "*",
66
65
  "react-native-svg": "*",
67
- "react-native-web": "*",
68
66
  "react-native-webview": "*",
69
67
  "uglify-js": "*",
70
68
  "validate-color": "*",