@applicaster/quick-brick-core 13.0.0-alpha.5371423120 → 13.0.0-alpha.6714678893

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.
@@ -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
  }
@@ -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,
@@ -19,3 +19,5 @@ export const TYPE_KEYS = [
19
19
  "layout",
20
20
  "pipesEndpoints",
21
21
  ];
22
+
23
+ export const ACTIVE_LAYOUT_ID_STORAGE_KEY = "active_layout_id";
@@ -1,5 +1,5 @@
1
1
  import * as R from "ramda";
2
- import { Dimensions } from "react-native";
2
+ import { Dimensions, NativeModules } from "react-native";
3
3
  import { loadAppContextData } from "@applicaster/zapp-react-native-redux";
4
4
  import { isTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
5
5
  import { mapPromises } from "@applicaster/zapp-react-native-utils/arrayUtils";
@@ -7,6 +7,9 @@ import { fetchPluginConfiguration, getPromiseForType } from "../helpers";
7
7
  import { cacheAssets } from "../../AssetCache";
8
8
  import { actions as appDataActions } from "@applicaster/zapp-react-native-redux/AppData";
9
9
  import { logger } from "@applicaster/zapp-react-native-utils/logger";
10
+ import { ACTIVE_LAYOUT_ID_STORAGE_KEY } from "../consts";
11
+ const { AppLoaderBridge } = NativeModules;
12
+ import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
10
13
 
11
14
  export async function getNativeRemoteContextData(
12
15
  dispatch,
@@ -33,11 +36,19 @@ export async function getNativeRemoteContextData(
33
36
  R.pathSatisfies(R.is(Function), ["module", "selectLayout"])
34
37
  )(plugins);
35
38
 
36
- await layoutManagerPlugin?.module?.selectLayout({
37
- runtimeConfigurationUrls,
38
- plugin: layoutManagerPlugin,
39
- isTablet: isTabletDevice,
40
- });
39
+ if (layoutManagerPlugin) {
40
+ await layoutManagerPlugin.module?.selectLayout({
41
+ runtimeConfigurationUrls,
42
+ plugin: layoutManagerPlugin,
43
+ isTablet: isTabletDevice,
44
+ });
45
+ } else {
46
+ const layoutId = await localStorage.getItem(ACTIVE_LAYOUT_ID_STORAGE_KEY);
47
+
48
+ if (layoutId) {
49
+ await AppLoaderBridge?.switchLayout(layoutId, null);
50
+ }
51
+ }
41
52
  } catch (error) {
42
53
  logger.error({
43
54
  message: "Error selecting layout using layout manager plugin",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/quick-brick-core",
3
- "version": "13.0.0-alpha.5371423120",
3
+ "version": "13.0.0-alpha.6714678893",
4
4
  "description": "Core package for Applicaster's Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -29,13 +29,13 @@
29
29
  },
30
30
  "homepage": "https://github.com/applicaster/quickbrick#readme",
31
31
  "dependencies": {
32
- "@applicaster/applicaster-types": "13.0.0-alpha.5371423120",
33
- "@applicaster/quick-brick-core-plugins": "13.0.0-alpha.5371423120",
34
- "@applicaster/zapp-pipes-v2-client": "13.0.0-alpha.5371423120",
35
- "@applicaster/zapp-react-native-bridge": "13.0.0-alpha.5371423120",
36
- "@applicaster/zapp-react-native-redux": "13.0.0-alpha.5371423120",
37
- "@applicaster/zapp-react-native-ui-components": "13.0.0-alpha.5371423120",
38
- "@applicaster/zapp-react-native-utils": "13.0.0-alpha.5371423120",
32
+ "@applicaster/applicaster-types": "13.0.0-alpha.6714678893",
33
+ "@applicaster/quick-brick-core-plugins": "13.0.0-alpha.6714678893",
34
+ "@applicaster/zapp-pipes-v2-client": "13.0.0-alpha.6714678893",
35
+ "@applicaster/zapp-react-native-bridge": "13.0.0-alpha.6714678893",
36
+ "@applicaster/zapp-react-native-redux": "13.0.0-alpha.6714678893",
37
+ "@applicaster/zapp-react-native-ui-components": "13.0.0-alpha.6714678893",
38
+ "@applicaster/zapp-react-native-utils": "13.0.0-alpha.6714678893",
39
39
  "atob": "^2.1.2",
40
40
  "axios": "^0.28.0",
41
41
  "btoa": "^1.2.1",