@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/build/cjs/fileRoute.js +4 -0
- package/build/cjs/fileRoute.js.map +1 -1
- package/build/cjs/index.js +1 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/link.js.map +1 -1
- package/build/cjs/route.js +4 -0
- package/build/cjs/route.js.map +1 -1
- package/build/cjs/router.js.map +1 -1
- package/build/esm/index.js +8 -1
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +355 -355
- package/build/types/fileRoute.d.ts +4 -2
- package/build/types/route.d.ts +3 -0
- package/build/types/router.d.ts +1 -1
- package/build/umd/index.development.js +8 -0
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/fileRoute.ts +27 -1
- package/src/link.tsx +11 -3
- package/src/route.ts +33 -0
- package/src/router.ts +3 -1
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.
|
|
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.
|
|
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
|
|
178
|
-
|
|
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 (
|
|
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
|
}
|