@tanstack/react-router 1.84.4 → 1.85.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.
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/RouterProvider.d.cts +3 -3
- package/dist/cjs/router.cjs +3 -1
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +13 -13
- package/dist/cjs/routerContext.d.cts +1 -1
- package/dist/esm/RouterProvider.d.ts +3 -3
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/router.d.ts +13 -13
- package/dist/esm/router.js +3 -1
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerContext.d.ts +1 -1
- package/package.json +3 -3
- package/src/RouterProvider.tsx +4 -1
- package/src/router.ts +20 -6
package/dist/cjs/router.d.cts
CHANGED
|
@@ -34,8 +34,8 @@ declare global {
|
|
|
34
34
|
}
|
|
35
35
|
export interface Register {
|
|
36
36
|
}
|
|
37
|
-
export type AnyRouter = Router<any, any, any, any, any>;
|
|
38
|
-
export type AnyRouterWithContext<TContext> = Router<AnyRouteWithContext<TContext>, any, any, any>;
|
|
37
|
+
export type AnyRouter = Router<any, any, any, any, any, any>;
|
|
38
|
+
export type AnyRouterWithContext<TContext> = Router<AnyRouteWithContext<TContext>, any, any, any, any>;
|
|
39
39
|
export type RegisteredRouter = Register extends {
|
|
40
40
|
router: infer TRouter extends AnyRouter;
|
|
41
41
|
} ? TRouter : AnyRouter;
|
|
@@ -62,7 +62,7 @@ export type RouterContextOptions<TRouteTree extends AnyRoute> = AnyContext exten
|
|
|
62
62
|
context: InferRouterContext<TRouteTree>;
|
|
63
63
|
};
|
|
64
64
|
export type TrailingSlashOption = 'always' | 'never' | 'preserve';
|
|
65
|
-
export interface RouterOptions<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean = false, TDehydrated extends Record<string, any> = Record<string, any>, TSerializedError extends Record<string, any> = Record<string, any>> {
|
|
65
|
+
export interface RouterOptions<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean = false, TRouterHistory extends RouterHistory = RouterHistory, TDehydrated extends Record<string, any> = Record<string, any>, TSerializedError extends Record<string, any> = Record<string, any>> {
|
|
66
66
|
/**
|
|
67
67
|
* The history object that will be used to manage the browser history.
|
|
68
68
|
*
|
|
@@ -71,7 +71,7 @@ export interface RouterOptions<TRouteTree extends AnyRoute, TTrailingSlashOption
|
|
|
71
71
|
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#history-property)
|
|
72
72
|
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/history-types)
|
|
73
73
|
*/
|
|
74
|
-
history?:
|
|
74
|
+
history?: TRouterHistory;
|
|
75
75
|
/**
|
|
76
76
|
* A function that will be used to stringify search params when generating links.
|
|
77
77
|
*
|
|
@@ -417,7 +417,7 @@ export interface DehydratedRouter {
|
|
|
417
417
|
export interface ViewTransitionOptions {
|
|
418
418
|
types: Array<string>;
|
|
419
419
|
}
|
|
420
|
-
export type RouterConstructorOptions<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TDehydrated extends Record<string, any>, TSerializedError extends Record<string, any>> = Omit<RouterOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TDehydrated, TSerializedError>, 'context'> & RouterContextOptions<TRouteTree>;
|
|
420
|
+
export type RouterConstructorOptions<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TRouterHistory extends RouterHistory, TDehydrated extends Record<string, any>, TSerializedError extends Record<string, any>> = Omit<RouterOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated, TSerializedError>, 'context'> & RouterContextOptions<TRouteTree>;
|
|
421
421
|
export declare const componentTypes: readonly ["component", "errorComponent", "pendingComponent", "notFoundComponent"];
|
|
422
422
|
export type RouterEvents = {
|
|
423
423
|
onBeforeNavigate: {
|
|
@@ -461,14 +461,14 @@ export type RouterListener<TRouterEvent extends RouterEvent> = {
|
|
|
461
461
|
eventType: TRouterEvent['type'];
|
|
462
462
|
fn: ListenerFn<TRouterEvent>;
|
|
463
463
|
};
|
|
464
|
-
export declare function createRouter<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TDehydrated extends Record<string, any> = Record<string, any>, TSerializedError extends Record<string, any> = Record<string, any>>(options: undefined extends number ? 'strictNullChecks must be enabled in tsconfig.json' : RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TDehydrated, TSerializedError>): Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TDehydrated, TSerializedError>;
|
|
464
|
+
export declare function createRouter<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TRouterHistory extends RouterHistory = RouterHistory, TDehydrated extends Record<string, any> = Record<string, any>, TSerializedError extends Record<string, any> = Record<string, any>>(options: undefined extends number ? 'strictNullChecks must be enabled in tsconfig.json' : RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated, TSerializedError>): Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated, TSerializedError>;
|
|
465
465
|
type MatchRoutesOpts = {
|
|
466
466
|
preload?: boolean;
|
|
467
467
|
throwOnError?: boolean;
|
|
468
468
|
_buildLocation?: boolean;
|
|
469
469
|
dest?: BuildNextOptions;
|
|
470
470
|
};
|
|
471
|
-
export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailingSlashOption extends TrailingSlashOption, in out TDefaultStructuralSharingOption extends boolean, in out TDehydrated extends Record<string, any> = Record<string, any>, in out TSerializedError extends Record<string, any> = Record<string, any>> {
|
|
471
|
+
export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailingSlashOption extends TrailingSlashOption, in out TDefaultStructuralSharingOption extends boolean, in out TRouterHistory extends RouterHistory = RouterHistory, in out TDehydrated extends Record<string, any> = Record<string, any>, in out TSerializedError extends Record<string, any> = Record<string, any>> {
|
|
472
472
|
tempLocationKey: string | undefined;
|
|
473
473
|
resetNextScroll: boolean;
|
|
474
474
|
shouldViewTransition?: boolean | ViewTransitionOptions;
|
|
@@ -487,10 +487,10 @@ export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailing
|
|
|
487
487
|
}) => any;
|
|
488
488
|
serializer?: (data: any) => string;
|
|
489
489
|
__store: Store<RouterState<TRouteTree>>;
|
|
490
|
-
options: PickAsRequired<Omit<RouterOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TDehydrated, TSerializedError>, 'transformer'> & {
|
|
490
|
+
options: PickAsRequired<Omit<RouterOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated, TSerializedError>, 'transformer'> & {
|
|
491
491
|
transformer: RouterTransformer;
|
|
492
492
|
}, 'stringifySearch' | 'parseSearch' | 'context'>;
|
|
493
|
-
history:
|
|
493
|
+
history: TRouterHistory;
|
|
494
494
|
latestLocation: ParsedLocation<FullSearchSchema<TRouteTree>>;
|
|
495
495
|
basepath: string;
|
|
496
496
|
routeTree: TRouteTree;
|
|
@@ -502,9 +502,9 @@ export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailing
|
|
|
502
502
|
/**
|
|
503
503
|
* @deprecated Use the `createRouter` function instead
|
|
504
504
|
*/
|
|
505
|
-
constructor(options: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TDehydrated, TSerializedError>);
|
|
505
|
+
constructor(options: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated, TSerializedError>);
|
|
506
506
|
startReactTransition: (fn: () => void) => void;
|
|
507
|
-
update: (newOptions: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TDehydrated, TSerializedError>) => void;
|
|
507
|
+
update: (newOptions: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated, TSerializedError>) => void;
|
|
508
508
|
get state(): RouterState<TRouteTree, import('./Matches.cjs').RouteMatch<any, any, any, any, any, any, any>>;
|
|
509
509
|
buildRouteTree: () => void;
|
|
510
510
|
subscribe: <TType extends keyof RouterEvents>(eventType: TType, fn: ListenerFn<RouterEvents[TType]>) => () => void;
|
|
@@ -557,8 +557,8 @@ export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailing
|
|
|
557
557
|
filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean;
|
|
558
558
|
}) => void;
|
|
559
559
|
clearExpiredCache: () => void;
|
|
560
|
-
preloadRoute: <TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string | undefined = undefined, TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = "">(opts: NavigateOptions<Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TDehydrated, TSerializedError>, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<Array<AnyRouteMatch> | undefined>;
|
|
561
|
-
matchRoute: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string | undefined = undefined, TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TDehydrated, TSerializedError>, TFrom, TTo>, opts?: MatchRouteOptions) => false | RouteById<TRouteTree, TResolved>["types"]["allParams"];
|
|
560
|
+
preloadRoute: <TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string | undefined = undefined, TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = "">(opts: NavigateOptions<Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated, TSerializedError>, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<Array<AnyRouteMatch> | undefined>;
|
|
561
|
+
matchRoute: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string | undefined = undefined, TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated, TSerializedError>, TFrom, TTo>, opts?: MatchRouteOptions) => false | RouteById<TRouteTree, TResolved>["types"]["allParams"];
|
|
562
562
|
dehydrate: () => DehydratedRouter;
|
|
563
563
|
hydrate: () => void;
|
|
564
564
|
injectedHtml: Array<() => string>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Router } from './router.cjs';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
export declare function getRouterContext(): React.Context<Router<any, any, any, Record<string, any>, Record<string, any>>>;
|
|
3
|
+
export declare function getRouterContext(): React.Context<Router<any, any, any, import('@tanstack/history').RouterHistory, Record<string, any>, Record<string, any>>>;
|
|
@@ -29,7 +29,7 @@ export declare function RouterContextProvider<TRouter extends AnyRouter = Regist
|
|
|
29
29
|
children: React.ReactNode;
|
|
30
30
|
}): import("react/jsx-runtime").JSX.Element;
|
|
31
31
|
export declare function RouterProvider<TRouter extends AnyRouter = RegisteredRouter, TDehydrated extends Record<string, any> = Record<string, any>>({ router, ...rest }: RouterProps<TRouter, TDehydrated>): import("react/jsx-runtime").JSX.Element;
|
|
32
|
-
export type RouterProps<TRouter extends AnyRouter = RegisteredRouter, TDehydrated extends Record<string, any> = Record<string, any>> = Omit<RouterOptions<TRouter['routeTree'], NonNullable<TRouter['options']['trailingSlash']>, NonNullable<TRouter['options']['defaultStructuralSharing']>, TDehydrated>, 'context'> & {
|
|
33
|
-
router: Router<TRouter['routeTree'], NonNullable<TRouter['options']['trailingSlash']>, NonNullable<TRouter['options']['defaultStructuralSharing']
|
|
34
|
-
context?: Partial<RouterOptions<TRouter['routeTree'], NonNullable<TRouter['options']['trailingSlash']>, NonNullable<TRouter['options']['defaultStructuralSharing']>, TDehydrated>['context']>;
|
|
32
|
+
export type RouterProps<TRouter extends AnyRouter = RegisteredRouter, TDehydrated extends Record<string, any> = Record<string, any>> = Omit<RouterOptions<TRouter['routeTree'], NonNullable<TRouter['options']['trailingSlash']>, NonNullable<TRouter['options']['defaultStructuralSharing']>, TRouter['history'], TDehydrated>, 'context'> & {
|
|
33
|
+
router: Router<TRouter['routeTree'], NonNullable<TRouter['options']['trailingSlash']>, NonNullable<TRouter['options']['defaultStructuralSharing']>, TRouter['history']>;
|
|
34
|
+
context?: Partial<RouterOptions<TRouter['routeTree'], NonNullable<TRouter['options']['trailingSlash']>, NonNullable<TRouter['options']['defaultStructuralSharing']>, TRouter['history'], TDehydrated>['context']>;
|
|
35
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouterProvider.js","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 ViewTransitionOptions,\n} from './router'\n\nexport interface CommitLocationOptions {\n replace?: boolean\n resetScroll?: boolean\n viewTransition?: boolean | ViewTransitionOptions\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 TRouter extends RegisteredRouter,\n TTo extends string | undefined,\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) => Promise<void>\n\nexport type BuildLocationFn = <\n TRouter extends RegisteredRouter,\n TTo extends string | undefined,\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 _includeValidateSearch?: 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 NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TDehydrated\n >,\n 'context'\n> & {\n router: Router<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']
|
|
1
|
+
{"version":3,"file":"RouterProvider.js","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 ViewTransitionOptions,\n} from './router'\n\nexport interface CommitLocationOptions {\n replace?: boolean\n resetScroll?: boolean\n viewTransition?: boolean | ViewTransitionOptions\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 TRouter extends RegisteredRouter,\n TTo extends string | undefined,\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) => Promise<void>\n\nexport type BuildLocationFn = <\n TRouter extends RegisteredRouter,\n TTo extends string | undefined,\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 _includeValidateSearch?: 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 NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >,\n 'context'\n> & {\n router: Router<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history']\n >\n context?: Partial<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >['context']\n >\n}\n"],"names":[],"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,IAAA;AAAA,EACV,CACM;AAER,QAAM,gBAAgB,iBAAiB;AAEvC,QAAM,WACH,oBAAA,cAAc,UAAd,EAAuB,OAAO,QAAS,UAAS;AAG/C,MAAA,OAAO,QAAQ,MAAM;AACvB,WAAQ,oBAAA,OAAO,QAAQ,MAAf,EAAqB,UAAS,UAAA;AAAA,EAAA;AAGjC,SAAA;AACT;AAEO,SAAS,eAGd,EAAE,QAAQ,GAAG,QAA2C;AACxD,6BACG,uBAAsB,EAAA,QAAiB,GAAG,MACzC,UAAA,oBAAC,UAAQ,CAAA,GACX;AAEJ;"}
|
package/dist/esm/router.d.ts
CHANGED
|
@@ -34,8 +34,8 @@ declare global {
|
|
|
34
34
|
}
|
|
35
35
|
export interface Register {
|
|
36
36
|
}
|
|
37
|
-
export type AnyRouter = Router<any, any, any, any, any>;
|
|
38
|
-
export type AnyRouterWithContext<TContext> = Router<AnyRouteWithContext<TContext>, any, any, any>;
|
|
37
|
+
export type AnyRouter = Router<any, any, any, any, any, any>;
|
|
38
|
+
export type AnyRouterWithContext<TContext> = Router<AnyRouteWithContext<TContext>, any, any, any, any>;
|
|
39
39
|
export type RegisteredRouter = Register extends {
|
|
40
40
|
router: infer TRouter extends AnyRouter;
|
|
41
41
|
} ? TRouter : AnyRouter;
|
|
@@ -62,7 +62,7 @@ export type RouterContextOptions<TRouteTree extends AnyRoute> = AnyContext exten
|
|
|
62
62
|
context: InferRouterContext<TRouteTree>;
|
|
63
63
|
};
|
|
64
64
|
export type TrailingSlashOption = 'always' | 'never' | 'preserve';
|
|
65
|
-
export interface RouterOptions<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean = false, TDehydrated extends Record<string, any> = Record<string, any>, TSerializedError extends Record<string, any> = Record<string, any>> {
|
|
65
|
+
export interface RouterOptions<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean = false, TRouterHistory extends RouterHistory = RouterHistory, TDehydrated extends Record<string, any> = Record<string, any>, TSerializedError extends Record<string, any> = Record<string, any>> {
|
|
66
66
|
/**
|
|
67
67
|
* The history object that will be used to manage the browser history.
|
|
68
68
|
*
|
|
@@ -71,7 +71,7 @@ export interface RouterOptions<TRouteTree extends AnyRoute, TTrailingSlashOption
|
|
|
71
71
|
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#history-property)
|
|
72
72
|
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/history-types)
|
|
73
73
|
*/
|
|
74
|
-
history?:
|
|
74
|
+
history?: TRouterHistory;
|
|
75
75
|
/**
|
|
76
76
|
* A function that will be used to stringify search params when generating links.
|
|
77
77
|
*
|
|
@@ -417,7 +417,7 @@ export interface DehydratedRouter {
|
|
|
417
417
|
export interface ViewTransitionOptions {
|
|
418
418
|
types: Array<string>;
|
|
419
419
|
}
|
|
420
|
-
export type RouterConstructorOptions<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TDehydrated extends Record<string, any>, TSerializedError extends Record<string, any>> = Omit<RouterOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TDehydrated, TSerializedError>, 'context'> & RouterContextOptions<TRouteTree>;
|
|
420
|
+
export type RouterConstructorOptions<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TRouterHistory extends RouterHistory, TDehydrated extends Record<string, any>, TSerializedError extends Record<string, any>> = Omit<RouterOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated, TSerializedError>, 'context'> & RouterContextOptions<TRouteTree>;
|
|
421
421
|
export declare const componentTypes: readonly ["component", "errorComponent", "pendingComponent", "notFoundComponent"];
|
|
422
422
|
export type RouterEvents = {
|
|
423
423
|
onBeforeNavigate: {
|
|
@@ -461,14 +461,14 @@ export type RouterListener<TRouterEvent extends RouterEvent> = {
|
|
|
461
461
|
eventType: TRouterEvent['type'];
|
|
462
462
|
fn: ListenerFn<TRouterEvent>;
|
|
463
463
|
};
|
|
464
|
-
export declare function createRouter<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TDehydrated extends Record<string, any> = Record<string, any>, TSerializedError extends Record<string, any> = Record<string, any>>(options: undefined extends number ? 'strictNullChecks must be enabled in tsconfig.json' : RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TDehydrated, TSerializedError>): Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TDehydrated, TSerializedError>;
|
|
464
|
+
export declare function createRouter<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TRouterHistory extends RouterHistory = RouterHistory, TDehydrated extends Record<string, any> = Record<string, any>, TSerializedError extends Record<string, any> = Record<string, any>>(options: undefined extends number ? 'strictNullChecks must be enabled in tsconfig.json' : RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated, TSerializedError>): Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated, TSerializedError>;
|
|
465
465
|
type MatchRoutesOpts = {
|
|
466
466
|
preload?: boolean;
|
|
467
467
|
throwOnError?: boolean;
|
|
468
468
|
_buildLocation?: boolean;
|
|
469
469
|
dest?: BuildNextOptions;
|
|
470
470
|
};
|
|
471
|
-
export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailingSlashOption extends TrailingSlashOption, in out TDefaultStructuralSharingOption extends boolean, in out TDehydrated extends Record<string, any> = Record<string, any>, in out TSerializedError extends Record<string, any> = Record<string, any>> {
|
|
471
|
+
export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailingSlashOption extends TrailingSlashOption, in out TDefaultStructuralSharingOption extends boolean, in out TRouterHistory extends RouterHistory = RouterHistory, in out TDehydrated extends Record<string, any> = Record<string, any>, in out TSerializedError extends Record<string, any> = Record<string, any>> {
|
|
472
472
|
tempLocationKey: string | undefined;
|
|
473
473
|
resetNextScroll: boolean;
|
|
474
474
|
shouldViewTransition?: boolean | ViewTransitionOptions;
|
|
@@ -487,10 +487,10 @@ export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailing
|
|
|
487
487
|
}) => any;
|
|
488
488
|
serializer?: (data: any) => string;
|
|
489
489
|
__store: Store<RouterState<TRouteTree>>;
|
|
490
|
-
options: PickAsRequired<Omit<RouterOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TDehydrated, TSerializedError>, 'transformer'> & {
|
|
490
|
+
options: PickAsRequired<Omit<RouterOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated, TSerializedError>, 'transformer'> & {
|
|
491
491
|
transformer: RouterTransformer;
|
|
492
492
|
}, 'stringifySearch' | 'parseSearch' | 'context'>;
|
|
493
|
-
history:
|
|
493
|
+
history: TRouterHistory;
|
|
494
494
|
latestLocation: ParsedLocation<FullSearchSchema<TRouteTree>>;
|
|
495
495
|
basepath: string;
|
|
496
496
|
routeTree: TRouteTree;
|
|
@@ -502,9 +502,9 @@ export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailing
|
|
|
502
502
|
/**
|
|
503
503
|
* @deprecated Use the `createRouter` function instead
|
|
504
504
|
*/
|
|
505
|
-
constructor(options: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TDehydrated, TSerializedError>);
|
|
505
|
+
constructor(options: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated, TSerializedError>);
|
|
506
506
|
startReactTransition: (fn: () => void) => void;
|
|
507
|
-
update: (newOptions: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TDehydrated, TSerializedError>) => void;
|
|
507
|
+
update: (newOptions: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated, TSerializedError>) => void;
|
|
508
508
|
get state(): RouterState<TRouteTree, import('./Matches.js').RouteMatch<any, any, any, any, any, any, any>>;
|
|
509
509
|
buildRouteTree: () => void;
|
|
510
510
|
subscribe: <TType extends keyof RouterEvents>(eventType: TType, fn: ListenerFn<RouterEvents[TType]>) => () => void;
|
|
@@ -557,8 +557,8 @@ export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailing
|
|
|
557
557
|
filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean;
|
|
558
558
|
}) => void;
|
|
559
559
|
clearExpiredCache: () => void;
|
|
560
|
-
preloadRoute: <TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string | undefined = undefined, TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = "">(opts: NavigateOptions<Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TDehydrated, TSerializedError>, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<Array<AnyRouteMatch> | undefined>;
|
|
561
|
-
matchRoute: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string | undefined = undefined, TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TDehydrated, TSerializedError>, TFrom, TTo>, opts?: MatchRouteOptions) => false | RouteById<TRouteTree, TResolved>["types"]["allParams"];
|
|
560
|
+
preloadRoute: <TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string | undefined = undefined, TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = "">(opts: NavigateOptions<Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated, TSerializedError>, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<Array<AnyRouteMatch> | undefined>;
|
|
561
|
+
matchRoute: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string | undefined = undefined, TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated, TSerializedError>, TFrom, TTo>, opts?: MatchRouteOptions) => false | RouteById<TRouteTree, TResolved>["types"]["allParams"];
|
|
562
562
|
dehydrate: () => DehydratedRouter;
|
|
563
563
|
hydrate: () => void;
|
|
564
564
|
injectedHtml: Array<() => string>;
|
package/dist/esm/router.js
CHANGED
|
@@ -59,6 +59,7 @@ class Router {
|
|
|
59
59
|
this.subscribers = /* @__PURE__ */ new Set();
|
|
60
60
|
this.startReactTransition = (fn) => fn();
|
|
61
61
|
this.update = (newOptions) => {
|
|
62
|
+
var _a;
|
|
62
63
|
if (newOptions.notFoundRoute) {
|
|
63
64
|
console.warn(
|
|
64
65
|
"The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/guide/not-found-errors#migrating-from-notfoundroute for more info."
|
|
@@ -108,7 +109,8 @@ class Router {
|
|
|
108
109
|
}
|
|
109
110
|
});
|
|
110
111
|
}
|
|
111
|
-
if (typeof window !== "undefined" && "CSS" in window &&
|
|
112
|
+
if (typeof window !== "undefined" && "CSS" in window && // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
113
|
+
typeof ((_a = window.CSS) == null ? void 0 : _a.supports) === "function") {
|
|
112
114
|
this.isViewTransitionTypesSupported = window.CSS.supports(
|
|
113
115
|
"selector(:active-view-transition-type(a)"
|
|
114
116
|
);
|