catalyst-core 0.3.0-beta.4 → 0.3.0-beta.5

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.
package/dist/index.jsx CHANGED
@@ -1,4 +1,4 @@
1
- export * from "react-router-dom"
1
+ export * from "react-router"
2
2
  export * from "./web-router/components/RouterDataProvider.jsx"
3
3
  export * from "./web-router/components/MetaTag.jsx"
4
4
  export { split, hydrationReady } from "./web-router/components/Split.jsx"
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useNativeTransition = void 0;
7
7
  var _react = require("react");
8
- var _reactRouterDom = require("react-router-dom");
8
+ var _reactRouter = require("react-router");
9
9
  var _NativeBridge = _interopRequireDefault(require("../utils/NativeBridge.js"));
10
10
  var _NativeInterfaces = require("../constants/NativeInterfaces.js");
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -34,7 +34,7 @@ const MIN_TIMEOUT = 800;
34
34
  * timeout: ms safety timer (default: max(duration*3, 800))
35
35
  */
36
36
  const useNativeTransition = (defaults = {}) => {
37
- const router = (0, _reactRouterDom.useNavigate)();
37
+ const router = (0, _reactRouter.useNavigate)();
38
38
  const isNative = typeof window !== "undefined" && _NativeBridge.default.isAvailable();
39
39
  const [transitioning, setTransitioning] = (0, _react.useState)(false);
40
40
  const overlayRef = (0, _react.useRef)(null);
@@ -4,7 +4,7 @@ import { Provider } from "react-redux"
4
4
  import { Body } from "./document/Body.jsx"
5
5
  import { Head } from "./document/Head.jsx"
6
6
 
7
- import { StaticRouter } from "react-router-dom/server"
7
+ import { StaticRouter } from "react-router"
8
8
  import ServerRouter from "../../router/ServerRouter.js"
9
9
  import { renderToPipeableStream } from "react-dom/server"
10
10
  import { getUserAgentDetails } from "../utils/userAgentUtil.js"
@@ -288,6 +288,7 @@ const browserOptimizeDeps = [
288
288
  "react-dom",
289
289
  "react-dom/client",
290
290
  "react-redux",
291
+ "react-router",
291
292
  "react-router-dom",
292
293
  "redux",
293
294
  "redux-thunk",
@@ -396,6 +397,7 @@ export const sharedViteConfig = {
396
397
  exclude: [
397
398
  "react",
398
399
  "react-dom",
400
+ "react-router",
399
401
  "react-router-dom",
400
402
  "@tata1mg/router",
401
403
  // "@tata1mg/slowoi-react",
@@ -427,8 +429,15 @@ export const sharedViteConfig = {
427
429
  resolve: {
428
430
  alias: alias(),
429
431
  // Ensure only one copy of React-related packages is used (prevents
430
- // duplicate instances from hoisted/linked packages in monorepos)
431
- dedupe: ["react", "react-dom", "react-router-dom", "@tata1mg/slowboi-react"],
432
+ // duplicate instances from hoisted/linked packages in monorepos).
433
+ // NOTE: react-router deliberately excluded from dedupe. Consumer apps
434
+ // that still have an older react-router (e.g. v6, hoisted transitively
435
+ // through another dependency) at their own node_modules root would
436
+ // have that copy forced onto catalyst-core's v7 import too, silently
437
+ // resolving to the wrong package version (wrong export list, e.g.
438
+ // missing StaticRouter/Link) instead of an error. See tata1mg/1mg_web
439
+ // fix/react-router-v7-upgrade-staging for the confirmed repro.
440
+ dedupe: ["react", "react-dom", "react-router-dom"],
432
441
  },
433
442
  define: {
434
443
  ...getClientEnvVariables(),
@@ -3,7 +3,7 @@ import { HelmetProvider, Helmet } from "react-helmet-async"
3
3
  import { OneMgRouterContext } from "../context.jsx"
4
4
  import { useRouterData } from "./RouterDataProvider.jsx"
5
5
  import { deleteHeadTagsByDataAttribute, getMetaData } from "../utils/metaDataUtils.jsx"
6
- import { useLocation } from "react-router-dom"
6
+ import { useLocation } from "react-router"
7
7
 
8
8
  /**
9
9
  * @description renders meta tags component assigned to setMetaData
@@ -7,7 +7,7 @@ import {
7
7
  useSearchParams,
8
8
  UNSAFE_RouteContext,
9
9
  matchRoutes,
10
- } from "react-router-dom"
10
+ } from "react-router"
11
11
  import { OneMgRouterContext } from "../context.jsx"
12
12
  // import sanitizeHtml from "sanitize-html"
13
13
 
@@ -41,15 +41,15 @@ const INITIAL_DATA_STATE = {
41
41
  /**
42
42
  * @typedef RouterFetcherProps
43
43
  * @property {any} route route object
44
- * @property {import("react-router-dom").Location} location the current location object, which represents the current URL in web browsers.
45
- * @property {import("react-router-dom").Params} params object of key/value pairs of the dynamic params from the current URL that were matched by the route path.
44
+ * @property {import("react-router").Location} location the current location object, which represents the current URL in web browsers.
45
+ * @property {import("react-router").Params} params object of key/value pairs of the dynamic params from the current URL that were matched by the route path.
46
46
  * @property {URLSearchParams} searchParams search parameters via URLSearchParams interface.
47
- * @property {import("react-router-dom").NavigateFunction} navigate function to navigate to other pages based on response.
47
+ * @property {import("react-router").NavigateFunction} navigate function to navigate to other pages based on response.
48
48
  */
49
49
 
50
50
  /**
51
51
  * @typedef ServerFetchDataProps
52
- * @property {import("react-router-dom").RouteObject[]} routes routes Array
52
+ * @property {import("react-router").RouteObject[]} routes routes Array
53
53
  * @property {string} url current url
54
54
  * @property {import("express").Request} req Express request object
55
55
  */
@@ -139,7 +139,7 @@ const fetchRouteData = async (routerProps, fetcherArgs, refetchArgs) => {
139
139
  /**
140
140
  *
141
141
  * @param {RouteContextObject} routeContext route context object
142
- * @returns {import('react-router-dom').RouteMatch[]} Array of matched routes
142
+ * @returns {import('react-router').RouteMatch[]} Array of matched routes
143
143
  */
144
144
  const getMatchedRoutes = ({ matches, outlet }) => {
145
145
  if (outlet) {
@@ -150,7 +150,7 @@ const getMatchedRoutes = ({ matches, outlet }) => {
150
150
 
151
151
  /**
152
152
  * Generates route key for given route using pathname and query params
153
- * @param {import('react-router-dom').RouteMatch} match Router Match Object
153
+ * @param {import('react-router').RouteMatch} match Router Match Object
154
154
  * @param {string} searchParamsString Query params string
155
155
  * @returns {string} routerKey
156
156
  */
@@ -190,7 +190,7 @@ export const RouterDataProvider = ({ children, initialState, fetcherArgs = {}, c
190
190
 
191
191
  /**
192
192
  * @description HOF which returns a function to refetch the route data
193
- * @param {import("react-router-dom").RouteObject} route
193
+ * @param {import("react-router").RouteObject} route
194
194
  * @param {string} routeKey
195
195
  * @returns
196
196
  */
@@ -214,7 +214,7 @@ export const RouterDataProvider = ({ children, initialState, fetcherArgs = {}, c
214
214
 
215
215
  /**
216
216
  * @description HOF which returns a function to clear the route data immediately or after given time in ms
217
- * @param {import("react-router-dom").RouteObject} route
217
+ * @param {import("react-router").RouteObject} route
218
218
  * @param {string} routeKey
219
219
  * @returns
220
220
  */
@@ -235,7 +235,7 @@ export const RouterDataProvider = ({ children, initialState, fetcherArgs = {}, c
235
235
 
236
236
  /**
237
237
  * @description Check the config for refetching the data
238
- * @param {import('react-router-dom').RouteObject} route
238
+ * @param {import('react-router').RouteObject} route
239
239
  * @returns {boolean}
240
240
  */
241
241
  const shouldFetch = (route) => {
@@ -2,7 +2,7 @@ import { createContext } from "react"
2
2
 
3
3
  /**
4
4
  * @typedef oneMgRouterContext
5
- * @property {import("react-router-dom").RouteMatch<string, import("react-router-dom").RouteObject>[]=} matchedRoutes
5
+ * @property {import("react-router").RouteMatch<string, import("react-router").RouteObject>[]=} matchedRoutes
6
6
  */
7
7
 
8
8
  /**
@@ -1,4 +1,4 @@
1
- import { useNavigate, useLocation } from "react-router-dom"
1
+ import { useNavigate, useLocation } from "react-router"
2
2
 
3
3
  /**
4
4
  * @param {number} delay
@@ -47,11 +47,11 @@ export type RouterFetcherProps = {
47
47
  /**
48
48
  * the current location object, which represents the current URL in web browsers.
49
49
  */
50
- location: import("react-router-dom").Location
50
+ location: import("react-router").Location
51
51
  /**
52
52
  * object of key/value pairs of the dynamic params from the current URL that were matched by the route path.
53
53
  */
54
- params: import("react-router-dom").Params
54
+ params: import("react-router").Params
55
55
  /**
56
56
  * search parameters via URLSearchParams interface.
57
57
  */
@@ -59,13 +59,13 @@ export type RouterFetcherProps = {
59
59
  /**
60
60
  * function to navigate to other pages based on response.
61
61
  */
62
- navigate: import("react-router-dom").NavigateFunction
62
+ navigate: import("react-router").NavigateFunction
63
63
  }
64
64
  export type ServerFetchDataProps = {
65
65
  /**
66
66
  * routes Array
67
67
  */
68
- routes: import("react-router-dom").RouteObject[]
68
+ routes: import("react-router").RouteObject[]
69
69
  /**
70
70
  * current url
71
71
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @typedef oneMgRouterContext
3
- * @property {import("react-router-dom").RouteMatch<string, import("react-router-dom").RouteObject>[]=} matchedRoutes
3
+ * @property {import("react-router").RouteMatch<string, import("react-router").RouteObject>[]=} matchedRoutes
4
4
  */
5
5
  /**
6
6
  * @description This is internal context made for sharing data among router components
@@ -9,6 +9,6 @@
9
9
  export const OneMgRouterContext: import("react").Context<oneMgRouterContext>
10
10
  export type oneMgRouterContext = {
11
11
  matchedRoutes?:
12
- | import("react-router-dom").RouteMatch<string, import("react-router-dom").RouteObject>[]
12
+ | import("react-router").RouteMatch<string, import("react-router").RouteObject>[]
13
13
  | undefined
14
14
  }
@@ -1 +1 @@
1
- export function useNavigateWithTransition(): import("react-router-dom").NavigateFunction
1
+ export function useNavigateWithTransition(): import("react-router").NavigateFunction
@@ -1,3 +1,3 @@
1
- export * from "react-router-dom"
1
+ export * from "react-router"
2
2
  declare const _default: any
3
3
  export default _default
@@ -22,3 +22,19 @@ export function deleteHeadTagsByDataAttribute(attributeName: string, attributeVa
22
22
  * @returns {Array<JSX.Element>} - List of all meta tags for the matched location.
23
23
  */
24
24
  export function getMetaData(matchedRoutes: Array<Match>, routeData: Object): Array<JSX.Element>
25
+ /**
26
+ * Static function defined on a route component that returns metadata elements
27
+ * to be rendered in the document head for that route.
28
+ * Must return an array of JSX elements (e.g. <title>, <meta>), NOT a plain
29
+ * object. Returning an object fails silently: no error is thrown, but the
30
+ * tags will not appear in the rendered <head>.
31
+ *
32
+ * @param {any} fetcherData - Data returned from the route's fetcher (serverFetcher/clientFetcher).
33
+ * @returns {Array<JSX.Element>} - Array of JSX head elements (title, meta, link, etc).
34
+ *
35
+ * @example
36
+ * HomePage.setMetaData = (apiResponse) => [
37
+ * <title key="title">{apiResponse?.title || "Home"}</title>,
38
+ * ];
39
+ */
40
+ export type SetMetaData = (fetcherData: any) => Array<JSX.Element>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "catalyst-core",
3
- "version": "0.3.0-beta.4",
3
+ "version": "0.3.0-beta.5",
4
4
  "type": "module",
5
5
  "main": "./dist/index.jsx",
6
6
  "description": "Web framework that provides great performance out of the box",
@@ -50,7 +50,7 @@
50
50
  "react-helmet-async": "^1.3.0",
51
51
  "react-redux": "^9.2.0",
52
52
  "react-refresh": "^0.14.0",
53
- "react-router-dom": "^6.16.0",
53
+ "react-router": "^7.18.2",
54
54
  "redux": "^4.2.1",
55
55
  "sanitize-html": "^2.17.6",
56
56
  "sass": "^1.89.2",