@devp0nt/route0 1.0.0-next.67 → 1.0.0-next.68
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/flat0.cjs +2 -0
- package/dist/cjs/flat0.cjs.map +1 -0
- package/dist/cjs/flat0.d.cts +2 -0
- package/dist/cjs/index.cjs +234 -311
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +91 -181
- package/dist/esm/flat0.d.ts +2 -0
- package/dist/esm/flat0.js +1 -0
- package/dist/esm/flat0.js.map +1 -0
- package/dist/esm/index.d.ts +91 -181
- package/dist/esm/index.js +234 -311
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/flat0.ts +0 -0
- package/src/index.test.ts +409 -621
- package/src/index.ts +419 -836
package/dist/cjs/index.d.cts
CHANGED
|
@@ -11,13 +11,18 @@ import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
|
11
11
|
* Instances are callable (same as `.get()`), so `route(input)` and
|
|
12
12
|
* `route.get(input)` are equivalent.
|
|
13
13
|
*/
|
|
14
|
-
declare class Route0<TDefinition extends string> {
|
|
14
|
+
declare class Route0<TDefinition extends string, TSearch extends UnknownSearch = UnknownSearch> {
|
|
15
15
|
readonly definition: TDefinition;
|
|
16
|
-
readonly
|
|
17
|
-
readonly paramsDefinition: _ParamsDefinition<TDefinition>;
|
|
18
|
-
readonly searchDefinition: _SearchDefinition<TDefinition>;
|
|
19
|
-
readonly hasLooseSearch: HasLooseSearch<TDefinition>;
|
|
16
|
+
readonly params: _ParamsDefinition<TDefinition>;
|
|
20
17
|
private _origin;
|
|
18
|
+
private _callable;
|
|
19
|
+
Infer: {
|
|
20
|
+
ParamsDefinition: _ParamsDefinition<TDefinition>;
|
|
21
|
+
ParamsInput: _ParamsInput<TDefinition>;
|
|
22
|
+
ParamsInputStringOnly: _ParamsInputStringOnly<TDefinition>;
|
|
23
|
+
ParamsOutput: ParamsOutput<TDefinition>;
|
|
24
|
+
SearchInput: TSearch;
|
|
25
|
+
};
|
|
21
26
|
/** Base URL used when generating absolute URLs (`abs: true`). */
|
|
22
27
|
get origin(): string;
|
|
23
28
|
set origin(origin: string);
|
|
@@ -33,67 +38,28 @@ declare class Route0<TDefinition extends string> {
|
|
|
33
38
|
*
|
|
34
39
|
* Unlike `create`, passing a callable route returns the same instance.
|
|
35
40
|
*/
|
|
36
|
-
static from<TDefinition extends string>(definition: TDefinition | AnyRoute<TDefinition> | CallableRoute<TDefinition>): CallableRoute<TDefinition>;
|
|
37
|
-
private static _splitPathDefinitionAndSearchTailDefinition;
|
|
41
|
+
static from<TDefinition extends string, TSearch extends UnknownSearch>(definition: TDefinition | AnyRoute<TDefinition, TSearch> | CallableRoute<TDefinition, TSearch>): CallableRoute<TDefinition, TSearch>;
|
|
38
42
|
private static _getAbsPath;
|
|
39
|
-
private static
|
|
40
|
-
|
|
41
|
-
private static _getSearchDefinitionBydefinition;
|
|
42
|
-
private static _hasLooseSearch;
|
|
43
|
+
private static _getParamsDefinitionByDefinition;
|
|
44
|
+
search<TNewSearch extends UnknownSearch>(): CallableRoute<TDefinition, TNewSearch>;
|
|
43
45
|
/** Extends the current route definition by appending a suffix route. */
|
|
44
|
-
extend<TSuffixDefinition extends string>(suffixDefinition: TSuffixDefinition): CallableRoute<PathExtended<TDefinition, TSuffixDefinition
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
search?: _LooseSearchInput<TDefinition>;
|
|
60
|
-
abs?: boolean | string;
|
|
61
|
-
hash?: string | number;
|
|
62
|
-
}>): OnlyIfNoParams<TDefinition, string>;
|
|
63
|
-
/**
|
|
64
|
-
* Flat input variant of `get()`, where path params + search keys
|
|
65
|
-
* are provided in a single object.
|
|
66
|
-
*/
|
|
67
|
-
flat<TLoose extends boolean = HasLooseSearch<TDefinition>>(input: OnlyIfHasParams<TDefinition, WithParamsInput<TDefinition, FlatInput<TDefinition, TLoose> & {
|
|
68
|
-
hash?: string | number;
|
|
69
|
-
}>>, abs?: boolean | string, loose?: TLoose): OnlyIfHasParams<TDefinition, string>;
|
|
70
|
-
flat(...args: OnlyIfNoParams<TDefinition, [], [never]>): string;
|
|
71
|
-
flat<TLoose extends boolean = HasLooseSearch<TDefinition>>(input: OnlyIfNoParams<TDefinition, FlatInput<TDefinition, TLoose> & {
|
|
72
|
-
hash?: string | number;
|
|
73
|
-
}>, abs?: boolean | string, loose?: TLoose): OnlyIfNoParams<TDefinition, string>;
|
|
74
|
-
/** Same as `flat()`, but always accepts loose search keys. */
|
|
75
|
-
flatLoose(input: OnlyIfHasParams<TDefinition, WithParamsInput<TDefinition, LooseFlatInput<TDefinition> & {
|
|
76
|
-
hash?: string | number;
|
|
77
|
-
}>>, abs?: boolean | string): OnlyIfHasParams<TDefinition, string>;
|
|
78
|
-
flatLoose(...args: OnlyIfNoParams<TDefinition, [], [never]>): string;
|
|
79
|
-
flatLoose(input: OnlyIfNoParams<TDefinition, LooseFlatInput<TDefinition> & {
|
|
80
|
-
hash?: string | number;
|
|
81
|
-
}>, abs?: boolean | string): OnlyIfNoParams<TDefinition, string>;
|
|
82
|
-
/** Same as `flat()`, but only allows declared search keys. */
|
|
83
|
-
flatStrict(input: OnlyIfHasParams<TDefinition, WithParamsInput<TDefinition, StrictFlatInput<TDefinition> & {
|
|
84
|
-
hash?: string | number;
|
|
85
|
-
}>>, abs?: boolean | string): OnlyIfHasParams<TDefinition, string>;
|
|
86
|
-
flatStrict(...args: OnlyIfNoParams<TDefinition, [], [never]>): string;
|
|
87
|
-
flatStrict(input: OnlyIfNoParams<TDefinition, StrictFlatInput<TDefinition> & {
|
|
88
|
-
hash?: string | number;
|
|
89
|
-
}>, abs?: boolean | string): OnlyIfNoParams<TDefinition, string>;
|
|
46
|
+
extend<TSuffixDefinition extends string>(suffixDefinition: TSuffixDefinition): CallableRoute<PathExtended<TDefinition, TSuffixDefinition>, TSearch>;
|
|
47
|
+
get(...args: IsParamsOptional<TDefinition> extends true ? [abs: boolean | string | undefined] : never): string;
|
|
48
|
+
get(...args: IsParamsOptional<TDefinition> extends true ? [
|
|
49
|
+
input?: (_ParamsInput<TDefinition> & {
|
|
50
|
+
'?'?: TSearch;
|
|
51
|
+
'#'?: string | number;
|
|
52
|
+
}) | undefined,
|
|
53
|
+
abs?: boolean | string | undefined
|
|
54
|
+
] : [
|
|
55
|
+
input: _ParamsInput<TDefinition> & {
|
|
56
|
+
'?'?: TSearch;
|
|
57
|
+
'#'?: string | number;
|
|
58
|
+
},
|
|
59
|
+
abs?: boolean | string | undefined
|
|
60
|
+
]): string;
|
|
90
61
|
/** Returns path param keys extracted from route definition. */
|
|
91
62
|
getParamsKeys(): string[];
|
|
92
|
-
/** Returns named search keys extracted from route definition. */
|
|
93
|
-
getSearchKeys(): string[];
|
|
94
|
-
/** Returns all flat input keys (`search + params`). */
|
|
95
|
-
getFlatKeys(): string[];
|
|
96
|
-
getDefinition(): string;
|
|
97
63
|
/** Clones route with optional config override. */
|
|
98
64
|
clone(config?: RouteConfigInput): CallableRoute<TDefinition>;
|
|
99
65
|
getRegexBaseStrictString(): string;
|
|
@@ -141,18 +107,10 @@ declare class Route0<TDefinition extends string> {
|
|
|
141
107
|
getLocation(url: AnyLocation): KnownLocation<TDefinition>;
|
|
142
108
|
getLocation(hrefOrHrefRelOrLocation: string | AnyLocation | URL): KnownLocation<TDefinition>;
|
|
143
109
|
private _validateParamsInput;
|
|
144
|
-
private _validateSearchInput;
|
|
145
|
-
private _validateFlatInput;
|
|
146
110
|
private _safeParseSchemaResult;
|
|
147
111
|
private _parseSchemaResult;
|
|
148
112
|
/** Standard Schema for route params input. */
|
|
149
|
-
readonly
|
|
150
|
-
/** Standard Schema for strict search input. */
|
|
151
|
-
readonly strictSearchInputSchema: Route0Schema<StrictSearchInput<TDefinition>, StrictSearchOutput<TDefinition>>;
|
|
152
|
-
/** Standard Schema for loose search input. */
|
|
153
|
-
readonly looseSearchInputSchema: Route0Schema<LooseSearchInput<TDefinition>, LooseSearchOutput<TDefinition>>;
|
|
154
|
-
/** Standard Schema for route flat input (uses route default strict/loose mode). */
|
|
155
|
-
readonly flatInputSchema: Route0Schema<FlatInput<TDefinition, HasLooseSearch<TDefinition>>, FlatOutput<TDefinition, HasLooseSearch<TDefinition>>>;
|
|
113
|
+
readonly paramsSchema: SchemaRoute0<ParamsInput<TDefinition>, ParamsOutput<TDefinition>>;
|
|
156
114
|
/** True when path structure is equal (param names are ignored). */
|
|
157
115
|
isSame(other: AnyRoute): boolean;
|
|
158
116
|
/** Static convenience wrapper for `isSame`. */
|
|
@@ -163,6 +121,8 @@ declare class Route0<TDefinition extends string> {
|
|
|
163
121
|
isAncestor(other: AnyRoute | string | undefined): boolean;
|
|
164
122
|
/** True when two route patterns can match the same concrete URL. */
|
|
165
123
|
isConflict(other: AnyRoute | string | undefined): boolean;
|
|
124
|
+
/** True when paths are same or can overlap when optional parts are omitted. */
|
|
125
|
+
isMayBeSame(other: AnyRoute | string | undefined): boolean;
|
|
166
126
|
/** Specificity comparator used for deterministic route ordering. */
|
|
167
127
|
isMoreSpecificThan(other: AnyRoute | string | undefined): boolean;
|
|
168
128
|
}
|
|
@@ -212,9 +172,9 @@ declare class Routes<const T extends RoutesRecord = any> {
|
|
|
212
172
|
};
|
|
213
173
|
}
|
|
214
174
|
/** Any route instance shape, preserving literal path type when known. */
|
|
215
|
-
type AnyRoute<T extends Route0<string> | string = string> = T extends string ? Route0<T> : T;
|
|
175
|
+
type AnyRoute<T extends Route0<string> | string = string, TSearch extends UnknownSearch = UnknownSearch> = T extends string ? Route0<T, TSearch> : T;
|
|
216
176
|
/** Callable route (`route(input)`) plus route instance methods/properties. */
|
|
217
|
-
type CallableRoute<T extends Route0<string> | string = string> = AnyRoute<T> & AnyRoute<T>['get'];
|
|
177
|
+
type CallableRoute<T extends Route0<string> | string = string, TSearch extends UnknownSearch = UnknownSearch> = AnyRoute<T, TSearch> & AnyRoute<T, TSearch>['get'];
|
|
218
178
|
/** Route input accepted by most APIs: definition string or route object/callable. */
|
|
219
179
|
type AnyRouteOrDefinition<T extends string = string> = AnyRoute<T> | CallableRoute<T> | T;
|
|
220
180
|
/** Route-level runtime configuration. */
|
|
@@ -232,67 +192,23 @@ type RoutesPretty<TRoutesRecord extends RoutesRecord = any> = RoutesRecordHydrat
|
|
|
232
192
|
type ExtractRoutesKeys<TRoutes extends RoutesPretty | RoutesRecord> = TRoutes extends RoutesPretty ? Extract<keyof TRoutes['_']['routes'], string> : TRoutes extends RoutesRecord ? Extract<keyof TRoutes, string> : never;
|
|
233
193
|
type ExtractRoute<TRoutes extends RoutesPretty | RoutesRecord, TKey extends ExtractRoutesKeys<TRoutes>> = TRoutes extends RoutesPretty ? TRoutes['_']['routes'][TKey] : TRoutes extends RoutesRecord ? TRoutes[TKey] : never;
|
|
234
194
|
type Definition<T extends AnyRoute | string> = T extends AnyRoute ? T['definition'] : T extends string ? T : never;
|
|
235
|
-
type
|
|
236
|
-
type
|
|
237
|
-
type
|
|
238
|
-
type
|
|
239
|
-
type
|
|
240
|
-
type IsDescendant<T extends AnyRoute | string, TDescendant extends AnyRoute | string> = _IsDescendant<PathDefinition<T>, PathDefinition<TDescendant>>;
|
|
241
|
-
type IsSame<T extends AnyRoute | string, TExact extends AnyRoute | string> = _IsSame<PathDefinition<T>, PathDefinition<TExact>>;
|
|
195
|
+
type ParamsDefinition<T extends AnyRoute | string> = T extends AnyRoute ? T['params'] : T extends string ? _ParamsDefinition<T> : undefined;
|
|
196
|
+
type Extended<T extends AnyRoute | string | undefined, TSuffixDefinition extends string, TSearch extends UnknownSearch = UnknownSearch> = T extends AnyRoute ? Route0<PathExtended<T['definition'], TSuffixDefinition>, TSearch> : T extends string ? Route0<PathExtended<T, TSuffixDefinition>, TSearch> : T extends undefined ? Route0<TSuffixDefinition, TSearch> : never;
|
|
197
|
+
type IsAncestor<T extends AnyRoute | string, TAncestor extends AnyRoute | string> = _IsAncestor<Definition<T>, Definition<TAncestor>>;
|
|
198
|
+
type IsDescendant<T extends AnyRoute | string, TDescendant extends AnyRoute | string> = _IsDescendant<Definition<T>, Definition<TDescendant>>;
|
|
199
|
+
type IsSame<T extends AnyRoute | string, TExact extends AnyRoute | string> = _IsSame<Definition<T>, Definition<TExact>>;
|
|
242
200
|
type IsSameParams<T1 extends AnyRoute | string, T2 extends AnyRoute | string> = _IsSameParams<ParamsDefinition<T1>, ParamsDefinition<T2>>;
|
|
243
|
-
type HasParams<T extends AnyRoute | string> =
|
|
244
|
-
type
|
|
245
|
-
type HasNamedSearch<T extends AnyRoute | string> = SearchTailDefinitionWithoutFirstAndLastAmp<Definition<T>> extends '' ? false : true;
|
|
246
|
-
type HasLooseSearch<T extends AnyRoute | string> = Definition<T> extends `${string}&` ? true : false;
|
|
201
|
+
type HasParams<T extends AnyRoute | string> = keyof _ParamsDefinition<Definition<T>> extends never ? false : true;
|
|
202
|
+
type HasRequiredParams<T extends AnyRoute | string> = _RequiredParamKeys<Definition<T>> extends never ? false : true;
|
|
247
203
|
type ParamsOutput<T extends AnyRoute | string> = {
|
|
248
|
-
[K in keyof ParamsDefinition<T>]: string;
|
|
249
|
-
};
|
|
250
|
-
type LooseSearchOutput<T extends AnyRoute | string = string> = Partial<{
|
|
251
|
-
[K in keyof SearchDefinition<T>]?: string;
|
|
252
|
-
} & Record<string, string | undefined>>;
|
|
253
|
-
type StrictSearchOutput<T extends AnyRoute | string> = Partial<{
|
|
254
|
-
[K in keyof SearchDefinition<T>]?: string | undefined;
|
|
255
|
-
}>;
|
|
256
|
-
type LooseFlatOutput<T extends AnyRoute | string = string> = HasParams<Definition<T>> extends true ? ParamsOutput<T> & LooseSearchOutput<T> : LooseSearchOutput<T>;
|
|
257
|
-
type StrictFlatOutput<T extends AnyRoute | string> = HasParams<Definition<T>> extends true ? ParamsOutput<T> & StrictSearchOutput<T> : StrictSearchOutput<T>;
|
|
258
|
-
type FlatOutput<T extends AnyRoute | string, TLoose extends boolean = HasLooseSearch<T>> = TLoose extends true ? LooseFlatOutput<T> : StrictFlatOutput<T>;
|
|
259
|
-
type LooseFlatOutputWithHash<T extends AnyRoute | string = string> = LooseFlatOutput<T> & {
|
|
260
|
-
hash?: string | undefined;
|
|
204
|
+
[K in keyof ParamsDefinition<T>]: ParamsDefinition<T>[K] extends true ? string : string | undefined;
|
|
261
205
|
};
|
|
262
|
-
type
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
type FlatOutputWithHash<T extends AnyRoute | string, TLoose extends boolean = HasLooseSearch<T>> = FlatOutput<T, TLoose> & {
|
|
266
|
-
hash?: string | undefined;
|
|
267
|
-
};
|
|
268
|
-
type ParamsInput<T extends AnyRoute | string = string> = _ParamsInput<PathDefinition<T>>;
|
|
269
|
-
type LooseSearchInput<T extends AnyRoute | string = string> = _LooseSearchInput<Definition<T>>;
|
|
270
|
-
type StrictSearchInput<T extends AnyRoute | string> = _StrictSearchInput<Definition<T>>;
|
|
271
|
-
type LooseFlatInput<T extends AnyRoute | string> = _LooseFlatInput<Definition<T>>;
|
|
272
|
-
type StrictFlatInput<T extends AnyRoute | string> = _StrictFlatInput<Definition<T>>;
|
|
273
|
-
type FlatInput<T extends AnyRoute | string, TLoose extends boolean = HasLooseSearch<T>> = TLoose extends true ? LooseFlatInput<T> : StrictFlatInput<T>;
|
|
274
|
-
type LooseFlatInputWithHash<T extends AnyRoute | string> = LooseFlatInput<T> & {
|
|
275
|
-
hash?: string | number;
|
|
276
|
-
};
|
|
277
|
-
type StrictFlatInputWithHash<T extends AnyRoute | string> = StrictFlatInput<T> & {
|
|
278
|
-
hash?: string | number;
|
|
279
|
-
};
|
|
280
|
-
type FlatInputWithHash<T extends AnyRoute | string, TLoose extends boolean = HasLooseSearch<T>> = FlatInput<T, TLoose> & {
|
|
281
|
-
hash?: string | number;
|
|
282
|
-
};
|
|
283
|
-
type CanInputBeEmpty<T extends AnyRoute | string> = HasParams<Definition<T>> extends true ? false : true;
|
|
284
|
-
type ParamsInputStringOnly<T extends AnyRoute | string = string> = _ParamsInputStringOnly<PathDefinition<T>>;
|
|
285
|
-
type LooseSearchInputStringOnly<T extends AnyRoute | string = string> = _LooseSearchInputStringOnly<Definition<T>>;
|
|
286
|
-
type StrictSearchInputStringOnly<T extends AnyRoute | string> = _StrictSearchInputStringOnly<Definition<T>>;
|
|
287
|
-
type LooseFlatInputStringOnly<T extends AnyRoute | string> = _LooseFlatInputStringOnly<Definition<T>>;
|
|
288
|
-
type StrictFlatInputStringOnly<T extends AnyRoute | string> = _StrictFlatInputStringOnly<Definition<T>>;
|
|
289
|
-
type FlatInputStringOnly<T extends AnyRoute | string, TLoose extends boolean = HasLooseSearch<T>> = TLoose extends true ? LooseFlatInputStringOnly<T> : StrictFlatInputStringOnly<T>;
|
|
206
|
+
type ParamsInput<T extends AnyRoute | string = string> = _ParamsInput<Definition<T>>;
|
|
207
|
+
type IsParamsOptional<T extends AnyRoute | string> = HasRequiredParams<Definition<T>> extends true ? false : true;
|
|
208
|
+
type ParamsInputStringOnly<T extends AnyRoute | string = string> = _ParamsInputStringOnly<Definition<T>>;
|
|
290
209
|
type LocationParams<TDefinition extends string> = {
|
|
291
|
-
[K in keyof _ParamsDefinition<TDefinition>]: string;
|
|
210
|
+
[K in keyof _ParamsDefinition<TDefinition>]: _ParamsDefinition<TDefinition>[K] extends true ? string : string | undefined;
|
|
292
211
|
};
|
|
293
|
-
type LocationSearch<TDefinition extends string = string> = {
|
|
294
|
-
[K in keyof _SearchDefinition<TDefinition>]: string | undefined;
|
|
295
|
-
} & Record<string, string | undefined>;
|
|
296
212
|
/**
|
|
297
213
|
* URL location primitives independent from route-matching state.
|
|
298
214
|
*
|
|
@@ -371,7 +287,7 @@ type UnknownLocationState = {
|
|
|
371
287
|
known: false;
|
|
372
288
|
route: undefined;
|
|
373
289
|
params: undefined;
|
|
374
|
-
searchParams:
|
|
290
|
+
searchParams: UnknownSearch;
|
|
375
291
|
exact: false;
|
|
376
292
|
ancestor: false;
|
|
377
293
|
descendant: false;
|
|
@@ -395,7 +311,7 @@ type ExactLocationState<TRoute extends AnyRoute | string = AnyRoute | string> =
|
|
|
395
311
|
known: true;
|
|
396
312
|
route: Definition<TRoute>;
|
|
397
313
|
params: ParamsOutput<TRoute>;
|
|
398
|
-
searchParams:
|
|
314
|
+
searchParams: UnknownSearch;
|
|
399
315
|
exact: true;
|
|
400
316
|
ancestor: false;
|
|
401
317
|
descendant: false;
|
|
@@ -407,7 +323,7 @@ type AncestorLocationState<TRoute extends AnyRoute | string = AnyRoute | string>
|
|
|
407
323
|
known: true;
|
|
408
324
|
route: Definition<TRoute>;
|
|
409
325
|
params: ParamsOutput<TRoute>;
|
|
410
|
-
searchParams:
|
|
326
|
+
searchParams: UnknownSearch;
|
|
411
327
|
exact: false;
|
|
412
328
|
ancestor: true;
|
|
413
329
|
descendant: false;
|
|
@@ -419,7 +335,7 @@ type WeakAncestorLocationState<TRoute extends AnyRoute | string = AnyRoute | str
|
|
|
419
335
|
known: true;
|
|
420
336
|
route: Definition<TRoute>;
|
|
421
337
|
params: ParamsOutput<TRoute>;
|
|
422
|
-
searchParams:
|
|
338
|
+
searchParams: UnknownSearch;
|
|
423
339
|
exact: false;
|
|
424
340
|
ancestor: true;
|
|
425
341
|
descendant: false;
|
|
@@ -431,19 +347,20 @@ type DescendantLocationState<TRoute extends AnyRoute | string = AnyRoute | strin
|
|
|
431
347
|
known: true;
|
|
432
348
|
route: Definition<TRoute>;
|
|
433
349
|
params: Partial<ParamsOutput<TRoute>>;
|
|
434
|
-
searchParams:
|
|
350
|
+
searchParams: UnknownSearch;
|
|
435
351
|
exact: false;
|
|
436
352
|
ancestor: false;
|
|
437
353
|
descendant: true;
|
|
438
354
|
unmatched: false;
|
|
439
355
|
};
|
|
440
356
|
type DescendantLocation<TRoute extends AnyRoute | string = AnyRoute | string> = _GeneralLocation & DescendantLocationState<TRoute>;
|
|
357
|
+
type UnknownSearch = Record<string, unknown>;
|
|
441
358
|
/** It is when route not match at all, but params partially match. */
|
|
442
359
|
type WeakDescendantLocationState<TRoute extends AnyRoute | string = AnyRoute | string> = {
|
|
443
360
|
known: true;
|
|
444
361
|
route: Definition<TRoute>;
|
|
445
362
|
params: Partial<ParamsOutput<TRoute>>;
|
|
446
|
-
searchParams:
|
|
363
|
+
searchParams: UnknownSearch;
|
|
447
364
|
exact: false;
|
|
448
365
|
ancestor: false;
|
|
449
366
|
descendant: true;
|
|
@@ -452,54 +369,49 @@ type WeakDescendantLocationState<TRoute extends AnyRoute | string = AnyRoute | s
|
|
|
452
369
|
type WeakDescendantLocation<TRoute extends AnyRoute | string = AnyRoute | string> = _GeneralLocation & WeakDescendantLocationState<TRoute>;
|
|
453
370
|
type KnownLocation<TRoute extends AnyRoute | string = AnyRoute | string> = UnmatchedLocation<TRoute> | ExactLocation<TRoute> | AncestorLocation<TRoute> | WeakAncestorLocation<TRoute> | DescendantLocation<TRoute> | WeakDescendantLocation<TRoute>;
|
|
454
371
|
type AnyLocation<TRoute extends AnyRoute | string = AnyRoute | string> = UnknownLocation | KnownLocation<TRoute>;
|
|
455
|
-
type
|
|
456
|
-
type
|
|
457
|
-
[K in
|
|
458
|
-
}
|
|
459
|
-
type
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
[K in keyof
|
|
464
|
-
}
|
|
465
|
-
type
|
|
466
|
-
[K in keyof
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
}
|
|
471
|
-
type
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
[K in
|
|
372
|
+
type _ParamsDefinition<TDefinition extends string> = _ExtractParamsDefinitionBySegments<_SplitPathSegments<Definition<TDefinition>>>;
|
|
373
|
+
type _Simplify<T> = {
|
|
374
|
+
[K in keyof T]: T[K];
|
|
375
|
+
} & {};
|
|
376
|
+
type _IfNoKeys<T extends object, TYes, TNo> = keyof T extends never ? TYes : TNo;
|
|
377
|
+
type _ParamsInput<TDefinition extends string> = _ParamsDefinition<TDefinition> extends infer TDef extends Record<string, boolean> ? _IfNoKeys<TDef, Record<never, never>, _Simplify<{
|
|
378
|
+
[K in keyof TDef as TDef[K] extends true ? K : never]: string | number;
|
|
379
|
+
} & {
|
|
380
|
+
[K in keyof TDef as TDef[K] extends false ? K : never]?: string | number | undefined;
|
|
381
|
+
}>> : Record<never, never>;
|
|
382
|
+
type _ParamsInputStringOnly<TDefinition extends string> = _ParamsDefinition<TDefinition> extends infer TDef extends Record<string, boolean> ? _IfNoKeys<TDef, Record<never, never>, _Simplify<{
|
|
383
|
+
[K in keyof TDef as TDef[K] extends true ? K : never]: string;
|
|
384
|
+
} & {
|
|
385
|
+
[K in keyof TDef as TDef[K] extends false ? K : never]?: string | undefined;
|
|
386
|
+
}>> : Record<never, never>;
|
|
387
|
+
type _SplitPathSegments<TPath extends string> = TPath extends '' ? [] : TPath extends '/' ? [] : TPath extends `/${infer Rest}` ? _SplitPathSegments<Rest> : TPath extends `${infer Segment}/${infer Rest}` ? Segment extends '' ? _SplitPathSegments<Rest> : [Segment, ..._SplitPathSegments<Rest>] : TPath extends '' ? [] : [TPath];
|
|
388
|
+
type _ParamDefinitionFromSegment<TSegment extends string> = TSegment extends `:${infer Name}?` ? {
|
|
389
|
+
[K in Name]: false;
|
|
390
|
+
} : TSegment extends `:${infer Name}` ? {
|
|
391
|
+
[K in Name]: true;
|
|
392
|
+
} : TSegment extends `${string}*?` ? {
|
|
393
|
+
'*': false;
|
|
394
|
+
} : TSegment extends `${string}*` ? {
|
|
395
|
+
'*': true;
|
|
396
|
+
} : Record<never, never>;
|
|
397
|
+
type _MergeParamDefinitions<A extends Record<string, boolean>, B extends Record<string, boolean>> = {
|
|
398
|
+
[K in keyof A | keyof B]: K extends keyof B ? B[K] : K extends keyof A ? A[K] : never;
|
|
475
399
|
};
|
|
476
|
-
type
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
type _StrictFlatInputStringOnly<TDefinition extends string> = HasParams<TDefinition> extends true ? HasNamedSearch<TDefinition> extends true ? _StrictSearchInputStringOnly<TDefinition> & _ParamsInputStringOnly<TDefinition> : _ParamsInputStringOnly<TDefinition> : HasNamedSearch<TDefinition> extends true ? _StrictSearchInputStringOnly<TDefinition> : Record<never, never>;
|
|
484
|
-
type TrimSearchTailDefinition<S extends string> = S extends `${infer P}&${string}` ? P : S;
|
|
485
|
-
type SearchTailDefinitionWithoutFirstAmp<S extends string> = S extends `${string}&${infer T}` ? T : '';
|
|
486
|
-
type SearchTailDefinitionWithoutFirstAndLastAmp<S extends string> = S extends `${string}&${infer T}&` ? T : S extends `${string}&${infer T}` ? T : '';
|
|
487
|
-
type SearchTailDefinitionWithFirstAmp<S extends string> = S extends `${string}&${infer T}` ? `&${T}` : '';
|
|
488
|
-
type AmpSplit<S extends string> = S extends `${infer A}&${infer B}` ? A | AmpSplit<B> : S;
|
|
489
|
-
type NonEmpty<T> = [T] extends ['' | never] ? never : T;
|
|
490
|
-
type ExtractPathParams<S extends string> = S extends `${string}:${infer After}` ? After extends `${infer Name}/${infer Rest}` ? Name | ExtractPathParams<`/${Rest}`> : After : never;
|
|
400
|
+
type _ExtractParamsDefinitionBySegments<TSegments extends string[]> = TSegments extends [
|
|
401
|
+
infer Segment extends string,
|
|
402
|
+
...infer Rest extends string[]
|
|
403
|
+
] ? _MergeParamDefinitions<_ParamDefinitionFromSegment<Segment>, _ExtractParamsDefinitionBySegments<Rest>> : Record<never, never>;
|
|
404
|
+
type _RequiredParamKeys<TDefinition extends string> = {
|
|
405
|
+
[K in keyof _ParamsDefinition<TDefinition>]: _ParamsDefinition<TDefinition>[K] extends true ? K : never;
|
|
406
|
+
}[keyof _ParamsDefinition<TDefinition>];
|
|
491
407
|
type ReplacePathParams<S extends string> = S extends `${infer Head}:${infer Tail}` ? Tail extends `${infer _Param}/${infer Rest}` ? ReplacePathParams<`${Head}${string}/${Rest}`> : `${Head}${string}` : S;
|
|
492
408
|
type DedupeSlashes<S extends string> = S extends `${infer A}//${infer B}` ? DedupeSlashes<`${A}/${B}`> : S;
|
|
493
409
|
type EmptyRecord = Record<never, never>;
|
|
494
|
-
type JoinPath<Parent extends string, Suffix extends string> = DedupeSlashes<
|
|
410
|
+
type JoinPath<Parent extends string, Suffix extends string> = DedupeSlashes<Definition<Parent> extends infer A extends string ? Definition<Suffix> extends infer B extends string ? A extends '' ? B extends '' ? '' : B extends `/${string}` ? B : `/${B}` : B extends '' ? A : A extends `${string}/` ? `${A}${B}` : B extends `/${string}` ? `${A}${B}` : `${A}/${B}` : never : never>;
|
|
495
411
|
type OnlyIfNoParams<TRoute extends AnyRoute | string, Yes, No = never> = HasParams<TRoute> extends false ? Yes : No;
|
|
496
412
|
type OnlyIfHasParams<TRoute extends AnyRoute | string, Yes, No = never> = HasParams<TRoute> extends true ? Yes : No;
|
|
497
|
-
type PathExtended<
|
|
498
|
-
type
|
|
499
|
-
search?: _LooseSearchInput<any>;
|
|
500
|
-
abs?: boolean | string;
|
|
501
|
-
hash?: string | number;
|
|
502
|
-
} | undefined = undefined> = _ParamsInput<TDefinition> & (T extends undefined ? Record<never, never> : T);
|
|
413
|
+
type PathExtended<TSourceDefinitionDefinition extends string, TSuffixDefinitionDefinition extends string> = `${JoinPath<TSourceDefinitionDefinition, TSuffixDefinitionDefinition>}`;
|
|
414
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
503
415
|
type _IsSameParams<T1 extends object | undefined, T2 extends object | undefined> = T1 extends undefined ? T2 extends undefined ? true : false : T2 extends undefined ? false : T1 extends T2 ? T2 extends T1 ? true : false : false;
|
|
504
416
|
type _IsAncestor<T extends string, TAncestor extends string> = T extends TAncestor ? false : T extends `${TAncestor}${string}` ? true : false;
|
|
505
417
|
type _IsDescendant<T extends string, TDescendant extends string> = TDescendant extends T ? false : TDescendant extends `${T}${string}` ? true : false;
|
|
@@ -513,11 +425,9 @@ type _SafeParseInputResult<TInputParsed extends Record<string, unknown>> = {
|
|
|
513
425
|
data: undefined;
|
|
514
426
|
error: Error;
|
|
515
427
|
};
|
|
516
|
-
type
|
|
517
|
-
type SafeParseInputLooseResult<TDefinition extends string> = _SafeParseInputResult<LooseFlatOutput<TDefinition>>;
|
|
518
|
-
type Route0Schema<TInput extends Record<string, unknown>, TOutput extends Record<string, unknown>> = StandardSchemaV1<TInput, TOutput> & {
|
|
428
|
+
type SchemaRoute0<TInput extends Record<string, unknown>, TOutput extends Record<string, unknown>> = StandardSchemaV1<TInput, TOutput> & {
|
|
519
429
|
parse: (input: unknown) => TOutput;
|
|
520
430
|
safeParse: (input: unknown) => _SafeParseInputResult<TOutput>;
|
|
521
431
|
};
|
|
522
432
|
|
|
523
|
-
export { type
|
|
433
|
+
export { type AncestorLocation, type AncestorLocationState, type AnyLocation, type AnyRoute, type AnyRouteOrDefinition, type CallableRoute, type DedupeSlashes, type Definition, type DescendantLocation, type DescendantLocationState, type EmptyRecord, type ExactLocation, type ExactLocationState, type Extended, type ExtractRoute, type ExtractRoutesKeys, type HasParams, type HasRequiredParams, type IsAncestor, type IsAny, type IsDescendant, type IsParamsOptional, type IsSame, type IsSameParams, type JoinPath, type KnownLocation, type LocationParams, type OnlyIfHasParams, type OnlyIfNoParams, type ParamsDefinition, type ParamsInput, type ParamsInputStringOnly, type ParamsOutput, type PathExtended, type ReplacePathParams, Route0, type RouteConfigInput, Routes, type RoutesPretty, type RoutesRecord, type RoutesRecordHydrated, type SchemaRoute0, type UnknownLocation, type UnknownLocationState, type UnknownSearch, type UnmatchedLocation, type UnmatchedLocationState, type WeakAncestorLocation, type WeakAncestorLocationState, type WeakDescendantLocation, type WeakDescendantLocationState, type _ExtractParamsDefinitionBySegments, type _GeneralLocation, type _IfNoKeys, type _IsAncestor, type _IsDescendant, type _IsSame, type _IsSameParams, type _MergeParamDefinitions, type _ParamDefinitionFromSegment, type _ParamsDefinition, type _ParamsInput, type _ParamsInputStringOnly, type _RequiredParamKeys, type _SafeParseInputResult, type _Simplify, type _SplitPathSegments };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=flat0.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|