@tanstack/react-router 1.83.1 → 1.84.2

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.
@@ -44,9 +44,9 @@ export interface SplatParams {
44
44
  _splat?: string;
45
45
  }
46
46
  export type ResolveParams<TPath extends string> = ParseSplatParams<TPath> extends never ? Record<ParsePathParams<TPath>, string> : Record<ParsePathParams<TPath>, string> & SplatParams;
47
- export type ParseParamsFn<TPath extends string, TParams> = (rawParams: ResolveParams<TPath>) => TParams extends Record<ParsePathParams<TPath>, any> ? TParams : Record<ParsePathParams<TPath>, any>;
48
- export type StringifyParamsFn<TPath extends string, TParams> = (params: TParams) => ResolveParams<TPath>;
49
- export type ParamsOptions<TPath extends string, TParams> = {
47
+ export type ParseParamsFn<in out TPath extends string, in out TParams> = (rawParams: ResolveParams<TPath>) => TParams extends Record<ParsePathParams<TPath>, any> ? TParams : Record<ParsePathParams<TPath>, any>;
48
+ export type StringifyParamsFn<in out TPath extends string, in out TParams> = (params: TParams) => ResolveParams<TPath>;
49
+ export type ParamsOptions<in out TPath extends string, in out TParams> = {
50
50
  params?: {
51
51
  parse?: ParseParamsFn<TPath, TParams>;
52
52
  stringify?: StringifyParamsFn<TPath, TParams>;
@@ -335,7 +335,7 @@ export declare class Route<in out TParentRoute extends RouteConstraints['TParent
335
335
  originalIndex: number;
336
336
  defaultSsr?: boolean;
337
337
  }) => void;
338
- addChildren<const TNewChildren extends Record<string, AnyRoute> | ReadonlyArray<AnyRoute>>(children: TNewChildren): Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren>;
338
+ addChildren<const TNewChildren>(children: Constrain<TNewChildren, ReadonlyArray<AnyRoute> | Record<string, AnyRoute>>): Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren>;
339
339
  _addFileChildren<const TNewChildren>(children: TNewChildren): Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren>;
340
340
  updateLoader: <TNewLoaderFn>(options: {
341
341
  loader: Constrain<TNewLoaderFn, RouteLoaderFn<TParentRoute, TCustomId, TParams, TLoaderDeps, TRouterContext, TRouteContextFn, TBeforeLoadFn>>;
@@ -351,7 +351,7 @@ export declare class Route<in out TParentRoute extends RouteConstraints['TParent
351
351
  useNavigate: () => UseNavigateResult<TFullPath>;
352
352
  }
353
353
  export declare function createRoute<TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, TPath extends RouteConstraints['TPath'] = '/', TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, TCustomId extends RouteConstraints['TCustomId'] = string, TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, TSearchValidator = undefined, TParams = ResolveParams<TPath>, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TChildren = unknown>(options: RouteOptions<TParentRoute, TId, TCustomId, TFullPath, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, AnyContext, TRouteContextFn, TBeforeLoadFn>): Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, AnyContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren>;
354
- export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any>;
354
+ export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>;
355
355
  export type RootRouteOptions<TSearchValidator = undefined, TRouterContext = {}, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined> = Omit<RouteOptions<any, // TParentRoute
356
356
  RootRouteId, // TId
357
357
  RootRouteId, // TCustomId
@@ -376,7 +376,7 @@ TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildre
376
376
  * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
377
377
  */
378
378
  constructor(options?: RootRouteOptions<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn>);
379
- addChildren<const TNewChildren extends Record<string, AnyRoute> | ReadonlyArray<AnyRoute>>(children: TNewChildren): RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren, TFileRouteTypes>;
379
+ addChildren<const TNewChildren>(children: Constrain<TNewChildren, ReadonlyArray<AnyRoute> | Record<string, AnyRoute>>): RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren, TFileRouteTypes>;
380
380
  _addFileChildren<const TNewChildren>(children: TNewChildren): RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren, TFileRouteTypes>;
381
381
  _addFileTypes<TFileRouteTypes>(): RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes>;
382
382
  }
@@ -57,6 +57,7 @@ class Router {
57
57
  )}`;
58
58
  this.resetNextScroll = true;
59
59
  this.shouldViewTransition = void 0;
60
+ this.isViewTransitionTypesSupported = void 0;
60
61
  this.subscribers = /* @__PURE__ */ new Set();
61
62
  this.startReactTransition = (fn) => fn();
62
63
  this.update = (newOptions) => {
@@ -109,6 +110,11 @@ class Router {
109
110
  }
110
111
  });
111
112
  }
113
+ if (typeof window !== "undefined" && "CSS" in window && typeof window.CSS.supports === "function") {
114
+ this.isViewTransitionTypesSupported = window.CSS.supports(
115
+ "selector(:active-view-transition-type(a)"
116
+ );
117
+ }
112
118
  };
113
119
  this.buildRouteTree = () => {
114
120
  this.routesById = {};
@@ -733,7 +739,16 @@ class Router {
733
739
  const shouldViewTransition = this.shouldViewTransition ?? this.options.defaultViewTransition;
734
740
  delete this.shouldViewTransition;
735
741
  if (shouldViewTransition && typeof document !== "undefined" && "startViewTransition" in document && typeof document.startViewTransition === "function") {
736
- document.startViewTransition(fn);
742
+ let startViewTransitionParams;
743
+ if (typeof shouldViewTransition === "object" && this.isViewTransitionTypesSupported) {
744
+ startViewTransitionParams = {
745
+ update: fn,
746
+ types: shouldViewTransition.types
747
+ };
748
+ } else {
749
+ startViewTransitionParams = fn;
750
+ }
751
+ document.startViewTransition(startViewTransitionParams);
737
752
  } else {
738
753
  fn();
739
754
  }