@devp0nt/route0 1.0.0-next.3 → 1.0.0-next.30

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.
@@ -1,99 +1,255 @@
1
- declare class Route0<TPathOriginalDefinition extends string, TPathDefinition extends Route0._PathDefinition<TPathOriginalDefinition>, TParamsDefinition extends Route0._ParamsDefinition<TPathOriginalDefinition>, TQueryDefinition extends Route0._QueryDefinition<TPathOriginalDefinition>> {
2
- pathOriginalDefinition: TPathOriginalDefinition;
3
- private pathDefinition;
4
- paramsDefinition: TParamsDefinition;
5
- queryDefinition: TQueryDefinition;
1
+ declare class Route0<TDefinition extends string> {
2
+ readonly definition: TDefinition;
3
+ readonly pathDefinition: _PathDefinition<TDefinition>;
4
+ readonly paramsDefinition: _ParamsDefinition<TDefinition>;
5
+ readonly searchDefinition: _SearchDefinition<TDefinition>;
6
6
  baseUrl: string;
7
7
  private constructor();
8
- static create<TPathOriginalDefinition extends string, TPathDefinition extends Route0._PathDefinition<TPathOriginalDefinition>, TParamsDefinition extends Route0._ParamsDefinition<TPathOriginalDefinition>, TQueryDefinition extends Route0._QueryDefinition<TPathOriginalDefinition>>(definition: TPathOriginalDefinition, config?: Route0.RouteConfigInput): Route0.Callable<Route0<TPathOriginalDefinition, TPathDefinition, TParamsDefinition, TQueryDefinition>>;
9
- private static _splitPathDefinitionAndQueryTailDefinition;
8
+ static create<TDefinition extends string>(definition: TDefinition | AnyRoute<TDefinition>, config?: RouteConfigInput): CallabelRoute<TDefinition>;
9
+ private static _splitPathDefinitionAndSearchTailDefinition;
10
10
  private static _getAbsPath;
11
- private static _getPathDefinitionByOriginalDefinition;
12
- private static _getParamsDefinitionByRouteDefinition;
13
- private static _getQueryDefinitionByRouteDefinition;
14
- static overrideMany<T extends Record<string, Route0<any, any, any, any>>>(routes: T, config: Route0.RouteConfigInput): T;
15
- extend<TSuffixDefinition extends string>(suffixDefinition: TSuffixDefinition): Route0.Callable<Route0<Route0._RoutePathOriginalDefinitionExtended<TPathOriginalDefinition, TSuffixDefinition>, Route0._PathDefinition<Route0._RoutePathOriginalDefinitionExtended<TPathOriginalDefinition, TSuffixDefinition>>, Route0._ParamsDefinition<Route0._RoutePathOriginalDefinitionExtended<TPathOriginalDefinition, TSuffixDefinition>>, Route0._QueryDefinition<Route0._RoutePathOriginalDefinitionExtended<TPathOriginalDefinition, TSuffixDefinition>>>>;
16
- get(input: Route0._OnlyIfHasParams<TParamsDefinition, Route0._WithParamsInput<TParamsDefinition, {
17
- query?: undefined;
11
+ private static _getPathDefinitionBydefinition;
12
+ private static _getParamsDefinitionBydefinition;
13
+ private static _getSearchDefinitionBydefinition;
14
+ extend<TSuffixDefinition extends string>(suffixDefinition: TSuffixDefinition): CallabelRoute<PathExtended<TDefinition, TSuffixDefinition>>;
15
+ get(input: OnlyIfHasParams<_ParamsDefinition<TDefinition>, WithParamsInput<TDefinition, {
16
+ search?: undefined;
18
17
  abs?: false;
19
- }>>): Route0._OnlyIfHasParams<TParamsDefinition, Route0._PathOnlyRouteValue<TPathOriginalDefinition>>;
20
- get(input: Route0._OnlyIfHasParams<TParamsDefinition, Route0._WithParamsInput<TParamsDefinition, {
21
- query: Route0._QueryInput<TQueryDefinition>;
18
+ }>>): OnlyIfHasParams<_ParamsDefinition<TDefinition>, PathOnlyRouteValue<TDefinition>>;
19
+ get(input: OnlyIfHasParams<_ParamsDefinition<TDefinition>, WithParamsInput<TDefinition, {
20
+ search: _SearchInput<TDefinition>;
22
21
  abs?: false;
23
- }>>): Route0._OnlyIfHasParams<TParamsDefinition, Route0._WithQueryRouteValue<TPathOriginalDefinition>>;
24
- get(input: Route0._OnlyIfHasParams<TParamsDefinition, Route0._WithParamsInput<TParamsDefinition, {
25
- query?: undefined;
22
+ }>>): OnlyIfHasParams<_ParamsDefinition<TDefinition>, WithSearchRouteValue<TDefinition>>;
23
+ get(input: OnlyIfHasParams<_ParamsDefinition<TDefinition>, WithParamsInput<TDefinition, {
24
+ search?: undefined;
26
25
  abs: true;
27
- }>>): Route0._OnlyIfHasParams<TParamsDefinition, Route0._AbsolutePathOnlyRouteValue<TPathOriginalDefinition>>;
28
- get(input: Route0._OnlyIfHasParams<TParamsDefinition, Route0._WithParamsInput<TParamsDefinition, {
29
- query: Route0._QueryInput<TQueryDefinition>;
26
+ }>>): OnlyIfHasParams<_ParamsDefinition<TDefinition>, AbsolutePathOnlyRouteValue<TDefinition>>;
27
+ get(input: OnlyIfHasParams<_ParamsDefinition<TDefinition>, WithParamsInput<TDefinition, {
28
+ search: _SearchInput<TDefinition>;
30
29
  abs: true;
31
- }>>): Route0._OnlyIfHasParams<TParamsDefinition, Route0._AbsoluteWithQueryRouteValue<TPathOriginalDefinition>>;
32
- get(...args: Route0._OnlyIfNoParams<TParamsDefinition, [], [never]>): Route0._PathOnlyRouteValue<TPathOriginalDefinition>;
33
- get(input: Route0._OnlyIfNoParams<TParamsDefinition, {
34
- query?: undefined;
30
+ }>>): OnlyIfHasParams<_ParamsDefinition<TDefinition>, AbsoluteWithSearchRouteValue<TDefinition>>;
31
+ get(...args: OnlyIfNoParams<_ParamsDefinition<TDefinition>, [], [never]>): PathOnlyRouteValue<TDefinition>;
32
+ get(input: OnlyIfNoParams<_ParamsDefinition<TDefinition>, {
33
+ search?: undefined;
35
34
  abs?: false;
36
- }>): Route0._OnlyIfNoParams<TParamsDefinition, Route0._PathOnlyRouteValue<TPathOriginalDefinition>>;
37
- get(input: Route0._OnlyIfNoParams<TParamsDefinition, {
38
- query: Route0._QueryInput<TQueryDefinition>;
35
+ }>): OnlyIfNoParams<_ParamsDefinition<TDefinition>, PathOnlyRouteValue<TDefinition>>;
36
+ get(input: OnlyIfNoParams<_ParamsDefinition<TDefinition>, {
37
+ search: _SearchInput<TDefinition>;
39
38
  abs?: false;
40
- }>): Route0._OnlyIfNoParams<TParamsDefinition, Route0._WithQueryRouteValue<TPathOriginalDefinition>>;
41
- get(input: Route0._OnlyIfNoParams<TParamsDefinition, {
42
- query?: undefined;
39
+ }>): OnlyIfNoParams<_ParamsDefinition<TDefinition>, WithSearchRouteValue<TDefinition>>;
40
+ get(input: OnlyIfNoParams<_ParamsDefinition<TDefinition>, {
41
+ search?: undefined;
43
42
  abs: true;
44
- }>): Route0._OnlyIfNoParams<TParamsDefinition, Route0._AbsolutePathOnlyRouteValue<TPathOriginalDefinition>>;
45
- get(input: Route0._OnlyIfNoParams<TParamsDefinition, {
46
- query: Route0._QueryInput<TQueryDefinition>;
43
+ }>): OnlyIfNoParams<_ParamsDefinition<TDefinition>, AbsolutePathOnlyRouteValue<TDefinition>>;
44
+ get(input: OnlyIfNoParams<_ParamsDefinition<TDefinition>, {
45
+ search: _SearchInput<TDefinition>;
47
46
  abs: true;
48
- }>): Route0._OnlyIfNoParams<TParamsDefinition, Route0._AbsoluteWithQueryRouteValue<TPathOriginalDefinition>>;
49
- getDefinition(): TPathDefinition;
50
- clone(config?: Route0.RouteConfigInput): Route0<TPathOriginalDefinition, Route0._TrimQueryTailDefinition<TPathOriginalDefinition>, Route0._ParamsDefinition<TPathOriginalDefinition>, Route0._QueryDefinition<TPathOriginalDefinition>>;
47
+ }>): OnlyIfNoParams<_ParamsDefinition<TDefinition>, AbsoluteWithSearchRouteValue<TDefinition>>;
48
+ flat(input: OnlyIfHasParams<_ParamsDefinition<TDefinition>, WithParamsInput<TDefinition>>, abs?: false): OnlyIfHasParams<_ParamsDefinition<TDefinition>, PathOnlyRouteValue<TDefinition>>;
49
+ flat(input: OnlyIfHasParams<_ParamsDefinition<TDefinition>, WithParamsInput<TDefinition, _SearchInput<TDefinition>>>, abs?: false): OnlyIfHasParams<_ParamsDefinition<TDefinition>, WithSearchRouteValue<TDefinition>>;
50
+ flat(input: OnlyIfHasParams<_ParamsDefinition<TDefinition>, WithParamsInput<TDefinition>>, abs: true): OnlyIfHasParams<_ParamsDefinition<TDefinition>, AbsolutePathOnlyRouteValue<TDefinition>>;
51
+ flat(input: OnlyIfHasParams<_ParamsDefinition<TDefinition>, WithParamsInput<TDefinition, _SearchInput<TDefinition>>>, abs: true): OnlyIfHasParams<_ParamsDefinition<TDefinition>, AbsoluteWithSearchRouteValue<TDefinition>>;
52
+ flat(...args: OnlyIfNoParams<_ParamsDefinition<TDefinition>, [], [never]>): PathOnlyRouteValue<TDefinition>;
53
+ flat(input: OnlyIfNoParams<_ParamsDefinition<TDefinition>, Record<never, never>>, abs?: false): OnlyIfNoParams<_ParamsDefinition<TDefinition>, PathOnlyRouteValue<TDefinition>>;
54
+ flat(input: OnlyIfNoParams<_ParamsDefinition<TDefinition>, _SearchInput<TDefinition>>, abs?: false): OnlyIfNoParams<_ParamsDefinition<TDefinition>, WithSearchRouteValue<TDefinition>>;
55
+ flat(input: OnlyIfNoParams<_ParamsDefinition<TDefinition>, Record<never, never>>, abs: true): OnlyIfNoParams<_ParamsDefinition<TDefinition>, AbsolutePathOnlyRouteValue<TDefinition>>;
56
+ flat(input: OnlyIfNoParams<_ParamsDefinition<TDefinition>, _SearchInput<TDefinition>>, abs: true): OnlyIfNoParams<_ParamsDefinition<TDefinition>, AbsoluteWithSearchRouteValue<TDefinition>>;
57
+ getParamsKeys(): string[];
58
+ getSearchKeys(): string[];
59
+ getFlatKeys(): string[];
60
+ getDefinition(): string;
61
+ clone(config?: RouteConfigInput): Route0<TDefinition>;
62
+ getRegexString(): string;
63
+ getRegex(): RegExp;
64
+ static getRegexStringGroup(routes: AnyRoute[]): string;
65
+ static getRegexGroup(routes: AnyRoute[]): RegExp;
66
+ static getLocation(href: `${string}://${string}`): UnknownLocation;
67
+ static getLocation(hrefRel: `/${string}`): UnknownLocation;
68
+ static getLocation(hrefOrHrefRel: string): UnknownLocation;
69
+ static getLocation(location: AnyLocation): UnknownLocation;
70
+ static getLocation(url: URL): UnknownLocation;
71
+ static getLocation(hrefOrHrefRelOrLocation: string | AnyLocation | URL): UnknownLocation;
72
+ getLocation(href: `${string}://${string}`): KnownLocation<TDefinition>;
73
+ getLocation(hrefRel: `/${string}`): KnownLocation<TDefinition>;
74
+ getLocation(hrefOrHrefRel: string): KnownLocation<TDefinition>;
75
+ getLocation(location: AnyLocation): KnownLocation<TDefinition>;
76
+ getLocation(url: AnyLocation): KnownLocation<TDefinition>;
77
+ getLocation(hrefOrHrefRelOrLocation: string | AnyLocation | URL): KnownLocation<TDefinition>;
78
+ isSame(other: Route0<TDefinition>): boolean;
79
+ static isSame(a: AnyRoute | string | undefined, b: AnyRoute | string | undefined): boolean;
80
+ isChildren(other: AnyRoute | string | undefined): boolean;
81
+ isParent(other: AnyRoute | string | undefined): boolean;
82
+ isConflict(other: AnyRoute | string | undefined): boolean;
83
+ isMoreSpecificThan(other: AnyRoute | string | undefined): boolean;
51
84
  }
52
- declare namespace Route0 {
53
- type Callable<T extends Route0<any, any, any, any>> = T & T['get'];
54
- type RouteConfigInput = {
55
- baseUrl?: string;
85
+ declare class Routes<const T extends RoutesRecord = RoutesRecord> {
86
+ private readonly routes;
87
+ private readonly pathsOrdering;
88
+ private readonly keysOrdering;
89
+ private readonly ordered;
90
+ _: {
91
+ getLocation: Routes<T>['getLocation'];
92
+ override: Routes<T>['override'];
93
+ pathsOrdering: Routes<T>['pathsOrdering'];
94
+ keysOrdering: Routes<T>['keysOrdering'];
95
+ ordered: Routes<T>['ordered'];
56
96
  };
57
- type Params<TRoute0 extends Route0<any, any, any, any>> = {
58
- [K in keyof TRoute0['paramsDefinition']]: string;
59
- };
60
- type Query<TRoute0 extends Route0<any, any, any, any>> = Partial<{
61
- [K in keyof TRoute0['queryDefinition']]: string | undefined;
62
- } & Record<string, string | undefined>>;
63
- type _TrimQueryTailDefinition<S extends string> = S extends `${infer P}&${string}` ? P : S;
64
- type _QueryTailDefinitionWithoutFirstAmp<S extends string> = S extends `${string}&${infer T}` ? T : '';
65
- type _QueryTailDefinitionWithFirstAmp<S extends string> = S extends `${string}&${infer T}` ? `&${T}` : '';
66
- type _AmpSplit<S extends string> = S extends `${infer A}&${infer B}` ? A | _AmpSplit<B> : S;
67
- type _NonEmpty<T> = [T] extends ['' | never] ? never : T;
68
- type _ExtractPathParams<S extends string> = S extends `${string}:${infer After}` ? After extends `${infer Name}/${infer Rest}` ? Name | _ExtractPathParams<`/${Rest}`> : After : never;
69
- type _ReplacePathParams<S extends string> = S extends `${infer Head}:${infer Tail}` ? Tail extends `${infer _Param}/${infer Rest}` ? _ReplacePathParams<`${Head}${string}/${Rest}`> : `${Head}${string}` : S;
70
- type _DedupeSlashes<S extends string> = S extends `${infer A}//${infer B}` ? _DedupeSlashes<`${A}/${B}`> : S;
71
- type _EmptyRecord = Record<never, never>;
72
- type _JoinPath<Parent extends string, Suffix extends string> = _DedupeSlashes<Route0._PathDefinition<Parent> extends infer A extends string ? _PathDefinition<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>;
73
- type _OnlyIfNoParams<TParams extends object, Yes, No = never> = keyof TParams extends never ? Yes : No;
74
- type _OnlyIfHasParams<TParams extends object, Yes, No = never> = keyof TParams extends never ? No : Yes;
75
- type _PathDefinition<TPathOriginalDefinition extends string> = _TrimQueryTailDefinition<TPathOriginalDefinition>;
76
- type _ParamsDefinition<TPathOriginalDefinition extends string> = _ExtractPathParams<_PathDefinition<TPathOriginalDefinition>> extends infer U ? [U] extends [never] ? _EmptyRecord : {
77
- [K in Extract<U, string>]: true;
78
- } : _EmptyRecord;
79
- type _QueryDefinition<TPathOriginalDefinition extends string> = _NonEmpty<_QueryTailDefinitionWithoutFirstAmp<TPathOriginalDefinition>> extends infer Tail extends string ? _AmpSplit<Tail> extends infer U ? [U] extends [never] ? _EmptyRecord : {
80
- [K in Extract<U, string>]: true;
81
- } : _EmptyRecord : _EmptyRecord;
82
- type _RoutePathOriginalDefinitionExtended<TSourcePathOriginalDefinition extends string, TSuffixPathOriginalDefinition extends string> = `${_JoinPath<TSourcePathOriginalDefinition, TSuffixPathOriginalDefinition>}${_QueryTailDefinitionWithFirstAmp<TSuffixPathOriginalDefinition>}`;
83
- type _ParamsInput<TParamsDefinition extends object> = {
84
- [K in keyof TParamsDefinition]: string | number;
97
+ private constructor();
98
+ static create<const T extends RoutesRecord>(routes: T): RoutesPretty<T>;
99
+ private static prettify;
100
+ private static hydrate;
101
+ private getLocation;
102
+ private static makeOrdering;
103
+ private override;
104
+ static _: {
105
+ prettify: typeof Routes.prettify;
106
+ hydrate: typeof Routes.hydrate;
107
+ makeOrdering: typeof Routes.makeOrdering;
85
108
  };
86
- type _QueryInput<TQueryDefinition extends object> = Partial<{
87
- [K in keyof TQueryDefinition]: string | number;
88
- }> & Record<string, string | number>;
89
- type _WithParamsInput<TParamsDefinition extends object, T extends {
90
- query?: _QueryInput<any>;
91
- abs?: boolean;
92
- }> = _ParamsInput<TParamsDefinition> & T;
93
- type _PathOnlyRouteValue<TPathOriginalDefinition extends string> = `${_ReplacePathParams<_PathDefinition<TPathOriginalDefinition>>}`;
94
- type _WithQueryRouteValue<TPathOriginalDefinition extends string> = `${_ReplacePathParams<_PathDefinition<TPathOriginalDefinition>>}?${string}`;
95
- type _AbsolutePathOnlyRouteValue<TPathOriginalDefinition extends string> = `${string}${_PathOnlyRouteValue<TPathOriginalDefinition>}`;
96
- type _AbsoluteWithQueryRouteValue<TPathOriginalDefinition extends string> = `${string}${_WithQueryRouteValue<TPathOriginalDefinition>}`;
97
109
  }
110
+ type AnyRoute<T extends Route0<string> | string = string> = T extends string ? Route0<T> : T;
111
+ type CallabelRoute<T extends Route0<string> | string = string> = AnyRoute<T> & AnyRoute<T>['get'];
112
+ type AnyRouteOrDefinition<T extends string = string> = AnyRoute<T> | CallabelRoute<T> | T;
113
+ type RouteConfigInput = {
114
+ baseUrl?: string;
115
+ };
116
+ type RoutesRecord = Record<string, AnyRoute | string>;
117
+ type RoutesRecordHydrated<TRoutesRecord extends RoutesRecord = RoutesRecord> = {
118
+ [K in keyof TRoutesRecord]: CallabelRoute<TRoutesRecord[K]>;
119
+ };
120
+ type RoutesPretty<TRoutesRecord extends RoutesRecord = RoutesRecord> = RoutesRecordHydrated<TRoutesRecord> & Routes<TRoutesRecord>;
121
+ type ExtractRoutesKeys<TRoutes extends RoutesPretty | RoutesRecord> = TRoutes extends RoutesPretty ? keyof TRoutes['routes'] : TRoutes extends RoutesRecord ? keyof TRoutes : never;
122
+ type ExtractRoute<TRoutes extends RoutesPretty | RoutesRecord, TKey extends keyof ExtractRoutesKeys<TRoutes>> = TKey extends keyof TRoutes ? TRoutes[TKey] : never;
123
+ type Definition<T extends AnyRoute | string> = T extends AnyRoute ? T['definition'] : T extends string ? T : never;
124
+ type PathDefinition<T extends AnyRoute | string> = T extends AnyRoute ? T['pathDefinition'] : T extends string ? _PathDefinition<T> : never;
125
+ type ParamsDefinition<T extends AnyRoute | string> = T extends AnyRoute ? T['paramsDefinition'] : T extends string ? _ParamsDefinition<T> : undefined;
126
+ type SearchDefinition<T extends AnyRoute | string> = T extends AnyRoute ? T['searchDefinition'] : T extends string ? _SearchDefinition<T> : undefined;
127
+ type Extended<T extends AnyRoute | string | undefined, TSuffixDefinition extends string> = T extends AnyRoute ? Route0<PathExtended<T['definition'], TSuffixDefinition>> : T extends string ? Route0<PathExtended<T, TSuffixDefinition>> : T extends undefined ? Route0<TSuffixDefinition> : never;
128
+ type IsParent<T extends AnyRoute | string, TParent extends AnyRoute | string> = _IsParent<PathDefinition<T>, PathDefinition<TParent>>;
129
+ type IsChildren<T extends AnyRoute | string, TChildren extends AnyRoute | string> = _IsChildren<PathDefinition<T>, PathDefinition<TChildren>>;
130
+ type IsSame<T extends AnyRoute | string, TExact extends AnyRoute | string> = _IsSame<PathDefinition<T>, PathDefinition<TExact>>;
131
+ type IsSameParams<T1 extends AnyRoute | string, T2 extends AnyRoute | string> = _IsSameParams<ParamsDefinition<T1>, ParamsDefinition<T2>>;
132
+ type HasParams<T extends AnyRoute | string> = ExtractPathParams<PathDefinition<T>> extends infer U ? ([U] extends [never] ? false : true) : false;
133
+ type HasSearch<T extends AnyRoute | string> = NonEmpty<SearchTailDefinitionWithoutFirstAmp<Definition<T>>> extends infer Tail extends string ? AmpSplit<Tail> extends infer U ? [U] extends [never] ? false : true : false : false;
134
+ type ParamsOutput<T extends AnyRoute | string> = {
135
+ [K in keyof ParamsDefinition<T>]: string;
136
+ };
137
+ type SearchOutput<T extends AnyRoute | string = string> = Partial<{
138
+ [K in keyof SearchDefinition<T>]?: string;
139
+ } & Record<string, string | undefined>>;
140
+ type StrictSearchOutput<T extends AnyRoute | string> = Partial<{
141
+ [K in keyof SearchDefinition<T>]?: string | undefined;
142
+ }>;
143
+ type FlatOutput<T extends AnyRoute | string = string> = HasParams<Definition<T>> extends true ? ParamsOutput<T> & SearchOutput<T> : SearchOutput<T>;
144
+ type StrictFlatOutput<T extends AnyRoute | string> = HasParams<Definition<T>> extends true ? ParamsOutput<T> & StrictSearchOutput<T> : StrictSearchOutput<T>;
145
+ type ParamsInput<T extends AnyRoute | string = string> = _ParamsInput<PathDefinition<T>>;
146
+ type SearchInput<T extends AnyRoute | string = string> = _SearchInput<Definition<T>>;
147
+ type StrictSearchInput<T extends AnyRoute | string> = _StrictSearchInput<Definition<T>>;
148
+ type FlatInput<T extends AnyRoute | string> = _FlatInput<Definition<T>>;
149
+ type StrictFlatInput<T extends AnyRoute | string> = _StrictFlatInput<Definition<T>>;
150
+ type CanInputBeEmpty<T extends AnyRoute | string> = HasParams<Definition<T>> extends true ? false : true;
151
+ type LocationParams<TDefinition extends string> = {
152
+ [K in keyof _ParamsDefinition<TDefinition>]: string;
153
+ };
154
+ type LocationSearch<TDefinition extends string = string> = {
155
+ [K in keyof _SearchDefinition<TDefinition>]: string | undefined;
156
+ } & Record<string, string | undefined>;
157
+ type _GeneralLocation = {
158
+ pathname: string;
159
+ search: string;
160
+ hash: string;
161
+ origin?: string;
162
+ href?: string;
163
+ hrefRel: string;
164
+ abs: boolean;
165
+ port?: string;
166
+ host?: string;
167
+ hostname?: string;
168
+ };
169
+ type UnknownLocation = _GeneralLocation & {
170
+ params: undefined;
171
+ searchParams: SearchOutput;
172
+ route: undefined;
173
+ exact: false;
174
+ parent: false;
175
+ children: false;
176
+ };
177
+ type UnmatchedLocation<TRoute extends AnyRoute | string = AnyRoute | string> = _GeneralLocation & {
178
+ params: Record<never, never>;
179
+ searchParams: SearchOutput<TRoute>;
180
+ route: Definition<TRoute>;
181
+ exact: false;
182
+ parent: false;
183
+ children: false;
184
+ };
185
+ type ExactLocation<TRoute extends AnyRoute | string = AnyRoute | string> = _GeneralLocation & {
186
+ params: ParamsOutput<TRoute>;
187
+ searchParams: SearchOutput<TRoute>;
188
+ route: Definition<TRoute>;
189
+ exact: true;
190
+ parent: false;
191
+ children: false;
192
+ };
193
+ type ParentLocation<TRoute extends AnyRoute | string = AnyRoute | string> = _GeneralLocation & {
194
+ params: Partial<ParamsOutput<TRoute>>;
195
+ searchParams: SearchOutput<TRoute>;
196
+ route: Definition<TRoute>;
197
+ exact: false;
198
+ parent: true;
199
+ children: false;
200
+ };
201
+ type ChildrenLocation<TRoute extends AnyRoute | string = AnyRoute | string> = _GeneralLocation & {
202
+ params: ParamsOutput<TRoute>;
203
+ searchParams: SearchOutput<TRoute>;
204
+ route: Definition<TRoute>;
205
+ exact: false;
206
+ parent: false;
207
+ children: true;
208
+ };
209
+ type KnownLocation<TRoute extends AnyRoute | string = AnyRoute | string> = UnmatchedLocation<TRoute> | ExactLocation<TRoute> | ParentLocation<TRoute> | ChildrenLocation<TRoute>;
210
+ type AnyLocation<TRoute extends AnyRoute = AnyRoute> = UnknownLocation | KnownLocation<TRoute>;
211
+ type _PathDefinition<T extends string> = T extends string ? TrimSearchTailDefinition<T> : never;
212
+ type _ParamsDefinition<TDefinition extends string> = ExtractPathParams<PathDefinition<TDefinition>> extends infer U ? [U] extends [never] ? undefined : {
213
+ [K in Extract<U, string>]: true;
214
+ } : undefined;
215
+ type _SearchDefinition<TDefinition extends string> = NonEmpty<SearchTailDefinitionWithoutFirstAmp<TDefinition>> extends infer Tail extends string ? AmpSplit<Tail> extends infer U ? [U] extends [never] ? undefined : {
216
+ [K in Extract<U, string>]: true;
217
+ } : undefined : undefined;
218
+ type _ParamsInput<TDefinition extends string> = _ParamsDefinition<TDefinition> extends undefined ? Record<never, never> : {
219
+ [K in keyof _ParamsDefinition<TDefinition>]: string | number;
220
+ };
221
+ type _SearchInput<TDefinition extends string> = _SearchDefinition<TDefinition> extends undefined ? Record<string, string | number> : Partial<{
222
+ [K in keyof _SearchDefinition<TDefinition>]: string | number;
223
+ }> & Record<string, string | number>;
224
+ type _StrictSearchInput<TDefinition extends string> = Partial<{
225
+ [K in keyof _SearchDefinition<TDefinition>]: string | number;
226
+ }>;
227
+ type _FlatInput<TDefinition extends string> = HasParams<TDefinition> extends true ? _ParamsInput<TDefinition> & _SearchInput<TDefinition> : _SearchInput<TDefinition>;
228
+ type _StrictFlatInput<TDefinition extends string> = HasParams<TDefinition> extends true ? HasSearch<TDefinition> extends true ? _StrictSearchInput<TDefinition> & _ParamsInput<TDefinition> : _ParamsInput<TDefinition> : HasSearch<TDefinition> extends true ? _StrictSearchInput<TDefinition> : Record<never, never>;
229
+ type TrimSearchTailDefinition<S extends string> = S extends `${infer P}&${string}` ? P : S;
230
+ type SearchTailDefinitionWithoutFirstAmp<S extends string> = S extends `${string}&${infer T}` ? T : '';
231
+ type SearchTailDefinitionWithFirstAmp<S extends string> = S extends `${string}&${infer T}` ? `&${T}` : '';
232
+ type AmpSplit<S extends string> = S extends `${infer A}&${infer B}` ? A | AmpSplit<B> : S;
233
+ type NonEmpty<T> = [T] extends ['' | never] ? never : T;
234
+ type ExtractPathParams<S extends string> = S extends `${string}:${infer After}` ? After extends `${infer Name}/${infer Rest}` ? Name | ExtractPathParams<`/${Rest}`> : After : never;
235
+ type ReplacePathParams<S extends string> = S extends `${infer Head}:${infer Tail}` ? Tail extends `${infer _Param}/${infer Rest}` ? ReplacePathParams<`${Head}${string}/${Rest}`> : `${Head}${string}` : S;
236
+ type DedupeSlashes<S extends string> = S extends `${infer A}//${infer B}` ? DedupeSlashes<`${A}/${B}`> : S;
237
+ type EmptyRecord = Record<never, never>;
238
+ type JoinPath<Parent extends string, Suffix extends string> = DedupeSlashes<PathDefinition<Parent> extends infer A extends string ? PathDefinition<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>;
239
+ type OnlyIfNoParams<TParams extends object | undefined, Yes, No = never> = TParams extends undefined ? Yes : No;
240
+ type OnlyIfHasParams<TParams extends object | undefined, Yes, No = never> = TParams extends undefined ? No : Yes;
241
+ type PathOnlyRouteValue<TDefinition extends string> = `${ReplacePathParams<PathDefinition<TDefinition>>}`;
242
+ type WithSearchRouteValue<TDefinition extends string> = `${ReplacePathParams<PathDefinition<TDefinition>>}?${string}`;
243
+ type AbsolutePathOnlyRouteValue<TDefinition extends string> = PathOnlyRouteValue<TDefinition> extends '/' ? string : `${string}${PathOnlyRouteValue<TDefinition>}`;
244
+ type AbsoluteWithSearchRouteValue<TDefinition extends string> = `${string}${WithSearchRouteValue<TDefinition>}`;
245
+ type PathExtended<TSourcedefinitionDefinition extends string, TSuffixdefinitionDefinition extends string> = `${JoinPath<TSourcedefinitionDefinition, TSuffixdefinitionDefinition>}${SearchTailDefinitionWithFirstAmp<TSuffixdefinitionDefinition>}`;
246
+ type WithParamsInput<TDefinition extends string, T extends {
247
+ search?: _SearchInput<any>;
248
+ abs?: boolean;
249
+ } | undefined = undefined> = _ParamsInput<TDefinition> & (T extends undefined ? Record<never, never> : T);
250
+ 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;
251
+ type _IsParent<T extends string, TParent extends string> = T extends TParent ? false : T extends `${TParent}${string}` ? true : false;
252
+ type _IsChildren<T extends string, TChildren extends string> = TChildren extends T ? false : TChildren extends `${T}${string}` ? true : false;
253
+ type _IsSame<T extends string, TExact extends string> = T extends TExact ? TExact extends T ? true : false : false;
98
254
 
99
- export { Route0 };
255
+ export { type AbsolutePathOnlyRouteValue, type AbsoluteWithSearchRouteValue, type AmpSplit, type AnyLocation, type AnyRoute, type AnyRouteOrDefinition, type CallabelRoute, type CanInputBeEmpty, type ChildrenLocation, type DedupeSlashes, type Definition, type EmptyRecord, type ExactLocation, type Extended, type ExtractPathParams, type ExtractRoute, type ExtractRoutesKeys, type FlatInput, type FlatOutput, type HasParams, type HasSearch, type IsChildren, type IsParent, type IsSame, type IsSameParams, type JoinPath, type KnownLocation, type LocationParams, type LocationSearch, type NonEmpty, type OnlyIfHasParams, type OnlyIfNoParams, type ParamsDefinition, type ParamsInput, type ParamsOutput, type ParentLocation, type PathDefinition, type PathExtended, type PathOnlyRouteValue, type ReplacePathParams, Route0, type RouteConfigInput, Routes, type RoutesPretty, type RoutesRecord, type RoutesRecordHydrated, type SearchDefinition, type SearchInput, type SearchOutput, type SearchTailDefinitionWithFirstAmp, type SearchTailDefinitionWithoutFirstAmp, type StrictFlatInput, type StrictFlatOutput, type StrictSearchInput, type StrictSearchOutput, type TrimSearchTailDefinition, type UnknownLocation, type UnmatchedLocation, type WithParamsInput, type WithSearchRouteValue, type _FlatInput, type _GeneralLocation, type _IsChildren, type _IsParent, type _IsSame, type _IsSameParams, type _ParamsDefinition, type _ParamsInput, type _PathDefinition, type _SearchDefinition, type _SearchInput, type _StrictFlatInput, type _StrictSearchInput };