@applicaster/quick-brick-core 12.0.0-alpha.5114122134 → 12.0.0-alpha.5251355865

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.
@@ -88,10 +88,12 @@ const getActionInitialStateSetters = (key) => {
88
88
  return R.compose(
89
89
  R.map((subscription: { [x: string]: any; pluginId: any }) => {
90
90
  return async () => {
91
+ const now = performance.now();
92
+
91
93
  logger.info({
92
94
  message: `Invocation Started - action plugin ${key}, pluginId: ${
93
95
  subscription.pluginId
94
- }: ${performance.now()}`,
96
+ }`,
95
97
  });
96
98
 
97
99
  const promiseFunc = subscription[key];
@@ -101,7 +103,7 @@ const getActionInitialStateSetters = (key) => {
101
103
  logger.info({
102
104
  message: `Invocation Completed - action plugin ${key}, pluginId: ${
103
105
  subscription.pluginId
104
- }: ${performance.now()}`,
106
+ }: ${performance.now() - now} ms`,
105
107
  });
106
108
 
107
109
  return result;
@@ -1,8 +1,6 @@
1
1
  import React from "react";
2
2
  import { render, waitFor, cleanup } from "@testing-library/react-native";
3
3
 
4
- jest.mock("react-native");
5
-
6
4
  const theme = {
7
5
  screen_margin_top: 0,
8
6
  app_background_color: "white",
@@ -7,8 +7,6 @@ import { URLSchemeListener } from "../index";
7
7
 
8
8
  const URL = "url";
9
9
 
10
- jest.mock("react-native");
11
-
12
10
  const TestComponent = () => (
13
11
  <View>
14
12
  <Text>I'm a test component</Text>
@@ -13,6 +13,7 @@ import {
13
13
  useNavigation,
14
14
  } from "@applicaster/zapp-react-native-utils/reactHooks";
15
15
  import { useDimensions } from "@applicaster/zapp-react-native-utils/reactHooks/layout";
16
+ import { ModalComponent } from "@applicaster/zapp-react-native-ui-components/Components";
16
17
 
17
18
  const styles = StyleSheet.create({
18
19
  container: {
@@ -55,7 +56,10 @@ export function ModalBottomSheet(props: Props) {
55
56
  modal_bottom_sheet_tablet_max_width: sheetTabletMaxWidth,
56
57
  } = theme;
57
58
 
58
- const { ModalBottomSheetContent, modalBottomSheetContentProps } = props;
59
+ const {
60
+ ModalBottomSheetContent = ModalComponent,
61
+ modalBottomSheetContentProps,
62
+ } = props;
59
63
 
60
64
  const onLayout = useCallback(({ nativeEvent }) => {
61
65
  const calculatedHeight = nativeEvent?.layout?.height;
@@ -17,7 +17,7 @@ const styles = StyleSheet.create({
17
17
  export function ModalContent(props: Props) {
18
18
  const { modalScreenProps } = props;
19
19
 
20
- if (modalScreenProps?.screenData?.ModalBottomSheetContent) {
20
+ if (modalScreenProps?.screenData?.modalBottomSheetContentProps) {
21
21
  const { ModalBottomSheetContent, modalBottomSheetContentProps } =
22
22
  modalScreenProps?.screenData || {};
23
23
 
@@ -1,16 +1,16 @@
1
1
  import * as React from "react";
2
2
 
3
- import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
4
-
5
3
  import { ModalPresenter } from "./ModalPresenter";
6
4
  import { ModalContent } from "./ModalContent";
7
5
  import { ModalChildrenWrapper } from "./ModalChildrenWrapper";
8
6
  import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
9
7
  import { ScreenContextProvider } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenContext";
10
8
  import { ROUTE_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/routeTypes";
9
+ import { useModalStore } from "@applicaster/zapp-react-native-utils/modalState";
11
10
 
12
11
  export function ModalProvider() {
13
- const { modalState } = useNavigation();
12
+ const { modalState } = useModalStore();
13
+
14
14
  const [modalVisible, setModalVisible] = React.useState(false);
15
15
  const [modalShown, setModalShown] = React.useState(false);
16
16
 
@@ -63,6 +63,7 @@ import { findParent } from "@applicaster/zapp-react-native-ui-components/Context
63
63
  import { ZappPipesEntryContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
64
64
  import { PlayNextState } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/OverlayObserver/OverlaysObserver";
65
65
  import { inflateUrl } from "@applicaster/zapp-react-native-ui-components/Components/LinkHandler/LinkHandler";
66
+ import { useModalStore } from "@applicaster/zapp-react-native-utils/modalState";
66
67
 
67
68
  const logger = coreAppLogger.addSubsystem("Navigator");
68
69
 
@@ -92,13 +93,6 @@ const navigationActions = {
92
93
 
93
94
  const platform = getPlatform();
94
95
 
95
- const initialModalState = {
96
- visible: false,
97
- screen: null,
98
- options: {},
99
- props: {},
100
- };
101
-
102
96
  export function NavigationProvider({ children }: Props) {
103
97
  const {
104
98
  appData: { layoutVersion },
@@ -130,8 +124,7 @@ export function NavigationProvider({ children }: Props) {
130
124
  ZappPipesEntryContext.Context
131
125
  );
132
126
 
133
- const [modalState, setModalState] =
134
- React.useState<ModalState>(initialModalState);
127
+ const { openModal, dismissModal } = useModalStore();
135
128
 
136
129
  const playNextOverlayState = React.useRef();
137
130
 
@@ -153,6 +146,12 @@ export function NavigationProvider({ children }: Props) {
153
146
  [pathname, rivers]
154
147
  );
155
148
 
149
+ const getModalState: () => ModalState = () => {
150
+ const { modalState } = useModalStore.getState();
151
+
152
+ return modalState;
153
+ };
154
+
156
155
  const homeRiver = React.useMemo(
157
156
  () => homeRiverSelector({ rivers }),
158
157
  [rivers]
@@ -615,31 +614,6 @@ export function NavigationProvider({ children }: Props) {
615
614
  },
616
615
  });
617
616
 
618
- const openModal = React.useCallback(
619
- ({ item, options = {}, props = {} }: OpenModalArg) => {
620
- setModalState({
621
- visible: true,
622
- screen: item as ZappRiver,
623
- options: {
624
- animated: true,
625
- animationType: "slide",
626
- onShow: () => {},
627
- presentationStyle: "overFullScreen",
628
- transparent: true,
629
- ...options,
630
- onDismiss: () => {
631
- setModalState(initialModalState);
632
- },
633
- onRequestClose: () => {
634
- dismissModal();
635
- },
636
- },
637
- props,
638
- });
639
- },
640
- []
641
- );
642
-
643
617
  const openPiP = React.useCallback(() => {
644
618
  dispatch(setVideoPiP());
645
619
  }, []);
@@ -660,10 +634,6 @@ export function NavigationProvider({ children }: Props) {
660
634
  }
661
635
  }, [state?.options?.videoModal?.previousMode]);
662
636
 
663
- const dismissModal = React.useCallback(() => {
664
- setModalState(() => ({ ...initialModalState }));
665
- }, []);
666
-
667
637
  const openModalBottomSheet = React.useCallback(
668
638
  ({
669
639
  ModalBottomSheetContent,
@@ -730,7 +700,7 @@ export function NavigationProvider({ children }: Props) {
730
700
  modalData: state.stack.modal?.state ?? null,
731
701
  openModal,
732
702
  dismissModal,
733
- modalState,
703
+ getModalState,
734
704
  openModalBottomSheet,
735
705
  closeModalBottomSheet,
736
706
  videoModalState: state.options.videoModal,
@@ -748,14 +718,7 @@ export function NavigationProvider({ children }: Props) {
748
718
  getStack,
749
719
  getStackForPathname,
750
720
  }),
751
- [
752
- rivers,
753
- plugins,
754
- JSON.stringify(state),
755
- modalState,
756
- appLaunched,
757
- startUpHooks,
758
- ]
721
+ [rivers, plugins, JSON.stringify(state), appLaunched, startUpHooks]
759
722
  );
760
723
 
761
724
  // when running the tests, we pass the dispatch function
@@ -11,7 +11,9 @@ Object {
11
11
  "presentationStyle": "overFullScreen",
12
12
  "transparent": true,
13
13
  },
14
- "props": Object {},
14
+ "props": Object {
15
+ "screenData": Object {},
16
+ },
15
17
  "screen": Object {
16
18
  "id": "A1234",
17
19
  "navigations": Array [],
@@ -30,26 +32,7 @@ Object {
30
32
  }
31
33
  `;
32
34
 
33
- exports[`<NavigationProvider /> modal feature sets the modalState when opening a modal 1`] = `
34
- Object {
35
- "options": Object {
36
- "animated": true,
37
- "animationType": "slide",
38
- "onDismiss": [Function],
39
- "onRequestClose": [Function],
40
- "onShow": [Function],
41
- "presentationStyle": "overFullScreen",
42
- "transparent": true,
43
- },
44
- "props": Object {},
45
- "screen": Object {
46
- "id": "A1234",
47
- "navigations": Array [],
48
- "ui_components": Array [],
49
- },
50
- "visible": true,
51
- }
52
- `;
35
+ exports[`<NavigationProvider /> modal feature sets the modalState when opening a modal 1`] = `undefined`;
53
36
 
54
37
  exports[`<NavigationProvider /> modal feature should reset state to initial when dismissing a modal ( closeModalBottomSheet ) opened by openModalBottomSheet 1`] = `
55
38
  Object {
@@ -552,7 +552,7 @@ describe("<NavigationProvider />", () => {
552
552
 
553
553
  const view = wrapper.root.findByType(View);
554
554
  act(() => view.props.navigator.openModal({ item: rivers.A1234 }));
555
- expect(view.props.navigator.modalState).toMatchSnapshot();
555
+ expect(view.props.navigator.get).toMatchSnapshot();
556
556
  });
557
557
 
558
558
  it("removes the visible flag when dismissing a modal", () => {
@@ -568,10 +568,10 @@ describe("<NavigationProvider />", () => {
568
568
 
569
569
  const view = wrapper.root.findByType(View);
570
570
  act(() => view.props.navigator.openModal({ item: rivers.A1234 }));
571
- expect(view.props.navigator.modalState).toMatchSnapshot();
571
+ expect(view.props.navigator.getModalState()).toMatchSnapshot();
572
572
  act(() => view.props.navigator.dismissModal());
573
- expect(view.props.navigator.modalState.visible).toBeFalsy();
574
- expect(view.props.navigator.modalState).toMatchSnapshot();
573
+ expect(view.props.navigator.getModalState().visible).toBeFalsy();
574
+ expect(view.props.navigator.getModalState()).toMatchSnapshot();
575
575
  });
576
576
 
577
577
  it("should reset state to initial when dismissing a modal ( closeModalBottomSheet ) opened by openModalBottomSheet", () => {
@@ -594,9 +594,9 @@ describe("<NavigationProvider />", () => {
594
594
  })
595
595
  );
596
596
 
597
- expect(view.props.navigator.modalState).toMatchSnapshot();
597
+ expect(view.props.navigator.getModalState()).toMatchSnapshot();
598
598
  act(() => view.props.navigator.closeModalBottomSheet());
599
- expect(view.props.navigator.modalState).toMatchSnapshot();
599
+ expect(view.props.navigator.getModalState()).toMatchSnapshot();
600
600
  });
601
601
  });
602
602
  });
@@ -27,6 +27,7 @@ Object {
27
27
  "AppContainer": [Function],
28
28
  "ContentScreen": [Function],
29
29
  "HookRenderer": [Function],
30
+ "ModalComponent": [Function],
30
31
  "PlayerContainer": Object {
31
32
  "$$typeof": Symbol(react.memo),
32
33
  "WrappedComponent": Object {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/quick-brick-core",
3
- "version": "12.0.0-alpha.5114122134",
3
+ "version": "12.0.0-alpha.5251355865",
4
4
  "description": "Core package for Applicaster's Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -30,15 +30,15 @@
30
30
  },
31
31
  "homepage": "https://github.com/applicaster/quickbrick#readme",
32
32
  "dependencies": {
33
- "@applicaster/applicaster-types": "12.0.0-alpha.5114122134",
34
- "@applicaster/quick-brick-core-plugins": "12.0.0-alpha.5114122134",
35
- "@applicaster/zapp-pipes-v2-client": "12.0.0-alpha.5114122134",
36
- "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.5114122134",
37
- "@applicaster/zapp-react-native-redux": "12.0.0-alpha.5114122134",
38
- "@applicaster/zapp-react-native-ui-components": "12.0.0-alpha.5114122134",
39
- "@applicaster/zapp-react-native-utils": "12.0.0-alpha.5114122134",
33
+ "@applicaster/applicaster-types": "12.0.0-alpha.5251355865",
34
+ "@applicaster/quick-brick-core-plugins": "12.0.0-alpha.5251355865",
35
+ "@applicaster/zapp-pipes-v2-client": "12.0.0-alpha.5251355865",
36
+ "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.5251355865",
37
+ "@applicaster/zapp-react-native-redux": "12.0.0-alpha.5251355865",
38
+ "@applicaster/zapp-react-native-ui-components": "12.0.0-alpha.5251355865",
39
+ "@applicaster/zapp-react-native-utils": "12.0.0-alpha.5251355865",
40
40
  "atob": "^2.1.2",
41
- "axios": "^0.21.2",
41
+ "axios": "^0.28.0",
42
42
  "btoa": "^1.2.1",
43
43
  "camelize": "^1.0.0",
44
44
  "md5": "^2.3.0",