@real-router/react 0.4.2 → 0.4.4

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/README.md CHANGED
@@ -30,8 +30,11 @@ import { createRoot } from "react-dom/client";
30
30
  // Define routes
31
31
  const routes = [
32
32
  { name: "home", path: "/" },
33
- { name: "users", path: "/users" },
34
- { name: "users.profile", path: "/:id" },
33
+ {
34
+ name: "users",
35
+ path: "/users",
36
+ children: [{ name: "profile", path: "/:id" }],
37
+ },
35
38
  ];
36
39
 
37
40
  // Create and configure router
@@ -70,6 +73,7 @@ createRoot(document.getElementById("root")!).render(
70
73
  ### Provider
71
74
 
72
75
  #### `<RouterProvider router={router}>`
76
+
73
77
  Provides router instance to component tree via React Context.\
74
78
  `router: Router` — router instance from `createRouter()`\
75
79
  `children: ReactNode` — child components\
@@ -86,6 +90,7 @@ Provides router instance to component tree via React Context.\
86
90
  ### Hooks
87
91
 
88
92
  #### `useRouter(): Router`
93
+
89
94
  Get router instance. **Never re-renders** on navigation.\
90
95
  Returns: `Router` — router instance\
91
96
  [Wiki](https://github.com/greydragon888/real-router/wiki/useRouter)
@@ -97,10 +102,11 @@ const NavigateButton = () => {
97
102
  const router = useRouter();
98
103
 
99
104
  return <button onClick={() => router.navigate("home")}>Go Home</button>;
100
- }
105
+ };
101
106
  ```
102
107
 
103
108
  #### `useRoute(): { router, route, previousRoute }`
109
+
104
110
  Get current route state. **Re-renders on every navigation.**\
105
111
  Returns: `{ router: Router, route: State | undefined, previousRoute: State | undefined }`\
106
112
  [Wiki](https://github.com/greydragon888/real-router/wiki/useRoute)
@@ -119,10 +125,11 @@ const CurrentRoute = () => {
119
125
  <button onClick={() => router.navigate("home")}>Go Home</button>
120
126
  </div>
121
127
  );
122
- }
128
+ };
123
129
  ```
124
130
 
125
131
  #### `useRouteNode(nodeName: string): { router, route, previousRoute }`
132
+
126
133
  Optimized hook for nested routes. **Re-renders only when specified node changes.**\
127
134
  `nodeName: string` — route segment to observe (e.g., `"users"`)
128
135
  Returns: `{ router: Router, route: State | undefined, previousRoute: State | undefined }`\
@@ -148,7 +155,7 @@ const UsersSection = () => {
148
155
  default:
149
156
  return null;
150
157
  }
151
- }
158
+ };
152
159
  ```
153
160
 
154
161
  ---
@@ -156,6 +163,7 @@ const UsersSection = () => {
156
163
  ### Components
157
164
 
158
165
  #### `<Link routeName={string} routeParams={object} ...props>`
166
+
159
167
  Navigation link with automatic active state detection.\
160
168
  `routeName: string` — target route name\
161
169
  `routeParams?: Params` — route parameters\
@@ -175,15 +183,17 @@ import { Link } from "@real-router/react";
175
183
  activeStrict={false}
176
184
  >
177
185
  View Profile
178
- </Link>
186
+ </Link>;
179
187
  ```
180
188
 
181
189
  #### `<ConnectedLink ...props>`
190
+
182
191
  Same as `Link`, but re-renders on every route change.\
183
192
  Props: same as `Link`\
184
193
  [Wiki](https://github.com/greydragon888/real-router/wiki/ConnectedLink)
185
194
 
186
195
  #### `<BaseLink router={router} ...props>`
196
+
187
197
  Low-level link component. Requires router instance as prop.\
188
198
  `router: Router` — router instance\
189
199
  Props: same as `Link`\
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- var e=require("react"),t=require("@real-router/helpers"),r=require("react/jsx-runtime"),o=require("@real-router/core"),u=Object.freeze({}),s=Object.freeze({});function n(t,r,o){const u=e.useRef(void 0),s=e.useRef(r),n=e.useRef(o);if(s.current=r,n.current=o,void 0===u.current){const e=t.getState(),r=!n.current||e&&n.current(e);u.current=s.current(r&&e?{route:e,previousRoute:void 0}:void 0)}const a=e.useCallback(()=>u.current,[]),i=e.useCallback(e=>t.subscribe(t=>{let r=!0;if(n.current&&(r=n.current(t.route,t.previousRoute)),!r)return;const o=s.current(t);Object.is(u.current,o)||(u.current=o,e())}),[t]);return e.useSyncExternalStore(i,a,a)}function a(t){const r=JSON.stringify(t);return e.useMemo(()=>t,[r])}var i=new WeakMap;var c=e.memo(({routeName:o,routeParams:i=u,routeOptions:c=s,className:l,activeClassName:v="active",activeStrict:d=!1,ignoreQueryParams:m=!0,onClick:p,target:R,router:f,children:g,...x})=>{const b=a(i),N=a(c),h=function(r,o,s=u,i=!1,c=!0){const l=a(s),v=e.useMemo(()=>function(e,t,r,o){return JSON.stringify({routeName:e,routeParams:t,activeStrict:r,ignoreQueryParams:o})}(o,l,i,c),[o,l,i,c]),d=e.useRef(void 0),m=e.useRef(void 0);m.current!==v&&(d.current=void 0,m.current=v);const p=e.useCallback((e,r)=>{const u=t.areRoutesRelated(o,e.name),s=r&&t.areRoutesRelated(o,r.name);return!(!u&&!s)},[o]),R=e.useCallback(e=>{const u=e?.route??r.getState();if(!u)return d.current=!1,!1;if(!t.areRoutesRelated(o,u.name))return d.current=!1,!1;const s=r.isActiveRoute(o,l,i,c);return d.current=s,s},[r,o,l,i,c]);return n(r,R,p)}(f,o,b,d,m),C=e.useMemo(()=>"function"==typeof f.buildUrl?f.buildUrl(o,b):f.buildPath(o,b),[f,o,b]),S=e.useCallback(e=>{p&&(p(e),e.defaultPrevented)||function(e){return!(0!==e.button||e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e)&&"_blank"!==R&&(e.preventDefault(),f.navigate(o,b,N).catch(()=>{}))},[p,R,f,o,b,N]),y=e.useMemo(()=>h&&v?l?`${l} ${v}`.trim():v:l??void 0,[h,l,v]),{previousRoute:P,...k}=x;return r.jsx("a",{...k,href:C,className:y,onClick:S,"data-route":o,"data-active":h,children:g})},(e,t)=>e.router===t.router&&e.routeName===t.routeName&&JSON.stringify(e.routeParams)===JSON.stringify(t.routeParams)&&JSON.stringify(e.routeOptions)===JSON.stringify(t.routeOptions)&&e.className===t.className&&e.activeClassName===t.activeClassName&&e.activeStrict===t.activeStrict&&e.ignoreQueryParams===t.ignoreQueryParams&&e.onClick===t.onClick&&e.target===t.target&&e.children===t.children);c.displayName="BaseLink";var l=e.createContext(null),v=e.createContext(null),d=e.createContext(null),m=()=>{const t=e.useContext(l);if(!t)throw new Error("useRoute must be used within a RouteProvider");return t},p=()=>{const t=e.useContext(v);if(!t)throw new Error("useRouter must be used within a RouterProvider");return t};exports.BaseLink=c,exports.ConnectedLink=e=>{const t=p(),{route:o}=m(),{routeOptions:u,...s}=e;return r.jsx(c,{router:t,route:o,...s})},exports.Link=e=>{const t=p(),{route:o,previousRoute:u,routeOptions:s,...n}=e;return r.jsx(c,{router:t,...n})},exports.NavigatorContext=d,exports.RouteContext=l,exports.RouterContext=v,exports.RouterProvider=({router:t,children:u})=>{const s=e.useMemo(()=>o.getNavigator(t),[t]),n=e.useMemo(()=>{let e={route:t.getState(),previousRoute:void 0};return{getSnapshot:()=>e,subscribe:r=>t.subscribe(({route:t,previousRoute:o})=>{e={route:t,previousRoute:o},r()})}},[t]),a=e.useSyncExternalStore(n.subscribe,n.getSnapshot),i=e.useMemo(()=>({navigator:s,...a}),[s,a]);return r.jsx(v.Provider,{value:t,children:r.jsx(d.Provider,{value:s,children:r.jsx(l.Provider,{value:i,children:u})})})},exports.useNavigator=()=>{const t=e.useContext(d);if(!t)throw new Error("useNavigator must be used within a RouterProvider");return t},exports.useRoute=m,exports.useRouteNode=function(t){const r=p(),u=e.useMemo(()=>function(e,t){let r=i.get(e);r||(r=new Map,i.set(e,r));let o=r.get(t);if(!o){o=e.shouldUpdateNode(t);const u=o;o=(e,t)=>u(e,t),r.set(t,o)}return o}(r,t),[r,t]),s=e.useCallback(e=>{const o=e?.route??r.getState();return o&&""!==t&&o.name!==t&&!o.name.startsWith(`${t}.`)?{route:void 0,previousRoute:e?.previousRoute}:{route:o,previousRoute:e?.previousRoute}},[r,t]),a=n(r,s,u),c=e.useMemo(()=>o.getNavigator(r),[r]);return e.useMemo(()=>({navigator:c,route:a.route,previousRoute:a.previousRoute}),[c,a.route,a.previousRoute])},exports.useRouter=p;//# sourceMappingURL=index.js.map
1
+ var e=require("react"),t=require("@real-router/helpers"),r=require("react/jsx-runtime"),u=require("@real-router/core"),o=Object.freeze({}),s=Object.freeze({});function n(t,r,u){const o=e.useRef(void 0),s=e.useRef(r),n=e.useRef(u);if(s.current=r,n.current=u,void 0===o.current){const e=t.getState(),r=!n.current||e&&n.current(e);o.current=s.current(r&&e?{route:e,previousRoute:void 0}:void 0)}const a=e.useCallback(()=>o.current,[]),i=e.useCallback(e=>t.subscribe(t=>{let r=!0;if(n.current&&(r=n.current(t.route,t.previousRoute)),!r)return;const u=s.current(t);Object.is(o.current,u)||(o.current=u,e())}),[t]);return e.useSyncExternalStore(i,a,a)}function a(t){const r=JSON.stringify(t);return e.useMemo(()=>t,[r])}var i=new WeakMap;var c=e.memo(({routeName:u,routeParams:i=o,routeOptions:c=s,className:l,activeClassName:v="active",activeStrict:m=!1,ignoreQueryParams:d=!0,onClick:p,target:R,router:f,children:g,...x})=>{const b=a(i),N=a(c),h=function(r,u,s=o,i=!1,c=!0){const l=a(s),v=e.useMemo(()=>function(e,t,r,u){return JSON.stringify({routeName:e,routeParams:t,activeStrict:r,ignoreQueryParams:u})}(u,l,i,c),[u,l,i,c]),m=e.useRef(void 0),d=e.useRef(void 0);d.current!==v&&(m.current=void 0,d.current=v);const p=e.useCallback((e,r)=>{const o=t.areRoutesRelated(u,e.name),s=r&&t.areRoutesRelated(u,r.name);return!(!o&&!s)},[u]),R=e.useCallback(e=>{const o=e?.route??r.getState();if(!o)return m.current=!1,!1;if(!t.areRoutesRelated(u,o.name))return m.current=!1,!1;const s=r.isActiveRoute(u,l,i,c);return m.current=s,s},[r,u,l,i,c]);return n(r,R,p)}(f,u,b,m,d),C=e.useMemo(()=>"function"==typeof f.buildUrl?f.buildUrl(u,b):f.buildPath(u,b),[f,u,b]),S=e.useCallback(e=>{p&&(p(e),e.defaultPrevented)||function(e){return!(0!==e.button||e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e)&&"_blank"!==R&&(e.preventDefault(),f.navigate(u,b,N).catch(()=>{}))},[p,R,f,u,b,N]),y=e.useMemo(()=>h&&v?l?`${l} ${v}`.trim():v:l??void 0,[h,l,v]),{previousRoute:k,...O}=x;return r.jsx("a",{...O,href:C,className:y,onClick:S,"data-route":u,"data-active":h,children:g})},(e,t)=>e.router===t.router&&e.routeName===t.routeName&&JSON.stringify(e.routeParams)===JSON.stringify(t.routeParams)&&JSON.stringify(e.routeOptions)===JSON.stringify(t.routeOptions)&&e.className===t.className&&e.activeClassName===t.activeClassName&&e.activeStrict===t.activeStrict&&e.ignoreQueryParams===t.ignoreQueryParams&&e.onClick===t.onClick&&e.target===t.target&&e.children===t.children);c.displayName="BaseLink";var l=e.createContext(null),v=e.createContext(null),m=e.createContext(null),d=()=>{const t=e.use(v);if(!t)throw new Error("useRouter must be used within a RouterProvider");return t},p=()=>{const t=e.use(l);if(!t)throw new Error("useRoute must be used within a RouteProvider");return t};exports.BaseLink=c,exports.ConnectedLink=e=>{const t=d(),{route:u}=p(),{routeOptions:o,...s}=e;return r.jsx(c,{router:t,route:u,...s})},exports.Link=e=>{const t=d(),{route:u,previousRoute:o,routeOptions:s,...n}=e;return r.jsx(c,{router:t,...n})},exports.NavigatorContext=m,exports.RouteContext=l,exports.RouterContext=v,exports.RouterProvider=({router:t,children:o})=>{const s=e.useMemo(()=>u.getNavigator(t),[t]),n=e.useMemo(()=>{let e={route:t.getState(),previousRoute:void 0};return{getSnapshot:()=>e,subscribe:r=>t.subscribe(({route:t,previousRoute:u})=>{e={route:t,previousRoute:u},r()})}},[t]),a=e.useSyncExternalStore(n.subscribe,n.getSnapshot),i=e.useMemo(()=>({navigator:s,...a}),[s,a]);return r.jsx(v,{value:t,children:r.jsx(m,{value:s,children:r.jsx(l,{value:i,children:o})})})},exports.useNavigator=()=>{const t=e.use(m);if(!t)throw new Error("useNavigator must be used within a RouterProvider");return t},exports.useRoute=p,exports.useRouteNode=function(t){const r=d(),o=e.useMemo(()=>function(e,t){let r=i.get(e);r||(r=new Map,i.set(e,r));let u=r.get(t);if(!u){u=e.shouldUpdateNode(t);const o=u;u=(e,t)=>o(e,t),r.set(t,u)}return u}(r,t),[r,t]),s=e.useCallback(e=>{const u=e?.route??r.getState();return u&&""!==t&&u.name!==t&&!u.name.startsWith(`${t}.`)?{route:void 0,previousRoute:e?.previousRoute}:{route:u,previousRoute:e?.previousRoute}},[r,t]),a=n(r,s,o),c=e.useMemo(()=>u.getNavigator(r),[r]);return e.useMemo(()=>({navigator:c,route:a.route,previousRoute:a.previousRoute}),[c,a.route,a.previousRoute])},exports.useRouter=d;//# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/constants.ts","../../src/hooks/useRouterSubscription.tsx","../../src/hooks/useStableValue.tsx","../../src/utils.ts","../../src/hooks/useIsActiveRoute.tsx","../../src/components/BaseLink.tsx","../../src/components/Link.tsx","../../src/components/ConnectedLink.tsx","../../src/hooks/useRouteNode.tsx","../../src/context.ts","../../src/hooks/useRoute.tsx","../../src/hooks/useNavigator.tsx","../../src/RouterProvider.tsx","../../src/hooks/useRouter.tsx"],"names":["useRef","useCallback","useSyncExternalStore","useMemo","areRoutesRelated","memo","jsx","getNavigator","createContext","useContext"],"mappings":";;;AAKO,IAAM,YAAA,GAAe,MAAA,CAAO,MAAA,CAAO,EAAE,CAAA;AAKrC,IAAM,aAAA,GAAgB,MAAA,CAAO,MAAA,CAAO,EAAE,CAAA;ACGtC,SAAS,qBAAA,CACd,MAAA,EACA,QAAA,EACA,YAAA,EACG;AAEH,EAAA,MAAM,QAAA,GAAWA,aAAsB,MAAS,CAAA;AAChD,EAAA,MAAM,WAAA,GAAcA,aAAO,QAAQ,CAAA;AACnC,EAAA,MAAM,eAAA,GAAkBA,aAAO,YAAY,CAAA;AAG3C,EAAA,WAAA,CAAY,OAAA,GAAU,QAAA;AACtB,EAAA,eAAA,CAAgB,OAAA,GAAU,YAAA;AAG1B,EAAA,IAAI,QAAA,CAAS,YAAY,MAAA,EAAW;AAElC,IAAA,MAAM,YAAA,GAAe,OAAO,QAAA,EAAS;AAGrC,IAAA,MAAM,mBACJ,CAAC,eAAA,CAAgB,WAChB,YAAA,IAAgB,eAAA,CAAg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EAAE,aAAa,SAAA,EAAU;AAAA,EAClC,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AAGX,EAAA,MAAM,KAAA,GAAQD,0BAAAA,CAAqB,KAAA,CAAM,SAAA,EAAW,MAAM,WAAW,CAAA;AAGrE,EAAA,MAAM,iBAAA,GAAoBC,aAAAA;AAAA,IACxB,OAAO,EAAE,SAAA,EAAW,GAAG,KAAA,EAAM,CAAA;AAAA,IAC7B,CAAC,WAAW,KAAK;AAAA,GACnB;AAEA,EAAA,uBACEG,eAAC,aAAA,CAAc,QAAA,EAAd,EAAuB,KAAA,EAAO,MAAA,EAC7B,QAAA,kBAAAA,cAAAA,CAAC,gBAAA,CAAiB,QAAA,EAAjB,EAA0B,KAAA,EAAO,SAAA,EAChC,QAAA,kBAAAA,cAAAA,CAAC,YAAA,CAAa,QAAA,EAAb,EAAsB,KAAA,EAAO,iBAAA,EAC3B,QAAA,EACH,CAAA,EACF,CAAA,EACF,CAAA;AAEJ;ACzDO,IAAM,YAAY,MAAc;AACrC,EAAA,MAAM,MAAA,GAASG,iBAAW,aAAa,CAAA;AAEvC,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,IAAI,MAAM,gDAAgD,CAAA;AAAA,EAClE;AAEA,EAAA,OAAO,MAAA;AACT","file":"index.js","sourcesContent":["// packages/react/modules/constants.ts\n\n/**\n * Stable empty object for default params\n */\nexport const EMPTY_PARAMS = Object.freeze({});\n\n/**\n * Stable empty options object\n */\nexport const EMPTY_OPTIONS = Object.freeze({});\n","// packages/react/modules/hooks/useRouterSubscription.tsx\n\nimport { useCallback, useRef, useSyncExternalStore } from \"react\";\n\nimport type { Router, State, SubscribeState } from \"@real-router/core\";\n\n/**\n * Generic hook for subscribing to router changes with optimization.\n *\n * @param router - Real Router instance\n * @param selector - Function to derive state from router subscription\n * @param shouldUpdate - Optional predicate to filter updates\n */\nexport function useRouterSubscription<T>(\n router: Router,\n selector: (sub?: SubscribeState) => T,\n shouldUpdate?: (newRoute: State, prevRoute?: State) => boolean,\n): T {\n // Store current value\n const stateRef = useRef<T | undefined>(undefined);\n const selectorRef = useRef(selector);\n const shouldUpdateRef = useRef(shouldUpdate);\n\n // Update refs to avoid stale closures\n selectorRef.current = selector;\n shouldUpdateRef.current = shouldUpdate;\n\n // Lazy initialization\n if (stateRef.current === undefined) {\n // Get initial state from router\n const currentState = router.getState();\n\n // Check if initial state is relevant for this subscription\n const shouldInitialize =\n !shouldUpdateRef.current ||\n (currentState && shouldUpdateRef.current(currentState));\n\n stateRef.current = selectorRef.current(\n shouldInitialize && currentState\n ? { route: currentState, previousRoute: undefined }\n : undefined,\n );\n }\n\n // Stable snapshot getter\n const getSnapshot = useCallback(() => stateRef.current as T, []);\n\n // Subscribe function with optimization\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n return router.subscribe((next) => {\n // Check if we should process this update\n let shouldProcess = true;\n\n if (shouldUpdateRef.current) {\n shouldProcess = shouldUpdateRef.current(\n next.route,\n next.previousRoute,\n );\n }\n\n if (!shouldProcess) {\n return;\n }\n\n // Calculate new value\n const newValue = selectorRef.current(next);\n\n // Only trigger update if value actually changed\n if (!Object.is(stateRef.current, newValue)) {\n stateRef.current = newValue;\n\n onStoreChange();\n }\n });\n },\n [router],\n );\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","// packages/react/modules/hooks/useStableValue.tsx\n\nimport { useMemo } from \"react\";\n\n/**\n * Stabilizes a value reference based on deep equality (via JSON serialization).\n * Returns the same reference until the serialized value changes.\n *\n * Useful for object/array dependencies in hooks like useMemo, useCallback, useEffect\n * to prevent unnecessary re-renders when the value is structurally the same.\n *\n * @example\n * ```tsx\n * const stableParams = useStableValue(routeParams);\n * const href = useMemo(() => {\n * return router.buildUrl(routeName, stableParams);\n * }, [router, routeName, stableParams]);\n * ```\n *\n * @param value - The value to stabilize\n * @returns A stable reference to the value\n */\nexport function useStableValue<T>(value: T): T {\n const serialized = JSON.stringify(value);\n\n // We intentionally use serialized in deps to detect deep changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => value, [serialized]);\n}\n","// packages/react/modules/utils.ts\n\nimport type { Params, Router, State } from \"@real-router/core\";\nimport type { MouseEvent } from \"react\";\n\n/**\n * Cache for shouldUpdateNode functions to avoid recreating them\n */\nexport const shouldUpdateCache = new WeakMap<\n Router,\n Map<string, (toState: State, fromState?: State) => boolean>\n>();\n\n/**\n * Get cached shouldUpdateNode function for a router and nodeName\n */\nexport function getCachedShouldUpdate(\n router: Router,\n nodeName: string,\n): (toState: State, fromState?: State) => boolean {\n let cache = shouldUpdateCache.get(router);\n\n if (!cache) {\n cache = new Map();\n shouldUpdateCache.set(router, cache);\n }\n\n let fn = cache.get(nodeName);\n\n if (!fn) {\n fn = router.shouldUpdateNode(nodeName);\n\n const originalFn = fn;\n\n fn = (toState: State, fromState?: State) => originalFn(toState, fromState);\n\n cache.set(nodeName, fn);\n }\n\n return fn;\n}\n\n/**\n * Check if navigation should be handled by router\n */\nexport function shouldNavigate(evt: MouseEvent): boolean {\n return (\n evt.button === 0 && // left click\n !evt.metaKey &&\n !evt.altKey &&\n !evt.ctrlKey &&\n !evt.shiftKey\n );\n}\n\n/**\n * Create cache key for route active check\n */\nexport function createActiveCheckKey(\n routeName: string,\n routeParams: Params,\n activeStrict: boolean,\n ignoreQueryParams: boolean,\n): string {\n return JSON.stringify({\n routeName,\n routeParams,\n activeStrict,\n ignoreQueryParams,\n });\n}\n","// packages/react/modules/hooks/useIsActiveRoute.tsx\n\nimport { areRoutesRelated } from \"@real-router/helpers\";\nimport { useCallback, useMemo, useRef } from \"react\";\n\nimport { useRouterSubscription } from \"./useRouterSubscription\";\nimport { useStableValue } from \"./useStableValue\";\nimport { EMPTY_PARAMS } from \"../constants\";\nimport { createActiveCheckKey } from \"../utils\";\n\nimport type { Params, Router, State, SubscribeState } from \"@real-router/core\";\n\n/**\n * Optimized hook to check if a route is active.\n * Minimizes unnecessary recalculations and re-renders.\n */\nexport function useIsActiveRoute(\n router: Router,\n routeName: string,\n routeParams: Params = EMPTY_PARAMS,\n activeStrict = false,\n ignoreQueryParams = true,\n): boolean {\n // Stabilize params reference to prevent unnecessary recalculations\n const stableParams = useStableValue(routeParams);\n\n // Create stable cache key\n const cacheKey = useMemo(\n () =>\n createActiveCheckKey(\n routeName,\n stableParams,\n activeStrict,\n ignoreQueryParams,\n ),\n [routeName, stableParams, activeStrict, ignoreQueryParams],\n );\n\n // Cache the active state\n const isActiveRef = useRef<boolean | undefined>(undefined);\n const lastCacheKey = useRef<string | undefined>(undefined);\n\n if (lastCacheKey.current !== cacheKey) {\n isActiveRef.current = undefined;\n lastCacheKey.current = cacheKey;\n }\n\n // Optimize shouldUpdate to skip unrelated routes\n const shouldUpdate = useCallback(\n (newRoute: State, prevRoute?: State) => {\n const isNewRelated = areRoutesRelated(routeName, newRoute.name);\n const isPrevRelated =\n prevRoute && areRoutesRelated(routeName, prevRoute.name);\n\n return !!(isNewRelated || isPrevRelated);\n },\n [routeName],\n );\n\n // Selector that performs active check\n const selector = useCallback(\n (sub?: SubscribeState): boolean => {\n const currentRoute = sub?.route ?? router.getState();\n\n // Fast path: if no current route, not active\n if (!currentRoute) {\n isActiveRef.current = false;\n\n return false;\n }\n\n // Fast path: skip unrelated routes\n if (!areRoutesRelated(routeName, currentRoute.name)) {\n isActiveRef.current = false;\n\n return false;\n }\n\n // Full check for related routes\n const isActive = router.isActiveRoute(\n routeName,\n stableParams,\n activeStrict,\n ignoreQueryParams,\n );\n\n isActiveRef.current = isActive;\n\n return isActive;\n },\n [router, routeName, stableParams, activeStrict, ignoreQueryParams],\n );\n\n return useRouterSubscription(router, selector, shouldUpdate);\n}\n","// packages/react/modules/components/BaseLink.tsx\n\nimport { memo, useCallback, useMemo } from \"react\";\n\nimport { EMPTY_PARAMS, EMPTY_OPTIONS } from \"../constants\";\nimport { useIsActiveRoute } from \"../hooks/useIsActiveRoute\";\nimport { useStableValue } from \"../hooks/useStableValue\";\nimport { shouldNavigate } from \"../utils\";\n\nimport type { BaseLinkProps } from \"../types\";\nimport type { FC, MouseEvent } from \"react\";\n\n/**\n * Optimized BaseLink component with memoization and performance improvements\n */\nexport const BaseLink: FC<BaseLinkProps> = memo(\n ({\n routeName,\n routeParams = EMPTY_PARAMS,\n routeOptions = EMPTY_OPTIONS,\n className,\n activeClassName = \"active\",\n activeStrict = false,\n ignoreQueryParams = true,\n onClick,\n target,\n router,\n children,\n ...props\n }) => {\n // Stabilize object references to prevent unnecessary re-renders\n const stableParams = useStableValue(routeParams);\n const stableOptions = useStableValue(routeOptions);\n\n // Use optimized hook for active state checking\n const isActive = useIsActiveRoute(\n router,\n routeName,\n stableParams,\n activeStrict,\n ignoreQueryParams,\n );\n\n // Build URL with memoization\n const href = useMemo(() => {\n // Use buildUrl if available (browser plugin installed)\n // Otherwise fall back to buildPath (e.g., in SSR or without browser plugin)\n if (typeof router.buildUrl === \"function\") {\n return router.buildUrl(routeName, stableParams);\n }\n\n return router.buildPath(routeName, stableParams);\n }, [router, routeName, stableParams]);\n\n // Optimized click handler\n const handleClick = useCallback(\n (evt: MouseEvent<HTMLAnchorElement>) => {\n // Call custom onClick if provided\n if (onClick) {\n onClick(evt);\n // Respect preventDefault from custom handler\n if (evt.defaultPrevented) {\n return;\n }\n }\n\n // Check if we should handle navigation\n if (!shouldNavigate(evt) || target === \"_blank\") {\n return;\n }\n\n // Prevent default link behavior\n evt.preventDefault();\n\n // Perform navigation (fire-and-forget)\n router.navigate(routeName, stableParams, stableOptions).catch(() => {});\n },\n [onClick, target, router, routeName, stableParams, stableOptions],\n );\n\n // Build className efficiently\n const finalClassName = useMemo(() => {\n if (isActive && activeClassName) {\n return className\n ? `${className} ${activeClassName}`.trim()\n : activeClassName;\n }\n\n return className ?? undefined;\n }, [isActive, className, activeClassName]);\n\n // Filter out previousRoute from props\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { previousRoute, ...restProps } = props;\n\n return (\n <a\n {...restProps}\n href={href}\n className={finalClassName}\n onClick={handleClick}\n data-route={routeName} // For event delegation if needed\n data-active={isActive} // For CSS selectors if needed\n >\n {children}\n </a>\n );\n },\n (prevProps, nextProps) => {\n // Custom comparison for better memoization\n // Check if props that affect rendering have changed\n return (\n prevProps.router === nextProps.router &&\n prevProps.routeName === nextProps.routeName &&\n JSON.stringify(prevProps.routeParams) ===\n JSON.stringify(nextProps.routeParams) &&\n JSON.stringify(prevProps.routeOptions) ===\n JSON.stringify(nextProps.routeOptions) &&\n prevProps.className === nextProps.className &&\n prevProps.activeClassName === nextProps.activeClassName &&\n prevProps.activeStrict === nextProps.activeStrict &&\n prevProps.ignoreQueryParams === nextProps.ignoreQueryParams &&\n prevProps.onClick === nextProps.onClick &&\n prevProps.target === nextProps.target &&\n prevProps.children === nextProps.children\n );\n },\n);\n\nBaseLink.displayName = \"BaseLink\";\n","// packages/react/modules/components/Link.tsx\n\nimport { useRouter } from \"@real-router/react\";\n\nimport { BaseLink } from \"./BaseLink\";\n\nimport type { BaseLinkProps } from \"./interfaces\";\nimport type { FC } from \"react\";\n\nexport const Link: FC<Omit<BaseLinkProps, \"router\">> = (props) => {\n const router = useRouter();\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { route, previousRoute, routeOptions, ...linkProps } = props;\n\n return <BaseLink router={router} {...linkProps} />;\n};\n","// packages/react/modules/components/ConnectedLink.tsx\n\nimport { useRoute, useRouter } from \"@real-router/react\";\n\nimport { BaseLink } from \"./BaseLink\";\n\nimport type { BaseLinkProps } from \"./interfaces\";\nimport type { FC } from \"react\";\n\nexport const ConnectedLink: FC<\n Omit<BaseLinkProps, \"router\" | \"route\" | \"previousRoute\">\n> = (props) => {\n const router = useRouter();\n const { route } = useRoute();\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { routeOptions, ...linkProps } = props;\n\n return <BaseLink router={router} route={route} {...linkProps} />;\n};\n","// packages/react/modules/hooks/useRouteNode.tsx\n\nimport { getNavigator } from \"@real-router/core\";\nimport { useCallback, useMemo } from \"react\";\n\nimport { useRouter } from \"@real-router/react\";\n\nimport { useRouterSubscription } from \"./useRouterSubscription\";\nimport { getCachedShouldUpdate } from \"../utils\";\n\nimport type { RouteContext, RouteState } from \"../types\";\nimport type { State, SubscribeState } from \"@real-router/core\";\n\n/**\n * Hook that subscribes to a specific route node with optimizations.\n * Provides the current and previous route when the node is affected.\n */\nexport function useRouteNode(nodeName: string): RouteContext {\n // Get router from context with error handling\n const router = useRouter();\n\n // Get cached shouldUpdate function to avoid recreation\n const shouldUpdate = useMemo(\n () => getCachedShouldUpdate(router, nodeName),\n [router, nodeName],\n );\n\n // Stable state factory\n // useRouteNode.tsx\n const stateFactory = useCallback(\n (sub?: SubscribeState): RouteState => {\n const currentRoute = sub?.route ?? router.getState();\n\n // Проверяем, активен ли узел\n if (currentRoute && nodeName !== \"\") {\n // Корневой узел всегда активен\n const isNodeActive =\n currentRoute.name === nodeName ||\n currentRoute.name.startsWith(`${nodeName}.`);\n\n if (!isNodeActive) {\n return {\n route: undefined,\n previousRoute: sub?.previousRoute,\n };\n }\n }\n\n return {\n route: currentRoute,\n previousRoute: sub?.previousRoute,\n };\n },\n [router, nodeName],\n );\n\n // Subscribe to router with optimization\n const state = useRouterSubscription<RouteState>(\n router,\n stateFactory,\n shouldUpdate as (newRoute: State, prevRoute?: State) => boolean,\n );\n\n // Return memoized context - useMemo ensures stable reference when deps unchanged\n const navigator = useMemo(() => getNavigator(router), [router]);\n\n return useMemo(\n (): RouteContext => ({\n navigator,\n route: state.route,\n previousRoute: state.previousRoute,\n }),\n [navigator, state.route, state.previousRoute],\n );\n}\n","// packages/react/modules/context.ts\n\nimport { createContext } from \"react\";\n\nimport type { RouteContext as RouteContextType } from \"./types\";\nimport type { Router, Navigator } from \"@real-router/core\";\n\nexport const RouteContext = createContext<RouteContextType | null>(null);\n\nexport const RouterContext = createContext<Router | null>(null);\n\nexport const NavigatorContext = createContext<Navigator | null>(null);\n","// packages/react/modules/hooks/useRoute.tsx\n\nimport { useContext } from \"react\";\n\nimport { RouteContext } from \"../context\";\n\nimport type { RouteContext as RouteContextType } from \"../types\";\n\nexport const useRoute = (): RouteContextType => {\n const routeContext = useContext(RouteContext);\n\n if (!routeContext) {\n throw new Error(\"useRoute must be used within a RouteProvider\");\n }\n\n return routeContext;\n};\n","// packages/react/modules/hooks/useNavigator.tsx\n\nimport { useContext } from \"react\";\n\nimport { NavigatorContext } from \"../context\";\n\nimport type { Navigator } from \"@real-router/core\";\n\nexport const useNavigator = (): Navigator => {\n const navigator = useContext(NavigatorContext);\n\n if (!navigator) {\n throw new Error(\"useNavigator must be used within a RouterProvider\");\n }\n\n return navigator;\n};\n","// packages/react/modules/RouterProvider.tsx\n\nimport { getNavigator } from \"@real-router/core\";\nimport { useMemo, useSyncExternalStore } from \"react\";\n\nimport { NavigatorContext, RouteContext, RouterContext } from \"./context\";\n\nimport type { RouteState } from \"./types\";\nimport type { Router } from \"@real-router/core\";\nimport type { FC, ReactNode } from \"react\";\n\nexport interface RouteProviderProps {\n router: Router;\n children: ReactNode;\n}\n\nexport const RouterProvider: FC<RouteProviderProps> = ({\n router,\n children,\n}) => {\n // Get navigator instance from router\n const navigator = useMemo(() => getNavigator(router), [router]);\n\n // Local store state to hold route information\n const store = useMemo(() => {\n let currentState: RouteState = {\n route: router.getState(),\n previousRoute: undefined,\n };\n\n // This will be called to return the current state snapshot\n const getSnapshot = () => currentState;\n\n // Subscribe to router updates and notify React when state changes\n const subscribe = (callback: () => void) => {\n const unsubscribe = router.subscribe(({ route, previousRoute }) => {\n currentState = { route, previousRoute };\n callback(); // Notify React to trigger re-render\n });\n\n // Note: router.subscribe() always returns a function, no need to check\n return unsubscribe;\n };\n\n return { getSnapshot, subscribe };\n }, [router]);\n\n // Using useSyncExternalStore to manage subscription and state updates\n const state = useSyncExternalStore(store.subscribe, store.getSnapshot);\n\n // Memoize RouteContext value to prevent unnecessary re-renders\n const routeContextValue = useMemo(\n () => ({ navigator, ...state }),\n [navigator, state],\n );\n\n return (\n <RouterContext.Provider value={router}>\n <NavigatorContext.Provider value={navigator}>\n <RouteContext.Provider value={routeContextValue}>\n {children}\n </RouteContext.Provider>\n </NavigatorContext.Provider>\n </RouterContext.Provider>\n );\n};\n","// packages/react/modules/hooks/useRouter.tsx\n\nimport { useContext } from \"react\";\n\nimport { RouterContext } from \"../context\";\n\nimport type { Router } from \"@real-router/core\";\n\nexport const useRouter = (): Router => {\n const router = useContext(RouterContext);\n\n if (!router) {\n throw new Error(\"useRouter must be used within a RouterProvider\");\n }\n\n return router;\n};\n"]}
1
+ {"version":3,"sources":["../../src/constants.ts","../../src/hooks/useRouterSubscription.tsx","../../src/hooks/useStableValue.tsx","../../src/utils.ts","../../src/hooks/useIsActiveRoute.tsx","../../src/components/BaseLink.tsx","../../src/context.ts","../../src/hooks/useRouter.tsx","../../src/components/Link.tsx","../../src/hooks/useRoute.tsx","../../src/components/ConnectedLink.tsx","../../src/hooks/useRouteNode.tsx","../../src/hooks/useNavigator.tsx","../../src/RouterProvider.tsx"],"names":["useRef","useCallback","useSyncExternalStore","useMemo","areRoutesRelated","memo","jsx","createContext","use","getNavigator"],"mappings":";;;AAKO,IAAM,YAAA,GAAe,MAAA,CAAO,MAAA,CAAO,EAAE,CAAA;AAKrC,IAAM,aAAA,GAAgB,MAAA,CAAO,MAAA,CAAO,EAAE,CAAA;ACGtC,SAAS,qBAAA,CACd,MAAA,EACA,QAAA,EACA,YAAA,EACG;AAEH,EAAA,MAAM,QAAA,GAAWA,aAAsB,MAAS,CAAA;AAChD,EAAA,MAAM,WAAA,GAAcA,aAAO,QAAQ,CAAA;AACnC,EAAA,MAAM,eAAA,GAAkBA,aAAO,YAAY,CAAA;AAG3C,EAAA,WAAA,CAAY,OAAA,GAAU,QAAA;AACtB,EAAA,eAAA,CAAgB,OAAA,GAAU,YAAA;AAG1B,EAAA,IAAI,QAAA,CAAS,YAAY,MAAA,EAAW;AAElC,IAAA,MAAM,YAAA,GAAe,OAAO,QAAA,EAAS;AAGrC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AY,CAAC,QAAA,KAAyB;AAC1C,MAAA,MAAM,cAAc,MAAA,CAAO,SAAA,CAAU,CAAC,EAAE,KAAA,EAAO,eAAc,KAAM;AACjE,QAAA,YAAA,GAAe,EAAE,OAAO,aAAA,EAAc;AACtC,QAAA,QAAA,EAAS;AAAA,MACX,CAAC,CAAA;AAGD,MAAA,OAAO,WAAA;AAAA,IACT,CAAA;AAEA,IAAA,OAAO,EAAE,aAAa,SAAA,EAAU;AAAA,EAClC,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AAGX,EAAA,MAAM,KAAA,GAAQD,0BAAAA,CAAqB,KAAA,CAAM,SAAA,EAAW,MAAM,WAAW,CAAA;AAGrE,EAAA,MAAM,iBAAA,GAAoBC,aAAAA;AAAA,IACxB,OAAO,EAAE,SAAA,EAAW,GAAG,KAAA,EAAM,CAAA;AAAA,IAC7B,CAAC,WAAW,KAAK;AAAA,GACnB;AAEA,EAAA,uBACEG,cAAAA,CAAC,aAAA,EAAA,EAAc,KAAA,EAAO,MAAA,EACpB,0BAAAA,cAAAA,CAAC,gBAAA,EAAA,EAAiB,KAAA,EAAO,SAAA,EACvB,0BAAAA,cAAAA,CAAC,YAAA,EAAA,EAAa,OAAO,iBAAA,EAAoB,QAAA,EAAS,GACpD,CAAA,EACF,CAAA;AAEJ","file":"index.js","sourcesContent":["// packages/react/modules/constants.ts\n\n/**\n * Stable empty object for default params\n */\nexport const EMPTY_PARAMS = Object.freeze({});\n\n/**\n * Stable empty options object\n */\nexport const EMPTY_OPTIONS = Object.freeze({});\n","// packages/react/modules/hooks/useRouterSubscription.tsx\n\nimport { useCallback, useRef, useSyncExternalStore } from \"react\";\n\nimport type { Router, State, SubscribeState } from \"@real-router/core\";\n\n/**\n * Generic hook for subscribing to router changes with optimization.\n *\n * @param router - Real Router instance\n * @param selector - Function to derive state from router subscription\n * @param shouldUpdate - Optional predicate to filter updates\n */\nexport function useRouterSubscription<T>(\n router: Router,\n selector: (sub?: SubscribeState) => T,\n shouldUpdate?: (newRoute: State, prevRoute?: State) => boolean,\n): T {\n // Store current value\n const stateRef = useRef<T | undefined>(undefined);\n const selectorRef = useRef(selector);\n const shouldUpdateRef = useRef(shouldUpdate);\n\n // Update refs to avoid stale closures\n selectorRef.current = selector;\n shouldUpdateRef.current = shouldUpdate;\n\n // Lazy initialization\n if (stateRef.current === undefined) {\n // Get initial state from router\n const currentState = router.getState();\n\n // Check if initial state is relevant for this subscription\n const shouldInitialize =\n !shouldUpdateRef.current ||\n (currentState && shouldUpdateRef.current(currentState));\n\n stateRef.current = selectorRef.current(\n shouldInitialize && currentState\n ? { route: currentState, previousRoute: undefined }\n : undefined,\n );\n }\n\n // Stable snapshot getter\n const getSnapshot = useCallback(() => stateRef.current as T, []);\n\n // Subscribe function with optimization\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n return router.subscribe((next) => {\n // Check if we should process this update\n let shouldProcess = true;\n\n if (shouldUpdateRef.current) {\n shouldProcess = shouldUpdateRef.current(\n next.route,\n next.previousRoute,\n );\n }\n\n if (!shouldProcess) {\n return;\n }\n\n // Calculate new value\n const newValue = selectorRef.current(next);\n\n // Only trigger update if value actually changed\n if (!Object.is(stateRef.current, newValue)) {\n stateRef.current = newValue;\n\n onStoreChange();\n }\n });\n },\n [router],\n );\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","// packages/react/modules/hooks/useStableValue.tsx\n\nimport { useMemo } from \"react\";\n\n/**\n * Stabilizes a value reference based on deep equality (via JSON serialization).\n * Returns the same reference until the serialized value changes.\n *\n * Useful for object/array dependencies in hooks like useMemo, useCallback, useEffect\n * to prevent unnecessary re-renders when the value is structurally the same.\n *\n * @example\n * ```tsx\n * const stableParams = useStableValue(routeParams);\n * const href = useMemo(() => {\n * return router.buildUrl(routeName, stableParams);\n * }, [router, routeName, stableParams]);\n * ```\n *\n * @param value - The value to stabilize\n * @returns A stable reference to the value\n */\nexport function useStableValue<T>(value: T): T {\n const serialized = JSON.stringify(value);\n\n // We intentionally use serialized in deps to detect deep changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => value, [serialized]);\n}\n","// packages/react/modules/utils.ts\n\nimport type { Params, Router, State } from \"@real-router/core\";\nimport type { MouseEvent } from \"react\";\n\n/**\n * Cache for shouldUpdateNode functions to avoid recreating them\n */\nexport const shouldUpdateCache = new WeakMap<\n Router,\n Map<string, (toState: State, fromState?: State) => boolean>\n>();\n\n/**\n * Get cached shouldUpdateNode function for a router and nodeName\n */\nexport function getCachedShouldUpdate(\n router: Router,\n nodeName: string,\n): (toState: State, fromState?: State) => boolean {\n let cache = shouldUpdateCache.get(router);\n\n if (!cache) {\n cache = new Map();\n shouldUpdateCache.set(router, cache);\n }\n\n let fn = cache.get(nodeName);\n\n if (!fn) {\n fn = router.shouldUpdateNode(nodeName);\n\n const originalFn = fn;\n\n fn = (toState: State, fromState?: State) => originalFn(toState, fromState);\n\n cache.set(nodeName, fn);\n }\n\n return fn;\n}\n\n/**\n * Check if navigation should be handled by router\n */\nexport function shouldNavigate(evt: MouseEvent): boolean {\n return (\n evt.button === 0 && // left click\n !evt.metaKey &&\n !evt.altKey &&\n !evt.ctrlKey &&\n !evt.shiftKey\n );\n}\n\n/**\n * Create cache key for route active check\n */\nexport function createActiveCheckKey(\n routeName: string,\n routeParams: Params,\n activeStrict: boolean,\n ignoreQueryParams: boolean,\n): string {\n return JSON.stringify({\n routeName,\n routeParams,\n activeStrict,\n ignoreQueryParams,\n });\n}\n","// packages/react/modules/hooks/useIsActiveRoute.tsx\n\nimport { areRoutesRelated } from \"@real-router/helpers\";\nimport { useCallback, useMemo, useRef } from \"react\";\n\nimport { useRouterSubscription } from \"./useRouterSubscription\";\nimport { useStableValue } from \"./useStableValue\";\nimport { EMPTY_PARAMS } from \"../constants\";\nimport { createActiveCheckKey } from \"../utils\";\n\nimport type { Params, Router, State, SubscribeState } from \"@real-router/core\";\n\n/**\n * Optimized hook to check if a route is active.\n * Minimizes unnecessary recalculations and re-renders.\n */\nexport function useIsActiveRoute(\n router: Router,\n routeName: string,\n routeParams: Params = EMPTY_PARAMS,\n activeStrict = false,\n ignoreQueryParams = true,\n): boolean {\n // Stabilize params reference to prevent unnecessary recalculations\n const stableParams = useStableValue(routeParams);\n\n // Create stable cache key\n const cacheKey = useMemo(\n () =>\n createActiveCheckKey(\n routeName,\n stableParams,\n activeStrict,\n ignoreQueryParams,\n ),\n [routeName, stableParams, activeStrict, ignoreQueryParams],\n );\n\n // Cache the active state\n const isActiveRef = useRef<boolean | undefined>(undefined);\n const lastCacheKeyRef = useRef<string | undefined>(undefined);\n\n if (lastCacheKeyRef.current !== cacheKey) {\n isActiveRef.current = undefined;\n lastCacheKeyRef.current = cacheKey;\n }\n\n // Optimize shouldUpdate to skip unrelated routes\n const shouldUpdate = useCallback(\n (newRoute: State, prevRoute?: State) => {\n const isNewRelated = areRoutesRelated(routeName, newRoute.name);\n const isPrevRelated =\n prevRoute && areRoutesRelated(routeName, prevRoute.name);\n\n return !!(isNewRelated || isPrevRelated);\n },\n [routeName],\n );\n\n // Selector that performs active check\n const selector = useCallback(\n (sub?: SubscribeState): boolean => {\n const currentRoute = sub?.route ?? router.getState();\n\n // Fast path: if no current route, not active\n if (!currentRoute) {\n isActiveRef.current = false;\n\n return false;\n }\n\n // Fast path: skip unrelated routes\n if (!areRoutesRelated(routeName, currentRoute.name)) {\n isActiveRef.current = false;\n\n return false;\n }\n\n // Full check for related routes\n const isActive = router.isActiveRoute(\n routeName,\n stableParams,\n activeStrict,\n ignoreQueryParams,\n );\n\n isActiveRef.current = isActive;\n\n return isActive;\n },\n [router, routeName, stableParams, activeStrict, ignoreQueryParams],\n );\n\n return useRouterSubscription(router, selector, shouldUpdate);\n}\n","// packages/react/modules/components/BaseLink.tsx\n\nimport { memo, useCallback, useMemo } from \"react\";\n\nimport { EMPTY_PARAMS, EMPTY_OPTIONS } from \"../constants\";\nimport { useIsActiveRoute } from \"../hooks/useIsActiveRoute\";\nimport { useStableValue } from \"../hooks/useStableValue\";\nimport { shouldNavigate } from \"../utils\";\n\nimport type { BaseLinkProps } from \"../types\";\nimport type { FC, MouseEvent } from \"react\";\n\n/**\n * Optimized BaseLink component with memoization and performance improvements\n */\nexport const BaseLink: FC<BaseLinkProps> = memo(\n ({\n routeName,\n routeParams = EMPTY_PARAMS,\n routeOptions = EMPTY_OPTIONS,\n className,\n activeClassName = \"active\",\n activeStrict = false,\n ignoreQueryParams = true,\n onClick,\n target,\n router,\n children,\n ...props\n }) => {\n // Stabilize object references to prevent unnecessary re-renders\n const stableParams = useStableValue(routeParams);\n const stableOptions = useStableValue(routeOptions);\n\n // Use optimized hook for active state checking\n const isActive = useIsActiveRoute(\n router,\n routeName,\n stableParams,\n activeStrict,\n ignoreQueryParams,\n );\n\n // Build URL with memoization\n const href = useMemo(() => {\n // Use buildUrl if available (browser plugin installed)\n // Otherwise fall back to buildPath (e.g., in SSR or without browser plugin)\n if (typeof router.buildUrl === \"function\") {\n return router.buildUrl(routeName, stableParams);\n }\n\n return router.buildPath(routeName, stableParams);\n }, [router, routeName, stableParams]);\n\n // Optimized click handler\n const handleClick = useCallback(\n (evt: MouseEvent<HTMLAnchorElement>) => {\n // Call custom onClick if provided\n if (onClick) {\n onClick(evt);\n // Respect preventDefault from custom handler\n if (evt.defaultPrevented) {\n return;\n }\n }\n\n // Check if we should handle navigation\n if (!shouldNavigate(evt) || target === \"_blank\") {\n return;\n }\n\n // Prevent default link behavior\n evt.preventDefault();\n\n // Perform navigation (fire-and-forget)\n router.navigate(routeName, stableParams, stableOptions).catch(() => {});\n },\n [onClick, target, router, routeName, stableParams, stableOptions],\n );\n\n // Build className efficiently\n const finalClassName = useMemo(() => {\n if (isActive && activeClassName) {\n return className\n ? `${className} ${activeClassName}`.trim()\n : activeClassName;\n }\n\n return className ?? undefined;\n }, [isActive, className, activeClassName]);\n\n // Filter out previousRoute from props\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { previousRoute, ...restProps } = props;\n\n return (\n <a\n {...restProps}\n href={href}\n className={finalClassName}\n onClick={handleClick}\n data-route={routeName} // For event delegation if needed\n data-active={isActive} // For CSS selectors if needed\n >\n {children}\n </a>\n );\n },\n (prevProps, nextProps) => {\n // Custom comparison for better memoization\n // Check if props that affect rendering have changed\n return (\n prevProps.router === nextProps.router &&\n prevProps.routeName === nextProps.routeName &&\n JSON.stringify(prevProps.routeParams) ===\n JSON.stringify(nextProps.routeParams) &&\n JSON.stringify(prevProps.routeOptions) ===\n JSON.stringify(nextProps.routeOptions) &&\n prevProps.className === nextProps.className &&\n prevProps.activeClassName === nextProps.activeClassName &&\n prevProps.activeStrict === nextProps.activeStrict &&\n prevProps.ignoreQueryParams === nextProps.ignoreQueryParams &&\n prevProps.onClick === nextProps.onClick &&\n prevProps.target === nextProps.target &&\n prevProps.children === nextProps.children\n );\n },\n);\n\nBaseLink.displayName = \"BaseLink\";\n","// packages/react/modules/context.ts\n\nimport { createContext } from \"react\";\n\nimport type { RouteContext as RouteContextType } from \"./types\";\nimport type { Router, Navigator } from \"@real-router/core\";\n\nexport const RouteContext = createContext<RouteContextType | null>(null);\n\nexport const RouterContext = createContext<Router | null>(null);\n\nexport const NavigatorContext = createContext<Navigator | null>(null);\n","// packages/react/modules/hooks/useRouter.tsx\n\nimport { use } from \"react\";\n\nimport { RouterContext } from \"../context\";\n\nimport type { Router } from \"@real-router/core\";\n\nexport const useRouter = (): Router => {\n const router = use(RouterContext);\n\n if (!router) {\n throw new Error(\"useRouter must be used within a RouterProvider\");\n }\n\n return router;\n};\n","// packages/react/modules/components/Link.tsx\n\nimport { BaseLink } from \"./BaseLink\";\nimport { useRouter } from \"../hooks/useRouter\";\n\nimport type { BaseLinkProps } from \"./interfaces\";\nimport type { FC } from \"react\";\n\nexport const Link: FC<Omit<BaseLinkProps, \"router\">> = (props) => {\n const router = useRouter();\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { route, previousRoute, routeOptions, ...linkProps } = props;\n\n return <BaseLink router={router} {...linkProps} />;\n};\n","// packages/react/modules/hooks/useRoute.tsx\n\nimport { use } from \"react\";\n\nimport { RouteContext } from \"../context\";\n\nimport type { RouteContext as RouteContextType } from \"../types\";\n\nexport const useRoute = (): RouteContextType => {\n const routeContext = use(RouteContext);\n\n if (!routeContext) {\n throw new Error(\"useRoute must be used within a RouteProvider\");\n }\n\n return routeContext;\n};\n","// packages/react/modules/components/ConnectedLink.tsx\n\nimport { BaseLink } from \"./BaseLink\";\nimport { useRoute } from \"../hooks/useRoute\";\nimport { useRouter } from \"../hooks/useRouter\";\n\nimport type { BaseLinkProps } from \"./interfaces\";\nimport type { FC } from \"react\";\n\nexport const ConnectedLink: FC<\n Omit<BaseLinkProps, \"router\" | \"route\" | \"previousRoute\">\n> = (props) => {\n const router = useRouter();\n const { route } = useRoute();\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { routeOptions, ...linkProps } = props;\n\n return <BaseLink router={router} route={route} {...linkProps} />;\n};\n","// packages/react/modules/hooks/useRouteNode.tsx\n\nimport { getNavigator } from \"@real-router/core\";\nimport { useCallback, useMemo } from \"react\";\n\nimport { useRouter } from \"./useRouter\";\nimport { useRouterSubscription } from \"./useRouterSubscription\";\nimport { getCachedShouldUpdate } from \"../utils\";\n\nimport type { RouteContext, RouteState } from \"../types\";\nimport type { State, SubscribeState } from \"@real-router/core\";\n\n/**\n * Hook that subscribes to a specific route node with optimizations.\n * Provides the current and previous route when the node is affected.\n */\nexport function useRouteNode(nodeName: string): RouteContext {\n // Get router from context with error handling\n const router = useRouter();\n\n // Get cached shouldUpdate function to avoid recreation\n const shouldUpdate = useMemo(\n () => getCachedShouldUpdate(router, nodeName),\n [router, nodeName],\n );\n\n // Stable state factory\n // useRouteNode.tsx\n const stateFactory = useCallback(\n (sub?: SubscribeState): RouteState => {\n const currentRoute = sub?.route ?? router.getState();\n\n // Проверяем, активен ли узел\n if (currentRoute && nodeName !== \"\") {\n // Корневой узел всегда активен\n const isNodeActive =\n currentRoute.name === nodeName ||\n currentRoute.name.startsWith(`${nodeName}.`);\n\n if (!isNodeActive) {\n return {\n route: undefined,\n previousRoute: sub?.previousRoute,\n };\n }\n }\n\n return {\n route: currentRoute,\n previousRoute: sub?.previousRoute,\n };\n },\n [router, nodeName],\n );\n\n // Subscribe to router with optimization\n const state = useRouterSubscription<RouteState>(\n router,\n stateFactory,\n shouldUpdate as (newRoute: State, prevRoute?: State) => boolean,\n );\n\n // Return memoized context - useMemo ensures stable reference when deps unchanged\n const navigator = useMemo(() => getNavigator(router), [router]);\n\n return useMemo(\n (): RouteContext => ({\n navigator,\n route: state.route,\n previousRoute: state.previousRoute,\n }),\n [navigator, state.route, state.previousRoute],\n );\n}\n","// packages/react/modules/hooks/useNavigator.tsx\n\nimport { use } from \"react\";\n\nimport { NavigatorContext } from \"../context\";\n\nimport type { Navigator } from \"@real-router/core\";\n\nexport const useNavigator = (): Navigator => {\n const navigator = use(NavigatorContext);\n\n if (!navigator) {\n throw new Error(\"useNavigator must be used within a RouterProvider\");\n }\n\n return navigator;\n};\n","// packages/react/modules/RouterProvider.tsx\n\nimport { getNavigator } from \"@real-router/core\";\nimport { useMemo, useSyncExternalStore } from \"react\";\n\nimport { NavigatorContext, RouteContext, RouterContext } from \"./context\";\n\nimport type { RouteState } from \"./types\";\nimport type { Router } from \"@real-router/core\";\nimport type { FC, ReactNode } from \"react\";\n\nexport interface RouteProviderProps {\n router: Router;\n children: ReactNode;\n}\n\nexport const RouterProvider: FC<RouteProviderProps> = ({\n router,\n children,\n}) => {\n // Get navigator instance from router\n const navigator = useMemo(() => getNavigator(router), [router]);\n\n // Local store state to hold route information\n const store = useMemo(() => {\n let currentState: RouteState = {\n route: router.getState(),\n previousRoute: undefined,\n };\n\n // This will be called to return the current state snapshot\n const getSnapshot = () => currentState;\n\n // Subscribe to router updates and notify React when state changes\n const subscribe = (callback: () => void) => {\n const unsubscribe = router.subscribe(({ route, previousRoute }) => {\n currentState = { route, previousRoute };\n callback(); // Notify React to trigger re-render\n });\n\n // Note: router.subscribe() always returns a function, no need to check\n return unsubscribe;\n };\n\n return { getSnapshot, subscribe };\n }, [router]);\n\n // Using useSyncExternalStore to manage subscription and state updates\n const state = useSyncExternalStore(store.subscribe, store.getSnapshot);\n\n // Memoize RouteContext value to prevent unnecessary re-renders\n const routeContextValue = useMemo(\n () => ({ navigator, ...state }),\n [navigator, state],\n );\n\n return (\n <RouterContext value={router}>\n <NavigatorContext value={navigator}>\n <RouteContext value={routeContextValue}>{children}</RouteContext>\n </NavigatorContext>\n </RouterContext>\n );\n};\n"]}
@@ -1 +1 @@
1
- {"inputs":{"../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js":{"bytes":569,"imports":[],"format":"esm"},"src/constants.ts":{"bytes":225,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useRouterSubscription.tsx":{"bytes":2370,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useStableValue.tsx":{"bytes":976,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/utils.ts":{"bytes":1483,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useIsActiveRoute.tsx":{"bytes":2679,"imports":[{"path":"@real-router/helpers","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/hooks/useRouterSubscription.tsx","kind":"import-statement","original":"./useRouterSubscription"},{"path":"src/hooks/useStableValue.tsx","kind":"import-statement","original":"./useStableValue"},{"path":"src/constants.ts","kind":"import-statement","original":"../constants"},{"path":"src/utils.ts","kind":"import-statement","original":"../utils"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/components/BaseLink.tsx":{"bytes":4067,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"../constants"},{"path":"src/hooks/useIsActiveRoute.tsx","kind":"import-statement","original":"../hooks/useIsActiveRoute"},{"path":"src/hooks/useStableValue.tsx","kind":"import-statement","original":"../hooks/useStableValue"},{"path":"src/utils.ts","kind":"import-statement","original":"../utils"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/components/Link.tsx":{"bytes":512,"imports":[{"path":"src/index.ts","kind":"import-statement","original":"@real-router/react"},{"path":"src/components/BaseLink.tsx","kind":"import-statement","original":"./BaseLink"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/components/ConnectedLink.tsx":{"bytes":596,"imports":[{"path":"src/index.ts","kind":"import-statement","original":"@real-router/react"},{"path":"src/components/BaseLink.tsx","kind":"import-statement","original":"./BaseLink"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useRouteNode.tsx":{"bytes":2220,"imports":[{"path":"@real-router/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/index.ts","kind":"import-statement","original":"@real-router/react"},{"path":"src/hooks/useRouterSubscription.tsx","kind":"import-statement","original":"./useRouterSubscription"},{"path":"src/utils.ts","kind":"import-statement","original":"../utils"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/context.ts":{"bytes":416,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useRoute.tsx":{"bytes":417,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/context.ts","kind":"import-statement","original":"../context"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useNavigator.tsx":{"bytes":408,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/context.ts","kind":"import-statement","original":"../context"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/RouterProvider.tsx":{"bytes":2032,"imports":[{"path":"@real-router/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/context.ts","kind":"import-statement","original":"./context"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useRouter.tsx":{"bytes":378,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/context.ts","kind":"import-statement","original":"../context"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":663,"imports":[{"path":"src/components/BaseLink.tsx","kind":"import-statement","original":"./components/BaseLink"},{"path":"src/components/Link.tsx","kind":"import-statement","original":"./components/Link"},{"path":"src/components/ConnectedLink.tsx","kind":"import-statement","original":"./components/ConnectedLink"},{"path":"src/hooks/useRouteNode.tsx","kind":"import-statement","original":"./hooks/useRouteNode"},{"path":"src/hooks/useRoute.tsx","kind":"import-statement","original":"./hooks/useRoute"},{"path":"src/hooks/useNavigator.tsx","kind":"import-statement","original":"./hooks/useNavigator"},{"path":"src/RouterProvider.tsx","kind":"import-statement","original":"./RouterProvider"},{"path":"src/context.ts","kind":"import-statement","original":"./context"},{"path":"src/hooks/useRouter.tsx","kind":"import-statement","original":"./hooks/useRouter"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/cjs/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":27471},"dist/cjs/index.js":{"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@real-router/helpers","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"@real-router/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@real-router/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"exports":["BaseLink","ConnectedLink","Link","NavigatorContext","RouteContext","RouterContext","RouterProvider","useNavigator","useRoute","useRouteNode","useRouter"],"entryPoint":"src/index.ts","inputs":{"src/components/BaseLink.tsx":{"bytesInOutput":2638},"src/constants.ts":{"bytesInOutput":77},"src/hooks/useIsActiveRoute.tsx":{"bytesInOutput":1723},"src/hooks/useRouterSubscription.tsx":{"bytesInOutput":1386},"src/hooks/useStableValue.tsx":{"bytesInOutput":157},"src/utils.ts":{"bytesInOutput":816},"src/index.ts":{"bytesInOutput":0},"src/components/Link.tsx":{"bytesInOutput":243},"src/components/ConnectedLink.tsx":{"bytesInOutput":269},"src/hooks/useRouteNode.tsx":{"bytesInOutput":1188},"src/hooks/useRoute.tsx":{"bytesInOutput":230},"src/context.ts":{"bytesInOutput":164},"src/hooks/useNavigator.tsx":{"bytesInOutput":250},"src/RouterProvider.tsx":{"bytesInOutput":1210},"src/hooks/useRouter.tsx":{"bytesInOutput":232}},"bytes":11258}}}
1
+ {"inputs":{"../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js":{"bytes":569,"imports":[],"format":"esm"},"src/constants.ts":{"bytes":225,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useRouterSubscription.tsx":{"bytes":2370,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useStableValue.tsx":{"bytes":976,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/utils.ts":{"bytes":1483,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useIsActiveRoute.tsx":{"bytes":2688,"imports":[{"path":"@real-router/helpers","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/hooks/useRouterSubscription.tsx","kind":"import-statement","original":"./useRouterSubscription"},{"path":"src/hooks/useStableValue.tsx","kind":"import-statement","original":"./useStableValue"},{"path":"src/constants.ts","kind":"import-statement","original":"../constants"},{"path":"src/utils.ts","kind":"import-statement","original":"../utils"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/components/BaseLink.tsx":{"bytes":4067,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"../constants"},{"path":"src/hooks/useIsActiveRoute.tsx","kind":"import-statement","original":"../hooks/useIsActiveRoute"},{"path":"src/hooks/useStableValue.tsx","kind":"import-statement","original":"../hooks/useStableValue"},{"path":"src/utils.ts","kind":"import-statement","original":"../utils"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/context.ts":{"bytes":416,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useRouter.tsx":{"bytes":364,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/context.ts","kind":"import-statement","original":"../context"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/components/Link.tsx":{"bytes":511,"imports":[{"path":"src/components/BaseLink.tsx","kind":"import-statement","original":"./BaseLink"},{"path":"src/hooks/useRouter.tsx","kind":"import-statement","original":"../hooks/useRouter"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useRoute.tsx":{"bytes":403,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/context.ts","kind":"import-statement","original":"../context"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/components/ConnectedLink.tsx":{"bytes":631,"imports":[{"path":"src/components/BaseLink.tsx","kind":"import-statement","original":"./BaseLink"},{"path":"src/hooks/useRoute.tsx","kind":"import-statement","original":"../hooks/useRoute"},{"path":"src/hooks/useRouter.tsx","kind":"import-statement","original":"../hooks/useRouter"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useRouteNode.tsx":{"bytes":2212,"imports":[{"path":"@real-router/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/hooks/useRouter.tsx","kind":"import-statement","original":"./useRouter"},{"path":"src/hooks/useRouterSubscription.tsx","kind":"import-statement","original":"./useRouterSubscription"},{"path":"src/utils.ts","kind":"import-statement","original":"../utils"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useNavigator.tsx":{"bytes":394,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/context.ts","kind":"import-statement","original":"../context"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/RouterProvider.tsx":{"bytes":1958,"imports":[{"path":"@real-router/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/context.ts","kind":"import-statement","original":"./context"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":663,"imports":[{"path":"src/components/BaseLink.tsx","kind":"import-statement","original":"./components/BaseLink"},{"path":"src/components/Link.tsx","kind":"import-statement","original":"./components/Link"},{"path":"src/components/ConnectedLink.tsx","kind":"import-statement","original":"./components/ConnectedLink"},{"path":"src/hooks/useRouteNode.tsx","kind":"import-statement","original":"./hooks/useRouteNode"},{"path":"src/hooks/useRoute.tsx","kind":"import-statement","original":"./hooks/useRoute"},{"path":"src/hooks/useNavigator.tsx","kind":"import-statement","original":"./hooks/useNavigator"},{"path":"src/RouterProvider.tsx","kind":"import-statement","original":"./RouterProvider"},{"path":"src/context.ts","kind":"import-statement","original":"./context"},{"path":"src/hooks/useRouter.tsx","kind":"import-statement","original":"./hooks/useRouter"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/cjs/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":27326},"dist/cjs/index.js":{"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@real-router/helpers","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"@real-router/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@real-router/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"exports":["BaseLink","ConnectedLink","Link","NavigatorContext","RouteContext","RouterContext","RouterProvider","useNavigator","useRoute","useRouteNode","useRouter"],"entryPoint":"src/index.ts","inputs":{"src/components/BaseLink.tsx":{"bytesInOutput":2638},"src/constants.ts":{"bytesInOutput":77},"src/hooks/useIsActiveRoute.tsx":{"bytesInOutput":1732},"src/hooks/useRouterSubscription.tsx":{"bytesInOutput":1386},"src/hooks/useStableValue.tsx":{"bytesInOutput":157},"src/utils.ts":{"bytesInOutput":816},"src/index.ts":{"bytesInOutput":0},"src/hooks/useRouter.tsx":{"bytesInOutput":202},"src/context.ts":{"bytesInOutput":164},"src/components/Link.tsx":{"bytesInOutput":243},"src/hooks/useRoute.tsx":{"bytesInOutput":225},"src/components/ConnectedLink.tsx":{"bytesInOutput":269},"src/hooks/useRouteNode.tsx":{"bytesInOutput":1188},"src/hooks/useNavigator.tsx":{"bytesInOutput":229},"src/RouterProvider.tsx":{"bytesInOutput":1183}},"bytes":11185}}}
@@ -1 +1 @@
1
- import{memo as r,useMemo as e,useCallback as t,createContext as o,useRef as u,useSyncExternalStore as n,useContext as i}from"react";import{areRoutesRelated as a}from"@real-router/helpers";import{jsx as s}from"react/jsx-runtime";import{getNavigator as c}from"@real-router/core";var v=Object.freeze({}),l=Object.freeze({});function m(r,e,o){const i=u(void 0),a=u(e),s=u(o);if(a.current=e,s.current=o,void 0===i.current){const e=r.getState(),t=!s.current||e&&s.current(e);i.current=a.current(t&&e?{route:e,previousRoute:void 0}:void 0)}const c=t(()=>i.current,[]),v=t(e=>r.subscribe(r=>{let t=!0;if(s.current&&(t=s.current(r.route,r.previousRoute)),!t)return;const o=a.current(r);Object.is(i.current,o)||(i.current=o,e())}),[r]);return n(v,c,c)}function d(r){const t=JSON.stringify(r);return e(()=>r,[t])}var f=new WeakMap;var p=r(({routeName:r,routeParams:o=v,routeOptions:n=l,className:i,activeClassName:c="active",activeStrict:f=!1,ignoreQueryParams:p=!0,onClick:g,target:h,router:N,children:R,...b})=>{const y=d(o),P=d(n),S=function(r,o,n=v,i=!1,s=!0){const c=d(n),l=e(()=>function(r,e,t,o){return JSON.stringify({routeName:r,routeParams:e,activeStrict:t,ignoreQueryParams:o})}(o,c,i,s),[o,c,i,s]),f=u(void 0),p=u(void 0);p.current!==l&&(f.current=void 0,p.current=l);const g=t((r,e)=>{const t=a(o,r.name),u=e&&a(o,e.name);return!(!t&&!u)},[o]),h=t(e=>{const t=e?.route??r.getState();if(!t)return f.current=!1,!1;if(!a(o,t.name))return f.current=!1,!1;const u=r.isActiveRoute(o,c,i,s);return f.current=u,u},[r,o,c,i,s]);return m(r,h,g)}(N,r,y,f,p),O=e(()=>"function"==typeof N.buildUrl?N.buildUrl(r,y):N.buildPath(r,y),[N,r,y]),w=t(e=>{g&&(g(e),e.defaultPrevented)||function(r){return!(0!==r.button||r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}(e)&&"_blank"!==h&&(e.preventDefault(),N.navigate(r,y,P).catch(()=>{}))},[g,h,N,r,y,P]),k=e(()=>S&&c?i?`${i} ${c}`.trim():c:i??void 0,[S,i,c]),{previousRoute:C,...J}=b;return s("a",{...J,href:O,className:k,onClick:w,"data-route":r,"data-active":S,children:R})},(r,e)=>r.router===e.router&&r.routeName===e.routeName&&JSON.stringify(r.routeParams)===JSON.stringify(e.routeParams)&&JSON.stringify(r.routeOptions)===JSON.stringify(e.routeOptions)&&r.className===e.className&&r.activeClassName===e.activeClassName&&r.activeStrict===e.activeStrict&&r.ignoreQueryParams===e.ignoreQueryParams&&r.onClick===e.onClick&&r.target===e.target&&r.children===e.children);p.displayName="BaseLink";var g=r=>{const e=w(),{route:t,previousRoute:o,routeOptions:u,...n}=r;return s(p,{router:e,...n})},h=r=>{const e=w(),{route:t}=P(),{routeOptions:o,...u}=r;return s(p,{router:e,route:t,...u})};function N(r){const o=w(),u=e(()=>function(r,e){let t=f.get(r);t||(t=new Map,f.set(r,t));let o=t.get(e);if(!o){o=r.shouldUpdateNode(e);const u=o;o=(r,e)=>u(r,e),t.set(e,o)}return o}(o,r),[o,r]),n=t(e=>{const t=e?.route??o.getState();return t&&""!==r&&t.name!==r&&!t.name.startsWith(`${r}.`)?{route:void 0,previousRoute:e?.previousRoute}:{route:t,previousRoute:e?.previousRoute}},[o,r]),i=m(o,n,u),a=e(()=>c(o),[o]);return e(()=>({navigator:a,route:i.route,previousRoute:i.previousRoute}),[a,i.route,i.previousRoute])}var R=o(null),b=o(null),y=o(null),P=()=>{const r=i(R);if(!r)throw new Error("useRoute must be used within a RouteProvider");return r},S=()=>{const r=i(y);if(!r)throw new Error("useNavigator must be used within a RouterProvider");return r},O=({router:r,children:t})=>{const o=e(()=>c(r),[r]),u=e(()=>{let e={route:r.getState(),previousRoute:void 0};return{getSnapshot:()=>e,subscribe:t=>r.subscribe(({route:r,previousRoute:o})=>{e={route:r,previousRoute:o},t()})}},[r]),i=n(u.subscribe,u.getSnapshot),a=e(()=>({navigator:o,...i}),[o,i]);return s(b.Provider,{value:r,children:s(y.Provider,{value:o,children:s(R.Provider,{value:a,children:t})})})},w=()=>{const r=i(b);if(!r)throw new Error("useRouter must be used within a RouterProvider");return r};export{p as BaseLink,h as ConnectedLink,g as Link,y as NavigatorContext,R as RouteContext,b as RouterContext,O as RouterProvider,S as useNavigator,P as useRoute,N as useRouteNode,w as useRouter};//# sourceMappingURL=index.mjs.map
1
+ import{memo as e,useMemo as r,useCallback as t,createContext as o,useRef as u,useSyncExternalStore as n,use as i}from"react";import{areRoutesRelated as a}from"@real-router/helpers";import{jsx as s}from"react/jsx-runtime";import{getNavigator as c}from"@real-router/core";var v=Object.freeze({}),l=Object.freeze({});function m(e,r,o){const i=u(void 0),a=u(r),s=u(o);if(a.current=r,s.current=o,void 0===i.current){const r=e.getState(),t=!s.current||r&&s.current(r);i.current=a.current(t&&r?{route:r,previousRoute:void 0}:void 0)}const c=t(()=>i.current,[]),v=t(r=>e.subscribe(e=>{let t=!0;if(s.current&&(t=s.current(e.route,e.previousRoute)),!t)return;const o=a.current(e);Object.is(i.current,o)||(i.current=o,r())}),[e]);return n(v,c,c)}function d(e){const t=JSON.stringify(e);return r(()=>e,[t])}var f=new WeakMap;var p=e(({routeName:e,routeParams:o=v,routeOptions:n=l,className:i,activeClassName:c="active",activeStrict:f=!1,ignoreQueryParams:p=!0,onClick:g,target:h,router:N,children:R,...b})=>{const y=d(o),S=d(n),O=function(e,o,n=v,i=!1,s=!0){const c=d(n),l=r(()=>function(e,r,t,o){return JSON.stringify({routeName:e,routeParams:r,activeStrict:t,ignoreQueryParams:o})}(o,c,i,s),[o,c,i,s]),f=u(void 0),p=u(void 0);p.current!==l&&(f.current=void 0,p.current=l);const g=t((e,r)=>{const t=a(o,e.name),u=r&&a(o,r.name);return!(!t&&!u)},[o]),h=t(r=>{const t=r?.route??e.getState();if(!t)return f.current=!1,!1;if(!a(o,t.name))return f.current=!1,!1;const u=e.isActiveRoute(o,c,i,s);return f.current=u,u},[e,o,c,i,s]);return m(e,h,g)}(N,e,y,f,p),P=r(()=>"function"==typeof N.buildUrl?N.buildUrl(e,y):N.buildPath(e,y),[N,e,y]),w=t(r=>{g&&(g(r),r.defaultPrevented)||function(e){return!(0!==e.button||e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(r)&&"_blank"!==h&&(r.preventDefault(),N.navigate(e,y,S).catch(()=>{}))},[g,h,N,e,y,S]),k=r(()=>O&&c?i?`${i} ${c}`.trim():c:i??void 0,[O,i,c]),{previousRoute:C,...J}=b;return s("a",{...J,href:P,className:k,onClick:w,"data-route":e,"data-active":O,children:R})},(e,r)=>e.router===r.router&&e.routeName===r.routeName&&JSON.stringify(e.routeParams)===JSON.stringify(r.routeParams)&&JSON.stringify(e.routeOptions)===JSON.stringify(r.routeOptions)&&e.className===r.className&&e.activeClassName===r.activeClassName&&e.activeStrict===r.activeStrict&&e.ignoreQueryParams===r.ignoreQueryParams&&e.onClick===r.onClick&&e.target===r.target&&e.children===r.children);p.displayName="BaseLink";var g=o(null),h=o(null),N=o(null),R=()=>{const e=i(h);if(!e)throw new Error("useRouter must be used within a RouterProvider");return e},b=e=>{const r=R(),{route:t,previousRoute:o,routeOptions:u,...n}=e;return s(p,{router:r,...n})},y=()=>{const e=i(g);if(!e)throw new Error("useRoute must be used within a RouteProvider");return e},S=e=>{const r=R(),{route:t}=y(),{routeOptions:o,...u}=e;return s(p,{router:r,route:t,...u})};function O(e){const o=R(),u=r(()=>function(e,r){let t=f.get(e);t||(t=new Map,f.set(e,t));let o=t.get(r);if(!o){o=e.shouldUpdateNode(r);const u=o;o=(e,r)=>u(e,r),t.set(r,o)}return o}(o,e),[o,e]),n=t(r=>{const t=r?.route??o.getState();return t&&""!==e&&t.name!==e&&!t.name.startsWith(`${e}.`)?{route:void 0,previousRoute:r?.previousRoute}:{route:t,previousRoute:r?.previousRoute}},[o,e]),i=m(o,n,u),a=r(()=>c(o),[o]);return r(()=>({navigator:a,route:i.route,previousRoute:i.previousRoute}),[a,i.route,i.previousRoute])}var P=()=>{const e=i(N);if(!e)throw new Error("useNavigator must be used within a RouterProvider");return e},w=({router:e,children:t})=>{const o=r(()=>c(e),[e]),u=r(()=>{let r={route:e.getState(),previousRoute:void 0};return{getSnapshot:()=>r,subscribe:t=>e.subscribe(({route:e,previousRoute:o})=>{r={route:e,previousRoute:o},t()})}},[e]),i=n(u.subscribe,u.getSnapshot),a=r(()=>({navigator:o,...i}),[o,i]);return s(h,{value:e,children:s(N,{value:o,children:s(g,{value:a,children:t})})})};export{p as BaseLink,S as ConnectedLink,b as Link,N as NavigatorContext,g as RouteContext,h as RouterContext,w as RouterProvider,P as useNavigator,y as useRoute,O as useRouteNode,R as useRouter};//# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/constants.ts","../../src/hooks/useRouterSubscription.tsx","../../src/hooks/useStableValue.tsx","../../src/utils.ts","../../src/hooks/useIsActiveRoute.tsx","../../src/components/BaseLink.tsx","../../src/components/Link.tsx","../../src/components/ConnectedLink.tsx","../../src/hooks/useRouteNode.tsx","../../src/context.ts","../../src/hooks/useRoute.tsx","../../src/hooks/useNavigator.tsx","../../src/RouterProvider.tsx","../../src/hooks/useRouter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ACzDO,IAAM,YAAY,MAAc;AACrC,EAAA,MAAM,MAAA,GAASC,WAAW,aAAa,CAAA;AAEvC,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,IAAI,MAAM,gDAAgD,CAAA;AAAA,EAClE;AAEA,EAAA,OAAO,MAAA;AACT","file":"index.mjs","sourcesContent":["// packages/react/modules/constants.ts\n\n/**\n * Stable empty object for default params\n */\nexport const EMPTY_PARAMS = Object.freeze({});\n\n/**\n * Stable empty options object\n */\nexport const EMPTY_OPTIONS = Object.freeze({});\n","// packages/react/modules/hooks/useRouterSubscription.tsx\n\nimport { useCallback, useRef, useSyncExternalStore } from \"react\";\n\nimport type { Router, State, SubscribeState } from \"@real-router/core\";\n\n/**\n * Generic hook for subscribing to router changes with optimization.\n *\n * @param router - Real Router instance\n * @param selector - Function to derive state from router subscription\n * @param shouldUpdate - Optional predicate to filter updates\n */\nexport function useRouterSubscription<T>(\n router: Router,\n selector: (sub?: SubscribeState) => T,\n shouldUpdate?: (newRoute: State, prevRoute?: State) => boolean,\n): T {\n // Store current value\n const stateRef = useRef<T | undefined>(undefined);\n const selectorRef = useRef(selector);\n const shouldUpdateRef = useRef(shouldUpdate);\n\n // Update refs to avoid stale closures\n selectorRef.current = selector;\n shouldUpdateRef.current = shouldUpdate;\n\n // Lazy initialization\n if (stateRef.current === undefined) {\n // Get initial state from router\n const currentState = router.getState();\n\n // Check if initial state is relevant for this subscription\n const shouldInitialize =\n !shouldUpdateRef.current ||\n (currentState && shouldUpdateRef.current(currentState));\n\n stateRef.current = selectorRef.current(\n shouldInitialize && currentState\n ? { route: currentState, previousRoute: undefined }\n : undefined,\n );\n }\n\n // Stable snapshot getter\n const getSnapshot = useCallback(() => stateRef.current as T, []);\n\n // Subscribe function with optimization\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n return router.subscribe((next) => {\n // Check if we should process this update\n let shouldProcess = true;\n\n if (shouldUpdateRef.current) {\n shouldProcess = shouldUpdateRef.current(\n next.route,\n next.previousRoute,\n );\n }\n\n if (!shouldProcess) {\n return;\n }\n\n // Calculate new value\n const newValue = selectorRef.current(next);\n\n // Only trigger update if value actually changed\n if (!Object.is(stateRef.current, newValue)) {\n stateRef.current = newValue;\n\n onStoreChange();\n }\n });\n },\n [router],\n );\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","// packages/react/modules/hooks/useStableValue.tsx\n\nimport { useMemo } from \"react\";\n\n/**\n * Stabilizes a value reference based on deep equality (via JSON serialization).\n * Returns the same reference until the serialized value changes.\n *\n * Useful for object/array dependencies in hooks like useMemo, useCallback, useEffect\n * to prevent unnecessary re-renders when the value is structurally the same.\n *\n * @example\n * ```tsx\n * const stableParams = useStableValue(routeParams);\n * const href = useMemo(() => {\n * return router.buildUrl(routeName, stableParams);\n * }, [router, routeName, stableParams]);\n * ```\n *\n * @param value - The value to stabilize\n * @returns A stable reference to the value\n */\nexport function useStableValue<T>(value: T): T {\n const serialized = JSON.stringify(value);\n\n // We intentionally use serialized in deps to detect deep changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => value, [serialized]);\n}\n","// packages/react/modules/utils.ts\n\nimport type { Params, Router, State } from \"@real-router/core\";\nimport type { MouseEvent } from \"react\";\n\n/**\n * Cache for shouldUpdateNode functions to avoid recreating them\n */\nexport const shouldUpdateCache = new WeakMap<\n Router,\n Map<string, (toState: State, fromState?: State) => boolean>\n>();\n\n/**\n * Get cached shouldUpdateNode function for a router and nodeName\n */\nexport function getCachedShouldUpdate(\n router: Router,\n nodeName: string,\n): (toState: State, fromState?: State) => boolean {\n let cache = shouldUpdateCache.get(router);\n\n if (!cache) {\n cache = new Map();\n shouldUpdateCache.set(router, cache);\n }\n\n let fn = cache.get(nodeName);\n\n if (!fn) {\n fn = router.shouldUpdateNode(nodeName);\n\n const originalFn = fn;\n\n fn = (toState: State, fromState?: State) => originalFn(toState, fromState);\n\n cache.set(nodeName, fn);\n }\n\n return fn;\n}\n\n/**\n * Check if navigation should be handled by router\n */\nexport function shouldNavigate(evt: MouseEvent): boolean {\n return (\n evt.button === 0 && // left click\n !evt.metaKey &&\n !evt.altKey &&\n !evt.ctrlKey &&\n !evt.shiftKey\n );\n}\n\n/**\n * Create cache key for route active check\n */\nexport function createActiveCheckKey(\n routeName: string,\n routeParams: Params,\n activeStrict: boolean,\n ignoreQueryParams: boolean,\n): string {\n return JSON.stringify({\n routeName,\n routeParams,\n activeStrict,\n ignoreQueryParams,\n });\n}\n","// packages/react/modules/hooks/useIsActiveRoute.tsx\n\nimport { areRoutesRelated } from \"@real-router/helpers\";\nimport { useCallback, useMemo, useRef } from \"react\";\n\nimport { useRouterSubscription } from \"./useRouterSubscription\";\nimport { useStableValue } from \"./useStableValue\";\nimport { EMPTY_PARAMS } from \"../constants\";\nimport { createActiveCheckKey } from \"../utils\";\n\nimport type { Params, Router, State, SubscribeState } from \"@real-router/core\";\n\n/**\n * Optimized hook to check if a route is active.\n * Minimizes unnecessary recalculations and re-renders.\n */\nexport function useIsActiveRoute(\n router: Router,\n routeName: string,\n routeParams: Params = EMPTY_PARAMS,\n activeStrict = false,\n ignoreQueryParams = true,\n): boolean {\n // Stabilize params reference to prevent unnecessary recalculations\n const stableParams = useStableValue(routeParams);\n\n // Create stable cache key\n const cacheKey = useMemo(\n () =>\n createActiveCheckKey(\n routeName,\n stableParams,\n activeStrict,\n ignoreQueryParams,\n ),\n [routeName, stableParams, activeStrict, ignoreQueryParams],\n );\n\n // Cache the active state\n const isActiveRef = useRef<boolean | undefined>(undefined);\n const lastCacheKey = useRef<string | undefined>(undefined);\n\n if (lastCacheKey.current !== cacheKey) {\n isActiveRef.current = undefined;\n lastCacheKey.current = cacheKey;\n }\n\n // Optimize shouldUpdate to skip unrelated routes\n const shouldUpdate = useCallback(\n (newRoute: State, prevRoute?: State) => {\n const isNewRelated = areRoutesRelated(routeName, newRoute.name);\n const isPrevRelated =\n prevRoute && areRoutesRelated(routeName, prevRoute.name);\n\n return !!(isNewRelated || isPrevRelated);\n },\n [routeName],\n );\n\n // Selector that performs active check\n const selector = useCallback(\n (sub?: SubscribeState): boolean => {\n const currentRoute = sub?.route ?? router.getState();\n\n // Fast path: if no current route, not active\n if (!currentRoute) {\n isActiveRef.current = false;\n\n return false;\n }\n\n // Fast path: skip unrelated routes\n if (!areRoutesRelated(routeName, currentRoute.name)) {\n isActiveRef.current = false;\n\n return false;\n }\n\n // Full check for related routes\n const isActive = router.isActiveRoute(\n routeName,\n stableParams,\n activeStrict,\n ignoreQueryParams,\n );\n\n isActiveRef.current = isActive;\n\n return isActive;\n },\n [router, routeName, stableParams, activeStrict, ignoreQueryParams],\n );\n\n return useRouterSubscription(router, selector, shouldUpdate);\n}\n","// packages/react/modules/components/BaseLink.tsx\n\nimport { memo, useCallback, useMemo } from \"react\";\n\nimport { EMPTY_PARAMS, EMPTY_OPTIONS } from \"../constants\";\nimport { useIsActiveRoute } from \"../hooks/useIsActiveRoute\";\nimport { useStableValue } from \"../hooks/useStableValue\";\nimport { shouldNavigate } from \"../utils\";\n\nimport type { BaseLinkProps } from \"../types\";\nimport type { FC, MouseEvent } from \"react\";\n\n/**\n * Optimized BaseLink component with memoization and performance improvements\n */\nexport const BaseLink: FC<BaseLinkProps> = memo(\n ({\n routeName,\n routeParams = EMPTY_PARAMS,\n routeOptions = EMPTY_OPTIONS,\n className,\n activeClassName = \"active\",\n activeStrict = false,\n ignoreQueryParams = true,\n onClick,\n target,\n router,\n children,\n ...props\n }) => {\n // Stabilize object references to prevent unnecessary re-renders\n const stableParams = useStableValue(routeParams);\n const stableOptions = useStableValue(routeOptions);\n\n // Use optimized hook for active state checking\n const isActive = useIsActiveRoute(\n router,\n routeName,\n stableParams,\n activeStrict,\n ignoreQueryParams,\n );\n\n // Build URL with memoization\n const href = useMemo(() => {\n // Use buildUrl if available (browser plugin installed)\n // Otherwise fall back to buildPath (e.g., in SSR or without browser plugin)\n if (typeof router.buildUrl === \"function\") {\n return router.buildUrl(routeName, stableParams);\n }\n\n return router.buildPath(routeName, stableParams);\n }, [router, routeName, stableParams]);\n\n // Optimized click handler\n const handleClick = useCallback(\n (evt: MouseEvent<HTMLAnchorElement>) => {\n // Call custom onClick if provided\n if (onClick) {\n onClick(evt);\n // Respect preventDefault from custom handler\n if (evt.defaultPrevented) {\n return;\n }\n }\n\n // Check if we should handle navigation\n if (!shouldNavigate(evt) || target === \"_blank\") {\n return;\n }\n\n // Prevent default link behavior\n evt.preventDefault();\n\n // Perform navigation (fire-and-forget)\n router.navigate(routeName, stableParams, stableOptions).catch(() => {});\n },\n [onClick, target, router, routeName, stableParams, stableOptions],\n );\n\n // Build className efficiently\n const finalClassName = useMemo(() => {\n if (isActive && activeClassName) {\n return className\n ? `${className} ${activeClassName}`.trim()\n : activeClassName;\n }\n\n return className ?? undefined;\n }, [isActive, className, activeClassName]);\n\n // Filter out previousRoute from props\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { previousRoute, ...restProps } = props;\n\n return (\n <a\n {...restProps}\n href={href}\n className={finalClassName}\n onClick={handleClick}\n data-route={routeName} // For event delegation if needed\n data-active={isActive} // For CSS selectors if needed\n >\n {children}\n </a>\n );\n },\n (prevProps, nextProps) => {\n // Custom comparison for better memoization\n // Check if props that affect rendering have changed\n return (\n prevProps.router === nextProps.router &&\n prevProps.routeName === nextProps.routeName &&\n JSON.stringify(prevProps.routeParams) ===\n JSON.stringify(nextProps.routeParams) &&\n JSON.stringify(prevProps.routeOptions) ===\n JSON.stringify(nextProps.routeOptions) &&\n prevProps.className === nextProps.className &&\n prevProps.activeClassName === nextProps.activeClassName &&\n prevProps.activeStrict === nextProps.activeStrict &&\n prevProps.ignoreQueryParams === nextProps.ignoreQueryParams &&\n prevProps.onClick === nextProps.onClick &&\n prevProps.target === nextProps.target &&\n prevProps.children === nextProps.children\n );\n },\n);\n\nBaseLink.displayName = \"BaseLink\";\n","// packages/react/modules/components/Link.tsx\n\nimport { useRouter } from \"@real-router/react\";\n\nimport { BaseLink } from \"./BaseLink\";\n\nimport type { BaseLinkProps } from \"./interfaces\";\nimport type { FC } from \"react\";\n\nexport const Link: FC<Omit<BaseLinkProps, \"router\">> = (props) => {\n const router = useRouter();\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { route, previousRoute, routeOptions, ...linkProps } = props;\n\n return <BaseLink router={router} {...linkProps} />;\n};\n","// packages/react/modules/components/ConnectedLink.tsx\n\nimport { useRoute, useRouter } from \"@real-router/react\";\n\nimport { BaseLink } from \"./BaseLink\";\n\nimport type { BaseLinkProps } from \"./interfaces\";\nimport type { FC } from \"react\";\n\nexport const ConnectedLink: FC<\n Omit<BaseLinkProps, \"router\" | \"route\" | \"previousRoute\">\n> = (props) => {\n const router = useRouter();\n const { route } = useRoute();\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { routeOptions, ...linkProps } = props;\n\n return <BaseLink router={router} route={route} {...linkProps} />;\n};\n","// packages/react/modules/hooks/useRouteNode.tsx\n\nimport { getNavigator } from \"@real-router/core\";\nimport { useCallback, useMemo } from \"react\";\n\nimport { useRouter } from \"@real-router/react\";\n\nimport { useRouterSubscription } from \"./useRouterSubscription\";\nimport { getCachedShouldUpdate } from \"../utils\";\n\nimport type { RouteContext, RouteState } from \"../types\";\nimport type { State, SubscribeState } from \"@real-router/core\";\n\n/**\n * Hook that subscribes to a specific route node with optimizations.\n * Provides the current and previous route when the node is affected.\n */\nexport function useRouteNode(nodeName: string): RouteContext {\n // Get router from context with error handling\n const router = useRouter();\n\n // Get cached shouldUpdate function to avoid recreation\n const shouldUpdate = useMemo(\n () => getCachedShouldUpdate(router, nodeName),\n [router, nodeName],\n );\n\n // Stable state factory\n // useRouteNode.tsx\n const stateFactory = useCallback(\n (sub?: SubscribeState): RouteState => {\n const currentRoute = sub?.route ?? router.getState();\n\n // Проверяем, активен ли узел\n if (currentRoute && nodeName !== \"\") {\n // Корневой узел всегда активен\n const isNodeActive =\n currentRoute.name === nodeName ||\n currentRoute.name.startsWith(`${nodeName}.`);\n\n if (!isNodeActive) {\n return {\n route: undefined,\n previousRoute: sub?.previousRoute,\n };\n }\n }\n\n return {\n route: currentRoute,\n previousRoute: sub?.previousRoute,\n };\n },\n [router, nodeName],\n );\n\n // Subscribe to router with optimization\n const state = useRouterSubscription<RouteState>(\n router,\n stateFactory,\n shouldUpdate as (newRoute: State, prevRoute?: State) => boolean,\n );\n\n // Return memoized context - useMemo ensures stable reference when deps unchanged\n const navigator = useMemo(() => getNavigator(router), [router]);\n\n return useMemo(\n (): RouteContext => ({\n navigator,\n route: state.route,\n previousRoute: state.previousRoute,\n }),\n [navigator, state.route, state.previousRoute],\n );\n}\n","// packages/react/modules/context.ts\n\nimport { createContext } from \"react\";\n\nimport type { RouteContext as RouteContextType } from \"./types\";\nimport type { Router, Navigator } from \"@real-router/core\";\n\nexport const RouteContext = createContext<RouteContextType | null>(null);\n\nexport const RouterContext = createContext<Router | null>(null);\n\nexport const NavigatorContext = createContext<Navigator | null>(null);\n","// packages/react/modules/hooks/useRoute.tsx\n\nimport { useContext } from \"react\";\n\nimport { RouteContext } from \"../context\";\n\nimport type { RouteContext as RouteContextType } from \"../types\";\n\nexport const useRoute = (): RouteContextType => {\n const routeContext = useContext(RouteContext);\n\n if (!routeContext) {\n throw new Error(\"useRoute must be used within a RouteProvider\");\n }\n\n return routeContext;\n};\n","// packages/react/modules/hooks/useNavigator.tsx\n\nimport { useContext } from \"react\";\n\nimport { NavigatorContext } from \"../context\";\n\nimport type { Navigator } from \"@real-router/core\";\n\nexport const useNavigator = (): Navigator => {\n const navigator = useContext(NavigatorContext);\n\n if (!navigator) {\n throw new Error(\"useNavigator must be used within a RouterProvider\");\n }\n\n return navigator;\n};\n","// packages/react/modules/RouterProvider.tsx\n\nimport { getNavigator } from \"@real-router/core\";\nimport { useMemo, useSyncExternalStore } from \"react\";\n\nimport { NavigatorContext, RouteContext, RouterContext } from \"./context\";\n\nimport type { RouteState } from \"./types\";\nimport type { Router } from \"@real-router/core\";\nimport type { FC, ReactNode } from \"react\";\n\nexport interface RouteProviderProps {\n router: Router;\n children: ReactNode;\n}\n\nexport const RouterProvider: FC<RouteProviderProps> = ({\n router,\n children,\n}) => {\n // Get navigator instance from router\n const navigator = useMemo(() => getNavigator(router), [router]);\n\n // Local store state to hold route information\n const store = useMemo(() => {\n let currentState: RouteState = {\n route: router.getState(),\n previousRoute: undefined,\n };\n\n // This will be called to return the current state snapshot\n const getSnapshot = () => currentState;\n\n // Subscribe to router updates and notify React when state changes\n const subscribe = (callback: () => void) => {\n const unsubscribe = router.subscribe(({ route, previousRoute }) => {\n currentState = { route, previousRoute };\n callback(); // Notify React to trigger re-render\n });\n\n // Note: router.subscribe() always returns a function, no need to check\n return unsubscribe;\n };\n\n return { getSnapshot, subscribe };\n }, [router]);\n\n // Using useSyncExternalStore to manage subscription and state updates\n const state = useSyncExternalStore(store.subscribe, store.getSnapshot);\n\n // Memoize RouteContext value to prevent unnecessary re-renders\n const routeContextValue = useMemo(\n () => ({ navigator, ...state }),\n [navigator, state],\n );\n\n return (\n <RouterContext.Provider value={router}>\n <NavigatorContext.Provider value={navigator}>\n <RouteContext.Provider value={routeContextValue}>\n {children}\n </RouteContext.Provider>\n </NavigatorContext.Provider>\n </RouterContext.Provider>\n );\n};\n","// packages/react/modules/hooks/useRouter.tsx\n\nimport { useContext } from \"react\";\n\nimport { RouterContext } from \"../context\";\n\nimport type { Router } from \"@real-router/core\";\n\nexport const useRouter = (): Router => {\n const router = useContext(RouterContext);\n\n if (!router) {\n throw new Error(\"useRouter must be used within a RouterProvider\");\n }\n\n return router;\n};\n"]}
1
+ {"version":3,"sources":["../../src/constants.ts","../../src/hooks/useRouterSubscription.tsx","../../src/hooks/useStableValue.tsx","../../src/utils.ts","../../src/hooks/useIsActiveRoute.tsx","../../src/components/BaseLink.tsx","../../src/context.ts","../../src/hooks/useRouter.tsx","../../src/components/Link.tsx","../../src/hooks/useRoute.tsx","../../src/components/ConnectedLink.tsx","../../src/hooks/useRouteNode.tsx","../../src/hooks/useNavigator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AAA,CAAC,gBAAA,EAAA,EAAiB,KAAA,EAAO,SAAA,EACvB,0BAAAA,GAAAA,CAAC,YAAA,EAAA,EAAa,OAAO,iBAAA,EAAoB,QAAA,EAAS,GACpD,CAAA,EACF,CAAA;AAEJ","file":"index.mjs","sourcesContent":["// packages/react/modules/constants.ts\n\n/**\n * Stable empty object for default params\n */\nexport const EMPTY_PARAMS = Object.freeze({});\n\n/**\n * Stable empty options object\n */\nexport const EMPTY_OPTIONS = Object.freeze({});\n","// packages/react/modules/hooks/useRouterSubscription.tsx\n\nimport { useCallback, useRef, useSyncExternalStore } from \"react\";\n\nimport type { Router, State, SubscribeState } from \"@real-router/core\";\n\n/**\n * Generic hook for subscribing to router changes with optimization.\n *\n * @param router - Real Router instance\n * @param selector - Function to derive state from router subscription\n * @param shouldUpdate - Optional predicate to filter updates\n */\nexport function useRouterSubscription<T>(\n router: Router,\n selector: (sub?: SubscribeState) => T,\n shouldUpdate?: (newRoute: State, prevRoute?: State) => boolean,\n): T {\n // Store current value\n const stateRef = useRef<T | undefined>(undefined);\n const selectorRef = useRef(selector);\n const shouldUpdateRef = useRef(shouldUpdate);\n\n // Update refs to avoid stale closures\n selectorRef.current = selector;\n shouldUpdateRef.current = shouldUpdate;\n\n // Lazy initialization\n if (stateRef.current === undefined) {\n // Get initial state from router\n const currentState = router.getState();\n\n // Check if initial state is relevant for this subscription\n const shouldInitialize =\n !shouldUpdateRef.current ||\n (currentState && shouldUpdateRef.current(currentState));\n\n stateRef.current = selectorRef.current(\n shouldInitialize && currentState\n ? { route: currentState, previousRoute: undefined }\n : undefined,\n );\n }\n\n // Stable snapshot getter\n const getSnapshot = useCallback(() => stateRef.current as T, []);\n\n // Subscribe function with optimization\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n return router.subscribe((next) => {\n // Check if we should process this update\n let shouldProcess = true;\n\n if (shouldUpdateRef.current) {\n shouldProcess = shouldUpdateRef.current(\n next.route,\n next.previousRoute,\n );\n }\n\n if (!shouldProcess) {\n return;\n }\n\n // Calculate new value\n const newValue = selectorRef.current(next);\n\n // Only trigger update if value actually changed\n if (!Object.is(stateRef.current, newValue)) {\n stateRef.current = newValue;\n\n onStoreChange();\n }\n });\n },\n [router],\n );\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","// packages/react/modules/hooks/useStableValue.tsx\n\nimport { useMemo } from \"react\";\n\n/**\n * Stabilizes a value reference based on deep equality (via JSON serialization).\n * Returns the same reference until the serialized value changes.\n *\n * Useful for object/array dependencies in hooks like useMemo, useCallback, useEffect\n * to prevent unnecessary re-renders when the value is structurally the same.\n *\n * @example\n * ```tsx\n * const stableParams = useStableValue(routeParams);\n * const href = useMemo(() => {\n * return router.buildUrl(routeName, stableParams);\n * }, [router, routeName, stableParams]);\n * ```\n *\n * @param value - The value to stabilize\n * @returns A stable reference to the value\n */\nexport function useStableValue<T>(value: T): T {\n const serialized = JSON.stringify(value);\n\n // We intentionally use serialized in deps to detect deep changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => value, [serialized]);\n}\n","// packages/react/modules/utils.ts\n\nimport type { Params, Router, State } from \"@real-router/core\";\nimport type { MouseEvent } from \"react\";\n\n/**\n * Cache for shouldUpdateNode functions to avoid recreating them\n */\nexport const shouldUpdateCache = new WeakMap<\n Router,\n Map<string, (toState: State, fromState?: State) => boolean>\n>();\n\n/**\n * Get cached shouldUpdateNode function for a router and nodeName\n */\nexport function getCachedShouldUpdate(\n router: Router,\n nodeName: string,\n): (toState: State, fromState?: State) => boolean {\n let cache = shouldUpdateCache.get(router);\n\n if (!cache) {\n cache = new Map();\n shouldUpdateCache.set(router, cache);\n }\n\n let fn = cache.get(nodeName);\n\n if (!fn) {\n fn = router.shouldUpdateNode(nodeName);\n\n const originalFn = fn;\n\n fn = (toState: State, fromState?: State) => originalFn(toState, fromState);\n\n cache.set(nodeName, fn);\n }\n\n return fn;\n}\n\n/**\n * Check if navigation should be handled by router\n */\nexport function shouldNavigate(evt: MouseEvent): boolean {\n return (\n evt.button === 0 && // left click\n !evt.metaKey &&\n !evt.altKey &&\n !evt.ctrlKey &&\n !evt.shiftKey\n );\n}\n\n/**\n * Create cache key for route active check\n */\nexport function createActiveCheckKey(\n routeName: string,\n routeParams: Params,\n activeStrict: boolean,\n ignoreQueryParams: boolean,\n): string {\n return JSON.stringify({\n routeName,\n routeParams,\n activeStrict,\n ignoreQueryParams,\n });\n}\n","// packages/react/modules/hooks/useIsActiveRoute.tsx\n\nimport { areRoutesRelated } from \"@real-router/helpers\";\nimport { useCallback, useMemo, useRef } from \"react\";\n\nimport { useRouterSubscription } from \"./useRouterSubscription\";\nimport { useStableValue } from \"./useStableValue\";\nimport { EMPTY_PARAMS } from \"../constants\";\nimport { createActiveCheckKey } from \"../utils\";\n\nimport type { Params, Router, State, SubscribeState } from \"@real-router/core\";\n\n/**\n * Optimized hook to check if a route is active.\n * Minimizes unnecessary recalculations and re-renders.\n */\nexport function useIsActiveRoute(\n router: Router,\n routeName: string,\n routeParams: Params = EMPTY_PARAMS,\n activeStrict = false,\n ignoreQueryParams = true,\n): boolean {\n // Stabilize params reference to prevent unnecessary recalculations\n const stableParams = useStableValue(routeParams);\n\n // Create stable cache key\n const cacheKey = useMemo(\n () =>\n createActiveCheckKey(\n routeName,\n stableParams,\n activeStrict,\n ignoreQueryParams,\n ),\n [routeName, stableParams, activeStrict, ignoreQueryParams],\n );\n\n // Cache the active state\n const isActiveRef = useRef<boolean | undefined>(undefined);\n const lastCacheKeyRef = useRef<string | undefined>(undefined);\n\n if (lastCacheKeyRef.current !== cacheKey) {\n isActiveRef.current = undefined;\n lastCacheKeyRef.current = cacheKey;\n }\n\n // Optimize shouldUpdate to skip unrelated routes\n const shouldUpdate = useCallback(\n (newRoute: State, prevRoute?: State) => {\n const isNewRelated = areRoutesRelated(routeName, newRoute.name);\n const isPrevRelated =\n prevRoute && areRoutesRelated(routeName, prevRoute.name);\n\n return !!(isNewRelated || isPrevRelated);\n },\n [routeName],\n );\n\n // Selector that performs active check\n const selector = useCallback(\n (sub?: SubscribeState): boolean => {\n const currentRoute = sub?.route ?? router.getState();\n\n // Fast path: if no current route, not active\n if (!currentRoute) {\n isActiveRef.current = false;\n\n return false;\n }\n\n // Fast path: skip unrelated routes\n if (!areRoutesRelated(routeName, currentRoute.name)) {\n isActiveRef.current = false;\n\n return false;\n }\n\n // Full check for related routes\n const isActive = router.isActiveRoute(\n routeName,\n stableParams,\n activeStrict,\n ignoreQueryParams,\n );\n\n isActiveRef.current = isActive;\n\n return isActive;\n },\n [router, routeName, stableParams, activeStrict, ignoreQueryParams],\n );\n\n return useRouterSubscription(router, selector, shouldUpdate);\n}\n","// packages/react/modules/components/BaseLink.tsx\n\nimport { memo, useCallback, useMemo } from \"react\";\n\nimport { EMPTY_PARAMS, EMPTY_OPTIONS } from \"../constants\";\nimport { useIsActiveRoute } from \"../hooks/useIsActiveRoute\";\nimport { useStableValue } from \"../hooks/useStableValue\";\nimport { shouldNavigate } from \"../utils\";\n\nimport type { BaseLinkProps } from \"../types\";\nimport type { FC, MouseEvent } from \"react\";\n\n/**\n * Optimized BaseLink component with memoization and performance improvements\n */\nexport const BaseLink: FC<BaseLinkProps> = memo(\n ({\n routeName,\n routeParams = EMPTY_PARAMS,\n routeOptions = EMPTY_OPTIONS,\n className,\n activeClassName = \"active\",\n activeStrict = false,\n ignoreQueryParams = true,\n onClick,\n target,\n router,\n children,\n ...props\n }) => {\n // Stabilize object references to prevent unnecessary re-renders\n const stableParams = useStableValue(routeParams);\n const stableOptions = useStableValue(routeOptions);\n\n // Use optimized hook for active state checking\n const isActive = useIsActiveRoute(\n router,\n routeName,\n stableParams,\n activeStrict,\n ignoreQueryParams,\n );\n\n // Build URL with memoization\n const href = useMemo(() => {\n // Use buildUrl if available (browser plugin installed)\n // Otherwise fall back to buildPath (e.g., in SSR or without browser plugin)\n if (typeof router.buildUrl === \"function\") {\n return router.buildUrl(routeName, stableParams);\n }\n\n return router.buildPath(routeName, stableParams);\n }, [router, routeName, stableParams]);\n\n // Optimized click handler\n const handleClick = useCallback(\n (evt: MouseEvent<HTMLAnchorElement>) => {\n // Call custom onClick if provided\n if (onClick) {\n onClick(evt);\n // Respect preventDefault from custom handler\n if (evt.defaultPrevented) {\n return;\n }\n }\n\n // Check if we should handle navigation\n if (!shouldNavigate(evt) || target === \"_blank\") {\n return;\n }\n\n // Prevent default link behavior\n evt.preventDefault();\n\n // Perform navigation (fire-and-forget)\n router.navigate(routeName, stableParams, stableOptions).catch(() => {});\n },\n [onClick, target, router, routeName, stableParams, stableOptions],\n );\n\n // Build className efficiently\n const finalClassName = useMemo(() => {\n if (isActive && activeClassName) {\n return className\n ? `${className} ${activeClassName}`.trim()\n : activeClassName;\n }\n\n return className ?? undefined;\n }, [isActive, className, activeClassName]);\n\n // Filter out previousRoute from props\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { previousRoute, ...restProps } = props;\n\n return (\n <a\n {...restProps}\n href={href}\n className={finalClassName}\n onClick={handleClick}\n data-route={routeName} // For event delegation if needed\n data-active={isActive} // For CSS selectors if needed\n >\n {children}\n </a>\n );\n },\n (prevProps, nextProps) => {\n // Custom comparison for better memoization\n // Check if props that affect rendering have changed\n return (\n prevProps.router === nextProps.router &&\n prevProps.routeName === nextProps.routeName &&\n JSON.stringify(prevProps.routeParams) ===\n JSON.stringify(nextProps.routeParams) &&\n JSON.stringify(prevProps.routeOptions) ===\n JSON.stringify(nextProps.routeOptions) &&\n prevProps.className === nextProps.className &&\n prevProps.activeClassName === nextProps.activeClassName &&\n prevProps.activeStrict === nextProps.activeStrict &&\n prevProps.ignoreQueryParams === nextProps.ignoreQueryParams &&\n prevProps.onClick === nextProps.onClick &&\n prevProps.target === nextProps.target &&\n prevProps.children === nextProps.children\n );\n },\n);\n\nBaseLink.displayName = \"BaseLink\";\n","// packages/react/modules/context.ts\n\nimport { createContext } from \"react\";\n\nimport type { RouteContext as RouteContextType } from \"./types\";\nimport type { Router, Navigator } from \"@real-router/core\";\n\nexport const RouteContext = createContext<RouteContextType | null>(null);\n\nexport const RouterContext = createContext<Router | null>(null);\n\nexport const NavigatorContext = createContext<Navigator | null>(null);\n","// packages/react/modules/hooks/useRouter.tsx\n\nimport { use } from \"react\";\n\nimport { RouterContext } from \"../context\";\n\nimport type { Router } from \"@real-router/core\";\n\nexport const useRouter = (): Router => {\n const router = use(RouterContext);\n\n if (!router) {\n throw new Error(\"useRouter must be used within a RouterProvider\");\n }\n\n return router;\n};\n","// packages/react/modules/components/Link.tsx\n\nimport { BaseLink } from \"./BaseLink\";\nimport { useRouter } from \"../hooks/useRouter\";\n\nimport type { BaseLinkProps } from \"./interfaces\";\nimport type { FC } from \"react\";\n\nexport const Link: FC<Omit<BaseLinkProps, \"router\">> = (props) => {\n const router = useRouter();\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { route, previousRoute, routeOptions, ...linkProps } = props;\n\n return <BaseLink router={router} {...linkProps} />;\n};\n","// packages/react/modules/hooks/useRoute.tsx\n\nimport { use } from \"react\";\n\nimport { RouteContext } from \"../context\";\n\nimport type { RouteContext as RouteContextType } from \"../types\";\n\nexport const useRoute = (): RouteContextType => {\n const routeContext = use(RouteContext);\n\n if (!routeContext) {\n throw new Error(\"useRoute must be used within a RouteProvider\");\n }\n\n return routeContext;\n};\n","// packages/react/modules/components/ConnectedLink.tsx\n\nimport { BaseLink } from \"./BaseLink\";\nimport { useRoute } from \"../hooks/useRoute\";\nimport { useRouter } from \"../hooks/useRouter\";\n\nimport type { BaseLinkProps } from \"./interfaces\";\nimport type { FC } from \"react\";\n\nexport const ConnectedLink: FC<\n Omit<BaseLinkProps, \"router\" | \"route\" | \"previousRoute\">\n> = (props) => {\n const router = useRouter();\n const { route } = useRoute();\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { routeOptions, ...linkProps } = props;\n\n return <BaseLink router={router} route={route} {...linkProps} />;\n};\n","// packages/react/modules/hooks/useRouteNode.tsx\n\nimport { getNavigator } from \"@real-router/core\";\nimport { useCallback, useMemo } from \"react\";\n\nimport { useRouter } from \"./useRouter\";\nimport { useRouterSubscription } from \"./useRouterSubscription\";\nimport { getCachedShouldUpdate } from \"../utils\";\n\nimport type { RouteContext, RouteState } from \"../types\";\nimport type { State, SubscribeState } from \"@real-router/core\";\n\n/**\n * Hook that subscribes to a specific route node with optimizations.\n * Provides the current and previous route when the node is affected.\n */\nexport function useRouteNode(nodeName: string): RouteContext {\n // Get router from context with error handling\n const router = useRouter();\n\n // Get cached shouldUpdate function to avoid recreation\n const shouldUpdate = useMemo(\n () => getCachedShouldUpdate(router, nodeName),\n [router, nodeName],\n );\n\n // Stable state factory\n // useRouteNode.tsx\n const stateFactory = useCallback(\n (sub?: SubscribeState): RouteState => {\n const currentRoute = sub?.route ?? router.getState();\n\n // Проверяем, активен ли узел\n if (currentRoute && nodeName !== \"\") {\n // Корневой узел всегда активен\n const isNodeActive =\n currentRoute.name === nodeName ||\n currentRoute.name.startsWith(`${nodeName}.`);\n\n if (!isNodeActive) {\n return {\n route: undefined,\n previousRoute: sub?.previousRoute,\n };\n }\n }\n\n return {\n route: currentRoute,\n previousRoute: sub?.previousRoute,\n };\n },\n [router, nodeName],\n );\n\n // Subscribe to router with optimization\n const state = useRouterSubscription<RouteState>(\n router,\n stateFactory,\n shouldUpdate as (newRoute: State, prevRoute?: State) => boolean,\n );\n\n // Return memoized context - useMemo ensures stable reference when deps unchanged\n const navigator = useMemo(() => getNavigator(router), [router]);\n\n return useMemo(\n (): RouteContext => ({\n navigator,\n route: state.route,\n previousRoute: state.previousRoute,\n }),\n [navigator, state.route, state.previousRoute],\n );\n}\n","// packages/react/modules/hooks/useNavigator.tsx\n\nimport { use } from \"react\";\n\nimport { NavigatorContext } from \"../context\";\n\nimport type { Navigator } from \"@real-router/core\";\n\nexport const useNavigator = (): Navigator => {\n const navigator = use(NavigatorContext);\n\n if (!navigator) {\n throw new Error(\"useNavigator must be used within a RouterProvider\");\n }\n\n return navigator;\n};\n","// packages/react/modules/RouterProvider.tsx\n\nimport { getNavigator } from \"@real-router/core\";\nimport { useMemo, useSyncExternalStore } from \"react\";\n\nimport { NavigatorContext, RouteContext, RouterContext } from \"./context\";\n\nimport type { RouteState } from \"./types\";\nimport type { Router } from \"@real-router/core\";\nimport type { FC, ReactNode } from \"react\";\n\nexport interface RouteProviderProps {\n router: Router;\n children: ReactNode;\n}\n\nexport const RouterProvider: FC<RouteProviderProps> = ({\n router,\n children,\n}) => {\n // Get navigator instance from router\n const navigator = useMemo(() => getNavigator(router), [router]);\n\n // Local store state to hold route information\n const store = useMemo(() => {\n let currentState: RouteState = {\n route: router.getState(),\n previousRoute: undefined,\n };\n\n // This will be called to return the current state snapshot\n const getSnapshot = () => currentState;\n\n // Subscribe to router updates and notify React when state changes\n const subscribe = (callback: () => void) => {\n const unsubscribe = router.subscribe(({ route, previousRoute }) => {\n currentState = { route, previousRoute };\n callback(); // Notify React to trigger re-render\n });\n\n // Note: router.subscribe() always returns a function, no need to check\n return unsubscribe;\n };\n\n return { getSnapshot, subscribe };\n }, [router]);\n\n // Using useSyncExternalStore to manage subscription and state updates\n const state = useSyncExternalStore(store.subscribe, store.getSnapshot);\n\n // Memoize RouteContext value to prevent unnecessary re-renders\n const routeContextValue = useMemo(\n () => ({ navigator, ...state }),\n [navigator, state],\n );\n\n return (\n <RouterContext value={router}>\n <NavigatorContext value={navigator}>\n <RouteContext value={routeContextValue}>{children}</RouteContext>\n </NavigatorContext>\n </RouterContext>\n );\n};\n"]}
@@ -1 +1 @@
1
- {"inputs":{"src/constants.ts":{"bytes":225,"imports":[],"format":"esm"},"src/hooks/useRouterSubscription.tsx":{"bytes":2370,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useStableValue.tsx":{"bytes":976,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/utils.ts":{"bytes":1483,"imports":[],"format":"esm"},"src/hooks/useIsActiveRoute.tsx":{"bytes":2679,"imports":[{"path":"@real-router/helpers","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/hooks/useRouterSubscription.tsx","kind":"import-statement","original":"./useRouterSubscription"},{"path":"src/hooks/useStableValue.tsx","kind":"import-statement","original":"./useStableValue"},{"path":"src/constants.ts","kind":"import-statement","original":"../constants"},{"path":"src/utils.ts","kind":"import-statement","original":"../utils"}],"format":"esm"},"src/components/BaseLink.tsx":{"bytes":4067,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"../constants"},{"path":"src/hooks/useIsActiveRoute.tsx","kind":"import-statement","original":"../hooks/useIsActiveRoute"},{"path":"src/hooks/useStableValue.tsx","kind":"import-statement","original":"../hooks/useStableValue"},{"path":"src/utils.ts","kind":"import-statement","original":"../utils"},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/components/Link.tsx":{"bytes":512,"imports":[{"path":"src/index.ts","kind":"import-statement","original":"@real-router/react"},{"path":"src/components/BaseLink.tsx","kind":"import-statement","original":"./BaseLink"},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/components/ConnectedLink.tsx":{"bytes":596,"imports":[{"path":"src/index.ts","kind":"import-statement","original":"@real-router/react"},{"path":"src/components/BaseLink.tsx","kind":"import-statement","original":"./BaseLink"},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useRouteNode.tsx":{"bytes":2220,"imports":[{"path":"@real-router/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/index.ts","kind":"import-statement","original":"@real-router/react"},{"path":"src/hooks/useRouterSubscription.tsx","kind":"import-statement","original":"./useRouterSubscription"},{"path":"src/utils.ts","kind":"import-statement","original":"../utils"}],"format":"esm"},"src/context.ts":{"bytes":416,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useRoute.tsx":{"bytes":417,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/context.ts","kind":"import-statement","original":"../context"}],"format":"esm"},"src/hooks/useNavigator.tsx":{"bytes":408,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/context.ts","kind":"import-statement","original":"../context"}],"format":"esm"},"src/RouterProvider.tsx":{"bytes":2032,"imports":[{"path":"@real-router/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/context.ts","kind":"import-statement","original":"./context"},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useRouter.tsx":{"bytes":378,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/context.ts","kind":"import-statement","original":"../context"}],"format":"esm"},"src/index.ts":{"bytes":663,"imports":[{"path":"src/components/BaseLink.tsx","kind":"import-statement","original":"./components/BaseLink"},{"path":"src/components/Link.tsx","kind":"import-statement","original":"./components/Link"},{"path":"src/components/ConnectedLink.tsx","kind":"import-statement","original":"./components/ConnectedLink"},{"path":"src/hooks/useRouteNode.tsx","kind":"import-statement","original":"./hooks/useRouteNode"},{"path":"src/hooks/useRoute.tsx","kind":"import-statement","original":"./hooks/useRoute"},{"path":"src/hooks/useNavigator.tsx","kind":"import-statement","original":"./hooks/useNavigator"},{"path":"src/RouterProvider.tsx","kind":"import-statement","original":"./RouterProvider"},{"path":"src/context.ts","kind":"import-statement","original":"./context"},{"path":"src/hooks/useRouter.tsx","kind":"import-statement","original":"./hooks/useRouter"}],"format":"esm"}},"outputs":{"dist/esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":27471},"dist/esm/index.mjs":{"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@real-router/helpers","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"@real-router/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@real-router/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"exports":["BaseLink","ConnectedLink","Link","NavigatorContext","RouteContext","RouterContext","RouterProvider","useNavigator","useRoute","useRouteNode","useRouter"],"entryPoint":"src/index.ts","inputs":{"src/components/BaseLink.tsx":{"bytesInOutput":2638},"src/constants.ts":{"bytesInOutput":77},"src/hooks/useIsActiveRoute.tsx":{"bytesInOutput":1723},"src/hooks/useRouterSubscription.tsx":{"bytesInOutput":1386},"src/hooks/useStableValue.tsx":{"bytesInOutput":157},"src/utils.ts":{"bytesInOutput":816},"src/index.ts":{"bytesInOutput":0},"src/components/Link.tsx":{"bytesInOutput":243},"src/components/ConnectedLink.tsx":{"bytesInOutput":269},"src/hooks/useRouteNode.tsx":{"bytesInOutput":1188},"src/hooks/useRoute.tsx":{"bytesInOutput":230},"src/context.ts":{"bytesInOutput":164},"src/hooks/useNavigator.tsx":{"bytesInOutput":250},"src/RouterProvider.tsx":{"bytesInOutput":1210},"src/hooks/useRouter.tsx":{"bytesInOutput":232}},"bytes":11258}}}
1
+ {"inputs":{"src/constants.ts":{"bytes":225,"imports":[],"format":"esm"},"src/hooks/useRouterSubscription.tsx":{"bytes":2370,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useStableValue.tsx":{"bytes":976,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/utils.ts":{"bytes":1483,"imports":[],"format":"esm"},"src/hooks/useIsActiveRoute.tsx":{"bytes":2688,"imports":[{"path":"@real-router/helpers","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/hooks/useRouterSubscription.tsx","kind":"import-statement","original":"./useRouterSubscription"},{"path":"src/hooks/useStableValue.tsx","kind":"import-statement","original":"./useStableValue"},{"path":"src/constants.ts","kind":"import-statement","original":"../constants"},{"path":"src/utils.ts","kind":"import-statement","original":"../utils"}],"format":"esm"},"src/components/BaseLink.tsx":{"bytes":4067,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"../constants"},{"path":"src/hooks/useIsActiveRoute.tsx","kind":"import-statement","original":"../hooks/useIsActiveRoute"},{"path":"src/hooks/useStableValue.tsx","kind":"import-statement","original":"../hooks/useStableValue"},{"path":"src/utils.ts","kind":"import-statement","original":"../utils"},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/context.ts":{"bytes":416,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useRouter.tsx":{"bytes":364,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/context.ts","kind":"import-statement","original":"../context"}],"format":"esm"},"src/components/Link.tsx":{"bytes":511,"imports":[{"path":"src/components/BaseLink.tsx","kind":"import-statement","original":"./BaseLink"},{"path":"src/hooks/useRouter.tsx","kind":"import-statement","original":"../hooks/useRouter"},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useRoute.tsx":{"bytes":403,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/context.ts","kind":"import-statement","original":"../context"}],"format":"esm"},"src/components/ConnectedLink.tsx":{"bytes":631,"imports":[{"path":"src/components/BaseLink.tsx","kind":"import-statement","original":"./BaseLink"},{"path":"src/hooks/useRoute.tsx","kind":"import-statement","original":"../hooks/useRoute"},{"path":"src/hooks/useRouter.tsx","kind":"import-statement","original":"../hooks/useRouter"},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/useRouteNode.tsx":{"bytes":2212,"imports":[{"path":"@real-router/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/hooks/useRouter.tsx","kind":"import-statement","original":"./useRouter"},{"path":"src/hooks/useRouterSubscription.tsx","kind":"import-statement","original":"./useRouterSubscription"},{"path":"src/utils.ts","kind":"import-statement","original":"../utils"}],"format":"esm"},"src/hooks/useNavigator.tsx":{"bytes":394,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/context.ts","kind":"import-statement","original":"../context"}],"format":"esm"},"src/RouterProvider.tsx":{"bytes":1958,"imports":[{"path":"@real-router/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/context.ts","kind":"import-statement","original":"./context"},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":663,"imports":[{"path":"src/components/BaseLink.tsx","kind":"import-statement","original":"./components/BaseLink"},{"path":"src/components/Link.tsx","kind":"import-statement","original":"./components/Link"},{"path":"src/components/ConnectedLink.tsx","kind":"import-statement","original":"./components/ConnectedLink"},{"path":"src/hooks/useRouteNode.tsx","kind":"import-statement","original":"./hooks/useRouteNode"},{"path":"src/hooks/useRoute.tsx","kind":"import-statement","original":"./hooks/useRoute"},{"path":"src/hooks/useNavigator.tsx","kind":"import-statement","original":"./hooks/useNavigator"},{"path":"src/RouterProvider.tsx","kind":"import-statement","original":"./RouterProvider"},{"path":"src/context.ts","kind":"import-statement","original":"./context"},{"path":"src/hooks/useRouter.tsx","kind":"import-statement","original":"./hooks/useRouter"}],"format":"esm"}},"outputs":{"dist/esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":27326},"dist/esm/index.mjs":{"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@real-router/helpers","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"@real-router/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@real-router/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"exports":["BaseLink","ConnectedLink","Link","NavigatorContext","RouteContext","RouterContext","RouterProvider","useNavigator","useRoute","useRouteNode","useRouter"],"entryPoint":"src/index.ts","inputs":{"src/components/BaseLink.tsx":{"bytesInOutput":2638},"src/constants.ts":{"bytesInOutput":77},"src/hooks/useIsActiveRoute.tsx":{"bytesInOutput":1732},"src/hooks/useRouterSubscription.tsx":{"bytesInOutput":1386},"src/hooks/useStableValue.tsx":{"bytesInOutput":157},"src/utils.ts":{"bytesInOutput":816},"src/index.ts":{"bytesInOutput":0},"src/hooks/useRouter.tsx":{"bytesInOutput":202},"src/context.ts":{"bytesInOutput":164},"src/components/Link.tsx":{"bytesInOutput":243},"src/hooks/useRoute.tsx":{"bytesInOutput":225},"src/components/ConnectedLink.tsx":{"bytesInOutput":269},"src/hooks/useRouteNode.tsx":{"bytesInOutput":1188},"src/hooks/useNavigator.tsx":{"bytesInOutput":229},"src/RouterProvider.tsx":{"bytesInOutput":1183}},"bytes":11185}}}