@tanstack/react-router 0.0.1-beta.204 → 0.0.1-beta.206
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/RouterProvider.js +963 -0
- package/build/cjs/RouterProvider.js.map +1 -0
- package/build/cjs/fileRoute.js +29 -0
- package/build/cjs/fileRoute.js.map +1 -0
- package/build/cjs/index.js +69 -21
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/path.js +211 -0
- package/build/cjs/path.js.map +1 -0
- package/build/cjs/qss.js +65 -0
- package/build/cjs/qss.js.map +1 -0
- package/build/cjs/react.js +148 -190
- package/build/cjs/react.js.map +1 -1
- package/build/cjs/redirects.js +27 -0
- package/build/cjs/redirects.js.map +1 -0
- package/build/cjs/route.js +136 -0
- package/build/cjs/route.js.map +1 -0
- package/build/cjs/router.js +203 -0
- package/build/cjs/router.js.map +1 -0
- package/build/cjs/searchParams.js +83 -0
- package/build/cjs/searchParams.js.map +1 -0
- package/build/cjs/utils.js +196 -0
- package/build/cjs/utils.js.map +1 -0
- package/build/esm/index.js +1801 -211
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +385 -164
- package/build/types/RouteMatch.d.ts +23 -0
- package/build/types/RouterProvider.d.ts +54 -0
- package/build/types/awaited.d.ts +0 -8
- package/build/types/defer.d.ts +0 -0
- package/build/types/fileRoute.d.ts +17 -0
- package/build/types/history.d.ts +7 -0
- package/build/types/index.d.ts +17 -4
- package/build/types/link.d.ts +98 -0
- package/build/types/location.d.ts +14 -0
- package/build/types/path.d.ts +16 -0
- package/build/types/qss.d.ts +2 -0
- package/build/types/react.d.ts +23 -83
- package/build/types/redirects.d.ts +10 -0
- package/build/types/route.d.ts +222 -0
- package/build/types/routeInfo.d.ts +22 -0
- package/build/types/router.d.ts +115 -0
- package/build/types/scroll-restoration.d.ts +0 -3
- package/build/types/searchParams.d.ts +7 -0
- package/build/types/utils.d.ts +48 -0
- package/build/umd/index.development.js +1118 -1540
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +2 -33
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -4
- package/src/RouteMatch.ts +28 -0
- package/src/RouterProvider.tsx +1390 -0
- package/src/awaited.tsx +40 -40
- package/src/defer.ts +55 -0
- package/src/fileRoute.ts +143 -0
- package/src/history.ts +8 -0
- package/src/index.tsx +18 -5
- package/src/link.ts +347 -0
- package/src/location.ts +14 -0
- package/src/path.ts +256 -0
- package/src/qss.ts +53 -0
- package/src/react.tsx +174 -422
- package/src/redirects.ts +31 -0
- package/src/route.ts +710 -0
- package/src/routeInfo.ts +68 -0
- package/src/router.ts +373 -0
- package/src/scroll-restoration.tsx +205 -27
- package/src/searchParams.ts +78 -0
- package/src/utils.ts +257 -0
- package/build/cjs/awaited.js +0 -45
- package/build/cjs/awaited.js.map +0 -1
- package/build/cjs/scroll-restoration.js +0 -56
- package/build/cjs/scroll-restoration.js.map +0 -1
package/src/redirects.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { NavigateOptions } from './link'
|
|
2
|
+
import { AnyRoute } from './route'
|
|
3
|
+
import { RoutePaths } from './routeInfo'
|
|
4
|
+
import { RegisteredRouter } from './router'
|
|
5
|
+
|
|
6
|
+
// Detect if we're in the DOM
|
|
7
|
+
|
|
8
|
+
export type AnyRedirect = Redirect<any, any, any>
|
|
9
|
+
|
|
10
|
+
export type Redirect<
|
|
11
|
+
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
12
|
+
TFrom extends RoutePaths<TRouteTree> = '/',
|
|
13
|
+
TTo extends string = '',
|
|
14
|
+
TMaskFrom extends RoutePaths<TRouteTree> = TFrom,
|
|
15
|
+
TMaskTo extends string = '',
|
|
16
|
+
> = NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {
|
|
17
|
+
code?: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function redirect<
|
|
21
|
+
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
22
|
+
TFrom extends RoutePaths<TRouteTree> = '/',
|
|
23
|
+
TTo extends string = '',
|
|
24
|
+
>(opts: Redirect<TRouteTree, TFrom, TTo>): Redirect<TRouteTree, TFrom, TTo> {
|
|
25
|
+
;(opts as any).isRedirect = true
|
|
26
|
+
return opts
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function isRedirect(obj: any): obj is AnyRedirect {
|
|
30
|
+
return !!obj?.isRedirect
|
|
31
|
+
}
|