@applicaster/quick-brick-core 15.1.11-rc.1 → 15.1.12-rc.0

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.
@@ -58,6 +58,7 @@ import {
58
58
  getTargetScreen,
59
59
  legacyScreenData,
60
60
  openExternalUrl,
61
+ stripHookPrefix,
61
62
  } from "./utils";
62
63
  import {
63
64
  debounce,
@@ -417,6 +418,19 @@ export function NavigationProvider({ children }: Props) {
417
418
  },
418
419
  dispose
419
420
  ) => {
421
+ logger.debug({
422
+ message: `Hook screen presented: ${
423
+ hookPlugin.isModalHook() ? `(modal) ${route}` : route
424
+ }`,
425
+ data: {
426
+ route,
427
+ hookIdentifier: hookPlugin?.identifier,
428
+ hookScreenId: hookPlugin?.screen_id,
429
+ isModal: hookPlugin.isModalHook(),
430
+ lastHook: hookPlugin?.lastHook,
431
+ },
432
+ });
433
+
420
434
  if (hookPlugin?.lastHook) {
421
435
  dispose();
422
436
  }
@@ -549,6 +563,17 @@ export function NavigationProvider({ children }: Props) {
549
563
  currentStartUpHooks.current && setStartUpHooks(false);
550
564
  }
551
565
 
566
+ logger.debug({
567
+ message: `Hooks complete, navigating to: ${targetRoute}`,
568
+ data: {
569
+ targetRoute,
570
+ hookIdentifier: hookPlugin?.identifier,
571
+ screenId: screen?.id,
572
+ screenName: screen?.name,
573
+ options,
574
+ },
575
+ });
576
+
552
577
  dispatch(
553
578
  navigationAction(targetRoute, { screen, entry: payload, options })
554
579
  );
@@ -587,12 +612,28 @@ export function NavigationProvider({ children }: Props) {
587
612
  ) => {
588
613
  const { entry, screen, targetRoute, externalUrl } = getNavigationTarget(
589
614
  item,
590
- action === ACTIONS.REPLACE ? "" : pathnameRef.current,
615
+ action === ACTIONS.REPLACE ? "" : stripHookPrefix(pathnameRef.current),
591
616
  contentTypes,
592
617
  layoutVersion,
593
618
  rivers
594
619
  );
595
620
 
621
+ logger.debug({
622
+ message: `Navigating: ${pathnameRef.current || "(none)"} -> ${
623
+ targetRoute || externalUrl || "(unresolved)"
624
+ }`,
625
+ data: {
626
+ action,
627
+ from: pathnameRef.current,
628
+ to: targetRoute,
629
+ externalUrl,
630
+ screenId: screen?.id,
631
+ screenName: screen?.name,
632
+ entryType: entry?.type?.value,
633
+ options,
634
+ },
635
+ });
636
+
596
637
  if (externalUrl) {
597
638
  const openURL = async (url) => {
598
639
  const inflatedURL = await inflateUrl(url);
@@ -681,6 +722,15 @@ export function NavigationProvider({ children }: Props) {
681
722
 
682
723
  hooksManager.handleHooks(legacyScreenData({ entry, screen }));
683
724
  } else {
725
+ logger.debug({
726
+ message: `Navigating offline (hooks skipped) to: ${targetRoute}`,
727
+ data: {
728
+ targetRoute,
729
+ screenId: screen?.id,
730
+ screenName: screen?.name,
731
+ },
732
+ });
733
+
684
734
  dispatch(navigationAction(targetRoute, { screen, entry, options }));
685
735
  }
686
736
  },
@@ -1,4 +1,4 @@
1
- const { targetShouldOpenExternally } = require("../utils");
1
+ const { targetShouldOpenExternally, stripHookPrefix } = require("../utils");
2
2
 
3
3
  const mockedOpenUrl = jest.fn();
4
4
 
@@ -116,3 +116,33 @@ describe("targetShouldOpenExternally", () => {
116
116
  });
117
117
  });
118
118
  });
119
+
120
+ describe("stripHookPrefix", () => {
121
+ const HOOK = "203d96a9-f4af-49d1-9890-435e683b9274";
122
+ const MANAGE = "9f8e1e06-abd6-48b9-b73a-4caf4601f870";
123
+
124
+ it("drops the hook segment so a hook screen navigates from the root", () => {
125
+ expect(stripHookPrefix(`/hooks/${HOOK}`)).toBe("");
126
+ });
127
+
128
+ it("keeps the screens opened from a hook, without their hook prefix", () => {
129
+ expect(stripHookPrefix(`/hooks/${HOOK}/river/${MANAGE}`)).toBe(
130
+ `/river/${MANAGE}`
131
+ );
132
+ });
133
+
134
+ it("leaves a regular route untouched", () => {
135
+ expect(stripHookPrefix(`/river/${MANAGE}`)).toBe(`/river/${MANAGE}`);
136
+ });
137
+
138
+ it("only strips a hook segment at the start of the path", () => {
139
+ expect(stripHookPrefix(`/river/${MANAGE}/hooks/${HOOK}`)).toBe(
140
+ `/river/${MANAGE}/hooks/${HOOK}`
141
+ );
142
+ });
143
+
144
+ it("returns an empty prefix for an empty or missing path", () => {
145
+ expect(stripHookPrefix("")).toBe("");
146
+ expect(stripHookPrefix(undefined)).toBe("");
147
+ });
148
+ });
@@ -18,6 +18,20 @@ const WEBVIEW_SCREEN_IDENTIFIER = "webview_screen_qb";
18
18
 
19
19
  const logger = coreAppLogger.addSubsystem("Navigator");
20
20
 
21
+ /**
22
+ * Drops a leading `/hooks/<screen_id>` segment from a path.
23
+ *
24
+ * Routes are built by appending to the current path, and a hook screen is
25
+ * presented at an absolute `/hooks/<screen_id>`. Without this, every screen
26
+ * opened from a hook would inherit that prefix for good: the hook's stack entry
27
+ * would stay buried under its descendants, and `canGoBack` — which treats any
28
+ * route containing `/hooks` as a hook — would count the whole branch as one
29
+ * entry and send Back home instead of popping.
30
+ */
31
+ export function stripHookPrefix(pathname?: string): string {
32
+ return pathname?.replace(/^\/hooks\/[^/]+/, "") ?? "";
33
+ }
34
+
21
35
  export function targetShouldOpenExternally(
22
36
  target: ZappEntry,
23
37
  targetScreen: ZappRiver | null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/quick-brick-core",
3
- "version": "15.1.11-rc.1",
3
+ "version": "15.1.12-rc.0",
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": "15.1.11-rc.1",
32
- "@applicaster/quick-brick-core-plugins": "15.1.11-rc.1",
33
- "@applicaster/zapp-pipes-v2-client": "15.1.11-rc.1",
34
- "@applicaster/zapp-react-native-bridge": "15.1.11-rc.1",
35
- "@applicaster/zapp-react-native-redux": "15.1.11-rc.1",
36
- "@applicaster/zapp-react-native-ui-components": "15.1.11-rc.1",
37
- "@applicaster/zapp-react-native-utils": "15.1.11-rc.1",
31
+ "@applicaster/applicaster-types": "15.1.12-rc.0",
32
+ "@applicaster/quick-brick-core-plugins": "15.1.12-rc.0",
33
+ "@applicaster/zapp-pipes-v2-client": "15.1.12-rc.0",
34
+ "@applicaster/zapp-react-native-bridge": "15.1.12-rc.0",
35
+ "@applicaster/zapp-react-native-redux": "15.1.12-rc.0",
36
+ "@applicaster/zapp-react-native-ui-components": "15.1.12-rc.0",
37
+ "@applicaster/zapp-react-native-utils": "15.1.12-rc.0",
38
38
  "atob": "^2.1.2",
39
39
  "axios": "^0.28.0",
40
40
  "btoa": "^1.2.1",