@tanstack/react-router 1.12.15 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/cjs/Matches.d.cts +5 -5
  2. package/dist/cjs/RouterProvider.d.cts +6 -6
  3. package/dist/cjs/awaited.d.cts +1 -1
  4. package/dist/cjs/defer.d.cts +1 -1
  5. package/dist/cjs/fileRoute.d.cts +3 -3
  6. package/dist/cjs/index.d.cts +27 -27
  7. package/dist/cjs/lazyRouteComponent.d.cts +1 -1
  8. package/dist/cjs/link.d.cts +6 -6
  9. package/dist/cjs/location.d.cts +1 -1
  10. package/dist/cjs/path.d.cts +2 -2
  11. package/dist/cjs/redirects.d.cts +4 -4
  12. package/dist/cjs/route.d.cts +7 -7
  13. package/dist/cjs/routeInfo.d.cts +2 -2
  14. package/dist/cjs/router.cjs +12 -9
  15. package/dist/cjs/router.cjs.map +1 -1
  16. package/dist/cjs/router.d.cts +21 -12
  17. package/dist/cjs/routerContext.d.cts +1 -1
  18. package/dist/cjs/scroll-restoration.d.cts +1 -1
  19. package/dist/cjs/searchParams.d.cts +1 -1
  20. package/dist/cjs/useBlocker.d.cts +1 -1
  21. package/dist/cjs/useNavigate.d.cts +5 -5
  22. package/dist/cjs/useParams.d.cts +5 -5
  23. package/dist/cjs/useRouteContext.d.cts +4 -4
  24. package/dist/cjs/useRouter.d.cts +2 -2
  25. package/dist/cjs/useRouterState.d.cts +2 -2
  26. package/dist/cjs/useSearch.d.cts +4 -4
  27. package/dist/esm/Matches.d.ts +5 -5
  28. package/dist/esm/RouterProvider.d.ts +6 -6
  29. package/dist/esm/awaited.d.ts +1 -1
  30. package/dist/esm/defer.d.ts +1 -1
  31. package/dist/esm/fileRoute.d.ts +3 -3
  32. package/dist/esm/index.d.ts +27 -27
  33. package/dist/esm/lazyRouteComponent.d.ts +1 -1
  34. package/dist/esm/link.d.ts +6 -6
  35. package/dist/esm/location.d.ts +1 -1
  36. package/dist/esm/path.d.ts +2 -2
  37. package/dist/esm/redirects.d.ts +4 -4
  38. package/dist/esm/route.d.ts +7 -7
  39. package/dist/esm/routeInfo.d.ts +2 -2
  40. package/dist/esm/router.d.ts +21 -12
  41. package/dist/esm/router.js +12 -9
  42. package/dist/esm/router.js.map +1 -1
  43. package/dist/esm/routerContext.d.ts +1 -1
  44. package/dist/esm/scroll-restoration.d.ts +1 -1
  45. package/dist/esm/searchParams.d.ts +1 -1
  46. package/dist/esm/useBlocker.d.ts +1 -1
  47. package/dist/esm/useNavigate.d.ts +5 -5
  48. package/dist/esm/useParams.d.ts +5 -5
  49. package/dist/esm/useRouteContext.d.ts +4 -4
  50. package/dist/esm/useRouter.d.ts +2 -2
  51. package/dist/esm/useRouterState.d.ts +2 -2
  52. package/dist/esm/useSearch.d.ts +4 -4
  53. package/package.json +2 -2
  54. package/src/router.ts +21 -7
@@ -1,9 +1,9 @@
1
1
  import * as React from 'react';
2
- import { ResolveRelativePath, ToOptions } from './link';
3
- import { AnyRoute, ReactNode, RootSearchSchema, StaticDataRouteOption } from './route';
4
- import { AllParams, FullSearchSchema, ParseRoute, RouteById, RouteByPath, RouteIds, RoutePaths } from './routeInfo';
5
- import { RegisteredRouter, RouterState } from './router';
6
- import { DeepOptional, Expand, NoInfer, StrictOrFrom } from './utils';
2
+ import { ResolveRelativePath, ToOptions } from './link.cjs';
3
+ import { AnyRoute, ReactNode, RootSearchSchema, StaticDataRouteOption } from './route.cjs';
4
+ import { AllParams, FullSearchSchema, ParseRoute, RouteById, RouteByPath, RouteIds, RoutePaths } from './routeInfo.cjs';
5
+ import { RegisteredRouter, RouterState } from './router.cjs';
6
+ import { DeepOptional, Expand, NoInfer, StrictOrFrom } from './utils.cjs';
7
7
  export declare const matchContext: React.Context<string | undefined>;
8
8
  export interface RouteMatch<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'], TReturnIntersection extends boolean = false> {
9
9
  id: string;
@@ -1,10 +1,10 @@
1
1
  import * as React from 'react';
2
- import { NavigateOptions, ToOptions } from './link';
3
- import { ParsedLocation } from './location';
4
- import { AnyRoute } from './route';
5
- import { RoutePaths } from './routeInfo';
6
- import { RegisteredRouter, Router, RouterOptions, RouterState } from './router';
7
- import { RouteMatch } from './Matches';
2
+ import { NavigateOptions, ToOptions } from './link.cjs';
3
+ import { ParsedLocation } from './location.cjs';
4
+ import { AnyRoute } from './route.cjs';
5
+ import { RoutePaths } from './routeInfo.cjs';
6
+ import { RegisteredRouter, Router, RouterOptions, RouterState } from './router.cjs';
7
+ import { RouteMatch } from './Matches.cjs';
8
8
  export interface CommitLocationOptions {
9
9
  replace?: boolean;
10
10
  resetScroll?: boolean;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { DeferredPromise } from './defer';
2
+ import { DeferredPromise } from './defer.cjs';
3
3
  export type AwaitOptions<T> = {
4
4
  promise: DeferredPromise<T>;
5
5
  };
@@ -1,4 +1,4 @@
1
- import { defaultSerializeError } from './router';
1
+ import { defaultSerializeError } from './router.cjs';
2
2
  export type DeferredPromiseState<T> = {
3
3
  uid: string;
4
4
  } & ({
@@ -1,8 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import { NoInfer } from '@tanstack/react-store';
3
- import { ParsePathParams } from './link';
4
- import { AnyRoute, ResolveFullPath, ResolveFullSearchSchema, MergeFromFromParent, RouteContext, AnyContext, RouteOptions, UpdatableRouteOptions, Route, RootRouteId, TrimPathLeft, RouteConstraints, ResolveFullSearchSchemaInput, SearchSchemaInput, RouteLoaderFn, AnySearchSchema } from './route';
5
- import { Assign, Expand, IsAny } from './utils';
3
+ import { ParsePathParams } from './link.cjs';
4
+ import { AnyRoute, ResolveFullPath, ResolveFullSearchSchema, MergeFromFromParent, RouteContext, AnyContext, RouteOptions, UpdatableRouteOptions, Route, RootRouteId, TrimPathLeft, RouteConstraints, ResolveFullSearchSchemaInput, SearchSchemaInput, RouteLoaderFn, AnySearchSchema } from './route.cjs';
5
+ import { Assign, Expand, IsAny } from './utils.cjs';
6
6
  import { RegisteredRouter, RouteById, RouteIds } from '.';
7
7
  export interface FileRoutesByPath {
8
8
  }
@@ -1,30 +1,30 @@
1
1
  export * from '@tanstack/history';
2
2
  export { default as invariant } from 'tiny-invariant';
3
3
  export { default as warning } from 'tiny-warning';
4
- export * from './awaited';
5
- export * from './defer';
6
- export * from './CatchBoundary';
7
- export * from './fileRoute';
8
- export * from './history';
9
- export * from './lazyRouteComponent';
10
- export * from './link';
11
- export * from './location';
12
- export * from './Matches';
13
- export * from './path';
14
- export * from './qss';
15
- export * from './redirects';
16
- export * from './route';
17
- export * from './routeInfo';
18
- export * from './router';
19
- export * from './RouterProvider';
20
- export * from './scroll-restoration';
21
- export * from './searchParams';
22
- export * from './useBlocker';
23
- export * from './useNavigate';
24
- export * from './useParams';
25
- export * from './useSearch';
26
- export * from './routerContext';
27
- export * from './useRouteContext';
28
- export * from './useRouter';
29
- export * from './useRouterState';
30
- export * from './utils';
4
+ export * from './awaited.cjs';
5
+ export * from './defer.cjs';
6
+ export * from './CatchBoundary.cjs';
7
+ export * from './fileRoute.cjs';
8
+ export * from './history.cjs';
9
+ export * from './lazyRouteComponent.cjs';
10
+ export * from './link.cjs';
11
+ export * from './location.cjs';
12
+ export * from './Matches.cjs';
13
+ export * from './path.cjs';
14
+ export * from './qss.cjs';
15
+ export * from './redirects.cjs';
16
+ export * from './route.cjs';
17
+ export * from './routeInfo.cjs';
18
+ export * from './router.cjs';
19
+ export * from './RouterProvider.cjs';
20
+ export * from './scroll-restoration.cjs';
21
+ export * from './searchParams.cjs';
22
+ export * from './useBlocker.cjs';
23
+ export * from './useNavigate.cjs';
24
+ export * from './useParams.cjs';
25
+ export * from './useSearch.cjs';
26
+ export * from './routerContext.cjs';
27
+ export * from './useRouteContext.cjs';
28
+ export * from './useRouter.cjs';
29
+ export * from './useRouterState.cjs';
30
+ export * from './utils.cjs';
@@ -1,2 +1,2 @@
1
- import { AsyncRouteComponent } from './route';
1
+ import { AsyncRouteComponent } from './route.cjs';
2
2
  export declare function lazyRouteComponent<T extends Record<string, any>, TKey extends keyof T = 'default'>(importer: () => Promise<T>, exportName?: TKey): T[TKey] extends (props: infer TProps) => any ? AsyncRouteComponent<TProps> : never;
@@ -1,10 +1,10 @@
1
1
  import * as React from 'react';
2
- import { Trim } from './fileRoute';
3
- import { AnyRoute, ReactNode, RootSearchSchema } from './route';
4
- import { RouteByPath, RoutePaths } from './routeInfo';
5
- import { RegisteredRouter } from './router';
6
- import { LinkProps, UseLinkPropsOptions } from './useNavigate';
7
- import { Expand, NoInfer, NonNullableUpdater, PickRequired, StringLiteral, Updater, WithoutEmpty } from './utils';
2
+ import { Trim } from './fileRoute.cjs';
3
+ import { AnyRoute, ReactNode, RootSearchSchema } from './route.cjs';
4
+ import { RouteByPath, RoutePaths } from './routeInfo.cjs';
5
+ import { RegisteredRouter } from './router.cjs';
6
+ import { LinkProps, UseLinkPropsOptions } from './useNavigate.cjs';
7
+ import { Expand, NoInfer, NonNullableUpdater, PickRequired, StringLiteral, Updater, WithoutEmpty } from './utils.cjs';
8
8
  import { HistoryState } from '@tanstack/history';
9
9
  export type CleanPath<T extends string> = T extends `${infer L}//${infer R}` ? CleanPath<`${CleanPath<L>}/${CleanPath<R>}`> : T extends `${infer L}//` ? `${CleanPath<L>}/` : T extends `//${infer L}` ? `/${CleanPath<L>}` : T;
10
10
  export type Split<S, TIncludeTrailingSlash = true> = S extends unknown ? string extends S ? string[] : S extends string ? CleanPath<S> extends '' ? [] : TIncludeTrailingSlash extends true ? CleanPath<S> extends `${infer T}/` ? [...Split<T>, '/'] : CleanPath<S> extends `/${infer U}` ? Split<U> : CleanPath<S> extends `${infer T}/${infer U}` ? [...Split<T>, ...Split<U>] : [S] : CleanPath<S> extends `${infer T}/${infer U}` ? [...Split<T>, ...Split<U>] : S extends string ? [S] : never : never : never;
@@ -1,5 +1,5 @@
1
1
  import { HistoryState } from '@tanstack/history';
2
- import { AnySearchSchema } from './route';
2
+ import { AnySearchSchema } from './route.cjs';
3
3
  export interface ParsedLocation<TSearchObj extends AnySearchSchema = {}> {
4
4
  href: string;
5
5
  pathname: string;
@@ -1,5 +1,5 @@
1
- import { MatchLocation } from './RouterProvider';
2
- import { AnyPathParams } from './route';
1
+ import { MatchLocation } from './RouterProvider.cjs';
2
+ import { AnyPathParams } from './route.cjs';
3
3
  export interface Segment {
4
4
  type: 'pathname' | 'param' | 'wildcard';
5
5
  value: string;
@@ -1,7 +1,7 @@
1
- import { NavigateOptions } from './link';
2
- import { AnyRoute } from './route';
3
- import { RoutePaths } from './routeInfo';
4
- import { RegisteredRouter } from './router';
1
+ import { NavigateOptions } from './link.cjs';
2
+ import { AnyRoute } from './route.cjs';
3
+ import { RoutePaths } from './routeInfo.cjs';
4
+ import { RegisteredRouter } from './router.cjs';
5
5
  export type AnyRedirect = Redirect<any, any, any, any, any>;
6
6
  export type Redirect<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = ''> = {
7
7
  code?: number;
@@ -1,11 +1,11 @@
1
1
  import * as React from 'react';
2
- import { AnyRouteMatch } from './Matches';
3
- import { NavigateOptions, ParsePathParams, ToSubOptions } from './link';
4
- import { ParsedLocation } from './location';
5
- import { RouteById, RouteIds, RoutePaths } from './routeInfo';
6
- import { AnyRouter, RegisteredRouter } from './router';
7
- import { Assign, Expand, IsAny, NoInfer, PickRequired, UnionToIntersection } from './utils';
8
- import { BuildLocationFn, NavigateFn } from './RouterProvider';
2
+ import { AnyRouteMatch } from './Matches.cjs';
3
+ import { NavigateOptions, ParsePathParams, ToSubOptions } from './link.cjs';
4
+ import { ParsedLocation } from './location.cjs';
5
+ import { RouteById, RouteIds, RoutePaths } from './routeInfo.cjs';
6
+ import { AnyRouter, RegisteredRouter } from './router.cjs';
7
+ import { Assign, Expand, IsAny, NoInfer, PickRequired, UnionToIntersection } from './utils.cjs';
8
+ import { BuildLocationFn, NavigateFn } from './RouterProvider.cjs';
9
9
  import { LazyRoute } from '.';
10
10
  export declare const rootRouteId: "__root__";
11
11
  export type RootRouteId = typeof rootRouteId;
@@ -1,5 +1,5 @@
1
- import { AnyRoute, Route } from './route';
2
- import { Expand, UnionToIntersection, UnionToTuple } from './utils';
1
+ import { AnyRoute, Route } from './route.cjs';
2
+ import { Expand, UnionToIntersection, UnionToTuple } from './utils.cjs';
3
3
  export type ParseRoute<TRouteTree extends AnyRoute> = TRouteTree | ParseRouteChildren<TRouteTree>;
4
4
  export type ParseRouteChildren<TRouteTree extends AnyRoute> = TRouteTree extends Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, infer TChildren, any> ? unknown extends TChildren ? never : TChildren extends AnyRoute[] ? {
5
5
  [TId in TChildren[number]['id'] as string]: ParseRoute<TChildren[number]>;
@@ -966,7 +966,7 @@ class Router {
966
966
  const data = typeof getData === "function" ? await getData() : getData;
967
967
  return `<script id='${id}' suppressHydrationWarning>window["__TSR_DEHYDRATED__${utils.escapeJSON(
968
968
  strKey
969
- )}"] = ${JSON.stringify(data)}
969
+ )}"] = ${JSON.stringify(this.options.transformer.stringify(data))}
970
970
  ;(() => {
971
971
  var el = document.getElementById('${id}')
972
972
  el.parentElement.removeChild(el)
@@ -980,7 +980,9 @@ class Router {
980
980
  this.hydrateData = (key) => {
981
981
  if (typeof document !== "undefined") {
982
982
  const strKey = typeof key === "string" ? key : JSON.stringify(key);
983
- return window[`__TSR_DEHYDRATED__${strKey}`];
983
+ return this.options.transformer.parse(
984
+ window[`__TSR_DEHYDRATED__${strKey}`]
985
+ );
984
986
  }
985
987
  return void 0;
986
988
  };
@@ -1002,24 +1004,24 @@ class Router {
1002
1004
  };
1003
1005
  };
1004
1006
  this.hydrate = async (__do_not_use_server_ctx) => {
1005
- var _a, _b;
1007
+ var _a, _b, _c;
1006
1008
  let _ctx = __do_not_use_server_ctx;
1007
1009
  if (typeof document !== "undefined") {
1008
- _ctx = window.__TSR_DEHYDRATED__;
1010
+ _ctx = (_a = window.__TSR_DEHYDRATED__) == null ? void 0 : _a.data;
1009
1011
  }
1010
1012
  invariant(
1011
1013
  _ctx,
1012
1014
  "Expected to find a __TSR_DEHYDRATED__ property on window... but we did not. Did you forget to render <DehydrateRouter /> in your app?"
1013
1015
  );
1014
- const ctx = _ctx;
1016
+ const ctx = this.options.transformer.parse(_ctx);
1015
1017
  this.dehydratedData = ctx.payload;
1016
- (_b = (_a = this.options).hydrate) == null ? void 0 : _b.call(_a, ctx.payload);
1018
+ (_c = (_b = this.options).hydrate) == null ? void 0 : _c.call(_b, ctx.payload);
1017
1019
  const dehydratedState = ctx.router.state;
1018
1020
  let matches = this.matchRoutes(
1019
1021
  this.state.location.pathname,
1020
1022
  this.state.location.search
1021
1023
  ).map((match) => {
1022
- var _a2, _b2, _c, _d, _e, _f;
1024
+ var _a2, _b2, _c2, _d, _e, _f;
1023
1025
  const dehydratedMatch = dehydratedState.dehydratedMatches.find(
1024
1026
  (d) => d.id === match.id
1025
1027
  );
@@ -1035,7 +1037,7 @@ class Router {
1035
1037
  meta: (_b2 = (_a2 = route.options).meta) == null ? void 0 : _b2.call(_a2, {
1036
1038
  loaderData: dehydratedMatch.loaderData
1037
1039
  }),
1038
- links: (_d = (_c = route.options).links) == null ? void 0 : _d.call(_c),
1040
+ links: (_d = (_c2 = route.options).links) == null ? void 0 : _d.call(_c2),
1039
1041
  scripts: (_f = (_e = route.options).scripts) == null ? void 0 : _f.call(_e)
1040
1042
  };
1041
1043
  }
@@ -1056,7 +1058,8 @@ class Router {
1056
1058
  context: void 0,
1057
1059
  ...options,
1058
1060
  stringifySearch: (options == null ? void 0 : options.stringifySearch) ?? searchParams.defaultStringifySearch,
1059
- parseSearch: (options == null ? void 0 : options.parseSearch) ?? searchParams.defaultParseSearch
1061
+ parseSearch: (options == null ? void 0 : options.parseSearch) ?? searchParams.defaultParseSearch,
1062
+ transformer: (options == null ? void 0 : options.transformer) ?? JSON
1060
1063
  });
1061
1064
  }
1062
1065
  get state() {