@tanstack/react-router 1.18.2 → 1.18.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/cjs/Matches.cjs +75 -24
  2. package/dist/cjs/Matches.cjs.map +1 -1
  3. package/dist/cjs/Matches.d.cts +2 -3
  4. package/dist/cjs/RouterProvider.cjs +1 -10
  5. package/dist/cjs/RouterProvider.cjs.map +1 -1
  6. package/dist/cjs/awaited.cjs +2 -4
  7. package/dist/cjs/awaited.cjs.map +1 -1
  8. package/dist/cjs/fileRoute.cjs +6 -1
  9. package/dist/cjs/fileRoute.cjs.map +1 -1
  10. package/dist/cjs/fileRoute.d.cts +7 -6
  11. package/dist/cjs/link.cjs.map +1 -1
  12. package/dist/cjs/not-found.cjs.map +1 -1
  13. package/dist/cjs/not-found.d.cts +11 -1
  14. package/dist/cjs/redirects.cjs +1 -1
  15. package/dist/cjs/redirects.cjs.map +1 -1
  16. package/dist/cjs/route.cjs +3 -2
  17. package/dist/cjs/route.cjs.map +1 -1
  18. package/dist/cjs/route.d.cts +25 -24
  19. package/dist/cjs/router.cjs +172 -143
  20. package/dist/cjs/router.cjs.map +1 -1
  21. package/dist/cjs/router.d.cts +12 -8
  22. package/dist/esm/Matches.d.ts +2 -3
  23. package/dist/esm/Matches.js +67 -16
  24. package/dist/esm/Matches.js.map +1 -1
  25. package/dist/esm/RouterProvider.js +1 -10
  26. package/dist/esm/RouterProvider.js.map +1 -1
  27. package/dist/esm/awaited.js +2 -4
  28. package/dist/esm/awaited.js.map +1 -1
  29. package/dist/esm/fileRoute.d.ts +7 -6
  30. package/dist/esm/fileRoute.js +6 -1
  31. package/dist/esm/fileRoute.js.map +1 -1
  32. package/dist/esm/link.js.map +1 -1
  33. package/dist/esm/not-found.d.ts +11 -1
  34. package/dist/esm/not-found.js.map +1 -1
  35. package/dist/esm/redirects.js +1 -1
  36. package/dist/esm/redirects.js.map +1 -1
  37. package/dist/esm/route.d.ts +25 -24
  38. package/dist/esm/route.js +3 -2
  39. package/dist/esm/route.js.map +1 -1
  40. package/dist/esm/router.d.ts +12 -8
  41. package/dist/esm/router.js +163 -134
  42. package/dist/esm/router.js.map +1 -1
  43. package/package.json +1 -1
  44. package/src/Matches.tsx +100 -27
  45. package/src/RouterProvider.tsx +1 -12
  46. package/src/awaited.tsx +3 -5
  47. package/src/fileRoute.ts +16 -4
  48. package/src/link.tsx +0 -2
  49. package/src/not-found.tsx +11 -1
  50. package/src/redirects.ts +2 -1
  51. package/src/route.ts +55 -114
  52. package/src/router.ts +267 -175
@@ -7,9 +7,9 @@ const warning = require("tiny-warning");
7
7
  const CatchBoundary = require("./CatchBoundary.cjs");
8
8
  const useRouterState = require("./useRouterState.cjs");
9
9
  const useRouter = require("./useRouter.cjs");
10
- const route = require("./route.cjs");
11
10
  const utils = require("./utils.cjs");
12
11
  const notFound = require("./not-found.cjs");
12
+ const redirects = require("./redirects.cjs");
13
13
  function _interopNamespaceDefault(e) {
14
14
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
15
15
  if (e) {
@@ -71,15 +71,15 @@ function Match({ matchId }) {
71
71
  routeId,
72
72
  `Could not find routeId for matchId "${matchId}". Please file an issue!`
73
73
  );
74
- const route2 = router.routesById[routeId];
75
- const PendingComponent = route2.options.pendingComponent ?? router.options.defaultPendingComponent;
74
+ const route = router.routesById[routeId];
75
+ const PendingComponent = route.options.pendingComponent ?? router.options.defaultPendingComponent;
76
76
  const pendingElement = PendingComponent ? /* @__PURE__ */ jsxRuntime.jsx(PendingComponent, {}) : null;
77
- const routeErrorComponent = route2.options.errorComponent ?? router.options.defaultErrorComponent ?? CatchBoundary.ErrorComponent;
78
- const routeNotFoundComponent = route2.isRoot ? (
77
+ const routeErrorComponent = route.options.errorComponent ?? router.options.defaultErrorComponent ?? CatchBoundary.ErrorComponent;
78
+ const routeNotFoundComponent = route.isRoot ? (
79
79
  // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component
80
- route2.options.notFoundComponent ?? ((_a = router.options.notFoundRoute) == null ? void 0 : _a.options.component)
81
- ) : route2.options.notFoundComponent;
82
- const ResolvedSuspenseBoundary = route2.options.wrapInSuspense ?? PendingComponent ?? ((_b = route2.options.component) == null ? void 0 : _b.preload) ?? ((_c = route2.options.pendingComponent) == null ? void 0 : _c.preload) ?? ((_d = route2.options.errorComponent) == null ? void 0 : _d.preload) ? React__namespace.Suspense : SafeFragment;
80
+ route.options.notFoundComponent ?? ((_a = router.options.notFoundRoute) == null ? void 0 : _a.options.component)
81
+ ) : route.options.notFoundComponent;
82
+ const ResolvedSuspenseBoundary = route.options.wrapInSuspense ?? PendingComponent ?? ((_b = route.options.component) == null ? void 0 : _b.preload) ?? ((_c = route.options.pendingComponent) == null ? void 0 : _c.preload) ?? ((_d = route.options.errorComponent) == null ? void 0 : _d.preload) ? React__namespace.Suspense : SafeFragment;
83
83
  const ResolvedCatchBoundary = routeErrorComponent ? CatchBoundary.CatchBoundary : SafeFragment;
84
84
  const ResolvedNotFoundBoundary = routeNotFoundComponent ? notFound.CatchNotFound : SafeFragment;
85
85
  return /* @__PURE__ */ jsxRuntime.jsx(matchContext.Provider, { value: matchId, children: /* @__PURE__ */ jsxRuntime.jsx(ResolvedSuspenseBoundary, { fallback: pendingElement, children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -100,11 +100,9 @@ function Match({ matchId }) {
100
100
  ResolvedNotFoundBoundary,
101
101
  {
102
102
  fallback: (error) => {
103
- if (!routeNotFoundComponent || error.global && !route2.isRoot)
103
+ if (!routeNotFoundComponent || error.routeId && error.routeId !== routeId || !error.routeId && !route.isRoot)
104
104
  throw error;
105
- return React__namespace.createElement(routeNotFoundComponent, {
106
- data: error.data
107
- });
105
+ return React__namespace.createElement(routeNotFoundComponent, error);
108
106
  },
109
107
  children: /* @__PURE__ */ jsxRuntime.jsx(MatchInner, { matchId, pendingElement })
110
108
  }
@@ -124,26 +122,40 @@ function MatchInner({
124
122
  return (_a2 = getRenderedMatches(s).find((d) => d.id === matchId)) == null ? void 0 : _a2.routeId;
125
123
  }
126
124
  });
127
- const route$1 = router.routesById[routeId];
125
+ const route = router.routesById[routeId];
128
126
  const match = useRouterState.useRouterState({
129
127
  select: (s) => utils.pick(getRenderedMatches(s).find((d) => d.id === matchId), [
130
128
  "status",
131
129
  "error",
132
130
  "showPending",
133
- "loadPromise",
134
- "notFoundError"
131
+ "loadPromise"
135
132
  ])
136
133
  });
137
- if (match.notFoundError) {
138
- if (routeId === route.rootRouteId && !route$1.options.notFoundComponent)
139
- return /* @__PURE__ */ jsxRuntime.jsx(notFound.DefaultGlobalNotFound, {});
140
- invariant(
141
- route$1.options.notFoundComponent,
142
- "Route matched with notFoundError should have a notFoundComponent"
134
+ const RouteErrorComponent = (route.options.errorComponent ?? router.options.defaultErrorComponent) || CatchBoundary.ErrorComponent;
135
+ if (match.status === "notFound") {
136
+ invariant(notFound.isNotFound(match.error), "Expected a notFound error");
137
+ return renderRouteNotFound(router, route, match.error.data);
138
+ }
139
+ if (match.status === "redirected") {
140
+ invariant(redirects.isRedirect(match.error), "Expected a redirect error");
141
+ warning(
142
+ false,
143
+ "Tried to render a redirected route match! This is a weird circumstance, please file an issue!"
143
144
  );
144
- return /* @__PURE__ */ jsxRuntime.jsx(route$1.options.notFoundComponent, { data: match.notFoundError });
145
+ return null;
145
146
  }
146
147
  if (match.status === "error") {
148
+ if (utils.isServer) {
149
+ return /* @__PURE__ */ jsxRuntime.jsx(
150
+ RouteErrorComponent,
151
+ {
152
+ error: match.error,
153
+ info: {
154
+ componentStack: ""
155
+ }
156
+ }
157
+ );
158
+ }
147
159
  if (isServerSideError(match.error)) {
148
160
  const deserializeError = ((_a = router.options.errorSerializer) == null ? void 0 : _a.deserialize) ?? defaultDeserializeError;
149
161
  throw deserializeError(match.error.data);
@@ -158,7 +170,7 @@ function MatchInner({
158
170
  throw match.loadPromise;
159
171
  }
160
172
  if (match.status === "success") {
161
- let Comp = route$1.options.component ?? router.options.defaultComponent;
173
+ let Comp = route.options.component ?? router.options.defaultComponent;
162
174
  if (Comp) {
163
175
  return /* @__PURE__ */ jsxRuntime.jsx(Comp, {});
164
176
  }
@@ -170,7 +182,28 @@ function MatchInner({
170
182
  );
171
183
  }
172
184
  const Outlet = React__namespace.memo(function Outlet2() {
185
+ const router = useRouter.useRouter();
173
186
  const matchId = React__namespace.useContext(matchContext);
187
+ const routeId = useRouterState.useRouterState({
188
+ select: (s) => {
189
+ var _a;
190
+ return (_a = getRenderedMatches(s).find((d) => d.id === matchId)) == null ? void 0 : _a.routeId;
191
+ }
192
+ });
193
+ const route = router.routesById[routeId];
194
+ const { parentGlobalNotFound } = useRouterState.useRouterState({
195
+ select: (s) => {
196
+ const matches = getRenderedMatches(s);
197
+ const parentMatch = matches.find((d) => d.id === matchId);
198
+ invariant(
199
+ parentMatch,
200
+ `Could not find parent match for matchId "${matchId}"`
201
+ );
202
+ return {
203
+ parentGlobalNotFound: parentMatch.globalNotFound
204
+ };
205
+ }
206
+ });
174
207
  const childMatchId = useRouterState.useRouterState({
175
208
  select: (s) => {
176
209
  var _a;
@@ -179,11 +212,29 @@ const Outlet = React__namespace.memo(function Outlet2() {
179
212
  return (_a = matches[index + 1]) == null ? void 0 : _a.id;
180
213
  }
181
214
  });
215
+ if (parentGlobalNotFound) {
216
+ return renderRouteNotFound(router, route, void 0);
217
+ }
182
218
  if (!childMatchId) {
183
219
  return null;
184
220
  }
185
221
  return /* @__PURE__ */ jsxRuntime.jsx(Match, { matchId: childMatchId });
186
222
  });
223
+ function renderRouteNotFound(router, route, data) {
224
+ if (!route.options.notFoundComponent) {
225
+ if (router.options.defaultNotFoundComponent) {
226
+ return /* @__PURE__ */ jsxRuntime.jsx(router.options.defaultNotFoundComponent, { data });
227
+ }
228
+ if (process.env.NODE_ENV === "development") {
229
+ warning(
230
+ route.options.notFoundComponent,
231
+ `A notFoundError was encountered on the route with ID "${route.id}", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<div>Not Found<div>)`
232
+ );
233
+ }
234
+ return /* @__PURE__ */ jsxRuntime.jsx(notFound.DefaultGlobalNotFound, {});
235
+ }
236
+ return /* @__PURE__ */ jsxRuntime.jsx(route.options.notFoundComponent, { data });
237
+ }
187
238
  function useMatchRoute() {
188
239
  useRouterState.useRouterState({ select: (s) => [s.location, s.resolvedLocation] });
189
240
  const { matchRoute } = useRouter.useRouter();
@@ -233,7 +284,7 @@ function useMatch(opts) {
233
284
  const matchSelection = useRouterState.useRouterState({
234
285
  select: (state) => {
235
286
  const match = getRenderedMatches(state).find(
236
- (d) => d.id === nearestMatchId
287
+ (d) => (opts == null ? void 0 : opts.from) ? (opts == null ? void 0 : opts.from) === d.routeId : d.id === nearestMatchId
237
288
  );
238
289
  invariant(
239
290
  match,
@@ -1 +1 @@
1
- {"version":3,"file":"Matches.cjs","sources":["../../src/Matches.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { ResolveRelativePath, ToOptions } from './link'\nimport {\n AnyRoute,\n ReactNode,\n RootSearchSchema,\n StaticDataRouteOption,\n UpdatableStaticRouteOption,\n rootRouteId,\n} from './route'\nimport {\n AllParams,\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteByPath,\n RouteIds,\n RoutePaths,\n} from './routeInfo'\nimport { RegisteredRouter, RouterState } from './router'\nimport { DeepPartial, Expand, NoInfer, StrictOrFrom, pick } from './utils'\nimport {\n CatchNotFound,\n DefaultGlobalNotFound,\n NotFoundError,\n isNotFound,\n} from './not-found'\n\nexport const matchContext = React.createContext<string | undefined>(undefined)\n\nexport interface RouteMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n> {\n id: string\n routeId: TRouteId\n pathname: string\n params: TReturnIntersection extends false\n ? RouteById<TRouteTree, TRouteId>['types']['allParams']\n : Expand<Partial<AllParams<TRouteTree>>>\n status: 'pending' | 'success' | 'error'\n isFetching: boolean\n showPending: boolean\n error: unknown\n paramsError: unknown\n searchError: unknown\n updatedAt: number\n loadPromise?: Promise<void>\n loaderData?: RouteById<TRouteTree, TRouteId>['types']['loaderData']\n routeContext: RouteById<TRouteTree, TRouteId>['types']['routeContext']\n context: RouteById<TRouteTree, TRouteId>['types']['allContext']\n search: TReturnIntersection extends false\n ? Exclude<\n RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'],\n RootSearchSchema\n >\n : Expand<\n Partial<Omit<FullSearchSchema<TRouteTree>, keyof RootSearchSchema>>\n >\n fetchCount: number\n abortController: AbortController\n cause: 'preload' | 'enter' | 'stay'\n loaderDeps: RouteById<TRouteTree, TRouteId>['types']['loaderDeps']\n preload: boolean\n invalid: boolean\n pendingPromise?: Promise<void>\n meta?: JSX.IntrinsicElements['meta'][]\n links?: JSX.IntrinsicElements['link'][]\n scripts?: JSX.IntrinsicElements['script'][]\n headers?: Record<string, string>\n notFoundError?: NotFoundError\n staticData: StaticDataRouteOption\n}\n\nexport type AnyRouteMatch = RouteMatch<any, any>\n\nexport function Matches() {\n const router = useRouter()\n const matchId = useRouterState({\n select: (s) => {\n return getRenderedMatches(s)[0]?.id\n },\n })\n\n return (\n <matchContext.Provider value={matchId}>\n <CatchBoundary\n getResetKey={() => router.state.resolvedLocation.state?.key!}\n errorComponent={ErrorComponent}\n onCatch={(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 console.error(error)\n }}\n >\n {matchId ? <Match matchId={matchId} /> : null}\n </CatchBoundary>\n </matchContext.Provider>\n )\n}\n\nfunction SafeFragment(props: any) {\n return <>{props.children}</>\n}\n\nexport function Match({ matchId }: { matchId: string }) {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) =>\n getRenderedMatches(s).find((d) => d.id === matchId)?.routeId as string,\n })\n\n invariant(\n routeId,\n `Could not find routeId for matchId \"${matchId}\". Please file an issue!`,\n )\n\n const route = router.routesById[routeId]!\n\n const PendingComponent = (route.options.pendingComponent ??\n router.options.defaultPendingComponent) as any\n\n const pendingElement = PendingComponent ? <PendingComponent /> : null\n\n const routeErrorComponent =\n route.options.errorComponent ??\n router.options.defaultErrorComponent ??\n ErrorComponent\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 ResolvedSuspenseBoundary =\n route.options.wrapInSuspense ??\n PendingComponent ??\n route.options.component?.preload ??\n route.options.pendingComponent?.preload ??\n (route.options.errorComponent as any)?.preload\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 return (\n <matchContext.Provider value={matchId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => router.state.resolvedLocation.state?.key!}\n errorComponent={routeErrorComponent}\n onCatch={(error) => {\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 console.error(error)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n // If the current not found handler doesn't exist or doesn't handle global not founds, forward it up the tree\n if (!routeNotFoundComponent || (error.global && !route.isRoot))\n throw error\n\n return React.createElement(routeNotFoundComponent, {\n data: error.data,\n })\n }}\n >\n <MatchInner matchId={matchId!} pendingElement={pendingElement} />\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n )\n}\n\nfunction MatchInner({\n matchId,\n pendingElement,\n}: {\n matchId: string\n pendingElement: any\n}): any {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) =>\n getRenderedMatches(s).find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const match = useRouterState({\n select: (s) =>\n pick(getRenderedMatches(s).find((d) => d.id === matchId)!, [\n 'status',\n 'error',\n 'showPending',\n 'loadPromise',\n 'notFoundError',\n ]),\n })\n\n // If a global not-found is found, and it's the root route, render the global not-found component.\n if (match.notFoundError) {\n if (routeId === rootRouteId && !route.options.notFoundComponent)\n return <DefaultGlobalNotFound />\n\n invariant(\n route.options.notFoundComponent,\n 'Route matched with notFoundError should have a notFoundComponent',\n )\n\n return <route.options.notFoundComponent data={match.notFoundError} />\n }\n\n if (match.status === 'error') {\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n throw deserializeError(match.error.data)\n } else {\n throw match.error\n }\n }\n\n if (match.status === 'pending') {\n if (match.showPending) {\n return pendingElement\n }\n throw match.loadPromise\n }\n\n if (match.status === 'success') {\n let Comp = route.options.component ?? router.options.defaultComponent\n\n if (Comp) {\n return <Comp />\n }\n\n return <Outlet />\n }\n\n invariant(\n false,\n 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!',\n )\n}\n\nexport const Outlet = React.memo(function Outlet() {\n const matchId = React.useContext(matchContext)\n\n const childMatchId = useRouterState({\n select: (s) => {\n const matches = getRenderedMatches(s)\n const index = matches.findIndex((d) => d.id === matchId)\n return matches[index + 1]?.id\n },\n })\n\n if (!childMatchId) {\n return null\n }\n\n return <Match matchId={childMatchId} />\n})\n\nexport interface MatchRouteOptions {\n pending?: boolean\n caseSensitive?: boolean\n includeSearch?: boolean\n fuzzy?: boolean\n}\n\nexport type UseMatchRouteOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n Options extends ToOptions<\n TRouteTree,\n TFrom,\n TTo,\n TMaskFrom,\n TMaskTo\n > = ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n RelaxedOptions = Omit<Options, 'search' | 'params'> &\n DeepPartial<Pick<Options, 'search' | 'params'>>,\n> = RelaxedOptions & MatchRouteOptions\n\nexport function useMatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n>() {\n useRouterState({ select: (s) => [s.location, s.resolvedLocation] })\n const { matchRoute } = useRouter()\n\n return React.useCallback(\n <\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>,\n >(\n opts: UseMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n ): false | RouteById<TRouteTree, TResolved>['types']['allParams'] => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n return matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n },\n [],\n )\n}\n\nexport type MakeMatchRouteOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n> = UseMatchRouteOptions<TRouteTree, 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 TRouteTree,\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => ReactNode)\n | React.ReactNode\n}\n\nexport function MatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n>(\n props: MakeMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any)\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 function getRenderedMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n>(state: RouterState<TRouteTree>) {\n return state.pendingMatches?.some((d) => d.showPending)\n ? state.pendingMatches\n : state.matches\n}\n\nexport function useMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TReturnIntersection extends boolean = false,\n TRouteMatchState = RouteMatch<TRouteTree, TFrom, TReturnIntersection>,\n TSelected = TRouteMatchState,\n>(\n opts: StrictOrFrom<TFrom, TReturnIntersection> & {\n select?: (match: TRouteMatchState) => TSelected\n },\n): TSelected {\n const router = useRouter()\n const nearestMatchId = React.useContext(matchContext)\n\n const nearestMatchRouteId = getRenderedMatches(router.state).find(\n (d) => d.id === nearestMatchId,\n )?.routeId\n\n const matchRouteId = (() => {\n const matches = getRenderedMatches(router.state)\n const match = opts?.from\n ? matches.find((d) => d.routeId === opts?.from)\n : matches.find((d) => d.id === nearestMatchId)\n return match!.routeId\n })()\n\n if (opts?.strict ?? true) {\n invariant(\n nearestMatchRouteId == matchRouteId,\n `useMatch(\"${\n matchRouteId as string\n }\") is being called in a component that is meant to render the '${nearestMatchRouteId}' route. Did you mean to 'useMatch(\"${\n matchRouteId as string\n }\", { strict: false })' or 'useRoute(\"${\n matchRouteId as string\n }\")' instead?`,\n )\n }\n\n const matchSelection = useRouterState({\n select: (state) => {\n const match = getRenderedMatches(state).find(\n (d) => d.id === nearestMatchId,\n )\n\n invariant(\n match,\n `Could not find ${\n opts?.from\n ? `an active match from \"${opts.from}\"`\n : 'a nearest match!'\n }`,\n )\n\n return opts?.select ? opts.select(match as any) : match\n },\n })\n\n return matchSelection as any\n}\n\nexport function useMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = TRouteMatch[],\n>(opts?: {\n select?: (matches: TRouteMatch[]) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n return useRouterState({\n select: (state) => {\n const matches = getRenderedMatches(state)\n return opts?.select\n ? opts.select(matches as TRouteMatch[])\n : (matches as T)\n },\n })\n}\n\nexport function useParentMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = TRouteMatch[],\n>(opts?: {\n select?: (matches: TRouteMatch[]) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n const contextMatchId = React.useContext(matchContext)\n\n return useMatches({\n select: (matches) => {\n matches = matches.slice(\n 0,\n matches.findIndex((d) => d.id === contextMatchId),\n )\n return opts?.select\n ? opts.select(matches as TRouteMatch[])\n : (matches as T)\n },\n })\n}\n\nexport function useChildMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = TRouteMatch[],\n>(opts?: {\n select?: (matches: TRouteMatch[]) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n const contextMatchId = React.useContext(matchContext)\n\n return useMatches({\n select: (matches) => {\n matches = matches.slice(\n matches.findIndex((d) => d.id === contextMatchId) + 1,\n )\n return opts?.select\n ? opts.select(matches as TRouteMatch[])\n : (matches as T)\n },\n })\n}\n\nexport function useLoaderDeps<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<\n TRouteTree,\n TFrom\n >,\n TSelected = Required<TRouteMatch>['loaderDeps'],\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatch) => TSelected\n },\n): TSelected {\n return useMatch({\n ...opts,\n select: (s) => {\n return typeof opts.select === 'function'\n ? opts.select(s?.loaderDeps)\n : s?.loaderDeps\n },\n })\n}\n\nexport function useLoaderData<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<\n TRouteTree,\n TFrom\n >,\n TSelected = Required<TRouteMatch>['loaderData'],\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatch) => TSelected\n },\n): TSelected {\n return useMatch({\n ...opts,\n select: (s) => {\n return typeof opts.select === 'function'\n ? opts.select(s?.loaderData)\n : s?.loaderData\n },\n })\n}\n\nexport function isServerSideError(error: unknown): error is {\n __isServerError: true\n data: Record<string, any>\n} {\n if (!(typeof error === 'object' && error && 'data' in error)) return false\n if (!('__isServerError' in error && error.__isServerError)) return false\n if (!(typeof error.data === 'object' && error.data)) return false\n\n return error.__isServerError === true\n}\n\nexport function defaultDeserializeError(serializedData: Record<string, any>) {\n if ('name' in serializedData && 'message' in serializedData) {\n const error = new Error(serializedData.message)\n error.name = serializedData.name\n return error\n }\n\n return serializedData.data\n}\n"],"names":["React","useRouter","useRouterState","jsx","CatchBoundary","ErrorComponent","Fragment","_a","route","CatchNotFound","isNotFound","pick","rootRouteId","DefaultGlobalNotFound","Outlet"],"mappings":";;;;;;;;;;;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AO,eAAe;AACrB,WAAA;AAAA,EACT;AAEA,SAAO,eAAe;AACxB;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Matches.cjs","sources":["../../src/Matches.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { ResolveRelativePath, ToOptions } from './link'\nimport {\n AnyRoute,\n ReactNode,\n RootSearchSchema,\n StaticDataRouteOption,\n} from './route'\nimport {\n AllParams,\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteByPath,\n RouteIds,\n RoutePaths,\n} from './routeInfo'\nimport { AnyRouter, RegisteredRouter, RouterState } from './router'\nimport {\n DeepPartial,\n Expand,\n NoInfer,\n StrictOrFrom,\n isServer,\n pick,\n} from './utils'\nimport { CatchNotFound, DefaultGlobalNotFound, isNotFound } from './not-found'\nimport { isRedirect } from './redirects'\n\nexport const matchContext = React.createContext<string | undefined>(undefined)\n\nexport interface RouteMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n> {\n id: string\n routeId: TRouteId\n pathname: string\n params: TReturnIntersection extends false\n ? RouteById<TRouteTree, TRouteId>['types']['allParams']\n : Expand<Partial<AllParams<TRouteTree>>>\n status: 'pending' | 'success' | 'error' | 'redirected' | 'notFound'\n isFetching: boolean\n showPending: boolean\n error: unknown\n paramsError: unknown\n searchError: unknown\n updatedAt: number\n loadPromise?: Promise<void>\n loaderData?: RouteById<TRouteTree, TRouteId>['types']['loaderData']\n routeContext: RouteById<TRouteTree, TRouteId>['types']['routeContext']\n context: RouteById<TRouteTree, TRouteId>['types']['allContext']\n search: TReturnIntersection extends false\n ? Exclude<\n RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'],\n RootSearchSchema\n >\n : Expand<\n Partial<Omit<FullSearchSchema<TRouteTree>, keyof RootSearchSchema>>\n >\n fetchCount: number\n abortController: AbortController\n cause: 'preload' | 'enter' | 'stay'\n loaderDeps: RouteById<TRouteTree, TRouteId>['types']['loaderDeps']\n preload: boolean\n invalid: boolean\n pendingPromise?: Promise<void>\n meta?: JSX.IntrinsicElements['meta'][]\n links?: JSX.IntrinsicElements['link'][]\n scripts?: JSX.IntrinsicElements['script'][]\n headers?: Record<string, string>\n globalNotFound?: boolean\n staticData: StaticDataRouteOption\n}\n\nexport type AnyRouteMatch = RouteMatch<any, any>\n\nexport function Matches() {\n const router = useRouter()\n const matchId = useRouterState({\n select: (s) => {\n return getRenderedMatches(s)[0]?.id\n },\n })\n\n return (\n <matchContext.Provider value={matchId}>\n <CatchBoundary\n getResetKey={() => router.state.resolvedLocation.state?.key!}\n errorComponent={ErrorComponent}\n onCatch={(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 console.error(error)\n }}\n >\n {matchId ? <Match matchId={matchId} /> : null}\n </CatchBoundary>\n </matchContext.Provider>\n )\n}\n\nfunction SafeFragment(props: any) {\n return <>{props.children}</>\n}\n\nexport function Match({ matchId }: { matchId: string }) {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) =>\n getRenderedMatches(s).find((d) => d.id === matchId)?.routeId as string,\n })\n\n invariant(\n routeId,\n `Could not find routeId for matchId \"${matchId}\". Please file an issue!`,\n )\n\n const route = router.routesById[routeId]!\n\n const PendingComponent = (route.options.pendingComponent ??\n router.options.defaultPendingComponent) as any\n\n const pendingElement = PendingComponent ? <PendingComponent /> : null\n\n const routeErrorComponent =\n route.options.errorComponent ??\n router.options.defaultErrorComponent ??\n ErrorComponent\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 ResolvedSuspenseBoundary =\n route.options.wrapInSuspense ??\n PendingComponent ??\n route.options.component?.preload ??\n route.options.pendingComponent?.preload ??\n (route.options.errorComponent as any)?.preload\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 return (\n <matchContext.Provider value={matchId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => router.state.resolvedLocation.state?.key!}\n errorComponent={routeErrorComponent}\n onCatch={(error) => {\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 console.error(error)\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 !== routeId) ||\n (!error.routeId && !route.isRoot)\n )\n throw error\n\n return React.createElement(routeNotFoundComponent, error as any)\n }}\n >\n <MatchInner matchId={matchId!} pendingElement={pendingElement} />\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n )\n}\n\nfunction MatchInner({\n matchId,\n pendingElement,\n}: {\n matchId: string\n pendingElement: any\n}): any {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) =>\n getRenderedMatches(s).find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const match = useRouterState({\n select: (s) =>\n pick(getRenderedMatches(s).find((d) => d.id === matchId)!, [\n 'status',\n 'error',\n 'showPending',\n 'loadPromise',\n ]),\n })\n\n const RouteErrorComponent =\n (route.options.errorComponent ?? router.options.defaultErrorComponent) ||\n ErrorComponent\n\n if (match.status === 'notFound') {\n invariant(isNotFound(match.error), 'Expected a notFound error')\n\n return renderRouteNotFound(router, route, match.error.data)\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\n return null\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) {\n return (\n <RouteErrorComponent\n error={match.error}\n info={{\n componentStack: '',\n }}\n />\n )\n }\n\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n throw deserializeError(match.error.data)\n } else {\n throw match.error\n }\n }\n\n if (match.status === 'pending') {\n if (match.showPending) {\n return pendingElement\n }\n throw match.loadPromise\n }\n\n if (match.status === 'success') {\n let Comp = route.options.component ?? router.options.defaultComponent\n\n if (Comp) {\n return <Comp />\n }\n\n return <Outlet />\n }\n\n invariant(\n false,\n 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!',\n )\n}\n\nexport const Outlet = React.memo(function Outlet() {\n const router = useRouter()\n const matchId = React.useContext(matchContext)\n const routeId = useRouterState({\n select: (s) =>\n getRenderedMatches(s).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 = getRenderedMatches(s)\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 {\n parentGlobalNotFound: parentMatch.globalNotFound,\n }\n },\n })\n\n const childMatchId = useRouterState({\n select: (s) => {\n const matches = getRenderedMatches(s)\n const index = matches.findIndex((d) => d.id === matchId)\n return matches[index + 1]?.id\n },\n })\n\n if (parentGlobalNotFound) {\n return renderRouteNotFound(router, route, undefined)\n }\n\n if (!childMatchId) {\n return null\n }\n\n return <Match matchId={childMatchId} />\n})\n\nfunction renderRouteNotFound(router: AnyRouter, route: AnyRoute, data: any) {\n if (!route.options.notFoundComponent) {\n if (router.options.defaultNotFoundComponent) {\n return <router.options.defaultNotFoundComponent data={data} />\n }\n\n if (process.env.NODE_ENV === 'development') {\n warning(\n route.options.notFoundComponent,\n `A notFoundError was encountered on the route with ID \"${route.id}\", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<div>Not Found<div>)`,\n )\n }\n\n return <DefaultGlobalNotFound />\n }\n\n return <route.options.notFoundComponent data={data} />\n}\n\nexport interface MatchRouteOptions {\n pending?: boolean\n caseSensitive?: boolean\n includeSearch?: boolean\n fuzzy?: boolean\n}\n\nexport type UseMatchRouteOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n Options extends ToOptions<\n TRouteTree,\n TFrom,\n TTo,\n TMaskFrom,\n TMaskTo\n > = ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n RelaxedOptions = Omit<Options, 'search' | 'params'> &\n DeepPartial<Pick<Options, 'search' | 'params'>>,\n> = RelaxedOptions & MatchRouteOptions\n\nexport function useMatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n>() {\n useRouterState({ select: (s) => [s.location, s.resolvedLocation] })\n const { matchRoute } = useRouter()\n\n return React.useCallback(\n <\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>,\n >(\n opts: UseMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n ): false | RouteById<TRouteTree, TResolved>['types']['allParams'] => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n return matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n },\n [],\n )\n}\n\nexport type MakeMatchRouteOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n> = UseMatchRouteOptions<TRouteTree, 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 TRouteTree,\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => ReactNode)\n | React.ReactNode\n}\n\nexport function MatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n>(\n props: MakeMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any)\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 function getRenderedMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n>(state: RouterState<TRouteTree>) {\n return state.pendingMatches?.some((d) => d.showPending)\n ? state.pendingMatches\n : state.matches\n}\n\nexport function useMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TReturnIntersection extends boolean = false,\n TRouteMatchState = RouteMatch<TRouteTree, TFrom, TReturnIntersection>,\n TSelected = TRouteMatchState,\n>(\n opts: StrictOrFrom<TFrom, TReturnIntersection> & {\n select?: (match: TRouteMatchState) => TSelected\n },\n): TSelected {\n const router = useRouter()\n const nearestMatchId = React.useContext(matchContext)\n\n const nearestMatchRouteId = getRenderedMatches(router.state).find(\n (d) => d.id === nearestMatchId,\n )?.routeId\n\n const matchRouteId = (() => {\n const matches = getRenderedMatches(router.state)\n const match = opts?.from\n ? matches.find((d) => d.routeId === opts?.from)\n : matches.find((d) => d.id === nearestMatchId)\n return match!.routeId\n })()\n\n if (opts?.strict ?? true) {\n invariant(\n nearestMatchRouteId == matchRouteId,\n `useMatch(\"${\n matchRouteId as string\n }\") is being called in a component that is meant to render the '${nearestMatchRouteId}' route. Did you mean to 'useMatch(\"${\n matchRouteId as string\n }\", { strict: false })' or 'useRoute(\"${\n matchRouteId as string\n }\")' instead?`,\n )\n }\n\n const matchSelection = useRouterState({\n select: (state) => {\n const match = getRenderedMatches(state).find((d) =>\n opts?.from ? opts?.from === d.routeId : d.id === nearestMatchId,\n )\n\n invariant(\n match,\n `Could not find ${\n opts?.from\n ? `an active match from \"${opts.from}\"`\n : 'a nearest match!'\n }`,\n )\n\n return opts?.select ? opts.select(match as any) : match\n },\n })\n\n return matchSelection as any\n}\n\nexport function useMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = TRouteMatch[],\n>(opts?: {\n select?: (matches: TRouteMatch[]) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n return useRouterState({\n select: (state) => {\n const matches = getRenderedMatches(state)\n return opts?.select\n ? opts.select(matches as TRouteMatch[])\n : (matches as T)\n },\n })\n}\n\nexport function useParentMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = TRouteMatch[],\n>(opts?: {\n select?: (matches: TRouteMatch[]) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n const contextMatchId = React.useContext(matchContext)\n\n return useMatches({\n select: (matches) => {\n matches = matches.slice(\n 0,\n matches.findIndex((d) => d.id === contextMatchId),\n )\n return opts?.select\n ? opts.select(matches as TRouteMatch[])\n : (matches as T)\n },\n })\n}\n\nexport function useChildMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = TRouteMatch[],\n>(opts?: {\n select?: (matches: TRouteMatch[]) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n const contextMatchId = React.useContext(matchContext)\n\n return useMatches({\n select: (matches) => {\n matches = matches.slice(\n matches.findIndex((d) => d.id === contextMatchId) + 1,\n )\n return opts?.select\n ? opts.select(matches as TRouteMatch[])\n : (matches as T)\n },\n })\n}\n\nexport function useLoaderDeps<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<\n TRouteTree,\n TFrom\n >,\n TSelected = Required<TRouteMatch>['loaderDeps'],\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatch) => TSelected\n },\n): TSelected {\n return useMatch({\n ...opts,\n select: (s) => {\n return typeof opts.select === 'function'\n ? opts.select(s?.loaderDeps)\n : s?.loaderDeps\n },\n })\n}\n\nexport function useLoaderData<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<\n TRouteTree,\n TFrom\n >,\n TSelected = Required<TRouteMatch>['loaderData'],\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatch) => TSelected\n },\n): TSelected {\n return useMatch({\n ...opts,\n select: (s) => {\n return typeof opts.select === 'function'\n ? opts.select(s?.loaderData)\n : s?.loaderData\n },\n })\n}\n\nexport function isServerSideError(error: unknown): error is {\n __isServerError: true\n data: Record<string, any>\n} {\n if (!(typeof error === 'object' && error && 'data' in error)) return false\n if (!('__isServerError' in error && error.__isServerError)) return false\n if (!(typeof error.data === 'object' && error.data)) return false\n\n return error.__isServerError === true\n}\n\nexport function defaultDeserializeError(serializedData: Record<string, any>) {\n if ('name' in serializedData && 'message' in serializedData) {\n const error = new Error(serializedData.message)\n error.name = serializedData.name\n return error\n }\n\n return serializedData.data\n}\n"],"names":["React","useRouter","useRouterState","jsx","CatchBoundary","ErrorComponent","Fragment","_a","CatchNotFound","isNotFound","pick","isRedirect","isServer","Outlet","DefaultGlobalNotFound"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCa,MAAA,eAAeA,iBAAM,cAAkC,MAAS;AAiDtE,SAAS,UAAU;AACxB,QAAM,SAASC,UAAAA;AACf,QAAM,UAAUC,eAAAA,eAAe;AAAA,IAC7B,QAAQ,CAAC,MAAM;;AACb,cAAO,wBAAmB,CAAC,EAAE,CAAC,MAAvB,mBAA0B;AAAA,IACnC;AAAA,EAAA,CACD;AAED,SACGC,2BAAAA,IAAA,aAAa,UAAb,EAAsB,OAAO,SAC5B,UAAAA,2BAAA;AAAA,IAACC,cAAA;AAAA,IAAA;AAAA,MACC,aAAa,MAAA;;AAAM,4BAAO,MAAM,iBAAiB,UAA9B,mBAAqC;AAAA;AAAA,MACxD,gBAAgBC,cAAA;AAAA,MAChB,SAAS,CAAC,UAAU;AAClB;AAAA,UACE;AAAA,UACA;AAAA,QAAA;AAEF,gBAAQ,MAAM,KAAK;AAAA,MACrB;AAAA,MAEC,UAAU,UA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ASd,MAGW;AACX,SAAO,SAAS;AAAA,IACd,GAAG;AAAA,IACH,QAAQ,CAAC,MAAM;AACN,aAAA,OAAO,KAAK,WAAW,aAC1B,KAAK,OAAO,uBAAG,UAAU,IACzB,uBAAG;AAAA,IACT;AAAA,EAAA,CACD;AACH;AAEO,SAAS,cASd,MAGW;AACX,SAAO,SAAS;AAAA,IACd,GAAG;AAAA,IACH,QAAQ,CAAC,MAAM;AACN,aAAA,OAAO,KAAK,WAAW,aAC1B,KAAK,OAAO,uBAAG,UAAU,IACzB,uBAAG;AAAA,IACT;AAAA,EAAA,CACD;AACH;AAEO,SAAS,kBAAkB,OAGhC;AACA,MAAI,EAAE,OAAO,UAAU,YAAY,SAAS,UAAU;AAAe,WAAA;AACjE,MAAA,EAAE,qBAAqB,SAAS,MAAM;AAAyB,WAAA;AACnE,MAAI,EAAE,OAAO,MAAM,SAAS,YAAY,MAAM;AAAc,WAAA;AAE5D,SAAO,MAAM,oBAAoB;AACnC;AAEO,SAAS,wBAAwB,gBAAqC;AACvE,MAAA,UAAU,kBAAkB,aAAa,gBAAgB;AAC3D,UAAM,QAAQ,IAAI,MAAM,eAAe,OAAO;AAC9C,UAAM,OAAO,eAAe;AACrB,WAAA;AAAA,EACT;AAEA,SAAO,eAAe;AACxB;;;;;;;;;;;;;;;;"}
@@ -4,14 +4,13 @@ import { AnyRoute, ReactNode, RootSearchSchema, StaticDataRouteOption } from './
4
4
  import { AllParams, FullSearchSchema, ParseRoute, RouteById, RouteByPath, RouteIds, RoutePaths } from './routeInfo.cjs';
5
5
  import { RegisteredRouter, RouterState } from './router.cjs';
6
6
  import { DeepPartial, Expand, NoInfer, StrictOrFrom } from './utils.cjs';
7
- import { NotFoundError } from './not-found.cjs';
8
7
  export declare const matchContext: React.Context<string | undefined>;
9
8
  export interface RouteMatch<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'], TReturnIntersection extends boolean = false> {
10
9
  id: string;
11
10
  routeId: TRouteId;
12
11
  pathname: string;
13
12
  params: TReturnIntersection extends false ? RouteById<TRouteTree, TRouteId>['types']['allParams'] : Expand<Partial<AllParams<TRouteTree>>>;
14
- status: 'pending' | 'success' | 'error';
13
+ status: 'pending' | 'success' | 'error' | 'redirected' | 'notFound';
15
14
  isFetching: boolean;
16
15
  showPending: boolean;
17
16
  error: unknown;
@@ -34,7 +33,7 @@ export interface RouteMatch<TRouteTree extends AnyRoute = RegisteredRouter['rout
34
33
  links?: JSX.IntrinsicElements['link'][];
35
34
  scripts?: JSX.IntrinsicElements['script'][];
36
35
  headers?: Record<string, string>;
37
- notFoundError?: NotFoundError;
36
+ globalNotFound?: boolean;
38
37
  staticData: StaticDataRouteOption;
39
38
  }
40
39
  export type AnyRouteMatch = RouteMatch<any, any>;
@@ -85,19 +85,10 @@ function Transitioner() {
85
85
  utils.useLayoutEffect(() => {
86
86
  const unsub = router.history.subscribe(() => {
87
87
  router.latestLocation = router.parseLocation(router.latestLocation);
88
- if (routerState.location !== router.latestLocation) {
88
+ if (router.state.location !== router.latestLocation) {
89
89
  tryLoad();
90
90
  }
91
91
  });
92
- const nextLocation = router.buildLocation({
93
- search: true,
94
- params: true,
95
- hash: true,
96
- state: true
97
- });
98
- if (routerState.location.href !== nextLocation.href) {
99
- router.commitLocation({ ...nextLocation, replace: true });
100
- }
101
92
  return () => {
102
93
  unsub();
103
94
  };
@@ -1 +1 @@
1
- {"version":3,"file":"RouterProvider.cjs","sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Matches } from './Matches'\nimport { NavigateOptions, ToOptions } from './link'\nimport { ParsedLocation } from './location'\nimport { AnyRoute } from './route'\nimport { RoutePaths } from './routeInfo'\nimport { RegisteredRouter, Router, RouterOptions, RouterState } from './router'\nimport { pick, useLayoutEffect } from './utils'\n\nimport { RouteMatch } from './Matches'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\nimport { getRouterContext } from './routerContext'\n\nconst useTransition =\n React.useTransition ||\n (() => [\n false,\n (cb) => {\n cb()\n },\n ])\n\nexport interface CommitLocationOptions {\n replace?: boolean\n resetScroll?: boolean\n startTransition?: boolean\n}\n\nexport interface MatchLocation {\n to?: string | number | null\n fuzzy?: boolean\n caseSensitive?: boolean\n from?: string\n}\n\nexport type NavigateFn = <\n TTo extends string,\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> | string = string,\n TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,\n TMaskTo extends string = '',\n>(\n opts: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n) => Promise<void>\n\nexport type BuildLocationFn<TRouteTree extends AnyRoute> = <\n TTo extends string,\n TFrom extends RoutePaths<TRouteTree> | string = string,\n TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,\n TMaskTo extends string = '',\n>(\n opts: ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {\n leaveParams?: boolean\n },\n) => ParsedLocation\n\nexport type InjectedHtmlEntry = string | (() => Promise<string> | string)\n\nexport function RouterProvider<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({ router, ...rest }: RouterProps<TRouteTree, TDehydrated>) {\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 } as any)\n\n const matches = router.options.InnerWrap ? (\n <router.options.InnerWrap>\n <Matches />\n </router.options.InnerWrap>\n ) : (\n <Matches />\n )\n\n const routerContext = getRouterContext()\n\n const provider = (\n <routerContext.Provider value={router}>\n {matches}\n <Transitioner />\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\nfunction Transitioner() {\n const router = useRouter()\n const mountLoadForRouter = React.useRef({ router, mounted: false })\n const routerState = useRouterState({\n select: (s) =>\n pick(s, ['isLoading', 'location', 'resolvedLocation', 'isTransitioning']),\n })\n\n const [isTransitioning, startReactTransition] = useTransition()\n\n router.startReactTransition = startReactTransition\n\n React.useEffect(() => {\n if (isTransitioning) {\n router.__store.setState((s) => ({\n ...s,\n isTransitioning,\n }))\n }\n }, [isTransitioning])\n\n const tryLoad = () => {\n const apply = (cb: () => void) => {\n if (!routerState.isTransitioning) {\n startReactTransition(() => cb())\n } else {\n cb()\n }\n }\n\n apply(() => {\n try {\n router.load()\n } catch (err) {\n console.error(err)\n }\n })\n }\n\n useLayoutEffect(() => {\n const unsub = router.history.subscribe(() => {\n router.latestLocation = router.parseLocation(router.latestLocation)\n if (routerState.location !== router.latestLocation) {\n tryLoad()\n }\n })\n\n const nextLocation = router.buildLocation({\n search: true,\n params: true,\n hash: true,\n state: true,\n })\n\n if (routerState.location.href !== nextLocation.href) {\n router.commitLocation({ ...nextLocation, replace: true })\n }\n\n return () => {\n unsub()\n }\n }, [router.history])\n\n useLayoutEffect(() => {\n if (\n (React.useTransition as any)\n ? routerState.isTransitioning && !isTransitioning\n : true &&\n !routerState.isLoading &&\n routerState.resolvedLocation !== routerState.location\n ) {\n router.emit({\n type: 'onResolved',\n fromLocation: routerState.resolvedLocation,\n toLocation: routerState.location,\n pathChanged:\n routerState.location!.href !== routerState.resolvedLocation?.href,\n })\n\n if ((document as any).querySelector) {\n if (routerState.location.hash !== '') {\n const el = document.getElementById(\n routerState.location.hash,\n ) as HTMLElement | null\n if (el) {\n el.scrollIntoView()\n }\n }\n }\n\n router.__store.setState((s) => ({\n ...s,\n isTransitioning: false,\n resolvedLocation: s.location,\n }))\n }\n }, [\n routerState.isTransitioning,\n isTransitioning,\n routerState.isLoading,\n routerState.resolvedLocation,\n routerState.location,\n ])\n\n useLayoutEffect(() => {\n if (\n window.__TSR_DEHYDRATED__ ||\n (mountLoadForRouter.current.router === router &&\n mountLoadForRouter.current.mounted)\n ) {\n return\n }\n mountLoadForRouter.current = { router, mounted: true }\n tryLoad()\n }, [router])\n\n return null\n}\n\nexport function getRouteMatch<TRouteTree extends AnyRoute>(\n state: RouterState<TRouteTree>,\n id: string,\n): undefined | RouteMatch<TRouteTree> {\n return [\n ...state.cachedMatches,\n ...(state.pendingMatches ?? []),\n ...state.matches,\n ].find((d) => d.id === id)\n}\n\nexport type RouterProps<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<RouterOptions<TRouteTree, TDehydrated>, 'context'> & {\n router: Router<TRouteTree>\n context?: Partial<RouterOptions<TRouteTree, TDehydrated>['context']>\n}\n"],"names":["React","jsx","Matches","routerContext","getRouterContext","jsxs","useRouter","useRouterState","pick","useLayoutEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,gBACJA,iBAAM,kBACL,MAAM;AAAA,EACL;AAAA,EACA,CAAC,OAAO;AACH;EACL;AACF;AAsCK,SAAS,eAGd,EAAE,QAAQ,GAAG,QAA8C;AAE3D,SAAO,OAAO;AAAA,IACZ,GAAG,OAAO;AAAA,IACV,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,OAAO,QAAQ;AAAA,MAClB,GAAG,6BAAM;AAAA,IACX;AAAA,EAAA,CACM;AAER,QAAM,UAAU,OAAO,QAAQ,2CAC5B,OAAO,QAAQ,WAAf,EACC,UAACC,2BAAA,IAAAC,QAAA,SAAA,EAAQ,EACX,CAAA,mCAECA,QAAAA,SAAQ,CAAA,CAAA;AAGX,QAAMC,kBAAgBC,cAAAA;AAEtB,QAAM,WACHC,2BAAAA,KAAAF,gBAAc,UAAd,EAAuB,OAAO,QAC5B,UAAA;AAAA,IAAA;AAAA,mCACA,cAAa,EAAA;AAAA,EAChB,EAAA,CAAA;AAGE,MAAA,OAAO,QAAQ,MAAM;AACvB,WAAQF,2BAAAA,IAAA,OAAO,QAAQ,MAAf,EAAqB,UAAS,SAAA,CAAA;AAAA,EACxC;AAEO,SAAA;AACT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from 'react'\nimport { Matches } from './Matches'\nimport { NavigateOptions, ToOptions } from './link'\nimport { ParsedLocation } from './location'\nimport { AnyRoute } from './route'\nimport { RoutePaths } from './routeInfo'\nimport { RegisteredRouter, Router, RouterOptions, RouterState } from './router'\nimport { pick, useLayoutEffect } from './utils'\n\nimport { RouteMatch } from './Matches'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\nimport { getRouterContext } from './routerContext'\n\nconst useTransition =\n React.useTransition ||\n (() => [\n false,\n (cb) => {\n cb()\n },\n ])\n\nexport interface CommitLocationOptions {\n replace?: boolean\n resetScroll?: boolean\n startTransition?: boolean\n}\n\nexport interface MatchLocation {\n to?: string | number | null\n fuzzy?: boolean\n caseSensitive?: boolean\n from?: string\n}\n\nexport type NavigateFn = <\n TTo extends string,\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> | string = string,\n TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,\n TMaskTo extends string = '',\n>(\n opts: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n) => Promise<void>\n\nexport type BuildLocationFn<TRouteTree extends AnyRoute> = <\n TTo extends string,\n TFrom extends RoutePaths<TRouteTree> | string = string,\n TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,\n TMaskTo extends string = '',\n>(\n opts: ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {\n leaveParams?: boolean\n },\n) => ParsedLocation\n\nexport type InjectedHtmlEntry = string | (() => Promise<string> | string)\n\nexport function RouterProvider<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({ router, ...rest }: RouterProps<TRouteTree, TDehydrated>) {\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 } as any)\n\n const matches = router.options.InnerWrap ? (\n <router.options.InnerWrap>\n <Matches />\n </router.options.InnerWrap>\n ) : (\n <Matches />\n )\n\n const routerContext = getRouterContext()\n\n const provider = (\n <routerContext.Provider value={router}>\n {matches}\n <Transitioner />\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\nfunction Transitioner() {\n const router = useRouter()\n const mountLoadForRouter = React.useRef({ router, mounted: false })\n const routerState = useRouterState({\n select: (s) =>\n pick(s, ['isLoading', 'location', 'resolvedLocation', 'isTransitioning']),\n })\n\n const [isTransitioning, startReactTransition] = useTransition()\n\n router.startReactTransition = startReactTransition\n\n React.useEffect(() => {\n if (isTransitioning) {\n router.__store.setState((s) => ({\n ...s,\n isTransitioning,\n }))\n }\n }, [isTransitioning])\n\n const tryLoad = () => {\n const apply = (cb: () => void) => {\n if (!routerState.isTransitioning) {\n startReactTransition(() => cb())\n } else {\n cb()\n }\n }\n\n apply(() => {\n try {\n router.load()\n } catch (err) {\n console.error(err)\n }\n })\n }\n\n useLayoutEffect(() => {\n const unsub = router.history.subscribe(() => {\n router.latestLocation = router.parseLocation(router.latestLocation)\n if (router.state.location !== router.latestLocation) {\n tryLoad()\n }\n })\n\n return () => {\n unsub()\n }\n }, [router.history])\n\n useLayoutEffect(() => {\n if (\n (React.useTransition as any)\n ? routerState.isTransitioning && !isTransitioning\n : true &&\n !routerState.isLoading &&\n routerState.resolvedLocation !== routerState.location\n ) {\n router.emit({\n type: 'onResolved',\n fromLocation: routerState.resolvedLocation,\n toLocation: routerState.location,\n pathChanged:\n routerState.location!.href !== routerState.resolvedLocation?.href,\n })\n\n if ((document as any).querySelector) {\n if (routerState.location.hash !== '') {\n const el = document.getElementById(\n routerState.location.hash,\n ) as HTMLElement | null\n if (el) {\n el.scrollIntoView()\n }\n }\n }\n\n router.__store.setState((s) => ({\n ...s,\n isTransitioning: false,\n resolvedLocation: s.location,\n }))\n }\n }, [\n routerState.isTransitioning,\n isTransitioning,\n routerState.isLoading,\n routerState.resolvedLocation,\n routerState.location,\n ])\n\n useLayoutEffect(() => {\n if (\n window.__TSR_DEHYDRATED__ ||\n (mountLoadForRouter.current.router === router &&\n mountLoadForRouter.current.mounted)\n ) {\n return\n }\n mountLoadForRouter.current = { router, mounted: true }\n tryLoad()\n }, [router])\n\n return null\n}\n\nexport function getRouteMatch<TRouteTree extends AnyRoute>(\n state: RouterState<TRouteTree>,\n id: string,\n): undefined | RouteMatch<TRouteTree> {\n return [\n ...state.cachedMatches,\n ...(state.pendingMatches ?? []),\n ...state.matches,\n ].find((d) => d.id === id)\n}\n\nexport type RouterProps<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<RouterOptions<TRouteTree, TDehydrated>, 'context'> & {\n router: Router<TRouteTree>\n context?: Partial<RouterOptions<TRouteTree, TDehydrated>['context']>\n}\n"],"names":["React","jsx","Matches","routerContext","getRouterContext","jsxs","useRouter","useRouterState","pick","useLayoutEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,gBACJA,iBAAM,kBACL,MAAM;AAAA,EACL;AAAA,EACA,CAAC,OAAO;AACH;EACL;AACF;AAsCK,SAAS,eAGd,EAAE,QAAQ,GAAG,QAA8C;AAE3D,SAAO,OAAO;AAAA,IACZ,GAAG,OAAO;AAAA,IACV,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,OAAO,QAAQ;AAAA,MAClB,GAAG,6BAAM;AAAA,IACX;AAAA,EAAA,CACM;AAER,QAAM,UAAU,OAAO,QAAQ,2CAC5B,OAAO,QAAQ,WAAf,EACC,UAACC,2BAAA,IAAAC,QAAA,SAAA,EAAQ,EACX,CAAA,mCAECA,QAAAA,SAAQ,CAAA,CAAA;AAGX,QAAMC,kBAAgBC,cAAAA;AAEtB,QAAM,WACHC,2BAAAA,KAAAF,gBAAc,UAAd,EAAuB,OAAO,QAC5B,UAAA;AAAA,IAAA;AAAA,mCACA,cAAa,EAAA;AAAA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iBAAM,gBACH,YAAY,mBAAmB,CAAC,kBAEhC,CAAC,YAAY,aACb,YAAY,qBAAqB,YAAY,UACjD;AACA,aAAO,KAAK;AAAA,QACV,MAAM;AAAA,QACN,cAAc,YAAY;AAAA,QAC1B,YAAY,YAAY;AAAA,QACxB,aACE,YAAY,SAAU,WAAS,iBAAY,qBAAZ,mBAA8B;AAAA,MAAA,CAChE;AAED,UAAK,SAAiB,eAAe;AAC/B,YAAA,YAAY,SAAS,SAAS,IAAI;AACpC,gBAAM,KAAK,SAAS;AAAA,YAClB,YAAY,SAAS;AAAA,UAAA;AAEvB,cAAI,IAAI;AACN,eAAG,eAAe;AAAA,UACpB;AAAA,QACF;AAAA,MACF;AAEO,aAAA,QAAQ,SAAS,CAAC,OAAO;AAAA,QAC9B,GAAG;AAAA,QACH,iBAAiB;AAAA,QACjB,kBAAkB,EAAE;AAAA,MACpB,EAAA;AAAA,IACJ;AAAA,EAAA,GACC;AAAA,IACD,YAAY;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,YAAY;AAAA,EAAA,CACb;AAEDS,QAAAA,gBAAgB,MAAM;AAElB,QAAA,OAAO,sBACN,mBAAmB,QAAQ,WAAW,UACrC,mBAAmB,QAAQ,SAC7B;AACA;AAAA,IACF;AACA,uBAAmB,UAAU,EAAE,QAAQ,SAAS,KAAK;AAC7C;EAAA,GACP,CAAC,MAAM,CAAC;AAEJ,SAAA;AACT;AAEgB,SAAA,cACd,OACA,IACoC;AAC7B,SAAA;AAAA,IACL,GAAG,MAAM;AAAA,IACT,GAAI,MAAM,kBAAkB,CAAC;AAAA,IAC7B,GAAG,MAAM;AAAA,EAAA,EACT,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE;AAC3B;;;"}
@@ -3,12 +3,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
5
  const useRouter = require("./useRouter.cjs");
6
+ const router = require("./router.cjs");
6
7
  const defer = require("./defer.cjs");
7
- const warning = require("tiny-warning");
8
- require("@tanstack/history");
9
- require("tiny-invariant");
10
8
  const Matches = require("./Matches.cjs");
11
- const router = require("./router.cjs");
9
+ const warning = require("tiny-warning");
12
10
  function _interopNamespaceDefault(e) {
13
11
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
14
12
  if (e) {
@@ -1 +1 @@
1
- {"version":3,"file":"awaited.cjs","sources":["../../src/awaited.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useRouter } from './useRouter'\nimport { DeferredPromise, isDehydratedDeferred } from './defer'\nimport warning from 'tiny-warning'\nimport {\n isServerSideError,\n defaultDeserializeError,\n defaultSerializeError,\n} from '.'\n\nexport type AwaitOptions<T> = {\n promise: DeferredPromise<T>\n}\n\nexport function useAwaited<T>({ promise }: AwaitOptions<T>): [T] {\n const router = useRouter()\n // const rerender = React.useReducer((x) => x + 1, 0)[1]\n\n const state = promise.__deferredState\n\n // Dehydrated promises only\n // Successful or errored deferred promises mean they\n // were resolved on the server and no further action is needed\n if (isDehydratedDeferred(promise) && state.status === 'pending') {\n const streamedData = (window as any)[`__TSR__DEFERRED__${state.uid}`]\n\n if (streamedData) {\n Object.assign(state, streamedData)\n } else {\n let token = router.registeredDeferredsIds.get(state.uid)\n\n // If we haven't yet, create a promise and resolver that our streamed HTML can use\n // when the client-side data is streamed in and ready.\n if (!token) {\n token = {}\n router.registeredDeferredsIds.set(state.uid, token)\n router.registeredDeferreds.set(token, state)\n\n Object.assign(state, {\n resolve: () => {\n state.__resolvePromise?.()\n // rerender()\n },\n promise: new Promise((r) => {\n state.__resolvePromise = r as any\n }),\n __resolvePromise: () => {},\n })\n }\n }\n }\n\n // If the promise is pending, always throw the state.promise\n // For originating promises, this will be the original promise\n // For dehydrated promises, this will be the placeholder promise\n // that will be resolved when the server sends the real data\n if (state.status === 'pending') {\n throw isDehydratedDeferred(promise) ? state.promise : promise\n }\n\n // If we are the originator of the promise,\n // inject the state into the HTML stream\n if (!isDehydratedDeferred(promise)) {\n router.injectHtml(`<script class='tsr_deferred_data'>window.__TSR__DEFERRED__${state.uid} = ${router.options.transformer.stringify(state)}</script>\n<script class='tsr_deferred_handler'>\n if (window.__TSR__ROUTER__) {\n let deferred = window.__TSR__ROUTER__.getDeferred('${state.uid}')\n if (deferred) deferred.resolve(window.__TSR__DEFERRED__${state.uid})\n }\n document.querySelectorAll('.tsr_deferred_handler').forEach((el) => el.parentElement.removeChild(el))\n</script>`)\n }\n\n if (state.status === 'error') {\n if (typeof document !== 'undefined') {\n if (isServerSideError(state.error)) {\n throw (\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n )(state.error.data as any)\n } else {\n warning(\n false,\n \"Encountered a server-side error that doesn't fit the expected shape\",\n )\n throw state.error\n }\n } else {\n throw {\n data: (\n router.options.errorSerializer?.serialize ?? defaultSerializeError\n )(state.error),\n __isServerError: true,\n }\n }\n }\n\n return [promise.__deferredState.data as any]\n}\n\nexport function Await<T>(\n props: AwaitOptions<T> & {\n fallback?: React.ReactNode\n children: (result: T) => React.ReactNode\n },\n) {\n const inner = <AwaitInner {...props} />\n if (props.fallback) {\n return <React.Suspense fallback={props.fallback}>{inner}</React.Suspense>\n }\n return inner\n}\n\nfunction AwaitInner<T>(\n props: AwaitOptions<T> & {\n fallback?: React.ReactNode\n children: (result: T) => React.ReactNode\n },\n) {\n const awaited = useAwaited(props)\n return props.children(...awaited)\n}\n"],"names":["router","useRouter","isDehydratedDeferred","_a","isServerSideError","defaultDeserializeError","defaultSerializeError","jsx","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcgB,SAAA,WAAc,EAAE,WAAiC;;AAC/D,QAAMA,WAASC,UAAAA;AAGf,QAAM,QAAQ,QAAQ;AAKtB,MAAIC,MAAqB,qBAAA,OAAO,KAAK,MAAM,WAAW,WAAW;AAC/D,UAAM,eAAgB,OAAe,oBAAoB,MAAM,GAAG,EAAE;AAEpE,QAAI,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AAA,QACb,iBAAiB;AAAA,MAAA;AAAA,IAErB;AAAA,EACF;AAEO,SAAA,CAAC,QAAQ,gBAAgB,IAAW;AAC7C;AAEO,SAAS,MACd,OAIA;AACA,QAAM,QAAQC,2BAAAA,IAAC,YAAY,EAAA,GAAG,MAAO,CAAA;AACrC,MAAI,MAAM,UAAU;AAClB,0CAAQC,iBAAM,UAAN,EAAe,UAAU,MAAM,UAAW,UAAM,MAAA,CAAA;AAAA,EAC1D;AACO,SAAA;AACT;AAEA,SAAS,WACP,OAIA;AACM,QAAA,UAAU,WAAW,KAAK;AACzB,SAAA,MAAM,SAAS,GAAG,OAAO;AAClC;;;"}
1
+ {"version":3,"file":"awaited.cjs","sources":["../../src/awaited.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useRouter } from './useRouter'\nimport { defaultSerializeError } from './router'\nimport { DeferredPromise, isDehydratedDeferred } from './defer'\nimport { defaultDeserializeError, isServerSideError } from './Matches'\n\nimport warning from 'tiny-warning'\n\nexport type AwaitOptions<T> = {\n promise: DeferredPromise<T>\n}\n\nexport function useAwaited<T>({ promise }: AwaitOptions<T>): [T] {\n const router = useRouter()\n // const rerender = React.useReducer((x) => x + 1, 0)[1]\n\n const state = promise.__deferredState\n\n // Dehydrated promises only\n // Successful or errored deferred promises mean they\n // were resolved on the server and no further action is needed\n if (isDehydratedDeferred(promise) && state.status === 'pending') {\n const streamedData = (window as any)[`__TSR__DEFERRED__${state.uid}`]\n\n if (streamedData) {\n Object.assign(state, streamedData)\n } else {\n let token = router.registeredDeferredsIds.get(state.uid)\n\n // If we haven't yet, create a promise and resolver that our streamed HTML can use\n // when the client-side data is streamed in and ready.\n if (!token) {\n token = {}\n router.registeredDeferredsIds.set(state.uid, token)\n router.registeredDeferreds.set(token, state)\n\n Object.assign(state, {\n resolve: () => {\n state.__resolvePromise?.()\n // rerender()\n },\n promise: new Promise((r) => {\n state.__resolvePromise = r as any\n }),\n __resolvePromise: () => {},\n })\n }\n }\n }\n\n // If the promise is pending, always throw the state.promise\n // For originating promises, this will be the original promise\n // For dehydrated promises, this will be the placeholder promise\n // that will be resolved when the server sends the real data\n if (state.status === 'pending') {\n throw isDehydratedDeferred(promise) ? state.promise : promise\n }\n\n // If we are the originator of the promise,\n // inject the state into the HTML stream\n if (!isDehydratedDeferred(promise)) {\n router.injectHtml(`<script class='tsr_deferred_data'>window.__TSR__DEFERRED__${state.uid} = ${router.options.transformer.stringify(state)}</script>\n<script class='tsr_deferred_handler'>\n if (window.__TSR__ROUTER__) {\n let deferred = window.__TSR__ROUTER__.getDeferred('${state.uid}')\n if (deferred) deferred.resolve(window.__TSR__DEFERRED__${state.uid})\n }\n document.querySelectorAll('.tsr_deferred_handler').forEach((el) => el.parentElement.removeChild(el))\n</script>`)\n }\n\n if (state.status === 'error') {\n if (typeof document !== 'undefined') {\n if (isServerSideError(state.error)) {\n throw (\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n )(state.error.data as any)\n } else {\n warning(\n false,\n \"Encountered a server-side error that doesn't fit the expected shape\",\n )\n throw state.error\n }\n } else {\n throw {\n data: (\n router.options.errorSerializer?.serialize ?? defaultSerializeError\n )(state.error),\n __isServerError: true,\n }\n }\n }\n\n return [promise.__deferredState.data as any]\n}\n\nexport function Await<T>(\n props: AwaitOptions<T> & {\n fallback?: React.ReactNode\n children: (result: T) => React.ReactNode\n },\n) {\n const inner = <AwaitInner {...props} />\n if (props.fallback) {\n return <React.Suspense fallback={props.fallback}>{inner}</React.Suspense>\n }\n return inner\n}\n\nfunction AwaitInner<T>(\n props: AwaitOptions<T> & {\n fallback?: React.ReactNode\n children: (result: T) => React.ReactNode\n },\n) {\n const awaited = useAwaited(props)\n return props.children(...awaited)\n}\n"],"names":["router","useRouter","isDehydratedDeferred","_a","isServerSideError","defaultDeserializeError","defaultSerializeError","jsx","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAYgB,SAAA,WAAc,EAAE,WAAiC;;AAC/D,QAAMA,WAASC,UAAAA;AAGf,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QAAA;AAEF,cAAM,MAAM;AAAA,MACd;AAAA,IAAA,OACK;AACC,YAAA;AAAA,QACJ,SACEL,cAAO,QAAQ,oBAAfA,mBAAgC,cAAaM,OAAA,uBAC7C,MAAM,KAAK;AAAA,QACb,iBAAiB;AAAA,MAAA;AAAA,IAErB;AAAA,EACF;AAEO,SAAA,CAAC,QAAQ,gBAAgB,IAAW;AAC7C;AAEO,SAAS,MACd,OAIA;AACA,QAAM,QAAQC,2BAAAA,IAAC,YAAY,EAAA,GAAG,MAAO,CAAA;AACrC,MAAI,MAAM,UAAU;AAClB,0CAAQC,iBAAM,UAAN,EAAe,UAAU,MAAM,UAAW,UAAM,MAAA,CAAA;AAAA,EAC1D;AACO,SAAA;AACT;AAEA,SAAS,WACP,OAIA;AACM,QAAA,UAAU,WAAW,KAAK;AACzB,SAAA,MAAM,SAAS,GAAG,OAAO;AAClC;;;"}
@@ -64,9 +64,14 @@ function createLazyRoute(id) {
64
64
  return new LazyRoute({ id, ...opts });
65
65
  };
66
66
  }
67
- function createLazyFileRoute(id) {
67
+ function createLazyFileRoute(path) {
68
+ const id = removeGroups(path);
68
69
  return (opts) => new LazyRoute({ id, ...opts });
69
70
  }
71
+ const routeGroupPatternRegex = /\(.+\)/g;
72
+ function removeGroups(s) {
73
+ return s.replaceAll(routeGroupPatternRegex, "").replaceAll("//", "/");
74
+ }
70
75
  exports.FileRoute = FileRoute;
71
76
  exports.FileRouteLoader = FileRouteLoader;
72
77
  exports.LazyRoute = LazyRoute;
@@ -1 +1 @@
1
- {"version":3,"file":"fileRoute.cjs","sources":["../../src/fileRoute.ts"],"sourcesContent":["import { NoInfer } from '@tanstack/react-store'\nimport { ParsePathParams } from './link'\nimport {\n AnyRoute,\n ResolveFullPath,\n ResolveFullSearchSchema,\n MergeFromFromParent,\n RouteContext,\n AnyContext,\n RouteOptions,\n UpdatableRouteOptions,\n Route,\n createRoute,\n RootRouteId,\n TrimPathLeft,\n RouteConstraints,\n ResolveFullSearchSchemaInput,\n SearchSchemaInput,\n LoaderFnContext,\n RouteLoaderFn,\n AnyPathParams,\n AnySearchSchema,\n} from './route'\nimport { Assign, Expand, IsAny } from './utils'\nimport { useMatch, useLoaderDeps, useLoaderData, RouteMatch } from './Matches'\nimport { useSearch } from './useSearch'\nimport { useParams } from './useParams'\nimport warning from 'tiny-warning'\nimport { RegisteredRouter, RouteById, RouteIds } from '.'\n\nexport interface FileRoutesByPath {\n // '/': {\n // parentRoute: typeof rootRoute\n // }\n}\n\ntype Replace<\n S extends string,\n From extends string,\n To extends string,\n> = S extends `${infer Start}${From}${infer Rest}`\n ? `${Start}${To}${Replace<Rest, From, To>}`\n : S\n\nexport type TrimLeft<\n T extends string,\n S extends string,\n> = T extends `${S}${infer U}` ? U : T\n\nexport type TrimRight<\n T extends string,\n S extends string,\n> = T extends `${infer U}${S}` ? U : T\n\nexport type Trim<T extends string, S extends string> = TrimLeft<\n TrimRight<T, S>,\n S\n>\n\nexport type RemoveUnderScores<T extends string> = Replace<\n Replace<TrimRight<TrimLeft<T, '/_'>, '_'>, '_/', '/'>,\n '/_',\n '/'\n>\n\ntype RemoveRouteGroups<S extends string> =\n S extends `${infer Before}(${infer RouteGroup})${infer After}`\n ? RemoveRouteGroups<`${Before}${After}`>\n : S\n\ntype NormalizeSlashes<S extends string> =\n S extends `${infer Before}//${infer After}`\n ? NormalizeSlashes<`${Before}/${After}`>\n : S\n\ntype ReplaceFirstOccurrence<\n T extends string,\n Search extends string,\n Replacement extends string,\n> = T extends `${infer Prefix}${Search}${infer Suffix}`\n ? `${Prefix}${Replacement}${Suffix}`\n : T\n\nexport type ResolveFilePath<\n TParentRoute extends AnyRoute,\n TFilePath extends string,\n> = TParentRoute['id'] extends RootRouteId\n ? TrimPathLeft<TFilePath>\n : ReplaceFirstOccurrence<\n TrimPathLeft<TFilePath>,\n TrimPathLeft<TParentRoute['types']['customId']>,\n ''\n >\n\nexport type FileRoutePath<\n TParentRoute extends AnyRoute,\n TFilePath extends string,\n> =\n ResolveFilePath<TParentRoute, TFilePath> extends `_${infer _}`\n ? ''\n : ResolveFilePath<TParentRoute, TFilePath> extends `/_${infer _}`\n ? ''\n : ResolveFilePath<TParentRoute, TFilePath>\n\nexport function createFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = NormalizeSlashes<\n RemoveRouteGroups<TFilePath>\n >,\n TPath extends RouteConstraints['TPath'] = FileRoutePath<\n TParentRoute,\n TFilePath\n >,\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n NormalizeSlashes<RemoveRouteGroups<RemoveUnderScores<TPath>>>\n >,\n>(path: TFilePath) {\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute\n}\n\n/** \n @deprecated It's no longer recommended to use the `FileRoute` class directly.\n Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.\n*/\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = TFilePath,\n TPath extends RouteConstraints['TPath'] = FileRoutePath<\n TParentRoute,\n TFilePath\n >,\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n RemoveUnderScores<TPath>\n >,\n> {\n silent?: boolean\n\n constructor(\n public path: TFilePath,\n _opts?: { silent: boolean },\n ) {\n this.silent = _opts?.silent\n }\n\n createRoute = <\n TSearchSchemaInput extends RouteConstraints['TSearchSchema'] = {},\n TSearchSchema extends RouteConstraints['TSearchSchema'] = {},\n TSearchSchemaUsed extends Record<\n string,\n any\n > = TSearchSchemaInput extends SearchSchemaInput\n ? Omit<TSearchSchemaInput, keyof SearchSchemaInput>\n : TSearchSchema,\n TFullSearchSchemaInput extends\n RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n TFullSearchSchema extends\n RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<\n TParentRoute,\n TSearchSchema\n >,\n TParams extends RouteConstraints['TParams'] = Expand<\n Record<ParsePathParams<TPath>, string>\n >,\n TAllParams extends RouteConstraints['TAllParams'] = MergeFromFromParent<\n TParentRoute['types']['allParams'],\n TParams\n >,\n TRouteContextReturn extends\n RouteConstraints['TRouteContext'] = RouteContext,\n TRouteContext extends RouteConstraints['TRouteContext'] = [\n TRouteContextReturn,\n ] extends [never]\n ? RouteContext\n : TRouteContextReturn,\n TAllContext extends Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n > = Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n >,\n TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderData extends any = unknown,\n TChildren extends RouteConstraints['TChildren'] = unknown,\n TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute,\n >(\n options?: Omit<\n RouteOptions<\n TParentRoute,\n string,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TAllContext,\n TLoaderDeps,\n TLoaderData\n >,\n 'getParentRoute' | 'path' | 'id'\n > &\n UpdatableRouteOptions<TAllParams, TFullSearchSchema, TLoaderData>,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderData,\n TChildren,\n TRouteTree\n > => {\n warning(\n this.silent,\n 'FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.',\n )\n const route = createRoute(options as any)\n ;(route as any).isRoot = false\n return route as any\n }\n}\n\n/** \n @deprecated It's recommended not to split loaders into separate files.\n Instead, place the loader function in the the main route file, inside the\n `createFileRoute('/path/to/file)(options)` options.\n*/\nexport function FileRouteLoader<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(\n _path: TFilePath,\n): <TLoaderData extends any>(\n loaderFn: RouteLoaderFn<\n TRoute['types']['allParams'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['allContext'],\n TRoute['types']['routeContext'],\n TLoaderData\n >,\n) => RouteLoaderFn<\n TRoute['types']['allParams'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['allContext'],\n TRoute['types']['routeContext'],\n NoInfer<TLoaderData>\n> {\n warning(\n false,\n `FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \\`createFileRoute('/path/to/file')(options)\\` options`,\n )\n return (loaderFn) => loaderFn\n}\n\nexport type LazyRouteOptions = Pick<\n UpdatableRouteOptions<AnyPathParams, AnySearchSchema, any>,\n 'component' | 'errorComponent' | 'pendingComponent' | 'notFoundComponent'\n>\n\nexport class LazyRoute<TRoute extends AnyRoute> {\n options: {\n id: string\n } & LazyRouteOptions\n\n constructor(\n opts: {\n id: string\n } & LazyRouteOptions,\n ) {\n this.options = opts\n ;(this as any).$$typeof = Symbol.for('react.memo')\n }\n\n useMatch = <\n TRouteMatchState = RouteMatch<\n TRoute['types']['routeTree'],\n TRoute['types']['id']\n >,\n TSelected = TRouteMatchState,\n >(opts?: {\n select?: (match: TRouteMatchState) => TSelected\n }): TSelected => {\n return useMatch({ select: opts?.select, from: this.options.id })\n }\n\n useRouteContext = <TSelected = TRoute['types']['allContext']>(opts?: {\n select?: (s: TRoute['types']['allContext']) => TSelected\n }): TSelected => {\n return useMatch({\n from: this.options.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n })\n }\n\n useSearch = <TSelected = TRoute['types']['fullSearchSchema']>(opts?: {\n select?: (s: TRoute['types']['fullSearchSchema']) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.options.id })\n }\n\n useParams = <TSelected = TRoute['types']['allParams']>(opts?: {\n select?: (s: TRoute['types']['allParams']) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.options.id })\n }\n\n useLoaderDeps = <TSelected = TRoute['types']['loaderDeps']>(opts?: {\n select?: (s: TRoute['types']['loaderDeps']) => TSelected\n }): TSelected => {\n return useLoaderDeps({ ...opts, from: this.options.id } as any)\n }\n\n useLoaderData = <TSelected = TRoute['types']['loaderData']>(opts?: {\n select?: (s: TRoute['types']['loaderData']) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.options.id } as any)\n }\n}\n\nexport function createLazyRoute<\n TId extends RouteIds<RegisteredRouter['routeTree']>,\n TRoute extends AnyRoute = RouteById<RegisteredRouter['routeTree'], TId>,\n>(id: TId) {\n return (opts: LazyRouteOptions) => {\n return new LazyRoute<TRoute>({ id: id as any, ...opts })\n }\n}\n\nexport function createLazyFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(id: TFilePath) {\n return (opts: LazyRouteOptions) => new LazyRoute<TRoute>({ id, ...opts })\n}\n"],"names":["route","createRoute","opts","useMatch","useSearch","useParams","useLoaderDeps","useLoaderData"],"mappings":";;;;;;;AAwGO,SAAS,gBAcd,MAAiB;AACV,SAAA,IAAI,UAA0D,MAAM;AAAA,IACzE,QAAQ;AAAA,EACT,CAAA,EAAE;AACL;AAMO,MAAM,UAYX;AAAA,EAGA,YACS,MACP,OACA;AAFO,SAAA,OAAA;AAMT,SAAA,cAAc,CA4CZ,YA2CG;AACH;AAAA,QACE,KAAK;AAAA,QACL;AAAA,MAAA;AAEI,YAAAA,UAAQC,kBAAY,OAAc;AACtCD,cAAc,SAAS;AAClB,aAAAA;AAAAA,IAAA;AAjGP,SAA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A2B,IAAI,UAAkB,EAAE,IAAI,GAAG,MAAM;AAC1E;;;;;;;"}
1
+ {"version":3,"file":"fileRoute.cjs","sources":["../../src/fileRoute.ts"],"sourcesContent":["import { NoInfer } from '@tanstack/react-store'\nimport { ParsePathParams } from './link'\nimport {\n AnyRoute,\n ResolveFullPath,\n ResolveFullSearchSchema,\n MergeFromFromParent,\n RouteContext,\n AnyContext,\n RouteOptions,\n UpdatableRouteOptions,\n Route,\n createRoute,\n RootRouteId,\n TrimPathLeft,\n RouteConstraints,\n ResolveFullSearchSchemaInput,\n SearchSchemaInput,\n RouteLoaderFn,\n AnyPathParams,\n AnySearchSchema,\n} from './route'\nimport { Assign, Expand, IsAny } from './utils'\nimport { useMatch, useLoaderDeps, useLoaderData, RouteMatch } from './Matches'\nimport { useSearch } from './useSearch'\nimport { useParams } from './useParams'\nimport warning from 'tiny-warning'\nimport { RegisteredRouter } from './router'\nimport { RouteById, RouteIds } from './routeInfo'\n\nexport interface FileRoutesByPath {\n // '/': {\n // parentRoute: typeof rootRoute\n // }\n}\n\ntype Replace<\n S extends string,\n From extends string,\n To extends string,\n> = S extends `${infer Start}${From}${infer Rest}`\n ? `${Start}${To}${Replace<Rest, From, To>}`\n : S\n\nexport type TrimLeft<\n T extends string,\n S extends string,\n> = T extends `${S}${infer U}` ? U : T\n\nexport type TrimRight<\n T extends string,\n S extends string,\n> = T extends `${infer U}${S}` ? U : T\n\nexport type Trim<T extends string, S extends string> = TrimLeft<\n TrimRight<T, S>,\n S\n>\n\nexport type RemoveUnderScores<T extends string> = Replace<\n Replace<TrimRight<TrimLeft<T, '/_'>, '_'>, '_/', '/'>,\n '/_',\n '/'\n>\n\ntype RemoveRouteGroups<S extends string> =\n S extends `${infer Before}(${infer RouteGroup})${infer After}`\n ? RemoveRouteGroups<`${Before}${After}`>\n : S\n\ntype NormalizeSlashes<S extends string> =\n S extends `${infer Before}//${infer After}`\n ? NormalizeSlashes<`${Before}/${After}`>\n : S\n\ntype ReplaceFirstOccurrence<\n T extends string,\n Search extends string,\n Replacement extends string,\n> = T extends `${infer Prefix}${Search}${infer Suffix}`\n ? `${Prefix}${Replacement}${Suffix}`\n : T\n\nexport type ResolveFilePath<\n TParentRoute extends AnyRoute,\n TFilePath extends string,\n> = TParentRoute['id'] extends RootRouteId\n ? TrimPathLeft<TFilePath>\n : ReplaceFirstOccurrence<\n TrimPathLeft<TFilePath>,\n TrimPathLeft<TParentRoute['types']['customId']>,\n ''\n >\n\nexport type FileRoutePath<\n TParentRoute extends AnyRoute,\n TFilePath extends string,\n> =\n ResolveFilePath<TParentRoute, TFilePath> extends `_${infer _}`\n ? ''\n : ResolveFilePath<TParentRoute, TFilePath> extends `/_${infer _}`\n ? ''\n : ResolveFilePath<TParentRoute, TFilePath>\n\nexport function createFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = NormalizeSlashes<\n RemoveRouteGroups<TFilePath>\n >,\n TPath extends RouteConstraints['TPath'] = FileRoutePath<\n TParentRoute,\n TFilePath\n >,\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n NormalizeSlashes<RemoveRouteGroups<RemoveUnderScores<TPath>>>\n >,\n>(path: TFilePath) {\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute\n}\n\n/** \n @deprecated It's no longer recommended to use the `FileRoute` class directly.\n Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.\n*/\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = TFilePath,\n TPath extends RouteConstraints['TPath'] = FileRoutePath<\n TParentRoute,\n TFilePath\n >,\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n RemoveUnderScores<TPath>\n >,\n> {\n silent?: boolean\n\n constructor(\n public path: TFilePath,\n _opts?: { silent: boolean },\n ) {\n this.silent = _opts?.silent\n }\n\n createRoute = <\n TSearchSchemaInput extends RouteConstraints['TSearchSchema'] = {},\n TSearchSchema extends RouteConstraints['TSearchSchema'] = {},\n TSearchSchemaUsed extends Record<\n string,\n any\n > = TSearchSchemaInput extends SearchSchemaInput\n ? Omit<TSearchSchemaInput, keyof SearchSchemaInput>\n : TSearchSchema,\n TFullSearchSchemaInput extends\n RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n TFullSearchSchema extends\n RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<\n TParentRoute,\n TSearchSchema\n >,\n TParams extends RouteConstraints['TParams'] = Expand<\n Record<ParsePathParams<TPath>, string>\n >,\n TAllParams extends RouteConstraints['TAllParams'] = MergeFromFromParent<\n TParentRoute['types']['allParams'],\n TParams\n >,\n TRouteContextReturn extends\n RouteConstraints['TRouteContext'] = RouteContext,\n TRouteContext extends RouteConstraints['TRouteContext'] = [\n TRouteContextReturn,\n ] extends [never]\n ? RouteContext\n : TRouteContextReturn,\n TAllContext extends Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n > = Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n >,\n TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn extends any = unknown,\n TLoaderData extends any = [TLoaderDataReturn] extends [never]\n ? undefined\n : TLoaderDataReturn,\n TChildren extends RouteConstraints['TChildren'] = unknown,\n TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute,\n >(\n options?: Omit<\n RouteOptions<\n TParentRoute,\n string,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n 'getParentRoute' | 'path' | 'id'\n > &\n UpdatableRouteOptions<TAllParams, TFullSearchSchema, TLoaderData>,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TChildren,\n TRouteTree\n > => {\n warning(\n this.silent,\n 'FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.',\n )\n const route = createRoute(options as any)\n ;(route as any).isRoot = false\n return route as any\n }\n}\n\n/** \n @deprecated It's recommended not to split loaders into separate files.\n Instead, place the loader function in the the main route file, inside the\n `createFileRoute('/path/to/file)(options)` options.\n*/\nexport function FileRouteLoader<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(\n _path: TFilePath,\n): <TLoaderData extends any>(\n loaderFn: RouteLoaderFn<\n TRoute['types']['allParams'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['allContext'],\n TRoute['types']['routeContext'],\n TLoaderData\n >,\n) => RouteLoaderFn<\n TRoute['types']['allParams'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['allContext'],\n TRoute['types']['routeContext'],\n NoInfer<TLoaderData>\n> {\n warning(\n false,\n `FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \\`createFileRoute('/path/to/file')(options)\\` options`,\n )\n return (loaderFn) => loaderFn\n}\n\nexport type LazyRouteOptions = Pick<\n UpdatableRouteOptions<AnyPathParams, AnySearchSchema, any>,\n 'component' | 'errorComponent' | 'pendingComponent' | 'notFoundComponent'\n>\n\nexport class LazyRoute<TRoute extends AnyRoute> {\n options: {\n id: string\n } & LazyRouteOptions\n\n constructor(\n opts: {\n id: string\n } & LazyRouteOptions,\n ) {\n this.options = opts\n ;(this as any).$$typeof = Symbol.for('react.memo')\n }\n\n useMatch = <\n TRouteMatchState = RouteMatch<\n TRoute['types']['routeTree'],\n TRoute['types']['id']\n >,\n TSelected = TRouteMatchState,\n >(opts?: {\n select?: (match: TRouteMatchState) => TSelected\n }): TSelected => {\n return useMatch({ select: opts?.select, from: this.options.id })\n }\n\n useRouteContext = <TSelected = TRoute['types']['allContext']>(opts?: {\n select?: (s: TRoute['types']['allContext']) => TSelected\n }): TSelected => {\n return useMatch({\n from: this.options.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n })\n }\n\n useSearch = <TSelected = TRoute['types']['fullSearchSchema']>(opts?: {\n select?: (s: TRoute['types']['fullSearchSchema']) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.options.id })\n }\n\n useParams = <TSelected = TRoute['types']['allParams']>(opts?: {\n select?: (s: TRoute['types']['allParams']) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.options.id })\n }\n\n useLoaderDeps = <TSelected = TRoute['types']['loaderDeps']>(opts?: {\n select?: (s: TRoute['types']['loaderDeps']) => TSelected\n }): TSelected => {\n return useLoaderDeps({ ...opts, from: this.options.id } as any)\n }\n\n useLoaderData = <TSelected = TRoute['types']['loaderData']>(opts?: {\n select?: (s: TRoute['types']['loaderData']) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.options.id } as any)\n }\n}\n\nexport function createLazyRoute<\n TId extends RouteIds<RegisteredRouter['routeTree']>,\n TRoute extends AnyRoute = RouteById<RegisteredRouter['routeTree'], TId>,\n>(id: TId) {\n return (opts: LazyRouteOptions) => {\n return new LazyRoute<TRoute>({ id: id as any, ...opts })\n }\n}\n\nexport function createLazyFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(path: TFilePath) {\n const id = removeGroups(path)\n return (opts: LazyRouteOptions) => new LazyRoute<TRoute>({ id, ...opts })\n}\n\nconst routeGroupPatternRegex = /\\(.+\\)/g\n\nfunction removeGroups(s: string) {\n return s.replaceAll(routeGroupPatternRegex, '').replaceAll('//', '/')\n}\n"],"names":["route","createRoute","opts","useMatch","useSearch","useParams","useLoaderDeps","useLoaderData"],"mappings":";;;;;;;AAwGO,SAAS,gBAcd,MAAiB;AACV,SAAA,IAAI,UAA0D,MAAM;AAAA,IACzE,QAAQ;AAAA,EACT,CAAA,EAAE;AACL;AAMO,MAAM,UAYX;AAAA,EAGA,YACS,MACP,OACA;AAFO,SAAA,OAAA;AAMT,SAAA,cAAc,CA+CZ,YA6CG;AACH;AAAA,QACE,KAAK;AAAA,QACL;AAAA,MAAA;AAEI,YAAAA,UAAQC,kBAAY,OAAc;AACtCD,cAAc,SAAS;AAClB,aAAAA;AAAAA,IAAA;AAtGP,SAAK,SAAS,+BAAO;AAAA,EACvB;AAuGF;AAOO,SAAS,gBAId,OAeA;AACA;AAAA,IACE;AAAA,IACA;AAAA,EAAA;AAEF,SAAO,CAAC,aAAa;AACvB;AAOO,MAAM,UAAmC;AAAA,EAK9C,YACE,MAGA;AAKF,SAAA,WAAW,CAMTE,UAEe;AACR,aAAAC,QAAA,SAAS,EAAE,QAAQD,SAAA,gBAAAA,MAAM,QAAQ,MAAM,KAAK,QAAQ,GAAA,CAAI;AAAA,IAAA;AAGjE,SAAA,kBAAkB,CAA4CA,UAE7C;AACf,aAAOC,iBAAS;AAAA,QACd,MAAM,KAAK,QAAQ;AAAA,QACnB,QAAQ,CAAC,OAAYD,SAAA,gBAAAA,MAAM,UAASA,MAAK,OAAO,EAAE,OAAO,IAAI,EAAE;AAAA,MAAA,CAChE;AAAA,IAAA;AAGH,SAAA,YAAY,CAAkDA,UAE7C;AACR,aAAAE,UAAA,UAAU,EAAE,GAAGF,OAAM,MAAM,KAAK,QAAQ,IAAI;AAAA,IAAA;AAGrD,SAAA,YAAY,CAA2CA,UAEtC;AACR,aAAAG,UAAA,UAAU,EAAE,GAAGH,OAAM,MAAM,KAAK,QAAQ,IAAI;AAAA,IAAA;AAGrD,SAAA,gBAAgB,CAA4CA,UAE3C;AACR,aAAAI,QAAA,cAAc,EAAE,GAAGJ,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAAA;AAGhE,SAAA,gBAAgB,CAA4CA,UAE3C;AACR,aAAAK,QAAA,cAAc,EAAE,GAAGL,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAAA;AA9C9D,SAAK,UAAU;AACb,SAAa,WAAW,OAAO,IAAI,YAAY;AAAA,EACnD;AA8CF;AAEO,SAAS,gBAGd,IAAS;AACT,SAAO,CAAC,SAA2B;AACjC,WAAO,IAAI,UAAkB,EAAE,IAAe,GAAG,KAAM,CAAA;AAAA,EAAA;AAE3D;AAEO,SAAS,oBAGd,MAAiB;AACX,QAAA,KAAK,aAAa,IAAI;AACrB,SAAA,CAAC,SAA2B,IAAI,UAAkB,EAAE,IAAI,GAAG,MAAM;AAC1E;AAEA,MAAM,yBAAyB;AAE/B,SAAS,aAAa,GAAW;AAC/B,SAAO,EAAE,WAAW,wBAAwB,EAAE,EAAE,WAAW,MAAM,GAAG;AACtE;;;;;;;"}
@@ -4,7 +4,8 @@ import { ParsePathParams } from './link.cjs';
4
4
  import { AnyRoute, ResolveFullPath, ResolveFullSearchSchema, MergeFromFromParent, RouteContext, AnyContext, RouteOptions, UpdatableRouteOptions, Route, RootRouteId, TrimPathLeft, RouteConstraints, ResolveFullSearchSchemaInput, SearchSchemaInput, RouteLoaderFn, AnyPathParams, AnySearchSchema } from './route.cjs';
5
5
  import { Assign, Expand, IsAny } from './utils.cjs';
6
6
  import { RouteMatch } from './Matches.cjs';
7
- import { RegisteredRouter, RouteById, RouteIds } from '.';
7
+ import { RegisteredRouter } from './router.cjs';
8
+ import { RouteById, RouteIds } from './routeInfo.cjs';
8
9
  export interface FileRoutesByPath {
9
10
  }
10
11
  type Replace<S extends string, From extends string, To extends string> = S extends `${infer Start}${From}${infer Rest}` ? `${Start}${To}${Replace<Rest, From, To>}` : S;
@@ -17,7 +18,7 @@ type NormalizeSlashes<S extends string> = S extends `${infer Before}//${infer Af
17
18
  type ReplaceFirstOccurrence<T extends string, Search extends string, Replacement extends string> = T extends `${infer Prefix}${Search}${infer Suffix}` ? `${Prefix}${Replacement}${Suffix}` : T;
18
19
  export type ResolveFilePath<TParentRoute extends AnyRoute, TFilePath extends string> = TParentRoute['id'] extends RootRouteId ? TrimPathLeft<TFilePath> : ReplaceFirstOccurrence<TrimPathLeft<TFilePath>, TrimPathLeft<TParentRoute['types']['customId']>, ''>;
19
20
  export type FileRoutePath<TParentRoute extends AnyRoute, TFilePath extends string> = ResolveFilePath<TParentRoute, TFilePath> extends `_${infer _}` ? '' : ResolveFilePath<TParentRoute, TFilePath> extends `/_${infer _}` ? '' : ResolveFilePath<TParentRoute, TFilePath>;
20
- export declare function createFileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = NormalizeSlashes<RemoveRouteGroups<TFilePath>>, TPath extends RouteConstraints['TPath'] = FileRoutePath<TParentRoute, TFilePath>, TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, NormalizeSlashes<RemoveRouteGroups<RemoveUnderScores<TPath>>>>>(path: TFilePath): <TSearchSchemaInput extends AnySearchSchema = {}, TSearchSchema extends AnySearchSchema = {}, TSearchSchemaUsed extends Record<string, any> = TSearchSchemaInput extends SearchSchemaInput ? Omit<TSearchSchemaInput, "__TSearchSchemaInput__"> : TSearchSchema, TFullSearchSchemaInput extends AnySearchSchema = Expand<Assign<Omit<import("./route").InferFullSearchSchemaInput<TParentRoute>, "__TRootSearchSchema__">, TSearchSchemaUsed>>, TFullSearchSchema extends AnySearchSchema = Expand<Assign<Omit<import("./route").InferFullSearchSchema<TParentRoute>, "__TRootSearchSchema__">, TSearchSchema>>, TParams extends Record<string, any> = Expand<Record<TrimLeft<TrimRight<import("./link").Split<TPath, true>[number], "_">, "_"> extends infer T ? T extends TrimLeft<TrimRight<import("./link").Split<TPath, true>[number], "_">, "_"> ? T extends `$${infer L}` ? L extends "" ? "_splat" : L : never : never : never, string>>, TAllParams extends Record<string, any> = IsAny<TParentRoute["types"]["allParams"], TParams, TParentRoute["types"]["allParams"] & TParams>, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext extends RouteContext = [TRouteContextReturn] extends [never] ? RouteContext : TRouteContextReturn, TAllContext extends Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}, TParentRoute["types"]["allContext"]>, TRouteContext>> = Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}, TParentRoute["types"]["allContext"]>, TRouteContext>>, TRouterContext extends AnyContext = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderData extends unknown = unknown, TChildren extends unknown = unknown, TRouteTree extends AnyRoute = AnyRoute>(options?: (Omit<RouteOptions<TParentRoute, string, TPath, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderData>, "path" | "id" | "getParentRoute"> & {
21
+ export declare function createFileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = NormalizeSlashes<RemoveRouteGroups<TFilePath>>, TPath extends RouteConstraints['TPath'] = FileRoutePath<TParentRoute, TFilePath>, TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, NormalizeSlashes<RemoveRouteGroups<RemoveUnderScores<TPath>>>>>(path: TFilePath): <TSearchSchemaInput extends AnySearchSchema = {}, TSearchSchema extends AnySearchSchema = {}, TSearchSchemaUsed extends Record<string, any> = TSearchSchemaInput extends SearchSchemaInput ? Omit<TSearchSchemaInput, "__TSearchSchemaInput__"> : TSearchSchema, TFullSearchSchemaInput extends AnySearchSchema = Expand<Assign<Omit<import("./route").InferFullSearchSchemaInput<TParentRoute>, "__TRootSearchSchema__">, TSearchSchemaUsed>>, TFullSearchSchema extends AnySearchSchema = Expand<Assign<Omit<import("./route").InferFullSearchSchema<TParentRoute>, "__TRootSearchSchema__">, TSearchSchema>>, TParams extends Record<string, any> = Expand<Record<TrimLeft<TrimRight<import("./link").Split<TPath, true>[number], "_">, "_"> extends infer T ? T extends TrimLeft<TrimRight<import("./link").Split<TPath, true>[number], "_">, "_"> ? T extends `$${infer L}` ? L extends "" ? "_splat" : L : never : never : never, string>>, TAllParams extends Record<string, any> = IsAny<TParentRoute["types"]["allParams"], TParams, TParentRoute["types"]["allParams"] & TParams>, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext extends RouteContext = [TRouteContextReturn] extends [never] ? RouteContext : TRouteContextReturn, TAllContext extends Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}, TParentRoute["types"]["allContext"]>, TRouteContext>> = Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}, TParentRoute["types"]["allContext"]>, TRouteContext>>, TRouterContext extends AnyContext = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn extends unknown = unknown, TLoaderData extends unknown = [TLoaderDataReturn] extends [never] ? undefined : TLoaderDataReturn, TChildren extends unknown = unknown, TRouteTree extends AnyRoute = AnyRoute>(options?: (Omit<RouteOptions<TParentRoute, string, TPath, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderDataReturn, TLoaderData>, "path" | "id" | "getParentRoute"> & {
21
22
  caseSensitive?: boolean | undefined;
22
23
  wrapInSuspense?: boolean | undefined;
23
24
  component?: import("./route").RouteComponent<any> | undefined;
@@ -47,7 +48,7 @@ export declare function createFileRoute<TFilePath extends keyof FileRoutesByPath
47
48
  }) => Record<string, string> | Promise<Record<string, string>>) | undefined;
48
49
  } & {
49
50
  staticData?: import("./route").StaticDataRouteOption | undefined;
50
- }) | undefined) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderData, TChildren, TRouteTree>;
51
+ }) | undefined) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData, TChildren, TRouteTree>;
51
52
  /**
52
53
  @deprecated It's no longer recommended to use the `FileRoute` class directly.
53
54
  Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.
@@ -58,7 +59,7 @@ export declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParent
58
59
  constructor(path: TFilePath, _opts?: {
59
60
  silent: boolean;
60
61
  });
61
- createRoute: <TSearchSchemaInput extends AnySearchSchema = {}, TSearchSchema extends AnySearchSchema = {}, TSearchSchemaUsed extends Record<string, any> = TSearchSchemaInput extends SearchSchemaInput ? Omit<TSearchSchemaInput, "__TSearchSchemaInput__"> : TSearchSchema, TFullSearchSchemaInput extends AnySearchSchema = ResolveFullSearchSchemaInput<TParentRoute, TSearchSchemaUsed>, TFullSearchSchema extends AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<string, any> = Expand<Record<ParsePathParams<TPath>, string>>, TAllParams extends Record<string, any> = MergeFromFromParent<TParentRoute["types"]["allParams"], TParams>, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext extends RouteContext = [TRouteContextReturn] extends [never] ? RouteContext : TRouteContextReturn, TAllContext extends Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}>, TRouteContext>> = Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}>, TRouteContext>>, TRouterContext extends AnyContext = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderData extends unknown = unknown, TChildren extends unknown = unknown, TRouteTree extends AnyRoute = AnyRoute>(options?: (Omit<RouteOptions<TParentRoute, string, TPath, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderData>, "path" | "id" | "getParentRoute"> & {
62
+ createRoute: <TSearchSchemaInput extends AnySearchSchema = {}, TSearchSchema extends AnySearchSchema = {}, TSearchSchemaUsed extends Record<string, any> = TSearchSchemaInput extends SearchSchemaInput ? Omit<TSearchSchemaInput, "__TSearchSchemaInput__"> : TSearchSchema, TFullSearchSchemaInput extends AnySearchSchema = ResolveFullSearchSchemaInput<TParentRoute, TSearchSchemaUsed>, TFullSearchSchema extends AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<string, any> = Expand<Record<ParsePathParams<TPath>, string>>, TAllParams extends Record<string, any> = MergeFromFromParent<TParentRoute["types"]["allParams"], TParams>, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext extends RouteContext = [TRouteContextReturn] extends [never] ? RouteContext : TRouteContextReturn, TAllContext extends Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}>, TRouteContext>> = Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}>, TRouteContext>>, TRouterContext extends AnyContext = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn extends unknown = unknown, TLoaderData extends unknown = [TLoaderDataReturn] extends [never] ? undefined : TLoaderDataReturn, TChildren extends unknown = unknown, TRouteTree extends AnyRoute = AnyRoute>(options?: (Omit<RouteOptions<TParentRoute, string, TPath, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderDataReturn, TLoaderData>, "path" | "id" | "getParentRoute"> & {
62
63
  caseSensitive?: boolean | undefined;
63
64
  wrapInSuspense?: boolean | undefined;
64
65
  component?: import("./route").RouteComponent<any> | undefined;
@@ -88,7 +89,7 @@ export declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParent
88
89
  }) => Record<string, string> | Promise<Record<string, string>>) | undefined;
89
90
  } & {
90
91
  staticData?: import("./route").StaticDataRouteOption | undefined;
91
- }) | undefined) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderData, TChildren, TRouteTree>;
92
+ }) | undefined) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData, TChildren, TRouteTree>;
92
93
  }
93
94
  /**
94
95
  @deprecated It's recommended not to split loaders into separate files.
@@ -124,5 +125,5 @@ export declare class LazyRoute<TRoute extends AnyRoute> {
124
125
  } | undefined) => TSelected;
125
126
  }
126
127
  export declare function createLazyRoute<TId extends RouteIds<RegisteredRouter['routeTree']>, TRoute extends AnyRoute = RouteById<RegisteredRouter['routeTree'], TId>>(id: TId): (opts: LazyRouteOptions) => LazyRoute<TRoute>;
127
- export declare function createLazyFileRoute<TFilePath extends keyof FileRoutesByPath, TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute']>(id: TFilePath): (opts: LazyRouteOptions) => LazyRoute<TRoute>;
128
+ export declare function createLazyFileRoute<TFilePath extends keyof FileRoutesByPath, TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute']>(path: TFilePath): (opts: LazyRouteOptions) => LazyRoute<TRoute>;
128
129
  export {};