@tanstack/router-core 1.130.9 → 1.130.11
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/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +12 -0
- package/dist/cjs/router.cjs +8 -3
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/link.d.ts +12 -0
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/router.js +8 -3
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/link.ts +12 -0
- package/src/router.ts +21 -3
package/package.json
CHANGED
package/src/link.ts
CHANGED
|
@@ -393,6 +393,12 @@ export interface RequiredToOptions<
|
|
|
393
393
|
in out TFrom extends string,
|
|
394
394
|
in out TTo extends string | undefined,
|
|
395
395
|
> {
|
|
396
|
+
/**
|
|
397
|
+
* The internal route path to navigate to. This should be a relative or absolute path within your application.
|
|
398
|
+
* For external URLs, use the `href` property instead.
|
|
399
|
+
* @example "/dashboard" or "../profile"
|
|
400
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)
|
|
401
|
+
*/
|
|
396
402
|
to: ToPathOption<TRouter, TFrom, TTo> & {}
|
|
397
403
|
}
|
|
398
404
|
|
|
@@ -401,6 +407,12 @@ export interface OptionalToOptions<
|
|
|
401
407
|
in out TFrom extends string,
|
|
402
408
|
in out TTo extends string | undefined,
|
|
403
409
|
> {
|
|
410
|
+
/**
|
|
411
|
+
* The internal route path to navigate to. This should be a relative or absolute path within your application.
|
|
412
|
+
* For external URLs, use the `href` property instead.
|
|
413
|
+
* @example "/dashboard" or "../profile"
|
|
414
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)
|
|
415
|
+
*/
|
|
404
416
|
to?: ToPathOption<TRouter, TFrom, TTo> & {}
|
|
405
417
|
}
|
|
406
418
|
|
package/src/router.ts
CHANGED
|
@@ -3212,18 +3212,36 @@ export type ProcessRouteTreeResult<TRouteLike extends RouteLike> = {
|
|
|
3212
3212
|
const REQUIRED_PARAM_BASE_SCORE = 0.5
|
|
3213
3213
|
const OPTIONAL_PARAM_BASE_SCORE = 0.4
|
|
3214
3214
|
const WILDCARD_PARAM_BASE_SCORE = 0.25
|
|
3215
|
+
const BOTH_PRESENCE_BASE_SCORE = 0.05
|
|
3216
|
+
const PREFIX_PRESENCE_BASE_SCORE = 0.02
|
|
3217
|
+
const SUFFIX_PRESENCE_BASE_SCORE = 0.01
|
|
3218
|
+
const PREFIX_LENGTH_SCORE_MULTIPLIER = 0.0002
|
|
3219
|
+
const SUFFIX_LENGTH_SCORE_MULTIPLIER = 0.0001
|
|
3215
3220
|
|
|
3216
3221
|
function handleParam(segment: Segment, baseScore: number) {
|
|
3217
3222
|
if (segment.prefixSegment && segment.suffixSegment) {
|
|
3218
|
-
return
|
|
3223
|
+
return (
|
|
3224
|
+
baseScore +
|
|
3225
|
+
BOTH_PRESENCE_BASE_SCORE +
|
|
3226
|
+
PREFIX_LENGTH_SCORE_MULTIPLIER * segment.prefixSegment.length +
|
|
3227
|
+
SUFFIX_LENGTH_SCORE_MULTIPLIER * segment.suffixSegment.length
|
|
3228
|
+
)
|
|
3219
3229
|
}
|
|
3220
3230
|
|
|
3221
3231
|
if (segment.prefixSegment) {
|
|
3222
|
-
return
|
|
3232
|
+
return (
|
|
3233
|
+
baseScore +
|
|
3234
|
+
PREFIX_PRESENCE_BASE_SCORE +
|
|
3235
|
+
PREFIX_LENGTH_SCORE_MULTIPLIER * segment.prefixSegment.length
|
|
3236
|
+
)
|
|
3223
3237
|
}
|
|
3224
3238
|
|
|
3225
3239
|
if (segment.suffixSegment) {
|
|
3226
|
-
return
|
|
3240
|
+
return (
|
|
3241
|
+
baseScore +
|
|
3242
|
+
SUFFIX_PRESENCE_BASE_SCORE +
|
|
3243
|
+
SUFFIX_LENGTH_SCORE_MULTIPLIER * segment.suffixSegment.length
|
|
3244
|
+
)
|
|
3227
3245
|
}
|
|
3228
3246
|
|
|
3229
3247
|
return baseScore
|