@lookiero/checkout 0.6.0-beta.19 → 0.6.0-beta.20

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,6 +1,7 @@
1
1
  import { I18n } from "@lookiero/i18n-react";
2
2
  import { MessagingRoot } from "@lookiero/messaging-react/bootstrap";
3
3
  import { ComponentType } from "react";
4
+ import { useRoutes as reactRouterUseRoutes } from "react-router-native";
4
5
  import { Customer } from "../../projection/shared/customer";
5
6
  import { SentryLoggerFunctionArgs } from "../../shared/logging/SentryLogger";
6
7
  import { Menu, TabBar } from "./views/navigation/Navigation";
@@ -8,7 +9,7 @@ interface RootFunctionArgs {
8
9
  readonly Messaging: MessagingRoot;
9
10
  readonly I18n: I18n;
10
11
  readonly development?: boolean;
11
- readonly sentry?: SentryLoggerFunctionArgs;
12
+ readonly sentry: SentryLoggerFunctionArgs;
12
13
  readonly getAuthToken: () => Promise<string>;
13
14
  }
14
15
  interface RootFunction {
@@ -22,6 +23,7 @@ interface RootProps {
22
23
  readonly tabBar: TabBar;
23
24
  readonly onNotAccessible: () => void;
24
25
  readonly useRedirect: () => Record<string, string>;
26
+ readonly useRoutes?: typeof reactRouterUseRoutes;
25
27
  }
26
28
  declare const root: RootFunction;
27
29
  export type { RootProps };
@@ -1,23 +1,20 @@
1
- import { wrapUseRoutes as sentryWrapUseRoutes } from "@sentry/react";
2
1
  import React, { useCallback } from "react";
3
2
  import { Platform } from "react-native";
3
+ import { useRoutes as reactRouterUseRoutes } from "react-router-native";
4
4
  import { sentryLogger } from "../../shared/logging/SentryLogger";
5
5
  import { Routing } from "./routing/Routing";
6
6
  const root = ({ Messaging, I18n, getAuthToken, development, sentry }) => {
7
- const wrapUseRoutes = sentry ? sentryWrapUseRoutes : undefined;
8
7
  // eslint-disable-next-line react/display-name, react/prop-types
9
- const Root = ({ basePath, locale = "en", customer, menu, tabBar, onNotAccessible, useRedirect }) => {
8
+ const Root = ({ basePath, locale = "en", customer, menu, tabBar, onNotAccessible, useRedirect, useRoutes = reactRouterUseRoutes, }) => {
10
9
  const handleOnI18nError = useCallback(() => void 0, []);
11
10
  return (React.createElement(Messaging, { includeReactQueryDevTools: Platform.OS === "web" },
12
- React.createElement(Routing, { I18n: I18n, basePath: basePath, customer: customer, getAuthToken: getAuthToken, locale: locale, menu: menu, tabBar: tabBar, useRedirect: useRedirect, wrapUseRoutes: wrapUseRoutes, onI18nError: development ? undefined : handleOnI18nError, onNotAccessible: onNotAccessible })));
11
+ React.createElement(Routing, { I18n: I18n, basePath: basePath, customer: customer, getAuthToken: getAuthToken, locale: locale, menu: menu, tabBar: tabBar, useRedirect: useRedirect, useRoutes: useRoutes, onI18nError: development ? undefined : handleOnI18nError, onNotAccessible: onNotAccessible })));
13
12
  };
14
- return sentry
15
- ? sentryLogger({
16
- publicKey: sentry.publicKey,
17
- environment: sentry.environment,
18
- release: sentry.release,
19
- project: sentry.project,
20
- })(Root)
21
- : Root;
13
+ return sentryLogger({
14
+ publicKey: sentry.publicKey,
15
+ environment: sentry.environment,
16
+ release: sentry.release,
17
+ project: sentry.project,
18
+ })(Root);
22
19
  };
23
20
  export { root };
@@ -1,9 +1,8 @@
1
1
  import { I18n } from "@lookiero/i18n-react";
2
- import React, { FC } from "react";
3
- import { Location, RouteObject } from "react-router-native";
2
+ import { FC } from "react";
3
+ import { useRoutes as reactRouterUseRoutes } from "react-router-native";
4
4
  import { Customer } from "../../../projection/shared/customer";
5
5
  import { Menu, TabBar } from "../views/navigation/Navigation";
6
- type UseRoutes = (routes: RouteObject[], locationArg?: Partial<Location> | string) => React.ReactElement | null;
7
6
  interface RoutingProps {
8
7
  readonly basePath?: string;
9
8
  readonly customer: Customer | undefined;
@@ -15,7 +14,7 @@ interface RoutingProps {
15
14
  readonly onNotAccessible: () => void;
16
15
  readonly onI18nError?: (err: Error) => void;
17
16
  readonly useRedirect: () => Record<string, string>;
18
- readonly wrapUseRoutes?: (origUseRoutes: UseRoutes) => UseRoutes;
17
+ readonly useRoutes: typeof reactRouterUseRoutes;
19
18
  }
20
19
  declare const Routing: FC<RoutingProps>;
21
20
  export { Routing };
@@ -1,5 +1,5 @@
1
- import React, { lazy, Suspense, useMemo } from "react";
2
- import { Navigate, Outlet, useRoutes as reactRouterUseRoutes } from "react-router-native";
1
+ import React, { lazy, Suspense } from "react";
2
+ import { Navigate, Outlet } from "react-router-native";
3
3
  import { Spinner } from "../../../shared/ui/components/atoms/spinner/Spinner";
4
4
  import { App } from "../views/App";
5
5
  import { CheckoutPaymentModal } from "../views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal";
@@ -12,8 +12,7 @@ const Item = lazy(() => import("../views/item/Item").then((module) => ({ default
12
12
  const Summary = lazy(() => import("../views/summary/Summary").then((module) => ({ default: module.Summary })));
13
13
  const Checkout = lazy(() => import("../views/checkout/Checkout").then((module) => ({ default: module.Checkout })));
14
14
  const Feedback = lazy(() => import("../views/feedback/Feedback").then((module) => ({ default: module.Feedback })));
15
- const Routing = ({ basePath = "", customer, locale, I18n, menu, tabBar, getAuthToken, onI18nError, onNotAccessible, useRedirect, wrapUseRoutes = (routes) => routes, }) => {
16
- const useRoutes = useMemo(() => wrapUseRoutes(reactRouterUseRoutes), [wrapUseRoutes]);
15
+ const Routing = ({ basePath = "", customer, locale, I18n, menu, tabBar, getAuthToken, onI18nError, onNotAccessible, useRedirect, useRoutes, }) => {
17
16
  const routes = useRoutes([
18
17
  {
19
18
  path: "",
@@ -15,5 +15,5 @@ interface SentryLoggerFunction {
15
15
  (args: SentryLoggerFunctionArgs): <P extends SentryLoggerHOCProps>(Component: ComponentType<P>) => ComponentType<P & JSX.IntrinsicAttributes>;
16
16
  }
17
17
  declare const sentryLogger: SentryLoggerFunction;
18
- export type { SentryLoggerFunctionArgs };
18
+ export type { SentryLoggerFunctionArgs, SentryLoggerHOCProps };
19
19
  export { sentryLogger };
@@ -1,7 +1,9 @@
1
1
  import { defaultStackParser } from "@sentry/browser";
2
2
  import { makeMain } from "@sentry/core";
3
+ import { wrapUseRoutes } from "@sentry/react";
3
4
  import React, { useEffect } from "react";
4
5
  import { Platform } from "react-native";
6
+ import { useRoutes as reactRouterUseRoutes } from "react-router-native";
5
7
  import { Client, Hub, ErrorBoundary, transport, integrations, wrap } from "./SentryDependencies";
6
8
  const sentryLogger = ({ publicKey, environment, release, project }) => {
7
9
  let mainHub;
@@ -88,6 +90,7 @@ const sentryLogger = ({ publicKey, environment, release, project }) => {
88
90
  };
89
91
  return (Component) => {
90
92
  const WrappedComponent = wrap(Component);
93
+ const useRoutes = wrapUseRoutes(reactRouterUseRoutes);
91
94
  const SentryLogger = (props) => {
92
95
  const { customer } = props;
93
96
  useEffect(() => {
@@ -95,7 +98,7 @@ const sentryLogger = ({ publicKey, environment, release, project }) => {
95
98
  return onUnMount;
96
99
  }, [customer?.customerId]);
97
100
  return (React.createElement(ErrorBoundary, null,
98
- React.createElement(WrappedComponent, { ...props })));
101
+ React.createElement(WrappedComponent, { ...props, useRoutes: useRoutes })));
99
102
  };
100
103
  return SentryLogger;
101
104
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.6.0-beta.19",
3
+ "version": "0.6.0-beta.20",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [