@tanstack/react-router 0.0.1-beta.67 → 0.0.1-beta.69
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/index.js +15 -6
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.js +15 -7
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +50 -50
- package/build/types/index.d.ts +14 -13
- package/build/umd/index.development.js +41 -22
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +3 -3
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +62 -34
package/build/stats-react.json
CHANGED
|
@@ -7,31 +7,31 @@
|
|
|
7
7
|
"name": "index.production.js",
|
|
8
8
|
"children": [
|
|
9
9
|
{
|
|
10
|
-
"uid": "
|
|
10
|
+
"uid": "61e0-103",
|
|
11
11
|
"name": "\u0000rollupPluginBabelHelpers.js"
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
"name": "node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
|
|
15
|
-
"uid": "
|
|
15
|
+
"uid": "61e0-105"
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
"name": "packages",
|
|
19
19
|
"children": [
|
|
20
20
|
{
|
|
21
21
|
"name": "store/build/esm/index.js",
|
|
22
|
-
"uid": "
|
|
22
|
+
"uid": "61e0-107"
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
"name": "router/build/esm/index.js",
|
|
26
|
-
"uid": "
|
|
26
|
+
"uid": "61e0-109"
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
"name": "react-store/build/esm/index.js",
|
|
30
|
-
"uid": "
|
|
30
|
+
"uid": "61e0-111"
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
"name": "react-router/src/index.tsx",
|
|
34
|
-
"uid": "
|
|
34
|
+
"uid": "61e0-113"
|
|
35
35
|
}
|
|
36
36
|
]
|
|
37
37
|
}
|
|
@@ -41,155 +41,155 @@
|
|
|
41
41
|
"isRoot": true
|
|
42
42
|
},
|
|
43
43
|
"nodeParts": {
|
|
44
|
-
"
|
|
44
|
+
"61e0-103": {
|
|
45
45
|
"renderedLength": 429,
|
|
46
46
|
"gzipLength": 238,
|
|
47
47
|
"brotliLength": 0,
|
|
48
|
-
"mainUid": "
|
|
48
|
+
"mainUid": "61e0-102"
|
|
49
49
|
},
|
|
50
|
-
"
|
|
50
|
+
"61e0-105": {
|
|
51
51
|
"renderedLength": 181,
|
|
52
52
|
"gzipLength": 129,
|
|
53
53
|
"brotliLength": 0,
|
|
54
|
-
"mainUid": "
|
|
54
|
+
"mainUid": "61e0-104"
|
|
55
55
|
},
|
|
56
|
-
"
|
|
56
|
+
"61e0-107": {
|
|
57
57
|
"renderedLength": 1288,
|
|
58
58
|
"gzipLength": 497,
|
|
59
59
|
"brotliLength": 0,
|
|
60
|
-
"mainUid": "
|
|
60
|
+
"mainUid": "61e0-106"
|
|
61
61
|
},
|
|
62
|
-
"
|
|
63
|
-
"renderedLength":
|
|
64
|
-
"gzipLength":
|
|
62
|
+
"61e0-109": {
|
|
63
|
+
"renderedLength": 45882,
|
|
64
|
+
"gzipLength": 10946,
|
|
65
65
|
"brotliLength": 0,
|
|
66
|
-
"mainUid": "
|
|
66
|
+
"mainUid": "61e0-108"
|
|
67
67
|
},
|
|
68
|
-
"
|
|
68
|
+
"61e0-111": {
|
|
69
69
|
"renderedLength": 1571,
|
|
70
70
|
"gzipLength": 594,
|
|
71
71
|
"brotliLength": 0,
|
|
72
|
-
"mainUid": "
|
|
72
|
+
"mainUid": "61e0-110"
|
|
73
73
|
},
|
|
74
|
-
"
|
|
75
|
-
"renderedLength":
|
|
76
|
-
"gzipLength":
|
|
74
|
+
"61e0-113": {
|
|
75
|
+
"renderedLength": 12398,
|
|
76
|
+
"gzipLength": 3201,
|
|
77
77
|
"brotliLength": 0,
|
|
78
|
-
"mainUid": "
|
|
78
|
+
"mainUid": "61e0-112"
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
81
|
"nodeMetas": {
|
|
82
|
-
"
|
|
82
|
+
"61e0-102": {
|
|
83
83
|
"id": "\u0000rollupPluginBabelHelpers.js",
|
|
84
84
|
"moduleParts": {
|
|
85
|
-
"index.production.js": "
|
|
85
|
+
"index.production.js": "61e0-103"
|
|
86
86
|
},
|
|
87
87
|
"imported": [],
|
|
88
88
|
"importedBy": [
|
|
89
89
|
{
|
|
90
|
-
"uid": "
|
|
90
|
+
"uid": "61e0-112"
|
|
91
91
|
}
|
|
92
92
|
]
|
|
93
93
|
},
|
|
94
|
-
"
|
|
94
|
+
"61e0-104": {
|
|
95
95
|
"id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
|
|
96
96
|
"moduleParts": {
|
|
97
|
-
"index.production.js": "
|
|
97
|
+
"index.production.js": "61e0-105"
|
|
98
98
|
},
|
|
99
99
|
"imported": [],
|
|
100
100
|
"importedBy": [
|
|
101
101
|
{
|
|
102
|
-
"uid": "
|
|
102
|
+
"uid": "61e0-108"
|
|
103
103
|
}
|
|
104
104
|
]
|
|
105
105
|
},
|
|
106
|
-
"
|
|
106
|
+
"61e0-106": {
|
|
107
107
|
"id": "/packages/store/build/esm/index.js",
|
|
108
108
|
"moduleParts": {
|
|
109
|
-
"index.production.js": "
|
|
109
|
+
"index.production.js": "61e0-107"
|
|
110
110
|
},
|
|
111
111
|
"imported": [],
|
|
112
112
|
"importedBy": [
|
|
113
113
|
{
|
|
114
|
-
"uid": "
|
|
114
|
+
"uid": "61e0-108"
|
|
115
115
|
}
|
|
116
116
|
]
|
|
117
117
|
},
|
|
118
|
-
"
|
|
118
|
+
"61e0-108": {
|
|
119
119
|
"id": "/packages/router/build/esm/index.js",
|
|
120
120
|
"moduleParts": {
|
|
121
|
-
"index.production.js": "
|
|
121
|
+
"index.production.js": "61e0-109"
|
|
122
122
|
},
|
|
123
123
|
"imported": [
|
|
124
124
|
{
|
|
125
|
-
"uid": "
|
|
125
|
+
"uid": "61e0-104"
|
|
126
126
|
},
|
|
127
127
|
{
|
|
128
|
-
"uid": "
|
|
128
|
+
"uid": "61e0-106"
|
|
129
129
|
}
|
|
130
130
|
],
|
|
131
131
|
"importedBy": [
|
|
132
132
|
{
|
|
133
|
-
"uid": "
|
|
133
|
+
"uid": "61e0-112"
|
|
134
134
|
}
|
|
135
135
|
]
|
|
136
136
|
},
|
|
137
|
-
"
|
|
137
|
+
"61e0-110": {
|
|
138
138
|
"id": "/packages/react-store/build/esm/index.js",
|
|
139
139
|
"moduleParts": {
|
|
140
|
-
"index.production.js": "
|
|
140
|
+
"index.production.js": "61e0-111"
|
|
141
141
|
},
|
|
142
142
|
"imported": [
|
|
143
143
|
{
|
|
144
|
-
"uid": "
|
|
144
|
+
"uid": "61e0-115"
|
|
145
145
|
}
|
|
146
146
|
],
|
|
147
147
|
"importedBy": [
|
|
148
148
|
{
|
|
149
|
-
"uid": "
|
|
149
|
+
"uid": "61e0-112"
|
|
150
150
|
}
|
|
151
151
|
]
|
|
152
152
|
},
|
|
153
|
-
"
|
|
153
|
+
"61e0-112": {
|
|
154
154
|
"id": "/packages/react-router/src/index.tsx",
|
|
155
155
|
"moduleParts": {
|
|
156
|
-
"index.production.js": "
|
|
156
|
+
"index.production.js": "61e0-113"
|
|
157
157
|
},
|
|
158
158
|
"imported": [
|
|
159
159
|
{
|
|
160
|
-
"uid": "
|
|
160
|
+
"uid": "61e0-102"
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
|
-
"uid": "
|
|
163
|
+
"uid": "61e0-114"
|
|
164
164
|
},
|
|
165
165
|
{
|
|
166
|
-
"uid": "
|
|
166
|
+
"uid": "61e0-108"
|
|
167
167
|
},
|
|
168
168
|
{
|
|
169
|
-
"uid": "
|
|
169
|
+
"uid": "61e0-110"
|
|
170
170
|
}
|
|
171
171
|
],
|
|
172
172
|
"importedBy": [],
|
|
173
173
|
"isEntry": true
|
|
174
174
|
},
|
|
175
|
-
"
|
|
175
|
+
"61e0-114": {
|
|
176
176
|
"id": "react",
|
|
177
177
|
"moduleParts": {},
|
|
178
178
|
"imported": [],
|
|
179
179
|
"importedBy": [
|
|
180
180
|
{
|
|
181
|
-
"uid": "
|
|
181
|
+
"uid": "61e0-112"
|
|
182
182
|
}
|
|
183
183
|
],
|
|
184
184
|
"isExternal": true
|
|
185
185
|
},
|
|
186
|
-
"
|
|
186
|
+
"61e0-115": {
|
|
187
187
|
"id": "use-sync-external-store/shim/with-selector",
|
|
188
188
|
"moduleParts": {},
|
|
189
189
|
"imported": [],
|
|
190
190
|
"importedBy": [
|
|
191
191
|
{
|
|
192
|
-
"uid": "
|
|
192
|
+
"uid": "61e0-110"
|
|
193
193
|
}
|
|
194
194
|
],
|
|
195
195
|
"isExternal": true
|
package/build/types/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
import * as React from 'react';
|
|
12
|
-
import { RegisteredRoutesInfo, LinkOptions, ToOptions, MatchRouteOptions, RouteByPath, ResolveRelativePath, NoInfer, ValidFromPath, RegisteredRouter, AnyRootRoute, RootRoute, AnyRoutesInfo, RoutesInfo, Router,
|
|
12
|
+
import { RegisteredRoutesInfo, LinkOptions, ToOptions, MatchRouteOptions, RouteByPath, ResolveRelativePath, NoInfer, ValidFromPath, NavigateOptions, RegisteredRouter, AnyRootRoute, RootRoute, AnyRoutesInfo, RoutesInfo, Router, RouterConstructorOptions, DefaultRoutesInfo, RouterOptions, RouterStore, RouteMatch, AnyRouteMatch } from '@tanstack/router';
|
|
13
13
|
export * from '@tanstack/router';
|
|
14
14
|
export { useStore } from '@tanstack/react-store';
|
|
15
15
|
|
|
@@ -21,16 +21,16 @@ type RouteComponent<TProps = {}> = SyncRouteComponent<TProps> & {
|
|
|
21
21
|
declare function lazy(importer: () => Promise<{
|
|
22
22
|
default: SyncRouteComponent;
|
|
23
23
|
}>): RouteComponent;
|
|
24
|
-
type LinkPropsOptions<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = '
|
|
24
|
+
type LinkPropsOptions<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = ''> = LinkOptions<RegisteredRoutesInfo, TFrom, TTo> & {
|
|
25
25
|
activeProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
|
|
26
26
|
inactiveProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
|
|
27
27
|
};
|
|
28
|
-
type MakeUseMatchRouteOptions<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = '
|
|
29
|
-
type MakeMatchRouteOptions<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = '
|
|
28
|
+
type MakeUseMatchRouteOptions<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = ''> = ToOptions<RegisteredRoutesInfo, TFrom, TTo> & MatchRouteOptions;
|
|
29
|
+
type MakeMatchRouteOptions<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = ''> = ToOptions<RegisteredRoutesInfo, TFrom, TTo> & MatchRouteOptions & {
|
|
30
30
|
children?: ReactNode | ((params: RouteByPath<RegisteredRoutesInfo, ResolveRelativePath<TFrom, NoInfer<TTo>>>['__types']['allParams']) => ReactNode);
|
|
31
31
|
};
|
|
32
|
-
type MakeLinkPropsOptions<TFrom extends ValidFromPath<RegisteredRoutesInfo> = '/', TTo extends string = '
|
|
33
|
-
type MakeLinkOptions<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = '
|
|
32
|
+
type MakeLinkPropsOptions<TFrom extends ValidFromPath<RegisteredRoutesInfo> = '/', TTo extends string = ''> = LinkPropsOptions<TFrom, TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
33
|
+
type MakeLinkOptions<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = ''> = LinkPropsOptions<TFrom, TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement> & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {
|
|
34
34
|
children?: ReactNode | ((state: {
|
|
35
35
|
isActive: boolean;
|
|
36
36
|
}) => ReactNode);
|
|
@@ -56,11 +56,12 @@ type PromptProps = {
|
|
|
56
56
|
when?: boolean | any;
|
|
57
57
|
children?: ReactNode;
|
|
58
58
|
};
|
|
59
|
-
declare function useLinkProps<TFrom extends ValidFromPath<RegisteredRoutesInfo> = '/', TTo extends string = '
|
|
60
|
-
interface LinkFn<TDefaultFrom extends RegisteredRoutesInfo['routePaths'] = '/', TDefaultTo extends string = '
|
|
59
|
+
declare function useLinkProps<TFrom extends ValidFromPath<RegisteredRoutesInfo> = '/', TTo extends string = ''>(options: MakeLinkPropsOptions<TFrom, TTo>): React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
60
|
+
interface LinkFn<TDefaultFrom extends RegisteredRoutesInfo['routePaths'] = '/', TDefaultTo extends string = ''> {
|
|
61
61
|
<TFrom extends RegisteredRoutesInfo['routePaths'] = TDefaultFrom, TTo extends string = TDefaultTo>(props: MakeLinkOptions<TFrom, TTo> & React.RefAttributes<HTMLAnchorElement>): ReactNode;
|
|
62
62
|
}
|
|
63
63
|
declare const Link: LinkFn;
|
|
64
|
+
declare function Navigate<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = ''>(props: NavigateOptions<RegisteredRoutesInfo, TFrom, TTo>): null;
|
|
64
65
|
type MatchesContextValue = AnyRouteMatch[];
|
|
65
66
|
declare const matchesContext: React.Context<MatchesContextValue>;
|
|
66
67
|
declare const routerContext: React.Context<{
|
|
@@ -71,7 +72,7 @@ type MatchesProviderProps = {
|
|
|
71
72
|
children: ReactNode;
|
|
72
73
|
};
|
|
73
74
|
declare class ReactRouter<TRouteConfig extends AnyRootRoute = RootRoute, TRoutesInfo extends AnyRoutesInfo = RoutesInfo<TRouteConfig>> extends Router<TRouteConfig, TRoutesInfo> {
|
|
74
|
-
constructor(opts:
|
|
75
|
+
constructor(opts: RouterConstructorOptions<TRouteConfig>);
|
|
75
76
|
}
|
|
76
77
|
type RouterProps<TRouteConfig extends AnyRootRoute = RootRoute, TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo> = RouterOptions<TRouteConfig> & {
|
|
77
78
|
router: Router<TRouteConfig, TRoutesInfo>;
|
|
@@ -98,12 +99,12 @@ declare function useParams<TFrom extends keyof RegisteredRoutesInfo['routesById'
|
|
|
98
99
|
}): TSelected;
|
|
99
100
|
declare function useNavigate<TDefaultFrom extends keyof RegisteredRoutesInfo['routesById'] = '/'>(defaultOpts?: {
|
|
100
101
|
from?: TDefaultFrom;
|
|
101
|
-
}): <TFrom extends string = TDefaultFrom, TTo extends string = "
|
|
102
|
-
declare function useMatchRoute(): <TFrom extends ValidFromPath<AnyRoutesInfo> = "/", TTo extends string = "
|
|
103
|
-
declare function MatchRoute<TFrom extends ValidFromPath<RegisteredRoutesInfo> = '/', TTo extends string = '
|
|
102
|
+
}): <TFrom extends string = TDefaultFrom, TTo extends string = "">(opts?: MakeLinkOptions<TFrom, TTo> | undefined) => Promise<void>;
|
|
103
|
+
declare function useMatchRoute(): <TFrom extends ValidFromPath<AnyRoutesInfo> = "/", TTo extends string = "">(opts: MakeUseMatchRouteOptions<TFrom, TTo>) => false | {};
|
|
104
|
+
declare function MatchRoute<TFrom extends ValidFromPath<RegisteredRoutesInfo> = '/', TTo extends string = ''>(props: MakeMatchRouteOptions<TFrom, TTo>): any;
|
|
104
105
|
declare function Outlet(): JSX.Element | null;
|
|
105
106
|
declare function DefaultErrorBoundary({ error }: {
|
|
106
107
|
error: any;
|
|
107
108
|
}): JSX.Element;
|
|
108
109
|
|
|
109
|
-
export { DefaultErrorBoundary, Link, LinkFn, LinkPropsOptions, MakeLinkOptions, MakeLinkPropsOptions, MakeMatchRouteOptions, MakeUseMatchRouteOptions, MatchRoute, MatchesProviderProps, Outlet, PromptProps, ReactRouter, RouteComponent, RouterProps, RouterProvider, SyncRouteComponent, lazy, matchesContext, routerContext, useLinkProps, useMatch, useMatchRoute, useMatches, useNavigate, useParams, useRoute, useRouter, useRouterContext, useSearch };
|
|
110
|
+
export { DefaultErrorBoundary, Link, LinkFn, LinkPropsOptions, MakeLinkOptions, MakeLinkPropsOptions, MakeMatchRouteOptions, MakeUseMatchRouteOptions, MatchRoute, MatchesProviderProps, Navigate, Outlet, PromptProps, ReactRouter, RouteComponent, RouterProps, RouterProvider, SyncRouteComponent, lazy, matchesContext, routerContext, useLinkProps, useMatch, useMatchRoute, useMatches, useNavigate, useParams, useRoute, useRouter, useRouterContext, useSearch };
|
|
@@ -426,7 +426,7 @@
|
|
|
426
426
|
// Remove empty segments and '.' segments
|
|
427
427
|
const split = pathname.split('/').filter(Boolean);
|
|
428
428
|
segments.push(...split.map(part => {
|
|
429
|
-
if (part
|
|
429
|
+
if (part === '$') {
|
|
430
430
|
return {
|
|
431
431
|
type: 'wildcard',
|
|
432
432
|
value: part
|
|
@@ -455,7 +455,7 @@
|
|
|
455
455
|
function interpolatePath(path, params, leaveWildcard) {
|
|
456
456
|
const interpolatedPathSegments = parsePathname(path);
|
|
457
457
|
return joinPaths(interpolatedPathSegments.map(segment => {
|
|
458
|
-
if (segment.value === '
|
|
458
|
+
if (segment.value === '$' && !leaveWildcard) {
|
|
459
459
|
return '';
|
|
460
460
|
}
|
|
461
461
|
if (segment.type === 'param') {
|
|
@@ -479,7 +479,7 @@
|
|
|
479
479
|
}
|
|
480
480
|
from = basepath != '/' ? from.substring(basepath.length) : from;
|
|
481
481
|
const baseSegments = parsePathname(from);
|
|
482
|
-
const to = `${matchLocation.to ?? '
|
|
482
|
+
const to = `${matchLocation.to ?? '$'}`;
|
|
483
483
|
const routeSegments = parsePathname(to);
|
|
484
484
|
const params = {};
|
|
485
485
|
let isMatch = (() => {
|
|
@@ -491,7 +491,7 @@
|
|
|
491
491
|
if (routeSegment) {
|
|
492
492
|
if (routeSegment.type === 'wildcard') {
|
|
493
493
|
if (baseSegment?.value) {
|
|
494
|
-
params['
|
|
494
|
+
params['$'] = joinPaths(baseSegments.slice(i).map(d => d.value));
|
|
495
495
|
return true;
|
|
496
496
|
}
|
|
497
497
|
return false;
|
|
@@ -709,7 +709,13 @@
|
|
|
709
709
|
})
|
|
710
710
|
});
|
|
711
711
|
this.state = this.store.state;
|
|
712
|
-
|
|
712
|
+
componentTypes.map(async type => {
|
|
713
|
+
const component = this.route.options[type];
|
|
714
|
+
if (typeof this[type] !== 'function') {
|
|
715
|
+
this[type] = component;
|
|
716
|
+
}
|
|
717
|
+
});
|
|
718
|
+
if (this.state.status === 'idle' && !this.#hasLoaders()) {
|
|
713
719
|
this.store.setState(s => ({
|
|
714
720
|
...s,
|
|
715
721
|
status: 'success'
|
|
@@ -757,7 +763,7 @@
|
|
|
757
763
|
search
|
|
758
764
|
};
|
|
759
765
|
} catch (err) {
|
|
760
|
-
|
|
766
|
+
this.route.options.onValidateSearchError?.(err);
|
|
761
767
|
const error = new Error('Invalid search params found', {
|
|
762
768
|
cause: err
|
|
763
769
|
});
|
|
@@ -793,6 +799,7 @@
|
|
|
793
799
|
try {
|
|
794
800
|
info = this.#resolveInfo(opts);
|
|
795
801
|
} catch (err) {
|
|
802
|
+
this.route.options.onError?.(err);
|
|
796
803
|
this.store.setState(s => ({
|
|
797
804
|
...s,
|
|
798
805
|
status: 'error',
|
|
@@ -808,12 +815,6 @@
|
|
|
808
815
|
context,
|
|
809
816
|
routeContext
|
|
810
817
|
} = info;
|
|
811
|
-
componentTypes.map(async type => {
|
|
812
|
-
const component = this.route.options[type];
|
|
813
|
-
if (typeof this[type] !== 'function') {
|
|
814
|
-
this[type] = component;
|
|
815
|
-
}
|
|
816
|
-
});
|
|
817
818
|
|
|
818
819
|
// If the match is invalid, errored or idle, trigger it to load
|
|
819
820
|
if (this.state.status === 'pending') {
|
|
@@ -864,8 +865,7 @@
|
|
|
864
865
|
return;
|
|
865
866
|
});
|
|
866
867
|
try {
|
|
867
|
-
await componentsPromise;
|
|
868
|
-
await dataPromise;
|
|
868
|
+
await Promise.all([componentsPromise, dataPromise]);
|
|
869
869
|
if (latestPromise = checkLatest()) return await latestPromise;
|
|
870
870
|
this.store.setState(s => ({
|
|
871
871
|
...s,
|
|
@@ -874,6 +874,8 @@
|
|
|
874
874
|
updatedAt: Date.now()
|
|
875
875
|
}));
|
|
876
876
|
} catch (err) {
|
|
877
|
+
this.route.options.onLoadError?.(err);
|
|
878
|
+
this.route.options.onError?.(err);
|
|
877
879
|
this.store.setState(s => ({
|
|
878
880
|
...s,
|
|
879
881
|
error: err,
|
|
@@ -1261,8 +1263,9 @@
|
|
|
1261
1263
|
});
|
|
1262
1264
|
} catch (err) {
|
|
1263
1265
|
if (!opts?.preload) {
|
|
1264
|
-
match.route.options.
|
|
1266
|
+
match.route.options.onBeforeLoadError?.(err);
|
|
1265
1267
|
}
|
|
1268
|
+
match.route.options.onError?.(err);
|
|
1266
1269
|
throw err;
|
|
1267
1270
|
}
|
|
1268
1271
|
}));
|
|
@@ -1411,6 +1414,12 @@
|
|
|
1411
1414
|
});
|
|
1412
1415
|
}
|
|
1413
1416
|
};
|
|
1417
|
+
const handleTouchStart = e => {
|
|
1418
|
+
this.preloadRoute(nextOpts).catch(err => {
|
|
1419
|
+
console.warn(err);
|
|
1420
|
+
console.warn('Error preloading route! ☝️');
|
|
1421
|
+
});
|
|
1422
|
+
};
|
|
1414
1423
|
const handleEnter = e => {
|
|
1415
1424
|
const target = e.target || {};
|
|
1416
1425
|
if (preload) {
|
|
@@ -1440,6 +1449,7 @@
|
|
|
1440
1449
|
handleClick,
|
|
1441
1450
|
handleEnter,
|
|
1442
1451
|
handleLeave,
|
|
1452
|
+
handleTouchStart,
|
|
1443
1453
|
isActive,
|
|
1444
1454
|
disabled
|
|
1445
1455
|
};
|
|
@@ -1565,7 +1575,7 @@
|
|
|
1565
1575
|
key: dest.key
|
|
1566
1576
|
};
|
|
1567
1577
|
};
|
|
1568
|
-
#commitLocation = location => {
|
|
1578
|
+
#commitLocation = async location => {
|
|
1569
1579
|
const next = this.buildNext(location);
|
|
1570
1580
|
const id = '' + Date.now() + Math.random();
|
|
1571
1581
|
if (this.navigateTimeout) clearTimeout(this.navigateTimeout);
|
|
@@ -1710,7 +1720,6 @@
|
|
|
1710
1720
|
onMouseEnter,
|
|
1711
1721
|
onMouseLeave,
|
|
1712
1722
|
onTouchStart,
|
|
1713
|
-
onTouchEnd,
|
|
1714
1723
|
...rest
|
|
1715
1724
|
} = options;
|
|
1716
1725
|
const linkInfo = router.buildLink(options);
|
|
@@ -1727,6 +1736,7 @@
|
|
|
1727
1736
|
handleFocus,
|
|
1728
1737
|
handleEnter,
|
|
1729
1738
|
handleLeave,
|
|
1739
|
+
handleTouchStart,
|
|
1730
1740
|
isActive,
|
|
1731
1741
|
next
|
|
1732
1742
|
} = linkInfo;
|
|
@@ -1762,6 +1772,7 @@
|
|
|
1762
1772
|
onFocus: composeHandlers([onFocus, handleFocus]),
|
|
1763
1773
|
onMouseEnter: composeHandlers([onMouseEnter, handleEnter]),
|
|
1764
1774
|
onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),
|
|
1775
|
+
onTouchStart: composeHandlers([onTouchStart, handleTouchStart]),
|
|
1765
1776
|
target,
|
|
1766
1777
|
style: {
|
|
1767
1778
|
...style,
|
|
@@ -1786,6 +1797,13 @@
|
|
|
1786
1797
|
}) : props.children
|
|
1787
1798
|
}));
|
|
1788
1799
|
});
|
|
1800
|
+
function Navigate(props) {
|
|
1801
|
+
const router = useRouterContext();
|
|
1802
|
+
React__namespace.useLayoutEffect(() => {
|
|
1803
|
+
router.navigate(props);
|
|
1804
|
+
}, []);
|
|
1805
|
+
return null;
|
|
1806
|
+
}
|
|
1789
1807
|
const matchesContext = /*#__PURE__*/React__namespace.createContext(null);
|
|
1790
1808
|
const routerContext = /*#__PURE__*/React__namespace.createContext(null);
|
|
1791
1809
|
class ReactRouter extends Router {
|
|
@@ -1844,7 +1862,7 @@
|
|
|
1844
1862
|
function useRoute(routeId) {
|
|
1845
1863
|
const router = useRouterContext();
|
|
1846
1864
|
const resolvedRoute = router.getRoute(routeId);
|
|
1847
|
-
invariant(resolvedRoute, `Could not find a route for route "${routeId}"! Did you forget to add it to your route
|
|
1865
|
+
invariant(resolvedRoute, `Could not find a route for route "${routeId}"! Did you forget to add it to your route?`);
|
|
1848
1866
|
return resolvedRoute;
|
|
1849
1867
|
}
|
|
1850
1868
|
function useSearch(opts) {
|
|
@@ -1862,16 +1880,16 @@
|
|
|
1862
1880
|
}
|
|
1863
1881
|
function useNavigate(defaultOpts) {
|
|
1864
1882
|
const router = useRouterContext();
|
|
1865
|
-
return opts => {
|
|
1883
|
+
return React__namespace.useCallback(opts => {
|
|
1866
1884
|
return router.navigate({
|
|
1867
1885
|
...defaultOpts,
|
|
1868
1886
|
...opts
|
|
1869
1887
|
});
|
|
1870
|
-
};
|
|
1888
|
+
}, []);
|
|
1871
1889
|
}
|
|
1872
1890
|
function useMatchRoute() {
|
|
1873
1891
|
const router = useRouterContext();
|
|
1874
|
-
return opts => {
|
|
1892
|
+
return React__namespace.useCallback(opts => {
|
|
1875
1893
|
const {
|
|
1876
1894
|
pending,
|
|
1877
1895
|
caseSensitive,
|
|
@@ -1881,7 +1899,7 @@
|
|
|
1881
1899
|
pending,
|
|
1882
1900
|
caseSensitive
|
|
1883
1901
|
});
|
|
1884
|
-
};
|
|
1902
|
+
}, []);
|
|
1885
1903
|
}
|
|
1886
1904
|
function MatchRoute(props) {
|
|
1887
1905
|
const matchRoute = useMatchRoute();
|
|
@@ -2050,6 +2068,7 @@
|
|
|
2050
2068
|
exports.DefaultErrorBoundary = DefaultErrorBoundary;
|
|
2051
2069
|
exports.Link = Link;
|
|
2052
2070
|
exports.MatchRoute = MatchRoute;
|
|
2071
|
+
exports.Navigate = Navigate;
|
|
2053
2072
|
exports.Outlet = Outlet;
|
|
2054
2073
|
exports.ReactRouter = ReactRouter;
|
|
2055
2074
|
exports.RootRoute = RootRoute;
|