1
1
import { normalizeQuery , parseQuery , stringifyQuery } from '../../query'
2
2
import {
3
- LocationNormalized ,
3
+ type LocationNormalized ,
4
4
NEW_stringifyURL ,
5
5
parseURL ,
6
6
resolveRelativePath ,
7
7
} 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'
20
8
import type {
21
9
MatcherPatternPath ,
22
10
MatcherPatternHash ,
11
+ MatcherPattern ,
12
+ MatcherParamsFormatted ,
13
+ MatcherQueryParams ,
23
14
} 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'
24
25
import type { MatcherPatternQuery } from './matchers/matcher-pattern-query'
25
26
import { warn } from '../../warning'
26
27
28
+ /**
29
+ * Base interface for a resolver record that can be extended.
30
+ */
27
31
export interface EXPERIMENTAL_ResolverRecord_Base {
28
32
/**
29
33
* Name of the matcher. Unique across all matchers. If missing, this record
@@ -46,6 +50,10 @@ export interface EXPERIMENTAL_ResolverRecord_Base {
46
50
*/
47
51
hash ?: MatcherPatternHash
48
52
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
+ */
49
57
parent ?: EXPERIMENTAL_ResolverRecord | null // the parent can be matchable or not
50
58
51
59
// TODO: implement aliases
@@ -74,13 +82,17 @@ export interface EXPERIMENTAL_ResolverRecord_Matchable
74
82
path : MatcherPatternPath
75
83
}
76
84
85
+ /**
86
+ * A record that can be passed to the resolver. It can be extended via the
87
+ * `ExtensionT` type param.
88
+ */
77
89
export type EXPERIMENTAL_ResolverRecord < ExtensionT = { } > =
78
90
| ( EXPERIMENTAL_ResolverRecord_Matchable & ExtensionT )
79
91
| ( EXPERIMENTAL_ResolverRecord_Group & ExtensionT )
80
92
81
- export type EXPERIMENTAL_ResolverFixedRecord < ExtensionT = { } > =
82
- EXPERIMENTAL_ResolverRecord < ExtensionT >
83
-
93
+ /**
94
+ * @alias EXPERIMENTAL_Resolver_Base
95
+ */
84
96
export interface EXPERIMENTAL_ResolverFixed < TRecord >
85
97
extends EXPERIMENTAL_Resolver_Base < TRecord > { }
86
98
@@ -207,7 +219,7 @@ export function createFixedResolver<
207
219
208
220
if ( typeof to === 'object' && to . hash && ! to . hash . startsWith ( '#' ) ) {
209
221
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 } ".`
211
223
)
212
224
}
213
225
}
@@ -307,7 +319,6 @@ export function createFixedResolver<
307
319
params : parsedParams ,
308
320
matched,
309
321
}
310
- // TODO: handle object location { path, query, hash }
311
322
}
312
323
}
313
324
0 commit comments