@kitbag/router 0.4.0 → 0.4.1
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/kitbag-router.d.ts +749 -22
- package/dist/kitbag-router.js +587 -565
- package/dist/kitbag-router.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/kitbag-router.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AsyncComponentLoader } from 'vue';
|
|
2
2
|
import { Component } from 'vue';
|
|
3
3
|
import { ComponentOptionsMixin } from 'vue';
|
|
4
|
-
import { DeepReadonly } from 'vue';
|
|
5
4
|
import { DefineComponent } from 'vue';
|
|
6
5
|
import { ExtractPropTypes } from 'vue';
|
|
7
6
|
import { FunctionalComponent } from 'vue';
|
|
@@ -56,6 +55,13 @@ declare type __VLS_WithTemplateSlots_2<T, S> = T & {
|
|
|
56
55
|
*/
|
|
57
56
|
export declare type AddAfterRouteHook = (hook: AfterRouteHook) => RouteHookRemove;
|
|
58
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Adds a hook that is called after a route change. Returns a function to remove the hook.
|
|
60
|
+
* @param hook - {@link AfterRouteHook} The hook function to add.
|
|
61
|
+
* @returns {RouteHookRemove} A function that removes the added hook.
|
|
62
|
+
*/
|
|
63
|
+
declare type AddAfterRouteHook_2 = (hook: AfterRouteHook_2) => RouteHookRemove_2
|
|
64
|
+
|
|
59
65
|
/**
|
|
60
66
|
* Adds a hook that is called before a route change. Returns a function to remove the hook.
|
|
61
67
|
* @param hook - {@link BeforeRouteHook} The hook function to add.
|
|
@@ -63,6 +69,13 @@ export declare type AddAfterRouteHook = (hook: AfterRouteHook) => RouteHookRemov
|
|
|
63
69
|
*/
|
|
64
70
|
export declare type AddBeforeRouteHook = (hook: BeforeRouteHook) => RouteHookRemove;
|
|
65
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Adds a hook that is called before a route change. Returns a function to remove the hook.
|
|
74
|
+
* @param hook - {@link BeforeRouteHook} The hook function to add.
|
|
75
|
+
* @returns {RouteHookRemove} A function that removes the added hook.
|
|
76
|
+
*/
|
|
77
|
+
declare type AddBeforeRouteHook_2 = (hook: BeforeRouteHook_2) => RouteHookRemove_2
|
|
78
|
+
|
|
66
79
|
/**
|
|
67
80
|
* Represents a function called after a route change has occurred.
|
|
68
81
|
* @param to - {@link ResolvedRoute} The resolved route the router has navigated to.
|
|
@@ -71,11 +84,24 @@ export declare type AddBeforeRouteHook = (hook: BeforeRouteHook) => RouteHookRem
|
|
|
71
84
|
*/
|
|
72
85
|
export declare type AfterRouteHook = (to: ResolvedRoute, context: AfterRouteHookContext) => MaybePromise<void>;
|
|
73
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Represents a function called after a route change has occurred.
|
|
89
|
+
* @param to - {@link ResolvedRoute} The resolved route the router has navigated to.
|
|
90
|
+
* @param context - {@link AfterRouteHookContext} The context providing functions and state for the routing operation.
|
|
91
|
+
* @returns Possibly a promise that resolves when the hook's logic has completed.
|
|
92
|
+
*/
|
|
93
|
+
declare type AfterRouteHook_2 = (to: ResolvedRoute_2, context: AfterRouteHookContext_2) => MaybePromise_2<void>
|
|
94
|
+
|
|
74
95
|
/**
|
|
75
96
|
* Context provided to route hooks, containing context of previous route and functions for triggering rejections and push/replace to another route.
|
|
76
97
|
*/
|
|
77
98
|
declare type AfterRouteHookContext = RouteHookContext;
|
|
78
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Context provided to route hooks, containing context of previous route and functions for triggering rejections and push/replace to another route.
|
|
102
|
+
*/
|
|
103
|
+
declare type AfterRouteHookContext_2 = RouteHookContext_2
|
|
104
|
+
|
|
79
105
|
/**
|
|
80
106
|
* Enumerates the lifecycle events for after route hooks.
|
|
81
107
|
*/
|
|
@@ -89,6 +115,10 @@ export declare type AfterRouteHookResponse<TRoutes extends Routes> = RouteHookSu
|
|
|
89
115
|
|
|
90
116
|
declare type AllPropertiesAreOptional<T> = Record<string, unknown> extends T ? true : IsEmptyObject<OnlyRequiredProperties<T>>;
|
|
91
117
|
|
|
118
|
+
declare type AllPropertiesAreOptional_2<T> = Record<string, unknown> extends T
|
|
119
|
+
? true
|
|
120
|
+
: IsEmptyObject_2<OnlyRequiredProperties_2<T>>
|
|
121
|
+
|
|
92
122
|
declare type BaseResolvedRoute = Route & {
|
|
93
123
|
path: {
|
|
94
124
|
params: Record<string, unknown>;
|
|
@@ -98,6 +128,8 @@ declare type BaseResolvedRoute = Route & {
|
|
|
98
128
|
};
|
|
99
129
|
};
|
|
100
130
|
|
|
131
|
+
declare type BaseResolvedRoute_2 = Route_2 & { path: { params: Record<string, unknown> }, query: { params: Record<string, unknown> } }
|
|
132
|
+
|
|
101
133
|
declare type BaseRoute = {
|
|
102
134
|
key: string;
|
|
103
135
|
disabled: false;
|
|
@@ -109,6 +141,8 @@ declare type BaseRoute = {
|
|
|
109
141
|
};
|
|
110
142
|
};
|
|
111
143
|
|
|
144
|
+
declare type BaseRoute_2 = { key: string, disabled: false, path: { params: Record<string, unknown> }, query: { params: Record<string, unknown> } }
|
|
145
|
+
|
|
112
146
|
/**
|
|
113
147
|
* Represents a function called before a route change, potentially altering the routing operation.
|
|
114
148
|
* @param to - {@link ResolvedRoute} The resolved route the router is navigating to.
|
|
@@ -117,6 +151,14 @@ declare type BaseRoute = {
|
|
|
117
151
|
*/
|
|
118
152
|
export declare type BeforeRouteHook = (to: ResolvedRoute, context: BeforeRouteHookContext) => MaybePromise<void>;
|
|
119
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Represents a function called before a route change, potentially altering the routing operation.
|
|
156
|
+
* @param to - {@link ResolvedRoute} The resolved route the router is navigating to.
|
|
157
|
+
* @param context - {@link BeforeRouteHookContext} The context providing functions and state for the routing operation.
|
|
158
|
+
* @returns Possibly a promise that resolves when the hook's logic has completed.
|
|
159
|
+
*/
|
|
160
|
+
declare type BeforeRouteHook_2 = (to: ResolvedRoute_2, context: BeforeRouteHookContext_2) => MaybePromise_2<void>
|
|
161
|
+
|
|
120
162
|
/**
|
|
121
163
|
* Context provided to route hooks, containing context of previous route and functions for triggering rejections, push/replace to another route,
|
|
122
164
|
* as well as aborting current route change.
|
|
@@ -125,6 +167,14 @@ declare type BeforeRouteHookContext = RouteHookContext & {
|
|
|
125
167
|
abort: RouteHookAbort;
|
|
126
168
|
};
|
|
127
169
|
|
|
170
|
+
/**
|
|
171
|
+
* Context provided to route hooks, containing context of previous route and functions for triggering rejections, push/replace to another route,
|
|
172
|
+
* as well as aborting current route change.
|
|
173
|
+
*/
|
|
174
|
+
declare type BeforeRouteHookContext_2 = RouteHookContext_2 & {
|
|
175
|
+
abort: RouteHookAbort_2,
|
|
176
|
+
}
|
|
177
|
+
|
|
128
178
|
/**
|
|
129
179
|
* Enumerates the lifecycle events for before route hooks.
|
|
130
180
|
*/
|
|
@@ -136,10 +186,14 @@ export declare type BeforeRouteHookLifecycle = 'onBeforeRouteEnter' | 'onBeforeR
|
|
|
136
186
|
*/
|
|
137
187
|
export declare type BeforeRouteHookResponse<TRoutes extends Routes> = RouteHookSuccessResponse | RouteHookPushResponse<TRoutes> | RouteHookRejectResponse | RouteHookAbortResponse;
|
|
138
188
|
|
|
139
|
-
declare const builtInRejections:
|
|
189
|
+
declare const builtInRejections: ['NotFound'];
|
|
190
|
+
|
|
191
|
+
declare const builtInRejections_2: ['NotFound'] = ['NotFound'];
|
|
140
192
|
|
|
141
193
|
declare type BuiltInRejectionType = typeof builtInRejections[number];
|
|
142
194
|
|
|
195
|
+
declare type BuiltInRejectionType_2 = typeof builtInRejections_2[number]
|
|
196
|
+
|
|
143
197
|
/**
|
|
144
198
|
* Represents properties for child routes, including required component, name, and path.
|
|
145
199
|
*/
|
|
@@ -166,6 +220,32 @@ export declare type ChildRouteProps = (WithComponent | WithComponents) & WithHoo
|
|
|
166
220
|
meta?: RouteMeta;
|
|
167
221
|
};
|
|
168
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Represents properties for child routes, including required component, name, and path.
|
|
225
|
+
*/
|
|
226
|
+
declare type ChildRouteProps_2 = (WithComponent_2 | WithComponents_2) & WithHooks_2 & {
|
|
227
|
+
/**
|
|
228
|
+
* Name for route, used to create route keys and in navigation.
|
|
229
|
+
*/
|
|
230
|
+
name: string,
|
|
231
|
+
/**
|
|
232
|
+
* Children routes, expected type comes from `createRoutes()`
|
|
233
|
+
*/
|
|
234
|
+
disabled?: boolean,
|
|
235
|
+
/**
|
|
236
|
+
* Path part of URL.
|
|
237
|
+
*/
|
|
238
|
+
path: string | Path_2,
|
|
239
|
+
/**
|
|
240
|
+
* Query (aka search) part of URL.
|
|
241
|
+
*/
|
|
242
|
+
query?: string | Query_2,
|
|
243
|
+
/**
|
|
244
|
+
* Represents additional metadata associated with a route, customizable via declaration merging.
|
|
245
|
+
*/
|
|
246
|
+
meta?: RouteMeta_2,
|
|
247
|
+
}
|
|
248
|
+
|
|
169
249
|
declare type CombineName<TParentName extends string | undefined, TChildName extends string | undefined> = TParentName extends string ? TChildName extends string ? `${TParentName}.${TChildName}` : TParentName : TChildName extends string ? TChildName : '';
|
|
170
250
|
|
|
171
251
|
declare type CombinePath<TParent extends Path, TChild extends Path> = ToPath<TParent> extends {
|
|
@@ -210,6 +290,12 @@ export declare function component<TComponent extends Component>(component: TComp
|
|
|
210
290
|
|
|
211
291
|
declare type Constructor = new (...args: any) => any;
|
|
212
292
|
|
|
293
|
+
export declare function createParam<TParam extends ParamWithDefault>(param: TParam): TParam;
|
|
294
|
+
|
|
295
|
+
export declare function createParam<TParam extends Param>(param: TParam): ParamGetSet<ExtractParamType<TParam>>;
|
|
296
|
+
|
|
297
|
+
export declare function createParam<TParam extends Param>(param: TParam, defaultValue: ExtractParamType<TParam>): ParamWithDefault<TParam>;
|
|
298
|
+
|
|
213
299
|
/**
|
|
214
300
|
* Creates a router instance for a Vue application, equipped with methods for route handling, lifecycle hooks, and state management.
|
|
215
301
|
*
|
|
@@ -264,10 +350,32 @@ export declare class DuplicateParamsError extends Error {
|
|
|
264
350
|
*/
|
|
265
351
|
export declare type ExtractParamName<TParam extends string> = TParam extends `?${infer Param}` ? Param extends '' ? never : Param : TParam extends '' ? never : TParam;
|
|
266
352
|
|
|
353
|
+
/**
|
|
354
|
+
* Extracts the parameter name from a string, handling optional parameters denoted by a leading '?'.
|
|
355
|
+
* @template TParam - The string from which to extract the parameter name.
|
|
356
|
+
* @returns The extracted parameter name, or never if the parameter string is empty.
|
|
357
|
+
*/
|
|
358
|
+
declare type ExtractParamName_2<
|
|
359
|
+
TParam extends string
|
|
360
|
+
> = TParam extends `?${infer Param}`
|
|
361
|
+
? Param extends ''
|
|
362
|
+
? never
|
|
363
|
+
: Param
|
|
364
|
+
: TParam extends ''
|
|
365
|
+
? never
|
|
366
|
+
: TParam
|
|
367
|
+
|
|
267
368
|
declare type ExtractParamsFromPathString<TPath extends string, TParams extends Record<string, Param | undefined> = Record<never, never>> = TPath extends `${string}${ParamStart}${infer Param}${ParamEnd}${infer Rest}` ? MergeParams<{
|
|
268
369
|
[P in ExtractParamName<Param>]: ExtractPathParamType<Param, TParams>;
|
|
269
370
|
}, ExtractParamsFromPathString<Rest, TParams>> : Record<never, never>;
|
|
270
371
|
|
|
372
|
+
declare type ExtractParamsFromPathString_2<
|
|
373
|
+
TPath extends string,
|
|
374
|
+
TParams extends Record<string, Param_2 | undefined> = Record<never, never>
|
|
375
|
+
> = TPath extends `${string}${ParamStart_2}${infer Param}${ParamEnd_2}${infer Rest}`
|
|
376
|
+
? MergeParams_2<{ [P in ExtractParamName_2<Param>]: ExtractPathParamType_2<Param, TParams> }, ExtractParamsFromPathString_2<Rest, TParams>>
|
|
377
|
+
: Record<never, never>
|
|
378
|
+
|
|
271
379
|
/**
|
|
272
380
|
* Extracts the actual type from a parameter type, handling getters, setters, and potential undefined values.
|
|
273
381
|
* This type also is responsible for narrowing possibly undefined values when the param has a default value.
|
|
@@ -276,6 +384,22 @@ declare type ExtractParamsFromPathString<TPath extends string, TParams extends R
|
|
|
276
384
|
*/
|
|
277
385
|
export declare type ExtractParamType<TParam extends Param> = TParam extends ParamGetSet<infer Type> ? TParam extends IsOptionalParam ? TParam extends ParamWithDefault ? Type : Type | undefined : Type : TParam extends ParamGetter ? ReturnType<TParam> : string;
|
|
278
386
|
|
|
387
|
+
/**
|
|
388
|
+
* Extracts the actual type from a parameter type, handling getters, setters, and potential undefined values.
|
|
389
|
+
* This type also is responsible for narrowing possibly undefined values when the param has a default value.
|
|
390
|
+
* @template TParam - The parameter type.
|
|
391
|
+
* @returns The extracted type, or 'string' as a fallback.
|
|
392
|
+
*/
|
|
393
|
+
declare type ExtractParamType_2<TParam extends Param_2> = TParam extends ParamGetSet_2<infer Type>
|
|
394
|
+
? TParam extends IsOptionalParam_2
|
|
395
|
+
? TParam extends ParamWithDefault_2
|
|
396
|
+
? Type
|
|
397
|
+
: Type | undefined
|
|
398
|
+
: Type
|
|
399
|
+
: TParam extends ParamGetter_2
|
|
400
|
+
? ReturnType<TParam>
|
|
401
|
+
: string
|
|
402
|
+
|
|
279
403
|
/**
|
|
280
404
|
* Transforms a record of parameter types into a type with optional properties where the original type allows undefined.
|
|
281
405
|
* @template TParams - The record of parameter types, possibly including undefined.
|
|
@@ -285,12 +409,33 @@ export declare type ExtractParamTypes<TParams extends Record<string, Param>> = I
|
|
|
285
409
|
[K in keyof TParams]: ExtractParamType<TParams[K]>;
|
|
286
410
|
}>>;
|
|
287
411
|
|
|
412
|
+
/**
|
|
413
|
+
* Transforms a record of parameter types into a type with optional properties where the original type allows undefined.
|
|
414
|
+
* @template TParams - The record of parameter types, possibly including undefined.
|
|
415
|
+
* @returns A new type with the appropriate properties marked as optional.
|
|
416
|
+
*/
|
|
417
|
+
declare type ExtractParamTypes_2<TParams extends Record<string, Param_2>> = Identity_2<MakeOptional_2<{
|
|
418
|
+
[K in keyof TParams]: ExtractParamType_2<TParams[K]>
|
|
419
|
+
}>>
|
|
420
|
+
|
|
288
421
|
declare type ExtractParamTypesWithoutLosingOptional<TParams extends Record<string, Param>> = Identity<MakeOptional<{
|
|
289
422
|
[K in keyof TParams]: ExtractParamTypeWithoutLosingOptional<TParams[K]>;
|
|
290
423
|
}>>;
|
|
291
424
|
|
|
425
|
+
declare type ExtractParamTypesWithoutLosingOptional_2<TParams extends Record<string, Param_2>> = Identity_2<MakeOptional_2<{
|
|
426
|
+
[K in keyof TParams]: ExtractParamTypeWithoutLosingOptional_2<TParams[K]>
|
|
427
|
+
}>>
|
|
428
|
+
|
|
292
429
|
declare type ExtractParamTypeWithoutLosingOptional<TParam extends Param> = TParam extends ParamGetSet<infer Type> ? TParam extends IsOptionalParam ? Type | undefined : Type : TParam extends ParamGetter ? ReturnType<TParam> : string;
|
|
293
430
|
|
|
431
|
+
declare type ExtractParamTypeWithoutLosingOptional_2<TParam extends Param_2> = TParam extends ParamGetSet_2<infer Type>
|
|
432
|
+
? TParam extends IsOptionalParam_2
|
|
433
|
+
? Type | undefined
|
|
434
|
+
: Type
|
|
435
|
+
: TParam extends ParamGetter_2
|
|
436
|
+
? ReturnType<TParam>
|
|
437
|
+
: string
|
|
438
|
+
|
|
294
439
|
/**
|
|
295
440
|
* Determines the type of a path parameter from a record of parameter types, considering optional parameters.
|
|
296
441
|
* @template TParam - The parameter name string.
|
|
@@ -299,10 +444,36 @@ declare type ExtractParamTypeWithoutLosingOptional<TParam extends Param> = TPara
|
|
|
299
444
|
*/
|
|
300
445
|
export declare type ExtractPathParamType<TParam extends string, TParams extends Record<string, Param | undefined>> = TParam extends `?${infer OptionalParam}` ? OptionalParam extends keyof TParams ? TParams[OptionalParam] extends Param ? OptionalParamGetSet<TParams[OptionalParam]> : OptionalParamGetSet<StringConstructor> : OptionalParamGetSet<StringConstructor> : TParam extends keyof TParams ? TParams[TParam] : StringConstructor;
|
|
301
446
|
|
|
447
|
+
/**
|
|
448
|
+
* Determines the type of a path parameter from a record of parameter types, considering optional parameters.
|
|
449
|
+
* @template TParam - The parameter name string.
|
|
450
|
+
* @template TParams - The record object mapping parameter names to their types.
|
|
451
|
+
* @returns The type associated with the parameter, or StringConstructor if unspecified; may be undefined for optional parameters.
|
|
452
|
+
*/
|
|
453
|
+
declare type ExtractPathParamType_2<
|
|
454
|
+
TParam extends string,
|
|
455
|
+
TParams extends Record<string, Param_2 | undefined>
|
|
456
|
+
> = TParam extends `?${infer OptionalParam}`
|
|
457
|
+
? OptionalParam extends keyof TParams
|
|
458
|
+
? TParams[OptionalParam] extends Param_2
|
|
459
|
+
? OptionalParamGetSet_2<TParams[OptionalParam]>
|
|
460
|
+
: OptionalParamGetSet_2<StringConstructor>
|
|
461
|
+
: OptionalParamGetSet_2<StringConstructor>
|
|
462
|
+
: TParam extends keyof TParams
|
|
463
|
+
? TParams[TParam]
|
|
464
|
+
: StringConstructor
|
|
465
|
+
|
|
302
466
|
declare type ExtractQueryParamsFromQueryString<TQuery extends string, TParams extends Record<string, Param | undefined> = Record<never, never>> = TQuery extends `${string}=${ParamStart}${infer Param}${ParamEnd}${infer Rest}` ? MergeParams<{
|
|
303
467
|
[P in ExtractParamName<Param>]: ExtractPathParamType<Param, TParams>;
|
|
304
468
|
}, ExtractQueryParamsFromQueryString<Rest, TParams>> : Record<never, never>;
|
|
305
469
|
|
|
470
|
+
declare type ExtractQueryParamsFromQueryString_2<
|
|
471
|
+
TQuery extends string,
|
|
472
|
+
TParams extends Record<string, Param_2 | undefined> = Record<never, never>
|
|
473
|
+
> = TQuery extends `${string}=${ParamStart_2}${infer Param}${ParamEnd_2}${infer Rest}`
|
|
474
|
+
? MergeParams_2<{ [P in ExtractParamName_2<Param>]: ExtractPathParamType_2<Param, TParams> }, ExtractQueryParamsFromQueryString_2<Rest, TParams>>
|
|
475
|
+
: Record<never, never>
|
|
476
|
+
|
|
306
477
|
declare type ExtractRouteChildren<TRoute extends RouteProps> = TRoute extends ParentRouteProps ? TRoute['children'] extends Route[] ? TRoute['children'] : [] : [];
|
|
307
478
|
|
|
308
479
|
/**
|
|
@@ -320,6 +491,19 @@ export declare type ExtractRouteParamTypes<TRoute> = TRoute extends {
|
|
|
320
491
|
};
|
|
321
492
|
} ? ExtractParamTypes<MergeParams<PathParams, QueryParams>> : Record<string, unknown>;
|
|
322
493
|
|
|
494
|
+
/**
|
|
495
|
+
* Extracts combined types of path and query parameters for a given route, creating a unified parameter object.
|
|
496
|
+
* This parameter object type represents the expected type when accessing params from router.route or useRoute.
|
|
497
|
+
* @template TRoute - The route type from which to extract and merge parameter types.
|
|
498
|
+
* @returns A record of parameter names to their respective types, extracted and merged from both path and query parameters.
|
|
499
|
+
*/
|
|
500
|
+
declare type ExtractRouteParamTypes_2<TRoute> = TRoute extends {
|
|
501
|
+
path: { params: infer PathParams extends Record<string, Param_2> },
|
|
502
|
+
query: { params: infer QueryParams extends Record<string, Param_2> },
|
|
503
|
+
}
|
|
504
|
+
? ExtractParamTypes_2<MergeParams_2<PathParams, QueryParams>>
|
|
505
|
+
: Record<string, unknown>
|
|
506
|
+
|
|
323
507
|
declare type ExtractRouteParamTypesWithoutLosingOptional<TRoute> = TRoute extends {
|
|
324
508
|
path: {
|
|
325
509
|
params: infer PathParams extends Record<string, Param>;
|
|
@@ -329,9 +513,16 @@ declare type ExtractRouteParamTypesWithoutLosingOptional<TRoute> = TRoute extend
|
|
|
329
513
|
};
|
|
330
514
|
} ? ExtractParamTypesWithoutLosingOptional<MergeParams<PathParams, QueryParams>> : Record<string, unknown>;
|
|
331
515
|
|
|
516
|
+
declare type ExtractRouteParamTypesWithoutLosingOptional_2<TRoute> = TRoute extends {
|
|
517
|
+
path: { params: infer PathParams extends Record<string, Param_2> },
|
|
518
|
+
query: { params: infer QueryParams extends Record<string, Param_2> },
|
|
519
|
+
}
|
|
520
|
+
? ExtractParamTypesWithoutLosingOptional_2<MergeParams_2<PathParams, QueryParams>>
|
|
521
|
+
: Record<string, unknown>
|
|
522
|
+
|
|
332
523
|
declare type Flatten<T extends any[]> = T extends [infer First, ...infer Rest] ? First extends unknown[] ? Flatten<[...First, ...Flatten<Rest>]> : [First, ...Flatten<Rest>] : [];
|
|
333
524
|
|
|
334
|
-
declare type FlattenRoute<TRoute extends RouteProps, TKey extends string
|
|
525
|
+
declare type FlattenRoute<TRoute extends RouteProps, TKey extends string = string & TRoute['name'], TPath extends Path = ToPath<TRoute['path']>, TQuery extends Query = ToQuery<TRoute['query']>, TDisabled extends boolean = TRoute['disabled'] extends boolean ? TRoute['disabled'] : false, TChildren extends Route[] = ExtractRouteChildren<TRoute>> = [
|
|
335
526
|
Route<TKey, TPath, TQuery, TDisabled>,
|
|
336
527
|
...{
|
|
337
528
|
[K in keyof TChildren]: Route<CombineName<TKey, TChildren[K]['key']>, CombinePath<TPath, TChildren[K]['path']>, CombineQuery<TQuery, TChildren[K]['query']>, TChildren[K]['disabled']>;
|
|
@@ -348,12 +539,22 @@ declare type Identity<T> = T extends object ? {} & {
|
|
|
348
539
|
[P in keyof T as T[P] extends never ? never : P]: T[P];
|
|
349
540
|
} : T;
|
|
350
541
|
|
|
542
|
+
declare type Identity_2<T> = T extends object ? {} & {
|
|
543
|
+
[P in keyof T as T[P] extends never ? never : P]: T[P]
|
|
544
|
+
} : T
|
|
545
|
+
|
|
351
546
|
declare type IsEmptyObject<T> = T extends Record<string, never> ? (keyof T extends never ? true : false) : false;
|
|
352
547
|
|
|
548
|
+
declare type IsEmptyObject_2<T> = T extends Record<string, never> ? (keyof T extends never ? true : false) : false
|
|
549
|
+
|
|
353
550
|
declare type IsOptionalParam = {
|
|
354
551
|
[optionalParamKey]: true;
|
|
355
552
|
};
|
|
356
553
|
|
|
554
|
+
declare type IsOptionalParam_2 = {
|
|
555
|
+
[optionalParamKey_2]: true,
|
|
556
|
+
}
|
|
557
|
+
|
|
357
558
|
/**
|
|
358
559
|
* Type guard to check if a value conforms to the ParamGetSet type.
|
|
359
560
|
* @param value - The value to check.
|
|
@@ -387,30 +588,34 @@ declare type IsRouteOptions = {
|
|
|
387
588
|
exact?: boolean;
|
|
388
589
|
};
|
|
389
590
|
|
|
390
|
-
declare const isRouterRouteSymbol: unique symbol;
|
|
391
|
-
|
|
392
591
|
export declare function isRouteWithComponent(value: RouteProps): value is RouteProps & WithComponent;
|
|
393
592
|
|
|
394
593
|
export declare function isRouteWithComponent(value: Readonly<RouteProps>): value is Readonly<RouteProps & WithComponent>;
|
|
395
594
|
|
|
396
|
-
export declare function isRouteWithComponent(value: DeepReadonly<RouteProps>): value is DeepReadonly<RouteProps & WithComponent>;
|
|
397
|
-
|
|
398
595
|
export declare function isRouteWithComponents(value: RouteProps): value is RouteProps & WithComponents;
|
|
399
596
|
|
|
400
597
|
export declare function isRouteWithComponents(value: Readonly<RouteProps>): value is Readonly<RouteProps & WithComponents>;
|
|
401
598
|
|
|
402
|
-
export declare function isRouteWithComponents(value: DeepReadonly<RouteProps>): value is DeepReadonly<RouteProps & WithComponents>;
|
|
403
|
-
|
|
404
599
|
declare type MakeOptional<T> = {
|
|
405
600
|
[P in WithOptionalProperties<T>]?: T[P];
|
|
406
601
|
} & {
|
|
407
602
|
[P in Exclude<keyof T, WithOptionalProperties<T>>]: T[P];
|
|
408
603
|
};
|
|
409
604
|
|
|
605
|
+
declare type MakeOptional_2<T> = {
|
|
606
|
+
[P in WithOptionalProperties_2<T>]?: T[P];
|
|
607
|
+
} & {
|
|
608
|
+
[P in Exclude<keyof T, WithOptionalProperties_2<T>>]: T[P];
|
|
609
|
+
}
|
|
610
|
+
|
|
410
611
|
declare type MaybeArray<T> = T | T[];
|
|
411
612
|
|
|
613
|
+
declare type MaybeArray_2<T> = T | T[]
|
|
614
|
+
|
|
412
615
|
declare type MaybePromise<T> = T | Promise<T>;
|
|
413
616
|
|
|
617
|
+
declare type MaybePromise_2<T> = T | Promise<T>
|
|
618
|
+
|
|
414
619
|
/**
|
|
415
620
|
* Merges two parameter type records, ensuring no overlap in properties.
|
|
416
621
|
* @template TAlpha - The first record type.
|
|
@@ -421,8 +626,29 @@ export declare type MergeParams<TAlpha extends Record<string, unknown>, TBeta ex
|
|
|
421
626
|
[K in keyof TAlpha | keyof TBeta]: K extends keyof TAlpha & keyof TBeta ? never : K extends keyof TAlpha ? TAlpha[K] : K extends keyof TBeta ? TBeta[K] : never;
|
|
422
627
|
};
|
|
423
628
|
|
|
629
|
+
/**
|
|
630
|
+
* Merges two parameter type records, ensuring no overlap in properties.
|
|
631
|
+
* @template TAlpha - The first record type.
|
|
632
|
+
* @template TBeta - The second record type.
|
|
633
|
+
* @returns A new record type combining properties from both inputs without overlaps.
|
|
634
|
+
*/
|
|
635
|
+
declare type MergeParams_2<
|
|
636
|
+
TAlpha extends Record<string, unknown>,
|
|
637
|
+
TBeta extends Record<string, unknown>
|
|
638
|
+
> = {
|
|
639
|
+
[K in keyof TAlpha | keyof TBeta]: K extends keyof TAlpha & keyof TBeta
|
|
640
|
+
? never
|
|
641
|
+
: K extends keyof TAlpha
|
|
642
|
+
? TAlpha[K]
|
|
643
|
+
: K extends keyof TBeta
|
|
644
|
+
? TBeta[K]
|
|
645
|
+
: never
|
|
646
|
+
}
|
|
647
|
+
|
|
424
648
|
declare type NamedNotDisabled<T> = T extends BaseRoute ? T : never;
|
|
425
649
|
|
|
650
|
+
declare type NamedNotDisabled_2<T> = T extends BaseRoute_2 ? T : never
|
|
651
|
+
|
|
426
652
|
/**
|
|
427
653
|
* Registers a hook that is called after a route has been entered. Must be called during setup.
|
|
428
654
|
* This allows performing actions right after the component becomes active, such as fetching data or setting up event listeners.
|
|
@@ -472,36 +698,72 @@ declare type OnlyRequiredProperties<T> = {
|
|
|
472
698
|
[K in keyof T as Extract<T[K], undefined> extends never ? K : never]: T[K];
|
|
473
699
|
};
|
|
474
700
|
|
|
701
|
+
declare type OnlyRequiredProperties_2<T> = {
|
|
702
|
+
[K in keyof T as Extract<T[K], undefined> extends never ? K : never]: T[K]
|
|
703
|
+
}
|
|
704
|
+
|
|
475
705
|
declare type OptionalParamGetSet<TParam extends Param> = TParam extends ParamGetSet ? TParam & IsOptionalParam : ParamGetSet<ExtractParamType<TParam>> & IsOptionalParam;
|
|
476
706
|
|
|
707
|
+
declare type OptionalParamGetSet_2<TParam extends Param_2> = TParam extends ParamGetSet_2
|
|
708
|
+
? TParam & IsOptionalParam_2
|
|
709
|
+
: ParamGetSet_2<ExtractParamType_2<TParam>> & IsOptionalParam_2
|
|
710
|
+
|
|
477
711
|
declare const optionalParamKey: unique symbol;
|
|
478
712
|
|
|
713
|
+
declare const optionalParamKey_2 = Symbol();
|
|
714
|
+
|
|
479
715
|
export declare type Param = ParamGetter | ParamGetSet | RegExp | BooleanConstructor | NumberConstructor | StringConstructor | DateConstructor | JSON;
|
|
480
716
|
|
|
717
|
+
declare type Param_2 = ParamGetter_2 | ParamGetSet_2 | RegExp | BooleanConstructor | NumberConstructor | StringConstructor | DateConstructor | JSON
|
|
718
|
+
|
|
481
719
|
export declare type ParamEnd = typeof paramEnd;
|
|
482
720
|
|
|
483
721
|
export declare const paramEnd = "]";
|
|
484
722
|
|
|
723
|
+
declare type ParamEnd_2 = typeof paramEnd_2
|
|
724
|
+
|
|
725
|
+
declare const paramEnd_2 = ']';
|
|
726
|
+
|
|
485
727
|
export declare type ParamExtras = {
|
|
486
728
|
invalid: (message?: string) => never;
|
|
487
729
|
};
|
|
488
730
|
|
|
731
|
+
declare type ParamExtras_2 = {
|
|
732
|
+
invalid: (message?: string) => never,
|
|
733
|
+
}
|
|
734
|
+
|
|
489
735
|
export declare type ParamGetSet<T = any> = {
|
|
490
736
|
get: ParamGetter<T>;
|
|
491
737
|
set: ParamSetter<T>;
|
|
492
738
|
defaultValue?: T;
|
|
493
739
|
};
|
|
494
740
|
|
|
741
|
+
declare type ParamGetSet_2<T = any> = {
|
|
742
|
+
get: ParamGetter_2<T>,
|
|
743
|
+
set: ParamSetter_2<T>,
|
|
744
|
+
defaultValue?: T,
|
|
745
|
+
}
|
|
746
|
+
|
|
495
747
|
export declare type ParamGetter<T = any> = (value: string, extras: ParamExtras) => T;
|
|
496
748
|
|
|
749
|
+
declare type ParamGetter_2<T = any> = (value: string, extras: ParamExtras_2) => T
|
|
750
|
+
|
|
497
751
|
export declare type ParamSetter<T = any> = (value: T, extras: ParamExtras) => string;
|
|
498
752
|
|
|
753
|
+
declare type ParamSetter_2<T = any> = (value: T, extras: ParamExtras_2) => string
|
|
754
|
+
|
|
499
755
|
export declare type ParamStart = typeof paramStart;
|
|
500
756
|
|
|
501
757
|
export declare const paramStart = "[";
|
|
502
758
|
|
|
759
|
+
declare type ParamStart_2 = typeof paramStart_2
|
|
760
|
+
|
|
761
|
+
declare const paramStart_2 = '[';
|
|
762
|
+
|
|
503
763
|
export declare type ParamWithDefault<TParam extends Param = Param> = Required<ParamGetSet<ExtractParamType<TParam>>>;
|
|
504
764
|
|
|
765
|
+
declare type ParamWithDefault_2<TParam extends Param_2 = Param_2> = Required<ParamGetSet_2<ExtractParamType_2<TParam>>>
|
|
766
|
+
|
|
505
767
|
/**
|
|
506
768
|
* Represents properties common to parent routes in a route configuration, including hooks, path, and optional query parameters.
|
|
507
769
|
*/
|
|
@@ -532,6 +794,36 @@ export declare type ParentRouteProps = Partial<WithComponent | WithComponents> &
|
|
|
532
794
|
meta?: RouteMeta;
|
|
533
795
|
};
|
|
534
796
|
|
|
797
|
+
/**
|
|
798
|
+
* Represents properties common to parent routes in a route configuration, including hooks, path, and optional query parameters.
|
|
799
|
+
*/
|
|
800
|
+
declare type ParentRouteProps_2 = Partial<WithComponent_2 | WithComponents_2> & WithHooks_2 & {
|
|
801
|
+
/**
|
|
802
|
+
* Name for route, used to create route keys and in navigation.
|
|
803
|
+
*/
|
|
804
|
+
name?: string,
|
|
805
|
+
/**
|
|
806
|
+
* Path part of URL.
|
|
807
|
+
*/
|
|
808
|
+
path: string | Path_2,
|
|
809
|
+
/**
|
|
810
|
+
* Query (aka search) part of URL.
|
|
811
|
+
*/
|
|
812
|
+
query?: string | Query_2,
|
|
813
|
+
/**
|
|
814
|
+
* Disabled routes will not ever match but can still provide physical structure, nested children behave normally.
|
|
815
|
+
*/
|
|
816
|
+
disabled?: boolean,
|
|
817
|
+
/**
|
|
818
|
+
* Children routes, expected type comes from `createRoutes()`
|
|
819
|
+
*/
|
|
820
|
+
children: Routes_2,
|
|
821
|
+
/**
|
|
822
|
+
* Represents additional metadata associated with a route, customizable via declaration merging.
|
|
823
|
+
*/
|
|
824
|
+
meta?: RouteMeta_2,
|
|
825
|
+
}
|
|
826
|
+
|
|
535
827
|
declare type Path<TPath extends string = string, TParams extends PathParams<TPath> = Record<string, Param | undefined>> = {
|
|
536
828
|
path: TPath;
|
|
537
829
|
params: string extends TPath ? Record<string, Param> : Identity<ExtractParamsFromPathString<TPath, TParams>>;
|
|
@@ -563,10 +855,23 @@ declare type Path<TPath extends string = string, TParams extends PathParams<TPat
|
|
|
563
855
|
*/
|
|
564
856
|
export declare function path<TPath extends string, TParams extends PathParams<TPath>>(path: TPath, params: Identity<TParams>): Path<TPath, TParams>;
|
|
565
857
|
|
|
858
|
+
declare type Path_2<
|
|
859
|
+
TPath extends string = string,
|
|
860
|
+
TParams extends PathParams_2<TPath> = Record<string, Param_2 | undefined>
|
|
861
|
+
> = {
|
|
862
|
+
path: TPath,
|
|
863
|
+
params: string extends TPath ? Record<string, Param_2> : Identity_2<ExtractParamsFromPathString_2<TPath, TParams>>,
|
|
864
|
+
toString: () => string,
|
|
865
|
+
}
|
|
866
|
+
|
|
566
867
|
declare type PathParams<TPath extends string> = {
|
|
567
868
|
[K in keyof ExtractParamsFromPathString<TPath>]?: Param;
|
|
568
869
|
};
|
|
569
870
|
|
|
871
|
+
declare type PathParams_2<TPath extends string> = {
|
|
872
|
+
[K in keyof ExtractParamsFromPathString_2<TPath>]?: Param_2
|
|
873
|
+
}
|
|
874
|
+
|
|
570
875
|
declare type Props<TComponent extends Component> = TComponent extends Constructor ? InstanceType<TComponent>['$props'] : TComponent extends AsyncComponentLoader<infer T extends Component> ? Props<T> : TComponent extends FunctionalComponent<infer T> ? T : never;
|
|
571
876
|
|
|
572
877
|
declare type PropsGetter<TComponent extends Component> = () => MaybePromise<Props<TComponent>>;
|
|
@@ -602,10 +907,23 @@ declare type Query<TQuery extends string = string, TQueryParams extends QueryPar
|
|
|
602
907
|
*/
|
|
603
908
|
export declare function query<TQuery extends string, TParams extends QueryParams<TQuery>>(query: TQuery, params: Identity<TParams>): Query<TQuery, TParams>;
|
|
604
909
|
|
|
910
|
+
declare type Query_2<
|
|
911
|
+
TQuery extends string = string,
|
|
912
|
+
TQueryParams extends QueryParams_2<TQuery> = Record<string, Param_2 | undefined>
|
|
913
|
+
> = {
|
|
914
|
+
query: TQuery,
|
|
915
|
+
params: string extends TQuery ? Record<string, Param_2> : Identity_2<ExtractQueryParamsFromQueryString_2<TQuery, TQueryParams>>,
|
|
916
|
+
toString: () => string,
|
|
917
|
+
}
|
|
918
|
+
|
|
605
919
|
declare type QueryParams<T extends string> = {
|
|
606
920
|
[K in keyof ExtractQueryParamsFromQueryString<T>]?: Param;
|
|
607
921
|
};
|
|
608
922
|
|
|
923
|
+
declare type QueryParams_2<T extends string> = {
|
|
924
|
+
[K in keyof ExtractQueryParamsFromQueryString_2<T>]?: Param_2
|
|
925
|
+
}
|
|
926
|
+
|
|
609
927
|
/**
|
|
610
928
|
* Represents the state of currently registered router, and rejections. Used to provide correct type context for
|
|
611
929
|
* components like `RouterLink`, as well as for composables like `useRouter`, `useRoute`, and hooks.
|
|
@@ -622,6 +940,21 @@ declare type QueryParams<T extends string> = {
|
|
|
622
940
|
export declare interface Register {
|
|
623
941
|
}
|
|
624
942
|
|
|
943
|
+
/**
|
|
944
|
+
* Represents the state of currently registered router, and rejections. Used to provide correct type context for
|
|
945
|
+
* components like `RouterLink`, as well as for composables like `useRouter`, `useRoute`, and hooks.
|
|
946
|
+
*
|
|
947
|
+
* @example
|
|
948
|
+
* ```ts
|
|
949
|
+
* declare module '@kitbag/router' {
|
|
950
|
+
* interface Register {
|
|
951
|
+
* router: typeof router
|
|
952
|
+
* }
|
|
953
|
+
* }
|
|
954
|
+
* ```
|
|
955
|
+
*/
|
|
956
|
+
declare interface Register_2 {}
|
|
957
|
+
|
|
625
958
|
/**
|
|
626
959
|
* Represents the possible Rejections registered within {@link Register}
|
|
627
960
|
*/
|
|
@@ -629,6 +962,13 @@ export declare type RegisteredRejectionType = Register extends {
|
|
|
629
962
|
rejections: infer TRejections extends string[];
|
|
630
963
|
} ? TRejections[number] : never;
|
|
631
964
|
|
|
965
|
+
/**
|
|
966
|
+
* Represents the possible Rejections registered within {@link Register}
|
|
967
|
+
*/
|
|
968
|
+
declare type RegisteredRejectionType_2 = Register_2 extends { rejections: infer TRejections extends string[] }
|
|
969
|
+
? TRejections[number]
|
|
970
|
+
: never
|
|
971
|
+
|
|
632
972
|
/**
|
|
633
973
|
* Represents the a map of all possible RouteKeys with corresponding Route registered within {@link Register}
|
|
634
974
|
*/
|
|
@@ -646,11 +986,21 @@ export declare type RegisteredRouter = Register extends {
|
|
|
646
986
|
*/
|
|
647
987
|
export declare type RegisteredRouterPush = RouterPush<RegisteredRoutes>;
|
|
648
988
|
|
|
989
|
+
/**
|
|
990
|
+
* Represents the type for router `push`, with types for routes registered within {@link Register}
|
|
991
|
+
*/
|
|
992
|
+
declare type RegisteredRouterPush_2 = RouterPush_2<RegisteredRoutes_2>
|
|
993
|
+
|
|
649
994
|
/**
|
|
650
995
|
* Represents the type for router `replace`, with types for routes registered within {@link Register}
|
|
651
996
|
*/
|
|
652
997
|
export declare type RegisteredRouterReplace = RouterReplace<RegisteredRoutes>;
|
|
653
998
|
|
|
999
|
+
/**
|
|
1000
|
+
* Represents the type for router `replace`, with types for routes registered within {@link Register}
|
|
1001
|
+
*/
|
|
1002
|
+
declare type RegisteredRouterReplace_2 = RouterReplace_2<RegisteredRoutes_2>
|
|
1003
|
+
|
|
654
1004
|
/**
|
|
655
1005
|
* Represents the State property registered within {@link Register}
|
|
656
1006
|
*/
|
|
@@ -665,6 +1015,13 @@ export declare type RegisteredRoutes = Register extends {
|
|
|
665
1015
|
router: Router<infer TRoutes extends Routes>;
|
|
666
1016
|
} ? TRoutes : Route<string, Path<'', {}>, Query<'', {}>, false>[];
|
|
667
1017
|
|
|
1018
|
+
/**
|
|
1019
|
+
* Represents the Router routes property within {@link Register}
|
|
1020
|
+
*/
|
|
1021
|
+
declare type RegisteredRoutes_2 = Register_2 extends { router: Router_2<infer TRoutes extends Routes_2> }
|
|
1022
|
+
? TRoutes
|
|
1023
|
+
: Route_2<string, Path_2<'', {}>, Query_2<'', {}>, false>[]
|
|
1024
|
+
|
|
668
1025
|
/**
|
|
669
1026
|
* Represents the union of all possible RouteKeys registered within {@link Register}
|
|
670
1027
|
*/
|
|
@@ -674,7 +1031,7 @@ export declare type RegisteredRoutesKey = RoutesKey<RegisteredRoutes>;
|
|
|
674
1031
|
* Represents a route that the router has matched to current browser location.
|
|
675
1032
|
* @template TRoute - Underlying Route that has been resolved.
|
|
676
1033
|
*/
|
|
677
|
-
declare type ResolvedRoute<TRoute extends Route = BaseResolvedRoute> =
|
|
1034
|
+
declare type ResolvedRoute<TRoute extends Route = BaseResolvedRoute> = Readonly<{
|
|
678
1035
|
/**
|
|
679
1036
|
* The specific route properties that were matched in the current route.
|
|
680
1037
|
*/
|
|
@@ -698,11 +1055,44 @@ declare type ResolvedRoute<TRoute extends Route = BaseResolvedRoute> = DeepReado
|
|
|
698
1055
|
params: BaseResolvedRoute extends TRoute ? Record<string, unknown> : ExtractRouteParamTypes<TRoute>;
|
|
699
1056
|
}>;
|
|
700
1057
|
|
|
1058
|
+
/**
|
|
1059
|
+
* Represents a route that the router has matched to current browser location.
|
|
1060
|
+
* @template TRoute - Underlying Route that has been resolved.
|
|
1061
|
+
*/
|
|
1062
|
+
declare type ResolvedRoute_2<TRoute extends Route_2 = BaseResolvedRoute_2> = Readonly<{
|
|
1063
|
+
/**
|
|
1064
|
+
* The specific route properties that were matched in the current route.
|
|
1065
|
+
*/
|
|
1066
|
+
matched: TRoute['matched'],
|
|
1067
|
+
/**
|
|
1068
|
+
* The specific route properties that were matched in the current route, including any ancestors.
|
|
1069
|
+
* Order of routes will be from greatest ancestor to narrowest matched.
|
|
1070
|
+
*/
|
|
1071
|
+
matches: TRoute['matches'],
|
|
1072
|
+
/**
|
|
1073
|
+
* Unique identifier for the route, generated by joining route `name` by period. Key is used for routing and for matching.
|
|
1074
|
+
*/
|
|
1075
|
+
key: TRoute['key'],
|
|
1076
|
+
/**
|
|
1077
|
+
* Accessor for query string values from user in the current browser location.
|
|
1078
|
+
*/
|
|
1079
|
+
query: ResolvedRouteQuery_2,
|
|
1080
|
+
/**
|
|
1081
|
+
* Key value pair for route params, values will be the user provided value from current browser location.
|
|
1082
|
+
*/
|
|
1083
|
+
params: BaseResolvedRoute_2 extends TRoute ? Record<string, unknown> : ExtractRouteParamTypes_2<TRoute>,
|
|
1084
|
+
}>
|
|
1085
|
+
|
|
701
1086
|
declare type ResolvedRouteQuery = {
|
|
702
1087
|
get: (key: string) => string | null;
|
|
703
1088
|
getAll: (key: string) => string[];
|
|
704
1089
|
};
|
|
705
1090
|
|
|
1091
|
+
declare type ResolvedRouteQuery_2 = {
|
|
1092
|
+
get: (key: string) => string | null,
|
|
1093
|
+
getAll: (key: string) => string[],
|
|
1094
|
+
}
|
|
1095
|
+
|
|
706
1096
|
/**
|
|
707
1097
|
* Represents the structure of a route within the application. Return value of `createRoutes`
|
|
708
1098
|
* @template TKey - Represents the unique key identifying the route, typically a string.
|
|
@@ -710,7 +1100,7 @@ declare type ResolvedRouteQuery = {
|
|
|
710
1100
|
* @template TQuery - The type or structure of the query parameters associated with the route.
|
|
711
1101
|
* @template TDisabled - Indicates whether the route is disabled, which could affect routing logic.
|
|
712
1102
|
*/
|
|
713
|
-
export declare type Route<TKey extends string
|
|
1103
|
+
export declare type Route<TKey extends string = string, TPath extends string | Path = Path, TQuery extends string | Query = Query, TDisabled extends boolean = boolean> = {
|
|
714
1104
|
/**
|
|
715
1105
|
* The specific route properties that were matched in the current route.
|
|
716
1106
|
*/
|
|
@@ -739,8 +1129,51 @@ export declare type Route<TKey extends string | undefined = any, TPath extends s
|
|
|
739
1129
|
disabled: TDisabled extends boolean ? TDisabled : false;
|
|
740
1130
|
};
|
|
741
1131
|
|
|
1132
|
+
/**
|
|
1133
|
+
* Represents the structure of a route within the application. Return value of `createRoutes`
|
|
1134
|
+
* @template TKey - Represents the unique key identifying the route, typically a string.
|
|
1135
|
+
* @template TPath - The type or structure of the route's path.
|
|
1136
|
+
* @template TQuery - The type or structure of the query parameters associated with the route.
|
|
1137
|
+
* @template TDisabled - Indicates whether the route is disabled, which could affect routing logic.
|
|
1138
|
+
*/
|
|
1139
|
+
declare type Route_2<
|
|
1140
|
+
TKey extends string = string,
|
|
1141
|
+
TPath extends string | Path_2 = Path_2,
|
|
1142
|
+
TQuery extends string | Query_2 = Query_2,
|
|
1143
|
+
TDisabled extends boolean = boolean
|
|
1144
|
+
> = {
|
|
1145
|
+
/**
|
|
1146
|
+
* The specific route properties that were matched in the current route.
|
|
1147
|
+
*/
|
|
1148
|
+
matched: RoutePropsWithMeta_2,
|
|
1149
|
+
/**
|
|
1150
|
+
* The specific route properties that were matched in the current route, including any ancestors.
|
|
1151
|
+
* Order of routes will be from greatest ancestor to narrowest matched.
|
|
1152
|
+
*/
|
|
1153
|
+
matches: RoutePropsWithMeta_2[],
|
|
1154
|
+
/**
|
|
1155
|
+
* Unique identifier for the route, generated by joining route `name` by period. Key is used for routing and for matching.
|
|
1156
|
+
*/
|
|
1157
|
+
key: TKey,
|
|
1158
|
+
/**
|
|
1159
|
+
* Represents the structured path of the route, including path params.
|
|
1160
|
+
*/
|
|
1161
|
+
path: ToPath_2<TPath>,
|
|
1162
|
+
/**
|
|
1163
|
+
* Represents the structured query of the route, including query params.
|
|
1164
|
+
*/
|
|
1165
|
+
query: ToQuery_2<TQuery>,
|
|
1166
|
+
depth: number,
|
|
1167
|
+
/**
|
|
1168
|
+
* Indicates if the route is disabled.
|
|
1169
|
+
*/
|
|
1170
|
+
disabled: TDisabled extends boolean ? TDisabled : false,
|
|
1171
|
+
}
|
|
1172
|
+
|
|
742
1173
|
declare type RouteGetByKey<TRoutes extends Routes, TKey extends RoutesKey<TRoutes>> = RoutesMap<TRoutes>[TKey];
|
|
743
1174
|
|
|
1175
|
+
declare type RouteGetByKey_2<TRoutes extends Routes_2, TKey extends RoutesKey_2<TRoutes>> = RoutesMap_2<TRoutes>[TKey]
|
|
1176
|
+
|
|
744
1177
|
/**
|
|
745
1178
|
* Generic type representing a route hook, which can be either before or after a route change.
|
|
746
1179
|
*/
|
|
@@ -751,6 +1184,11 @@ export declare type RouteHook = BeforeRouteHook | AfterRouteHook;
|
|
|
751
1184
|
*/
|
|
752
1185
|
export declare type RouteHookAbort = () => void;
|
|
753
1186
|
|
|
1187
|
+
/**
|
|
1188
|
+
* A function that can be called to abort a routing operation.
|
|
1189
|
+
*/
|
|
1190
|
+
declare type RouteHookAbort_2 = () => void
|
|
1191
|
+
|
|
754
1192
|
/**
|
|
755
1193
|
* Defines the structure of an aborted route hook response.
|
|
756
1194
|
*/
|
|
@@ -768,6 +1206,16 @@ declare type RouteHookContext = {
|
|
|
768
1206
|
replace: RegisteredRouterReplace;
|
|
769
1207
|
};
|
|
770
1208
|
|
|
1209
|
+
/**
|
|
1210
|
+
* Context provided to route hooks, containing context of previous route and functions for triggering rejections and push/replace to another route.
|
|
1211
|
+
*/
|
|
1212
|
+
declare type RouteHookContext_2 = {
|
|
1213
|
+
from: ResolvedRoute_2 | null,
|
|
1214
|
+
reject: RouterReject_2,
|
|
1215
|
+
push: RegisteredRouterPush_2,
|
|
1216
|
+
replace: RegisteredRouterReplace_2,
|
|
1217
|
+
}
|
|
1218
|
+
|
|
771
1219
|
/**
|
|
772
1220
|
* Union type for all route hook lifecycle events.
|
|
773
1221
|
*/
|
|
@@ -795,6 +1243,11 @@ declare type RouteHookRejectResponse = {
|
|
|
795
1243
|
*/
|
|
796
1244
|
export declare type RouteHookRemove = () => void;
|
|
797
1245
|
|
|
1246
|
+
/**
|
|
1247
|
+
* A function to remove a previously registered route hook.
|
|
1248
|
+
*/
|
|
1249
|
+
declare type RouteHookRemove_2 = () => void
|
|
1250
|
+
|
|
798
1251
|
/**
|
|
799
1252
|
* Union type for all possible route hook responses, covering both before and after scenarios.
|
|
800
1253
|
* @template TRoutes - The type of the routes configuration.
|
|
@@ -822,20 +1275,48 @@ declare type RouteHookSuccessResponse = {
|
|
|
822
1275
|
export declare interface RouteMeta extends Record<string, unknown> {
|
|
823
1276
|
}
|
|
824
1277
|
|
|
1278
|
+
/**
|
|
1279
|
+
* Represents additional metadata associated with a route, customizable via declaration merging.
|
|
1280
|
+
* @example
|
|
1281
|
+
* ```ts
|
|
1282
|
+
* declare module '@kitbag/router' {
|
|
1283
|
+
* interface RouteMeta {
|
|
1284
|
+
* pageTitle?: string
|
|
1285
|
+
* }
|
|
1286
|
+
* }
|
|
1287
|
+
* ```
|
|
1288
|
+
*/
|
|
1289
|
+
declare interface RouteMeta_2 extends Record<string, unknown> {}
|
|
1290
|
+
|
|
825
1291
|
declare type RouteParamsByKey<TRoutes extends Routes, TKey extends string> = ExtractRouteParamTypesWithoutLosingOptional<RouteGetByKey<TRoutes, TKey>>;
|
|
826
1292
|
|
|
1293
|
+
declare type RouteParamsByKey_2<
|
|
1294
|
+
TRoutes extends Routes_2,
|
|
1295
|
+
TKey extends string
|
|
1296
|
+
> = ExtractRouteParamTypesWithoutLosingOptional_2<RouteGetByKey_2<TRoutes, TKey>>
|
|
1297
|
+
|
|
827
1298
|
/**
|
|
828
1299
|
* Unifies the properties of both parent and child routes, ensuring type safety and consistency across route configurations.
|
|
829
1300
|
*/
|
|
830
1301
|
export declare type RouteProps = Readonly<ParentRouteProps | ChildRouteProps>;
|
|
831
1302
|
|
|
1303
|
+
/**
|
|
1304
|
+
* Unifies the properties of both parent and child routes, ensuring type safety and consistency across route configurations.
|
|
1305
|
+
*/
|
|
1306
|
+
declare type RouteProps_2 = Readonly<ParentRouteProps_2 | ChildRouteProps_2>
|
|
1307
|
+
|
|
832
1308
|
/**
|
|
833
1309
|
* The Route properties originally provided to `createRoutes`. The only change is normalizing meta to always default to an empty object.
|
|
834
1310
|
*/
|
|
835
|
-
declare type RoutePropsWithMeta = RouteProps & {
|
|
1311
|
+
export declare type RoutePropsWithMeta = RouteProps & {
|
|
836
1312
|
meta: RouteMeta;
|
|
837
1313
|
};
|
|
838
1314
|
|
|
1315
|
+
/**
|
|
1316
|
+
* The Route properties originally provided to `createRoutes`. The only change is normalizing meta to always default to an empty object.
|
|
1317
|
+
*/
|
|
1318
|
+
declare type RoutePropsWithMeta_2 = RouteProps_2 & { meta: RouteMeta_2 }
|
|
1319
|
+
|
|
839
1320
|
export declare type Router<TRoutes extends Routes = any> = Plugin_2 & {
|
|
840
1321
|
/**
|
|
841
1322
|
* Manages the current route state.
|
|
@@ -907,12 +1388,100 @@ export declare type Router<TRoutes extends Routes = any> = Plugin_2 & {
|
|
|
907
1388
|
initialized: Promise<void>;
|
|
908
1389
|
};
|
|
909
1390
|
|
|
1391
|
+
declare type Router_2<
|
|
1392
|
+
TRoutes extends Routes_2 = any
|
|
1393
|
+
> = Plugin_2 & {
|
|
1394
|
+
/**
|
|
1395
|
+
* Manages the current route state.
|
|
1396
|
+
*/
|
|
1397
|
+
route: RouterRoute_2,
|
|
1398
|
+
/**
|
|
1399
|
+
* Resolves a URL to a route object.
|
|
1400
|
+
*/
|
|
1401
|
+
resolve: RouterResolve_2<TRoutes>,
|
|
1402
|
+
/**
|
|
1403
|
+
* Navigates to a specified path or route object in the history stack, adding a new entry.
|
|
1404
|
+
*/
|
|
1405
|
+
push: RouterPush_2<TRoutes>,
|
|
1406
|
+
/**
|
|
1407
|
+
* Replaces the current entry in the history stack with a new one.
|
|
1408
|
+
*/
|
|
1409
|
+
replace: RouterReplace_2<TRoutes>,
|
|
1410
|
+
/**
|
|
1411
|
+
* Finds a route object based on the provided lookup parameters.
|
|
1412
|
+
*/
|
|
1413
|
+
find: RouterFind_2<TRoutes>,
|
|
1414
|
+
/**
|
|
1415
|
+
* Handles route rejection based on a specified rejection type.
|
|
1416
|
+
*/
|
|
1417
|
+
reject: RouterReject_2,
|
|
1418
|
+
/**
|
|
1419
|
+
* Forces the router to re-evaluate the current route.
|
|
1420
|
+
*/
|
|
1421
|
+
refresh: () => void,
|
|
1422
|
+
/**
|
|
1423
|
+
* Navigates to the previous entry in the browser's history stack.
|
|
1424
|
+
*/
|
|
1425
|
+
back: () => void,
|
|
1426
|
+
/**
|
|
1427
|
+
* Navigates to the next entry in the browser's history stack.
|
|
1428
|
+
*/
|
|
1429
|
+
forward: () => void,
|
|
1430
|
+
/**
|
|
1431
|
+
* Moves the current history entry to a specific point in the history stack.
|
|
1432
|
+
*/
|
|
1433
|
+
go: (delta: number) => void,
|
|
1434
|
+
/**
|
|
1435
|
+
* Registers a hook to be called before a route is entered.
|
|
1436
|
+
*/
|
|
1437
|
+
onBeforeRouteEnter: AddBeforeRouteHook_2,
|
|
1438
|
+
/**
|
|
1439
|
+
* Registers a hook to be called before a route is left.
|
|
1440
|
+
*/
|
|
1441
|
+
onBeforeRouteLeave: AddBeforeRouteHook_2,
|
|
1442
|
+
/**
|
|
1443
|
+
* Registers a hook to be called before a route is updated.
|
|
1444
|
+
*/
|
|
1445
|
+
onBeforeRouteUpdate: AddBeforeRouteHook_2,
|
|
1446
|
+
/**
|
|
1447
|
+
* Registers a hook to be called after a route is entered.
|
|
1448
|
+
*/
|
|
1449
|
+
onAfterRouteEnter: AddAfterRouteHook_2,
|
|
1450
|
+
/**
|
|
1451
|
+
* Registers a hook to be called after a route is left.
|
|
1452
|
+
*/
|
|
1453
|
+
onAfterRouteLeave: AddAfterRouteHook_2,
|
|
1454
|
+
/**
|
|
1455
|
+
* Registers a hook to be called after a route is updated.
|
|
1456
|
+
*/
|
|
1457
|
+
onAfterRouteUpdate: AddAfterRouteHook_2,
|
|
1458
|
+
/**
|
|
1459
|
+
* A promise that resolves when the router is fully initialized.
|
|
1460
|
+
*/
|
|
1461
|
+
initialized: Promise<void>,
|
|
1462
|
+
}
|
|
1463
|
+
|
|
910
1464
|
declare type RouterFind<TRoutes extends Routes> = {
|
|
911
1465
|
<TSource extends RoutesKey<TRoutes>>(source: TSource, ...args: RouterFindArgs<TRoutes, TSource>): ResolvedRoute | undefined;
|
|
912
1466
|
(source: Url): ResolvedRoute | undefined;
|
|
913
1467
|
};
|
|
914
1468
|
|
|
915
|
-
declare type
|
|
1469
|
+
declare type RouterFind_2<
|
|
1470
|
+
TRoutes extends Routes_2
|
|
1471
|
+
> = {
|
|
1472
|
+
<TSource extends RoutesKey_2<TRoutes>>(source: TSource, ...args: RouterFindArgs_2<TRoutes, TSource>): ResolvedRoute_2 | undefined,
|
|
1473
|
+
(source: Url_2): ResolvedRoute_2 | undefined,
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
declare type RouterFindArgs<TRoutes extends Routes, TSource extends RoutesKey<TRoutes>, TParams = RouteParamsByKey<TRoutes, TSource>> = AllPropertiesAreOptional<TParams> extends true ? [params?: TParams] : [params: TParams];
|
|
1477
|
+
|
|
1478
|
+
declare type RouterFindArgs_2<
|
|
1479
|
+
TRoutes extends Routes_2,
|
|
1480
|
+
TSource extends RoutesKey_2<TRoutes>,
|
|
1481
|
+
TParams = RouteParamsByKey_2<TRoutes, TSource>
|
|
1482
|
+
> = AllPropertiesAreOptional_2<TParams> extends true
|
|
1483
|
+
? [params?: TParams]
|
|
1484
|
+
: [params: TParams]
|
|
916
1485
|
|
|
917
1486
|
declare type RouterHistoryMode = 'auto' | 'browser' | 'memory' | 'hash';
|
|
918
1487
|
|
|
@@ -966,15 +1535,37 @@ declare type RouterPush<TRoutes extends Routes = any> = {
|
|
|
966
1535
|
(source: Url, options?: RouterPushOptions): Promise<void>;
|
|
967
1536
|
};
|
|
968
1537
|
|
|
969
|
-
declare type
|
|
1538
|
+
declare type RouterPush_2<
|
|
1539
|
+
TRoutes extends Routes_2 = any
|
|
1540
|
+
> = {
|
|
1541
|
+
<TSource extends RoutesKey_2<TRoutes>>(source: TSource, ...args: RouterPushArgs_2<TRoutes, TSource>): Promise<void>,
|
|
1542
|
+
(source: Url_2, options?: RouterPushOptions_2): Promise<void>,
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
declare type RouterPushArgs<TRoutes extends Routes, TSource extends RoutesKey<TRoutes>, TParams = RouteParamsByKey<TRoutes, TSource>> = AllPropertiesAreOptional<TParams> extends true ? [params?: TParams, options?: RouterPushOptions] : [params: TParams, options?: RouterPushOptions];
|
|
1546
|
+
|
|
1547
|
+
declare type RouterPushArgs_2<
|
|
1548
|
+
TRoutes extends Routes_2,
|
|
1549
|
+
TSource extends RoutesKey_2<TRoutes>,
|
|
1550
|
+
TParams = RouteParamsByKey_2<TRoutes, TSource>
|
|
1551
|
+
> = AllPropertiesAreOptional_2<TParams> extends true
|
|
1552
|
+
? [params?: TParams, options?: RouterPushOptions_2]
|
|
1553
|
+
: [params: TParams, options?: RouterPushOptions_2]
|
|
970
1554
|
|
|
971
1555
|
declare type RouterPushOptions = {
|
|
972
1556
|
query?: Record<string, string>;
|
|
973
1557
|
replace?: boolean;
|
|
974
1558
|
};
|
|
975
1559
|
|
|
1560
|
+
declare type RouterPushOptions_2 = {
|
|
1561
|
+
query?: Record<string, string>,
|
|
1562
|
+
replace?: boolean,
|
|
1563
|
+
}
|
|
1564
|
+
|
|
976
1565
|
export declare type RouterReject = (type: RouterRejectionType) => void;
|
|
977
1566
|
|
|
1567
|
+
declare type RouterReject_2 = (type: RouterRejectionType_2) => void
|
|
1568
|
+
|
|
978
1569
|
declare type RouterRejection = Ref<null | {
|
|
979
1570
|
type: RouterRejectionType;
|
|
980
1571
|
component: Component;
|
|
@@ -988,39 +1579,102 @@ export declare const routerRejectionKey: InjectionKey<RouterRejection>;
|
|
|
988
1579
|
|
|
989
1580
|
declare type RouterRejectionType = BuiltInRejectionType | RegisteredRejectionType;
|
|
990
1581
|
|
|
1582
|
+
declare type RouterRejectionType_2 = BuiltInRejectionType_2 | RegisteredRejectionType_2
|
|
1583
|
+
|
|
991
1584
|
declare type RouterReplace<TRoutes extends Routes> = {
|
|
992
1585
|
<TSource extends RoutesKey<TRoutes>>(source: TSource, ...args: RouterReplaceArgs<TRoutes, TSource>): Promise<void>;
|
|
993
1586
|
(source: Url, options?: RouterReplaceOptions): Promise<void>;
|
|
994
1587
|
};
|
|
995
1588
|
|
|
996
|
-
declare type
|
|
1589
|
+
declare type RouterReplace_2<
|
|
1590
|
+
TRoutes extends Routes_2
|
|
1591
|
+
> = {
|
|
1592
|
+
<TSource extends RoutesKey_2<TRoutes>>(source: TSource, ...args: RouterReplaceArgs_2<TRoutes, TSource>): Promise<void>,
|
|
1593
|
+
(source: Url_2, options?: RouterReplaceOptions_2): Promise<void>,
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
declare type RouterReplaceArgs<TRoutes extends Routes, TSource extends RoutesKey<TRoutes>, TParams = RouteParamsByKey<TRoutes, TSource>> = AllPropertiesAreOptional<TParams> extends true ? [params?: TParams, options?: RouterReplaceOptions] : [params: TParams, options?: RouterReplaceOptions];
|
|
1597
|
+
|
|
1598
|
+
declare type RouterReplaceArgs_2<
|
|
1599
|
+
TRoutes extends Routes_2,
|
|
1600
|
+
TSource extends RoutesKey_2<TRoutes>,
|
|
1601
|
+
TParams = RouteParamsByKey_2<TRoutes, TSource>
|
|
1602
|
+
> = AllPropertiesAreOptional_2<TParams> extends true
|
|
1603
|
+
? [params?: TParams, options?: RouterReplaceOptions_2]
|
|
1604
|
+
: [params: TParams, options?: RouterReplaceOptions_2]
|
|
997
1605
|
|
|
998
1606
|
declare type RouterReplaceOptions = Omit<RouterPushOptions, 'replace'>;
|
|
999
1607
|
|
|
1608
|
+
declare type RouterReplaceOptions_2 = Omit<RouterPushOptions_2, 'replace'>
|
|
1609
|
+
|
|
1000
1610
|
declare type RouterResolve<TRoutes extends Routes> = {
|
|
1001
1611
|
<TSource extends RoutesKey<TRoutes>>(source: TSource, ...args: RouterResolveArgs<TRoutes, TSource>): string;
|
|
1002
1612
|
(source: Url, options?: RouterResolveOptions): string;
|
|
1003
1613
|
};
|
|
1004
1614
|
|
|
1005
|
-
declare type
|
|
1615
|
+
declare type RouterResolve_2<
|
|
1616
|
+
TRoutes extends Routes_2
|
|
1617
|
+
> = {
|
|
1618
|
+
<TSource extends RoutesKey_2<TRoutes>>(source: TSource, ...args: RouterResolveArgs_2<TRoutes, TSource>): string,
|
|
1619
|
+
(source: Url_2, options?: RouterResolveOptions_2): string,
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
declare type RouterResolveArgs<TRoutes extends Routes, TSource extends RoutesKey<TRoutes>, TParams = RouteParamsByKey<TRoutes, TSource>> = AllPropertiesAreOptional<TParams> extends true ? [params?: TParams, options?: RouterResolveOptions] : [params: TParams, options?: RouterResolveOptions];
|
|
1623
|
+
|
|
1624
|
+
declare type RouterResolveArgs_2<
|
|
1625
|
+
TRoutes extends Routes_2,
|
|
1626
|
+
TSource extends RoutesKey_2<TRoutes>,
|
|
1627
|
+
TParams = RouteParamsByKey_2<TRoutes, TSource>
|
|
1628
|
+
> = AllPropertiesAreOptional_2<TParams> extends true
|
|
1629
|
+
? [params?: TParams, options?: RouterResolveOptions_2]
|
|
1630
|
+
: [params: TParams, options?: RouterResolveOptions_2]
|
|
1006
1631
|
|
|
1007
1632
|
declare type RouterResolveOptions = {
|
|
1008
1633
|
query?: Record<string, string>;
|
|
1009
1634
|
};
|
|
1010
1635
|
|
|
1011
|
-
declare type
|
|
1636
|
+
declare type RouterResolveOptions_2 = {
|
|
1637
|
+
query?: Record<string, string>,
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
declare type RouterRoute<TRoute extends ResolvedRoute = ResolvedRoute> = Readonly<{
|
|
1641
|
+
key: TRoute['key'];
|
|
1642
|
+
matched: TRoute['matched'];
|
|
1643
|
+
matches: TRoute['matches'];
|
|
1644
|
+
query: ResolvedRouteQuery;
|
|
1012
1645
|
params: Writable<TRoute['params']>;
|
|
1013
1646
|
update: RouteUpdate<TRoute>;
|
|
1014
|
-
[isRouterRouteSymbol]: true;
|
|
1015
1647
|
}>;
|
|
1016
1648
|
|
|
1649
|
+
declare type RouterRoute_2<TRoute extends ResolvedRoute_2 = ResolvedRoute_2> = Readonly<{
|
|
1650
|
+
key: TRoute['key'],
|
|
1651
|
+
matched: TRoute['matched'],
|
|
1652
|
+
matches: TRoute['matches'],
|
|
1653
|
+
query: ResolvedRouteQuery_2,
|
|
1654
|
+
params: Writable_2<TRoute['params']>,
|
|
1655
|
+
update: RouteUpdate_2<TRoute>,
|
|
1656
|
+
}>
|
|
1657
|
+
|
|
1017
1658
|
export declare const RouterView: __VLS_WithTemplateSlots<DefineComponent<__VLS_TypePropsToRuntimeProps<{
|
|
1018
1659
|
name?: string | undefined;
|
|
1019
1660
|
}>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
1020
1661
|
name?: string | undefined;
|
|
1021
1662
|
}>>>, {}, {}>, Readonly<{
|
|
1022
1663
|
default?: ((props: {
|
|
1023
|
-
route:
|
|
1664
|
+
route: Readonly<{
|
|
1665
|
+
key: string;
|
|
1666
|
+
matched: RoutePropsWithMeta;
|
|
1667
|
+
matches: RoutePropsWithMeta[];
|
|
1668
|
+
query: ResolvedRouteQuery;
|
|
1669
|
+
params: Writable<Record<string, unknown>>;
|
|
1670
|
+
update: RouteUpdate<Readonly<{
|
|
1671
|
+
matched: RoutePropsWithMeta_2;
|
|
1672
|
+
matches: RoutePropsWithMeta_2[];
|
|
1673
|
+
key: string;
|
|
1674
|
+
query: ResolvedRouteQuery_2;
|
|
1675
|
+
params: Record<string, unknown>;
|
|
1676
|
+
}>>;
|
|
1677
|
+
}>;
|
|
1024
1678
|
component: Component;
|
|
1025
1679
|
rejection: {
|
|
1026
1680
|
type: "NotFound";
|
|
@@ -1031,7 +1685,20 @@ name?: string | undefined;
|
|
|
1031
1685
|
}>) | undefined;
|
|
1032
1686
|
}> & {
|
|
1033
1687
|
default?: ((props: {
|
|
1034
|
-
route:
|
|
1688
|
+
route: Readonly<{
|
|
1689
|
+
key: string;
|
|
1690
|
+
matched: RoutePropsWithMeta;
|
|
1691
|
+
matches: RoutePropsWithMeta[];
|
|
1692
|
+
query: ResolvedRouteQuery;
|
|
1693
|
+
params: Writable<Record<string, unknown>>;
|
|
1694
|
+
update: RouteUpdate<Readonly<{
|
|
1695
|
+
matched: RoutePropsWithMeta_2;
|
|
1696
|
+
matches: RoutePropsWithMeta_2[];
|
|
1697
|
+
key: string;
|
|
1698
|
+
query: ResolvedRouteQuery_2;
|
|
1699
|
+
params: Record<string, unknown>;
|
|
1700
|
+
}>>;
|
|
1701
|
+
}>;
|
|
1035
1702
|
component: Component;
|
|
1036
1703
|
rejection: {
|
|
1037
1704
|
type: "NotFound";
|
|
@@ -1047,29 +1714,57 @@ name?: string | undefined;
|
|
|
1047
1714
|
*/
|
|
1048
1715
|
export declare type Routes = Readonly<Route[]>;
|
|
1049
1716
|
|
|
1717
|
+
/**
|
|
1718
|
+
* Represents an immutable array of Route instances. Return value of `createRoutes`, expected param for `createRouter`.
|
|
1719
|
+
*/
|
|
1720
|
+
declare type Routes_2 = Readonly<Route_2[]>
|
|
1721
|
+
|
|
1050
1722
|
declare type RoutesKey<TRoutes extends Routes> = string & keyof RoutesMap<TRoutes>;
|
|
1051
1723
|
|
|
1724
|
+
declare type RoutesKey_2<TRoutes extends Routes_2> = string & keyof RoutesMap_2<TRoutes>
|
|
1725
|
+
|
|
1052
1726
|
declare type RoutesMap<TRoutes extends Routes = []> = {
|
|
1053
1727
|
[K in TRoutes[number] as NamedNotDisabled<K> extends {
|
|
1054
1728
|
key: string;
|
|
1055
1729
|
} ? NamedNotDisabled<K>['key'] : never]: NamedNotDisabled<K>;
|
|
1056
1730
|
};
|
|
1057
1731
|
|
|
1732
|
+
declare type RoutesMap_2<TRoutes extends Routes_2 = []> = {
|
|
1733
|
+
[K in TRoutes[number] as NamedNotDisabled_2<K> extends { key: string } ? NamedNotDisabled_2<K>['key']: never]: NamedNotDisabled_2<K>
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1058
1736
|
declare type RouteUpdate<TRoute extends ResolvedRoute = ResolvedRoute> = {
|
|
1059
1737
|
<TKey extends keyof TRoute['params']>(key: TKey, value: TRoute['params'][TKey], options?: RouterPushOptions): Promise<void>;
|
|
1060
1738
|
(params: Partial<TRoute['params']>, options?: RouterPushOptions): Promise<void>;
|
|
1061
1739
|
};
|
|
1062
1740
|
|
|
1741
|
+
declare type RouteUpdate_2<TRoute extends ResolvedRoute_2 = ResolvedRoute_2> = {
|
|
1742
|
+
<TKey extends keyof TRoute['params']>(key: TKey, value: TRoute['params'][TKey], options?: RouterPushOptions_2): Promise<void>,
|
|
1743
|
+
(params: Partial<TRoute['params']>, options?: RouterPushOptions_2): Promise<void>,
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1063
1746
|
declare type StringHasValue<T extends string | undefined> = T extends undefined ? false : '' extends T ? false : true;
|
|
1064
1747
|
|
|
1065
1748
|
declare type ToCallback = (resolve: RegisteredRouter['resolve']) => string;
|
|
1066
1749
|
|
|
1067
1750
|
declare type ToPath<T extends string | Path> = T extends string ? Path<T, {}> : T;
|
|
1068
1751
|
|
|
1752
|
+
declare type ToPath_2<T extends string | Path_2> = T extends string ? Path_2<T, {}> : T
|
|
1753
|
+
|
|
1069
1754
|
declare type ToQuery<T extends string | Query | undefined> = T extends string ? Query<T, {}> : T extends undefined ? Query<'', {}> : unknown extends T ? Query<'', {}> : T;
|
|
1070
1755
|
|
|
1756
|
+
declare type ToQuery_2<T extends string | Query_2 | undefined> = T extends string
|
|
1757
|
+
? Query_2<T, {}>
|
|
1758
|
+
: T extends undefined
|
|
1759
|
+
? Query_2<'', {}>
|
|
1760
|
+
: unknown extends T
|
|
1761
|
+
? Query_2<'', {}>
|
|
1762
|
+
: T
|
|
1763
|
+
|
|
1071
1764
|
declare type Url = `http://${string}` | `https://${string}` | `/${string}` | '/';
|
|
1072
1765
|
|
|
1766
|
+
declare type Url_2 = `http://${string}` | `https://${string}` | `/${string}` | '/'
|
|
1767
|
+
|
|
1073
1768
|
export declare type UseLink = {
|
|
1074
1769
|
/**
|
|
1075
1770
|
* ResolvedRoute if matched. Same value as `router.find`
|
|
@@ -1108,11 +1803,11 @@ export declare type UseLink = {
|
|
|
1108
1803
|
* @returns {UseLink} Reactive context values for as well as navigation methods.
|
|
1109
1804
|
*
|
|
1110
1805
|
*/
|
|
1111
|
-
export declare function useLink<TRouteKey extends
|
|
1806
|
+
export declare function useLink<TRouteKey extends RegisteredRoutesKey>(routeKey: MaybeRefOrGetter<TRouteKey>, ...args: UseLinkArgs<TRouteKey>): UseLink;
|
|
1112
1807
|
|
|
1113
1808
|
export declare function useLink(url: MaybeRefOrGetter<Url>): UseLink;
|
|
1114
1809
|
|
|
1115
|
-
declare type UseLinkArgs<TSource extends
|
|
1810
|
+
declare type UseLinkArgs<TSource extends RegisteredRoutesKey, TParams = RouteParamsByKey<RegisteredRoutes, TSource>> = AllPropertiesAreOptional<TParams> extends true ? [params?: MaybeRefOrGetter<TParams>, options?: MaybeRefOrGetter<RouterResolveOptions>] : [params: MaybeRefOrGetter<TParams>, options?: MaybeRefOrGetter<RouterResolveOptions>];
|
|
1116
1811
|
|
|
1117
1812
|
/**
|
|
1118
1813
|
* A composition to access the router's rejection state.
|
|
@@ -1175,6 +1870,13 @@ declare type WithComponent = {
|
|
|
1175
1870
|
component: Component;
|
|
1176
1871
|
};
|
|
1177
1872
|
|
|
1873
|
+
declare type WithComponent_2 = {
|
|
1874
|
+
/**
|
|
1875
|
+
* A Vue component, which can be either synchronous or asynchronous components.
|
|
1876
|
+
*/
|
|
1877
|
+
component: Component,
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1178
1880
|
declare type WithComponents = {
|
|
1179
1881
|
/**
|
|
1180
1882
|
* Multiple components for named views, which can be either synchronous or asynchronous components.
|
|
@@ -1182,6 +1884,13 @@ declare type WithComponents = {
|
|
|
1182
1884
|
components: Record<string, Component>;
|
|
1183
1885
|
};
|
|
1184
1886
|
|
|
1887
|
+
declare type WithComponents_2 = {
|
|
1888
|
+
/**
|
|
1889
|
+
* Multiple components for named views, which can be either synchronous or asynchronous components.
|
|
1890
|
+
*/
|
|
1891
|
+
components: Record<string, Component>,
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1185
1894
|
export declare function withDefault<TParam extends Param>(param: TParam, defaultValue: ExtractParamType<TParam>): ParamWithDefault<TParam>;
|
|
1186
1895
|
|
|
1187
1896
|
/**
|
|
@@ -1196,14 +1905,32 @@ declare type WithHooks = {
|
|
|
1196
1905
|
onAfterRouteLeave?: MaybeArray<AfterRouteHook>;
|
|
1197
1906
|
};
|
|
1198
1907
|
|
|
1908
|
+
/**
|
|
1909
|
+
* Defines route hooks that can be applied before entering, updating, or leaving a route, as well as after these events.
|
|
1910
|
+
*/
|
|
1911
|
+
declare type WithHooks_2 = {
|
|
1912
|
+
onBeforeRouteEnter?: MaybeArray_2<BeforeRouteHook_2>,
|
|
1913
|
+
onBeforeRouteUpdate?: MaybeArray_2<BeforeRouteHook_2>,
|
|
1914
|
+
onBeforeRouteLeave?: MaybeArray_2<BeforeRouteHook_2>,
|
|
1915
|
+
onAfterRouteEnter?: MaybeArray_2<AfterRouteHook_2>,
|
|
1916
|
+
onAfterRouteUpdate?: MaybeArray_2<AfterRouteHook_2>,
|
|
1917
|
+
onAfterRouteLeave?: MaybeArray_2<AfterRouteHook_2>,
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1199
1920
|
declare type WithOptionalProperties<T> = {
|
|
1200
1921
|
[P in keyof T]-?: undefined extends T[P] ? P : never;
|
|
1201
1922
|
}[keyof T];
|
|
1202
1923
|
|
|
1924
|
+
declare type WithOptionalProperties_2<T> = {
|
|
1925
|
+
[P in keyof T]-?: undefined extends T[P] ? P : never
|
|
1926
|
+
}[keyof T]
|
|
1927
|
+
|
|
1203
1928
|
declare type Writable<T> = {
|
|
1204
1929
|
-readonly [P in keyof T]: T[P];
|
|
1205
1930
|
};
|
|
1206
1931
|
|
|
1932
|
+
declare type Writable_2<T> = { -readonly [P in keyof T]: T[P] }
|
|
1933
|
+
|
|
1207
1934
|
export { }
|
|
1208
1935
|
|
|
1209
1936
|
|