@tanstack/react-router 0.0.1-beta.2 → 0.0.1-beta.20
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/react-router/src/index.js +95 -117
- package/build/cjs/react-router/src/index.js.map +1 -1
- package/build/cjs/router-core/build/esm/index.js +257 -227
- package/build/cjs/router-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +344 -343
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +29 -29
- package/build/types/index.d.ts +42 -10
- package/build/umd/index.development.js +351 -343
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +2 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +3 -2
- package/src/index.tsx +172 -136
package/build/stats-html.html
CHANGED
|
@@ -4014,7 +4014,7 @@ var drawChart = (function (exports) {
|
|
|
4014
4014
|
</script>
|
|
4015
4015
|
<script>
|
|
4016
4016
|
/*<!--*/
|
|
4017
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"uid":"
|
|
4017
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"uid":"877b-59","name":"\u0000rollupPluginBabelHelpers.js"},{"name":"packages","children":[{"name":"router-core/build/esm/index.js","uid":"877b-61"},{"name":"react-router/src/index.tsx","uid":"877b-63"}]}]}],"isRoot":true},"nodeParts":{"877b-59":{"renderedLength":798,"gzipLength":366,"brotliLength":0,"mainUid":"877b-58"},"877b-61":{"renderedLength":75162,"gzipLength":15777,"brotliLength":0,"mainUid":"877b-60"},"877b-63":{"renderedLength":12237,"gzipLength":3143,"brotliLength":0,"mainUid":"877b-62"}},"nodeMetas":{"877b-58":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"877b-59"},"imported":[],"importedBy":[{"uid":"877b-62"}]},"877b-60":{"id":"/packages/router-core/build/esm/index.js","moduleParts":{"index.production.js":"877b-61"},"imported":[],"importedBy":[{"uid":"877b-62"}]},"877b-62":{"id":"/packages/react-router/src/index.tsx","moduleParts":{"index.production.js":"877b-63"},"imported":[{"uid":"877b-58"},{"uid":"877b-64"},{"uid":"877b-65"},{"uid":"877b-60"}],"importedBy":[],"isEntry":true},"877b-64":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"877b-62"}],"isExternal":true},"877b-65":{"id":"use-sync-external-store/shim","moduleParts":{},"imported":[],"importedBy":[{"uid":"877b-62"}],"isExternal":true}},"env":{"rollup":"2.77.2"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
4018
4018
|
|
|
4019
4019
|
const run = () => {
|
|
4020
4020
|
const width = window.innerWidth;
|
package/build/stats-react.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"name": "index.production.js",
|
|
8
8
|
"children": [
|
|
9
9
|
{
|
|
10
|
-
"uid": "
|
|
10
|
+
"uid": "877b-67",
|
|
11
11
|
"name": "\u0000rollupPluginBabelHelpers.js"
|
|
12
12
|
},
|
|
13
13
|
{
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"children": [
|
|
16
16
|
{
|
|
17
17
|
"name": "router-core/build/esm/index.js",
|
|
18
|
-
"uid": "
|
|
18
|
+
"uid": "877b-69"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"name": "react-router/src/index.tsx",
|
|
22
|
-
"uid": "
|
|
22
|
+
"uid": "877b-71"
|
|
23
23
|
}
|
|
24
24
|
]
|
|
25
25
|
}
|
|
@@ -29,90 +29,90 @@
|
|
|
29
29
|
"isRoot": true
|
|
30
30
|
},
|
|
31
31
|
"nodeParts": {
|
|
32
|
-
"
|
|
32
|
+
"877b-67": {
|
|
33
33
|
"renderedLength": 798,
|
|
34
34
|
"gzipLength": 366,
|
|
35
35
|
"brotliLength": 0,
|
|
36
|
-
"mainUid": "
|
|
36
|
+
"mainUid": "877b-66"
|
|
37
37
|
},
|
|
38
|
-
"
|
|
39
|
-
"renderedLength":
|
|
40
|
-
"gzipLength":
|
|
38
|
+
"877b-69": {
|
|
39
|
+
"renderedLength": 75162,
|
|
40
|
+
"gzipLength": 15777,
|
|
41
41
|
"brotliLength": 0,
|
|
42
|
-
"mainUid": "
|
|
42
|
+
"mainUid": "877b-68"
|
|
43
43
|
},
|
|
44
|
-
"
|
|
45
|
-
"renderedLength":
|
|
46
|
-
"gzipLength":
|
|
44
|
+
"877b-71": {
|
|
45
|
+
"renderedLength": 12237,
|
|
46
|
+
"gzipLength": 3143,
|
|
47
47
|
"brotliLength": 0,
|
|
48
|
-
"mainUid": "
|
|
48
|
+
"mainUid": "877b-70"
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"nodeMetas": {
|
|
52
|
-
"
|
|
52
|
+
"877b-66": {
|
|
53
53
|
"id": "\u0000rollupPluginBabelHelpers.js",
|
|
54
54
|
"moduleParts": {
|
|
55
|
-
"index.production.js": "
|
|
55
|
+
"index.production.js": "877b-67"
|
|
56
56
|
},
|
|
57
57
|
"imported": [],
|
|
58
58
|
"importedBy": [
|
|
59
59
|
{
|
|
60
|
-
"uid": "
|
|
60
|
+
"uid": "877b-70"
|
|
61
61
|
}
|
|
62
62
|
]
|
|
63
63
|
},
|
|
64
|
-
"
|
|
64
|
+
"877b-68": {
|
|
65
65
|
"id": "/packages/router-core/build/esm/index.js",
|
|
66
66
|
"moduleParts": {
|
|
67
|
-
"index.production.js": "
|
|
67
|
+
"index.production.js": "877b-69"
|
|
68
68
|
},
|
|
69
69
|
"imported": [],
|
|
70
70
|
"importedBy": [
|
|
71
71
|
{
|
|
72
|
-
"uid": "
|
|
72
|
+
"uid": "877b-70"
|
|
73
73
|
}
|
|
74
74
|
]
|
|
75
75
|
},
|
|
76
|
-
"
|
|
76
|
+
"877b-70": {
|
|
77
77
|
"id": "/packages/react-router/src/index.tsx",
|
|
78
78
|
"moduleParts": {
|
|
79
|
-
"index.production.js": "
|
|
79
|
+
"index.production.js": "877b-71"
|
|
80
80
|
},
|
|
81
81
|
"imported": [
|
|
82
82
|
{
|
|
83
|
-
"uid": "
|
|
83
|
+
"uid": "877b-66"
|
|
84
84
|
},
|
|
85
85
|
{
|
|
86
|
-
"uid": "
|
|
86
|
+
"uid": "877b-72"
|
|
87
87
|
},
|
|
88
88
|
{
|
|
89
|
-
"uid": "
|
|
89
|
+
"uid": "877b-73"
|
|
90
90
|
},
|
|
91
91
|
{
|
|
92
|
-
"uid": "
|
|
92
|
+
"uid": "877b-68"
|
|
93
93
|
}
|
|
94
94
|
],
|
|
95
95
|
"importedBy": [],
|
|
96
96
|
"isEntry": true
|
|
97
97
|
},
|
|
98
|
-
"
|
|
98
|
+
"877b-72": {
|
|
99
99
|
"id": "react",
|
|
100
100
|
"moduleParts": {},
|
|
101
101
|
"imported": [],
|
|
102
102
|
"importedBy": [
|
|
103
103
|
{
|
|
104
|
-
"uid": "
|
|
104
|
+
"uid": "877b-70"
|
|
105
105
|
}
|
|
106
106
|
],
|
|
107
107
|
"isExternal": true
|
|
108
108
|
},
|
|
109
|
-
"
|
|
109
|
+
"877b-73": {
|
|
110
110
|
"id": "use-sync-external-store/shim",
|
|
111
111
|
"moduleParts": {},
|
|
112
112
|
"imported": [],
|
|
113
113
|
"importedBy": [
|
|
114
114
|
{
|
|
115
|
-
"uid": "
|
|
115
|
+
"uid": "877b-70"
|
|
116
116
|
}
|
|
117
117
|
],
|
|
118
118
|
"isExternal": true
|
package/build/types/index.d.ts
CHANGED
|
@@ -9,18 +9,34 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
import * as React from 'react';
|
|
12
|
-
import { AnyRouteConfig, RouteConfig, AnyAllRouteInfo, AllRouteInfo, RouterState, RouteMatch, ToOptions, MatchRouteOptions, RouteInfoByPath, ResolveRelativePath, NoInfer, DefaultAllRouteInfo, AnyRouteInfo, RouteInfo, CheckId, ToIdOption, ValidFromPath, LinkOptions,
|
|
12
|
+
import { AnyRouteConfig, RouteConfig, AnyAllRouteInfo, AllRouteInfo, RouterState, RouteMatch, ToOptions, MatchRouteOptions, RouteInfoByPath, ResolveRelativePath, NoInfer, DefaultAllRouteInfo, AnyRouteInfo, RouteInfo, CheckId, ToIdOption, ValidFromPath, LinkOptions, Router, RouterOptions } from '@tanstack/router-core';
|
|
13
13
|
export * from '@tanstack/router-core';
|
|
14
14
|
|
|
15
|
+
interface RegisterRouter {
|
|
16
|
+
}
|
|
17
|
+
type ResolvedRouter = RegisterRouter extends {
|
|
18
|
+
router: Router<infer TRouteConfig, infer TAllRouteInfo>;
|
|
19
|
+
} ? Router<TRouteConfig, TAllRouteInfo> : Router;
|
|
20
|
+
type ResolvedAllRouteInfo = RegisterRouter extends {
|
|
21
|
+
router: Router<infer TRouteConfig, infer TAllRouteInfo>;
|
|
22
|
+
} ? TAllRouteInfo : AnyAllRouteInfo;
|
|
23
|
+
type SyncRouteComponent = (props?: {}) => JSX.Element | React.ReactNode;
|
|
24
|
+
type RouteComponent = SyncRouteComponent & {
|
|
25
|
+
preload?: () => Promise<SyncRouteComponent>;
|
|
26
|
+
};
|
|
27
|
+
declare function lazy(importer: () => Promise<{
|
|
28
|
+
default: SyncRouteComponent;
|
|
29
|
+
}>): RouteComponent;
|
|
15
30
|
declare module '@tanstack/router-core' {
|
|
16
31
|
interface FrameworkGenerics {
|
|
17
|
-
|
|
18
|
-
SyncOrAsyncElement: React.ReactNode | (() => Promise<any>);
|
|
32
|
+
Component: RouteComponent;
|
|
19
33
|
}
|
|
20
34
|
interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>> {
|
|
21
35
|
useState: () => RouterState;
|
|
22
36
|
useRoute: <TId extends keyof TAllRouteInfo['routeInfoById']>(routeId: TId) => Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]>;
|
|
23
|
-
useMatch: <TId extends keyof TAllRouteInfo['routeInfoById']>(routeId: TId
|
|
37
|
+
useMatch: <TId extends keyof TAllRouteInfo['routeInfoById'], TStrict extends true | false = true>(routeId: TId, opts?: {
|
|
38
|
+
strict?: TStrict;
|
|
39
|
+
}) => TStrict extends true ? RouteMatch<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]> : RouteMatch<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]> | undefined;
|
|
24
40
|
linkProps: <TTo extends string = '.'>(props: LinkPropsOptions<TAllRouteInfo, '/', TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement>) => React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
25
41
|
Link: <TTo extends string = '.'>(props: LinkPropsOptions<TAllRouteInfo, '/', TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement> & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {
|
|
26
42
|
children?: React.ReactNode | ((state: {
|
|
@@ -32,7 +48,9 @@ declare module '@tanstack/router-core' {
|
|
|
32
48
|
}) => JSX.Element;
|
|
33
49
|
}
|
|
34
50
|
interface Route<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo> {
|
|
35
|
-
useRoute: <TTo extends string = '.', TResolved extends string = ResolveRelativePath<TRouteInfo['id'], NoInfer<TTo>>>(routeId: CheckId<TAllRouteInfo, TResolved, ToIdOption<TAllRouteInfo, TRouteInfo['id'], TTo
|
|
51
|
+
useRoute: <TTo extends string = '.', TResolved extends string = ResolveRelativePath<TRouteInfo['id'], NoInfer<TTo>>>(routeId: CheckId<TAllRouteInfo, TResolved, ToIdOption<TAllRouteInfo, TRouteInfo['id'], TTo>>, opts?: {
|
|
52
|
+
strict?: boolean;
|
|
53
|
+
}) => Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TResolved]>;
|
|
36
54
|
linkProps: <TTo extends string = '.'>(props: LinkPropsOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement>) => React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
37
55
|
Link: <TTo extends string = '.'>(props: LinkPropsOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement> & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {
|
|
38
56
|
children?: React.ReactNode | ((state: {
|
|
@@ -44,26 +62,40 @@ declare module '@tanstack/router-core' {
|
|
|
44
62
|
}) => JSX.Element;
|
|
45
63
|
}
|
|
46
64
|
}
|
|
47
|
-
|
|
65
|
+
type LinkPropsOptions<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'> = LinkOptions<TAllRouteInfo, TFrom, TTo> & {
|
|
48
66
|
activeProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
|
|
49
67
|
inactiveProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
|
|
50
68
|
};
|
|
51
|
-
|
|
69
|
+
type PromptProps = {
|
|
52
70
|
message: string;
|
|
53
71
|
when?: boolean | any;
|
|
54
72
|
children?: React.ReactNode;
|
|
55
73
|
};
|
|
56
|
-
declare
|
|
74
|
+
declare function Link<TTo extends string = '.'>(props: LinkPropsOptions<ResolvedAllRouteInfo, '/', TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement> & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {
|
|
75
|
+
children?: React.ReactNode | ((state: {
|
|
76
|
+
isActive: boolean;
|
|
77
|
+
}) => React.ReactNode);
|
|
78
|
+
}): JSX.Element;
|
|
79
|
+
declare const matchesContext: React.Context<RouteMatch<DefaultAllRouteInfo, RouteInfo<string, string, string, string, {}, {}, {}, unknown, unknown, {}, {}, {}, {}, Record<never, string>, {}>>[]>;
|
|
80
|
+
declare const routerContext: React.Context<{
|
|
81
|
+
router: ResolvedRouter;
|
|
82
|
+
}>;
|
|
83
|
+
type MatchesProviderProps = {
|
|
57
84
|
value: RouteMatch[];
|
|
58
85
|
children: React.ReactNode;
|
|
59
86
|
};
|
|
60
87
|
declare function MatchesProvider(props: MatchesProviderProps): JSX.Element;
|
|
61
88
|
declare function createReactRouter<TRouteConfig extends AnyRouteConfig = RouteConfig>(opts: RouterOptions<TRouteConfig>): Router<TRouteConfig>;
|
|
62
|
-
|
|
89
|
+
type RouterProps<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo> = RouterOptions<TRouteConfig> & {
|
|
63
90
|
router: Router<TRouteConfig, TAllRouteInfo>;
|
|
64
91
|
children?: React.ReactNode;
|
|
65
92
|
};
|
|
66
93
|
declare function RouterProvider<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo>({ children, router, ...rest }: RouterProps<TRouteConfig, TAllRouteInfo>): JSX.Element;
|
|
94
|
+
declare function useRouter(): ResolvedRouter;
|
|
95
|
+
declare function useMatches(): RouteMatch[];
|
|
96
|
+
declare function useMatch<TId extends keyof ResolvedAllRouteInfo['routeInfoById'], TStrict extends true | false = true>(routeId: TId, opts?: {
|
|
97
|
+
strict?: TStrict;
|
|
98
|
+
}): TStrict extends true ? RouteMatch<ResolvedAllRouteInfo, ResolvedAllRouteInfo['routeInfoById'][TId]> : RouteMatch<ResolvedAllRouteInfo, ResolvedAllRouteInfo['routeInfoById'][TId]> | undefined;
|
|
67
99
|
declare function Outlet(): JSX.Element | null;
|
|
68
100
|
declare function DefaultErrorBoundary({ error }: {
|
|
69
101
|
error: any;
|
|
@@ -71,4 +103,4 @@ declare function DefaultErrorBoundary({ error }: {
|
|
|
71
103
|
declare function usePrompt(message: string, when: boolean | any): void;
|
|
72
104
|
declare function Prompt({ message, when, children }: PromptProps): React.ReactNode;
|
|
73
105
|
|
|
74
|
-
export { DefaultErrorBoundary, MatchesProvider, MatchesProviderProps, Outlet, Prompt, PromptProps, RouterProps, RouterProvider, createReactRouter, usePrompt };
|
|
106
|
+
export { DefaultErrorBoundary, Link, MatchesProvider, MatchesProviderProps, Outlet, Prompt, PromptProps, RegisterRouter, ResolvedAllRouteInfo, ResolvedRouter, RouteComponent, RouterProps, RouterProvider, SyncRouteComponent, createReactRouter, lazy, matchesContext, routerContext, useMatch, useMatches, usePrompt, useRouter };
|