@tanstack/react-router 1.15.6 → 1.15.9

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/src/route.ts CHANGED
@@ -213,7 +213,11 @@ export type UpdatableRouteOptions<
213
213
  onEnter?: (match: AnyRouteMatch) => void
214
214
  onStay?: (match: AnyRouteMatch) => void
215
215
  onLeave?: (match: AnyRouteMatch) => void
216
- meta?: (ctx: { loaderData: TLoaderData }) => JSX.IntrinsicElements['meta'][]
216
+ meta?: (ctx: {
217
+ loaderData: TLoaderData
218
+ }) =>
219
+ | JSX.IntrinsicElements['meta'][]
220
+ | Promise<JSX.IntrinsicElements['meta'][]>
217
221
  links?: () => JSX.IntrinsicElements['link'][]
218
222
  scripts?: () => JSX.IntrinsicElements['script'][]
219
223
  } & UpdatableStaticRouteOption
@@ -371,11 +375,12 @@ export type MergeFromFromParent<T, U> = IsAny<T, U, T & U>
371
375
  export type ResolveAllParams<
372
376
  TParentRoute extends AnyRoute,
373
377
  TParams extends AnyPathParams,
374
- > = Record<never, string> extends TParentRoute['types']['allParams']
375
- ? TParams
376
- : Expand<
377
- UnionToIntersection<TParentRoute['types']['allParams'] & TParams> & {}
378
- >
378
+ > =
379
+ Record<never, string> extends TParentRoute['types']['allParams']
380
+ ? TParams
381
+ : Expand<
382
+ UnionToIntersection<TParentRoute['types']['allParams'] & TParams> & {}
383
+ >
379
384
 
380
385
  export type RouteConstraints = {
381
386
  TParentRoute: AnyRoute
@@ -516,9 +521,6 @@ export function getRouteApi<
516
521
  >({ id })
517
522
  }
518
523
 
519
- /**
520
- * @deprecated Use the `getRouteApi` function instead.
521
- */
522
524
  export class RouteApi<
523
525
  TId extends RouteIds<RegisteredRouter['routeTree']>,
524
526
  TRoute extends AnyRoute = RouteById<RegisteredRouter['routeTree'], TId>,
@@ -533,6 +535,9 @@ export class RouteApi<
533
535
  > {
534
536
  id: TId
535
537
 
538
+ /**
539
+ * @deprecated Use the `getRouteApi` function instead.
540
+ */
536
541
  constructor({ id }: { id: TId }) {
537
542
  this.id = id as any
538
543
  }
@@ -1063,15 +1068,12 @@ export function createRootRouteWithContext<TRouterContext extends {}>() {
1063
1068
  /**
1064
1069
  * @deprecated Use the `createRootRouteWithContext` function instead.
1065
1070
  */
1066
- export const rootRouteWithContext = createRootRouteWithContext;
1071
+ export const rootRouteWithContext = createRootRouteWithContext
1067
1072
 
1068
1073
  export type RootSearchSchema = {
1069
1074
  __TRootSearchSchema__: '__TRootSearchSchema__'
1070
1075
  }
1071
1076
 
1072
- /**
1073
- * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
1074
- */
1075
1077
  export class RootRoute<
1076
1078
  TSearchSchemaInput extends Record<string, any> = RootSearchSchema,
1077
1079
  TSearchSchema extends Record<string, any> = RootSearchSchema,
@@ -1105,6 +1107,9 @@ export class RootRoute<
1105
1107
  any, // TChildren
1106
1108
  any // TRouteTree
1107
1109
  > {
1110
+ /**
1111
+ * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
1112
+ */
1108
1113
  constructor(
1109
1114
  options?: Omit<
1110
1115
  RouteOptions<
package/src/router.ts CHANGED
@@ -1323,7 +1323,7 @@ export class Router<
1323
1323
 
1324
1324
  // wrap loader into an async function to be able to catch synchronous exceptions
1325
1325
  async function loader() {
1326
- await route.options.loader?.(loaderContext)
1326
+ return await route.options.loader?.(loaderContext)
1327
1327
  }
1328
1328
  // Kick off the loader!
1329
1329
  const loaderPromise = loader()
@@ -1356,7 +1356,7 @@ export class Router<
1356
1356
 
1357
1357
  if ((latestPromise = checkLatest())) return await latestPromise
1358
1358
 
1359
- const meta = route.options.meta?.({
1359
+ const meta = await route.options.meta?.({
1360
1360
  loaderData,
1361
1361
  })
1362
1362
 
@@ -1714,14 +1714,11 @@ export class Router<
1714
1714
  const id = `__TSR_DEHYDRATED__${strKey}`
1715
1715
  const data =
1716
1716
  typeof getData === 'function' ? await (getData as any)() : getData
1717
- return `<script id='${id}' suppressHydrationWarning>window["__TSR_DEHYDRATED__${escapeJSON(
1718
- strKey,
1719
- )}"] = ${JSON.stringify(this.options.transformer.stringify(data))}
1720
- ;(() => {
1721
- var el = document.getElementById('${id}')
1722
- el.parentElement.removeChild(el)
1723
- })()
1724
- </script>`
1717
+ return `<script id='${id}' suppressHydrationWarning>
1718
+ window["__TSR_DEHYDRATED__${escapeJSON(
1719
+ strKey,
1720
+ )}"] = ${JSON.stringify(this.options.transformer.stringify(data))}
1721
+ </script>`
1725
1722
  })
1726
1723
 
1727
1724
  return () => this.hydrateData<T>(key)