@applicaster/quick-brick-core 16.0.0-rc.76 → 16.0.0-rc.77

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.
@@ -55,6 +55,7 @@ import {
55
55
  getTargetScreen,
56
56
  legacyScreenData,
57
57
  openExternalUrl,
58
+ stripHookPrefix,
58
59
  } from "./utils";
59
60
  import {
60
61
  debounce,
@@ -414,6 +415,19 @@ export function NavigationProvider({ children }: Props) {
414
415
  },
415
416
  dispose
416
417
  ) => {
418
+ logger.debug({
419
+ message: `Hook screen presented: ${
420
+ hookPlugin.isModalHook() ? `(modal) ${route}` : route
421
+ }`,
422
+ data: {
423
+ route,
424
+ hookIdentifier: hookPlugin?.identifier,
425
+ hookScreenId: hookPlugin?.screen_id,
426
+ isModal: hookPlugin.isModalHook(),
427
+ lastHook: hookPlugin?.lastHook,
428
+ },
429
+ });
430
+
417
431
  if (hookPlugin?.lastHook) {
418
432
  dispose();
419
433
  }
@@ -536,6 +550,17 @@ export function NavigationProvider({ children }: Props) {
536
550
  currentStartUpHooks.current && setStartUpHooks(false);
537
551
  }
538
552
 
553
+ logger.debug({
554
+ message: `Hooks complete, navigating to: ${targetRoute}`,
555
+ data: {
556
+ targetRoute,
557
+ hookIdentifier: hookPlugin?.identifier,
558
+ screenId: screen?.id,
559
+ screenName: screen?.name,
560
+ options,
561
+ },
562
+ });
563
+
539
564
  dispatch(
540
565
  navigationAction(targetRoute, { screen, entry: payload, options })
541
566
  );
@@ -574,12 +599,28 @@ export function NavigationProvider({ children }: Props) {
574
599
  ) => {
575
600
  const { entry, screen, targetRoute, externalUrl } = getNavigationTarget(
576
601
  item,
577
- action === ACTIONS.REPLACE ? "" : pathnameRef.current,
602
+ action === ACTIONS.REPLACE ? "" : stripHookPrefix(pathnameRef.current),
578
603
  contentTypes,
579
604
  layoutVersion,
580
605
  rivers
581
606
  );
582
607
 
608
+ logger.debug({
609
+ message: `Navigating: ${pathnameRef.current || "(none)"} -> ${
610
+ targetRoute || externalUrl || "(unresolved)"
611
+ }`,
612
+ data: {
613
+ action,
614
+ from: pathnameRef.current,
615
+ to: targetRoute,
616
+ externalUrl,
617
+ screenId: screen?.id,
618
+ screenName: screen?.name,
619
+ entryType: entry?.type?.value,
620
+ options,
621
+ },
622
+ });
623
+
583
624
  if (externalUrl) {
584
625
  const openURL = async (url) => {
585
626
  const inflatedURL = await inflateUrl(url);
@@ -668,6 +709,15 @@ export function NavigationProvider({ children }: Props) {
668
709
 
669
710
  hooksManager.handleHooks(legacyScreenData({ entry, screen }));
670
711
  } else {
712
+ logger.debug({
713
+ message: `Navigating offline (hooks skipped) to: ${targetRoute}`,
714
+ data: {
715
+ targetRoute,
716
+ screenId: screen?.id,
717
+ screenName: screen?.name,
718
+ },
719
+ });
720
+
671
721
  dispatch(navigationAction(targetRoute, { screen, entry, options }));
672
722
  }
673
723
  },
@@ -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": "16.0.0-rc.76",
3
+ "version": "16.0.0-rc.77",
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": "16.0.0-rc.76",
32
- "@applicaster/quick-brick-core-plugins": "16.0.0-rc.76",
33
- "@applicaster/zapp-pipes-v2-client": "16.0.0-rc.76",
34
- "@applicaster/zapp-react-native-bridge": "16.0.0-rc.76",
35
- "@applicaster/zapp-react-native-redux": "16.0.0-rc.76",
36
- "@applicaster/zapp-react-native-ui-components": "16.0.0-rc.76",
37
- "@applicaster/zapp-react-native-utils": "16.0.0-rc.76",
31
+ "@applicaster/applicaster-types": "16.0.0-rc.77",
32
+ "@applicaster/quick-brick-core-plugins": "16.0.0-rc.77",
33
+ "@applicaster/zapp-pipes-v2-client": "16.0.0-rc.77",
34
+ "@applicaster/zapp-react-native-bridge": "16.0.0-rc.77",
35
+ "@applicaster/zapp-react-native-redux": "16.0.0-rc.77",
36
+ "@applicaster/zapp-react-native-ui-components": "16.0.0-rc.77",
37
+ "@applicaster/zapp-react-native-utils": "16.0.0-rc.77",
38
38
  "atob": "^2.1.2",
39
39
  "axios": "^0.28.0",
40
40
  "btoa": "^1.2.1",