@tanstack/react-router 1.1.5 → 1.1.7

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
3
  "author": "Tanner Linsley",
4
- "version": "1.1.5",
4
+ "version": "1.1.7",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router",
@@ -44,7 +44,7 @@
44
44
  "@tanstack/store": "^0.1.3",
45
45
  "tiny-invariant": "^1.3.1",
46
46
  "tiny-warning": "^1.0.3",
47
- "@tanstack/history": "1.1.5"
47
+ "@tanstack/history": "1.1.7"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "rollup --config rollup.config.js"
package/src/fileRoute.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { NoInfer } from '@tanstack/react-store'
1
2
  import { ParsePathParams } from './link'
2
3
  import {
3
4
  AnyRoute,
@@ -15,6 +16,8 @@ import {
15
16
  RouteConstraints,
16
17
  ResolveFullSearchSchemaInput,
17
18
  SearchSchemaInput,
19
+ LoaderFnContext,
20
+ RouteLoaderFn,
18
21
  } from './route'
19
22
  import { Assign, Expand, IsAny } from './utils'
20
23
 
@@ -93,7 +96,7 @@ export class FileRoute<
93
96
  string,
94
97
  any
95
98
  > = TSearchSchemaInput extends SearchSchemaInput
96
- ? TSearchSchemaInput
99
+ ? Omit<TSearchSchemaInput, keyof SearchSchemaInput>
97
100
  : TSearchSchema,
98
101
  TFullSearchSchemaInput extends
99
102
  RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchemaInput<
@@ -170,3 +173,26 @@ export class FileRoute<
170
173
  return route as any
171
174
  }
172
175
  }
176
+
177
+ export function FileRouteLoader<
178
+ TFilePath extends keyof FileRoutesByPath,
179
+ TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],
180
+ >(
181
+ _path: TFilePath,
182
+ ): <TLoaderData extends any>(
183
+ loaderFn: RouteLoaderFn<
184
+ TRoute['types']['allParams'],
185
+ TRoute['types']['loaderDeps'],
186
+ TRoute['types']['allContext'],
187
+ TRoute['types']['routeContext'],
188
+ TLoaderData
189
+ >,
190
+ ) => RouteLoaderFn<
191
+ TRoute['types']['allParams'],
192
+ TRoute['types']['loaderDeps'],
193
+ TRoute['types']['allContext'],
194
+ TRoute['types']['routeContext'],
195
+ NoInfer<TLoaderData>
196
+ > {
197
+ return (loaderFn) => loaderFn
198
+ }
package/src/link.tsx CHANGED
@@ -167,15 +167,23 @@ export type ToSubOptions<
167
167
 
168
168
  type ParamsReducer<TFrom, TTo> = TTo | ((current: TFrom) => TTo)
169
169
 
170
- type ParamVariant = 'PATH' | 'SEARCH';
170
+ type ParamVariant = 'PATH' | 'SEARCH'
171
171
  export type ParamOptions<
172
172
  TRouteTree extends AnyRoute,
173
173
  TFrom,
174
174
  TTo,
175
175
  TResolved,
176
176
  TParamVariant extends ParamVariant,
177
- TFromRouteType extends 'allParams' | 'fullSearchSchema' = TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchema',
178
- TToRouteType extends 'allParams' | 'fullSearchSchemaInput' = TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchemaInput',
177
+ TFromRouteType extends
178
+ | 'allParams'
179
+ | 'fullSearchSchema' = TParamVariant extends 'PATH'
180
+ ? 'allParams'
181
+ : 'fullSearchSchema',
182
+ TToRouteType extends
183
+ | 'allParams'
184
+ | 'fullSearchSchemaInput' = TParamVariant extends 'PATH'
185
+ ? 'allParams'
186
+ : 'fullSearchSchemaInput',
179
187
  TFromParams = Expand<RouteByPath<TRouteTree, TFrom>['types'][TFromRouteType]>,
180
188
  TToParams = TTo extends ''
181
189
  ? TFromParams
package/src/route.ts CHANGED
@@ -659,6 +659,39 @@ export class Route<
659
659
  return this as any
660
660
  }
661
661
 
662
+ updateLoader = <TNewLoaderData extends any = unknown>(options: {
663
+ loader: RouteLoaderFn<
664
+ TAllParams,
665
+ TLoaderDeps,
666
+ TAllContext,
667
+ TRouteContext,
668
+ TNewLoaderData
669
+ >
670
+ }) => {
671
+ Object.assign(this.options, options)
672
+ return this as unknown as Route<
673
+ TParentRoute,
674
+ TPath,
675
+ TFullPath,
676
+ TCustomId,
677
+ TId,
678
+ TSearchSchemaInput,
679
+ TSearchSchema,
680
+ TSearchSchemaUsed,
681
+ TFullSearchSchemaInput,
682
+ TFullSearchSchema,
683
+ TParams,
684
+ TAllParams,
685
+ TRouteContext,
686
+ TAllContext,
687
+ TRouterContext,
688
+ TLoaderDeps,
689
+ TNewLoaderData,
690
+ TChildren,
691
+ TRouteTree
692
+ >
693
+ }
694
+
662
695
  update = (options: UpdatableRouteOptions<TFullSearchSchema>) => {
663
696
  Object.assign(this.options, options)
664
697
  return this
package/src/router.ts CHANGED
@@ -1645,7 +1645,9 @@ export function lazyFn<
1645
1645
  T extends Record<string, (...args: any[]) => any>,
1646
1646
  TKey extends keyof T = 'default',
1647
1647
  >(fn: () => Promise<T>, key?: TKey) {
1648
- return async (...args: Parameters<T[TKey]>): Promise<ReturnType<T[TKey]>> => {
1648
+ return async (
1649
+ ...args: Parameters<T[TKey]>
1650
+ ): Promise<Awaited<ReturnType<T[TKey]>>> => {
1649
1651
  const imported = await fn()
1650
1652
  return imported[key || 'default'](...args)
1651
1653
  }