@depup/tanstack__react-router 1.167.0-depup.0 → 1.167.3-depup.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.
Files changed (197) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/Asset.cjs +115 -174
  3. package/dist/cjs/Asset.cjs.map +1 -1
  4. package/dist/cjs/CatchBoundary.cjs +92 -108
  5. package/dist/cjs/CatchBoundary.cjs.map +1 -1
  6. package/dist/cjs/ClientOnly.cjs +47 -13
  7. package/dist/cjs/ClientOnly.cjs.map +1 -1
  8. package/dist/cjs/HeadContent.cjs +23 -12
  9. package/dist/cjs/HeadContent.cjs.map +1 -1
  10. package/dist/cjs/HeadContent.dev.cjs +33 -38
  11. package/dist/cjs/HeadContent.dev.cjs.map +1 -1
  12. package/dist/cjs/Match.cjs +190 -247
  13. package/dist/cjs/Match.cjs.map +1 -1
  14. package/dist/cjs/Matches.cjs +131 -118
  15. package/dist/cjs/Matches.cjs.map +1 -1
  16. package/dist/cjs/RouterProvider.cjs +43 -27
  17. package/dist/cjs/RouterProvider.cjs.map +1 -1
  18. package/dist/cjs/SafeFragment.cjs +9 -5
  19. package/dist/cjs/SafeFragment.cjs.map +1 -1
  20. package/dist/cjs/ScriptOnce.cjs +17 -19
  21. package/dist/cjs/ScriptOnce.cjs.map +1 -1
  22. package/dist/cjs/Scripts.cjs +56 -54
  23. package/dist/cjs/Scripts.cjs.map +1 -1
  24. package/dist/cjs/ScrollRestoration.cjs +26 -30
  25. package/dist/cjs/ScrollRestoration.cjs.map +1 -1
  26. package/dist/cjs/Transitioner.cjs +109 -116
  27. package/dist/cjs/Transitioner.cjs.map +1 -1
  28. package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
  29. package/dist/cjs/awaited.cjs +28 -43
  30. package/dist/cjs/awaited.cjs.map +1 -1
  31. package/dist/cjs/fileRoute.cjs +133 -95
  32. package/dist/cjs/fileRoute.cjs.map +1 -1
  33. package/dist/cjs/headContentUtils.cjs +144 -181
  34. package/dist/cjs/headContentUtils.cjs.map +1 -1
  35. package/dist/cjs/index.cjs +249 -178
  36. package/dist/cjs/index.dev.cjs +249 -178
  37. package/dist/cjs/lazyRouteComponent.cjs +52 -67
  38. package/dist/cjs/lazyRouteComponent.cjs.map +1 -1
  39. package/dist/cjs/link.cjs +462 -556
  40. package/dist/cjs/link.cjs.map +1 -1
  41. package/dist/cjs/matchContext.cjs +9 -25
  42. package/dist/cjs/matchContext.cjs.map +1 -1
  43. package/dist/cjs/not-found.cjs +25 -32
  44. package/dist/cjs/not-found.cjs.map +1 -1
  45. package/dist/cjs/renderRouteNotFound.cjs +25 -19
  46. package/dist/cjs/renderRouteNotFound.cjs.map +1 -1
  47. package/dist/cjs/route.cjs +258 -178
  48. package/dist/cjs/route.cjs.map +1 -1
  49. package/dist/cjs/router.cjs +29 -16
  50. package/dist/cjs/router.cjs.map +1 -1
  51. package/dist/cjs/routerContext.cjs +8 -22
  52. package/dist/cjs/routerContext.cjs.map +1 -1
  53. package/dist/cjs/scroll-restoration.cjs +23 -36
  54. package/dist/cjs/scroll-restoration.cjs.map +1 -1
  55. package/dist/cjs/ssr/RouterClient.cjs +16 -22
  56. package/dist/cjs/ssr/RouterClient.cjs.map +1 -1
  57. package/dist/cjs/ssr/RouterServer.cjs +10 -6
  58. package/dist/cjs/ssr/RouterServer.cjs.map +1 -1
  59. package/dist/cjs/ssr/client.cjs +10 -10
  60. package/dist/cjs/ssr/defaultRenderHandler.cjs +13 -14
  61. package/dist/cjs/ssr/defaultRenderHandler.cjs.map +1 -1
  62. package/dist/cjs/ssr/defaultStreamHandler.cjs +14 -15
  63. package/dist/cjs/ssr/defaultStreamHandler.cjs.map +1 -1
  64. package/dist/cjs/ssr/renderRouterToStream.cjs +51 -71
  65. package/dist/cjs/ssr/renderRouterToStream.cjs.map +1 -1
  66. package/dist/cjs/ssr/renderRouterToString.cjs +26 -29
  67. package/dist/cjs/ssr/renderRouterToString.cjs.map +1 -1
  68. package/dist/cjs/ssr/server.cjs +18 -18
  69. package/dist/cjs/useBlocker.cjs +126 -162
  70. package/dist/cjs/useBlocker.cjs.map +1 -1
  71. package/dist/cjs/useCanGoBack.cjs +6 -5
  72. package/dist/cjs/useCanGoBack.cjs.map +1 -1
  73. package/dist/cjs/useLoaderData.cjs +24 -12
  74. package/dist/cjs/useLoaderData.cjs.map +1 -1
  75. package/dist/cjs/useLoaderDeps.cjs +23 -11
  76. package/dist/cjs/useLoaderDeps.cjs.map +1 -1
  77. package/dist/cjs/useLocation.cjs +17 -7
  78. package/dist/cjs/useLocation.cjs.map +1 -1
  79. package/dist/cjs/useMatch.cjs +25 -44
  80. package/dist/cjs/useMatch.cjs.map +1 -1
  81. package/dist/cjs/useNavigate.cjs +53 -43
  82. package/dist/cjs/useNavigate.cjs.map +1 -1
  83. package/dist/cjs/useParams.cjs +27 -14
  84. package/dist/cjs/useParams.cjs.map +1 -1
  85. package/dist/cjs/useRouteContext.cjs +9 -8
  86. package/dist/cjs/useRouteContext.cjs.map +1 -1
  87. package/dist/cjs/useRouter.cjs +23 -29
  88. package/dist/cjs/useRouter.cjs.map +1 -1
  89. package/dist/cjs/useRouterState.cjs +40 -35
  90. package/dist/cjs/useRouterState.cjs.map +1 -1
  91. package/dist/cjs/useSearch.cjs +26 -13
  92. package/dist/cjs/useSearch.cjs.map +1 -1
  93. package/dist/cjs/utils.cjs +81 -51
  94. package/dist/cjs/utils.cjs.map +1 -1
  95. package/dist/esm/Asset.js +112 -156
  96. package/dist/esm/Asset.js.map +1 -1
  97. package/dist/esm/CatchBoundary.js +90 -92
  98. package/dist/esm/CatchBoundary.js.map +1 -1
  99. package/dist/esm/ClientOnly.js +45 -14
  100. package/dist/esm/ClientOnly.js.map +1 -1
  101. package/dist/esm/HeadContent.dev.js +31 -21
  102. package/dist/esm/HeadContent.dev.js.map +1 -1
  103. package/dist/esm/HeadContent.js +20 -11
  104. package/dist/esm/HeadContent.js.map +1 -1
  105. package/dist/esm/Match.js +181 -226
  106. package/dist/esm/Match.js.map +1 -1
  107. package/dist/esm/Matches.js +125 -103
  108. package/dist/esm/Matches.js.map +1 -1
  109. package/dist/esm/RouterProvider.js +41 -28
  110. package/dist/esm/RouterProvider.js.map +1 -1
  111. package/dist/esm/SafeFragment.js +8 -6
  112. package/dist/esm/SafeFragment.js.map +1 -1
  113. package/dist/esm/ScriptOnce.js +15 -18
  114. package/dist/esm/ScriptOnce.js.map +1 -1
  115. package/dist/esm/Scripts.js +55 -54
  116. package/dist/esm/Scripts.js.map +1 -1
  117. package/dist/esm/ScrollRestoration.js +25 -31
  118. package/dist/esm/ScrollRestoration.js.map +1 -1
  119. package/dist/esm/Transitioner.js +106 -98
  120. package/dist/esm/Transitioner.js.map +1 -1
  121. package/dist/esm/awaited.js +26 -27
  122. package/dist/esm/awaited.js.map +1 -1
  123. package/dist/esm/fileRoute.js +127 -96
  124. package/dist/esm/fileRoute.js.map +1 -1
  125. package/dist/esm/headContentUtils.js +141 -163
  126. package/dist/esm/headContentUtils.js.map +1 -1
  127. package/dist/esm/index.dev.js +16 -117
  128. package/dist/esm/index.js +18 -118
  129. package/dist/esm/lazyRouteComponent.js +50 -50
  130. package/dist/esm/lazyRouteComponent.js.map +1 -1
  131. package/dist/esm/link.js +459 -541
  132. package/dist/esm/link.js.map +1 -1
  133. package/dist/esm/matchContext.js +8 -10
  134. package/dist/esm/matchContext.js.map +1 -1
  135. package/dist/esm/not-found.js +22 -32
  136. package/dist/esm/not-found.js.map +1 -1
  137. package/dist/esm/renderRouteNotFound.js +21 -18
  138. package/dist/esm/renderRouteNotFound.js.map +1 -1
  139. package/dist/esm/route.js +249 -180
  140. package/dist/esm/route.js.map +1 -1
  141. package/dist/esm/router.js +28 -17
  142. package/dist/esm/router.js.map +1 -1
  143. package/dist/esm/routerContext.js +7 -6
  144. package/dist/esm/routerContext.js.map +1 -1
  145. package/dist/esm/scroll-restoration.js +21 -35
  146. package/dist/esm/scroll-restoration.js.map +1 -1
  147. package/dist/esm/ssr/RouterClient.js +14 -21
  148. package/dist/esm/ssr/RouterClient.js.map +1 -1
  149. package/dist/esm/ssr/RouterServer.js +8 -6
  150. package/dist/esm/ssr/RouterServer.js.map +1 -1
  151. package/dist/esm/ssr/client.js +1 -4
  152. package/dist/esm/ssr/defaultRenderHandler.js +12 -13
  153. package/dist/esm/ssr/defaultRenderHandler.js.map +1 -1
  154. package/dist/esm/ssr/defaultStreamHandler.js +13 -14
  155. package/dist/esm/ssr/defaultStreamHandler.js.map +1 -1
  156. package/dist/esm/ssr/renderRouterToStream.js +48 -70
  157. package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
  158. package/dist/esm/ssr/renderRouterToString.js +24 -29
  159. package/dist/esm/ssr/renderRouterToString.js.map +1 -1
  160. package/dist/esm/ssr/server.js +3 -10
  161. package/dist/esm/useBlocker.js +124 -146
  162. package/dist/esm/useBlocker.js.map +1 -1
  163. package/dist/esm/useCanGoBack.js +6 -5
  164. package/dist/esm/useCanGoBack.js.map +1 -1
  165. package/dist/esm/useLoaderData.js +24 -12
  166. package/dist/esm/useLoaderData.js.map +1 -1
  167. package/dist/esm/useLoaderDeps.js +23 -11
  168. package/dist/esm/useLoaderDeps.js.map +1 -1
  169. package/dist/esm/useLocation.js +17 -7
  170. package/dist/esm/useLocation.js.map +1 -1
  171. package/dist/esm/useMatch.js +21 -26
  172. package/dist/esm/useMatch.js.map +1 -1
  173. package/dist/esm/useNavigate.js +50 -26
  174. package/dist/esm/useNavigate.js.map +1 -1
  175. package/dist/esm/useParams.js +27 -14
  176. package/dist/esm/useParams.js.map +1 -1
  177. package/dist/esm/useRouteContext.js +9 -8
  178. package/dist/esm/useRouteContext.js.map +1 -1
  179. package/dist/esm/useRouter.js +20 -12
  180. package/dist/esm/useRouter.js.map +1 -1
  181. package/dist/esm/useRouterState.js +38 -34
  182. package/dist/esm/useRouterState.js.map +1 -1
  183. package/dist/esm/useSearch.js +26 -13
  184. package/dist/esm/useSearch.js.map +1 -1
  185. package/dist/esm/utils.js +80 -39
  186. package/dist/esm/utils.js.map +1 -1
  187. package/dist/llms/rules/guide.d.ts +1 -1
  188. package/dist/llms/rules/guide.js +2 -2
  189. package/package.json +5 -5
  190. package/dist/cjs/index.cjs.map +0 -1
  191. package/dist/cjs/index.dev.cjs.map +0 -1
  192. package/dist/cjs/ssr/client.cjs.map +0 -1
  193. package/dist/cjs/ssr/server.cjs.map +0 -1
  194. package/dist/esm/index.dev.js.map +0 -1
  195. package/dist/esm/index.js.map +0 -1
  196. package/dist/esm/ssr/client.js.map +0 -1
  197. package/dist/esm/ssr/server.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Match.js","sources":["../../src/Match.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport {\n createControlledPromise,\n getLocationChangeInfo,\n isNotFound,\n isRedirect,\n rootRouteId,\n} from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound } from './not-found'\nimport { matchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport { ClientOnly } from './ClientOnly'\nimport type {\n AnyRoute,\n ParsedLocation,\n RootRouteOptions,\n} from '@tanstack/router-core'\n\nexport const Match = React.memo(function MatchImpl({\n matchId,\n}: {\n matchId: string\n}) {\n const router = useRouter()\n const matchState = useRouterState({\n select: (s) => {\n const matchIndex = s.matches.findIndex((d) => d.id === matchId)\n const match = s.matches[matchIndex]\n invariant(\n match,\n `Could not find match for matchId \"${matchId}\". Please file an issue!`,\n )\n return {\n routeId: match.routeId,\n ssr: match.ssr,\n _displayPending: match._displayPending,\n resetKey: s.loadedAt,\n parentRouteId: s.matches[matchIndex - 1]?.routeId as string,\n }\n },\n structuralSharing: true as any,\n })\n\n const route: AnyRoute = router.routesById[matchState.routeId]\n\n const PendingComponent =\n route.options.pendingComponent ?? router.options.defaultPendingComponent\n\n const pendingElement = PendingComponent ? <PendingComponent /> : null\n\n const routeErrorComponent =\n route.options.errorComponent ?? router.options.defaultErrorComponent\n\n const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch\n\n const routeNotFoundComponent = route.isRoot\n ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n (route.options.notFoundComponent ??\n router.options.notFoundRoute?.options.component)\n : route.options.notFoundComponent\n\n const resolvedNoSsr =\n matchState.ssr === false || matchState.ssr === 'data-only'\n const ResolvedSuspenseBoundary =\n // If we're on the root route, allow forcefully wrapping in suspense\n (!route.isRoot || route.options.wrapInSuspense || resolvedNoSsr) &&\n (route.options.wrapInSuspense ??\n PendingComponent ??\n ((route.options.errorComponent as any)?.preload || resolvedNoSsr))\n ? React.Suspense\n : SafeFragment\n\n const ResolvedCatchBoundary = routeErrorComponent\n ? CatchBoundary\n : SafeFragment\n\n const ResolvedNotFoundBoundary = routeNotFoundComponent\n ? CatchNotFound\n : SafeFragment\n\n const ShellComponent = route.isRoot\n ? ((route.options as RootRouteOptions).shellComponent ?? SafeFragment)\n : SafeFragment\n return (\n <ShellComponent>\n <matchContext.Provider value={matchId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => matchState.resetKey}\n errorComponent={routeErrorComponent || ErrorComponent}\n onCatch={(error, errorInfo) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(false, `Error in route match: ${matchId}`)\n routeOnCatch?.(error, errorInfo)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n // If the current not found handler doesn't exist or it has a\n // route ID which doesn't match the current route, rethrow the error\n if (\n !routeNotFoundComponent ||\n (error.routeId && error.routeId !== matchState.routeId) ||\n (!error.routeId && !route.isRoot)\n )\n throw error\n\n return React.createElement(routeNotFoundComponent, error as any)\n }}\n >\n {resolvedNoSsr || matchState._displayPending ? (\n <ClientOnly fallback={pendingElement}>\n <MatchInner matchId={matchId} />\n </ClientOnly>\n ) : (\n <MatchInner matchId={matchId} />\n )}\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n {matchState.parentRouteId === rootRouteId &&\n router.options.scrollRestoration ? (\n <>\n <OnRendered />\n <ScrollRestoration />\n </>\n ) : null}\n </ShellComponent>\n )\n})\n\n// On Rendered can't happen above the root layout because it actually\n// renders a dummy dom element to track the rendered state of the app.\n// We render a script tag with a key that changes based on the current\n// location state.__TSR_key. Also, because it's below the root layout, it\n// allows us to fire onRendered events even after a hydration mismatch\n// error that occurred above the root layout (like bad head/link tags,\n// which is common).\nfunction OnRendered() {\n const router = useRouter()\n\n const prevLocationRef = React.useRef<undefined | ParsedLocation<{}>>(\n undefined,\n )\n\n return (\n <script\n key={router.latestLocation.state.__TSR_key}\n suppressHydrationWarning\n ref={(el) => {\n if (\n el &&\n (prevLocationRef.current === undefined ||\n prevLocationRef.current.href !== router.latestLocation.href)\n ) {\n router.emit({\n type: 'onRendered',\n ...getLocationChangeInfo(router.state),\n })\n prevLocationRef.current = router.latestLocation\n }\n }}\n />\n )\n}\n\nexport const MatchInner = React.memo(function MatchInnerImpl({\n matchId,\n}: {\n matchId: string\n}): any {\n const router = useRouter()\n\n const { match, key, routeId } = useRouterState({\n select: (s) => {\n const match = s.matches.find((d) => d.id === matchId)!\n const routeId = match.routeId as string\n\n const remountFn =\n (router.routesById[routeId] as AnyRoute).options.remountDeps ??\n router.options.defaultRemountDeps\n const remountDeps = remountFn?.({\n routeId,\n loaderDeps: match.loaderDeps,\n params: match._strictParams,\n search: match._strictSearch,\n })\n const key = remountDeps ? JSON.stringify(remountDeps) : undefined\n\n return {\n key,\n routeId,\n match: {\n id: match.id,\n status: match.status,\n error: match.error,\n _forcePending: match._forcePending,\n _displayPending: match._displayPending,\n },\n }\n },\n structuralSharing: true as any,\n })\n\n const route = router.routesById[routeId] as AnyRoute\n\n const out = React.useMemo(() => {\n const Comp = route.options.component ?? router.options.defaultComponent\n if (Comp) {\n return <Comp key={key} />\n }\n return <Outlet />\n }, [key, route.options.component, router.options.defaultComponent])\n\n if (match._displayPending) {\n throw router.getMatch(match.id)?._nonReactive.displayPendingPromise\n }\n\n if (match._forcePending) {\n throw router.getMatch(match.id)?._nonReactive.minPendingPromise\n }\n\n // see also hydrate() in packages/router-core/src/ssr/ssr-client.ts\n if (match.status === 'pending') {\n // We're pending, and if we have a minPendingMs, we need to wait for it\n const pendingMinMs =\n route.options.pendingMinMs ?? router.options.defaultPendingMinMs\n if (pendingMinMs) {\n const routerMatch = router.getMatch(match.id)\n if (routerMatch && !routerMatch._nonReactive.minPendingPromise) {\n // Create a promise that will resolve after the minPendingMs\n if (!(isServer ?? router.isServer)) {\n const minPendingPromise = createControlledPromise<void>()\n\n routerMatch._nonReactive.minPendingPromise = minPendingPromise\n\n setTimeout(() => {\n minPendingPromise.resolve()\n // We've handled the minPendingPromise, so we can delete it\n routerMatch._nonReactive.minPendingPromise = undefined\n }, pendingMinMs)\n }\n }\n }\n throw router.getMatch(match.id)?._nonReactive.loadPromise\n }\n\n if (match.status === 'notFound') {\n invariant(isNotFound(match.error), 'Expected a notFound error')\n return renderRouteNotFound(router, route, match.error)\n }\n\n if (match.status === 'redirected') {\n // Redirects should be handled by the router transition. If we happen to\n // encounter a redirect here, it's a bug. Let's warn, but render nothing.\n invariant(isRedirect(match.error), 'Expected a redirect error')\n\n // warning(\n // false,\n // 'Tried to render a redirected route match! This is a weird circumstance, please file an issue!',\n // )\n throw router.getMatch(match.id)?._nonReactive.loadPromise\n }\n\n if (match.status === 'error') {\n // If we're on the server, we need to use React's new and super\n // wonky api for throwing errors from a server side render inside\n // of a suspense boundary. This is the only way to get\n // renderToPipeableStream to not hang indefinitely.\n // We'll serialize the error and rethrow it on the client.\n if (isServer ?? router.isServer) {\n const RouteErrorComponent =\n (route.options.errorComponent ??\n router.options.defaultErrorComponent) ||\n ErrorComponent\n return (\n <RouteErrorComponent\n error={match.error as any}\n reset={undefined as any}\n info={{\n componentStack: '',\n }}\n />\n )\n }\n\n throw match.error\n }\n\n return out\n})\n\n/**\n * Render the next child match in the route tree. Typically used inside\n * a route component to render nested routes.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/outletComponent\n */\nexport const Outlet = React.memo(function OutletImpl() {\n const router = useRouter()\n const matchId = React.useContext(matchContext)\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const parentGlobalNotFound = useRouterState({\n select: (s) => {\n const matches = s.matches\n const parentMatch = matches.find((d) => d.id === matchId)\n invariant(\n parentMatch,\n `Could not find parent match for matchId \"${matchId}\"`,\n )\n return parentMatch.globalNotFound\n },\n })\n\n const childMatchId = useRouterState({\n select: (s) => {\n const matches = s.matches\n const index = matches.findIndex((d) => d.id === matchId)\n return matches[index + 1]?.id\n },\n })\n\n const pendingElement = router.options.defaultPendingComponent ? (\n <router.options.defaultPendingComponent />\n ) : null\n\n if (parentGlobalNotFound) {\n return renderRouteNotFound(router, route, undefined)\n }\n\n if (!childMatchId) {\n return null\n }\n\n const nextMatch = <Match matchId={childMatchId} />\n\n if (routeId === rootRouteId) {\n return (\n <React.Suspense fallback={pendingElement}>{nextMatch}</React.Suspense>\n )\n }\n\n return nextMatch\n})\n"],"names":["match","routeId","key"],"mappings":";;;;;;;;;;;;;;;AA0BO,MAAM,QAAQ,MAAM,KAAK,SAAS,UAAU;AAAA,EACjD;AACF,GAEG;AACD,QAAM,SAAS,UAAA;AACf,QAAM,aAAa,eAAe;AAAA,IAChC,QAAQ,CAAC,MAAM;AACb,YAAM,aAAa,EAAE,QAAQ,UAAU,CAAC,MAAM,EAAE,OAAO,OAAO;AAC9D,YAAM,QAAQ,EAAE,QAAQ,UAAU;AAClC;AAAA,QACE;AAAA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,CAAC,MAAM,EAAE,OAAO,OAAO,GAAG;AAAA,EAAA,CACzD;AAED,QAAM,QAAQ,OAAO,WAAW,OAAO;AAEvC,QAAM,uBAAuB,eAAe;AAAA,IAC1C,QAAQ,CAAC,MAAM;AACb,YAAM,UAAU,EAAE;AAClB,YAAM,cAAc,QAAQ,KAAK,CAAC,MAAM,EAAE,OAAO,OAAO;AACxD;AAAA,QACE;AAAA,QACA,4CAA4C,OAAO;AAAA,MAAA;AAErD,aAAO,YAAY;AAAA,IACrB;AAAA,EAAA,CACD;AAED,QAAM,eAAe,eAAe;AAAA,IAClC,QAAQ,CAAC,MAAM;AACb,YAAM,UAAU,EAAE;AAClB,YAAM,QAAQ,QAAQ,UAAU,CAAC,MAAM,EAAE,OAAO,OAAO;AACvD,aAAO,QAAQ,QAAQ,CAAC,GAAG;AAAA,IAC7B;AAAA,EAAA,CACD;AAED,QAAM,iBAAiB,OAAO,QAAQ,8CACnC,OAAO,QAAQ,yBAAf,CAAA,CAAuC,IACtC;AAEJ,MAAI,sBAAsB;AACxB,WAAO,oBAAoB,QAAQ,OAAO,MAAS;AAAA,EACrD;AAEA,MAAI,CAAC,cAAc;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,oBAAC,OAAA,EAAM,SAAS,aAAA,CAAc;AAEhD,MAAI,YAAY,aAAa;AAC3B,+BACG,MAAM,UAAN,EAAe,UAAU,gBAAiB,UAAA,WAAU;AAAA,EAEzD;AAEA,SAAO;AACT,CAAC;"}
1
+ {"version":3,"file":"Match.js","names":[],"sources":["../../src/Match.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport {\n createControlledPromise,\n getLocationChangeInfo,\n isNotFound,\n isRedirect,\n rootRouteId,\n} from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound } from './not-found'\nimport { matchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport { ClientOnly } from './ClientOnly'\nimport type {\n AnyRoute,\n ParsedLocation,\n RootRouteOptions,\n} from '@tanstack/router-core'\n\nexport const Match = React.memo(function MatchImpl({\n matchId,\n}: {\n matchId: string\n}) {\n const router = useRouter()\n const matchState = useRouterState({\n select: (s) => {\n const matchIndex = s.matches.findIndex((d) => d.id === matchId)\n const match = s.matches[matchIndex]\n invariant(\n match,\n `Could not find match for matchId \"${matchId}\". Please file an issue!`,\n )\n return {\n routeId: match.routeId,\n ssr: match.ssr,\n _displayPending: match._displayPending,\n resetKey: s.loadedAt,\n parentRouteId: s.matches[matchIndex - 1]?.routeId as string,\n }\n },\n structuralSharing: true as any,\n })\n\n const route: AnyRoute = router.routesById[matchState.routeId]\n\n const PendingComponent =\n route.options.pendingComponent ?? router.options.defaultPendingComponent\n\n const pendingElement = PendingComponent ? <PendingComponent /> : null\n\n const routeErrorComponent =\n route.options.errorComponent ?? router.options.defaultErrorComponent\n\n const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch\n\n const routeNotFoundComponent = route.isRoot\n ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n (route.options.notFoundComponent ??\n router.options.notFoundRoute?.options.component)\n : route.options.notFoundComponent\n\n const resolvedNoSsr =\n matchState.ssr === false || matchState.ssr === 'data-only'\n const ResolvedSuspenseBoundary =\n // If we're on the root route, allow forcefully wrapping in suspense\n (!route.isRoot || route.options.wrapInSuspense || resolvedNoSsr) &&\n (route.options.wrapInSuspense ??\n PendingComponent ??\n ((route.options.errorComponent as any)?.preload || resolvedNoSsr))\n ? React.Suspense\n : SafeFragment\n\n const ResolvedCatchBoundary = routeErrorComponent\n ? CatchBoundary\n : SafeFragment\n\n const ResolvedNotFoundBoundary = routeNotFoundComponent\n ? CatchNotFound\n : SafeFragment\n\n const ShellComponent = route.isRoot\n ? ((route.options as RootRouteOptions).shellComponent ?? SafeFragment)\n : SafeFragment\n return (\n <ShellComponent>\n <matchContext.Provider value={matchId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => matchState.resetKey}\n errorComponent={routeErrorComponent || ErrorComponent}\n onCatch={(error, errorInfo) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(false, `Error in route match: ${matchId}`)\n routeOnCatch?.(error, errorInfo)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n // If the current not found handler doesn't exist or it has a\n // route ID which doesn't match the current route, rethrow the error\n if (\n !routeNotFoundComponent ||\n (error.routeId && error.routeId !== matchState.routeId) ||\n (!error.routeId && !route.isRoot)\n )\n throw error\n\n return React.createElement(routeNotFoundComponent, error as any)\n }}\n >\n {resolvedNoSsr || matchState._displayPending ? (\n <ClientOnly fallback={pendingElement}>\n <MatchInner matchId={matchId} />\n </ClientOnly>\n ) : (\n <MatchInner matchId={matchId} />\n )}\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n {matchState.parentRouteId === rootRouteId &&\n router.options.scrollRestoration ? (\n <>\n <OnRendered />\n <ScrollRestoration />\n </>\n ) : null}\n </ShellComponent>\n )\n})\n\n// On Rendered can't happen above the root layout because it actually\n// renders a dummy dom element to track the rendered state of the app.\n// We render a script tag with a key that changes based on the current\n// location state.__TSR_key. Also, because it's below the root layout, it\n// allows us to fire onRendered events even after a hydration mismatch\n// error that occurred above the root layout (like bad head/link tags,\n// which is common).\nfunction OnRendered() {\n const router = useRouter()\n\n const prevLocationRef = React.useRef<undefined | ParsedLocation<{}>>(\n undefined,\n )\n\n return (\n <script\n key={router.latestLocation.state.__TSR_key}\n suppressHydrationWarning\n ref={(el) => {\n if (\n el &&\n (prevLocationRef.current === undefined ||\n prevLocationRef.current.href !== router.latestLocation.href)\n ) {\n router.emit({\n type: 'onRendered',\n ...getLocationChangeInfo(router.state),\n })\n prevLocationRef.current = router.latestLocation\n }\n }}\n />\n )\n}\n\nexport const MatchInner = React.memo(function MatchInnerImpl({\n matchId,\n}: {\n matchId: string\n}): any {\n const router = useRouter()\n\n const { match, key, routeId } = useRouterState({\n select: (s) => {\n const match = s.matches.find((d) => d.id === matchId)!\n const routeId = match.routeId as string\n\n const remountFn =\n (router.routesById[routeId] as AnyRoute).options.remountDeps ??\n router.options.defaultRemountDeps\n const remountDeps = remountFn?.({\n routeId,\n loaderDeps: match.loaderDeps,\n params: match._strictParams,\n search: match._strictSearch,\n })\n const key = remountDeps ? JSON.stringify(remountDeps) : undefined\n\n return {\n key,\n routeId,\n match: {\n id: match.id,\n status: match.status,\n error: match.error,\n _forcePending: match._forcePending,\n _displayPending: match._displayPending,\n },\n }\n },\n structuralSharing: true as any,\n })\n\n const route = router.routesById[routeId] as AnyRoute\n\n const out = React.useMemo(() => {\n const Comp = route.options.component ?? router.options.defaultComponent\n if (Comp) {\n return <Comp key={key} />\n }\n return <Outlet />\n }, [key, route.options.component, router.options.defaultComponent])\n\n if (match._displayPending) {\n throw router.getMatch(match.id)?._nonReactive.displayPendingPromise\n }\n\n if (match._forcePending) {\n throw router.getMatch(match.id)?._nonReactive.minPendingPromise\n }\n\n // see also hydrate() in packages/router-core/src/ssr/ssr-client.ts\n if (match.status === 'pending') {\n // We're pending, and if we have a minPendingMs, we need to wait for it\n const pendingMinMs =\n route.options.pendingMinMs ?? router.options.defaultPendingMinMs\n if (pendingMinMs) {\n const routerMatch = router.getMatch(match.id)\n if (routerMatch && !routerMatch._nonReactive.minPendingPromise) {\n // Create a promise that will resolve after the minPendingMs\n if (!(isServer ?? router.isServer)) {\n const minPendingPromise = createControlledPromise<void>()\n\n routerMatch._nonReactive.minPendingPromise = minPendingPromise\n\n setTimeout(() => {\n minPendingPromise.resolve()\n // We've handled the minPendingPromise, so we can delete it\n routerMatch._nonReactive.minPendingPromise = undefined\n }, pendingMinMs)\n }\n }\n }\n throw router.getMatch(match.id)?._nonReactive.loadPromise\n }\n\n if (match.status === 'notFound') {\n invariant(isNotFound(match.error), 'Expected a notFound error')\n return renderRouteNotFound(router, route, match.error)\n }\n\n if (match.status === 'redirected') {\n // Redirects should be handled by the router transition. If we happen to\n // encounter a redirect here, it's a bug. Let's warn, but render nothing.\n invariant(isRedirect(match.error), 'Expected a redirect error')\n\n // warning(\n // false,\n // 'Tried to render a redirected route match! This is a weird circumstance, please file an issue!',\n // )\n throw router.getMatch(match.id)?._nonReactive.loadPromise\n }\n\n if (match.status === 'error') {\n // If we're on the server, we need to use React's new and super\n // wonky api for throwing errors from a server side render inside\n // of a suspense boundary. This is the only way to get\n // renderToPipeableStream to not hang indefinitely.\n // We'll serialize the error and rethrow it on the client.\n if (isServer ?? router.isServer) {\n const RouteErrorComponent =\n (route.options.errorComponent ??\n router.options.defaultErrorComponent) ||\n ErrorComponent\n return (\n <RouteErrorComponent\n error={match.error as any}\n reset={undefined as any}\n info={{\n componentStack: '',\n }}\n />\n )\n }\n\n throw match.error\n }\n\n return out\n})\n\n/**\n * Render the next child match in the route tree. Typically used inside\n * a route component to render nested routes.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/outletComponent\n */\nexport const Outlet = React.memo(function OutletImpl() {\n const router = useRouter()\n const matchId = React.useContext(matchContext)\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const parentGlobalNotFound = useRouterState({\n select: (s) => {\n const matches = s.matches\n const parentMatch = matches.find((d) => d.id === matchId)\n invariant(\n parentMatch,\n `Could not find parent match for matchId \"${matchId}\"`,\n )\n return parentMatch.globalNotFound\n },\n })\n\n const childMatchId = useRouterState({\n select: (s) => {\n const matches = s.matches\n const index = matches.findIndex((d) => d.id === matchId)\n return matches[index + 1]?.id\n },\n })\n\n const pendingElement = router.options.defaultPendingComponent ? (\n <router.options.defaultPendingComponent />\n ) : null\n\n if (parentGlobalNotFound) {\n return renderRouteNotFound(router, route, undefined)\n }\n\n if (!childMatchId) {\n return null\n }\n\n const nextMatch = <Match matchId={childMatchId} />\n\n if (routeId === rootRouteId) {\n return (\n <React.Suspense fallback={pendingElement}>{nextMatch}</React.Suspense>\n )\n }\n\n return nextMatch\n})\n"],"mappings":";;;;;;;;;;;;;;;;AA0BA,IAAa,QAAQ,QAAM,KAAK,SAAS,UAAU,EACjD,WAGC;CACD,MAAM,SAAS,WAAW;CAC1B,MAAM,aAAa,eAAe;EAChC,SAAS,MAAM;GACb,MAAM,aAAa,EAAE,QAAQ,WAAW,MAAM,EAAE,OAAO,QAAQ;GAC/D,MAAM,QAAQ,EAAE,QAAQ;AACxB,aACE,OACA,qCAAqC,QAAQ,0BAC9C;AACD,UAAO;IACL,SAAS,MAAM;IACf,KAAK,MAAM;IACX,iBAAiB,MAAM;IACvB,UAAU,EAAE;IACZ,eAAe,EAAE,QAAQ,aAAa,IAAI;IAC3C;;EAEH,mBAAmB;EACpB,CAAC;CAEF,MAAM,QAAkB,OAAO,WAAW,WAAW;CAErD,MAAM,mBACJ,MAAM,QAAQ,oBAAoB,OAAO,QAAQ;CAEnD,MAAM,iBAAiB,mBAAmB,oBAAC,kBAAD,EAAoB,CAAA,GAAG;CAEjE,MAAM,sBACJ,MAAM,QAAQ,kBAAkB,OAAO,QAAQ;CAEjD,MAAM,eAAe,MAAM,QAAQ,WAAW,OAAO,QAAQ;CAE7D,MAAM,yBAAyB,MAAM,SAEhC,MAAM,QAAQ,qBACf,OAAO,QAAQ,eAAe,QAAQ,YACtC,MAAM,QAAQ;CAElB,MAAM,gBACJ,WAAW,QAAQ,SAAS,WAAW,QAAQ;CACjD,MAAM,4BAEH,CAAC,MAAM,UAAU,MAAM,QAAQ,kBAAkB,mBACjD,MAAM,QAAQ,kBACb,qBACE,MAAM,QAAQ,gBAAwB,WAAW,kBACjD,QAAM,WACN;CAEN,MAAM,wBA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MAAM,EAAE,OAAO,QAAQ,GACjC,IAAI;IAE9B,CAAC;CAEF,MAAM,iBAAiB,OAAO,QAAQ,0BACpC,oBAAC,OAAO,QAAQ,yBAAhB,EAA0C,CAAA,GACxC;AAEJ,KAAI,qBACF,QAAO,oBAAoB,QAAQ,OAAO,KAAA,EAAU;AAGtD,KAAI,CAAC,aACH,QAAO;CAGT,MAAM,YAAY,oBAAC,OAAD,EAAO,SAAS,cAAgB,CAAA;AAElD,KAAI,YAAY,YACd,QACE,oBAAC,QAAM,UAAP;EAAgB,UAAU;YAAiB;EAA2B,CAAA;AAI1E,QAAO;EACP"}
@@ -1,121 +1,143 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
- import warning from "tiny-warning";
4
- import { rootRouteId } from "@tanstack/router-core";
5
- import { isServer } from "@tanstack/router-core/isServer";
6
1
  import { CatchBoundary, ErrorComponent } from "./CatchBoundary.js";
7
- import { useRouterState } from "./useRouterState.js";
8
2
  import { useRouter } from "./useRouter.js";
9
- import { Transitioner } from "./Transitioner.js";
3
+ import { useRouterState } from "./useRouterState.js";
10
4
  import { matchContext } from "./matchContext.js";
11
- import { Match } from "./Match.js";
5
+ import { Transitioner } from "./Transitioner.js";
12
6
  import { SafeFragment } from "./SafeFragment.js";
7
+ import { Match } from "./Match.js";
8
+ import { rootRouteId } from "@tanstack/router-core";
9
+ import * as React$1 from "react";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ import warning from "tiny-warning";
12
+ import { isServer } from "@tanstack/router-core/isServer";
13
+ //#region src/Matches.tsx
14
+ /**
15
+ * Internal component that renders the router's active match tree with
16
+ * suspense, error, and not-found boundaries. Rendered by `RouterProvider`.
17
+ */
13
18
  function Matches() {
14
- const router = useRouter();
15
- const rootRoute = router.routesById[rootRouteId];
16
- const PendingComponent = rootRoute.options.pendingComponent ?? router.options.defaultPendingComponent;
17
- const pendingElement = PendingComponent ? /* @__PURE__ */ jsx(PendingComponent, {}) : null;
18
- const ResolvedSuspense = (isServer ?? router.isServer) || typeof document !== "undefined" && router.ssr ? SafeFragment : React.Suspense;
19
- const inner = /* @__PURE__ */ jsxs(ResolvedSuspense, { fallback: pendingElement, children: [
20
- !(isServer ?? router.isServer) && /* @__PURE__ */ jsx(Transitioner, {}),
21
- /* @__PURE__ */ jsx(MatchesInner, {})
22
- ] });
23
- return router.options.InnerWrap ? /* @__PURE__ */ jsx(router.options.InnerWrap, { children: inner }) : inner;
19
+ const router = useRouter();
20
+ const PendingComponent = router.routesById[rootRouteId].options.pendingComponent ?? router.options.defaultPendingComponent;
21
+ const pendingElement = PendingComponent ? /* @__PURE__ */ jsx(PendingComponent, {}) : null;
22
+ const inner = /* @__PURE__ */ jsxs((isServer ?? router.isServer) || typeof document !== "undefined" && router.ssr ? SafeFragment : React$1.Suspense, {
23
+ fallback: pendingElement,
24
+ children: [!(isServer ?? router.isServer) && /* @__PURE__ */ jsx(Transitioner, {}), /* @__PURE__ */ jsx(MatchesInner, {})]
25
+ });
26
+ return router.options.InnerWrap ? /* @__PURE__ */ jsx(router.options.InnerWrap, { children: inner }) : inner;
24
27
  }
25
28
  function MatchesInner() {
26
- const router = useRouter();
27
- const matchId = useRouterState({
28
- select: (s) => {
29
- return s.matches[0]?.id;
30
- }
31
- });
32
- const resetKey = useRouterState({
33
- select: (s) => s.loadedAt
34
- });
35
- const matchComponent = matchId ? /* @__PURE__ */ jsx(Match, { matchId }) : null;
36
- return /* @__PURE__ */ jsx(matchContext.Provider, { value: matchId, children: router.options.disableGlobalCatchBoundary ? matchComponent : /* @__PURE__ */ jsx(
37
- CatchBoundary,
38
- {
39
- getResetKey: () => resetKey,
40
- errorComponent: ErrorComponent,
41
- onCatch: process.env.NODE_ENV !== "production" ? (error) => {
42
- warning(
43
- false,
44
- `The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`
45
- );
46
- warning(false, error.message || error.toString());
47
- } : void 0,
48
- children: matchComponent
49
- }
50
- ) });
29
+ const router = useRouter();
30
+ const matchId = useRouterState({ select: (s) => {
31
+ return s.matches[0]?.id;
32
+ } });
33
+ const resetKey = useRouterState({ select: (s) => s.loadedAt });
34
+ const matchComponent = matchId ? /* @__PURE__ */ jsx(Match, { matchId }) : null;
35
+ return /* @__PURE__ */ jsx(matchContext.Provider, {
36
+ value: matchId,
37
+ children: router.options.disableGlobalCatchBoundary ? matchComponent : /* @__PURE__ */ jsx(CatchBoundary, {
38
+ getResetKey: () => resetKey,
39
+ errorComponent: ErrorComponent,
40
+ onCatch: process.env.NODE_ENV !== "production" ? (error) => {
41
+ warning(false, `The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`);
42
+ warning(false, error.message || error.toString());
43
+ } : void 0,
44
+ children: matchComponent
45
+ })
46
+ });
51
47
  }
48
+ /**
49
+ * Create a matcher function for testing locations against route definitions.
50
+ *
51
+ * The returned function accepts standard navigation options (`to`, `params`,
52
+ * `search`, etc.) and returns either `false` (no match) or the matched params
53
+ * object when the route matches the current or pending location.
54
+ *
55
+ * Useful for conditional rendering and active UI states.
56
+ *
57
+ * @returns A `matchRoute(options)` function that returns `false` or params.
58
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchRouteHook
59
+ */
52
60
  function useMatchRoute() {
53
- const router = useRouter();
54
- useRouterState({
55
- select: (s) => [s.location.href, s.resolvedLocation?.href, s.status],
56
- structuralSharing: true
57
- });
58
- return React.useCallback(
59
- (opts) => {
60
- const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts;
61
- return router.matchRoute(rest, {
62
- pending,
63
- caseSensitive,
64
- fuzzy,
65
- includeSearch
66
- });
67
- },
68
- [router]
69
- );
61
+ const router = useRouter();
62
+ useRouterState({
63
+ select: (s) => [
64
+ s.location.href,
65
+ s.resolvedLocation?.href,
66
+ s.status
67
+ ],
68
+ structuralSharing: true
69
+ });
70
+ return React$1.useCallback((opts) => {
71
+ const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts;
72
+ return router.matchRoute(rest, {
73
+ pending,
74
+ caseSensitive,
75
+ fuzzy,
76
+ includeSearch
77
+ });
78
+ }, [router]);
70
79
  }
80
+ /**
81
+ * Component that conditionally renders its children based on whether a route
82
+ * matches the provided `from`/`to` options. If `children` is a function, it
83
+ * receives the matched params object.
84
+ *
85
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/matchRouteComponent
86
+ */
71
87
  function MatchRoute(props) {
72
- const matchRoute = useMatchRoute();
73
- const params = matchRoute(props);
74
- if (typeof props.children === "function") {
75
- return props.children(params);
76
- }
77
- return params ? props.children : null;
88
+ const params = useMatchRoute()(props);
89
+ if (typeof props.children === "function") return props.children(params);
90
+ return params ? props.children : null;
78
91
  }
79
92
  function useMatches(opts) {
80
- return useRouterState({
81
- select: (state) => {
82
- const matches = state.matches;
83
- return opts?.select ? opts.select(matches) : matches;
84
- },
85
- structuralSharing: opts?.structuralSharing
86
- });
93
+ return useRouterState({
94
+ select: (state) => {
95
+ const matches = state.matches;
96
+ return opts?.select ? opts.select(matches) : matches;
97
+ },
98
+ structuralSharing: opts?.structuralSharing
99
+ });
87
100
  }
101
+ /**
102
+ * Read the full array of active route matches or select a derived subset.
103
+ *
104
+ * Useful for debugging, breadcrumbs, or aggregating metadata across matches.
105
+ *
106
+ * @returns The array of matches (or the selected value).
107
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchesHook
108
+ */
109
+ /**
110
+ * Read the full array of active route matches or select a derived subset.
111
+ *
112
+ * Useful for debugging, breadcrumbs, or aggregating metadata across matches.
113
+ *
114
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchesHook
115
+ */
88
116
  function useParentMatches(opts) {
89
- const contextMatchId = React.useContext(matchContext);
90
- return useMatches({
91
- select: (matches) => {
92
- matches = matches.slice(
93
- 0,
94
- matches.findIndex((d) => d.id === contextMatchId)
95
- );
96
- return opts?.select ? opts.select(matches) : matches;
97
- },
98
- structuralSharing: opts?.structuralSharing
99
- });
117
+ const contextMatchId = React$1.useContext(matchContext);
118
+ return useMatches({
119
+ select: (matches) => {
120
+ matches = matches.slice(0, matches.findIndex((d) => d.id === contextMatchId));
121
+ return opts?.select ? opts.select(matches) : matches;
122
+ },
123
+ structuralSharing: opts?.structuralSharing
124
+ });
100
125
  }
126
+ /**
127
+ * Read the array of active route matches that are children of the current
128
+ * match (or selected parent) in the match tree.
129
+ */
101
130
  function useChildMatches(opts) {
102
- const contextMatchId = React.useContext(matchContext);
103
- return useMatches({
104
- select: (matches) => {
105
- matches = matches.slice(
106
- matches.findIndex((d) => d.id === contextMatchId) + 1
107
- );
108
- return opts?.select ? opts.select(matches) : matches;
109
- },
110
- structuralSharing: opts?.structuralSharing
111
- });
131
+ const contextMatchId = React$1.useContext(matchContext);
132
+ return useMatches({
133
+ select: (matches) => {
134
+ matches = matches.slice(matches.findIndex((d) => d.id === contextMatchId) + 1);
135
+ return opts?.select ? opts.select(matches) : matches;
136
+ },
137
+ structuralSharing: opts?.structuralSharing
138
+ });
112
139
  }
113
- export {
114
- MatchRoute,
115
- Matches,
116
- useChildMatches,
117
- useMatchRoute,
118
- useMatches,
119
- useParentMatches
120
- };
121
- //# sourceMappingURL=Matches.js.map
140
+ //#endregion
141
+ export { MatchRoute, Matches, useChildMatches, useMatchRoute, useMatches, useParentMatches };
142
+
143
+ //# sourceMappingURL=Matches.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Matches.js","sources":["../../src/Matches.tsx"],"sourcesContent":["import * as React from 'react'\nimport warning from 'tiny-warning'\nimport { rootRouteId } from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { Transitioner } from './Transitioner'\nimport { matchContext } from './matchContext'\nimport { Match } from './Match'\nimport { SafeFragment } from './SafeFragment'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRoute,\n AnyRouter,\n DeepPartial,\n Expand,\n MakeOptionalPathParams,\n MakeOptionalSearchParams,\n MakeRouteMatchUnion,\n MaskOptions,\n MatchRouteOptions,\n NoInfer,\n RegisteredRouter,\n ResolveRelativePath,\n ResolveRoute,\n RouteByPath,\n RouterState,\n ToSubOptionsProps,\n} from '@tanstack/router-core'\n\ndeclare module '@tanstack/router-core' {\n export interface RouteMatchExtensions {\n meta?: Array<React.JSX.IntrinsicElements['meta'] | undefined>\n links?: Array<React.JSX.IntrinsicElements['link'] | undefined>\n scripts?: Array<React.JSX.IntrinsicElements['script'] | undefined>\n styles?: Array<React.JSX.IntrinsicElements['style'] | undefined>\n headScripts?: Array<React.JSX.IntrinsicElements['script'] | undefined>\n }\n}\n\n/**\n * Internal component that renders the router's active match tree with\n * suspense, error, and not-found boundaries. Rendered by `RouterProvider`.\n */\nexport function Matches() {\n const router = useRouter()\n const rootRoute: AnyRoute = router.routesById[rootRouteId]\n\n const PendingComponent =\n rootRoute.options.pendingComponent ?? router.options.defaultPendingComponent\n\n const pendingElement = PendingComponent ? <PendingComponent /> : null\n\n // Do not render a root Suspense during SSR or hydrating from SSR\n const ResolvedSuspense =\n (isServer ?? router.isServer) ||\n (typeof document !== 'undefined' && router.ssr)\n ? SafeFragment\n : React.Suspense\n\n const inner = (\n <ResolvedSuspense fallback={pendingElement}>\n {!(isServer ?? router.isServer) && <Transitioner />}\n <MatchesInner />\n </ResolvedSuspense>\n )\n\n return router.options.InnerWrap ? (\n <router.options.InnerWrap>{inner}</router.options.InnerWrap>\n ) : (\n inner\n )\n}\n\nfunction MatchesInner() {\n const router = useRouter()\n const matchId = useRouterState({\n select: (s) => {\n return s.matches[0]?.id\n },\n })\n\n const resetKey = useRouterState({\n select: (s) => s.loadedAt,\n })\n\n const matchComponent = matchId ? <Match matchId={matchId} /> : null\n\n return (\n <matchContext.Provider value={matchId}>\n {router.options.disableGlobalCatchBoundary ? (\n matchComponent\n ) : (\n <CatchBoundary\n getResetKey={() => resetKey}\n errorComponent={ErrorComponent}\n onCatch={\n process.env.NODE_ENV !== 'production'\n ? (error) => {\n warning(\n false,\n `The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`,\n )\n warning(false, error.message || error.toString())\n }\n : undefined\n }\n >\n {matchComponent}\n </CatchBoundary>\n )}\n </matchContext.Provider>\n )\n}\n\nexport type UseMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = ToSubOptionsProps<TRouter, TFrom, TTo> &\n DeepPartial<MakeOptionalSearchParams<TRouter, TFrom, TTo>> &\n DeepPartial<MakeOptionalPathParams<TRouter, TFrom, TTo>> &\n MaskOptions<TRouter, TMaskFrom, TMaskTo> &\n MatchRouteOptions\n\n/**\n * Create a matcher function for testing locations against route definitions.\n *\n * The returned function accepts standard navigation options (`to`, `params`,\n * `search`, etc.) and returns either `false` (no match) or the matched params\n * object when the route matches the current or pending location.\n *\n * Useful for conditional rendering and active UI states.\n *\n * @returns A `matchRoute(options)` function that returns `false` or params.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchRouteHook\n */\nexport function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>() {\n const router = useRouter()\n\n useRouterState({\n select: (s) => [s.location.href, s.resolvedLocation?.href, s.status],\n structuralSharing: true as any,\n })\n\n return React.useCallback(\n <\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n >(\n opts: UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n ):\n | false\n | Expand<ResolveRoute<TRouter, TFrom, TTo>['types']['allParams']> => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n },\n [router],\n )\n}\n\nexport type MakeMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | ((\n params?: RouteByPath<\n TRouter['routeTree'],\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => React.ReactNode)\n | React.ReactNode\n}\n\n/**\n * Component that conditionally renders its children based on whether a route\n * matches the provided `from`/`to` options. If `children` is a function, it\n * receives the matched params object.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/matchRouteComponent\n */\nexport function MatchRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(props: MakeMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any) as boolean\n\n if (typeof props.children === 'function') {\n return (props.children as any)(params)\n }\n\n return params ? props.children : null\n}\n\nexport interface UseMatchesBaseOptions<\n TRouter extends AnyRouter,\n TSelected,\n TStructuralSharing,\n> {\n select?: (\n matches: Array<MakeRouteMatchUnion<TRouter>>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n}\n\nexport type UseMatchesResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected ? Array<MakeRouteMatchUnion<TRouter>> : TSelected\n\nexport function useMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected, TStructuralSharing> &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n): UseMatchesResult<TRouter, TSelected> {\n return useRouterState({\n select: (state: RouterState<TRouter['routeTree']>) => {\n const matches = state.matches\n return opts?.select\n ? opts.select(matches as Array<MakeRouteMatchUnion<TRouter>>)\n : matches\n },\n structuralSharing: opts?.structuralSharing,\n } as any) as UseMatchesResult<TRouter, TSelected>\n}\n\n/**\n * Read the full array of active route matches or select a derived subset.\n *\n * Useful for debugging, breadcrumbs, or aggregating metadata across matches.\n *\n * @returns The array of matches (or the selected value).\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchesHook\n */\n\n/**\n * Read the full array of active route matches or select a derived subset.\n *\n * Useful for debugging, breadcrumbs, or aggregating metadata across matches.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchesHook\n */\nexport function useParentMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected, TStructuralSharing> &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n): UseMatchesResult<TRouter, TSelected> {\n const contextMatchId = React.useContext(matchContext)\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n 0,\n matches.findIndex((d) => d.id === contextMatchId),\n )\n return opts?.select ? opts.select(matches) : matches\n },\n structuralSharing: opts?.structuralSharing,\n } as any)\n}\n\n/**\n * Read the array of active route matches that are children of the current\n * match (or selected parent) in the match tree.\n */\nexport function useChildMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected, TStructuralSharing> &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n): UseMatchesResult<TRouter, TSelected> {\n const contextMatchId = React.useContext(matchContext)\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n matches.findIndex((d) => d.id === contextMatchId) + 1,\n )\n return opts?.select ? opts.select(matches) : matches\n },\n structuralSharing: opts?.structuralSharing,\n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EpD,SAAO,WAAW;AAAA,IAChB,QAAQ,CAAC,YAAiD;AACxD,gBAAU,QAAQ;AAAA,QAChB,QAAQ,UAAU,CAAC,MAAM,EAAE,OAAO,cAAc,IAAI;AAAA,MAAA;AAEtD,aAAO,MAAM,SAAS,KAAK,OAAO,OAAO,IAAI;AAAA,IAC/C;AAAA,IACA,mBAAmB,MAAM;AAAA,EAAA,CACnB;AACV;"}
1
+ {"version":3,"file":"Matches.js","names":[],"sources":["../../src/Matches.tsx"],"sourcesContent":["import * as React from 'react'\nimport warning from 'tiny-warning'\nimport { rootRouteId } from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { Transitioner } from './Transitioner'\nimport { matchContext } from './matchContext'\nimport { Match } from './Match'\nimport { SafeFragment } from './SafeFragment'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRoute,\n AnyRouter,\n DeepPartial,\n Expand,\n MakeOptionalPathParams,\n MakeOptionalSearchParams,\n MakeRouteMatchUnion,\n MaskOptions,\n MatchRouteOptions,\n NoInfer,\n RegisteredRouter,\n ResolveRelativePath,\n ResolveRoute,\n RouteByPath,\n RouterState,\n ToSubOptionsProps,\n} from '@tanstack/router-core'\n\ndeclare module '@tanstack/router-core' {\n export interface RouteMatchExtensions {\n meta?: Array<React.JSX.IntrinsicElements['meta'] | undefined>\n links?: Array<React.JSX.IntrinsicElements['link'] | undefined>\n scripts?: Array<React.JSX.IntrinsicElements['script'] | undefined>\n styles?: Array<React.JSX.IntrinsicElements['style'] | undefined>\n headScripts?: Array<React.JSX.IntrinsicElements['script'] | undefined>\n }\n}\n\n/**\n * Internal component that renders the router's active match tree with\n * suspense, error, and not-found boundaries. Rendered by `RouterProvider`.\n */\nexport function Matches() {\n const router = useRouter()\n const rootRoute: AnyRoute = router.routesById[rootRouteId]\n\n const PendingComponent =\n rootRoute.options.pendingComponent ?? router.options.defaultPendingComponent\n\n const pendingElement = PendingComponent ? <PendingComponent /> : null\n\n // Do not render a root Suspense during SSR or hydrating from SSR\n const ResolvedSuspense =\n (isServer ?? router.isServer) ||\n (typeof document !== 'undefined' && router.ssr)\n ? SafeFragment\n : React.Suspense\n\n const inner = (\n <ResolvedSuspense fallback={pendingElement}>\n {!(isServer ?? router.isServer) && <Transitioner />}\n <MatchesInner />\n </ResolvedSuspense>\n )\n\n return router.options.InnerWrap ? (\n <router.options.InnerWrap>{inner}</router.options.InnerWrap>\n ) : (\n inner\n )\n}\n\nfunction MatchesInner() {\n const router = useRouter()\n const matchId = useRouterState({\n select: (s) => {\n return s.matches[0]?.id\n },\n })\n\n const resetKey = useRouterState({\n select: (s) => s.loadedAt,\n })\n\n const matchComponent = matchId ? <Match matchId={matchId} /> : null\n\n return (\n <matchContext.Provider value={matchId}>\n {router.options.disableGlobalCatchBoundary ? (\n matchComponent\n ) : (\n <CatchBoundary\n getResetKey={() => resetKey}\n errorComponent={ErrorComponent}\n onCatch={\n process.env.NODE_ENV !== 'production'\n ? (error) => {\n warning(\n false,\n `The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`,\n )\n warning(false, error.message || error.toString())\n }\n : undefined\n }\n >\n {matchComponent}\n </CatchBoundary>\n )}\n </matchContext.Provider>\n )\n}\n\nexport type UseMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = ToSubOptionsProps<TRouter, TFrom, TTo> &\n DeepPartial<MakeOptionalSearchParams<TRouter, TFrom, TTo>> &\n DeepPartial<MakeOptionalPathParams<TRouter, TFrom, TTo>> &\n MaskOptions<TRouter, TMaskFrom, TMaskTo> &\n MatchRouteOptions\n\n/**\n * Create a matcher function for testing locations against route definitions.\n *\n * The returned function accepts standard navigation options (`to`, `params`,\n * `search`, etc.) and returns either `false` (no match) or the matched params\n * object when the route matches the current or pending location.\n *\n * Useful for conditional rendering and active UI states.\n *\n * @returns A `matchRoute(options)` function that returns `false` or params.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchRouteHook\n */\nexport function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>() {\n const router = useRouter()\n\n useRouterState({\n select: (s) => [s.location.href, s.resolvedLocation?.href, s.status],\n structuralSharing: true as any,\n })\n\n return React.useCallback(\n <\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n >(\n opts: UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n ):\n | false\n | Expand<ResolveRoute<TRouter, TFrom, TTo>['types']['allParams']> => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n },\n [router],\n )\n}\n\nexport type MakeMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | ((\n params?: RouteByPath<\n TRouter['routeTree'],\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => React.ReactNode)\n | React.ReactNode\n}\n\n/**\n * Component that conditionally renders its children based on whether a route\n * matches the provided `from`/`to` options. If `children` is a function, it\n * receives the matched params object.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/matchRouteComponent\n */\nexport function MatchRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(props: MakeMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any) as boolean\n\n if (typeof props.children === 'function') {\n return (props.children as any)(params)\n }\n\n return params ? props.children : null\n}\n\nexport interface UseMatchesBaseOptions<\n TRouter extends AnyRouter,\n TSelected,\n TStructuralSharing,\n> {\n select?: (\n matches: Array<MakeRouteMatchUnion<TRouter>>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n}\n\nexport type UseMatchesResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected ? Array<MakeRouteMatchUnion<TRouter>> : TSelected\n\nexport function useMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected, TStructuralSharing> &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n): UseMatchesResult<TRouter, TSelected> {\n return useRouterState({\n select: (state: RouterState<TRouter['routeTree']>) => {\n const matches = state.matches\n return opts?.select\n ? opts.select(matches as Array<MakeRouteMatchUnion<TRouter>>)\n : matches\n },\n structuralSharing: opts?.structuralSharing,\n } as any) as UseMatchesResult<TRouter, TSelected>\n}\n\n/**\n * Read the full array of active route matches or select a derived subset.\n *\n * Useful for debugging, breadcrumbs, or aggregating metadata across matches.\n *\n * @returns The array of matches (or the selected value).\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchesHook\n */\n\n/**\n * Read the full array of active route matches or select a derived subset.\n *\n * Useful for debugging, breadcrumbs, or aggregating metadata across matches.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchesHook\n */\nexport function useParentMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected, TStructuralSharing> &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n): UseMatchesResult<TRouter, TSelected> {\n const contextMatchId = React.useContext(matchContext)\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n 0,\n matches.findIndex((d) => d.id === contextMatchId),\n )\n return opts?.select ? opts.select(matches) : matches\n },\n structuralSharing: opts?.structuralSharing,\n } as any)\n}\n\n/**\n * Read the array of active route matches that are children of the current\n * match (or selected parent) in the match tree.\n */\nexport function useChildMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected, TStructuralSharing> &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n): UseMatchesResult<TRouter, TSelected> {\n const contextMatchId = React.useContext(matchContext)\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n matches.findIndex((d) => d.id === contextMatchId) + 1,\n )\n return opts?.select ? opts.select(matches) : matches\n },\n structuralSharing: opts?.structuralSharing,\n } as any)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgDA,SAAgB,UAAU;CACxB,MAAM,SAAS,WAAW;CAG1B,MAAM,mBAFsB,OAAO,WAAW,aAGlC,QAAQ,oBAAoB,OAAO,QAAQ;CAEvD,MAAM,iBAAiB,mBAAmB,oBAAC,kBAAD,EAAoB,CAAA,GAAG;CASjE,MAAM,QACJ,sBANC,YAAY,OAAO,aACnB,OAAO,aAAa,eAAe,OAAO,MACvC,eACA,QAAM,UAGV;EAAkB,UAAU;YAA5B,CACG,EAAE,YAAY,OAAO,aAAa,oBAAC,cAAD,EAAgB,CAAA,EACnD,oBAAC,cAAD,EAAgB,CAAA,CACC;;AAGrB,QAAO,OAAO,QAAQ,YACpB,oBAAC,OAAO,QAAQ,WAAhB,EAAA,UAA2B,OAAiC,CAAA,GAE5D;;AAIJ,SAAS,eAAe;CACtB,MAAM,SAAS,WAAW;CAC1B,MAAM,UAAU,eAAe,E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AAW,aAAa;AAErD,QAAO,WAAW;EAChB,SAAS,YAAiD;AACxD,aAAU,QAAQ,MAChB,GACA,QAAQ,WAAW,MAAM,EAAE,OAAO,eAAe,CAClD;AACD,UAAO,MAAM,SAAS,KAAK,OAAO,QAAQ,GAAG;;EAE/C,mBAAmB,MAAM;EAC1B,CAAQ;;;;;;AAOX,SAAgB,gBAKd,MAEsC;CACtC,MAAM,iBAAiB,QAAM,WAAW,aAAa;AAErD,QAAO,WAAW;EAChB,SAAS,YAAiD;AACxD,aAAU,QAAQ,MAChB,QAAQ,WAAW,MAAM,EAAE,OAAO,eAAe,GAAG,EACrD;AACD,UAAO,MAAM,SAAS,KAAK,OAAO,QAAQ,GAAG;;EAE/C,mBAAmB,MAAM;EAC1B,CAAQ"}
@@ -1,32 +1,45 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { Matches } from "./Matches.js";
3
1
  import { routerContext } from "./routerContext.js";
4
- function RouterContextProvider({
5
- router,
6
- children,
7
- ...rest
8
- }) {
9
- if (Object.keys(rest).length > 0) {
10
- router.update({
11
- ...router.options,
12
- ...rest,
13
- context: {
14
- ...router.options.context,
15
- ...rest.context
16
- }
17
- });
18
- }
19
- const provider = /* @__PURE__ */ jsx(routerContext.Provider, { value: router, children });
20
- if (router.options.Wrap) {
21
- return /* @__PURE__ */ jsx(router.options.Wrap, { children: provider });
22
- }
23
- return provider;
2
+ import { Matches } from "./Matches.js";
3
+ import "react";
4
+ import { jsx } from "react/jsx-runtime";
5
+ //#region src/RouterProvider.tsx
6
+ /**
7
+ * Low-level provider that places the router into React context and optionally
8
+ * updates router options from props. Most apps should use `RouterProvider`.
9
+ */
10
+ function RouterContextProvider({ router, children, ...rest }) {
11
+ if (Object.keys(rest).length > 0) router.update({
12
+ ...router.options,
13
+ ...rest,
14
+ context: {
15
+ ...router.options.context,
16
+ ...rest.context
17
+ }
18
+ });
19
+ const provider = /* @__PURE__ */ jsx(routerContext.Provider, {
20
+ value: router,
21
+ children
22
+ });
23
+ if (router.options.Wrap) return /* @__PURE__ */ jsx(router.options.Wrap, { children: provider });
24
+ return provider;
24
25
  }
26
+ /**
27
+ * Top-level component that renders the active route matches and provides the
28
+ * router to the React tree via context.
29
+ *
30
+ * Accepts the same options as `createRouter` via props to update the router
31
+ * instance after creation.
32
+ *
33
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction
34
+ */
25
35
  function RouterProvider({ router, ...rest }) {
26
- return /* @__PURE__ */ jsx(RouterContextProvider, { router, ...rest, children: /* @__PURE__ */ jsx(Matches, {}) });
36
+ return /* @__PURE__ */ jsx(RouterContextProvider, {
37
+ router,
38
+ ...rest,
39
+ children: /* @__PURE__ */ jsx(Matches, {})
40
+ });
27
41
  }
28
- export {
29
- RouterContextProvider,
30
- RouterProvider
31
- };
32
- //# sourceMappingURL=RouterProvider.js.map
42
+ //#endregion
43
+ export { RouterContextProvider, RouterProvider };
44
+
45
+ //# sourceMappingURL=RouterProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RouterProvider.js","sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Matches } from './Matches'\nimport { routerContext } from './routerContext'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterOptions,\n} from '@tanstack/router-core'\n\n/**\n * Low-level provider that places the router into React context and optionally\n * updates router options from props. Most apps should use `RouterProvider`.\n */\nexport function RouterContextProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({\n router,\n children,\n ...rest\n}: RouterProps<TRouter, TDehydrated> & {\n children: React.ReactNode\n}) {\n if (Object.keys(rest).length > 0) {\n // Allow the router to update options on the router instance\n router.update({\n ...router.options,\n ...rest,\n context: {\n ...router.options.context,\n ...rest.context,\n },\n })\n }\n\n const provider = (\n <routerContext.Provider value={router as AnyRouter}>\n {children}\n </routerContext.Provider>\n )\n\n if (router.options.Wrap) {\n return <router.options.Wrap>{provider}</router.options.Wrap>\n }\n\n return provider\n}\n\n/**\n * Top-level component that renders the active route matches and provides the\n * router to the React tree via context.\n *\n * Accepts the same options as `createRouter` via props to update the router\n * instance after creation.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction\n */\nexport function RouterProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({ router, ...rest }: RouterProps<TRouter, TDehydrated>) {\n return (\n <RouterContextProvider router={router} {...rest}>\n <Matches />\n </RouterContextProvider>\n )\n}\n\nexport type RouterProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >,\n 'context'\n> & {\n router: TRouter\n context?: Partial<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >['context']\n >\n}\n"],"names":[],"mappings":";;;AAaO,SAAS,sBAGd;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAEG;AACD,MAAI,OAAO,KAAK,IAAI,EAAE,SAAS,GAAG;AAEhC,WAAO,OAAO;AAAA,MACZ,GAAG,OAAO;AAAA,MACV,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAG,OAAO,QAAQ;AAAA,QAClB,GAAG,KAAK;AAAA,MAAA;AAAA,IACV,CACD;AAAA,EACH;AAEA,QAAM,WACJ,oBAAC,cAAc,UAAd,EAAuB,OAAO,QAC5B,UACH;AAGF,MAAI,OAAO,QAAQ,MAAM;AACvB,WAAO,oBAAC,OAAO,QAAQ,MAAf,EAAqB,UAAA,UAAS;AAAA,EACxC;AAEA,SAAO;AACT;AAWO,SAAS,eAGd,EAAE,QAAQ,GAAG,QAA2C;AACxD,6BACG,uBAAA,EAAsB,QAAiB,GAAG,MACzC,UAAA,oBAAC,WAAQ,GACX;AAEJ;"}
1
+ {"version":3,"file":"RouterProvider.js","names":[],"sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Matches } from './Matches'\nimport { routerContext } from './routerContext'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterOptions,\n} from '@tanstack/router-core'\n\n/**\n * Low-level provider that places the router into React context and optionally\n * updates router options from props. Most apps should use `RouterProvider`.\n */\nexport function RouterContextProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({\n router,\n children,\n ...rest\n}: RouterProps<TRouter, TDehydrated> & {\n children: React.ReactNode\n}) {\n if (Object.keys(rest).length > 0) {\n // Allow the router to update options on the router instance\n router.update({\n ...router.options,\n ...rest,\n context: {\n ...router.options.context,\n ...rest.context,\n },\n })\n }\n\n const provider = (\n <routerContext.Provider value={router as AnyRouter}>\n {children}\n </routerContext.Provider>\n )\n\n if (router.options.Wrap) {\n return <router.options.Wrap>{provider}</router.options.Wrap>\n }\n\n return provider\n}\n\n/**\n * Top-level component that renders the active route matches and provides the\n * router to the React tree via context.\n *\n * Accepts the same options as `createRouter` via props to update the router\n * instance after creation.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction\n */\nexport function RouterProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({ router, ...rest }: RouterProps<TRouter, TDehydrated>) {\n return (\n <RouterContextProvider router={router} {...rest}>\n <Matches />\n </RouterContextProvider>\n )\n}\n\nexport type RouterProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >,\n 'context'\n> & {\n router: TRouter\n context?: Partial<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >['context']\n >\n}\n"],"mappings":";;;;;;;;;AAaA,SAAgB,sBAGd,EACA,QACA,UACA,GAAG,QAGF;AACD,KAAI,OAAO,KAAK,KAAK,CAAC,SAAS,EAE7B,QAAO,OAAO;EACZ,GAAG,OAAO;EACV,GAAG;EACH,SAAS;GACP,GAAG,OAAO,QAAQ;GAClB,GAAG,KAAK;GACT;EACF,CAAC;CAGJ,MAAM,WACJ,oBAAC,cAAc,UAAf;EAAwB,OAAO;EAC5B;EACsB,CAAA;AAG3B,KAAI,OAAO,QAAQ,KACjB,QAAO,oBAAC,OAAO,QAAQ,MAAhB,EAAA,UAAsB,UAA+B,CAAA;AAG9D,QAAO;;;;;;;;;;;AAYT,SAAgB,eAGd,EAAE,QAAQ,GAAG,QAA2C;AACxD,QACE,oBAAC,uBAAD;EAA+B;EAAQ,GAAI;YACzC,oBAAC,SAAD,EAAW,CAAA;EACW,CAAA"}
@@ -1,8 +1,10 @@
1
- import { jsx, Fragment } from "react/jsx-runtime";
1
+ import "react";
2
+ import { Fragment, jsx } from "react/jsx-runtime";
3
+ //#region src/SafeFragment.tsx
2
4
  function SafeFragment(props) {
3
- return /* @__PURE__ */ jsx(Fragment, { children: props.children });
5
+ return /* @__PURE__ */ jsx(Fragment, { children: props.children });
4
6
  }
5
- export {
6
- SafeFragment
7
- };
8
- //# sourceMappingURL=SafeFragment.js.map
7
+ //#endregion
8
+ export { SafeFragment };
9
+
10
+ //# sourceMappingURL=SafeFragment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SafeFragment.js","sources":["../../src/SafeFragment.tsx"],"sourcesContent":["import * as React from 'react'\n\nexport function SafeFragment(props: any) {\n return <>{props.children}</>\n}\n"],"names":[],"mappings":";AAEO,SAAS,aAAa,OAAY;AACvC,SAAO,oBAAA,UAAA,EAAG,gBAAM,SAAA,CAAS;AAC3B;"}
1
+ {"version":3,"file":"SafeFragment.js","names":[],"sources":["../../src/SafeFragment.tsx"],"sourcesContent":["import * as React from 'react'\n\nexport function SafeFragment(props: any) {\n return <>{props.children}</>\n}\n"],"mappings":";;;AAEA,SAAgB,aAAa,OAAY;AACvC,QAAO,oBAAA,UAAA,EAAA,UAAG,MAAM,UAAY,CAAA"}
@@ -1,22 +1,19 @@
1
+ import { useRouter } from "./useRouter.js";
1
2
  import { jsx } from "react/jsx-runtime";
2
3
  import { isServer } from "@tanstack/router-core/isServer";
3
- import { useRouter } from "./useRouter.js";
4
+ //#region src/ScriptOnce.tsx
5
+ /**
6
+ * Server-only helper to emit a script tag exactly once during SSR.
7
+ */
4
8
  function ScriptOnce({ children }) {
5
- const router = useRouter();
6
- if (!(isServer ?? router.isServer)) {
7
- return null;
8
- }
9
- return /* @__PURE__ */ jsx(
10
- "script",
11
- {
12
- nonce: router.options.ssr?.nonce,
13
- dangerouslySetInnerHTML: {
14
- __html: children + ";document.currentScript.remove()"
15
- }
16
- }
17
- );
9
+ const router = useRouter();
10
+ if (!(isServer ?? router.isServer)) return null;
11
+ return /* @__PURE__ */ jsx("script", {
12
+ nonce: router.options.ssr?.nonce,
13
+ dangerouslySetInnerHTML: { __html: children + ";document.currentScript.remove()" }
14
+ });
18
15
  }
19
- export {
20
- ScriptOnce
21
- };
22
- //# sourceMappingURL=ScriptOnce.js.map
16
+ //#endregion
17
+ export { ScriptOnce };
18
+
19
+ //# sourceMappingURL=ScriptOnce.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ScriptOnce.js","sources":["../../src/ScriptOnce.tsx"],"sourcesContent":["import { isServer } from '@tanstack/router-core/isServer'\nimport { useRouter } from './useRouter'\n\n/**\n * Server-only helper to emit a script tag exactly once during SSR.\n */\nexport function ScriptOnce({ children }: { children: string }) {\n const router = useRouter()\n if (!(isServer ?? router.isServer)) {\n return null\n }\n\n return (\n <script\n nonce={router.options.ssr?.nonce}\n dangerouslySetInnerHTML={{\n __html: children + ';document.currentScript.remove()',\n }}\n />\n )\n}\n"],"names":[],"mappings":";;;AAMO,SAAS,WAAW,EAAE,YAAkC;AAC7D,QAAM,SAAS,UAAA;AACf,MAAI,EAAE,YAAY,OAAO,WAAW;AAClC,WAAO;AAAA,EACT;AAEA,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAO,OAAO,QAAQ,KAAK;AAAA,MAC3B,yBAAyB;AAAA,QACvB,QAAQ,WAAW;AAAA,MAAA;AAAA,IACrB;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"ScriptOnce.js","names":[],"sources":["../../src/ScriptOnce.tsx"],"sourcesContent":["import { isServer } from '@tanstack/router-core/isServer'\nimport { useRouter } from './useRouter'\n\n/**\n * Server-only helper to emit a script tag exactly once during SSR.\n */\nexport function ScriptOnce({ children }: { children: string }) {\n const router = useRouter()\n if (!(isServer ?? router.isServer)) {\n return null\n }\n\n return (\n <script\n nonce={router.options.ssr?.nonce}\n dangerouslySetInnerHTML={{\n __html: children + ';document.currentScript.remove()',\n }}\n />\n )\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,WAAW,EAAE,YAAkC;CAC7D,MAAM,SAAS,WAAW;AAC1B,KAAI,EAAE,YAAY,OAAO,UACvB,QAAO;AAGT,QACE,oBAAC,UAAD;EACE,OAAO,OAAO,QAAQ,KAAK;EAC3B,yBAAyB,EACvB,QAAQ,WAAW,oCACpB;EACD,CAAA"}