Skip to content

Commit 4e596e9

Browse files
committed
refactor: rename methods to keep same names
1 parent 7d6164a commit 4e596e9

File tree

7 files changed

+61
-62
lines changed

7 files changed

+61
-62
lines changed

packages/router/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@
120120
"@vue/devtools-api": "^6.6.4"
121121
},
122122
"devDependencies": {
123-
"@microsoft/api-extractor": "^7.52.11",
124-
"@rollup/plugin-alias": "^5.1.1",
125123
"@rollup/plugin-commonjs": "^25.0.8",
126124
"@rollup/plugin-node-resolve": "^15.3.1",
127125
"@rollup/plugin-replace": "^5.0.7",
@@ -145,7 +143,6 @@
145143
"nightwatch-helpers": "^1.2.0",
146144
"rimraf": "^6.0.1",
147145
"rollup": "^3.29.5",
148-
"rollup-plugin-analyzer": "^4.0.0",
149146
"rollup-plugin-typescript2": "^0.36.0",
150147
"tsdown": "^0.12.9",
151148
"tsup": "^8.5.0",

packages/router/src/experimental/route-resolver/matchers/matcher-pattern.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ import type { Simplify } from '../../../types/utils'
1010
*
1111
* @template TIn - type of the input value to match against the pattern
1212
* @template TParams - type of the output value after matching
13+
* @template TParamsRaw - type of the input value to build the input from
1314
*
1415
* In the case of the `path`, the `TIn` is a `string`, but in the case of the
15-
* query, it's the object of query params.
16+
* query, it's the object of query params. `TParamsRaw` allows for a more permissive
17+
* type when building the value, for example allowing numbers and strings like
18+
* the old params.
1619
*
1720
* @internal this is the base interface for all matcher patterns, it shouldn't
1821
* be used directly

packages/router/src/experimental/route-resolver/matchers/param-parsers/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface ParamParser<
1414
// not allow `null` within an array or `undefined`)
1515
TUrlParam = MatcherQueryParamsValue,
1616
// the type that can be passed as a location when navigating: `router.push({ params: { }})`
17-
// it's sometimes for more permissive than TParam, for example allowing nullish values
17+
// it's sometimes more permissive than TParam, for example allowing nullish values
1818
TParamRaw = TParam,
1919
> {
2020
get?: (value: NoInfer<TUrlParam>) => TParam

packages/router/src/experimental/route-resolver/resolver-abstract.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export type RecordName = string | symbol
1414
* serialization of params, query, and hash.
1515
*
1616
* - `TMatcherRecordRaw` represents the raw record type passed to {@link addMatcher}.
17-
* - `TMatcherRecord` represents the normalized record type returned by {@link getRecords}.
17+
* - `TMatcherRecord` represents the normalized record type returned by {@link getRoutes}.
1818
*/
1919
export interface EXPERIMENTAL_Resolver_Base<TRecord> {
2020
/**
@@ -44,7 +44,7 @@ export interface EXPERIMENTAL_Resolver_Base<TRecord> {
4444
*/
4545
resolve(
4646
location: ResolverLocationAsNamed,
47-
// TODO: is this useful?
47+
// TODO: is this type strictness useful?
4848
currentLocation?: undefined
4949
// currentLocation?: undefined | NEW_LocationResolved<TMatcherRecord>
5050
): ResolverLocationResolved<TRecord>
@@ -78,16 +78,15 @@ export interface EXPERIMENTAL_Resolver_Base<TRecord> {
7878
): ResolverLocationResolved<TRecord>
7979

8080
/**
81-
* Get a list of all resolver records.
82-
* Previously named `getRoutes()`
81+
* Get a list of all resolver route records.
8382
*/
84-
getRecords(): TRecord[]
83+
getRoutes(): TRecord[]
8584

8685
/**
8786
* Get a resolver record by its name.
8887
* Previously named `getRecordMatcher()`
8988
*/
90-
getRecord(name: RecordName): TRecord | undefined
89+
getRoute(name: RecordName): TRecord | undefined
9190
}
9291

9392
/**

packages/router/src/experimental/route-resolver/resolver-fixed.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ export interface EXPERIMENTAL_ResolverRecord_Base {
6565
*/
6666
export interface EXPERIMENTAL_ResolverRecord_Group
6767
extends EXPERIMENTAL_ResolverRecord_Base {
68+
/**
69+
* A group route cannot be matched directly and so names are not allowed.
70+
*/
6871
name?: undefined
6972
path?: undefined
7073
// Query is the only kind of matcher that is non-exclusive
@@ -74,7 +77,8 @@ export interface EXPERIMENTAL_ResolverRecord_Group
7477
}
7578

7679
/**
77-
* A matchable record is a record that can be matched by a path, query or hash and will resolve to a location.
80+
* A matchable record is a record that can be matched by a path, query or hash
81+
* and will resolve to a location.
7882
*/
7983
export interface EXPERIMENTAL_ResolverRecord_Matchable
8084
extends EXPERIMENTAL_ResolverRecord_Base {
@@ -324,7 +328,7 @@ export function createFixedResolver<
324328

325329
return {
326330
resolve,
327-
getRecords: () => records,
328-
getRecord: name => recordMap.get(name),
331+
getRoutes: () => records,
332+
getRoute: name => recordMap.get(name),
329333
}
330334
}

packages/router/src/experimental/router.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,10 @@ export interface EXPERIMENTAL_RouterOptions
390390
resolver: EXPERIMENTAL_ResolverFixed<EXPERIMENTAL_RouteRecordNormalized_Matchable>
391391
}
392392

393+
// TODO: Make the Router extends the resolver so that it automatically exposes
394+
// getRoutes and resolve. This should make it automatic to have a dynamic
395+
// resolver
396+
393397
/**
394398
* Router base instance.
395399
*
@@ -614,14 +618,6 @@ export function experimental_createRouter(
614618
history.scrollRestoration = 'manual'
615619
}
616620

617-
function getRoutes() {
618-
return resolver.getRecords()
619-
}
620-
621-
function hasRoute(name: NonNullable<RouteRecordNameGeneric>): boolean {
622-
return !!resolver.getRecord(name)
623-
}
624-
625621
// NOTE: to support multiple overloads
626622
type TRecord = EXPERIMENTAL_RouteRecordNormalized
627623
type _resolveArgs =
@@ -1290,8 +1286,8 @@ export function experimental_createRouter(
12901286
currentRoute,
12911287
listening: true,
12921288

1293-
hasRoute,
1294-
getRoutes,
1289+
hasRoute: name => !!resolver.getRoute(name),
1290+
getRoutes: () => resolver.getRoutes(),
12951291
// @ts-expect-error FIXME: update EXPERIMENTAL_Router types
12961292
resolve,
12971293
options,

0 commit comments

Comments
 (0)