@tanstack/router-core 1.132.0-alpha.16 → 1.132.0-alpha.19
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/dist/cjs/path.cjs +1 -0
- package/dist/cjs/path.cjs.map +1 -1
- package/dist/cjs/router.cjs +24 -6
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/path.js +1 -0
- package/dist/esm/path.js.map +1 -1
- package/dist/esm/router.js +24 -6
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/path.ts +4 -0
- package/src/router.ts +38 -12
package/package.json
CHANGED
package/src/path.ts
CHANGED
|
@@ -397,6 +397,10 @@ export function interpolatePath({
|
|
|
397
397
|
|
|
398
398
|
if (segment.type === SEGMENT_TYPE_WILDCARD) {
|
|
399
399
|
usedParams._splat = params._splat
|
|
400
|
+
|
|
401
|
+
// TODO: Deprecate *
|
|
402
|
+
usedParams['*'] = params._splat
|
|
403
|
+
|
|
400
404
|
const segmentPrefix = segment.prefixSegment || ''
|
|
401
405
|
const segmentSuffix = segment.suffixSegment || ''
|
|
402
406
|
|
package/src/router.ts
CHANGED
|
@@ -1301,20 +1301,44 @@ export class RouterCore<
|
|
|
1301
1301
|
|
|
1302
1302
|
const loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) : ''
|
|
1303
1303
|
|
|
1304
|
-
const {
|
|
1304
|
+
const { interpolatedPath } = interpolatePath({
|
|
1305
1305
|
path: route.fullPath,
|
|
1306
1306
|
params: routeParams,
|
|
1307
1307
|
decodeCharMap: this.pathParamsDecodeCharMap,
|
|
1308
1308
|
})
|
|
1309
1309
|
|
|
1310
|
-
const
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1310
|
+
const interpolatePathResult = interpolatePath({
|
|
1311
|
+
path: route.id,
|
|
1312
|
+
params: routeParams,
|
|
1313
|
+
leaveWildcards: true,
|
|
1314
|
+
decodeCharMap: this.pathParamsDecodeCharMap,
|
|
1315
|
+
parseCache: this.parsePathnameCache,
|
|
1316
|
+
})
|
|
1317
|
+
|
|
1318
|
+
const strictParams = interpolatePathResult.usedParams
|
|
1319
|
+
|
|
1320
|
+
let paramsError = parseErrors[index]
|
|
1321
|
+
|
|
1322
|
+
const strictParseParams =
|
|
1323
|
+
route.options.params?.parse ?? route.options.parseParams
|
|
1324
|
+
|
|
1325
|
+
if (strictParseParams) {
|
|
1326
|
+
try {
|
|
1327
|
+
Object.assign(strictParams, strictParseParams(strictParams as any))
|
|
1328
|
+
} catch (err: any) {
|
|
1329
|
+
// any param errors should already have been dealt with above, if this
|
|
1330
|
+
// somehow differs, let's report this in the same manner
|
|
1331
|
+
if (!paramsError) {
|
|
1332
|
+
paramsError = new PathParamError(err.message, {
|
|
1333
|
+
cause: err,
|
|
1334
|
+
})
|
|
1335
|
+
|
|
1336
|
+
if (opts?.throwOnError) {
|
|
1337
|
+
throw paramsError
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1318
1342
|
|
|
1319
1343
|
// Waste not, want not. If we already have a match for this route,
|
|
1320
1344
|
// reuse it. This is important for layout routes, which might stick
|
|
@@ -1322,6 +1346,8 @@ export class RouterCore<
|
|
|
1322
1346
|
|
|
1323
1347
|
// Existing matches are matches that are already loaded along with
|
|
1324
1348
|
// pending matches that are still loading
|
|
1349
|
+
const matchId = interpolatePathResult.interpolatedPath + loaderDepsHash
|
|
1350
|
+
|
|
1325
1351
|
const existingMatch = this.getMatch(matchId)
|
|
1326
1352
|
|
|
1327
1353
|
const previousMatch = this.state.matches.find(
|
|
@@ -1339,7 +1365,7 @@ export class RouterCore<
|
|
|
1339
1365
|
params: previousMatch
|
|
1340
1366
|
? replaceEqualDeep(previousMatch.params, routeParams)
|
|
1341
1367
|
: routeParams,
|
|
1342
|
-
_strictParams:
|
|
1368
|
+
_strictParams: strictParams,
|
|
1343
1369
|
search: previousMatch
|
|
1344
1370
|
? replaceEqualDeep(previousMatch.search, preMatchSearch)
|
|
1345
1371
|
: replaceEqualDeep(existingMatch.search, preMatchSearch),
|
|
@@ -1361,7 +1387,7 @@ export class RouterCore<
|
|
|
1361
1387
|
params: previousMatch
|
|
1362
1388
|
? replaceEqualDeep(previousMatch.params, routeParams)
|
|
1363
1389
|
: routeParams,
|
|
1364
|
-
_strictParams:
|
|
1390
|
+
_strictParams: strictParams,
|
|
1365
1391
|
pathname: interpolatedPath,
|
|
1366
1392
|
updatedAt: Date.now(),
|
|
1367
1393
|
search: previousMatch
|
|
@@ -1372,7 +1398,7 @@ export class RouterCore<
|
|
|
1372
1398
|
status,
|
|
1373
1399
|
isFetching: false,
|
|
1374
1400
|
error: undefined,
|
|
1375
|
-
paramsError:
|
|
1401
|
+
paramsError: paramsError,
|
|
1376
1402
|
__routeContext: undefined,
|
|
1377
1403
|
_nonReactive: {
|
|
1378
1404
|
loadPromise: createControlledPromise(),
|