@real-router/react 0.24.1 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +127 -7
- package/dist/cjs/Await-whr-pcvo.d.ts +41 -0
- package/dist/cjs/Await-whr-pcvo.d.ts.map +1 -0
- package/dist/cjs/HttpStatusProvider-Dh6cMr95.d.ts +143 -0
- package/dist/cjs/HttpStatusProvider-Dh6cMr95.d.ts.map +1 -0
- package/dist/cjs/Link-BspioC76.js +2 -0
- package/dist/cjs/Link-BspioC76.js.map +1 -0
- package/dist/cjs/RouterErrorBoundary-BlJmaoyr.d.ts +47 -0
- package/dist/cjs/RouterErrorBoundary-BlJmaoyr.d.ts.map +1 -0
- package/dist/cjs/{RouterProvider-Bj1_NbpA.d.ts → RouterProvider-DvC9mViF.d.ts} +2 -2
- package/dist/cjs/RouterProvider-DvC9mViF.d.ts.map +1 -0
- package/dist/cjs/RouterProvider-fJvMO5Tc.js +2 -0
- package/dist/cjs/RouterProvider-fJvMO5Tc.js.map +1 -0
- package/dist/cjs/createHttpStatusSink-D_6IiR5E.js +2 -0
- package/dist/cjs/createHttpStatusSink-D_6IiR5E.js.map +1 -0
- package/dist/cjs/index.d.ts +6 -281
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.react-server.d.ts +5 -0
- package/dist/cjs/index.react-server.js +0 -0
- package/dist/cjs/ink.d.ts +2 -1
- package/dist/cjs/ink.d.ts.map +1 -1
- package/dist/cjs/ink.js +1 -1
- package/dist/cjs/ink.js.map +1 -1
- package/dist/cjs/legacy.d.ts +3 -2
- package/dist/cjs/legacy.js +1 -1
- package/dist/cjs/legacy.ssr.d.ts +3 -0
- package/dist/cjs/legacy.ssr.js +1 -0
- package/dist/cjs/ssr.d.ts +4 -0
- package/dist/cjs/ssr.js +2 -0
- package/dist/cjs/ssr.js.map +1 -0
- package/dist/cjs/ssr.react-server.d.ts +3 -0
- package/dist/cjs/ssr.react-server.js +0 -0
- package/dist/cjs/useDeferred-DE5YUsfa.d.ts +24 -0
- package/dist/cjs/useDeferred-DE5YUsfa.d.ts.map +1 -0
- package/dist/cjs/useRoute-Dudo2K_0.js +2 -0
- package/dist/cjs/useRoute-Dudo2K_0.js.map +1 -0
- package/dist/cjs/useRouteEnter-gfy65W0D.d.ts +279 -0
- package/dist/cjs/useRouteEnter-gfy65W0D.d.ts.map +1 -0
- package/dist/cjs/useRouterTransition-BfayPs0h.d.ts +56 -0
- package/dist/cjs/useRouterTransition-BfayPs0h.d.ts.map +1 -0
- package/dist/esm/Await-qSmJ-ZuN.d.mts +41 -0
- package/dist/esm/Await-qSmJ-ZuN.d.mts.map +1 -0
- package/dist/esm/HttpStatusProvider-Cy9GSANm.d.mts +143 -0
- package/dist/esm/HttpStatusProvider-Cy9GSANm.d.mts.map +1 -0
- package/dist/esm/Link-BQol2GYb.mjs +2 -0
- package/dist/esm/Link-BQol2GYb.mjs.map +1 -0
- package/dist/esm/RouterErrorBoundary-C-MH_yrP.d.mts +47 -0
- package/dist/esm/RouterErrorBoundary-C-MH_yrP.d.mts.map +1 -0
- package/dist/esm/{RouterProvider-Dr3X_vbc.d.mts → RouterProvider-D_ZlPVAC.d.mts} +2 -2
- package/dist/esm/RouterProvider-D_ZlPVAC.d.mts.map +1 -0
- package/dist/esm/RouterProvider-a9y9bqji.mjs +2 -0
- package/dist/esm/RouterProvider-a9y9bqji.mjs.map +1 -0
- package/dist/esm/createHttpStatusSink-BXWVamHE.mjs +2 -0
- package/dist/esm/createHttpStatusSink-BXWVamHE.mjs.map +1 -0
- package/dist/esm/index.d.mts +6 -281
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.react-server.d.mts +5 -0
- package/dist/esm/index.react-server.mjs +0 -0
- package/dist/esm/ink.d.mts +2 -1
- package/dist/esm/ink.d.mts.map +1 -1
- package/dist/esm/ink.mjs +1 -1
- package/dist/esm/ink.mjs.map +1 -1
- package/dist/esm/legacy.d.mts +3 -2
- package/dist/esm/legacy.mjs +1 -1
- package/dist/esm/legacy.ssr.d.mts +3 -0
- package/dist/esm/legacy.ssr.mjs +1 -0
- package/dist/esm/ssr.d.mts +4 -0
- package/dist/esm/ssr.mjs +2 -0
- package/dist/esm/ssr.mjs.map +1 -0
- package/dist/esm/ssr.react-server.d.mts +3 -0
- package/dist/esm/ssr.react-server.mjs +0 -0
- package/dist/esm/useDeferred-B5Qy7ttQ.d.mts +24 -0
- package/dist/esm/useDeferred-B5Qy7ttQ.d.mts.map +1 -0
- package/dist/esm/useRoute-Bta1jyl2.mjs +2 -0
- package/dist/esm/useRoute-Bta1jyl2.mjs.map +1 -0
- package/dist/esm/useRouteEnter-CxjYofFa.d.mts +279 -0
- package/dist/esm/useRouteEnter-CxjYofFa.d.mts.map +1 -0
- package/dist/esm/useRouterTransition-CI1P95ZQ.d.mts +56 -0
- package/dist/esm/useRouterTransition-CI1P95ZQ.d.mts.map +1 -0
- package/package.json +46 -4
- package/src/components/Await.tsx +46 -0
- package/src/components/ClientOnly.tsx +25 -0
- package/src/components/HttpStatusCode.tsx +66 -0
- package/src/components/HttpStatusProvider.tsx +26 -0
- package/src/components/InkLink.tsx +44 -22
- package/src/components/Link.tsx +32 -36
- package/src/components/RouterErrorBoundary.tsx +21 -6
- package/src/components/ServerOnly.tsx +26 -0
- package/src/components/Streamed.tsx +30 -0
- package/src/components/modern/RouteView/RouteView.tsx +9 -3
- package/src/components/modern/RouteView/helpers.tsx +26 -16
- package/src/constants.ts +7 -8
- package/src/context.ts +4 -2
- package/src/hooks/useDeferred.tsx +34 -0
- package/src/hooks/useIsActiveRoute.tsx +17 -9
- package/src/hooks/useNavigator.tsx +0 -2
- package/src/hooks/useRoute.tsx +10 -7
- package/src/hooks/useRouter.tsx +0 -2
- package/src/index.react-server.ts +33 -0
- package/src/index.ts +5 -0
- package/src/legacy.ssr.ts +35 -0
- package/src/legacy.ts +4 -0
- package/src/ssr.react-server.ts +21 -0
- package/src/ssr.ts +43 -0
- package/src/utils/createHttpStatusSink.ts +27 -0
- package/dist/cjs/Link-DYvAnJlk.js +0 -2
- package/dist/cjs/Link-DYvAnJlk.js.map +0 -1
- package/dist/cjs/RouterProvider-Bj1_NbpA.d.ts.map +0 -1
- package/dist/cjs/RouterProvider-CfBNR-k7.js +0 -2
- package/dist/cjs/RouterProvider-CfBNR-k7.js.map +0 -1
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/useRouterTransition-BYit_9Mt.d.ts +0 -92
- package/dist/cjs/useRouterTransition-BYit_9Mt.d.ts.map +0 -1
- package/dist/esm/Link-C7upxMc8.mjs +0 -2
- package/dist/esm/Link-C7upxMc8.mjs.map +0 -1
- package/dist/esm/RouterProvider-CS2ZoONm.mjs +0 -2
- package/dist/esm/RouterProvider-CS2ZoONm.mjs.map +0 -1
- package/dist/esm/RouterProvider-Dr3X_vbc.d.mts.map +0 -1
- package/dist/esm/index.d.mts.map +0 -1
- package/dist/esm/useRouterTransition-B65Wvngj.d.mts +0 -92
- package/dist/esm/useRouterTransition-B65Wvngj.d.mts.map +0 -1
|
File without changes
|
package/dist/cjs/ink.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as RouterErrorBoundaryProps, t as RouterErrorBoundary } from "./RouterErrorBoundary-BlJmaoyr.js";
|
|
2
|
+
import { a as useNavigator, i as useRouteUtils, n as useRouteNode, o as useRouter, r as useRoute, t as useRouterTransition } from "./useRouterTransition-BfayPs0h.js";
|
|
2
3
|
import { FC, ReactNode } from "react";
|
|
3
4
|
import { NavigationOptions, Navigator, Params, Router } from "@real-router/core";
|
|
4
5
|
import { RouterTransitionSnapshot } from "@real-router/sources";
|
package/dist/cjs/ink.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ink.d.ts","names":[],"sources":["../../src/ink-types.ts","../../src/components/InkLink.tsx","../../src/components/InkRouterProvider.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ink.d.ts","names":[],"sources":["../../src/ink-types.ts","../../src/components/InkLink.tsx","../../src/components/InkRouterProvider.tsx"],"mappings":";;;;;;;UAGiB,YAAA,WAAuB,MAAA,GAAS,MAAA;EAC/C,SAAA;EACA,WAAA,GAAc,CAAA;EACd,YAAA,GAAe,iBAAA;EACf,YAAA;EACA,iBAAA;EACA,QAAA,GAAW,SAAA;EACX,KAAA;EACA,WAAA;EACA,UAAA;EACA,OAAA;EACA,aAAA;EACA,YAAA;EACA,EAAA;EACA,SAAA;EACA,QAAA;AAAA;AAAA,UAGe,sBAAA;EACf,MAAA,EAAQ,MAAA;EACR,QAAA,GAAW,SAAA;AAAA;;;cCyGA,OAAA,EAAS,EAAA,CAAG,YAAA;;;cC3HZ,iBAAA,EAAmB,EAAA,CAAG,sBAAA"}
|
package/dist/cjs/ink.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./RouterProvider-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useRoute-Dudo2K_0.js`),t=require(`./RouterProvider-fJvMO5Tc.js`);let n=require(`react`),r=require(`react/jsx-runtime`),i=require(`ink`);function a(e,t,n,r,i){return e?n??r??i:t?r??i:i}function o(e,n){return e.routeName===n.routeName&&e.activeStrict===n.activeStrict&&e.ignoreQueryParams===n.ignoreQueryParams&&e.color===n.color&&e.activeColor===n.activeColor&&e.focusColor===n.focusColor&&e.inverse===n.inverse&&e.activeInverse===n.activeInverse&&e.focusInverse===n.focusInverse&&e.id===n.id&&e.autoFocus===n.autoFocus&&e.onSelect===n.onSelect&&e.children===n.children&&t.u(e.routeParams,n.routeParams)&&t.u(e.routeOptions,n.routeOptions)}const s=(0,n.memo)(({routeName:n,routeParams:o=e.r,routeOptions:s=e.n,activeStrict:c=!1,ignoreQueryParams:l=!0,color:u,activeColor:d,focusColor:f,inverse:p,activeInverse:m,focusInverse:h,id:g,autoFocus:_,onSelect:v,children:y})=>{let b=t.p(),{isFocused:x}=(0,i.useFocus)({...g!==void 0&&{id:g},..._!==void 0&&{autoFocus:_}}),S=t.o(n,o,c,l);(0,i.useInput)((e,t)=>{t.return&&(v?.(),b.navigate(n,o,s).catch(()=>{}))},{isActive:x});let C=a(x,S,f,d,u),w=a(x,S,h,m,p),T={};return C!==void 0&&(T.color=C),w!==void 0&&(T.inverse=w),(0,r.jsx)(i.Text,{...T,children:y})},o);s.displayName=`InkLink`;const c=({router:e,children:n})=>(0,r.jsx)(t.t,{router:e,children:n});exports.InkLink=s,exports.InkRouterProvider=c,exports.RouterErrorBoundary=t.a,exports.useNavigator=t.i,exports.useRoute=e.t,exports.useRouteNode=t.f,exports.useRouteUtils=t.r,exports.useRouter=t.p,exports.useRouterTransition=t.n;
|
|
2
2
|
//# sourceMappingURL=ink.js.map
|
package/dist/cjs/ink.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ink.js","names":["shallowEqual","EMPTY_PARAMS","EMPTY_OPTIONS","useRouter","useIsActiveRoute","Text","RouterProvider"],"sources":["../../src/components/InkLink.tsx","../../src/components/InkRouterProvider.tsx"],"sourcesContent":["import { Text, useFocus, useInput } from \"ink\";\nimport { memo
|
|
1
|
+
{"version":3,"file":"ink.js","names":["shallowEqual","EMPTY_PARAMS","EMPTY_OPTIONS","useRouter","useIsActiveRoute","Text","RouterProvider"],"sources":["../../src/components/InkLink.tsx","../../src/components/InkRouterProvider.tsx"],"sourcesContent":["import { Text, useFocus, useInput } from \"ink\";\nimport { memo } from \"react\";\n\nimport { EMPTY_OPTIONS, EMPTY_PARAMS } from \"../constants\";\nimport { shallowEqual } from \"../dom-utils\";\nimport { useIsActiveRoute } from \"../hooks/useIsActiveRoute\";\nimport { useRouter } from \"../hooks/useRouter\";\n\nimport type { InkLinkProps } from \"../ink-types\";\nimport type { FC } from \"react\";\n\n/**\n * Pick the most specific value across focus / active / base priority.\n * Focus wins over active; active wins over base. Each layer falls through\n * to the next when its value is undefined, matching the original explicit\n * if/else cascade for both `color` and `inverse`.\n */\nfunction pickPriority<T>(\n isFocused: boolean,\n isRouteActive: boolean,\n focusValue: T | undefined,\n activeValue: T | undefined,\n baseValue: T | undefined,\n): T | undefined {\n if (isFocused) {\n return focusValue ?? activeValue ?? baseValue;\n }\n\n if (isRouteActive) {\n return activeValue ?? baseValue;\n }\n\n return baseValue;\n}\n\nfunction areInkLinkPropsEqual(\n prev: Readonly<InkLinkProps>,\n next: Readonly<InkLinkProps>,\n): boolean {\n return (\n prev.routeName === next.routeName &&\n prev.activeStrict === next.activeStrict &&\n prev.ignoreQueryParams === next.ignoreQueryParams &&\n prev.color === next.color &&\n prev.activeColor === next.activeColor &&\n prev.focusColor === next.focusColor &&\n prev.inverse === next.inverse &&\n prev.activeInverse === next.activeInverse &&\n prev.focusInverse === next.focusInverse &&\n prev.id === next.id &&\n prev.autoFocus === next.autoFocus &&\n prev.onSelect === next.onSelect &&\n prev.children === next.children &&\n shallowEqual(prev.routeParams, next.routeParams) &&\n shallowEqual(prev.routeOptions, next.routeOptions)\n );\n}\n\nconst InkLinkImpl: FC<InkLinkProps> = ({\n routeName,\n routeParams = EMPTY_PARAMS,\n routeOptions = EMPTY_OPTIONS,\n activeStrict = false,\n ignoreQueryParams = true,\n color,\n activeColor,\n focusColor,\n inverse,\n activeInverse,\n focusInverse,\n id,\n autoFocus,\n onSelect,\n children,\n}) => {\n const router = useRouter();\n const { isFocused } = useFocus({\n ...(id !== undefined && { id }),\n ...(autoFocus !== undefined && { autoFocus }),\n });\n const isRouteActive = useIsActiveRoute(\n routeName,\n routeParams,\n activeStrict,\n ignoreQueryParams,\n );\n\n // No useCallback: `useInput` consumes the handler via its own internal\n // ref; a stable identity provides no cache-bail-out benefit here. Same\n // reasoning as Link's handleClick.\n useInput(\n (_input, key) => {\n if (key.return) {\n onSelect?.();\n router.navigate(routeName, routeParams, routeOptions).catch(() => {});\n }\n },\n { isActive: isFocused },\n );\n\n const finalColor = pickPriority(\n isFocused,\n isRouteActive,\n focusColor,\n activeColor,\n color,\n );\n const finalInverse = pickPriority(\n isFocused,\n isRouteActive,\n focusInverse,\n activeInverse,\n inverse,\n );\n\n const textProps: { color?: string; inverse?: boolean } = {};\n\n if (finalColor !== undefined) {\n textProps.color = finalColor;\n }\n\n if (finalInverse !== undefined) {\n textProps.inverse = finalInverse;\n }\n\n return <Text {...textProps}>{children}</Text>;\n};\n\nexport const InkLink: FC<InkLinkProps> = memo(\n InkLinkImpl,\n areInkLinkPropsEqual,\n);\n\nInkLink.displayName = \"InkLink\";\n","import { RouterProvider } from \"../RouterProvider\";\n\nimport type { InkRouterProviderProps } from \"../ink-types\";\nimport type { FC } from \"react\";\n\nexport const InkRouterProvider: FC<InkRouterProviderProps> = ({\n router,\n children,\n}) => <RouterProvider router={router}>{children}</RouterProvider>;\n"],"mappings":"8NAiBA,SAAS,EACP,EACA,EACA,EACA,EACA,EACe,CASf,OARI,EACK,GAAc,GAAe,EAGlC,EACK,GAAe,EAGjB,EAGT,SAAS,EACP,EACA,EACS,CACT,OACE,EAAK,YAAc,EAAK,WACxB,EAAK,eAAiB,EAAK,cAC3B,EAAK,oBAAsB,EAAK,mBAChC,EAAK,QAAU,EAAK,OACpB,EAAK,cAAgB,EAAK,aAC1B,EAAK,aAAe,EAAK,YACzB,EAAK,UAAY,EAAK,SACtB,EAAK,gBAAkB,EAAK,eAC5B,EAAK,eAAiB,EAAK,cAC3B,EAAK,KAAO,EAAK,IACjB,EAAK,YAAc,EAAK,WACxB,EAAK,WAAa,EAAK,UACvB,EAAK,WAAa,EAAK,UACvBA,EAAAA,EAAa,EAAK,YAAa,EAAK,YAAY,EAChDA,EAAAA,EAAa,EAAK,aAAc,EAAK,aAAa,CA0EtD,MAAa,GAAA,EAAA,EAAA,OAtE0B,CACrC,YACA,cAAcC,EAAAA,EACd,eAAeC,EAAAA,EACf,eAAe,GACf,oBAAoB,GACpB,QACA,cACA,aACA,UACA,gBACA,eACA,KACA,YACA,WACA,cACI,CACJ,IAAM,EAASC,EAAAA,GAAW,CACpB,CAAE,cAAA,EAAA,EAAA,UAAuB,CAC7B,GAAI,IAAO,IAAA,IAAa,CAAE,KAAI,CAC9B,GAAI,IAAc,IAAA,IAAa,CAAE,YAAW,CAC7C,CAAC,CACI,EAAgBC,EAAAA,EACpB,EACA,EACA,EACA,EACD,EAKD,EAAA,EAAA,WACG,EAAQ,IAAQ,CACX,EAAI,SACN,KAAY,CACZ,EAAO,SAAS,EAAW,EAAa,EAAa,CAAC,UAAY,GAAG,GAGzE,CAAE,SAAU,EAAW,CACxB,CAED,IAAM,EAAa,EACjB,EACA,EACA,EACA,EACA,EACD,CACK,EAAe,EACnB,EACA,EACA,EACA,EACA,EACD,CAEK,EAAmD,EAAE,CAU3D,OARI,IAAe,IAAA,KACjB,EAAU,MAAQ,GAGhB,IAAiB,IAAA,KACnB,EAAU,QAAU,IAGf,EAAA,EAAA,KAACC,EAAAA,KAAD,CAAM,GAAI,EAAY,WAAgB,CAAA,EAK7C,EACD,CAED,EAAQ,YAAc,UChItB,MAAa,GAAiD,CAC5D,SACA,eACI,EAAA,EAAA,KAACC,EAAAA,EAAD,CAAwB,SAAS,WAA0B,CAAA"}
|
package/dist/cjs/legacy.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as Link, t as RouterProvider } from "./RouterProvider-
|
|
1
|
+
import { n as RouterErrorBoundaryProps, r as LinkProps, t as RouterErrorBoundary } from "./RouterErrorBoundary-BlJmaoyr.js";
|
|
2
|
+
import { n as Link, t as RouterProvider } from "./RouterProvider-DvC9mViF.js";
|
|
3
|
+
import { a as useNavigator, i as useRouteUtils, n as useRouteNode, o as useRouter, r as useRoute, t as useRouterTransition } from "./useRouterTransition-BfayPs0h.js";
|
|
3
4
|
import { Navigator } from "@real-router/core";
|
|
4
5
|
import { RouterTransitionSnapshot } from "@real-router/sources";
|
|
5
6
|
export { Link, type LinkProps, type Navigator, RouterErrorBoundary, type RouterErrorBoundaryProps, RouterProvider, type RouterTransitionSnapshot, useNavigator, useRoute, useRouteNode, useRouteUtils, useRouter, useRouterTransition };
|
package/dist/cjs/legacy.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useRoute-Dudo2K_0.js`),t=require(`./RouterProvider-fJvMO5Tc.js`),n=require(`./Link-BspioC76.js`);exports.Link=n.t,exports.RouterErrorBoundary=t.a,exports.RouterProvider=t.t,exports.useNavigator=t.i,exports.useRoute=e.t,exports.useRouteNode=t.f,exports.useRouteUtils=t.r,exports.useRouter=t.p,exports.useRouterTransition=t.n;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as HttpStatusCode, c as StreamedProps, d as ClientOnly, f as ClientOnlyProps, i as createHttpStatusSink, l as ServerOnly, n as HttpStatusProviderProps, o as HttpStatusCodeProps, r as HttpStatusSink, s as Streamed, t as HttpStatusProvider, u as ServerOnlyProps } from "./HttpStatusProvider-Dh6cMr95.js";
|
|
2
|
+
import { t as useDeferred } from "./useDeferred-DE5YUsfa.js";
|
|
3
|
+
export { ClientOnly, type ClientOnlyProps, HttpStatusCode, type HttpStatusCodeProps, HttpStatusProvider, type HttpStatusProviderProps, type HttpStatusSink, ServerOnly, type ServerOnlyProps, Streamed, type StreamedProps, createHttpStatusSink, useDeferred };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./createHttpStatusSink-D_6IiR5E.js`);exports.ClientOnly=e.s,exports.HttpStatusCode=e.n,exports.HttpStatusProvider=e.r,exports.ServerOnly=e.o,exports.Streamed=e.i,exports.createHttpStatusSink=e.t,exports.useDeferred=e.a;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { a as HttpStatusCode, c as StreamedProps, d as ClientOnly, f as ClientOnlyProps, i as createHttpStatusSink, l as ServerOnly, n as HttpStatusProviderProps, o as HttpStatusCodeProps, r as HttpStatusSink, s as Streamed, t as HttpStatusProvider, u as ServerOnlyProps } from "./HttpStatusProvider-Dh6cMr95.js";
|
|
2
|
+
import { t as useDeferred } from "./useDeferred-DE5YUsfa.js";
|
|
3
|
+
import { n as AwaitProps, t as Await } from "./Await-whr-pcvo.js";
|
|
4
|
+
export { Await, type AwaitProps, ClientOnly, type ClientOnlyProps, HttpStatusCode, type HttpStatusCodeProps, HttpStatusProvider, type HttpStatusProviderProps, type HttpStatusSink, ServerOnly, type ServerOnlyProps, Streamed, type StreamedProps, createHttpStatusSink, useDeferred };
|
package/dist/cjs/ssr.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./createHttpStatusSink-D_6IiR5E.js`);let t=require(`react`);function n({name:n,children:r}){return r((0,t.use)(e.a(n)))}exports.Await=n,exports.ClientOnly=e.s,exports.HttpStatusCode=e.n,exports.HttpStatusProvider=e.r,exports.ServerOnly=e.o,exports.Streamed=e.i,exports.createHttpStatusSink=e.t,exports.useDeferred=e.a;
|
|
2
|
+
//# sourceMappingURL=ssr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssr.js","names":["useDeferred"],"sources":["../../src/components/Await.tsx"],"sourcesContent":["import { use } from \"react\";\n\nimport { useDeferred } from \"../hooks/useDeferred\";\n\nimport type { ReactNode } from \"react\";\n\nexport interface AwaitProps<T> {\n /** Deferred key declared in the loader's `defer({ deferred: { <name>: ... } })`. */\n readonly name: string;\n /** Render the resolved value. Suspends while pending; throws inside the\n * nearest Error Boundary on rejection. */\n readonly children: (value: T) => ReactNode;\n}\n\n/**\n * Ergonomic wrapper around `useDeferred(name)` + React 19's `use(promise)`.\n *\n * ```tsx\n * <Suspense fallback={<Spinner />}>\n * <Await<Review[]> name=\"reviews\">\n * {(reviews) => <ReviewList items={reviews} />}\n * </Await>\n * </Suspense>\n * ```\n *\n * Equivalent to:\n *\n * ```tsx\n * function Inner() {\n * const reviews = use(useDeferred<Review[]>(\"reviews\"));\n * return <ReviewList items={reviews} />;\n * }\n * ```\n *\n * Pick `<Await>` for cross-adapter consistency with the SvelteKit\n * `{#await}` / Solid `<Await/>` shape; pick the inline `use(useDeferred(...))`\n * form if you prefer one fewer abstraction.\n */\nexport function Await<T = unknown>({\n name,\n children,\n}: AwaitProps<T>): ReactNode {\n const value = use(useDeferred<T>(name));\n\n return children(value);\n}\n"],"mappings":"gJAsCA,SAAgB,EAAmB,CACjC,OACA,YAC2B,CAG3B,OAAO,GAAA,EAAA,EAAA,KAFWA,EAAAA,EAAe,EAAK,CAEjB,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { c as StreamedProps, f as ClientOnlyProps, n as HttpStatusProviderProps, o as HttpStatusCodeProps, r as HttpStatusSink, u as ServerOnlyProps } from "./HttpStatusProvider-Dh6cMr95.js";
|
|
2
|
+
import { n as AwaitProps } from "./Await-whr-pcvo.js";
|
|
3
|
+
export { type AwaitProps, type ClientOnlyProps, type HttpStatusCodeProps, type HttpStatusProviderProps, type HttpStatusSink, type ServerOnlyProps, type StreamedProps };
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/hooks/useDeferred.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Read a deferred promise published by `defer({ deferred: { <key>: Promise } })`
|
|
4
|
+
* inside an SSR data loader.
|
|
5
|
+
*
|
|
6
|
+
* - **Server render**: returns the actual loader-returned promise. Combine
|
|
7
|
+
* with `<Suspense>` + `use(promise)` for native streaming via React 19's
|
|
8
|
+
* `renderToReadableStream`.
|
|
9
|
+
* - **Post-hydration**: returns a registry-backed promise; the inline
|
|
10
|
+
* `<script>__rrDefer__("key", json)</script>` tags emitted by the server
|
|
11
|
+
* stream resolve it. `use()` returns synchronously once the registry
|
|
12
|
+
* settles.
|
|
13
|
+
* - **Unknown key**: returns a never-resolving promise — Suspense boundary
|
|
14
|
+
* stays in fallback. This surfaces consumer/loader key drift as a visible
|
|
15
|
+
* loading state instead of a silent runtime error.
|
|
16
|
+
*
|
|
17
|
+
* The hook subscribes to `RouteContext`, so it re-runs on every navigation.
|
|
18
|
+
* Promise reference identity is stable across renders within the same
|
|
19
|
+
* navigation — `use()` will not re-suspend on rerenders.
|
|
20
|
+
*/
|
|
21
|
+
declare function useDeferred<T = unknown>(key: string): Promise<T>;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { useDeferred as t };
|
|
24
|
+
//# sourceMappingURL=useDeferred-DE5YUsfa.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDeferred-DE5YUsfa.d.ts","names":[],"sources":["../../src/hooks/useDeferred.tsx"],"mappings":";;AA0BA;;;;;;;;;;;;;;;;;;iBAAgB,WAAA,aAAA,CAAyB,GAAA,WAAc,OAAA,CAAQ,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
let e=require(`react`);const t=(0,e.createContext)(null),n=(0,e.createContext)(null),r=(0,e.createContext)(null),i=Object.freeze({}),a=Object.freeze({}),o=new Promise(()=>{}),s=()=>{let n=(0,e.useContext)(t);if(!n)throw Error(`useRoute must be used within a RouterProvider`);if(!n.route)throw Error(`useRoute called with no active route. Did you forget to await router.start() before rendering, or is the router stopped/disposed?`);return n};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return s}});
|
|
2
|
+
//# sourceMappingURL=useRoute-Dudo2K_0.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRoute-Dudo2K_0.js","names":[],"sources":["../../src/context.ts","../../src/constants.ts","../../src/hooks/useRoute.tsx"],"sourcesContent":["import { createContext } from \"react\";\n\nimport type { RouteContext as RouteContextType } from \"./types\";\nimport type { Router, Navigator } from \"@real-router/core\";\n\n// All three contexts use the `<T | null>` shape with a `null` default. Hooks\n// (useRouter / useRoute / useNavigator) treat a `null` read as\n// \"RouterProvider missing\" and throw — this surfaces wiring mistakes loudly\n// instead of letting consumers chase an undefined router instance.\nexport const RouteContext = createContext<RouteContextType | null>(null);\n\nexport const RouterContext = createContext<Router | null>(null);\n\nexport const NavigatorContext = createContext<Navigator | null>(null);\n","export const EMPTY_PARAMS = Object.freeze({});\n\nexport const EMPTY_OPTIONS = Object.freeze({});\n\n// Singleton forever-pending promise — module-scope so `useDeferred(unknownKey)`\n// returns a stable reference across calls (Suspense boundary doesn't retry).\nexport const NEVER_PROMISE = new Promise<never>(() => {\n // Intentionally never resolves — surfaces a forever-pending Suspense boundary\n // when a key is requested that the loader never declared.\n});\n","import { useContext } from \"react\";\n\nimport { RouteContext } from \"../context\";\n\nimport type { RouteContext as RouteContextType } from \"../types\";\nimport type { Params, State } from \"@real-router/core\";\n\n/**\n * Return shape of `useRoute<P>()` — the context with `route` narrowed to\n * `State<P>` (non-nullable). Promoting the intersection to a named alias\n * keeps the function signature and the cast site in sync.\n */\ntype RouteHookResult<P extends Params = Params> = Omit<\n RouteContextType<P>,\n \"route\"\n> & { route: State<P> };\n\nexport const useRoute = <P extends Params = Params>(): RouteHookResult<P> => {\n const routeContext = useContext(RouteContext);\n\n if (!routeContext) {\n throw new Error(\"useRoute must be used within a RouterProvider\");\n }\n\n if (!routeContext.route) {\n throw new Error(\n \"useRoute called with no active route. Did you forget to await router.start() before rendering, or is the router stopped/disposed?\",\n );\n }\n\n return routeContext as RouteHookResult<P>;\n};\n"],"mappings":"uBASA,MAAa,GAAA,EAAA,EAAA,eAAsD,KAAK,CAE3D,GAAA,EAAA,EAAA,eAA6C,KAAK,CAElD,GAAA,EAAA,EAAA,eAAmD,KAAK,CCbxD,EAAe,OAAO,OAAO,EAAE,CAAC,CAEhC,EAAgB,OAAO,OAAO,EAAE,CAAC,CAIjC,EAAgB,IAAI,YAAqB,GAGpD,CCQW,MAAgE,CAC3E,IAAM,GAAA,EAAA,EAAA,YAA0B,EAAa,CAE7C,GAAI,CAAC,EACH,MAAU,MAAM,gDAAgD,CAGlE,GAAI,CAAC,EAAa,MAChB,MAAU,MACR,oIACD,CAGH,OAAO"}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
|
+
import { State } from "@real-router/core";
|
|
3
|
+
|
|
4
|
+
//#region src/components/modern/RouteView/types.d.ts
|
|
5
|
+
interface RouteViewProps {
|
|
6
|
+
/** Route tree node name to subscribe to. "" for root. */
|
|
7
|
+
readonly nodeName: string;
|
|
8
|
+
/** <RouteView.Match>, <RouteView.Self>, and <RouteView.NotFound> elements. */
|
|
9
|
+
readonly children: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
interface MatchProps {
|
|
12
|
+
/** Route segment to match against. */
|
|
13
|
+
readonly segment: string;
|
|
14
|
+
/** Exact match only (no descendants). Defaults to false. */
|
|
15
|
+
readonly exact?: boolean;
|
|
16
|
+
/** Preserve component state when deactivated (React Activity). Defaults to false. */
|
|
17
|
+
readonly keepAlive?: boolean;
|
|
18
|
+
/** Fallback content to show while children are suspended. */
|
|
19
|
+
readonly fallback?: ReactNode;
|
|
20
|
+
/** Content to render when matched. */
|
|
21
|
+
readonly children: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
interface SelfProps {
|
|
24
|
+
/**
|
|
25
|
+
* Fallback content to show while children are suspended.
|
|
26
|
+
*
|
|
27
|
+
* Symmetric with `<RouteView.Match fallback>` — wraps children in
|
|
28
|
+
* `<Suspense>` when defined.
|
|
29
|
+
*/
|
|
30
|
+
readonly fallback?: ReactNode;
|
|
31
|
+
/** Content to render when the active route name equals the parent RouteView's nodeName. */
|
|
32
|
+
readonly children: ReactNode;
|
|
33
|
+
}
|
|
34
|
+
interface NotFoundProps {
|
|
35
|
+
/** Content to render on UNKNOWN_ROUTE. */
|
|
36
|
+
readonly children: ReactNode;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/components/modern/RouteView/components.d.ts
|
|
40
|
+
declare function Match(_props: MatchProps): null;
|
|
41
|
+
declare namespace Match {
|
|
42
|
+
var displayName: string;
|
|
43
|
+
}
|
|
44
|
+
declare function Self(_props: SelfProps): null;
|
|
45
|
+
declare namespace Self {
|
|
46
|
+
var displayName: string;
|
|
47
|
+
}
|
|
48
|
+
declare function NotFound(_props: NotFoundProps): null;
|
|
49
|
+
declare namespace NotFound {
|
|
50
|
+
var displayName: string;
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/components/modern/RouteView/RouteView.d.ts
|
|
54
|
+
declare function RouteViewRoot({
|
|
55
|
+
nodeName,
|
|
56
|
+
children
|
|
57
|
+
}: Readonly<RouteViewProps>): ReactElement | null;
|
|
58
|
+
declare namespace RouteViewRoot {
|
|
59
|
+
var displayName: string;
|
|
60
|
+
}
|
|
61
|
+
declare const RouteView: typeof RouteViewRoot & {
|
|
62
|
+
Match: typeof Match;
|
|
63
|
+
Self: typeof Self;
|
|
64
|
+
NotFound: typeof NotFound;
|
|
65
|
+
};
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/hooks/useRouteExit.d.ts
|
|
68
|
+
interface RouteExitContext {
|
|
69
|
+
/** The route being left. */
|
|
70
|
+
route: State;
|
|
71
|
+
/** The route being navigated to. */
|
|
72
|
+
nextRoute: State;
|
|
73
|
+
/**
|
|
74
|
+
* AbortSignal that fires when this navigation is superseded by a later
|
|
75
|
+
* one (rapid clicks). Already filtered: when the handler runs,
|
|
76
|
+
* `signal.aborted` is guaranteed to be `false`. Use
|
|
77
|
+
* `signal.addEventListener("abort", cleanup, { once: true })` for
|
|
78
|
+
* cleanup that must run on cancellation.
|
|
79
|
+
*/
|
|
80
|
+
signal: AbortSignal;
|
|
81
|
+
}
|
|
82
|
+
interface UseRouteExitOptions {
|
|
83
|
+
/**
|
|
84
|
+
* Skip the handler when `route.name === nextRoute.name`
|
|
85
|
+
* (sort/filter/query-only navigations on the same route). Default:
|
|
86
|
+
* `true`.
|
|
87
|
+
*/
|
|
88
|
+
skipSameRoute?: boolean;
|
|
89
|
+
}
|
|
90
|
+
type RouteExitHandler = (context: RouteExitContext) => void | Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Subscribe to the router's leave-window with the universal guards baked
|
|
93
|
+
* in. Wraps `router.subscribeLeave` so consumers don't repeat the same
|
|
94
|
+
* boilerplate every time:
|
|
95
|
+
*
|
|
96
|
+
* - **Reentrant abort pre-check**: if `signal.aborted` is already `true`
|
|
97
|
+
* when the handler would run (rapid navigation superseded a slower
|
|
98
|
+
* one), the handler is skipped entirely. `signal.addEventListener(
|
|
99
|
+
* "abort", ...)` does not fire retroactively, so without this guard
|
|
100
|
+
* downstream cleanup would never trigger.
|
|
101
|
+
* - **Same-route skip**: by default, `route.name === nextRoute.name`
|
|
102
|
+
* short-circuits the handler — query-only navigations (sort, filter,
|
|
103
|
+
* pagination) skip the work. Opt out with `skipSameRoute: false`.
|
|
104
|
+
* - **Stable handler reference**: the handler can change identity on
|
|
105
|
+
* every render without causing resubscription — internal ref keeps
|
|
106
|
+
* the latest handler accessible to the long-lived subscription.
|
|
107
|
+
*
|
|
108
|
+
* Returns nothing — the subscription's lifecycle is bound to the
|
|
109
|
+
* component's mount.
|
|
110
|
+
*
|
|
111
|
+
* If the handler returns a Promise, the router blocks on it. If the
|
|
112
|
+
* Promise resolves, navigation proceeds. If it rejects, the router emits
|
|
113
|
+
* `TRANSITION_CANCELLED` (existing core behavior, no change here).
|
|
114
|
+
*
|
|
115
|
+
* @example Animation
|
|
116
|
+
* ```tsx
|
|
117
|
+
* const ref = useRef<HTMLDivElement>(null);
|
|
118
|
+
*
|
|
119
|
+
* useRouteExit(async ({ signal }) => {
|
|
120
|
+
* const el = ref.current;
|
|
121
|
+
* if (!el) return;
|
|
122
|
+
* el.classList.add("fade-out");
|
|
123
|
+
* const cleanup = () => el.classList.remove("fade-out");
|
|
124
|
+
* signal.addEventListener("abort", cleanup, { once: true });
|
|
125
|
+
* try {
|
|
126
|
+
* el.getBoundingClientRect(); // style flush
|
|
127
|
+
* await Promise.allSettled(el.getAnimations().map((a) => a.finished));
|
|
128
|
+
* } finally {
|
|
129
|
+
* cleanup();
|
|
130
|
+
* }
|
|
131
|
+
* });
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* @example Auto-save form draft
|
|
135
|
+
* ```tsx
|
|
136
|
+
* useRouteExit(async ({ signal }) => {
|
|
137
|
+
* if (formState.dirty) await api.saveDraft(formState, { signal });
|
|
138
|
+
* });
|
|
139
|
+
* ```
|
|
140
|
+
*
|
|
141
|
+
* @example Cancel inflight requests
|
|
142
|
+
* ```tsx
|
|
143
|
+
* useRouteExit(() => {
|
|
144
|
+
* inflightController.abort();
|
|
145
|
+
* });
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @example Library-coordinated exit (motion / framer-motion)
|
|
149
|
+
* ```tsx
|
|
150
|
+
* const exitResolverRef = useRef<(() => void) | null>(null);
|
|
151
|
+
*
|
|
152
|
+
* useRouteExit(({ signal }) => {
|
|
153
|
+
* return new Promise<void>((resolve) => {
|
|
154
|
+
* exitResolverRef.current = resolve;
|
|
155
|
+
* signal.addEventListener("abort", () => resolve(), { once: true });
|
|
156
|
+
* });
|
|
157
|
+
* });
|
|
158
|
+
*
|
|
159
|
+
* const onExitComplete = () => exitResolverRef.current?.();
|
|
160
|
+
* // pass onExitComplete to <AnimatePresence>
|
|
161
|
+
* ```
|
|
162
|
+
*
|
|
163
|
+
* @example Reading rich transition metadata via `nextRoute.transition`
|
|
164
|
+
* ```tsx
|
|
165
|
+
* useRouteExit(({ route, nextRoute }) => {
|
|
166
|
+
* // nextRoute.transition: TransitionMeta — preview of the upcoming nav
|
|
167
|
+
* if (nextRoute.transition.segments.deactivated.includes("products")) {
|
|
168
|
+
* // leaving the products subtree entirely — flush product-related caches
|
|
169
|
+
* productCache.clear();
|
|
170
|
+
* }
|
|
171
|
+
* if (nextRoute.transition.redirected) {
|
|
172
|
+
* // skip animation when navigation arrived via redirect
|
|
173
|
+
* return;
|
|
174
|
+
* }
|
|
175
|
+
* });
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
declare function useRouteExit(handler: RouteExitHandler, options?: UseRouteExitOptions): void;
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/hooks/useRouteEnter.d.ts
|
|
181
|
+
interface RouteEnterContext {
|
|
182
|
+
/** The route that was just activated. */
|
|
183
|
+
route: State;
|
|
184
|
+
/** The route that was active immediately before this navigation. */
|
|
185
|
+
previousRoute: State;
|
|
186
|
+
}
|
|
187
|
+
type RouteEnterHandler = (context: RouteEnterContext) => void;
|
|
188
|
+
interface UseRouteEnterOptions {
|
|
189
|
+
/**
|
|
190
|
+
* Skip the handler when `route.name === previousRoute.name`
|
|
191
|
+
* (sort/filter/query-only navigations on the same route). Default:
|
|
192
|
+
* `true`. Symmetric with `useRouteExit`'s same-name option.
|
|
193
|
+
*/
|
|
194
|
+
skipSameRoute?: boolean;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Fire `handler` once when the component mounts as a result of a
|
|
198
|
+
* navigation. Mirror of `useRouteExit` for the entry side.
|
|
199
|
+
*
|
|
200
|
+
* What this hook covers that ad-hoc `useEffect` + `useRoute()` doesn't:
|
|
201
|
+
*
|
|
202
|
+
* - **Skip-initial**: handler is skipped when there is no
|
|
203
|
+
* `previousRoute` (i.e. first-load mount). Most consumers want to
|
|
204
|
+
* fire side effects only on real navigations, not on hydration.
|
|
205
|
+
* - **Same-route skip** (default): handler is skipped when
|
|
206
|
+
* `route.name === previousRoute.name`. Sort/filter/query-only
|
|
207
|
+
* navigations re-run the effect (because `route` reference changes
|
|
208
|
+
* in `useRoute`'s snapshot), but they are not "entries" in the
|
|
209
|
+
* animation / analytics sense — the component instance has stayed
|
|
210
|
+
* mounted throughout. Opt out with `skipSameRoute: false` when
|
|
211
|
+
* the handler legitimately needs to fire on every navigation
|
|
212
|
+
* (e.g. analytics tracking each query-param flip).
|
|
213
|
+
* - **StrictMode double-mount immunity**: in dev, React's StrictMode
|
|
214
|
+
* runs every effect twice to surface bugs. Without a guard,
|
|
215
|
+
* analytics fire twice, animations restart, focus jumps. The hook
|
|
216
|
+
* tracks the last-handled `route` reference and short-circuits the
|
|
217
|
+
* second pass.
|
|
218
|
+
* - **Latest-handler ref**: the handler can change identity on every
|
|
219
|
+
* render without re-running the effect — the registered wrapper
|
|
220
|
+
* dispatches to whatever `handlerRef.current` points to.
|
|
221
|
+
* - **Mount-time `route` / `previousRoute` snapshot**: the handler
|
|
222
|
+
* receives the values that were live at the moment of mount, not
|
|
223
|
+
* the latest ones (which may have moved on if the user navigated
|
|
224
|
+
* again before the effect drained).
|
|
225
|
+
*
|
|
226
|
+
* Race-safety: `useRoute()` is wired through `useSyncExternalStore` from
|
|
227
|
+
* `@real-router/sources`, so by the time the new component's effect
|
|
228
|
+
* runs, the snapshot is the post-commit one. This is the reason we can
|
|
229
|
+
* read mount-time context from `useRoute()` instead of subscribing to
|
|
230
|
+
* `router.subscribe` directly (which fires before React schedules a
|
|
231
|
+
* re-render — the well-known race in distributed components).
|
|
232
|
+
*
|
|
233
|
+
* @example Direction-aware entry animation
|
|
234
|
+
* ```tsx
|
|
235
|
+
* useRouteEnter(({ route }) => {
|
|
236
|
+
* const direction = route.context.browser?.direction;
|
|
237
|
+
* ref.current?.classList.add(
|
|
238
|
+
* direction === "back" ? "slide-from-left" : "slide-from-right",
|
|
239
|
+
* );
|
|
240
|
+
* });
|
|
241
|
+
* ```
|
|
242
|
+
*
|
|
243
|
+
* @example Source-aware focus management
|
|
244
|
+
* ```tsx
|
|
245
|
+
* useRouteEnter(({ route }) => {
|
|
246
|
+
* if (route.context.browser?.source === "navigate") {
|
|
247
|
+
* headingRef.current?.focus();
|
|
248
|
+
* }
|
|
249
|
+
* });
|
|
250
|
+
* ```
|
|
251
|
+
*
|
|
252
|
+
* @example Analytics page-enter event (skip-initial built-in)
|
|
253
|
+
* ```tsx
|
|
254
|
+
* useRouteEnter(({ route, previousRoute }) => {
|
|
255
|
+
* analytics.track("page_enter", {
|
|
256
|
+
* route: route.name,
|
|
257
|
+
* from: previousRoute.name,
|
|
258
|
+
* });
|
|
259
|
+
* });
|
|
260
|
+
* ```
|
|
261
|
+
*
|
|
262
|
+
* @example Reading rich transition metadata via `route.transition`
|
|
263
|
+
* ```tsx
|
|
264
|
+
* useRouteEnter(({ route }) => {
|
|
265
|
+
* // route.transition: TransitionMeta — populated by core for every state
|
|
266
|
+
* if (route.transition.redirected) {
|
|
267
|
+
* showToast(`Redirected from ${route.transition.from}`);
|
|
268
|
+
* }
|
|
269
|
+
* if (route.transition.segments.activated.includes("products")) {
|
|
270
|
+
* // products subtree just became active (could be products or
|
|
271
|
+
* // products.detail). Useful for subtree-scoped side effects.
|
|
272
|
+
* }
|
|
273
|
+
* });
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
276
|
+
declare function useRouteEnter(handler: RouteEnterHandler, options?: UseRouteEnterOptions): void;
|
|
277
|
+
//#endregion
|
|
278
|
+
export { RouteExitContext as a, useRouteExit as c, NotFoundProps as d, RouteViewProps as f, useRouteEnter as i, RouteView as l, RouteEnterHandler as n, RouteExitHandler as o, SelfProps as p, UseRouteEnterOptions as r, UseRouteExitOptions as s, RouteEnterContext as t, MatchProps as u };
|
|
279
|
+
//# sourceMappingURL=useRouteEnter-gfy65W0D.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRouteEnter-gfy65W0D.d.ts","names":[],"sources":["../../src/components/modern/RouteView/types.ts","../../src/components/modern/RouteView/components.tsx","../../src/components/modern/RouteView/RouteView.tsx","../../src/hooks/useRouteExit.tsx","../../src/hooks/useRouteEnter.tsx"],"mappings":";;;;UAEiB,cAAA;;WAEN,QAAA;EAFM;EAAA,SAIN,QAAA,EAAU,SAAA;AAAA;AAAA,UAGJ,UAAA;EALN;EAAA,SAOA,OAAA;EALU;EAAA,SAOV,KAAA;EAPmB;EAAA,SASnB,SAAA;EANgB;EAAA,SAQhB,QAAA,GAAW,SAAA;EAEQ;EAAA,SAAnB,QAAA,EAAU,SAAA;AAAA;AAAA,UAGJ,SAAA;EALN;;;;;;EAAA,SAYA,QAAA,GAAW,SAAA;EAPI;EAAA,SASf,QAAA,EAAU,SAAA;AAAA;AAAA,UAGJ,aAAA;EALK;EAAA,SAOX,QAAA,EAAU,SAAA;AAAA;;;iBClCL,KAAA,CAAM,MAAA,EAAQ,UAAA;AAAA,kBAAd,KAAA;EAAA,IAAK,WAAA;AAAA;AAAA,iBAML,IAAA,CAAK,MAAA,EAAQ,SAAA;AAAA,kBAAb,IAAA;EAAA,IAAI,WAAA;AAAA;AAAA,iBAMJ,QAAA,CAAS,MAAA,EAAQ,aAAA;AAAA,kBAAjB,QAAA;EAAA,IAAQ,WAAA;AAAA;;;iBCLf,aAAA,CAAA;EACP,QAAA;EACA;AAAA,GACC,QAAA,CAAS,cAAA,IAAkB,YAAA;AAAA,kBAHrB,aAAA;EAAA,IAAa,WAAA;AAAA;AAAA,cAgDT,SAAA,SAAS,aAAA;;;;;;;UCnDL,gBAAA;;EAEf,KAAA,EAAO,KAAA;EHNQ;EGQf,SAAA,EAAW,KAAA;;;;;;;;EAQX,MAAA,EAAQ,WAAA;AAAA;AAAA,UAGO,mBAAA;EHFa;;;;;EGQ5B,aAAA;AAAA;AAAA,KAGU,gBAAA,IACV,OAAA,EAAS,gBAAA,YACC,OAAA;;;AHVZ;;;;;;;;;;AAYA;;;;;;;;AChCA;;;;;;;;;;AAMA;;;;;;;;;;AAMA;;;;;;;;;;;;;ACP0C;;;;;;;;;;;;;;;;;;;AAKA;;;;;AA6C1C;;;;;;;;;;iBCgEgB,YAAA,CACd,OAAA,EAAS,gBAAA,EACT,OAAA,GAAU,mBAAA;;;UCrHK,iBAAA;;EAEf,KAAA,EAAO,KAAA;EJNQ;EIQf,aAAA,EAAe,KAAA;AAAA;AAAA,KAGL,iBAAA,IAAqB,OAAA,EAAS,iBAAA;AAAA,UAEzB,oBAAA;EJTN;;;;AAGX;EIYE,aAAA;AAAA;;;;;;;;;;;AJCF;;;;;;;;;;AAYA;;;;;;;;AChCA;;;;;;;;;;AAMA;;;;;;;;;;AAMA;;;;;;;;;;;;;ACP0C;;;;;;;;;;;;;;;;;;;iBEiG1B,aAAA,CACd,OAAA,EAAS,iBAAA,EACT,OAAA,GAAU,oBAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { i as RouteContext } from "./RouterErrorBoundary-BlJmaoyr.js";
|
|
2
|
+
import { Navigator, Params, Router, State } from "@real-router/core";
|
|
3
|
+
import { RouteUtils } from "@real-router/route-utils";
|
|
4
|
+
import { RouterTransitionSnapshot } from "@real-router/sources";
|
|
5
|
+
|
|
6
|
+
//#region src/hooks/useRouter.d.ts
|
|
7
|
+
declare const useRouter: () => Router;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/hooks/useNavigator.d.ts
|
|
10
|
+
declare const useNavigator: () => Navigator;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/hooks/useRouteUtils.d.ts
|
|
13
|
+
/**
|
|
14
|
+
* Returns a pre-computed {@link RouteUtils} instance for the current router.
|
|
15
|
+
*
|
|
16
|
+
* `getRouteUtils` is WeakMap-cached per `RouteTreeNode` inside
|
|
17
|
+
* `@real-router/route-utils`, so the same router always returns the same
|
|
18
|
+
* `RouteUtils` instance across renders — no local cache needed in the adapter.
|
|
19
|
+
*
|
|
20
|
+
* @returns RouteUtils instance with pre-computed chains and siblings
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* const utils = useRouteUtils();
|
|
25
|
+
*
|
|
26
|
+
* utils.getChain("users.profile");
|
|
27
|
+
* // → ["users", "users.profile"]
|
|
28
|
+
*
|
|
29
|
+
* utils.getSiblings("users");
|
|
30
|
+
* // → ["admin"]
|
|
31
|
+
*
|
|
32
|
+
* utils.isDescendantOf("users.profile", "users");
|
|
33
|
+
* // → true
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare const useRouteUtils: () => RouteUtils;
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/hooks/useRoute.d.ts
|
|
39
|
+
/**
|
|
40
|
+
* Return shape of `useRoute<P>()` — the context with `route` narrowed to
|
|
41
|
+
* `State<P>` (non-nullable). Promoting the intersection to a named alias
|
|
42
|
+
* keeps the function signature and the cast site in sync.
|
|
43
|
+
*/
|
|
44
|
+
type RouteHookResult<P extends Params = Params> = Omit<RouteContext<P>, "route"> & {
|
|
45
|
+
route: State<P>;
|
|
46
|
+
};
|
|
47
|
+
declare const useRoute: <P extends Params = Params>() => RouteHookResult<P>;
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/hooks/useRouteNode.d.ts
|
|
50
|
+
declare function useRouteNode(nodeName: string): RouteContext;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/hooks/useRouterTransition.d.ts
|
|
53
|
+
declare function useRouterTransition(): RouterTransitionSnapshot;
|
|
54
|
+
//#endregion
|
|
55
|
+
export { useNavigator as a, useRouteUtils as i, useRouteNode as n, useRouter as o, useRoute as r, useRouterTransition as t };
|
|
56
|
+
//# sourceMappingURL=useRouterTransition-BfayPs0h.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRouterTransition-BfayPs0h.d.ts","names":[],"sources":["../../src/hooks/useRouter.tsx","../../src/hooks/useNavigator.tsx","../../src/hooks/useRouteUtils.tsx","../../src/hooks/useRoute.tsx","../../src/hooks/useRouteNode.tsx","../../src/hooks/useRouterTransition.tsx"],"mappings":";;;;;;cAMa,SAAA,QAAgB,MAAA;;;cCAhB,YAAA,QAAmB,SAAA;;;;;;;;ADAhC;;;;;;;;ACAA;;;;;;;;ACwBA;;cAAa,aAAA,QAAoB,UAAA;;;;;;;AFxBjC;KGMK,eAAA,WAA0B,MAAA,GAAS,MAAA,IAAU,IAAA,CAChD,YAAA,CAAiB,CAAA;EAEb,KAAA,EAAO,KAAA,CAAM,CAAA;AAAA;AAAA,cAEN,QAAA,aAAsB,MAAA,GAAS,MAAA,OAAW,eAAA,CAAgB,CAAA;;;iBCTvD,YAAA,CAAa,QAAA,WAAmB,YAAA;;;iBCDhC,mBAAA,CAAA,GAAuB,wBAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/Await.d.ts
|
|
4
|
+
interface AwaitProps<T> {
|
|
5
|
+
/** Deferred key declared in the loader's `defer({ deferred: { <name>: ... } })`. */
|
|
6
|
+
readonly name: string;
|
|
7
|
+
/** Render the resolved value. Suspends while pending; throws inside the
|
|
8
|
+
* nearest Error Boundary on rejection. */
|
|
9
|
+
readonly children: (value: T) => ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Ergonomic wrapper around `useDeferred(name)` + React 19's `use(promise)`.
|
|
13
|
+
*
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <Suspense fallback={<Spinner />}>
|
|
16
|
+
* <Await<Review[]> name="reviews">
|
|
17
|
+
* {(reviews) => <ReviewList items={reviews} />}
|
|
18
|
+
* </Await>
|
|
19
|
+
* </Suspense>
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Equivalent to:
|
|
23
|
+
*
|
|
24
|
+
* ```tsx
|
|
25
|
+
* function Inner() {
|
|
26
|
+
* const reviews = use(useDeferred<Review[]>("reviews"));
|
|
27
|
+
* return <ReviewList items={reviews} />;
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* Pick `<Await>` for cross-adapter consistency with the SvelteKit
|
|
32
|
+
* `{#await}` / Solid `<Await/>` shape; pick the inline `use(useDeferred(...))`
|
|
33
|
+
* form if you prefer one fewer abstraction.
|
|
34
|
+
*/
|
|
35
|
+
declare function Await<T = unknown>({
|
|
36
|
+
name,
|
|
37
|
+
children
|
|
38
|
+
}: AwaitProps<T>): ReactNode;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { AwaitProps as n, Await as t };
|
|
41
|
+
//# sourceMappingURL=Await-qSmJ-ZuN.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Await-qSmJ-ZuN.d.mts","names":[],"sources":["../../src/components/Await.tsx"],"mappings":";;;UAMiB,UAAA;;WAEN,IAAA;EAFgB;;EAAA,SAKhB,QAAA,GAAW,KAAA,EAAO,CAAA,KAAM,SAAA;AAAA;;;;;;;;AA2BnC;;;;;;;;;;;;;;;;;iBAAgB,KAAA,aAAA,CAAA;EACd,IAAA;EACA;AAAA,GACC,UAAA,CAAW,CAAA,IAAK,SAAA"}
|