@tanstack/react-router 0.0.1-beta.157 → 0.0.1-beta.159

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.
@@ -7,7 +7,7 @@
7
7
  "name": "index.production.js",
8
8
  "children": [
9
9
  {
10
- "uid": "7589-167",
10
+ "uid": "3b6d-167",
11
11
  "name": "\u0000rollupPluginBabelHelpers.js"
12
12
  },
13
13
  {
@@ -15,19 +15,19 @@
15
15
  "children": [
16
16
  {
17
17
  "name": "store/build/esm/index.js",
18
- "uid": "7589-169"
18
+ "uid": "3b6d-169"
19
19
  },
20
20
  {
21
21
  "name": "react-store/build/esm/index.js",
22
- "uid": "7589-171"
22
+ "uid": "3b6d-171"
23
23
  },
24
24
  {
25
25
  "name": "router-core/build/esm/index.js",
26
- "uid": "7589-177"
26
+ "uid": "3b6d-177"
27
27
  },
28
28
  {
29
29
  "name": "react-router/src/index.tsx",
30
- "uid": "7589-179"
30
+ "uid": "3b6d-179"
31
31
  }
32
32
  ]
33
33
  },
@@ -36,11 +36,11 @@
36
36
  "children": [
37
37
  {
38
38
  "name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
39
- "uid": "7589-173"
39
+ "uid": "3b6d-173"
40
40
  },
41
41
  {
42
42
  "name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
43
- "uid": "7589-175"
43
+ "uid": "3b6d-175"
44
44
  }
45
45
  ]
46
46
  }
@@ -50,194 +50,194 @@
50
50
  "isRoot": true
51
51
  },
52
52
  "nodeParts": {
53
- "7589-167": {
53
+ "3b6d-167": {
54
54
  "renderedLength": 429,
55
55
  "gzipLength": 238,
56
56
  "brotliLength": 0,
57
- "mainUid": "7589-166"
57
+ "mainUid": "3b6d-166"
58
58
  },
59
- "7589-169": {
59
+ "3b6d-169": {
60
60
  "renderedLength": 1843,
61
61
  "gzipLength": 644,
62
62
  "brotliLength": 0,
63
- "mainUid": "7589-168"
63
+ "mainUid": "3b6d-168"
64
64
  },
65
- "7589-171": {
65
+ "3b6d-171": {
66
66
  "renderedLength": 1006,
67
67
  "gzipLength": 479,
68
68
  "brotliLength": 0,
69
- "mainUid": "7589-170"
69
+ "mainUid": "3b6d-170"
70
70
  },
71
- "7589-173": {
71
+ "3b6d-173": {
72
72
  "renderedLength": 181,
73
73
  "gzipLength": 129,
74
74
  "brotliLength": 0,
75
- "mainUid": "7589-172"
75
+ "mainUid": "3b6d-172"
76
76
  },
77
- "7589-175": {
77
+ "3b6d-175": {
78
78
  "renderedLength": 44,
79
79
  "gzipLength": 62,
80
80
  "brotliLength": 0,
81
- "mainUid": "7589-174"
81
+ "mainUid": "3b6d-174"
82
82
  },
83
- "7589-177": {
84
- "renderedLength": 56618,
85
- "gzipLength": 13404,
83
+ "3b6d-177": {
84
+ "renderedLength": 56305,
85
+ "gzipLength": 13276,
86
86
  "brotliLength": 0,
87
- "mainUid": "7589-176"
87
+ "mainUid": "3b6d-176"
88
88
  },
89
- "7589-179": {
89
+ "3b6d-179": {
90
90
  "renderedLength": 17095,
91
91
  "gzipLength": 3814,
92
92
  "brotliLength": 0,
93
- "mainUid": "7589-178"
93
+ "mainUid": "3b6d-178"
94
94
  }
95
95
  },
96
96
  "nodeMetas": {
97
- "7589-166": {
97
+ "3b6d-166": {
98
98
  "id": "\u0000rollupPluginBabelHelpers.js",
99
99
  "moduleParts": {
100
- "index.production.js": "7589-167"
100
+ "index.production.js": "3b6d-167"
101
101
  },
102
102
  "imported": [],
103
103
  "importedBy": [
104
104
  {
105
- "uid": "7589-178"
105
+ "uid": "3b6d-178"
106
106
  }
107
107
  ]
108
108
  },
109
- "7589-168": {
109
+ "3b6d-168": {
110
110
  "id": "/packages/store/build/esm/index.js",
111
111
  "moduleParts": {
112
- "index.production.js": "7589-169"
112
+ "index.production.js": "3b6d-169"
113
113
  },
114
114
  "imported": [],
115
115
  "importedBy": [
116
116
  {
117
- "uid": "7589-170"
117
+ "uid": "3b6d-170"
118
118
  }
119
119
  ]
120
120
  },
121
- "7589-170": {
121
+ "3b6d-170": {
122
122
  "id": "/packages/react-store/build/esm/index.js",
123
123
  "moduleParts": {
124
- "index.production.js": "7589-171"
124
+ "index.production.js": "3b6d-171"
125
125
  },
126
126
  "imported": [
127
127
  {
128
- "uid": "7589-181"
128
+ "uid": "3b6d-181"
129
129
  },
130
130
  {
131
- "uid": "7589-168"
131
+ "uid": "3b6d-168"
132
132
  }
133
133
  ],
134
134
  "importedBy": [
135
135
  {
136
- "uid": "7589-178"
136
+ "uid": "3b6d-178"
137
137
  },
138
138
  {
139
- "uid": "7589-176"
139
+ "uid": "3b6d-176"
140
140
  }
141
141
  ]
142
142
  },
143
- "7589-172": {
143
+ "3b6d-172": {
144
144
  "id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
145
145
  "moduleParts": {
146
- "index.production.js": "7589-173"
146
+ "index.production.js": "3b6d-173"
147
147
  },
148
148
  "imported": [],
149
149
  "importedBy": [
150
150
  {
151
- "uid": "7589-178"
151
+ "uid": "3b6d-178"
152
152
  },
153
153
  {
154
- "uid": "7589-176"
154
+ "uid": "3b6d-176"
155
155
  }
156
156
  ]
157
157
  },
158
- "7589-174": {
158
+ "3b6d-174": {
159
159
  "id": "/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
160
160
  "moduleParts": {
161
- "index.production.js": "7589-175"
161
+ "index.production.js": "3b6d-175"
162
162
  },
163
163
  "imported": [],
164
164
  "importedBy": [
165
165
  {
166
- "uid": "7589-178"
166
+ "uid": "3b6d-178"
167
167
  },
168
168
  {
169
- "uid": "7589-176"
169
+ "uid": "3b6d-176"
170
170
  }
171
171
  ]
172
172
  },
173
- "7589-176": {
173
+ "3b6d-176": {
174
174
  "id": "/packages/router-core/build/esm/index.js",
175
175
  "moduleParts": {
176
- "index.production.js": "7589-177"
176
+ "index.production.js": "3b6d-177"
177
177
  },
178
178
  "imported": [
179
179
  {
180
- "uid": "7589-172"
180
+ "uid": "3b6d-172"
181
181
  },
182
182
  {
183
- "uid": "7589-174"
183
+ "uid": "3b6d-174"
184
184
  },
185
185
  {
186
- "uid": "7589-170"
186
+ "uid": "3b6d-170"
187
187
  }
188
188
  ],
189
189
  "importedBy": [
190
190
  {
191
- "uid": "7589-178"
191
+ "uid": "3b6d-178"
192
192
  }
193
193
  ]
194
194
  },
195
- "7589-178": {
195
+ "3b6d-178": {
196
196
  "id": "/packages/react-router/src/index.tsx",
197
197
  "moduleParts": {
198
- "index.production.js": "7589-179"
198
+ "index.production.js": "3b6d-179"
199
199
  },
200
200
  "imported": [
201
201
  {
202
- "uid": "7589-166"
202
+ "uid": "3b6d-166"
203
203
  },
204
204
  {
205
- "uid": "7589-180"
205
+ "uid": "3b6d-180"
206
206
  },
207
207
  {
208
- "uid": "7589-170"
208
+ "uid": "3b6d-170"
209
209
  },
210
210
  {
211
- "uid": "7589-172"
211
+ "uid": "3b6d-172"
212
212
  },
213
213
  {
214
- "uid": "7589-174"
214
+ "uid": "3b6d-174"
215
215
  },
216
216
  {
217
- "uid": "7589-176"
217
+ "uid": "3b6d-176"
218
218
  }
219
219
  ],
220
220
  "importedBy": [],
221
221
  "isEntry": true
222
222
  },
223
- "7589-180": {
223
+ "3b6d-180": {
224
224
  "id": "react",
225
225
  "moduleParts": {},
226
226
  "imported": [],
227
227
  "importedBy": [
228
228
  {
229
- "uid": "7589-178"
229
+ "uid": "3b6d-178"
230
230
  }
231
231
  ],
232
232
  "isExternal": true
233
233
  },
234
- "7589-181": {
234
+ "3b6d-181": {
235
235
  "id": "use-sync-external-store/shim/with-selector",
236
236
  "moduleParts": {},
237
237
  "imported": [],
238
238
  "importedBy": [
239
239
  {
240
- "uid": "7589-170"
240
+ "uid": "3b6d-170"
241
241
  }
242
242
  ],
243
243
  "isExternal": true
@@ -8,11 +8,12 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
+ import * as _tanstack_router_core from '@tanstack/router-core';
12
+ import { RouteConstraints, AnyRoute, ResolveFullPath, ResolveId, ResolveFullSearchSchema, ParsePathParams, MergeParamsFromParent, RouteContext, AnyContext, UseLoaderResult, AnyRouteProps, RoutePaths, RegisteredRouter, LinkOptions, ToOptions, MatchRouteOptions, RouteByPath, ResolveRelativePath, NavigateOptions, RouterOptions, Router, RouteMatch, RouteIds, RouteById, ParseRoute, RoutesById, AllParams } from '@tanstack/router-core';
13
+ export * from '@tanstack/router-core';
11
14
  import * as React from 'react';
12
15
  import { NoInfer } from '@tanstack/react-store';
13
16
  export { useStore } from '@tanstack/react-store';
14
- import { RouteConstraints, AnyRoute, ResolveFullPath, ResolveId, ResolveFullSearchSchema, ParsePathParams, MergeParamsFromParent, RouteContext, AnyContext, UseLoaderResult, AnyRouteProps, RoutePaths, RegisteredRouter, LinkOptions, ToOptions, MatchRouteOptions, RouteByPath, ResolveRelativePath, NavigateOptions, Router, RouterOptions, RouteMatch, RouteIds, RouteById, ParseRoute, RoutesById, AllParams } from '@tanstack/router-core';
15
- export * from '@tanstack/router-core';
16
17
 
17
18
  declare module '@tanstack/router-core' {
18
19
  interface RegisterRouteComponent<TProps extends Record<string, any>> {
@@ -90,15 +91,15 @@ interface LinkComponent<TProps extends Record<string, any> = {}> {
90
91
  declare const Link: LinkComponent;
91
92
  declare function Navigate<TFrom extends RoutePaths<RegisteredRouter['routeTree']> = '/', TTo extends string = ''>(props: NavigateOptions<RegisteredRouter['routeTree'], TFrom, TTo>): null;
92
93
  declare const matchIdsContext: React.Context<string[]>;
93
- declare const routerContext: React.Context<Router<AnyRoute, Record<string, any>>>;
94
- type RouterProps<TRouteTree extends AnyRoute = AnyRoute, TDehydrated extends Record<string, any> = Record<string, any>> = Omit<RouterOptions<TRouteTree, TDehydrated>, 'context'> & {
94
+ declare const routerContext: React.Context<_tanstack_router_core.AnyRouter>;
95
+ type RouterProps<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TDehydrated extends Record<string, any> = Record<string, any>> = Omit<RouterOptions<TRouteTree, TDehydrated>, 'context'> & {
95
96
  router: Router<TRouteTree>;
96
97
  context?: Partial<RouterOptions<TRouteTree, TDehydrated>['context']>;
97
98
  };
98
99
  declare function useRouterState<TSelected = RegisteredRouter['state']>(opts?: {
99
100
  select: (state: RegisteredRouter['state']) => TSelected;
100
101
  }): TSelected;
101
- declare function RouterProvider<TRouteTree extends AnyRoute = AnyRoute, TDehydrated extends Record<string, any> = Record<string, any>>({ router, ...rest }: RouterProps<TRouteTree, TDehydrated>): JSX.Element;
102
+ declare function RouterProvider<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TDehydrated extends Record<string, any> = Record<string, any>>({ router, ...rest }: RouterProps<TRouteTree, TDehydrated>): JSX.Element;
102
103
  declare function useRouter(): RegisteredRouter;
103
104
  declare function useMatches<T = RouteMatch[]>(opts?: {
104
105
  select?: (matches: RouteMatch[]) => T;
@@ -135,7 +136,7 @@ declare function useParams<TFrom extends RouteIds<RegisteredRouter['routeTree']>
135
136
  }): TSelected;
136
137
  declare function useNavigate<TDefaultFrom extends RoutePaths<RegisteredRouter['routeTree']> = '/'>(defaultOpts?: {
137
138
  from?: TDefaultFrom;
138
- }): <TFrom extends unknown = TDefaultFrom, TTo extends string = "">(opts?: NavigateOptions<AnyRoute, TFrom, TTo> | undefined) => Promise<void>;
139
+ }): <TFrom extends unknown = TDefaultFrom, TTo extends string = "">(opts?: NavigateOptions<any, TFrom, TTo> | undefined) => Promise<void>;
139
140
  declare function useMatchRoute(): <TFrom extends string = "/", TTo extends string = "">(opts: MakeUseMatchRouteOptions<TFrom, TTo>) => any;
140
141
  declare function MatchRoute<TFrom extends string = '/', TTo extends string = ''>(props: MakeMatchRouteOptions<TFrom, TTo>): any;
141
142
  declare function Outlet(): JSX.Element | null;
@@ -1141,42 +1141,36 @@
1141
1141
  if (routeCursor) matchedRoutes.unshift(routeCursor);
1142
1142
  }
1143
1143
 
1144
- // Alright, by now we should have all of our
1145
- // matching routes and their param pairs, let's
1146
- // Turn them into actual `Match` objects and
1147
- // accumulate the params into a single params bag
1148
- let allParams = {};
1149
-
1150
1144
  // Existing matches are matches that are already loaded along with
1151
1145
  // pending matches that are still loading
1152
1146
 
1153
- const matches = matchedRoutes.map(route => {
1154
- let parsedParams;
1147
+ const parseErrors = matchedRoutes.map(route => {
1155
1148
  let parsedParamsError;
1156
- try {
1157
- parsedParams = route.options.parseParams?.(routeParams) ?? routeParams;
1158
- // (typeof route.options.parseParams === 'object' &&
1159
- // route.options.parseParams.parse
1160
- // ? route.options.parseParams.parse(routeParams)
1161
- // : (route.options.parseParams as any)?.(routeParams!)) ?? routeParams
1162
- } catch (err) {
1163
- parsedParamsError = new PathParamError(err.message, {
1164
- cause: err
1165
- });
1166
- if (opts?.throwOnError) {
1167
- throw parsedParamsError;
1149
+ if (route.options.parseParams) {
1150
+ try {
1151
+ const parsedParams = route.options.parseParams(routeParams);
1152
+ // Add the parsed params to the accumulated params bag
1153
+ Object.assign(routeParams, parsedParams);
1154
+ } catch (err) {
1155
+ parsedParamsError = new PathParamError(err.message, {
1156
+ cause: err
1157
+ });
1158
+ if (opts?.throwOnError) {
1159
+ throw parsedParamsError;
1160
+ }
1161
+ return parsedParamsError;
1168
1162
  }
1169
1163
  }
1170
-
1171
- // Add the parsed params to the accumulated params bag
1172
- Object.assign(allParams, parsedParams);
1173
- const interpolatedPath = interpolatePath(route.path, allParams);
1164
+ return;
1165
+ });
1166
+ const matches = matchedRoutes.map((route, index) => {
1167
+ const interpolatedPath = interpolatePath(route.path, routeParams);
1174
1168
  const key = route.options.key ? route.options.key({
1175
- params: allParams,
1169
+ params: routeParams,
1176
1170
  search: locationSearch
1177
1171
  }) ?? '' : '';
1178
1172
  const stringifiedKey = key ? JSON.stringify(key) : '';
1179
- const matchId = interpolatePath(route.id, allParams, true) + stringifiedKey;
1173
+ const matchId = interpolatePath(route.id, routeParams, true) + stringifiedKey;
1180
1174
 
1181
1175
  // Waste not, want not. If we already have a match for this route,
1182
1176
  // reuse it. This is important for layout routes, which might stick
@@ -1194,7 +1188,7 @@
1194
1188
  id: matchId,
1195
1189
  key: stringifiedKey,
1196
1190
  routeId: route.id,
1197
- params: allParams,
1191
+ params: routeParams,
1198
1192
  pathname: joinPaths([this.basepath, interpolatedPath]),
1199
1193
  updatedAt: Date.now(),
1200
1194
  invalidAt: Infinity,
@@ -1205,7 +1199,7 @@
1205
1199
  isFetching: false,
1206
1200
  invalid: false,
1207
1201
  error: undefined,
1208
- paramsError: parsedParamsError,
1202
+ paramsError: parseErrors[index],
1209
1203
  searchError: undefined,
1210
1204
  loaderData: undefined,
1211
1205
  loadPromise: Promise.resolve(),