@tanstack/react-router 1.45.11 → 1.45.14

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 (75) hide show
  1. package/dist/cjs/Match.cjs +14 -7
  2. package/dist/cjs/Match.cjs.map +1 -1
  3. package/dist/cjs/Match.d.cts +5 -2
  4. package/dist/cjs/Matches.cjs.map +1 -1
  5. package/dist/cjs/Matches.d.cts +1 -1
  6. package/dist/cjs/RouterProvider.cjs.map +1 -1
  7. package/dist/cjs/Transitioner.cjs +0 -3
  8. package/dist/cjs/Transitioner.cjs.map +1 -1
  9. package/dist/cjs/fileRoute.cjs.map +1 -1
  10. package/dist/cjs/fileRoute.d.cts +2 -3
  11. package/dist/cjs/index.d.cts +37 -20
  12. package/dist/cjs/not-found.cjs.map +1 -1
  13. package/dist/cjs/not-found.d.cts +1 -1
  14. package/dist/cjs/renderRouteNotFound.cjs.map +1 -1
  15. package/dist/cjs/route.cjs.map +1 -1
  16. package/dist/cjs/route.d.cts +0 -1
  17. package/dist/cjs/router.cjs +2 -2
  18. package/dist/cjs/router.cjs.map +1 -1
  19. package/dist/cjs/router.d.cts +1 -1
  20. package/dist/cjs/useLoaderData.cjs.map +1 -1
  21. package/dist/cjs/useLoaderData.d.cts +3 -3
  22. package/dist/cjs/useLoaderDeps.cjs.map +1 -1
  23. package/dist/cjs/useMatch.cjs.map +1 -1
  24. package/dist/cjs/useNavigate.cjs +0 -2
  25. package/dist/cjs/useNavigate.cjs.map +1 -1
  26. package/dist/cjs/useRouter.cjs.map +1 -1
  27. package/dist/cjs/useRouterState.cjs.map +1 -1
  28. package/dist/cjs/utils.cjs.map +1 -1
  29. package/dist/esm/Match.d.ts +5 -2
  30. package/dist/esm/Match.js +14 -7
  31. package/dist/esm/Match.js.map +1 -1
  32. package/dist/esm/Matches.d.ts +1 -1
  33. package/dist/esm/Matches.js.map +1 -1
  34. package/dist/esm/RouterProvider.js.map +1 -1
  35. package/dist/esm/Transitioner.js +0 -3
  36. package/dist/esm/Transitioner.js.map +1 -1
  37. package/dist/esm/fileRoute.d.ts +2 -3
  38. package/dist/esm/fileRoute.js.map +1 -1
  39. package/dist/esm/index.d.ts +37 -20
  40. package/dist/esm/not-found.d.ts +1 -1
  41. package/dist/esm/not-found.js.map +1 -1
  42. package/dist/esm/renderRouteNotFound.js.map +1 -1
  43. package/dist/esm/route.d.ts +0 -1
  44. package/dist/esm/route.js.map +1 -1
  45. package/dist/esm/router.d.ts +1 -1
  46. package/dist/esm/router.js +2 -2
  47. package/dist/esm/router.js.map +1 -1
  48. package/dist/esm/useLoaderData.d.ts +3 -3
  49. package/dist/esm/useLoaderData.js.map +1 -1
  50. package/dist/esm/useLoaderDeps.js.map +1 -1
  51. package/dist/esm/useMatch.js.map +1 -1
  52. package/dist/esm/useNavigate.js +0 -2
  53. package/dist/esm/useNavigate.js.map +1 -1
  54. package/dist/esm/useRouter.js.map +1 -1
  55. package/dist/esm/useRouterState.js.map +1 -1
  56. package/dist/esm/utils.js.map +1 -1
  57. package/package.json +2 -2
  58. package/src/Match.tsx +20 -10
  59. package/src/Matches.tsx +1 -1
  60. package/src/RouterProvider.tsx +0 -5
  61. package/src/Transitioner.tsx +1 -1
  62. package/src/fileRoute.ts +1 -5
  63. package/src/index.tsx +192 -150
  64. package/src/not-found.tsx +1 -2
  65. package/src/renderRouteNotFound.tsx +2 -2
  66. package/src/route.ts +3 -3
  67. package/src/routeInfo.ts +1 -1
  68. package/src/router.ts +6 -10
  69. package/src/useLoaderData.tsx +13 -6
  70. package/src/useLoaderDeps.tsx +2 -2
  71. package/src/useMatch.tsx +2 -2
  72. package/src/useNavigate.tsx +0 -3
  73. package/src/useRouter.tsx +1 -1
  74. package/src/useRouterState.tsx +1 -1
  75. package/src/utils.ts +1 -1
@@ -33,7 +33,9 @@ function _interopNamespaceDefault(e) {
33
33
  return Object.freeze(n);
34
34
  }
35
35
  const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
36
- function Match({ matchId }) {
36
+ const Match = React__namespace.memo(function MatchImpl({
37
+ matchId
38
+ }) {
37
39
  var _a, _b;
38
40
  const router = useRouter.useRouter();
39
41
  const routeId = useRouterState.useRouterState({
@@ -87,8 +89,10 @@ function Match({ matchId }) {
87
89
  )
88
90
  }
89
91
  ) }) });
90
- }
91
- function MatchInner({ matchId }) {
92
+ });
93
+ const MatchInner = React__namespace.memo(function MatchInnerImpl({
94
+ matchId
95
+ }) {
92
96
  var _a, _b;
93
97
  const router = useRouter.useRouter();
94
98
  const routeId = useRouterState.useRouterState({
@@ -115,6 +119,10 @@ function MatchInner({ matchId }) {
115
119
  ]);
116
120
  }
117
121
  });
122
+ const out = React__namespace.useMemo(() => {
123
+ const Comp = route.options.component ?? router.options.defaultComponent;
124
+ return Comp ? /* @__PURE__ */ jsxRuntime.jsx(Comp, {}, matchId) : /* @__PURE__ */ jsxRuntime.jsx(Outlet, {});
125
+ }, [matchId, route.options.component, router.options.defaultComponent]);
118
126
  const RouteErrorComponent = (route.options.errorComponent ?? router.options.defaultErrorComponent) || CatchBoundary.ErrorComponent;
119
127
  if (match.status === "notFound") {
120
128
  let error;
@@ -172,14 +180,12 @@ function MatchInner({ matchId }) {
172
180
  }
173
181
  throw match.loadPromise;
174
182
  }
175
- const Comp = route.options.component ?? router.options.defaultComponent;
176
- const out = Comp ? /* @__PURE__ */ jsxRuntime.jsx(Comp, {}) : /* @__PURE__ */ jsxRuntime.jsx(Outlet, {});
177
183
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
178
184
  out,
179
185
  router.AfterEachMatch ? /* @__PURE__ */ jsxRuntime.jsx(router.AfterEachMatch, { match, matchIndex }) : null
180
186
  ] });
181
- }
182
- const Outlet = React__namespace.memo(function Outlet2() {
187
+ });
188
+ const Outlet = React__namespace.memo(function OutletImpl() {
183
189
  const router = useRouter.useRouter();
184
190
  const matchId = React__namespace.useContext(matchContext.matchContext);
185
191
  const routeId = useRouterState.useRouterState({
@@ -224,5 +230,6 @@ const Outlet = React__namespace.memo(function Outlet2() {
224
230
  return nextMatch;
225
231
  });
226
232
  exports.Match = Match;
233
+ exports.MatchInner = MatchInner;
227
234
  exports.Outlet = Outlet;
228
235
  //# sourceMappingURL=Match.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Match.cjs","sources":["../../src/Match.tsx"],"sourcesContent":["'use client'\n\nimport * 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 { createControlledPromise, pick } from './utils'\nimport { CatchNotFound, isNotFound } from './not-found'\nimport { isRedirect } from './redirects'\nimport { type AnyRoute } from './route'\nimport { matchContext } from './matchContext'\nimport { defaultDeserializeError, isServerSideError } from './isServerSideError'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { rootRouteId } from './root'\n\nexport function Match({ matchId }: { matchId: string }) {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) => s.matches.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: AnyRoute = router.routesById[routeId]\n\n const PendingComponent =\n route.options.pendingComponent ?? router.options.defaultPendingComponent\n\n const pendingElement = PendingComponent ? <PendingComponent /> : null\n\n const routeErrorComponent =\n route.options.errorComponent ?? router.options.defaultErrorComponent\n\n const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch\n\n const routeNotFoundComponent = route.isRoot\n ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n (route.options.notFoundComponent ??\n router.options.notFoundRoute?.options.component)\n : route.options.notFoundComponent\n\n const ResolvedSuspenseBoundary =\n // If we're on the root route, allow forcefully wrapping in suspense\n (!route.isRoot || route.options.wrapInSuspense) &&\n (route.options.wrapInSuspense ??\n PendingComponent ??\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 const resetKey = useRouterState({\n select: (s) => s.loadedAt,\n })\n\n return (\n <matchContext.Provider value={matchId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => resetKey}\n errorComponent={routeErrorComponent || ErrorComponent}\n onCatch={(error, errorInfo) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(false, `Error in route match: ${matchId}`)\n routeOnCatch?.(error, errorInfo)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n // If the current not found handler doesn't exist or it has a\n // route ID which doesn't match the current route, rethrow the error\n if (\n !routeNotFoundComponent ||\n (error.routeId && error.routeId !== 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} />\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n )\n}\nfunction MatchInner({ matchId }: { matchId: string }): any {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const matchIndex = useRouterState({\n select: (s) => {\n return s.matches.findIndex((d) => d.id === matchId)\n },\n })\n\n const match = useRouterState({\n select: (s) => {\n const match = s.matches[matchIndex]!\n return pick(match, [\n 'id',\n 'status',\n 'error',\n 'loadPromise',\n 'minPendingPromise',\n ])\n },\n })\n\n // function useChangedDiff(value: any) {\n // const ref = React.useRef(value)\n // const changed = ref.current !== value\n // if (changed) {\n // console.log(\n // 'Changed:',\n // value,\n // Object.fromEntries(\n // Object.entries(value).filter(\n // ([key, val]) => val !== ref.current[key],\n // ),\n // ),\n // )\n // }\n // ref.current = value\n // }\n\n // useChangedDiff(match)\n\n const RouteErrorComponent =\n (route.options.errorComponent ?? router.options.defaultErrorComponent) ||\n ErrorComponent\n\n if (match.status === 'notFound') {\n let error: unknown\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n\n error = deserializeError(match.error.data)\n } else {\n error = match.error\n }\n\n invariant(isNotFound(error), 'Expected a notFound error')\n\n return renderRouteNotFound(router, route, error)\n }\n\n if (match.status === 'redirected') {\n // Redirects should be handled by the router transition. If we happen to\n // encounter a redirect here, it's a bug. Let's warn, but render nothing.\n invariant(isRedirect(match.error), 'Expected a redirect error')\n\n // warning(\n // false,\n // 'Tried to render a redirected route match! This is a weird circumstance, please file an issue!',\n // )\n throw match.loadPromise\n }\n\n if (match.status === 'error') {\n // If we're on the server, we need to use React's new and super\n // wonky api for throwing errors from a server side render inside\n // of a suspense boundary. This is the only way to get\n // renderToPipeableStream to not hang indefinitely.\n // We'll serialize the error and rethrow it on the client.\n if (router.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 // We're pending, and if we have a minPendingMs, we need to wait for it\n const pendingMinMs =\n route.options.pendingMinMs ?? router.options.defaultPendingMinMs\n\n if (pendingMinMs && !match.minPendingPromise) {\n // Create a promise that will resolve after the minPendingMs\n if (!router.isServer) {\n const minPendingPromise = createControlledPromise<void>()\n\n Promise.resolve().then(() => {\n router.updateMatch(match.id, (prev) => ({\n ...prev,\n minPendingPromise,\n }))\n })\n\n setTimeout(() => {\n minPendingPromise.resolve()\n\n // We've handled the minPendingPromise, so we can delete it\n router.updateMatch(match.id, (prev) => ({\n ...prev,\n minPendingPromise: undefined,\n }))\n }, pendingMinMs)\n }\n }\n\n throw match.loadPromise\n }\n\n const Comp = route.options.component ?? router.options.defaultComponent\n\n const out = Comp ? <Comp /> : <Outlet />\n\n return (\n <>\n {out}\n {router.AfterEachMatch ? (\n <router.AfterEachMatch match={match} matchIndex={matchIndex} />\n ) : null}\n </>\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) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const { parentGlobalNotFound } = useRouterState({\n select: (s) => {\n const matches = s.matches\n const parentMatch = matches.find((d) => d.id === matchId)\n invariant(\n parentMatch,\n `Could not find parent match for matchId \"${matchId}\"`,\n )\n return {\n parentGlobalNotFound: parentMatch.globalNotFound,\n }\n },\n })\n\n const childMatchId = useRouterState({\n select: (s) => {\n const matches = s.matches\n const index = matches.findIndex((d) => d.id === matchId)\n return matches[index + 1]?.id\n },\n })\n\n if (parentGlobalNotFound) {\n return renderRouteNotFound(router, route, undefined)\n }\n\n if (!childMatchId) {\n return null\n }\n\n const nextMatch = <Match matchId={childMatchId} />\n\n const pendingElement = router.options.defaultPendingComponent ? (\n <router.options.defaultPendingComponent />\n ) : null\n\n if (matchId === rootRouteId) {\n return (\n <React.Suspense fallback={pendingElement}>{nextMatch}</React.Suspense>\n )\n }\n\n return nextMatch\n})\n"],"names":["match"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBgB;;AACd;AACA;AAA+B;;AACd;AAAyC;AAAA;AAG1D;AAAA;AACE;AAC8C;AAG1C;AAEN;AAGA;AAEA;AAGA;AAEA;AAAqC;AAAA;AAGK;AAGpC;AAAA;AAAA;AAOA;AAEA;AAIA;AAIN;AAAgC;AACb;AAIjB;AAEI;AAAC;AAAA;AACoB;AACoB;AAGjC;AACI;AACR;AAAsB;AACxB;AAEA;AAAC;AAAA;AAKK;AAIM;AAED;AAAwD;AACjE;AAE8B;AAAA;AAChC;AAAA;AAKV;AACA;;AACE;AACA;AAA+B;;AACd;AAAyC;AAAA;AAGpD;AAEN;AAAkC;AAE9B;AAAkD;AACpD;AAGF;AAA6B;AAEnBA;AACN;AAAmB;AACjB;AACA;AACA;AACA;AACA;AACD;AACH;AAsBF;AAII;AACE;AACA;AACF;AAGQ;AAAiC;AAEzC;AAAc;AAGN;AAEH;AAAwC;AAG7C;AAGF;AAMA;AAAY;AAGV;AAMF;AAEI;AAAA;AAAC;AAAA;AACc;AACP;AACY;AAClB;AAAA;AAAA;AAKF;AACF;AAEM;AAAiC;AAEvC;AAAY;AACd;AAGE;AAEF;AAGI;AAEE;AACF;AAEQ;AACN;AAAwC;AACnC;AACH;AACA;AAGJ;AACE;AAGA;AAAwC;AACnC;AACgB;AACnB;AACW;AACjB;AAGF;AAAY;AAGd;AAEA;AAEA;AAEK;AAAA;AAGG;AAGV;AAEO;AACL;AACM;AACN;AAA+B;;AACd;AAAyC;AAAA;AAGpD;AAEA;AAA0C;AAE5C;AACA;AACA;AAAA;AACE;AACmD;AAE9C;AAAA;AAC6B;AAAA;AAEtC;AAGF;AAAoC;;AAEhC;AACA;AACO;AAAoB;AAC7B;AAGF;AACS;AAA4C;AAGrD;AACS;AAAA;AAGT;AAEM;AAIN;AACE;AACuD;AAIlD;AACT;;;"}
1
+ {"version":3,"file":"Match.cjs","sources":["../../src/Match.tsx"],"sourcesContent":["'use client'\n\nimport * 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 { createControlledPromise, pick } from './utils'\nimport { CatchNotFound, isNotFound } from './not-found'\nimport { isRedirect } from './redirects'\nimport { matchContext } from './matchContext'\nimport { defaultDeserializeError, isServerSideError } from './isServerSideError'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { rootRouteId } from './root'\nimport type { AnyRoute } from './route'\n\nexport const Match = React.memo(function MatchImpl({\n matchId,\n}: {\n matchId: string\n}) {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) => s.matches.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: AnyRoute = router.routesById[routeId]\n\n const PendingComponent =\n route.options.pendingComponent ?? router.options.defaultPendingComponent\n\n const pendingElement = PendingComponent ? <PendingComponent /> : null\n\n const routeErrorComponent =\n route.options.errorComponent ?? router.options.defaultErrorComponent\n\n const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch\n\n const routeNotFoundComponent = route.isRoot\n ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n (route.options.notFoundComponent ??\n router.options.notFoundRoute?.options.component)\n : route.options.notFoundComponent\n\n const ResolvedSuspenseBoundary =\n // If we're on the root route, allow forcefully wrapping in suspense\n (!route.isRoot || route.options.wrapInSuspense) &&\n (route.options.wrapInSuspense ??\n PendingComponent ??\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 const resetKey = useRouterState({\n select: (s) => s.loadedAt,\n })\n\n return (\n <matchContext.Provider value={matchId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => resetKey}\n errorComponent={routeErrorComponent || ErrorComponent}\n onCatch={(error, errorInfo) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(false, `Error in route match: ${matchId}`)\n routeOnCatch?.(error, errorInfo)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n // If the current not found handler doesn't exist or it has a\n // route ID which doesn't match the current route, rethrow the error\n if (\n !routeNotFoundComponent ||\n (error.routeId && error.routeId !== 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} />\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n )\n})\n\nexport const MatchInner = React.memo(function MatchInnerImpl({\n matchId,\n}: {\n matchId: string\n}): any {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const matchIndex = useRouterState({\n select: (s) => {\n return s.matches.findIndex((d) => d.id === matchId)\n },\n })\n\n const match = useRouterState({\n select: (s) => {\n const match = s.matches[matchIndex]!\n return pick(match, [\n 'id',\n 'status',\n 'error',\n 'loadPromise',\n 'minPendingPromise',\n ])\n },\n })\n\n const out = React.useMemo(() => {\n const Comp = route.options.component ?? router.options.defaultComponent\n return Comp ? <Comp key={matchId} /> : <Outlet />\n }, [matchId, route.options.component, router.options.defaultComponent])\n\n // function useChangedDiff(value: any) {\n // const ref = React.useRef(value)\n // const changed = ref.current !== value\n // if (changed) {\n // console.log(\n // 'Changed:',\n // value,\n // Object.fromEntries(\n // Object.entries(value).filter(\n // ([key, val]) => val !== ref.current[key],\n // ),\n // ),\n // )\n // }\n // ref.current = value\n // }\n\n // useChangedDiff(match)\n\n const RouteErrorComponent =\n (route.options.errorComponent ?? router.options.defaultErrorComponent) ||\n ErrorComponent\n\n if (match.status === 'notFound') {\n let error: unknown\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n\n error = deserializeError(match.error.data)\n } else {\n error = match.error\n }\n\n invariant(isNotFound(error), 'Expected a notFound error')\n\n return renderRouteNotFound(router, route, error)\n }\n\n if (match.status === 'redirected') {\n // Redirects should be handled by the router transition. If we happen to\n // encounter a redirect here, it's a bug. Let's warn, but render nothing.\n invariant(isRedirect(match.error), 'Expected a redirect error')\n\n // warning(\n // false,\n // 'Tried to render a redirected route match! This is a weird circumstance, please file an issue!',\n // )\n throw match.loadPromise\n }\n\n if (match.status === 'error') {\n // If we're on the server, we need to use React's new and super\n // wonky api for throwing errors from a server side render inside\n // of a suspense boundary. This is the only way to get\n // renderToPipeableStream to not hang indefinitely.\n // We'll serialize the error and rethrow it on the client.\n if (router.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 // We're pending, and if we have a minPendingMs, we need to wait for it\n const pendingMinMs =\n route.options.pendingMinMs ?? router.options.defaultPendingMinMs\n\n if (pendingMinMs && !match.minPendingPromise) {\n // Create a promise that will resolve after the minPendingMs\n if (!router.isServer) {\n const minPendingPromise = createControlledPromise<void>()\n\n Promise.resolve().then(() => {\n router.updateMatch(match.id, (prev) => ({\n ...prev,\n minPendingPromise,\n }))\n })\n\n setTimeout(() => {\n minPendingPromise.resolve()\n\n // We've handled the minPendingPromise, so we can delete it\n router.updateMatch(match.id, (prev) => ({\n ...prev,\n minPendingPromise: undefined,\n }))\n }, pendingMinMs)\n }\n }\n\n throw match.loadPromise\n }\n\n return (\n <>\n {out}\n {router.AfterEachMatch ? (\n <router.AfterEachMatch match={match} matchIndex={matchIndex} />\n ) : null}\n </>\n )\n})\n\nexport const Outlet = React.memo(function OutletImpl() {\n const router = useRouter()\n const matchId = React.useContext(matchContext)\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const { parentGlobalNotFound } = useRouterState({\n select: (s) => {\n const matches = s.matches\n const parentMatch = matches.find((d) => d.id === matchId)\n invariant(\n parentMatch,\n `Could not find parent match for matchId \"${matchId}\"`,\n )\n return {\n parentGlobalNotFound: parentMatch.globalNotFound,\n }\n },\n })\n\n const childMatchId = useRouterState({\n select: (s) => {\n const matches = s.matches\n const index = matches.findIndex((d) => d.id === matchId)\n return matches[index + 1]?.id\n },\n })\n\n if (parentGlobalNotFound) {\n return renderRouteNotFound(router, route, undefined)\n }\n\n if (!childMatchId) {\n return null\n }\n\n const nextMatch = <Match matchId={childMatchId} />\n\n const pendingElement = router.options.defaultPendingComponent ? (\n <router.options.defaultPendingComponent />\n ) : null\n\n if (matchId === rootRouteId) {\n return (\n <React.Suspense fallback={pendingElement}>{nextMatch}</React.Suspense>\n )\n }\n\n return nextMatch\n})\n"],"names":["match"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBO;AAA4C;AAEnD;;AAGE;AACA;AAA+B;;AACd;AAAyC;AAAA;AAG1D;AAAA;AACE;AAC8C;AAG1C;AAEN;AAGA;AAEA;AAGA;AAEA;AAAqC;AAAA;AAGK;AAGpC;AAAA;AAAA;AAOA;AAEA;AAIA;AAIN;AAAgC;AACb;AAIjB;AAEI;AAAC;AAAA;AACoB;AACoB;AAGjC;AACI;AACR;AAAsB;AACxB;AAEA;AAAC;AAAA;AAKK;AAIM;AAED;AAAwD;AACjE;AAE8B;AAAA;AAChC;AAAA;AAKV;AAEO;AAAsD;AAE7D;;AAGE;AACA;AAA+B;;AACd;AAAyC;AAAA;AAGpD;AAEN;AAAkC;AAE9B;AAAkD;AACpD;AAGF;AAA6B;AAEnBA;AACN;AAAmB;AACjB;AACA;AACA;AACA;AACA;AACD;AACH;AAGI;AACJ;AACA;AAA+C;AAsBjD;AAII;AACE;AACA;AACF;AAGQ;AAAiC;AAEzC;AAAc;AAGN;AAEH;AAAwC;AAG7C;AAGF;AAMA;AAAY;AAGV;AAMF;AAEI;AAAA;AAAC;AAAA;AACc;AACP;AACY;AAClB;AAAA;AAAA;AAKF;AACF;AAEM;AAAiC;AAEvC;AAAY;AACd;AAGE;AAEF;AAGI;AAEE;AACF;AAEQ;AACN;AAAwC;AACnC;AACH;AACA;AAGJ;AACE;AAGA;AAAwC;AACnC;AACgB;AACnB;AACW;AACjB;AAGF;AAAY;AAGd;AAEK;AAAA;AAGG;AAGV;AAEO;AACL;AACM;AACN;AAA+B;;AACd;AAAyC;AAAA;AAGpD;AAEA;AAA0C;AAE5C;AACA;AACA;AAAA;AACE;AACmD;AAE9C;AAAA;AAC6B;AAAA;AAEtC;AAGF;AAAoC;;AAEhC;AACA;AACO;AAAoB;AAC7B;AAGF;AACS;AAA4C;AAGrD;AACS;AAAA;AAGT;AAEM;AAIN;AACE;AACuD;AAIlD;AACT;;;;"}
@@ -1,5 +1,8 @@
1
1
  import * as React from 'react';
2
- export declare function Match({ matchId }: {
2
+ export declare const Match: React.NamedExoticComponent<{
3
3
  matchId: string;
4
- }): import("react/jsx-runtime").JSX.Element;
4
+ }>;
5
+ export declare const MatchInner: React.NamedExoticComponent<{
6
+ matchId: string;
7
+ }>;
5
8
  export declare const Outlet: React.NamedExoticComponent<object>;
@@ -1 +1 @@
1
- {"version":3,"file":"Matches.cjs","sources":["../../src/Matches.tsx"],"sourcesContent":["import * as React from 'react'\nimport warning from 'tiny-warning'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { type AnyRouter, type RegisteredRouter } from './router'\nimport { Transitioner } from './Transitioner'\nimport {\n type AnyRoute,\n type ReactNode,\n type StaticDataRouteOption,\n} from './route'\nimport { matchContext } from './matchContext'\nimport { Match } from './Match'\nimport { SafeFragment } from './SafeFragment'\nimport type { ResolveRelativePath, ToOptions } from './link'\nimport type {\n AllContext,\n AllLoaderData,\n AllParams,\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteByPath,\n RouteIds,\n RoutePaths,\n} from './routeInfo'\nimport type { ControlledPromise, DeepPartial, NoInfer } from './utils'\n\nexport interface RouteMatch<\n TRouteId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps,\n> {\n id: string\n routeId: TRouteId\n index: number\n pathname: string\n params: TAllParams\n status: 'pending' | 'success' | 'error' | 'redirected' | 'notFound'\n isFetching: false | 'beforeLoad' | 'loader'\n error: unknown\n paramsError: unknown\n searchError: unknown\n updatedAt: number\n componentsPromise?: Promise<Array<void>>\n loadPromise?: ControlledPromise<void>\n beforeLoadPromise?: ControlledPromise<void>\n loaderPromise?: ControlledPromise<void>\n loaderData?: TLoaderData\n routeContext: TRouteContext\n context: TAllContext\n search: TFullSearchSchema\n fetchCount: number\n abortController: AbortController\n cause: 'preload' | 'enter' | 'stay'\n loaderDeps: TLoaderDeps\n preload: boolean\n invalid: boolean\n meta?: Array<React.JSX.IntrinsicElements['meta']>\n links?: Array<React.JSX.IntrinsicElements['link']>\n scripts?: Array<React.JSX.IntrinsicElements['script']>\n headers?: Record<string, string>\n globalNotFound?: boolean\n staticData: StaticDataRouteOption\n minPendingPromise?: ControlledPromise<void>\n pendingTimeout?: ReturnType<typeof setTimeout>\n}\n\nexport type MakeRouteMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId = ParseRoute<TRouteTree>['id'],\n TStrict extends boolean = true,\n TTypes extends AnyRoute['types'] = RouteById<TRouteTree, TRouteId>['types'],\n TAllParams = TStrict extends false\n ? AllParams<TRouteTree>\n : TTypes['allParams'],\n TFullSearchSchema = TStrict extends false\n ? FullSearchSchema<TRouteTree>\n : TTypes['fullSearchSchema'],\n TLoaderData = TStrict extends false\n ? AllLoaderData<TRouteTree>\n : TTypes['loaderData'],\n TAllContext = TStrict extends false\n ? AllContext<TRouteTree>\n : TTypes['allContext'],\n TRouteContext = TTypes['routeContext'],\n TLoaderDeps = TTypes['loaderDeps'],\n> = RouteMatch<\n TRouteId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps\n>\n\nexport type AnyRouteMatch = RouteMatch<any, any, any, any, any, any, any>\n\nexport function Matches() {\n const router = useRouter()\n\n const pendingElement = router.options.defaultPendingComponent ? (\n <router.options.defaultPendingComponent />\n ) : null\n\n const ResolvedSuspense = !router.state.matches.length\n ? React.Suspense\n : SafeFragment\n\n const inner = (\n <ResolvedSuspense fallback={pendingElement}>\n <Transitioner />\n <MatchesInner />\n </ResolvedSuspense>\n )\n\n return router.options.InnerWrap ? (\n <router.options.InnerWrap>{inner}</router.options.InnerWrap>\n ) : (\n inner\n )\n}\n\nfunction MatchesInner() {\n const matchId = useRouterState({\n select: (s) => {\n return s.matches[0]?.id\n },\n })\n\n const resetKey = useRouterState({\n select: (s) => s.loadedAt,\n })\n\n return (\n <matchContext.Provider value={matchId}>\n <CatchBoundary\n getResetKey={() => resetKey}\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 warning(false, error.message || error.toString())\n }}\n >\n {matchId ? <Match matchId={matchId} /> : null}\n </CatchBoundary>\n </matchContext.Provider>\n )\n}\n\nexport interface MatchRouteOptions {\n pending?: boolean\n caseSensitive?: boolean\n includeSearch?: boolean\n fuzzy?: boolean\n}\n\nexport type UseMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> = RoutePaths<\n TRouter['routeTree']\n >,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> = TFrom,\n TMaskTo extends string = '',\n TOptions extends ToOptions<\n TRouter,\n TFrom,\n TTo,\n TMaskFrom,\n TMaskTo\n > = ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n TRelaxedOptions = Omit<TOptions, 'search' | 'params'> &\n DeepPartial<Pick<TOptions, 'search' | 'params'>>,\n> = TRelaxedOptions & MatchRouteOptions\n\nexport function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>() {\n const router = useRouter()\n\n useRouterState({\n select: (s) => [s.location.href, s.resolvedLocation.href, s.status],\n })\n\n return React.useCallback(\n <\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>,\n >(\n opts: UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n ):\n | false\n | RouteByPath<TRouter['routeTree'], TResolved>['types']['allParams'] => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n },\n [router],\n )\n}\n\nexport type MakeMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> = RoutePaths<\n TRouter['routeTree']\n >,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> = TFrom,\n TMaskTo extends string = '',\n> = UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | ((\n params?: RouteByPath<\n TRouter['routeTree'],\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => ReactNode)\n | React.ReactNode\n}\n\nexport function MatchRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> = RoutePaths<\n TRouter['routeTree']\n >,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> = TFrom,\n TMaskTo extends string = '',\n>(props: MakeMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): 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 useMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TRouteMatch = MakeRouteMatch<TRouteTree, TRouteId>,\n T = Array<TRouteMatch>,\n>(opts?: { select?: (matches: Array<TRouteMatch>) => T }): T {\n return useRouterState({\n select: (state) => {\n const matches = state.matches\n return opts?.select\n ? opts.select(matches as Array<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 TRouteMatch = MakeRouteMatch<TRouteTree, TRouteId>,\n T = Array<TRouteMatch>,\n>(opts?: { select?: (matches: Array<TRouteMatch>) => T }): 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 Array<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 TRouteMatch = MakeRouteMatch<TRouteTree, TRouteId>,\n T = Array<TRouteMatch>,\n>(opts?: { select?: (matches: Array<TRouteMatch>) => T }): 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 Array<TRouteMatch>)\n : (matches as T)\n },\n })\n}\n"],"names":["useRouter","React","SafeFragment","jsxs","jsx","Transitioner","useRouterState","matchContext","CatchBoundary","ErrorComponent","Match"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwGO,SAAS,UAAU;AACxB,QAAM,SAASA,UAAAA;AAET,QAAA,iBAAiB,OAAO,QAAQ,yDACnC,OAAO,QAAQ,yBAAf,CAAuC,CAAA,IACtC;AAEJ,QAAM,mBAAmB,CAAC,OAAO,M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AA,OAAO,WAAW,MAAa;AAAA,QACpC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA,CACD;AAAA,IACH;AAAA,IACA,CAAC,MAAM;AAAA,EAAA;AAEX;AAsBO,SAAS,WAQd,OAA4E;AAC5E,QAAM,aAAa;AACb,QAAA,SAAS,WAAW,KAAY;AAElC,MAAA,OAAO,MAAM,aAAa,YAAY;AAChC,WAAA,MAAM,SAAiB,MAAM;AAAA,EACvC;AAEO,SAAA,SAAS,MAAM,WAAW;AACnC;AAEO,SAAS,WAKd,MAA2D;AAC3D,SAAOK,8BAAe;AAAA,IACpB,QAAQ,CAAC,UAAU;AACjB,YAAM,UAAU,MAAM;AACtB,cAAO,6BAAM,UACT,KAAK,OAAO,OAA6B,IACxC;AAAA,IACP;AAAA,EAAA,CACD;AACH;AAEO,SAAS,iBAKd,MAA2D;AACrD,QAAA,iBAAiBL,iBAAM,WAAWM,aAAY,YAAA;AAEpD,SAAO,WAAW;AAAA,IAChB,QAAQ,CAAC,YAAY;AACnB,gBAAU,QAAQ;AAAA,QAChB;AAAA,QACA,QAAQ,UAAU,CAAC,MAAM,EAAE,OAAO,cAAc;AAAA,MAAA;AAElD,cAAO,6BAAM,UACT,KAAK,OAAO,OAA6B,IACxC;AAAA,IACP;AAAA,EAAA,CACD;AACH;AAEO,SAAS,gBAKd,MAA2D;AACrD,QAAA,iBAAiBN,iBAAM,WAAWM,aAAY,YAAA;AAEpD,SAAO,WAAW;AAAA,IAChB,QAAQ,CAAC,YAAY;AACnB,gBAAU,QAAQ;AAAA,QAChB,QAAQ,UAAU,CAAC,MAAM,EAAE,OAAO,cAAc,IAAI;AAAA,MAAA;AAEtD,cAAO,6BAAM,UACT,KAAK,OAAO,OAA6B,IACxC;AAAA,IACP;AAAA,EAAA,CACD;AACH;;;;;;;"}
1
+ {"version":3,"file":"Matches.cjs","sources":["../../src/Matches.tsx"],"sourcesContent":["import * as React from 'react'\nimport warning from 'tiny-warning'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { Transitioner } from './Transitioner'\nimport {\n type AnyRoute,\n type ReactNode,\n type StaticDataRouteOption,\n} from './route'\nimport { matchContext } from './matchContext'\nimport { Match } from './Match'\nimport { SafeFragment } from './SafeFragment'\nimport type { AnyRouter, RegisteredRouter } from './router'\nimport type { ResolveRelativePath, ToOptions } from './link'\nimport type {\n AllContext,\n AllLoaderData,\n AllParams,\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteByPath,\n RouteIds,\n RoutePaths,\n} from './routeInfo'\nimport type { ControlledPromise, DeepPartial, NoInfer } from './utils'\n\nexport interface RouteMatch<\n TRouteId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps,\n> {\n id: string\n routeId: TRouteId\n index: number\n pathname: string\n params: TAllParams\n status: 'pending' | 'success' | 'error' | 'redirected' | 'notFound'\n isFetching: false | 'beforeLoad' | 'loader'\n error: unknown\n paramsError: unknown\n searchError: unknown\n updatedAt: number\n componentsPromise?: Promise<Array<void>>\n loadPromise?: ControlledPromise<void>\n beforeLoadPromise?: ControlledPromise<void>\n loaderPromise?: ControlledPromise<void>\n loaderData?: TLoaderData\n routeContext: TRouteContext\n context: TAllContext\n search: TFullSearchSchema\n fetchCount: number\n abortController: AbortController\n cause: 'preload' | 'enter' | 'stay'\n loaderDeps: TLoaderDeps\n preload: boolean\n invalid: boolean\n meta?: Array<React.JSX.IntrinsicElements['meta']>\n links?: Array<React.JSX.IntrinsicElements['link']>\n scripts?: Array<React.JSX.IntrinsicElements['script']>\n headers?: Record<string, string>\n globalNotFound?: boolean\n staticData: StaticDataRouteOption\n minPendingPromise?: ControlledPromise<void>\n pendingTimeout?: ReturnType<typeof setTimeout>\n}\n\nexport type MakeRouteMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId = ParseRoute<TRouteTree>['id'],\n TStrict extends boolean = true,\n TTypes extends AnyRoute['types'] = RouteById<TRouteTree, TRouteId>['types'],\n TAllParams = TStrict extends false\n ? AllParams<TRouteTree>\n : TTypes['allParams'],\n TFullSearchSchema = TStrict extends false\n ? FullSearchSchema<TRouteTree>\n : TTypes['fullSearchSchema'],\n TLoaderData = TStrict extends false\n ? AllLoaderData<TRouteTree>\n : TTypes['loaderData'],\n TAllContext = TStrict extends false\n ? AllContext<TRouteTree>\n : TTypes['allContext'],\n TRouteContext = TTypes['routeContext'],\n TLoaderDeps = TTypes['loaderDeps'],\n> = RouteMatch<\n TRouteId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps\n>\n\nexport type AnyRouteMatch = RouteMatch<any, any, any, any, any, any, any>\n\nexport function Matches() {\n const router = useRouter()\n\n const pendingElement = router.options.defaultPendingComponent ? (\n <router.options.defaultPendingComponent />\n ) : null\n\n const ResolvedSuspense = !router.state.matches.length\n ? React.Suspense\n : SafeFragment\n\n const inner = (\n <ResolvedSuspense fallback={pendingElement}>\n <Transitioner />\n <MatchesInner />\n </ResolvedSuspense>\n )\n\n return router.options.InnerWrap ? (\n <router.options.InnerWrap>{inner}</router.options.InnerWrap>\n ) : (\n inner\n )\n}\n\nfunction MatchesInner() {\n const matchId = useRouterState({\n select: (s) => {\n return s.matches[0]?.id\n },\n })\n\n const resetKey = useRouterState({\n select: (s) => s.loadedAt,\n })\n\n return (\n <matchContext.Provider value={matchId}>\n <CatchBoundary\n getResetKey={() => resetKey}\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 warning(false, error.message || error.toString())\n }}\n >\n {matchId ? <Match matchId={matchId} /> : null}\n </CatchBoundary>\n </matchContext.Provider>\n )\n}\n\nexport interface MatchRouteOptions {\n pending?: boolean\n caseSensitive?: boolean\n includeSearch?: boolean\n fuzzy?: boolean\n}\n\nexport type UseMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> = RoutePaths<\n TRouter['routeTree']\n >,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> = TFrom,\n TMaskTo extends string = '',\n TOptions extends ToOptions<\n TRouter,\n TFrom,\n TTo,\n TMaskFrom,\n TMaskTo\n > = ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n TRelaxedOptions = Omit<TOptions, 'search' | 'params'> &\n DeepPartial<Pick<TOptions, 'search' | 'params'>>,\n> = TRelaxedOptions & MatchRouteOptions\n\nexport function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>() {\n const router = useRouter()\n\n useRouterState({\n select: (s) => [s.location.href, s.resolvedLocation.href, s.status],\n })\n\n return React.useCallback(\n <\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>,\n >(\n opts: UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n ):\n | false\n | RouteByPath<TRouter['routeTree'], TResolved>['types']['allParams'] => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n },\n [router],\n )\n}\n\nexport type MakeMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> = RoutePaths<\n TRouter['routeTree']\n >,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> = TFrom,\n TMaskTo extends string = '',\n> = UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | ((\n params?: RouteByPath<\n TRouter['routeTree'],\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => ReactNode)\n | React.ReactNode\n}\n\nexport function MatchRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> = RoutePaths<\n TRouter['routeTree']\n >,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> = TFrom,\n TMaskTo extends string = '',\n>(props: MakeMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): 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 useMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TRouteMatch = MakeRouteMatch<TRouteTree, TRouteId>,\n T = Array<TRouteMatch>,\n>(opts?: { select?: (matches: Array<TRouteMatch>) => T }): T {\n return useRouterState({\n select: (state) => {\n const matches = state.matches\n return opts?.select\n ? opts.select(matches as Array<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 TRouteMatch = MakeRouteMatch<TRouteTree, TRouteId>,\n T = Array<TRouteMatch>,\n>(opts?: { select?: (matches: Array<TRouteMatch>) => T }): 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 Array<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 TRouteMatch = MakeRouteMatch<TRouteTree, TRouteId>,\n T = Array<TRouteMatch>,\n>(opts?: { select?: (matches: Array<TRouteMatch>) => T }): 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 Array<TRouteMatch>)\n : (matches as T)\n },\n })\n}\n"],"names":["useRouter","React","SafeFragment","jsxs","jsx","Transitioner","useRouterState","matchContext","CatchBoundary","ErrorComponent","Match"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwGO,SAAS,UAAU;AACxB,QAAM,SAASA,UAAAA;AAET,QAAA,iBAAiB,OAAO,QAAQ,yDACnC,OAAO,QAAQ,yBAAf,CAAuC,CAAA,IACtC;AAEJ,QAAM,mBAAmB,CAAC,OAAO,MAAM,QAAQ,SAC3CC,iBAAM,WACNC;AAEJ,QAAM,QACJC,2BAAAA,KAAC,kBAAiB,EAAA,UAAU,gBAC1B,UAAA;AAAA,IAAAC,2BAAA,IAACC,aAAa,cAAA,EAAA;AAAA,mCACb,cAAa,EAAA;AAAA,EAChB,EAAA,CAAA;AAGK,SAAA,OAAO,QAAQ,YACpBD,2BAAA,IAAC,OAAO,QAAQ,WAAf,EAA0B,UAAA,MAAM,CAAA,IAEjC;AAEJ;AAEA,SAAS,eAAe;AACtB,QAAM,UAAUE,eAAAA,eAAe;AAAA,IAC7B,QAAQ,CAAC,MAAM;;AACN,cAAA,OAAE,QAAQ,CAAC,MAAX,mBAAc;AAAA,IACvB;AAAA,EAAA,CACD;AAED,QAAM,WAAWA,eAAAA,eAAe;AAAA,IAC9B,QAAQ,CAAC,MAAM,EAAE;AAAA,EAAA,CAClB;AAED,SACGF,2BAAAA,IAAAG,aAAAA,aAAa,UAAb,EAAsB,OAAO,SAC5B,UAAAH,2BAAA;AAAA,IAACI,cAAA;AAAA,IAAA;AAAA,MACC,aAAa,MAAM;AAAA,MACnB,gBAAgBC,cAAA;AAAA,MAChB,SAAS,CAAC,UAAU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AElD,cAAO,6BAAM,UACT,KAAK,OAAO,OAA6B,IACxC;AAAA,IACP;AAAA,EAAA,CACD;AACH;AAEO,SAAS,gBAKd,MAA2D;AACrD,QAAA,iBAAiBN,iBAAM,WAAWM,aAAY,YAAA;AAEpD,SAAO,WAAW;AAAA,IAChB,QAAQ,CAAC,YAAY;AACnB,gBAAU,QAAQ;AAAA,QAChB,QAAQ,UAAU,CAAC,MAAM,EAAE,OAAO,cAAc,IAAI;AAAA,MAAA;AAEtD,cAAO,6BAAM,UACT,KAAK,OAAO,OAA6B,IACxC;AAAA,IACP;AAAA,EAAA,CACD;AACH;;;;;;;"}
@@ -1,5 +1,5 @@
1
- import { AnyRouter, RegisteredRouter } from './router.cjs';
2
1
  import { AnyRoute, ReactNode, StaticDataRouteOption } from './route.cjs';
2
+ import { AnyRouter, RegisteredRouter } from './router.cjs';
3
3
  import { ResolveRelativePath, ToOptions } from './link.cjs';
4
4
  import { AllContext, AllLoaderData, AllParams, FullSearchSchema, ParseRoute, RouteById, RouteByPath, RouteIds, RoutePaths } from './routeInfo.cjs';
5
5
  import { ControlledPromise, DeepPartial, NoInfer } from './utils.cjs';
@@ -1 +1 @@
1
- {"version":3,"file":"RouterProvider.cjs","sources":["../../src/RouterProvider.tsx"],"sourcesContent":["// eslint-disable-next-line ts/consistent-type-imports\nimport * as React from 'react'\nimport { Matches } from './Matches'\nimport { getRouterContext } from './routerContext'\nimport type { NavigateOptions, ToOptions } from './link'\nimport type { ParsedLocation } from './location'\nimport type { AnyRoute } from './route'\nimport type { RoutePaths } from './routeInfo'\nimport type {\n AnyRouter,\n RegisteredRouter,\n Router,\n RouterOptions,\n RouterState,\n} from './router'\n\nimport type { MakeRouteMatch } from './Matches'\n\nexport interface CommitLocationOptions {\n replace?: boolean\n resetScroll?: boolean\n viewTransition?: boolean\n /**\n * @deprecated All navigations use React transitions under the hood now\n **/\n startTransition?: boolean\n ignoreBlocker?: 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 TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n>(\n opts: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {\n __isRedirect?: boolean\n },\n) => Promise<void>\n\nexport type BuildLocationFn = <\n TTo extends string,\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n>(\n opts: ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {\n leaveParams?: boolean\n },\n) => ParsedLocation\n\nexport type InjectedHtmlEntry = string | (() => Promise<string> | string)\n\nexport function RouterContextProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({\n router,\n children,\n ...rest\n}: RouterProps<TRouter, TDehydrated> & {\n children: React.ReactNode\n}) {\n // 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 routerContext = getRouterContext()\n\n const provider = (\n <routerContext.Provider value={router}>{children}</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\nexport function RouterProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({ router, ...rest }: RouterProps<TRouter, TDehydrated>) {\n return (\n <RouterContextProvider router={router} {...rest}>\n <Matches />\n </RouterContextProvider>\n )\n}\n\nexport type RouterProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n TDehydrated\n >,\n 'context'\n> & {\n router: Router<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>\n >\n context?: Partial<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n TDehydrated\n >['context']\n >\n}\n"],"names":["routerContext","getRouterContext","jsx","Matches"],"mappings":";;;;;AA8DO,SAAS,sBAGd;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAEG;AAED,SAAO,OAAO;AAAA,IACZ,GAAG,OAAO;AAAA,IACV,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,OAAO,QAAQ;AAAA,MAClB,GAAG,KAAK;AAAA,IACV;AAAA,EAAA,CACM;AAER,QAAMA,kBAAgBC,cAAAA;AAEtB,QAAM,WACHC,2BAAA,IAAAF,gBAAc,UAAd,EAAuB,OAAO,QAAS,SAAS,CAAA;AAG/C,MAAA,OAAO,QAAQ,MAAM;AACvB,WAAQE,2BAAAA,IAAA,OAAO,QAAQ,MAAf,EAAqB,UAAS,SAAA,CAAA;AAAA,EACxC;AAEO,SAAA;AACT;AAEO,SAAS,eAGd,EAAE,QAAQ,GAAG,QAA2C;AACxD,wCACG,uBAAsB,EAAA,QAAiB,GAAG,MACzC,UAAAA,+BAACC,QAAAA,UAAQ,CAAA,EACX,CAAA;AAEJ;;;"}
1
+ {"version":3,"file":"RouterProvider.cjs","sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Matches } from './Matches'\nimport { getRouterContext } from './routerContext'\nimport type { NavigateOptions, ToOptions } from './link'\nimport type { ParsedLocation } from './location'\nimport type { RoutePaths } from './routeInfo'\nimport type {\n AnyRouter,\n RegisteredRouter,\n Router,\n RouterOptions,\n} from './router'\n\nexport interface CommitLocationOptions {\n replace?: boolean\n resetScroll?: boolean\n viewTransition?: boolean\n /**\n * @deprecated All navigations use React transitions under the hood now\n **/\n startTransition?: boolean\n ignoreBlocker?: 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 TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n>(\n opts: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {\n __isRedirect?: boolean\n },\n) => Promise<void>\n\nexport type BuildLocationFn = <\n TTo extends string,\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n>(\n opts: ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {\n leaveParams?: boolean\n },\n) => ParsedLocation\n\nexport type InjectedHtmlEntry = string | (() => Promise<string> | string)\n\nexport function RouterContextProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({\n router,\n children,\n ...rest\n}: RouterProps<TRouter, TDehydrated> & {\n children: React.ReactNode\n}) {\n // 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 routerContext = getRouterContext()\n\n const provider = (\n <routerContext.Provider value={router}>{children}</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\nexport function RouterProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({ router, ...rest }: RouterProps<TRouter, TDehydrated>) {\n return (\n <RouterContextProvider router={router} {...rest}>\n <Matches />\n </RouterContextProvider>\n )\n}\n\nexport type RouterProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n TDehydrated\n >,\n 'context'\n> & {\n router: Router<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>\n >\n context?: Partial<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n TDehydrated\n >['context']\n >\n}\n"],"names":["routerContext","getRouterContext","jsx","Matches"],"mappings":";;;;;AAyDO,SAAS,sBAGd;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAEG;AAED,SAAO,OAAO;AAAA,IACZ,GAAG,OAAO;AAAA,IACV,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,OAAO,QAAQ;AAAA,MAClB,GAAG,KAAK;AAAA,IACV;AAAA,EAAA,CACM;AAER,QAAMA,kBAAgBC,cAAAA;AAEtB,QAAM,WACHC,2BAAA,IAAAF,gBAAc,UAAd,EAAuB,OAAO,QAAS,SAAS,CAAA;AAG/C,MAAA,OAAO,QAAQ,MAAM;AACvB,WAAQE,2BAAAA,IAAA,OAAO,QAAQ,MAAf,EAAqB,UAAS,SAAA,CAAA;AAAA,EACxC;AAEO,SAAA;AACT;AAEO,SAAS,eAGd,EAAE,QAAQ,GAAG,QAA2C;AACxD,wCACG,uBAAsB,EAAA,QAAiB,GAAG,MACzC,UAAAA,+BAACC,QAAAA,UAAQ,CAAA,EACX,CAAA;AAEJ;;;"}
@@ -4,9 +4,6 @@ const React = require("react");
4
4
  const utils = require("./utils.cjs");
5
5
  const useRouter = require("./useRouter.cjs");
6
6
  const useRouterState = require("./useRouterState.cjs");
7
- require("@tanstack/history");
8
- require("tiny-invariant");
9
- require("tiny-warning");
10
7
  const path = require("./path.cjs");
11
8
  function _interopNamespaceDefault(e) {
12
9
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -1 +1 @@
1
- {"version":3,"file":"Transitioner.cjs","sources":["../../src/Transitioner.tsx"],"sourcesContent":["import * as React from 'react'\nimport { pick, useLayoutEffect, usePrevious } from './utils'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\nimport { trimPathRight } from '.'\n\nexport function 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_] = React.useTransition()\n // Track pending state changes\n const hasPendingMatches = useRouterState({\n select: (s) => s.matches.some((d) => d.status === 'pending'),\n })\n\n const previousIsLoading = usePrevious(routerState.isLoading)\n\n const isAnyPending =\n routerState.isLoading || isTransitioning || hasPendingMatches\n const previousIsAnyPending = usePrevious(isAnyPending)\n\n if (!router.isServer) {\n router.startReactTransition = startReactTransition_\n }\n\n // Subscribe to location changes\n // and try to load the new location\n React.useEffect(() => {\n const unsub = router.history.subscribe(router.load)\n\n const nextLocation = router.buildLocation({\n to: router.latestLocation.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n })\n\n if (\n trimPathRight(router.latestLocation.href) !==\n trimPathRight(nextLocation.href)\n ) {\n router.commitLocation({ ...nextLocation, replace: true })\n }\n\n return () => {\n unsub()\n }\n }, [router, router.history])\n\n // Try to load the initial location\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\n const tryLoad = async () => {\n try {\n await router.load()\n } catch (err) {\n console.error(err)\n }\n }\n\n tryLoad()\n }, [router])\n\n useLayoutEffect(() => {\n // The router was loading and now it's not\n if (previousIsLoading && !routerState.isLoading) {\n const toLocation = router.state.location\n const fromLocation = router.state.resolvedLocation\n const pathChanged = fromLocation.href !== toLocation.href\n\n router.emit({\n type: 'onLoad', // When the new URL has committed, when the new matches have been loaded into state.matches\n fromLocation,\n toLocation,\n pathChanged,\n })\n }\n }, [previousIsLoading, router, routerState.isLoading])\n\n useLayoutEffect(() => {\n // The router was pending and now it's not\n if (previousIsAnyPending && !isAnyPending) {\n const toLocation = router.state.location\n const fromLocation = router.state.resolvedLocation\n const pathChanged = fromLocation.href !== toLocation.href\n\n router.emit({\n type: 'onResolved',\n fromLocation,\n toLocation,\n pathChanged,\n })\n\n router.__store.setState((s) => ({\n ...s,\n status: 'idle',\n resolvedLocation: s.location,\n }))\n\n if ((document as any).querySelector) {\n if (router.state.location.hash !== '') {\n const el = document.getElementById(router.state.location.hash)\n if (el) {\n el.scrollIntoView()\n }\n }\n }\n }\n }, [isAnyPending, previousIsAnyPending, router])\n\n return null\n}\n"],"names":["useRouter","React","useRouterState","pick","usePrevious","trimPathRight","useLayoutEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAMO,SAAS,eAAe;AAC7B,QAAM,SAASA,UAAAA;AACf,QAAM,qBAAqBC,iBAAM,OAAO,EAAE,QAAQ,SAAS,OAAO;AAClE,QAAM,cAAcC,eAAAA,eAAe;AAAA,IACjC,QAAQ,CAAC,MACPC,MAAAA,KAAK,GAAG,CAAC,aAAa,YAAY,oBAAoB,iBAAiB,CAAC;AAAA,EAAA,CAC3E;AAED,QAAM,CAAC,iBAAiB,qBAAqB,IAAIF,iBAAM,cAAc;AAErE,QAAM,oBAAoBC,eAAAA,eAAe;AAAA,IACvC,QAAQ,CAAC,MAAM,EAAE,QAAQ,KAAK,CAAC,MAAM,EAAE,WAAW,SAAS;AAAA,EAAA,CAC5D;AAEK,QAAA,oBAAoBE,MAAAA,YAAY,YAAY,SAAS;AAErD,QAAA,eACJ,YAAY,aAAa,mBAAmB;AACxC,QAAA,uBAAuBA,kBAAY,YAAY;AAEjD,MAAA,CAAC,OAAO,UAAU;AACpB,WAAO,uBAAuB;AAAA,EAChC;AAIAH,mBAAM,UAAU,MAAM;AACpB,UAAM,QAAQ,OAAO,QAAQ,UAAU,OAAO,IAAI;AAE5C,UAAA,eAAe,OAAO,c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AAEM,aAAA,QAAQ,SAAS,CAAC,OAAO;AAAA,QAC9B,GAAG;AAAA,QACH,QAAQ;AAAA,QACR,kBAAkB,EAAE;AAAA,MACpB,EAAA;AAEF,UAAK,SAAiB,eAAe;AACnC,YAAI,OAAO,MAAM,SAAS,SAAS,IAAI;AACrC,gBAAM,KAAK,SAAS,eAAe,OAAO,MAAM,SAAS,IAAI;AAC7D,cAAI,IAAI;AACN,eAAG,eAAe;AAAA,UACpB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACC,GAAA,CAAC,cAAc,sBAAsB,MAAM,CAAC;AAExC,SAAA;AACT;;"}
1
+ {"version":3,"file":"Transitioner.cjs","sources":["../../src/Transitioner.tsx"],"sourcesContent":["import * as React from 'react'\nimport { pick, useLayoutEffect, usePrevious } from './utils'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\nimport { trimPathRight } from './path'\n\nexport function 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_] = React.useTransition()\n // Track pending state changes\n const hasPendingMatches = useRouterState({\n select: (s) => s.matches.some((d) => d.status === 'pending'),\n })\n\n const previousIsLoading = usePrevious(routerState.isLoading)\n\n const isAnyPending =\n routerState.isLoading || isTransitioning || hasPendingMatches\n const previousIsAnyPending = usePrevious(isAnyPending)\n\n if (!router.isServer) {\n router.startReactTransition = startReactTransition_\n }\n\n // Subscribe to location changes\n // and try to load the new location\n React.useEffect(() => {\n const unsub = router.history.subscribe(router.load)\n\n const nextLocation = router.buildLocation({\n to: router.latestLocation.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n })\n\n if (\n trimPathRight(router.latestLocation.href) !==\n trimPathRight(nextLocation.href)\n ) {\n router.commitLocation({ ...nextLocation, replace: true })\n }\n\n return () => {\n unsub()\n }\n }, [router, router.history])\n\n // Try to load the initial location\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\n const tryLoad = async () => {\n try {\n await router.load()\n } catch (err) {\n console.error(err)\n }\n }\n\n tryLoad()\n }, [router])\n\n useLayoutEffect(() => {\n // The router was loading and now it's not\n if (previousIsLoading && !routerState.isLoading) {\n const toLocation = router.state.location\n const fromLocation = router.state.resolvedLocation\n const pathChanged = fromLocation.href !== toLocation.href\n\n router.emit({\n type: 'onLoad', // When the new URL has committed, when the new matches have been loaded into state.matches\n fromLocation,\n toLocation,\n pathChanged,\n })\n }\n }, [previousIsLoading, router, routerState.isLoading])\n\n useLayoutEffect(() => {\n // The router was pending and now it's not\n if (previousIsAnyPending && !isAnyPending) {\n const toLocation = router.state.location\n const fromLocation = router.state.resolvedLocation\n const pathChanged = fromLocation.href !== toLocation.href\n\n router.emit({\n type: 'onResolved',\n fromLocation,\n toLocation,\n pathChanged,\n })\n\n router.__store.setState((s) => ({\n ...s,\n status: 'idle',\n resolvedLocation: s.location,\n }))\n\n if ((document as any).querySelector) {\n if (router.state.location.hash !== '') {\n const el = document.getElementById(router.state.location.hash)\n if (el) {\n el.scrollIntoView()\n }\n }\n }\n }\n }, [isAnyPending, previousIsAnyPending, router])\n\n return null\n}\n"],"names":["useRouter","React","useRouterState","pick","usePrevious","trimPathRight","useLayoutEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAMO,SAAS,eAAe;AAC7B,QAAM,SAASA,UAAAA;AACf,QAAM,qBAAqBC,iBAAM,OAAO,EAAE,QAAQ,SAAS,OAAO;AAClE,QAAM,cAAcC,eAAAA,eAAe;AAAA,IACjC,QAAQ,CAAC,MACPC,MAAAA,KAAK,GAAG,CAAC,aAAa,YAAY,oBAAoB,iBAAiB,CAAC;AAAA,EAAA,CAC3E;AAED,QAAM,CAAC,iBAAiB,qBAAqB,I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,MAAM;AAC5B,YAAA,cAAc,aAAa,SAAS,WAAW;AAErD,aAAO,KAAK;AAAA,QACV,MAAM;AAAA;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,MAAA,CACD;AAAA,IACH;AAAA,KACC,CAAC,mBAAmB,QAAQ,YAAY,SAAS,CAAC;AAErDA,QAAAA,gBAAgB,MAAM;AAEhB,QAAA,wBAAwB,CAAC,cAAc;AACnC,YAAA,aAAa,OAAO,MAAM;AAC1B,YAAA,eAAe,OAAO,MAAM;AAC5B,YAAA,cAAc,aAAa,SAAS,WAAW;AAErD,aAAO,KAAK;AAAA,QACV,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,MAAA,CACD;AAEM,aAAA,QAAQ,SAAS,CAAC,OAAO;AAAA,QAC9B,GAAG;AAAA,QACH,QAAQ;AAAA,QACR,kBAAkB,EAAE;AAAA,MACpB,EAAA;AAEF,UAAK,SAAiB,eAAe;AACnC,YAAI,OAAO,MAAM,SAAS,SAAS,IAAI;AACrC,gBAAM,KAAK,SAAS,eAAe,OAAO,MAAM,SAAS,IAAI;AAC7D,cAAI,IAAI;AACN,eAAG,eAAe;AAAA,UACpB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACC,GAAA,CAAC,cAAc,sBAAsB,MAAM,CAAC;AAExC,SAAA;AACT;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"fileRoute.cjs","sources":["../../src/fileRoute.ts"],"sourcesContent":["import warning from 'tiny-warning'\nimport { createRoute } from './route'\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { useSearch } from './useSearch'\nimport { useParams } from './useParams'\nimport { useNavigate } from './useNavigate'\nimport type { ParsePathParams } from './link'\nimport type {\n AnyContext,\n AnyPathParams,\n AnyRoute,\n AnySearchSchema,\n FileBaseRouteOptions,\n InferAllContext,\n ResolveAllContext,\n ResolveAllParamsFromParent,\n ResolveFullSearchSchema,\n ResolveFullSearchSchemaInput,\n ResolveLoaderData,\n ResolveRouteContext,\n ResolveSearchSchemaUsed,\n Route,\n RouteConstraints,\n RouteContext,\n RouteLoaderFn,\n SearchSchemaInput,\n TrimPathLeft,\n UpdatableRouteOptions,\n} from './route'\nimport type { Assign, IsAny } from './utils'\nimport type { MakeRouteMatch } from './Matches'\nimport type { NoInfer } from '@tanstack/react-store'\nimport type { RegisteredRouter } from './router'\nimport type { RouteById, RouteIds } from './routeInfo'\nimport type { RootRouteId } from './root'\n\nexport interface FileRoutesByPath {\n // '/': {\n // parentRoute: typeof rootRoute\n // }\n}\n\nexport function createFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends\n RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],\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'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends\n RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],\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 = Record<string, unknown>,\n TSearchSchema = {},\n TSearchSchemaUsed = ResolveSearchSchemaUsed<\n TSearchSchemaInput,\n TSearchSchema\n >,\n TFullSearchSchemaInput = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,\n TParams = Record<ParsePathParams<TPath>, string>,\n TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>,\n TRouteContextReturn = RouteContext,\n TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n TAllContext = ResolveAllContext<TParentRoute, TRouteContext>,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n TChildren = unknown,\n >(\n options?: FileBaseRouteOptions<\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn\n > &\n UpdatableRouteOptions<\n TId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps\n >,\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 TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TChildren\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>(\n loaderFn: RouteLoaderFn<\n TRoute['types']['allParams'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['allContext'],\n TLoaderData\n >,\n) => RouteLoaderFn<\n TRoute['types']['allParams'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['allContext'],\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<\n string,\n AnyPathParams,\n AnySearchSchema,\n {},\n AnyContext,\n AnyContext,\n {}\n >,\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 TRouteMatch = MakeRouteMatch<\n RegisteredRouter['routeTree'],\n TRoute['types']['id']\n >,\n TSelected = TRouteMatch,\n >(opts?: {\n select?: (match: TRouteMatch) => 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 useNavigate = () => {\n return useNavigate({ from: this.options.id })\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","useNavigate"],"mappings":";;;;;;;;;;AA4CO,SAAS,gBAOd,MAAiB;AACV,SAAA,IAAI,UAA0D,MAAM;AAAA,IACzE,QAAQ;AAAA,EACT,CAAA,EAAE;AACL;AAMO,MAAM,UAOX;AAAA,EAGA,YACS,MACP,OACA;AAFO,SAAA,OAAA;AAMT,SAAA,cAAc,CAsBZ,YA0CG;AACH;AAAA,QACE,KAAK;AAAA,QACL;AAAA,MAAA;AAEI,YAAAA,UAAQC,kBAAY,OAAc;AACtCD,cAAc,SAAS;AAClB,aAAAA;AAAAA,IAAA;AA1EP,SAAK,SAAS,+BAAO;AAAA,EACvB;AA2EF;AAOO,SAAS,gBAId,OAaA;AACA;AAAA,IACE;AAAA,IACA;AAAA,EAAA;AAEF,SAAO,CA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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;;;;;;;"}
1
+ {"version":3,"file":"fileRoute.cjs","sources":["../../src/fileRoute.ts"],"sourcesContent":["import warning from 'tiny-warning'\nimport { createRoute } from './route'\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { useSearch } from './useSearch'\nimport { useParams } from './useParams'\nimport { useNavigate } from './useNavigate'\nimport type { NoInfer } from '@tanstack/react-store'\nimport type { ParsePathParams } from './link'\nimport type {\n AnyContext,\n AnyPathParams,\n AnyRoute,\n AnySearchSchema,\n FileBaseRouteOptions,\n InferAllContext,\n ResolveAllContext,\n ResolveAllParamsFromParent,\n ResolveFullSearchSchema,\n ResolveFullSearchSchemaInput,\n ResolveLoaderData,\n ResolveRouteContext,\n ResolveSearchSchemaUsed,\n Route,\n RouteConstraints,\n RouteContext,\n RouteLoaderFn,\n UpdatableRouteOptions,\n} from './route'\nimport type { MakeRouteMatch } from './Matches'\nimport type { RegisteredRouter } from './router'\nimport type { RouteById, RouteIds } from './routeInfo'\n\nexport interface FileRoutesByPath {\n // '/': {\n // parentRoute: typeof rootRoute\n // }\n}\n\nexport function createFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends\n RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],\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'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends\n RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],\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 = Record<string, unknown>,\n TSearchSchema = {},\n TSearchSchemaUsed = ResolveSearchSchemaUsed<\n TSearchSchemaInput,\n TSearchSchema\n >,\n TFullSearchSchemaInput = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,\n TParams = Record<ParsePathParams<TPath>, string>,\n TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>,\n TRouteContextReturn = RouteContext,\n TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n TAllContext = ResolveAllContext<TParentRoute, TRouteContext>,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n TChildren = unknown,\n >(\n options?: FileBaseRouteOptions<\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn\n > &\n UpdatableRouteOptions<\n TId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps\n >,\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 TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TChildren\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>(\n loaderFn: RouteLoaderFn<\n TRoute['types']['allParams'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['allContext'],\n TLoaderData\n >,\n) => RouteLoaderFn<\n TRoute['types']['allParams'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['allContext'],\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<\n string,\n AnyPathParams,\n AnySearchSchema,\n {},\n AnyContext,\n AnyContext,\n {}\n >,\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 TRouteMatch = MakeRouteMatch<\n RegisteredRouter['routeTree'],\n TRoute['types']['id']\n >,\n TSelected = TRouteMatch,\n >(opts?: {\n select?: (match: TRouteMatch) => 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 useNavigate = () => {\n return useNavigate({ from: this.options.id })\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","use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AAK,QAAQ,IAAW;AAAA,IAAA;AAGhE,SAAA,gBAAgB,CAA4CA,UAE3C;AACR,aAAAK,cAAA,cAAc,EAAE,GAAGL,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAAA;AAGhE,SAAA,cAAc,MAAM;AAClB,aAAOM,YAAAA,YAAY,EAAE,MAAM,KAAK,QAAQ,IAAI;AAAA,IAAA;AAlD5C,SAAK,UAAU;AACb,SAAa,WAAW,OAAO,IAAI,YAAY;AAAA,EACnD;AAkDF;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;;;;;;;"}
@@ -1,14 +1,13 @@
1
+ import { NoInfer } from '@tanstack/react-store';
1
2
  import { ParsePathParams } from './link.cjs';
2
3
  import { AnyContext, AnyPathParams, AnyRoute, AnySearchSchema, FileBaseRouteOptions, InferAllContext, ResolveAllContext, ResolveAllParamsFromParent, ResolveFullSearchSchema, ResolveFullSearchSchemaInput, ResolveLoaderData, ResolveRouteContext, ResolveSearchSchemaUsed, Route, RouteConstraints, RouteContext, RouteLoaderFn, UpdatableRouteOptions } from './route.cjs';
3
- import { Assign } from './utils.cjs';
4
4
  import { MakeRouteMatch } from './Matches.cjs';
5
- import { NoInfer } from '@tanstack/react-store';
6
5
  import { RegisteredRouter } from './router.cjs';
7
6
  import { RouteById, RouteIds } from './routeInfo.cjs';
8
7
 
9
8
  export interface FileRoutesByPath {
10
9
  }
11
- export declare function createFileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'], TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'], TFullPath extends RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath']>(path: TFilePath): <TSearchSchemaInput = Record<string, unknown>, TSearchSchema = {}, TSearchSchemaUsed = ResolveSearchSchemaUsed<TSearchSchemaInput, TSearchSchema>, TFullSearchSchemaInput = Assign<import('./route').InferFullSearchSchemaInput<TParentRoute>, TSearchSchemaUsed>, TFullSearchSchema = Assign<import('./route').InferFullSearchSchema<TParentRoute>, TSearchSchema>, TParams = Record<ParsePathParams<TPath, never>, string>, TAllParams = Assign<import('./route').InferAllParams<TParentRoute>, TParams>, TRouteContextReturn = RouteContext, TRouteContext = ResolveRouteContext<TRouteContextReturn>, TAllContext = Assign<InferAllContext<TParentRoute>, TRouteContext>, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = {}, TLoaderData = ResolveLoaderData<TLoaderDataReturn>, TChildren = unknown>(options?: ({
10
+ export declare function createFileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'], TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'], TFullPath extends RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath']>(path: TFilePath): <TSearchSchemaInput = Record<string, unknown>, TSearchSchema = {}, TSearchSchemaUsed = ResolveSearchSchemaUsed<TSearchSchemaInput, TSearchSchema>, TFullSearchSchemaInput = import('./utils').Assign<import('./route').InferFullSearchSchemaInput<TParentRoute>, TSearchSchemaUsed>, TFullSearchSchema = import('./utils').Assign<import('./route').InferFullSearchSchema<TParentRoute>, TSearchSchema>, TParams = Record<ParsePathParams<TPath, never>, string>, TAllParams = import('./utils').Assign<import('./route').InferAllParams<TParentRoute>, TParams>, TRouteContextReturn = RouteContext, TRouteContext = ResolveRouteContext<TRouteContextReturn>, TAllContext = import('./utils').Assign<InferAllContext<TParentRoute>, TRouteContext>, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = {}, TLoaderData = ResolveLoaderData<TLoaderDataReturn>, TChildren = unknown>(options?: ({
12
11
  validateSearch?: ((input: TSearchSchemaInput) => TSearchSchema) | {
13
12
  parse: (input: TSearchSchemaInput) => TSearchSchema;
14
13
  } | undefined;
@@ -1,34 +1,49 @@
1
- export { createHistory, createBrowserHistory, createHashHistory, createMemoryHistory, type BlockerFn, type HistoryLocation, type RouterHistory, type ParsedPath, type HistoryState, } from '@tanstack/history';
1
+ export { createHistory, createBrowserHistory, createHashHistory, createMemoryHistory, } from '@tanstack/history';
2
+ export type { BlockerFn, HistoryLocation, RouterHistory, ParsedPath, HistoryState, } from '@tanstack/history';
2
3
  export { default as invariant } from 'tiny-invariant';
3
4
  export { default as warning } from 'tiny-warning';
4
- export { useAwaited, Await, type AwaitOptions } from './awaited.cjs';
5
+ export { useAwaited, Await } from './awaited.cjs';
6
+ export type { AwaitOptions } from './awaited.cjs';
5
7
  export { ScriptOnce } from './ScriptOnce.cjs';
6
- export { defer, type DeferredPromiseState, type DeferredPromise } from './defer.cjs';
8
+ export { defer } from './defer.cjs';
9
+ export type { DeferredPromiseState, DeferredPromise } from './defer.cjs';
7
10
  export { CatchBoundary, ErrorComponent } from './CatchBoundary.cjs';
8
- export { FileRoute, createFileRoute, FileRouteLoader, LazyRoute, createLazyRoute, createLazyFileRoute, type FileRoutesByPath, type LazyRouteOptions, } from './fileRoute.cjs';
11
+ export { FileRoute, createFileRoute, FileRouteLoader, LazyRoute, createLazyRoute, createLazyFileRoute, } from './fileRoute.cjs';
12
+ export type { FileRoutesByPath, LazyRouteOptions } from './fileRoute.cjs';
9
13
  export * from './history.cjs';
10
14
  export { lazyRouteComponent } from './lazyRouteComponent.cjs';
11
- export { useLinkProps, createLink, Link, type CleanPath, type Split, type ParsePathParams, type Join, type Last, type RemoveTrailingSlashes, type RemoveLeadingSlashes, type SearchPaths, type SearchRelativePathAutoComplete, type RelativeToParentPathAutoComplete, type RelativeToCurrentPathAutoComplete, type AbsolutePathAutoComplete, type RelativeToPathAutoComplete, type NavigateOptions, type ToOptions, type ToMaskOptions, type ToSubOptions, type ResolveRoute, type SearchParamOptions, type PathParamOptions, type ToPathOption, type ActiveOptions, type LinkOptions, type CheckPath, type ResolveRelativePath, type UseLinkPropsOptions, type ActiveLinkOptions, type LinkProps, type LinkComponent, } from './link.cjs';
12
- export { type ParsedLocation } from './location.cjs';
13
- export { Matches, useMatchRoute, MatchRoute, useMatches, useParentMatches, useChildMatches, type RouteMatch, type AnyRouteMatch, type MatchRouteOptions, type UseMatchRouteOptions, type MakeMatchRouteOptions, } from './Matches.cjs';
15
+ export { useLinkProps, createLink, Link } from './link.cjs';
16
+ export type { CleanPath, Split, ParsePathParams, Join, Last, RemoveTrailingSlashes, RemoveLeadingSlashes, SearchPaths, SearchRelativePathAutoComplete, RelativeToParentPathAutoComplete, RelativeToCurrentPathAutoComplete, AbsolutePathAutoComplete, RelativeToPathAutoComplete, NavigateOptions, ToOptions, ToMaskOptions, ToSubOptions, ResolveRoute, SearchParamOptions, PathParamOptions, ToPathOption, ActiveOptions, LinkOptions, CheckPath, ResolveRelativePath, UseLinkPropsOptions, ActiveLinkOptions, LinkProps, LinkComponent, } from './link.cjs';
17
+ export type { ParsedLocation } from './location.cjs';
18
+ export { Matches, useMatchRoute, MatchRoute, useMatches, useParentMatches, useChildMatches, } from './Matches.cjs';
19
+ export type { RouteMatch, AnyRouteMatch, MatchRouteOptions, UseMatchRouteOptions, MakeMatchRouteOptions, } from './Matches.cjs';
14
20
  export { matchContext } from './matchContext.cjs';
15
21
  export { Match, Outlet } from './Match.cjs';
16
22
  export { isServerSideError, defaultDeserializeError } from './isServerSideError.cjs';
17
23
  export { useMatch } from './useMatch.cjs';
18
24
  export { useLoaderDeps } from './useLoaderDeps.cjs';
19
25
  export { useLoaderData } from './useLoaderData.cjs';
20
- export { joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, resolvePath, parsePathname, interpolatePath, matchPathname, removeBasepath, matchByPath, type Segment, } from './path.cjs';
26
+ export { joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, resolvePath, parsePathname, interpolatePath, matchPathname, removeBasepath, matchByPath, } from './path.cjs';
27
+ export type { Segment } from './path.cjs';
21
28
  export { encode, decode } from './qss.cjs';
22
- export { redirect, isRedirect, type AnyRedirect, type Redirect, type ResolvedRedirect, } from './redirects.cjs';
23
- export { rootRouteId, type RootRouteId } from './root.cjs';
24
- export { RouteApi, getRouteApi, Route, createRoute, RootRoute, rootRouteWithContext, createRootRoute, createRootRouteWithContext, createRouteMask, NotFoundRoute, type AnyPathParams, type SearchSchemaInput, type AnySearchSchema, type AnyContext, type RouteContext, type PreloadableObj, type RoutePathOptions, type StaticDataRouteOption, type RoutePathOptionsIntersection, type RouteOptions, type FileBaseRouteOptions, type BaseRouteOptions, type UpdatableRouteOptions, type UpdatableStaticRouteOption, type MetaDescriptor, type RouteLinkEntry, type ParseParamsFn, type SearchSchemaValidator, type SearchSchemaValidatorObj, type SearchSchemaValidatorFn, type RouteLoaderFn, type LoaderFnContext, type SearchFilter, type ResolveId, type InferFullSearchSchema, type InferFullSearchSchemaInput, type ResolveFullSearchSchema, type ResolveFullSearchSchemaInput, type AnyRoute, type RouteConstraints, type AnyRootRoute, type ResolveFullPath, type RouteMask, type ErrorRouteProps, type ErrorComponentProps, type NotFoundRouteProps, type ReactNode, type SyncRouteComponent, type AsyncRouteComponent, type RouteComponent, type ErrorRouteComponent, type NotFoundRouteComponent, type TrimPath, type TrimPathLeft, type TrimPathRight, type RootRouteOptions, type AnyRouteWithContext, } from './route.cjs';
25
- export { type ParseRoute, type RoutesById, type RouteById, type RouteIds, type RoutesByPath, type RouteByPath, type RoutePaths, type FullSearchSchema, type AllParams, } from './routeInfo.cjs';
26
- export { componentTypes, createRouter, Router, lazyFn, SearchParamError, PathParamError, getInitialRouterState, defaultSerializeError, type Register, type AnyRouter, type RegisteredRouter, type HydrationCtx, type RouterContextOptions, type TrailingSlashOption, type RouterOptions, type RouterTransformer, type RouterErrorSerializer, type RouterState, type ListenerFn, type BuildNextOptions, type DehydratedRouterState, type DehydratedRouteMatch, type DehydratedRouter, type RouterConstructorOptions, type RouterEvents, type RouterEvent, type RouterListener, type AnyRouterWithContext, } from './router.cjs';
27
- export { RouterProvider, RouterContextProvider, type RouterProps, type CommitLocationOptions, type MatchLocation, type NavigateFn, type BuildLocationFn, type InjectedHtmlEntry, } from './RouterProvider.cjs';
28
- export { useScrollRestoration, useElementScrollRestoration, ScrollRestoration, type ScrollRestorationOptions, } from './scroll-restoration.cjs';
29
- export { defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifySearchWith, type SearchSerializer, type SearchParser, } from './searchParams.cjs';
29
+ export { redirect, isRedirect } from './redirects.cjs';
30
+ export type { AnyRedirect, Redirect, ResolvedRedirect } from './redirects.cjs';
31
+ export { rootRouteId } from './root.cjs';
32
+ export type { RootRouteId } from './root.cjs';
33
+ export { RouteApi, getRouteApi, Route, createRoute, RootRoute, rootRouteWithContext, createRootRoute, createRootRouteWithContext, createRouteMask, NotFoundRoute, } from './route.cjs';
34
+ export type { AnyPathParams, SearchSchemaInput, AnySearchSchema, AnyContext, RouteContext, PreloadableObj, RoutePathOptions, StaticDataRouteOption, RoutePathOptionsIntersection, RouteOptions, FileBaseRouteOptions, BaseRouteOptions, UpdatableRouteOptions, UpdatableStaticRouteOption, MetaDescriptor, RouteLinkEntry, ParseParamsFn, SearchSchemaValidator, SearchSchemaValidatorObj, SearchSchemaValidatorFn, RouteLoaderFn, LoaderFnContext, SearchFilter, ResolveId, InferFullSearchSchema, InferFullSearchSchemaInput, ResolveFullSearchSchema, ResolveFullSearchSchemaInput, AnyRoute, RouteConstraints, AnyRootRoute, ResolveFullPath, RouteMask, ErrorRouteProps, ErrorComponentProps, NotFoundRouteProps, ReactNode, SyncRouteComponent, AsyncRouteComponent, RouteComponent, ErrorRouteComponent, NotFoundRouteComponent, TrimPath, TrimPathLeft, TrimPathRight, RootRouteOptions, AnyRouteWithContext, } from './route.cjs';
35
+ export type { ParseRoute, RoutesById, RouteById, RouteIds, RoutesByPath, RouteByPath, RoutePaths, FullSearchSchema, AllParams, } from './routeInfo.cjs';
36
+ export { componentTypes, createRouter, Router, lazyFn, SearchParamError, PathParamError, getInitialRouterState, defaultSerializeError, } from './router.cjs';
37
+ export type { Register, AnyRouter, RegisteredRouter, HydrationCtx, RouterContextOptions, TrailingSlashOption, RouterOptions, RouterTransformer, RouterErrorSerializer, RouterState, ListenerFn, BuildNextOptions, DehydratedRouterState, DehydratedRouteMatch, DehydratedRouter, RouterConstructorOptions, RouterEvents, RouterEvent, RouterListener, AnyRouterWithContext, } from './router.cjs';
38
+ export { RouterProvider, RouterContextProvider } from './RouterProvider.cjs';
39
+ export type { RouterProps, CommitLocationOptions, MatchLocation, NavigateFn, BuildLocationFn, InjectedHtmlEntry, } from './RouterProvider.cjs';
40
+ export { useScrollRestoration, useElementScrollRestoration, ScrollRestoration, } from './scroll-restoration.cjs';
41
+ export type { ScrollRestorationOptions } from './scroll-restoration.cjs';
42
+ export { defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifySearchWith, } from './searchParams.cjs';
43
+ export type { SearchSerializer, SearchParser } from './searchParams.cjs';
30
44
  export { useBlocker, Block } from './useBlocker.cjs';
31
- export { useNavigate, Navigate, type UseNavigateResult } from './useNavigate.cjs';
45
+ export { useNavigate, Navigate } from './useNavigate.cjs';
46
+ export type { UseNavigateResult } from './useNavigate.cjs';
32
47
  export { useParams } from './useParams.cjs';
33
48
  export { useSearch } from './useSearch.cjs';
34
49
  export { getRouterContext, } from './routerContext.cjs';
@@ -39,6 +54,8 @@ export { useLocation } from './useLocation.cjs';
39
54
  export { escapeJSON, // SSR
40
55
  useLayoutEffect, // SSR
41
56
  pick, functionalUpdate, replaceEqualDeep, isPlainObject, isPlainArray, deepEqual, useStableCallback, shallow, } from './utils';
42
- export { notFound, isNotFound, CatchNotFound, DefaultGlobalNotFound, type NotFoundError, } from './not-found.cjs';
43
- export { type Manifest, type RouterManagedTag } from './manifest.cjs';
44
- export { createControlledPromise, type ControlledPromise } from './utils.cjs';
57
+ export { notFound, isNotFound, CatchNotFound, DefaultGlobalNotFound, } from './not-found.cjs';
58
+ export type { NotFoundError } from './not-found.cjs';
59
+ export type { Manifest, RouterManagedTag } from './manifest.cjs';
60
+ export { createControlledPromise } from './utils.cjs';
61
+ export type { ControlledPromise } from './utils.cjs';
@@ -1 +1 @@
1
- {"version":3,"file":"not-found.cjs","sources":["../../src/not-found.tsx"],"sourcesContent":["// eslint-disable-next-line ts/consistent-type-imports\nimport * as React from 'react'\nimport { CatchBoundary } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport type { RegisteredRouter } from './router'\nimport type { RouteIds } from './routeInfo'\nimport type { ErrorInfo } from 'react'\n\nexport type NotFoundError = {\n /**\n @deprecated\n Use `routeId: rootRouteId` instead\n */\n global?: boolean\n /**\n @private\n Do not use this. It's used internally to indicate a path matching error\n */\n _global?: boolean\n data?: any\n throw?: boolean\n routeId?: RouteIds<RegisteredRouter['routeTree']>\n headers?: HeadersInit\n}\n\nexport function notFound(options: NotFoundError = {}) {\n ;(options as any).isNotFound = true\n if (options.throw) throw options\n return options\n}\n\nexport function isNotFound(obj: any): obj is NotFoundError {\n return !!obj?.isNotFound\n}\n\nexport function CatchNotFound(props: {\n fallback?: (error: NotFoundError) => React.ReactElement\n onCatch?: (error: Error, errorInfo: ErrorInfo) => void\n children: React.ReactNode\n}) {\n // TODO: Some way for the user to programmatically reset the not-found boundary?\n const resetKey = useRouterState({\n select: (s) => `not-found-${s.location.pathname}-${s.status}`,\n })\n\n return (\n <CatchBoundary\n getResetKey={() => resetKey}\n onCatch={(error, errorInfo) => {\n if (isNotFound(error)) {\n props.onCatch?.(error, errorInfo)\n } else {\n throw error\n }\n }}\n errorComponent={({ error }: { error: NotFoundError }) =>\n props.fallback?.(error)\n }\n >\n {props.children}\n </CatchBoundary>\n )\n}\n\nexport function DefaultGlobalNotFound() {\n return <p>Not Found</p>\n}\n"],"names":["useRouterState","jsx","CatchBoundary"],"mappings":";;;;;AAyBgB,SAAA,SAAS,UAAyB,IAAI;AAClD,UAAgB,aAAa;AAC3B,MAAA,QAAQ,MAAa,OAAA;AAClB,SAAA;AACT;AAEO,SAAS,WAAW,KAAgC;AAClD,SAAA,CAAC,EAAC,2BAAK;AAChB;AAEO,SAAS,cAAc,OAI3B;AAED,QAAM,WAAWA,eAAAA,eAAe;AAAA,IAC9B,QAAQ,CAAC,MAAM,aAAa,EAAE,SAAS,QAAQ,IAAI,EAAE,MAAM;AAAA,EAAA,CAC5D;AAGC,SAAAC,2BAAA;AAAA,IAACC,cAAA;AAAA,IAAA;AAAA,MACC,aAAa,MAAM;AAAA,MACnB,SAAS,CAAC,OAAO,cAAc;;AACzB,YAAA,WAAW,KAAK,GAAG;AACf,sBAAA,YAAA,+BAAU,OAAO;AAAA,QAAS,OAC3B;AACC,gBAAA;AAAA,QACR;AAAA,MACF;AAAA,MACA,gBAAgB,CAAC,EAAE,YACjB;;AAAA,2BAAM,aAAN,+BAAiB;AAAA;AAAA,MAGlB,UAAM,MAAA;AAAA,IAAA;AAAA,EAAA;AAGb;AAEO,SAAS,wBAAwB;AAC/B,SAAAD,2BAAA,IAAC,OAAE,UAAS,YAAA,CAAA;AACrB;;;;;"}
1
+ {"version":3,"file":"not-found.cjs","sources":["../../src/not-found.tsx"],"sourcesContent":["import * as React from 'react'\nimport { CatchBoundary } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport type { ErrorInfo } from 'react'\nimport type { RegisteredRouter } from './router'\nimport type { RouteIds } from './routeInfo'\n\nexport type NotFoundError = {\n /**\n @deprecated\n Use `routeId: rootRouteId` instead\n */\n global?: boolean\n /**\n @private\n Do not use this. It's used internally to indicate a path matching error\n */\n _global?: boolean\n data?: any\n throw?: boolean\n routeId?: RouteIds<RegisteredRouter['routeTree']>\n headers?: HeadersInit\n}\n\nexport function notFound(options: NotFoundError = {}) {\n ;(options as any).isNotFound = true\n if (options.throw) throw options\n return options\n}\n\nexport function isNotFound(obj: any): obj is NotFoundError {\n return !!obj?.isNotFound\n}\n\nexport function CatchNotFound(props: {\n fallback?: (error: NotFoundError) => React.ReactElement\n onCatch?: (error: Error, errorInfo: ErrorInfo) => void\n children: React.ReactNode\n}) {\n // TODO: Some way for the user to programmatically reset the not-found boundary?\n const resetKey = useRouterState({\n select: (s) => `not-found-${s.location.pathname}-${s.status}`,\n })\n\n return (\n <CatchBoundary\n getResetKey={() => resetKey}\n onCatch={(error, errorInfo) => {\n if (isNotFound(error)) {\n props.onCatch?.(error, errorInfo)\n } else {\n throw error\n }\n }}\n errorComponent={({ error }: { error: NotFoundError }) =>\n props.fallback?.(error)\n }\n >\n {props.children}\n </CatchBoundary>\n )\n}\n\nexport function DefaultGlobalNotFound() {\n return <p>Not Found</p>\n}\n"],"names":["useRouterState","jsx","CatchBoundary"],"mappings":";;;;;AAwBgB,SAAA,SAAS,UAAyB,IAAI;AAClD,UAAgB,aAAa;AAC3B,MAAA,QAAQ,MAAa,OAAA;AAClB,SAAA;AACT;AAEO,SAAS,WAAW,KAAgC;AAClD,SAAA,CAAC,EAAC,2BAAK;AAChB;AAEO,SAAS,cAAc,OAI3B;AAED,QAAM,WAAWA,eAAAA,eAAe;AAAA,IAC9B,QAAQ,CAAC,MAAM,aAAa,EAAE,SAAS,QAAQ,IAAI,EAAE,MAAM;AAAA,EAAA,CAC5D;AAGC,SAAAC,2BAAA;AAAA,IAACC,cAAA;AAAA,IAAA;AAAA,MACC,aAAa,MAAM;AAAA,MACnB,SAAS,CAAC,OAAO,cAAc;;AACzB,YAAA,WAAW,KAAK,GAAG;AACf,sBAAA,YAAA,+BAAU,OAAO;AAAA,QAAS,OAC3B;AACC,gBAAA;AAAA,QACR;AAAA,MACF;AAAA,MACA,gBAAgB,CAAC,EAAE,YACjB;;AAAA,2BAAM,aAAN,+BAAiB;AAAA;AAAA,MAGlB,UAAM,MAAA;AAAA,IAAA;AAAA,EAAA;AAGb;AAEO,SAAS,wBAAwB;AAC/B,SAAAD,2BAAA,IAAC,OAAE,UAAS,YAAA,CAAA;AACrB;;;;;"}
@@ -1,6 +1,6 @@
1
+ import { ErrorInfo } from 'react';
1
2
  import { RegisteredRouter } from './router.cjs';
2
3
  import { RouteIds } from './routeInfo.cjs';
3
- import { ErrorInfo } from 'react';
4
4
  import * as React from 'react';
5
5
  export type NotFoundError = {
6
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"renderRouteNotFound.cjs","sources":["../../src/renderRouteNotFound.tsx"],"sourcesContent":["import * as React from 'react'\nimport warning from 'tiny-warning'\nimport { DefaultGlobalNotFound } from './not-found'\nimport { type AnyRouter } from './router'\nimport { type AnyRoute } from './route'\n\nexport function renderRouteNotFound(\n router: AnyRouter,\n route: AnyRoute,\n data: any,\n) {\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"],"names":["jsx","DefaultGlobalNotFound"],"mappings":";;;;;AAMgB,SAAA,oBACd,QACA,OACA,MACA;AACI,MAAA,CAAC,MAAM,QAAQ,mBAAmB;AAChC,QAAA,OAAO,QAAQ,0BAA0B;AAC3C,aAAQA,2BAAAA,IAAA,OAAO,QAAQ,0BAAf,EAAwC,KAAY,CAAA;AAAA,IAC9D;AAEI,QAAA,QAAQ,IAAI,aAAa,eAAe;AAC1C;AAAA,QACE,MAAM,QAAQ;AAAA,QACd,yDAAyD,MAAM,EAAE;AAAA,MAAA;AAAA,IAErE;AAEA,0CAAQC,gCAAsB,CAAA,CAAA;AAAA,EAChC;AAEA,SAAQD,2BAAAA,IAAA,MAAM,QAAQ,mBAAd,EAAgC,KAAY,CAAA;AACtD;;"}
1
+ {"version":3,"file":"renderRouteNotFound.cjs","sources":["../../src/renderRouteNotFound.tsx"],"sourcesContent":["import * as React from 'react'\nimport warning from 'tiny-warning'\nimport { DefaultGlobalNotFound } from './not-found'\nimport type { AnyRouter } from './router'\nimport type { AnyRoute } from './route'\n\nexport function renderRouteNotFound(\n router: AnyRouter,\n route: AnyRoute,\n data: any,\n) {\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"],"names":["jsx","DefaultGlobalNotFound"],"mappings":";;;;;AAMgB,SAAA,oBACd,QACA,OACA,MACA;AACI,MAAA,CAAC,MAAM,QAAQ,mBAAmB;AAChC,QAAA,OAAO,QAAQ,0BAA0B;AAC3C,aAAQA,2BAAAA,IAAA,OAAO,QAAQ,0BAAf,EAAwC,KAAY,CAAA;AAAA,IAC9D;AAEI,QAAA,QAAQ,IAAI,aAAa,eAAe;AAC1C;AAAA,QACE,MAAM,QAAQ;AAAA,QACd,yDAAyD,MAAM,EAAE;AAAA,MAAA;AAAA,IAErE;AAEA,0CAAQC,gCAAsB,CAAA,CAAA;AAAA,EAChC;AAEA,SAAQD,2BAAAA,IAAA,MAAM,QAAQ,mBAAd,EAAgC,KAAY,CAAA;AACtD;;"}