@tanstack/react-router 1.2.3 → 1.2.5

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.
@@ -15,27 +15,7 @@ export type FileRoutePath<TParentRoute extends AnyRoute, TFilePath extends strin
15
15
  export declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = TFilePath, TPath extends RouteConstraints['TPath'] = FileRoutePath<TParentRoute, TFilePath>, TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, RemoveUnderScores<TPath>>> {
16
16
  path: TFilePath;
17
17
  constructor(path: TFilePath);
18
- createRoute: <TSearchSchemaInput extends import("./route").AnySearchSchema = {}, TSearchSchema extends import("./route").AnySearchSchema = {}, TSearchSchemaUsed extends Record<string, any> = TSearchSchemaInput extends SearchSchemaInput ? Omit<TSearchSchemaInput, "__TSearchSchemaInput__"> : TSearchSchema, TFullSearchSchemaInput extends import("./route").AnySearchSchema = ResolveFullSearchSchemaInput<TParentRoute, TSearchSchemaUsed>, TFullSearchSchema extends import("./route").AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<string, any> = Expand<Record<ParsePathParams<TPath>, string>>, TAllParams extends Record<string, any> = MergeFromFromParent<TParentRoute["types"]["allParams"], TParams>, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext extends RouteContext = [TRouteContextReturn] extends [never] ? RouteContext : TRouteContextReturn, TAllContext extends Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}>, TRouteContext>> = Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}>, TRouteContext>>, TRouterContext extends AnyContext = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderData extends unknown = unknown, TChildren extends unknown = unknown, TRouteTree extends AnyRoute = AnyRoute>(options?: (Omit<RouteOptions<TParentRoute, string, TPath, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderData>, "path" | "id" | "getParentRoute"> & {
19
- meta?: import("./route").RouteMeta | undefined;
20
- } & {
21
- caseSensitive?: boolean | undefined;
22
- wrapInSuspense?: boolean | undefined;
23
- component?: import("./route").RouteComponent<any> | undefined;
24
- errorComponent?: false | import("./route").ErrorRouteComponent | null | undefined;
25
- pendingComponent?: import("./route").RouteComponent<any> | undefined;
26
- pendingMs?: number | undefined;
27
- pendingMinMs?: number | undefined;
28
- staleTime?: number | undefined;
29
- gcTime?: number | undefined;
30
- preloadStaleTime?: number | undefined;
31
- preloadGcTime?: number | undefined;
32
- preSearchFilters?: import("./route").SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
33
- postSearchFilters?: import("./route").SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
34
- onError?: ((err: any) => void) | undefined;
35
- onEnter?: ((match: import("./Matches").AnyRouteMatch) => void) | undefined;
36
- onStay?: ((match: import("./Matches").AnyRouteMatch) => void) | undefined;
37
- onLeave?: ((match: import("./Matches").AnyRouteMatch) => void) | undefined;
38
- }) | undefined) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderData, TChildren, TRouteTree>;
18
+ createRoute: <TSearchSchemaInput extends import("./route").AnySearchSchema = {}, TSearchSchema extends import("./route").AnySearchSchema = {}, TSearchSchemaUsed extends Record<string, any> = TSearchSchemaInput extends SearchSchemaInput ? Omit<TSearchSchemaInput, "__TSearchSchemaInput__"> : TSearchSchema, TFullSearchSchemaInput extends import("./route").AnySearchSchema = ResolveFullSearchSchemaInput<TParentRoute, TSearchSchemaUsed>, TFullSearchSchema extends import("./route").AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<string, any> = Expand<Record<ParsePathParams<TPath>, string>>, TAllParams extends Record<string, any> = MergeFromFromParent<TParentRoute["types"]["allParams"], TParams>, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext extends RouteContext = [TRouteContextReturn] extends [never] ? RouteContext : TRouteContextReturn, TAllContext extends Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}>, TRouteContext>> = Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}>, TRouteContext>>, TRouterContext extends AnyContext = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderData extends unknown = unknown, TChildren extends unknown = unknown, TRouteTree extends AnyRoute = AnyRoute>(options?: (Omit<RouteOptions<TParentRoute, string, TPath, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderData>, "path" | "id" | "getParentRoute"> & UpdatableRouteOptions<TFullSearchSchema>) | undefined) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderData, TChildren, TRouteTree>;
39
19
  }
40
20
  export declare function FileRouteLoader<TFilePath extends keyof FileRoutesByPath, TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute']>(_path: TFilePath): <TLoaderData extends any>(loaderFn: RouteLoaderFn<TRoute['types']['allParams'], TRoute['types']['loaderDeps'], TRoute['types']['allContext'], TRoute['types']['routeContext'], TLoaderData>) => RouteLoaderFn<TRoute['types']['allParams'], TRoute['types']['loaderDeps'], TRoute['types']['allContext'], TRoute['types']['routeContext'], NoInfer<TLoaderData>>;
41
21
  export {};
@@ -4,7 +4,7 @@ import { NavigateOptions, ParsePathParams, ToSubOptions } from './link';
4
4
  import { ParsedLocation } from './location';
5
5
  import { RouteById, RouteIds, RoutePaths } from './routeInfo';
6
6
  import { AnyRouter, RegisteredRouter } from './router';
7
- import { Assign, Expand, IsAny, NoInfer, PickRequired, UnionToIntersection } from './utils';
7
+ import { Assign, Expand, IsAny, NoInfer, UnionToIntersection } from './utils';
8
8
  import { BuildLocationFn, NavigateFn } from './RouterProvider';
9
9
  export declare const rootRouteId: "__root__";
10
10
  export type RootRouteId = typeof rootRouteId;
@@ -16,8 +16,6 @@ export type AnySearchSchema = {};
16
16
  export type AnyContext = {};
17
17
  export interface RouteContext {
18
18
  }
19
- export interface RouteMeta {
20
- }
21
19
  export type PreloadableObj = {
22
20
  preload?: () => Promise<void>;
23
21
  };
@@ -27,11 +25,6 @@ export type RoutePathOptions<TCustomId, TPath> = {
27
25
  id: TCustomId;
28
26
  };
29
27
  export type RoutePathOptionsIntersection<TCustomId, TPath> = UnionToIntersection<RoutePathOptions<TCustomId, TPath>>;
30
- export type MetaOptions = keyof PickRequired<RouteMeta> extends never ? {
31
- meta?: RouteMeta;
32
- } : {
33
- meta: RouteMeta;
34
- };
35
28
  export type RouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TSearchSchemaInput extends Record<string, any> = {}, TSearchSchema extends Record<string, any> = {}, TSearchSchemaUsed extends Record<string, any> = {}, TFullSearchSchemaInput extends Record<string, any> = TSearchSchemaUsed, TFullSearchSchema extends Record<string, any> = TSearchSchema, TParams extends AnyPathParams = AnyPathParams, TAllParams extends AnyPathParams = TParams, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext extends RouteContext = RouteContext, TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, TAllContext extends Record<string, any> = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderData extends any = unknown> = BaseRouteOptions<TParentRoute, TCustomId, TPath, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderData> & UpdatableRouteOptions<NoInfer<TFullSearchSchema>>;
36
29
  export type ParamsFallback<TPath extends string, TParams> = unknown extends TParams ? Record<ParsePathParams<TPath>, string> : TParams;
37
30
  export type BaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TSearchSchemaInput extends Record<string, any> = {}, TSearchSchema extends Record<string, any> = {}, TSearchSchemaUsed extends Record<string, any> = {}, TFullSearchSchemaInput extends Record<string, any> = TSearchSchemaUsed, TFullSearchSchema extends Record<string, any> = TSearchSchema, TParams extends AnyPathParams = {}, TAllParams = ParamsFallback<TPath, TParams>, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext extends RouteContext = RouteContext, TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, TAllContext extends Record<string, any> = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderData extends any = unknown> = RoutePathOptions<TCustomId, TPath> & {
@@ -63,7 +56,7 @@ type BeforeLoadFn<TFullSearchSchema extends Record<string, any>, TParentRoute ex
63
56
  buildLocation: BuildLocationFn<TParentRoute>;
64
57
  cause: 'preload' | 'enter' | 'stay';
65
58
  }) => Promise<TRouteContextReturn> | TRouteContextReturn | void;
66
- export type UpdatableRouteOptions<TFullSearchSchema extends Record<string, any>> = MetaOptions & {
59
+ export type UpdatableRouteOptions<TFullSearchSchema extends Record<string, any>> = {
67
60
  caseSensitive?: boolean;
68
61
  wrapInSuspense?: boolean;
69
62
  component?: RouteComponent;
@@ -2037,13 +2037,18 @@
2037
2037
  // router can be used in a non-react environment if necessary
2038
2038
  startReactTransition = fn => fn();
2039
2039
  update = newOptions => {
2040
+ const previousOptions = this.options;
2040
2041
  this.options = {
2041
2042
  ...this.options,
2042
2043
  ...newOptions
2043
2044
  };
2044
- this.basepath = `/${trimPath(newOptions.basepath ?? '') ?? ''}`;
2045
+ if (!this.basepath || newOptions.basepath && newOptions.basepath !== previousOptions.basepath) {
2046
+ this.basepath = `/${trimPath(newOptions.basepath ?? '') ?? ''}`;
2047
+ }
2045
2048
  if (!this.history || this.options.history && this.options.history !== this.history) {
2046
- this.history = this.options.history ?? (typeof document !== 'undefined' ? createBrowserHistory() : createMemoryHistory());
2049
+ this.history = this.options.history ?? (typeof document !== 'undefined' ? createBrowserHistory() : createMemoryHistory({
2050
+ initialEntries: [this.options.basepath || '/']
2051
+ }));
2047
2052
  this.latestLocation = this.parseLocation();
2048
2053
  }
2049
2054
  if (this.options.routeTree !== this.routeTree) {