@kitbag/router 0.22.6 → 0.23.0
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/compositions/useQueryValue.d.ts +5 -5
- package/dist/compositions/useQueryValue.spec-d.d.ts +1 -0
- package/dist/kitbag-router.js +245 -249
- package/dist/kitbag-router.umd.cjs +2 -2
- package/dist/main.d.ts +1 -0
- package/dist/services/literal.d.ts +2 -0
- package/dist/types/createRouteOptions.d.ts +13 -5
- package/dist/types/params.d.ts +1 -1
- package/dist/utilities/testHelpers.d.ts +0 -42
- package/package.json +6 -6
package/dist/main.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export { createRouterPlugin } from './services/createRouterPlugin';
|
|
|
37
37
|
export { unionOf } from './services/unionOf';
|
|
38
38
|
export { arrayOf } from './services/arrayOf';
|
|
39
39
|
export { tupleOf } from './services/tupleOf';
|
|
40
|
+
export { literal } from './services/literal';
|
|
40
41
|
export { createParam } from './services/createParam';
|
|
41
42
|
export { createRouter } from './services/createRouter';
|
|
42
43
|
export { createUrl } from './services/createUrl';
|
|
@@ -8,7 +8,7 @@ import { Route } from './route';
|
|
|
8
8
|
import { ResolvedRoute } from './resolved';
|
|
9
9
|
import { ComponentProps } from '../services/component';
|
|
10
10
|
import { PropsCallbackContext } from './props';
|
|
11
|
-
import { MaybePromise } from './utilities';
|
|
11
|
+
import { Identity, MaybePromise } from './utilities';
|
|
12
12
|
import { ToMeta } from './meta';
|
|
13
13
|
import { ToState } from './state';
|
|
14
14
|
import { ToName } from './name';
|
|
@@ -33,6 +33,14 @@ export declare function isWithParent<T extends Record<string, unknown>>(options:
|
|
|
33
33
|
export type WithoutParent = {
|
|
34
34
|
parent?: never;
|
|
35
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* This type is used to strip the component and components properties from the options object
|
|
38
|
+
* when creating a Route to simplify and minimize the output type.
|
|
39
|
+
*/
|
|
40
|
+
type WithoutComponents = {
|
|
41
|
+
component: never;
|
|
42
|
+
components: never;
|
|
43
|
+
};
|
|
36
44
|
export declare function isWithComponent<T extends Record<string, unknown>>(options: T): options is T & {
|
|
37
45
|
component: Component;
|
|
38
46
|
};
|
|
@@ -102,7 +110,7 @@ type RoutePropsRecord<TOptions extends CreateRouteOptions = CreateRouteOptions,
|
|
|
102
110
|
[K in keyof TComponents as ComponentPropsAreOptional<TComponents[K]> extends false ? K : never]: PropsGetter<TOptions, TComponents[K]>;
|
|
103
111
|
};
|
|
104
112
|
export type CreateRouteProps<TOptions extends CreateRouteOptions = CreateRouteOptions> = TOptions['component'] extends Component ? PropsGetter<TOptions, TOptions['component']> : TOptions['components'] extends Record<string, Component> ? RoutePropsRecord<TOptions, TOptions['components']> : RouterViewPropsGetter<TOptions>;
|
|
105
|
-
type ToMatch<TOptions extends CreateRouteOptions, TProps
|
|
113
|
+
type ToMatch<TOptions extends CreateRouteOptions, TProps> = Omit<TOptions, 'props' | 'meta' | 'name'> & {
|
|
106
114
|
id: string;
|
|
107
115
|
name: ToName<TOptions['name']>;
|
|
108
116
|
props: TProps;
|
|
@@ -113,12 +121,12 @@ type ToMatch<TOptions extends CreateRouteOptions, TProps extends CreateRouteProp
|
|
|
113
121
|
};
|
|
114
122
|
type ToMatches<TOptions extends CreateRouteOptions, TProps extends CreateRouteProps<TOptions> | undefined> = TOptions extends {
|
|
115
123
|
parent: infer TParent extends Route;
|
|
116
|
-
} ? [...TParent['matches'], ToMatch<TOptions, TProps>] : [ToMatch<TOptions
|
|
124
|
+
} ? [...TParent['matches'], ToMatch<TOptions, TProps>] : [ToMatch<Identity<TOptions & WithoutComponents>, TProps>];
|
|
117
125
|
export type ToRoute<TOptions extends CreateRouteOptions, TProps extends CreateRouteProps<TOptions> | undefined = undefined> = CreateRouteOptions extends TOptions ? Route : TOptions extends {
|
|
118
126
|
parent: infer TParent extends Route;
|
|
119
|
-
} ? Route<ToName<TOptions['name']>, CombineUrl<TParent, ToUrl<TOptions>>, CombineMeta<ToMeta<TParent['meta']>, ToMeta<TOptions['meta']>>, CombineState<ToState<TParent['state']>, ToState<TOptions['state']>>, ToMatches<TOptions, CreateRouteProps<TOptions> extends TProps ? undefined : TProps>, [
|
|
127
|
+
} ? Route<ToName<TOptions['name']>, CombineUrl<TParent, ToUrl<TOptions & WithoutComponents>>, CombineMeta<ToMeta<TParent['meta']>, ToMeta<TOptions['meta']>>, CombineState<ToState<TParent['state']>, ToState<TOptions['state']>>, ToMatches<TOptions, CreateRouteProps<TOptions> extends TProps ? undefined : TProps>, [
|
|
120
128
|
...ToRouteContext<TParent['context']>,
|
|
121
129
|
...ToRouteContext<TOptions['context']>
|
|
122
|
-
]> : Route<ToName<TOptions['name']>, ToUrl<TOptions
|
|
130
|
+
]> : Route<ToName<TOptions['name']>, ToUrl<Identity<TOptions & WithoutComponents>>, ToMeta<TOptions['meta']>, ToState<TOptions['state']>, ToMatches<TOptions, CreateRouteProps<TOptions> extends TProps ? undefined : TProps>, ToRouteContext<TOptions['context']>>;
|
|
123
131
|
export declare function combineRoutes(parent: Route, child: Route): Route;
|
|
124
132
|
export {};
|
package/dist/types/params.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export type ExtractParamName<TParam extends PropertyKey> = TParam extends string
|
|
|
33
33
|
* @template TParam - The parameter type.
|
|
34
34
|
* @returns The extracted type, or 'string' as a fallback.
|
|
35
35
|
*/
|
|
36
|
-
export type ExtractParamType<TParam extends Param> = Param extends TParam ? unknown : TParam extends ParamGetSet<infer Type> ? Type : TParam extends ParamGetter ? ReturnType<TParam> : TParam extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TParam> : TParam extends LiteralParam ? TParam : string;
|
|
36
|
+
export type ExtractParamType<TParam extends Param> = Param extends TParam ? unknown : TParam extends ParamGetSet<infer Type> ? Type : TParam extends DateConstructor ? Date : TParam extends JSON ? unknown : TParam extends ParamGetter ? ReturnType<TParam> : TParam extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TParam> : TParam extends LiteralParam ? TParam : string;
|
|
37
37
|
export type ParamIsOptional<TParam extends string> = TParam extends `?${string}` ? true : false;
|
|
38
38
|
export type ParamIsGreedy<TParam extends string> = TParam extends `${string}*` ? true : false;
|
|
39
39
|
export type ParamIsOptionalOrHasDefault<TParamName extends string, TParam extends Param | undefined> = ParamIsOptional<TParamName> extends true ? true : TParam extends Required<ParamGetSet> ? true : false;
|
|
@@ -2261,17 +2261,11 @@ export declare const routes: readonly [import('../main').ToUrl<{
|
|
|
2261
2261
|
}], []>>, import('../main').ToUrl<{
|
|
2262
2262
|
readonly name: "parentB";
|
|
2263
2263
|
readonly path: "/parentB";
|
|
2264
|
-
readonly component: {
|
|
2265
|
-
template: string;
|
|
2266
|
-
};
|
|
2267
2264
|
}> & {
|
|
2268
2265
|
id: string;
|
|
2269
2266
|
matched: Omit<{
|
|
2270
2267
|
readonly name: "parentB";
|
|
2271
2268
|
readonly path: "/parentB";
|
|
2272
|
-
readonly component: {
|
|
2273
|
-
template: string;
|
|
2274
|
-
};
|
|
2275
2269
|
}, "meta" | "name" | "props"> & {
|
|
2276
2270
|
id: string;
|
|
2277
2271
|
name: "parentB";
|
|
@@ -2281,9 +2275,6 @@ export declare const routes: readonly [import('../main').ToUrl<{
|
|
|
2281
2275
|
matches: [Omit<{
|
|
2282
2276
|
readonly name: "parentB";
|
|
2283
2277
|
readonly path: "/parentB";
|
|
2284
|
-
readonly component: {
|
|
2285
|
-
template: string;
|
|
2286
|
-
};
|
|
2287
2278
|
}, "meta" | "name" | "props"> & {
|
|
2288
2279
|
id: string;
|
|
2289
2280
|
name: "parentB";
|
|
@@ -2300,15 +2291,9 @@ export declare const routes: readonly [import('../main').ToUrl<{
|
|
|
2300
2291
|
} & import('../main').InternalRouteHooks<import('../main').Route<"parentB", import('../main').ToUrl<{
|
|
2301
2292
|
readonly name: "parentB";
|
|
2302
2293
|
readonly path: "/parentB";
|
|
2303
|
-
readonly component: {
|
|
2304
|
-
template: string;
|
|
2305
|
-
};
|
|
2306
2294
|
}>, Readonly<{}>, {}, [Omit<{
|
|
2307
2295
|
readonly name: "parentB";
|
|
2308
2296
|
readonly path: "/parentB";
|
|
2309
|
-
readonly component: {
|
|
2310
|
-
template: string;
|
|
2311
|
-
};
|
|
2312
2297
|
}, "meta" | "name" | "props"> & {
|
|
2313
2298
|
id: string;
|
|
2314
2299
|
name: "parentB";
|
|
@@ -2317,15 +2302,9 @@ export declare const routes: readonly [import('../main').ToUrl<{
|
|
|
2317
2302
|
}], []>, []> & import('../types/redirects').RouteRedirects<import('../main').Route<"parentB", import('../main').ToUrl<{
|
|
2318
2303
|
readonly name: "parentB";
|
|
2319
2304
|
readonly path: "/parentB";
|
|
2320
|
-
readonly component: {
|
|
2321
|
-
template: string;
|
|
2322
|
-
};
|
|
2323
2305
|
}>, Readonly<{}>, {}, [Omit<{
|
|
2324
2306
|
readonly name: "parentB";
|
|
2325
2307
|
readonly path: "/parentB";
|
|
2326
|
-
readonly component: {
|
|
2327
|
-
template: string;
|
|
2328
|
-
};
|
|
2329
2308
|
}, "meta" | "name" | "props"> & {
|
|
2330
2309
|
id: string;
|
|
2331
2310
|
name: "parentB";
|
|
@@ -2334,17 +2313,11 @@ export declare const routes: readonly [import('../main').ToUrl<{
|
|
|
2334
2313
|
}], []>>, import('../main').ToUrl<{
|
|
2335
2314
|
readonly name: "parentC";
|
|
2336
2315
|
readonly path: "/";
|
|
2337
|
-
readonly component: {
|
|
2338
|
-
template: string;
|
|
2339
|
-
};
|
|
2340
2316
|
}> & {
|
|
2341
2317
|
id: string;
|
|
2342
2318
|
matched: Omit<{
|
|
2343
2319
|
readonly name: "parentC";
|
|
2344
2320
|
readonly path: "/";
|
|
2345
|
-
readonly component: {
|
|
2346
|
-
template: string;
|
|
2347
|
-
};
|
|
2348
2321
|
}, "meta" | "name" | "props"> & {
|
|
2349
2322
|
id: string;
|
|
2350
2323
|
name: "parentC";
|
|
@@ -2354,9 +2327,6 @@ export declare const routes: readonly [import('../main').ToUrl<{
|
|
|
2354
2327
|
matches: [Omit<{
|
|
2355
2328
|
readonly name: "parentC";
|
|
2356
2329
|
readonly path: "/";
|
|
2357
|
-
readonly component: {
|
|
2358
|
-
template: string;
|
|
2359
|
-
};
|
|
2360
2330
|
}, "meta" | "name" | "props"> & {
|
|
2361
2331
|
id: string;
|
|
2362
2332
|
name: "parentC";
|
|
@@ -2373,15 +2343,9 @@ export declare const routes: readonly [import('../main').ToUrl<{
|
|
|
2373
2343
|
} & import('../main').InternalRouteHooks<import('../main').Route<"parentC", import('../main').ToUrl<{
|
|
2374
2344
|
readonly name: "parentC";
|
|
2375
2345
|
readonly path: "/";
|
|
2376
|
-
readonly component: {
|
|
2377
|
-
template: string;
|
|
2378
|
-
};
|
|
2379
2346
|
}>, Readonly<{}>, {}, [Omit<{
|
|
2380
2347
|
readonly name: "parentC";
|
|
2381
2348
|
readonly path: "/";
|
|
2382
|
-
readonly component: {
|
|
2383
|
-
template: string;
|
|
2384
|
-
};
|
|
2385
2349
|
}, "meta" | "name" | "props"> & {
|
|
2386
2350
|
id: string;
|
|
2387
2351
|
name: "parentC";
|
|
@@ -2390,15 +2354,9 @@ export declare const routes: readonly [import('../main').ToUrl<{
|
|
|
2390
2354
|
}], []>, []> & import('../types/redirects').RouteRedirects<import('../main').Route<"parentC", import('../main').ToUrl<{
|
|
2391
2355
|
readonly name: "parentC";
|
|
2392
2356
|
readonly path: "/";
|
|
2393
|
-
readonly component: {
|
|
2394
|
-
template: string;
|
|
2395
|
-
};
|
|
2396
2357
|
}>, Readonly<{}>, {}, [Omit<{
|
|
2397
2358
|
readonly name: "parentC";
|
|
2398
2359
|
readonly path: "/";
|
|
2399
|
-
readonly component: {
|
|
2400
|
-
template: string;
|
|
2401
|
-
};
|
|
2402
2360
|
}, "meta" | "name" | "props"> & {
|
|
2403
2361
|
id: string;
|
|
2404
2362
|
name: "parentC";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitbag/router",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.23.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/kitbagjs/router/issues"
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"@kitbag/eslint-config": "1.0.2",
|
|
46
46
|
"@vitejs/plugin-vue": "^6.0.4",
|
|
47
47
|
"@vue/test-utils": "^2.4.6",
|
|
48
|
-
"eslint": "^10.0.
|
|
49
|
-
"globals": "^17.
|
|
50
|
-
"happy-dom": "^20.
|
|
48
|
+
"eslint": "^10.0.3",
|
|
49
|
+
"globals": "^17.4.0",
|
|
50
|
+
"happy-dom": "^20.7.0",
|
|
51
51
|
"typedoc": "^0.28.17",
|
|
52
52
|
"typedoc-plugin-markdown": "^4.10.0",
|
|
53
53
|
"typedoc-vitepress-theme": "^1.1.2",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"vite-plugin-dts": "^4.5.4",
|
|
58
58
|
"vitepress": "^1.6.4",
|
|
59
59
|
"vitest": "^4.0.18",
|
|
60
|
-
"vue-tsc": "^3.2.
|
|
60
|
+
"vue-tsc": "^3.2.5",
|
|
61
61
|
"zod": "4.0.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
@@ -71,6 +71,6 @@
|
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@standard-schema/spec": "^1.0.0",
|
|
74
|
-
"@vue/devtools-api": "^8.0.
|
|
74
|
+
"@vue/devtools-api": "^8.0.7"
|
|
75
75
|
}
|
|
76
76
|
}
|