{"version":3,"file":"useRoute-5MF3j-9P.mjs","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":"sDASA,MAAa,EAAe,EAAuC,IAAI,EAE1D,EAAgB,EAA6B,IAAI,EAEjD,EAAmB,EAAgC,IAAI,ECbvD,EAAe,OAAO,OAAO,CAAC,CAAC,EAE/B,EAAgB,OAAO,OAAO,CAAC,CAAC,EAIhC,EAAgB,IAAI,YAAqB,CAGtD,CAAC,ECQY,MAAgE,CAC3E,IAAM,EAAe,EAAW,CAAY,EAE5C,GAAI,CAAC,EACH,MAAU,MAAM,+CAA+C,EAGjE,GAAI,CAAC,EAAa,MAChB,MAAU,MACR,mIACF,EAGF,OAAO,CACT"}