@applicaster/quick-brick-core 12.0.0-rc.98 → 13.0.0-alpha.2322412833

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,15 +1,11 @@
1
- import React, { ReactChild, useCallback, useContext } from "react";
1
+ import React, { useCallback, useContext } from "react";
2
2
 
3
3
  import { URLSchemeHandler } from "../URLSchemeHandler";
4
4
  import { URLSchemeContext } from "./URLSchemeContextProvider";
5
5
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
6
6
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
7
7
 
8
- type Props = {
9
- children: ReactChild;
10
- };
11
-
12
- export function URLSchemeListener(props: Props) {
8
+ export function URLSchemeListener({ children }) {
13
9
  const { url, done } = useContext(URLSchemeContext);
14
10
 
15
11
  const navigator = useNavigation();
@@ -33,5 +29,5 @@ export function URLSchemeListener(props: Props) {
33
29
  return <URLSchemeHandler url={url} onFinish={onFinish} />;
34
30
  }
35
31
 
36
- return props.children;
32
+ return children;
37
33
  }
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+
3
+ export const LogicAggregatorContainer = ({ components }) => {
4
+ return components.map((Component, index) => <Component key={index} />);
5
+ };
@@ -66,6 +66,7 @@ import { inflateUrl } from "@applicaster/zapp-react-native-ui-components/Compone
66
66
  import { useModalStore } from "@applicaster/zapp-react-native-utils/modalState";
67
67
  import { useSubscriberFor } from "@applicaster/zapp-react-native-utils/reactHooks/useSubscriberFor";
68
68
  import { QBUIComponentEvents } from "@applicaster/zapp-react-native-ui-components/events";
69
+ import { Hook } from "@applicaster/zapp-react-native-utils/appUtils/HooksManager/Hook";
69
70
 
70
71
  const logger = coreAppLogger.addSubsystem("Navigator");
71
72
 
@@ -75,17 +76,6 @@ type Props = {
75
76
  plugins?: QuickBrickPlugin[];
76
77
  };
77
78
 
78
- type EntryWithParent = ZappEntry & { parent?: EntryWithParent };
79
-
80
- type SingleEntry = {
81
- data: EntryWithParent;
82
- route: string;
83
- id: string;
84
- parentId?: string;
85
- };
86
-
87
- type EntryContextType = { [K in string]: SingleEntry };
88
-
89
79
  const navigationActions = {
90
80
  [ACTIONS.PUSH]: push,
91
81
  [ACTIONS.REPLACE]: replace,
@@ -122,9 +112,7 @@ export function NavigationProvider({ children }: Props) {
122
112
  const pathname = state?.location?.pathname;
123
113
  const pathnameRef = React.useRef(pathname);
124
114
 
125
- const { context }: EntryContextType = React.useContext(
126
- ZappPipesEntryContext.Context
127
- );
115
+ const { context } = React.useContext(ZappPipesEntryContext.Context);
128
116
 
129
117
  const { openModal, dismissModal } = useModalStore();
130
118
 
@@ -380,7 +368,18 @@ export function NavigationProvider({ children }: Props) {
380
368
  }
381
369
  };
382
370
 
383
- const handleHookPresent = ({ hookPlugin, route, payload }, dispose) => {
371
+ const handleHookPresent = (
372
+ {
373
+ hookPlugin,
374
+ route,
375
+ payload,
376
+ }: {
377
+ hookPlugin: Hook;
378
+ route: string;
379
+ payload: object;
380
+ },
381
+ dispose
382
+ ) => {
384
383
  if (hookPlugin?.lastHook) {
385
384
  dispose();
386
385
  }
@@ -614,7 +613,9 @@ export function NavigationProvider({ children }: Props) {
614
613
  },
615
614
  };
616
615
 
617
- HooksManager(hooksOptions)
616
+ const hooksManager = HooksManager(hooksOptions);
617
+
618
+ hooksManager.subscriber
618
619
  .on(HOOKS_EVENTS.PRESENT_SCREEN_HOOK, handleHookPresent)
619
620
  .on(HOOKS_EVENTS.ERROR, handleHookError)
620
621
  .on(HOOKS_EVENTS.CANCEL, handleHookCancel)
@@ -625,8 +626,9 @@ export function NavigationProvider({ children }: Props) {
625
626
  screen,
626
627
  options,
627
628
  })
628
- )
629
- .handleHooks(legacyScreenData({ entry, screen }));
629
+ );
630
+
631
+ hooksManager.handleHooks(legacyScreenData({ entry, screen }));
630
632
  } else {
631
633
  dispatch(navigationAction(targetRoute, { screen, entry, options }));
632
634
  }
@@ -1,15 +1,9 @@
1
1
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
2
- import * as React from "react";
3
2
  import { usePluginScreenHooks } from "./usePluginScreenHooks";
4
3
 
5
- type Props = {
6
- pathname: string;
7
- children: React.ReactChildren;
8
- };
9
-
10
- export function ApplyScreenHooks({ children }: Props) {
4
+ export function ApplyScreenHooks() {
11
5
  const { currentRoute } = useNavigation();
12
6
  usePluginScreenHooks(currentRoute);
13
7
 
14
- return children;
8
+ return null;
15
9
  }
@@ -11,9 +11,7 @@ Object {
11
11
  "presentationStyle": "overFullScreen",
12
12
  "transparent": true,
13
13
  },
14
- "props": Object {
15
- "screenData": Object {},
16
- },
14
+ "props": undefined,
17
15
  "screen": Object {
18
16
  "id": "A1234",
19
17
  "navigations": Array [],
@@ -54,11 +54,10 @@ export function legacyScreenData(
54
54
  screenState: NavigationScreenData,
55
55
  plugins?: QuickBrickPlugin[]
56
56
  ): QuickBrickNavigationData {
57
- // @ts-ignore - this happens only on launch
58
- if (!screenState) return {};
59
-
60
- const entry = screenState?.entry;
61
57
  let targetScreen = screenState?.screen;
58
+ const entry = screenState?.entry;
59
+ // @ts-ignore - this happens only on launch
60
+ if (!targetScreen) return {};
62
61
 
63
62
  /**
64
63
  * HACK: We mutate targetScreen by merging screenOrientation for the player.
@@ -127,6 +126,10 @@ export function getNavigationTarget(
127
126
  targetRoute?: string;
128
127
  externalUrl?: string;
129
128
  } {
129
+ if (!item) {
130
+ return {};
131
+ }
132
+
130
133
  const targetRoute = getTargetRoute(item, pathname, {
131
134
  layoutVersion,
132
135
  contentTypes,
@@ -9,17 +9,9 @@ import {
9
9
  partitionByKeys,
10
10
  } from "@applicaster/zapp-react-native-utils/objectUtils";
11
11
 
12
- type Plugin = {
13
- name: string;
14
- identifier: string;
15
- module: any;
16
- type: string;
17
- configuration: { [key: string]: any };
18
- };
19
-
20
12
  type Props = {
21
13
  children: React.ReactNode;
22
- plugins: Plugin[];
14
+ plugins: QuickBrickPlugin[];
23
15
  };
24
16
 
25
17
  const DEFAULT_THEME_ID = "base-theme";
package/App/index.tsx CHANGED
@@ -28,16 +28,14 @@ import { withURLSchemeContextProvider } from "./DeepLinking/URLSchemeListener/UR
28
28
  import { appRemoteDataLoader } from "./appRemoteDataLoader";
29
29
  import { withActionExecutor } from "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutorContext";
30
30
  import { withScreenDataContextProvider } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
31
+ import { LogicAggregatorContainer } from "./LogicAggregatorContainer";
31
32
 
32
- /**
33
- * @typedef {Object} AppOptions
34
- * @param {Function} InteractionManager decorator to use for managing complex user interactions in the app
35
- * @param {ReactComponent} Layout Component to use as main layout for the app
36
-
37
- * @param {Object} QuickBrickManager QB manager module
38
- * @param {Function} QuickBrickManager.sendQuickBrickEvent function invoked to pass events to the native side
39
- * @param {[Function]} ContextProviders array of context providers to pass to the app
40
- */
33
+ interface AppOptions {
34
+ Layout: React.ComponentType;
35
+ OfflineHandler: React.ComponentType;
36
+ SplashLoader: React.ComponentType;
37
+ InteractionManager: React.ComponentType;
38
+ }
41
39
 
42
40
  /**
43
41
  * Creates a QuickBrick app with the provided options
@@ -45,12 +43,19 @@ import { withScreenDataContextProvider } from "@applicaster/zapp-react-native-ui
45
43
  * @param {AppOptions} options
46
44
  * @returns {ReactComponent}
47
45
  */
48
- const App = ({ Layout, OfflineHandler, SplashLoader }): ZappApp =>
49
- React.memo(function ZappApp({
50
- styles,
51
- components: { AppContainer },
52
- plugins,
53
- }: AppComponentProps) {
46
+ const App = ({
47
+ Layout,
48
+ OfflineHandler,
49
+ SplashLoader,
50
+ InteractionManager,
51
+ }: AppOptions): ZappApp =>
52
+ React.memo(function ZappApp(props: AppComponentProps) {
53
+ const {
54
+ styles,
55
+ components: { AppContainer },
56
+ plugins,
57
+ } = props;
58
+
54
59
  return (
55
60
  <ThemeManager plugins={plugins}>
56
61
  <SafeAreaProvider initialMetrics={initialWindowMetrics}>
@@ -59,15 +64,16 @@ const App = ({ Layout, OfflineHandler, SplashLoader }): ZappApp =>
59
64
  <URLSchemeListener>
60
65
  <SplashLoader>
61
66
  <OfflineHandler>
62
- <ApplyScreenHooks>
63
- <Layout>
64
- <RouteManager />
65
- </Layout>
66
- </ApplyScreenHooks>
67
+ <Layout>
68
+ <RouteManager />
69
+ </Layout>
67
70
  </OfflineHandler>
68
71
  </SplashLoader>
69
72
  <ModalProvider />
70
73
  </URLSchemeListener>
74
+ <LogicAggregatorContainer
75
+ components={[InteractionManager, ApplyScreenHooks]}
76
+ />
71
77
  </ErrorBoundary>
72
78
  </AppContainer>
73
79
  </SafeAreaProvider>
@@ -77,7 +83,7 @@ const App = ({ Layout, OfflineHandler, SplashLoader }): ZappApp =>
77
83
 
78
84
  export function createQuickBrickApp(options): ZappApp {
79
85
  const {
80
- InteractionManager = R.identity,
86
+ InteractionManager = () => null,
81
87
  Layout,
82
88
  QuickBrickManager,
83
89
  OfflineHandler = R.prop("children"),
@@ -95,16 +101,15 @@ export function createQuickBrickApp(options): ZappApp {
95
101
  storeConnector, // storeConnector should be first, as it disregards other props
96
102
  ...ContextProviders, // contexts consumers are only working below this point
97
103
  appRemoteDataLoader,
98
- withAppManager, // provides handlers when the app is going in the background, or comes out of it
104
+ withAppManager, // provides handlers when the app is going in the background, or comes out of it, can be moved to LogicAggregatorContainer
99
105
  ZappPipesEntryContext.withProvider,
100
106
  withURLSchemeContextProvider,
101
107
  withNetworkStatusProvider,
102
108
  withNavigationProvider,
103
109
  withScreenDataContextProvider,
104
110
  ZappPipesSearchContext.withProvider,
105
- InteractionManager,
106
111
  withActionExecutor,
107
112
  withActionsProvider,
108
- appLifeCycleManager(appLoader, QuickBrickManager)
109
- )(App({ Layout, OfflineHandler, SplashLoader }));
113
+ appLifeCycleManager(appLoader, QuickBrickManager) // can be moved to LogicAggregatorContainer
114
+ )(App({ Layout, OfflineHandler, SplashLoader, InteractionManager }));
110
115
  }
@@ -20,7 +20,6 @@ Object {
20
20
  "isAvailable": null,
21
21
  "nextState": null,
22
22
  },
23
- "isTransitioning": false,
24
23
  },
25
24
  "cellStyles": Object {},
26
25
  "components": Object {
package/defaults/index.js CHANGED
@@ -1,5 +1,3 @@
1
- // @flow
2
-
3
1
  /**
4
2
  * quick-brick-core module
5
3
  * @module @applicaster/quick-brick-core/defaults
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "@applicaster/quick-brick-core",
3
- "version": "12.0.0-rc.98",
3
+ "version": "13.0.0-alpha.2322412833",
4
4
  "description": "Core package for Applicaster's Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "scripts": {
8
8
  "test": "jest -w=2",
9
- "flow-types": "node_modules/.bin/flow-copy-source -v -i '**/__tests__**' . .",
10
9
  "build": "echo 'skipping ts build for core packages'"
11
10
  },
12
11
  "repository": {
@@ -30,13 +29,13 @@
30
29
  },
31
30
  "homepage": "https://github.com/applicaster/quickbrick#readme",
32
31
  "dependencies": {
33
- "@applicaster/applicaster-types": "12.0.0-rc.98",
34
- "@applicaster/quick-brick-core-plugins": "12.0.0-rc.98",
35
- "@applicaster/zapp-pipes-v2-client": "12.0.0-rc.98",
36
- "@applicaster/zapp-react-native-bridge": "12.0.0-rc.98",
37
- "@applicaster/zapp-react-native-redux": "12.0.0-rc.98",
38
- "@applicaster/zapp-react-native-ui-components": "12.0.0-rc.98",
39
- "@applicaster/zapp-react-native-utils": "12.0.0-rc.98",
32
+ "@applicaster/applicaster-types": "13.0.0-alpha.2322412833",
33
+ "@applicaster/quick-brick-core-plugins": "13.0.0-alpha.2322412833",
34
+ "@applicaster/zapp-pipes-v2-client": "13.0.0-alpha.2322412833",
35
+ "@applicaster/zapp-react-native-bridge": "13.0.0-alpha.2322412833",
36
+ "@applicaster/zapp-react-native-redux": "13.0.0-alpha.2322412833",
37
+ "@applicaster/zapp-react-native-ui-components": "13.0.0-alpha.2322412833",
38
+ "@applicaster/zapp-react-native-utils": "13.0.0-alpha.2322412833",
40
39
  "atob": "^2.1.2",
41
40
  "axios": "^0.28.0",
42
41
  "btoa": "^1.2.1",