11import { normalizeQuery , parseQuery , stringifyQuery } from '../../query'
22import {
3- LocationNormalized ,
3+ type LocationNormalized ,
44 NEW_stringifyURL ,
55 parseURL ,
66 resolveRelativePath ,
77} from '../../location'
8- import { MatcherParamsFormatted } from './matchers/matcher-pattern'
9- import { ResolverLocationAsRelative } from './resolver-abstract'
10- import { ResolverLocationAsPathAbsolute } from './resolver-abstract'
11- import { ResolverLocationAsPathRelative } from './resolver-abstract'
12- import { ResolverLocationAsNamed } from './resolver-abstract'
13- import {
14- RecordName ,
15- ResolverLocationResolved ,
16- EXPERIMENTAL_Resolver_Base ,
17- NO_MATCH_LOCATION ,
18- } from './resolver-abstract'
19- import { MatcherQueryParams } from './matchers/matcher-pattern'
208import type {
219 MatcherPatternPath ,
2210 MatcherPatternHash ,
11+ MatcherPattern ,
12+ MatcherParamsFormatted ,
13+ MatcherQueryParams ,
2314} from './matchers/matcher-pattern'
15+ import type {
16+ ResolverLocationAsRelative ,
17+ ResolverLocationAsPathAbsolute ,
18+ ResolverLocationAsPathRelative ,
19+ ResolverLocationAsNamed ,
20+ RecordName ,
21+ ResolverLocationResolved ,
22+ EXPERIMENTAL_Resolver_Base ,
23+ } from './resolver-abstract'
24+ import { NO_MATCH_LOCATION } from './resolver-abstract'
2425import type { MatcherPatternQuery } from './matchers/matcher-pattern-query'
2526import { warn } from '../../warning'
2627
28+ /**
29+ * Base interface for a resolver record that can be extended.
30+ */
2731export interface EXPERIMENTAL_ResolverRecord_Base {
2832 /**
2933 * Name of the matcher. Unique across all matchers. If missing, this record
@@ -46,6 +50,10 @@ export interface EXPERIMENTAL_ResolverRecord_Base {
4650 */
4751 hash ?: MatcherPatternHash
4852
53+ /**
54+ * Parent record. The parent can be a group or a matchable record.
55+ * It will be included in the `matched` array of a resolved location.
56+ */
4957 parent ?: EXPERIMENTAL_ResolverRecord | null // the parent can be matchable or not
5058
5159 // TODO: implement aliases
@@ -74,13 +82,17 @@ export interface EXPERIMENTAL_ResolverRecord_Matchable
7482 path : MatcherPatternPath
7583}
7684
85+ /**
86+ * A record that can be passed to the resolver. It can be extended via the
87+ * `ExtensionT` type param.
88+ */
7789export type EXPERIMENTAL_ResolverRecord < ExtensionT = { } > =
7890 | ( EXPERIMENTAL_ResolverRecord_Matchable & ExtensionT )
7991 | ( EXPERIMENTAL_ResolverRecord_Group & ExtensionT )
8092
81- export type EXPERIMENTAL_ResolverFixedRecord < ExtensionT = { } > =
82- EXPERIMENTAL_ResolverRecord < ExtensionT >
83-
93+ /**
94+ * @alias EXPERIMENTAL_Resolver_Base
95+ */
8496export interface EXPERIMENTAL_ResolverFixed < TRecord >
8597 extends EXPERIMENTAL_Resolver_Base < TRecord > { }
8698
@@ -207,7 +219,7 @@ export function createFixedResolver<
207219
208220 if ( typeof to === 'object' && to . hash && ! to . hash . startsWith ( '#' ) ) {
209221 warn (
210- `A \` hash\` should always start with the character "#". Replace "${ to . hash } " with "#${ to . hash } ".`
222+ `A " hash" should always start with the character "#". Replace "${ to . hash } " with "#${ to . hash } ".`
211223 )
212224 }
213225 }
@@ -307,7 +319,6 @@ export function createFixedResolver<
307319 params : parsedParams ,
308320 matched,
309321 }
310- // TODO: handle object location { path, query, hash }
311322 }
312323 }
313324
0 commit comments