@tanstack/router-core 0.0.1-beta.167 → 0.0.1-beta.168

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.
@@ -188,9 +188,9 @@ interface RouterOptions<TRouteTree extends AnyRoute, TDehydrated extends Record<
188
188
  parseSearch?: SearchParser;
189
189
  defaultPreload?: false | 'intent';
190
190
  defaultPreloadDelay?: number;
191
- defaultComponent?: RegisteredRouteComponent<RegisteredRouteProps<unknown, AnySearchSchema, AnyPathParams, AnyContext, AnyContext>>;
192
- defaultErrorComponent?: RegisteredRouteErrorComponent<RegisteredErrorRouteProps<AnySearchSchema, AnyPathParams, AnyContext, AnyContext>>;
193
- defaultPendingComponent?: RegisteredRouteComponent<RegisteredRouteProps<unknown, AnySearchSchema, AnyPathParams, AnyContext, AnyContext>>;
191
+ defaultComponent?: RegisteredRouteComponent<unknown, AnySearchSchema, AnyPathParams, AnyContext, AnyContext>;
192
+ defaultErrorComponent?: RegisteredErrorRouteComponent<AnySearchSchema, AnyPathParams, AnyContext, AnyContext>;
193
+ defaultPendingComponent?: RegisteredPendingRouteComponent<AnySearchSchema, AnyPathParams, AnyContext, AnyContext>;
194
194
  defaultMaxAge?: number;
195
195
  defaultGcMaxAge?: number;
196
196
  defaultPreloadMaxAge?: number;
@@ -370,9 +370,11 @@ interface RouteMeta {
370
370
  }
371
371
  interface RouteContext {
372
372
  }
373
- interface RegisterRouteComponent<TProps> {
373
+ interface RegisterRouteComponent<TLoader = unknown, TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> {
374
374
  }
375
- interface RegisterRouteErrorComponent<TProps> {
375
+ interface RegisterErrorRouteComponent<TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> {
376
+ }
377
+ interface RegisterPendingRouteComponent<TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> {
376
378
  }
377
379
  interface RegisterRouteProps<TLoader = unknown, TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> {
378
380
  }
@@ -380,21 +382,24 @@ interface RegisterErrorRouteProps<TFullSearchSchema extends AnySearchSchema = An
380
382
  }
381
383
  interface RegisterPendingRouteProps<TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> {
382
384
  }
383
- type RegisteredRouteComponent<TProps> = RegisterRouteComponent<TProps> extends {
385
+ type RegisteredRouteComponent<TLoader = unknown, TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> = RegisterRouteComponent<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TAllContext> extends {
384
386
  RouteComponent: infer T;
385
- } ? T : (props: TProps) => unknown;
386
- type RegisteredRouteErrorComponent<TProps> = RegisterRouteErrorComponent<TProps> extends {
387
- RouteErrorComponent: infer T;
388
- } ? T : (props: TProps) => unknown;
387
+ } ? T : () => unknown;
388
+ type RegisteredErrorRouteComponent<TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> = RegisterErrorRouteComponent<TFullSearchSchema, TAllParams, TRouteContext, TAllContext> extends {
389
+ ErrorRouteComponent: infer T;
390
+ } ? T : () => unknown;
391
+ type RegisteredPendingRouteComponent<TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> = RegisterPendingRouteComponent<TFullSearchSchema, TAllParams, TRouteContext, TAllContext> extends {
392
+ PendingRouteComponent: infer T;
393
+ } ? T : () => unknown;
389
394
  type RegisteredRouteProps<TLoader = unknown, TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> = RegisterRouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TAllContext> extends {
390
395
  RouteProps: infer T;
391
- } ? T : (props: {}) => unknown;
396
+ } ? T : {};
392
397
  type RegisteredErrorRouteProps<TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> = RegisterRouteProps<TFullSearchSchema, TAllParams, TRouteContext, TAllContext> extends {
393
398
  ErrorRouteProps: infer T;
394
- } ? T : (props: {}) => unknown;
399
+ } ? T : {};
395
400
  type RegisteredPendingRouteProps<TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> = RegisterRouteProps<TFullSearchSchema, TAllParams, TRouteContext, TAllContext> extends {
396
401
  PendingRouteProps: infer T;
397
- } ? T : (props: {}) => unknown;
402
+ } ? T : {};
398
403
  type PreloadableObj = {
399
404
  preload?: () => Promise<void>;
400
405
  };
@@ -447,9 +452,9 @@ type UpdatableRouteOptions<TLoader, TSearchSchema extends AnySearchSchema, TFull
447
452
  key?: null | false | GetKeyFn<TFullSearchSchema, TAllParams>;
448
453
  caseSensitive?: boolean;
449
454
  wrapInSuspense?: boolean;
450
- component?: RegisteredRouteComponent<RegisteredRouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TAllContext>>;
451
- errorComponent?: RegisteredRouteErrorComponent<RegisteredErrorRouteProps<TFullSearchSchema, TAllParams, TRouteContext, TAllContext>>;
452
- pendingComponent?: RegisteredRouteComponent<RegisteredPendingRouteProps<TFullSearchSchema, TAllParams, TRouteContext, TAllContext>>;
455
+ component?: RegisteredRouteComponent<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TAllContext>;
456
+ errorComponent?: RegisteredErrorRouteComponent<TFullSearchSchema, TAllParams, TRouteContext, TAllContext>;
457
+ pendingComponent?: RegisteredPendingRouteComponent<TFullSearchSchema, TAllParams, TRouteContext, TAllContext>;
453
458
  preSearchFilters?: SearchFilter<TFullSearchSchema>[];
454
459
  postSearchFilters?: SearchFilter<TFullSearchSchema>[];
455
460
  preloadMaxAge?: number;
@@ -616,9 +621,9 @@ declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute e
616
621
  key?: false | GetKeyFn<TFullSearchSchema, TAllParams> | null | undefined;
617
622
  caseSensitive?: boolean | undefined;
618
623
  wrapInSuspense?: boolean | undefined;
619
- component?: ((props: (props: {}) => unknown) => unknown) | undefined;
620
- errorComponent?: ((props: (props: {}) => unknown) => unknown) | undefined;
621
- pendingComponent?: ((props: (props: {}) => unknown) => unknown) | undefined;
624
+ component?: (() => unknown) | undefined;
625
+ errorComponent?: (() => unknown) | undefined;
626
+ pendingComponent?: (() => unknown) | undefined;
622
627
  preSearchFilters?: SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
623
628
  postSearchFilters?: SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
624
629
  preloadMaxAge?: number | undefined;
@@ -775,4 +780,4 @@ type DeferredPromise<T> = Promise<T> & {
775
780
  declare function defer<T>(_promise: Promise<T>): DeferredPromise<T>;
776
781
  declare function isDehydratedDeferred(obj: any): boolean;
777
782
 
778
- export { ActiveOptions, AllParams, AnyContext, AnyPathParams, AnyRedirect, AnyRootRoute, AnyRoute, AnyRouteMatch, AnyRouteProps, AnyRouter, AnySearchSchema, BaseRouteOptions, BuildNextOptions, CheckId, CheckIdError, CheckPath, CheckPathError, CheckRelativePath, CleanPath, ComponentFromRoute, ComponentPropsFromRoute, DeepAwaited, DeferredPromise, DeferredPromiseState, DefinedPathParamWarning, DehydratedRouteMatch, DehydratedRouter, DehydratedRouterState, Expand, FileRoute, FileRoutePath, FileRoutesByPath, FromLocation, FullSearchSchema, GetKeyFn, HydrationCtx, InferFullSearchSchema, IsAny, IsAnyBoolean, IsKnown, Join, Last, LinkInfo, LinkOptions, ListenerFn, LoaderContext, LoaderFn, LocationState, MatchLocation, MatchRouteOptions, MergeParamsFromParent, MergeUnion, MetaOptions, NavigateOptions, NoInfer, ParamsFallback, ParentParams, ParseParamsFn, ParseParamsObj, ParseParamsOption, ParsePathParams, ParseRoute, ParseRouteChildren, ParsedLocation, ParsedPath, PathParamError, PathParamMask, PathParamOptions, PickAsPartial, PickAsRequired, PickExclude, PickExtra, PickExtract, PickRequired, PickUnsafe, PreloadableObj, Redirect, Register, RegisterErrorRouteProps, RegisterPendingRouteProps, RegisterRouteComponent, RegisterRouteErrorComponent, RegisterRouteProps, RegisteredErrorRouteProps, RegisteredPendingRouteProps, RegisteredRouteComponent, RegisteredRouteErrorComponent, RegisteredRouteProps, RegisteredRouter, RelativeToPathAutoComplete, RemoveUnderScores, ResolveFilePath, ResolveFullPath, ResolveFullSearchSchema, ResolveId, ResolveRelativePath, RootRoute, RootRouteId, Route, RouteById, RouteByPath, RouteConstraints, RouteContext, RouteIds, RouteLoaderFromRoute, RouteMatch, RouteMeta, RouteOptions, RoutePathOptions, RoutePathOptionsIntersection, RoutePaths, Router, RouterConstructorOptions, RouterContext, RouterContextOptions, RouterEvent, RouterEvents, RouterHistory, RouterListener, RouterLocation, RouterOptions, RouterState, RoutesById, RoutesByPath, ScrollRestorationOptions, SearchFilter, SearchParamError, SearchParamOptions, SearchParser, SearchSchemaValidator, SearchSchemaValidatorFn, SearchSchemaValidatorObj, SearchSerializer, Segment, Split, StreamedPromise, Timeout, ToIdOption, ToOptions, ToPathOption, Trim, TrimLeft, TrimPath, TrimPathLeft, TrimPathRight, TrimRight, UnionToIntersection, UnloaderFn, UpdatableRouteOptions, Updater, UseLoaderResult, ValueKeys, Values, cleanPath, componentTypes, createBrowserHistory, createHashHistory, createMemoryHistory, decode, defaultParseSearch, defaultStringifySearch, defer, encode, functionalUpdate, interpolatePath, isDehydratedDeferred, isPlainObject, isRedirect, joinPaths, last, lazyFn, matchByPath, matchPathname, parsePathname, parseSearchWith, partialDeepEqual, pick, redirect, replaceEqualDeep, resolvePath, restoreScrollPositions, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight, watchScrollPositions };
783
+ export { ActiveOptions, AllParams, AnyContext, AnyPathParams, AnyRedirect, AnyRootRoute, AnyRoute, AnyRouteMatch, AnyRouteProps, AnyRouter, AnySearchSchema, BaseRouteOptions, BuildNextOptions, CheckId, CheckIdError, CheckPath, CheckPathError, CheckRelativePath, CleanPath, ComponentFromRoute, ComponentPropsFromRoute, DeepAwaited, DeferredPromise, DeferredPromiseState, DefinedPathParamWarning, DehydratedRouteMatch, DehydratedRouter, DehydratedRouterState, Expand, FileRoute, FileRoutePath, FileRoutesByPath, FromLocation, FullSearchSchema, GetKeyFn, HydrationCtx, InferFullSearchSchema, IsAny, IsAnyBoolean, IsKnown, Join, Last, LinkInfo, LinkOptions, ListenerFn, LoaderContext, LoaderFn, LocationState, MatchLocation, MatchRouteOptions, MergeParamsFromParent, MergeUnion, MetaOptions, NavigateOptions, NoInfer, ParamsFallback, ParentParams, ParseParamsFn, ParseParamsObj, ParseParamsOption, ParsePathParams, ParseRoute, ParseRouteChildren, ParsedLocation, ParsedPath, PathParamError, PathParamMask, PathParamOptions, PickAsPartial, PickAsRequired, PickExclude, PickExtra, PickExtract, PickRequired, PickUnsafe, PreloadableObj, Redirect, Register, RegisterErrorRouteComponent, RegisterErrorRouteProps, RegisterPendingRouteComponent, RegisterPendingRouteProps, RegisterRouteComponent, RegisterRouteProps, RegisteredErrorRouteComponent, RegisteredErrorRouteProps, RegisteredPendingRouteComponent, RegisteredPendingRouteProps, RegisteredRouteComponent, RegisteredRouteProps, RegisteredRouter, RelativeToPathAutoComplete, RemoveUnderScores, ResolveFilePath, ResolveFullPath, ResolveFullSearchSchema, ResolveId, ResolveRelativePath, RootRoute, RootRouteId, Route, RouteById, RouteByPath, RouteConstraints, RouteContext, RouteIds, RouteLoaderFromRoute, RouteMatch, RouteMeta, RouteOptions, RoutePathOptions, RoutePathOptionsIntersection, RoutePaths, Router, RouterConstructorOptions, RouterContext, RouterContextOptions, RouterEvent, RouterEvents, RouterHistory, RouterListener, RouterLocation, RouterOptions, RouterState, RoutesById, RoutesByPath, ScrollRestorationOptions, SearchFilter, SearchParamError, SearchParamOptions, SearchParser, SearchSchemaValidator, SearchSchemaValidatorFn, SearchSchemaValidatorObj, SearchSerializer, Segment, Split, StreamedPromise, Timeout, ToIdOption, ToOptions, ToPathOption, Trim, TrimLeft, TrimPath, TrimPathLeft, TrimPathRight, TrimRight, UnionToIntersection, UnloaderFn, UpdatableRouteOptions, Updater, UseLoaderResult, ValueKeys, Values, cleanPath, componentTypes, createBrowserHistory, createHashHistory, createMemoryHistory, decode, defaultParseSearch, defaultStringifySearch, defer, encode, functionalUpdate, interpolatePath, isDehydratedDeferred, isPlainObject, isRedirect, joinPaths, last, lazyFn, matchByPath, matchPathname, parsePathname, parseSearchWith, partialDeepEqual, pick, redirect, replaceEqualDeep, resolvePath, restoreScrollPositions, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight, watchScrollPositions };
@@ -1153,8 +1153,8 @@
1153
1153
  params: routeParams,
1154
1154
  pathname: joinPaths([this.basepath, interpolatedPath]),
1155
1155
  updatedAt: Date.now(),
1156
- invalidAt: 9999999999999,
1157
- preloadInvalidAt: 9999999999999,
1156
+ invalidAt: Infinity,
1157
+ preloadInvalidAt: Infinity,
1158
1158
  routeSearch: {},
1159
1159
  search: {},
1160
1160
  status: hasLoaders ? 'pending' : 'success',
@@ -1237,7 +1237,6 @@
1237
1237
  return matches;
1238
1238
  };
1239
1239
  loadMatches = async (resolvedMatches, opts) => {
1240
- this.cleanMatches();
1241
1240
  if (!opts?.preload) {
1242
1241
  resolvedMatches.forEach(match => {
1243
1242
  // Update each match with its latest route data
@@ -1250,10 +1249,12 @@
1250
1249
  error: match.error,
1251
1250
  paramsError: match.paramsError,
1252
1251
  searchError: match.searchError,
1253
- params: match.params
1252
+ params: match.params,
1253
+ preloadInvalidAt: 0
1254
1254
  }));
1255
1255
  });
1256
1256
  }
1257
+ this.cleanMatches();
1257
1258
  let firstBadMatchIndex;
1258
1259
 
1259
1260
  // Check each match middleware to see if the route can be accessed
@@ -1389,6 +1390,7 @@
1389
1390
  })());
1390
1391
  });
1391
1392
  await Promise.all(matchPromises);
1393
+ this.cleanMatches();
1392
1394
  };
1393
1395
  reload = () => {
1394
1396
  return this.navigate({
@@ -1832,7 +1834,7 @@
1832
1834
  const route = this.getRoute(match.routeId);
1833
1835
  const updatedAt = opts?.updatedAt ?? Date.now();
1834
1836
  const preloadInvalidAt = updatedAt + (opts?.maxAge ?? route.options.preloadMaxAge ?? this.options.defaultPreloadMaxAge ?? 5000);
1835
- const invalidAt = updatedAt + (opts?.maxAge ?? route.options.maxAge ?? this.options.defaultMaxAge ?? 9999999999999);
1837
+ const invalidAt = updatedAt + (opts?.maxAge ?? route.options.maxAge ?? this.options.defaultMaxAge ?? Infinity);
1836
1838
  this.setRouteMatch(id, s => ({
1837
1839
  ...s,
1838
1840
  error: undefined,
@@ -1843,7 +1845,6 @@
1843
1845
  preloadInvalidAt,
1844
1846
  invalidAt
1845
1847
  }));
1846
- if (this.state.matches.find(d => d.id === id)) ;
1847
1848
  };
1848
1849
  invalidate = async opts => {
1849
1850
  if (opts?.matchId) {