@tanstack/router-core 1.171.24 → 1.171.26

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.
@@ -460,7 +460,7 @@ export type RouterContextOptions<TRouteTree extends AnyRoute> = AnyContext exten
460
460
  context: InferRouterContext<TRouteTree>;
461
461
  };
462
462
  export type RouterConstructorOptions<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TRouterHistory extends RouterHistory, TDehydrated extends Record<string, any>> = Omit<RouterOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>, 'context' | 'serializationAdapters' | 'defaultSsr'> & RouterContextOptions<TRouteTree>;
463
- export type PreloadRouteFn<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TRouterHistory extends RouterHistory> = <TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string | undefined = undefined, TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''>(opts: NavigateOptions<RouterCore<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory>, TFrom, TTo, TMaskFrom, TMaskTo> & {}) => Promise<Array<AnyRouteMatch> | undefined>;
463
+ export type PreloadRouteFn<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TRouterHistory extends RouterHistory> = <TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string | undefined = undefined, TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''>(opts: NavigateOptions<RouterCore<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory>, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<Array<AnyRouteMatch> | undefined>;
464
464
  export type MatchRouteFn<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TRouterHistory extends RouterHistory> = <TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string | undefined = undefined, TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<RouterCore<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory>, TFrom, TTo>, opts?: MatchRouteOptions) => false | RouteById<TRouteTree, TResolved>['types']['allParams'];
465
465
  export type UpdateFn<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TRouterHistory extends RouterHistory, TDehydrated extends Record<string, any>> = (newOptions: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>) => void;
466
466
  export type InvalidateFn<TRouter extends AnyRouter> = (opts?: {
@@ -586,7 +586,7 @@ export declare function getLocationChangeInfo(location: ParsedLocation, resolved
586
586
  */
587
587
  export declare function _getUserHistoryState({ key: _key, __TSR_key: _tsrKey, __TSR_index: _tsrIndex, __hashScrollIntoViewOptions: _hashScroll, ...state }: ParsedHistoryState): HistoryState;
588
588
  /** Run route lifecycle callbacks in leave/enter/stay phases. */
589
- export declare function runRouteLifecycle(router: AnyRouter, previous: Array<AnyRouteMatch>, matches: Array<AnyRouteMatch>, isCurrent?: () => boolean): void;
589
+ export declare function runRouteLifecycle(router: AnyRouter, previous: Array<AnyRouteMatch>, matches: Array<AnyRouteMatch>, owner?: LoadTransaction): void;
590
590
  export type CreateRouterFn = <TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption = 'never', TDefaultStructuralSharingOption extends boolean = false, TRouterHistory extends RouterHistory = RouterHistory, TDehydrated extends Record<string, any> = Record<string, any>>(options: undefined extends number ? 'strictNullChecks must be enabled in tsconfig.json' : RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>) => RouterCore<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>;
591
591
  declare global {
592
592
  var __TSR_CACHE__: {
@@ -721,9 +721,7 @@ export declare class RouterCore<in out TRouteTree extends AnyRoute, in out TTrai
721
721
  */
722
722
  commitLocation: CommitLocationFn;
723
723
  /** Convenience helper: build a location from options, then commit it. */
724
- buildAndCommitLocation: ({ replace, resetScroll, hashScrollIntoView, viewTransition, ignoreBlocker, _redirects, href, ...rest }?: BuildNextOptions & CommitLocationOptions & {
725
- _redirects?: number;
726
- }) => Promise<void>;
724
+ buildAndCommitLocation: ({ replace, resetScroll, hashScrollIntoView, viewTransition, ignoreBlocker, ...rest }?: BuildNextOptions & CommitLocationOptions) => Promise<void>;
727
725
  /**
728
726
  * Imperatively navigate using standard `NavigateOptions`. When `reloadDocument`
729
727
  * or an absolute `href` is provided, performs a full document navigation.
@@ -37,10 +37,17 @@ declare const ERROR = 1;
37
37
  declare const NOT_FOUND = 2;
38
38
  declare const REDIRECTED = 3;
39
39
  declare const CANCELED = 4;
40
- type LoaderOutcome = [kind: typeof SUCCESS, data: unknown] | [kind: typeof ERROR, error: unknown] | [kind: typeof NOT_FOUND, error: NotFoundError] | [kind: typeof REDIRECTED, redirect: AnyRedirect] | [kind: typeof CANCELED];
40
+ type RedirectOutcome = [
41
+ kind: typeof REDIRECTED,
42
+ redirect: AnyRedirect,
43
+ location?: ParsedLocation
44
+ ];
45
+ type NonRedirectOutcome = [kind: typeof SUCCESS, data: unknown] | [kind: typeof ERROR, error: unknown] | [kind: typeof NOT_FOUND, error: NotFoundError] | [kind: typeof CANCELED];
46
+ type RawLoaderOutcome = NonRedirectOutcome | [kind: typeof REDIRECTED, redirect: AnyRedirect];
47
+ type LoaderOutcome = NonRedirectOutcome | RedirectOutcome;
41
48
  type IndexedOutcome = [index: number, outcome: LoaderOutcome, boundary?: number];
42
49
  export type LoaderFlight = [
43
- outcome: Promise<LoaderOutcome>,
50
+ outcome: Promise<RawLoaderOutcome>,
44
51
  controller: AbortController,
45
52
  leases: number
46
53
  ];
@@ -66,31 +73,25 @@ export type LoadTransaction = [
66
73
  startedAt: number,
67
74
  done: Promise<void>,
68
75
  /**
69
- * Dev-only HMR refresh mode. Presence is the mode flag; a refresh always
70
- * carries the presentation it started from and its optional hydration
71
- * handoff. While a publication awaits acknowledgement, its rollback lives
72
- * with the transaction that owns the publication.
76
+ * Dev-only HMR refresh mode. Presence forces successor rematerialization
77
+ * until this publication is acknowledged. The optional hydration handoff is
78
+ * retired when the refresh publishes.
73
79
  */
74
- refresh?: [
75
- presentation: Array<AnyRouteMatch>,
76
- handoff: NonNullable<AnyRouter['_handoff']> | undefined,
77
- rollback?: () => boolean
78
- ]
80
+ refresh?: [handoff: NonNullable<AnyRouter['_handoff']> | undefined]
79
81
  ];
80
82
  export type PendingSession = [
81
- owner: LoadTransaction,
82
- boundary: number,
83
+ generation: LoadTransaction,
84
+ boundaryId: string,
83
85
  /** Pending reveal time until acknowledged, then minimum-visible-until time. */
84
86
  deadline: number,
85
- timer?: ReturnType<typeof setTimeout>,
86
- ack?: Promise<boolean>,
87
+ revealTimer?: ReturnType<typeof setTimeout>,
88
+ ack?: Promise<boolean> | true,
87
89
  component?: unknown
88
90
  ];
89
91
  type CoordinatorRouter = AnyRouter & {
90
92
  /** Active speculative lanes retained for cancellation, invalidation, and cache clearing. */
91
93
  _preloads?: Map<AbortController, Array<AnyRouteMatch>>;
92
94
  _refreshNextLoad?: boolean;
93
- _cancelTransition?: () => void;
94
95
  };
95
96
  type BackgroundLoaderTask = [
96
97
  index: number,
@@ -100,14 +101,13 @@ type BackgroundLoaderTask = [
100
101
  ];
101
102
  export declare function waitFor<T>(value: T | PromiseLike<T>, signal: AbortSignal): Promise<T>;
102
103
  export declare function getRoute(router: AnyRouter, match: WorkMatch): AnyRoute;
103
- export declare function navigateFrom(router: AnyRouter, location: ParsedLocation): (opts: any) => Promise<void>;
104
104
  export declare function cacheLoaderMatch(router: CoordinatorRouter, match: SettledMatch, planned: AnyRouteMatch | undefined): void;
105
105
  export declare function projectLane(router: AnyRouter, lane: ReducedLane, signal: AbortSignal, start?: number, end?: number): Promise<ProjectedLane>;
106
106
  export declare function loadClientRoute(router: CoordinatorRouter, opts?: {
107
107
  sync?: boolean;
108
108
  }): Promise<void>;
109
109
  export declare function refreshClientRoute(router: CoordinatorRouter): Promise<void>;
110
- export declare function preloadClientRoute(router: CoordinatorRouter, opts: any, redirects?: number): Promise<Array<AnyRouteMatch> | undefined>;
110
+ export declare function preloadClientRoute(router: CoordinatorRouter, opts: any, redirects?: number, builtLocation?: ParsedLocation): Promise<Array<AnyRouteMatch> | undefined>;
111
111
  declare global {
112
112
  interface Window {
113
113
  [GLOBAL_TSR]?: TsrSsrGlobal;