@kevisual/router 0.0.17 → 0.0.18
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/router-browser.d.ts +5 -3
- package/dist/router-define.d.ts +3 -2
- package/dist/router.d.ts +5 -3
- package/package.json +1 -1
- package/src/route.ts +2 -2
- package/src/router-define.ts +3 -3
- package/src/test/define.ts +4 -0
package/dist/router-browser.d.ts
CHANGED
|
@@ -109,7 +109,8 @@ type RouteContext<T = {
|
|
|
109
109
|
/** 是否需要序列化 */
|
|
110
110
|
needSerialize?: boolean;
|
|
111
111
|
} & T;
|
|
112
|
-
type
|
|
112
|
+
type SimpleObject$1 = Record<string, any>;
|
|
113
|
+
type Run<T extends SimpleObject$1 = {}> = (ctx: RouteContext<T>) => Promise<typeof ctx | null | void>;
|
|
113
114
|
type NextRoute = Pick<Route, 'id' | 'path' | 'key'>;
|
|
114
115
|
type RouteMiddleware = {
|
|
115
116
|
path: string;
|
|
@@ -440,6 +441,7 @@ declare const parseSearchValue: (value?: string, opts?: {
|
|
|
440
441
|
type RouteObject = {
|
|
441
442
|
[key: string]: RouteOpts$1;
|
|
442
443
|
};
|
|
444
|
+
type SimpleObject = Record<string, any>;
|
|
443
445
|
declare function define<T extends Record<string, RouteOpts$1>>(value: T): {
|
|
444
446
|
[K in keyof T]: T[K] & RouteOpts$1;
|
|
445
447
|
};
|
|
@@ -461,8 +463,8 @@ declare class Chain {
|
|
|
461
463
|
setMiddleware(middleware: RouteMiddleware$1[]): this;
|
|
462
464
|
setKey(key: string): this;
|
|
463
465
|
setId(key: string): this;
|
|
464
|
-
setRun(run: Run$1): this;
|
|
465
|
-
define(run: Run$1): this;
|
|
466
|
+
setRun<U extends SimpleObject = {}>(run: Run$1<U>): this;
|
|
467
|
+
define<U extends SimpleObject = {}>(run: Run$1<U>): this;
|
|
466
468
|
createRoute(): this;
|
|
467
469
|
}
|
|
468
470
|
declare const util: {
|
package/dist/router-define.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { RouteOpts } from '@kevisual/router';
|
|
|
4
4
|
type RouteObject = {
|
|
5
5
|
[key: string]: RouteOpts;
|
|
6
6
|
};
|
|
7
|
+
type SimpleObject = Record<string, any>;
|
|
7
8
|
declare function define<T extends Record<string, RouteOpts>>(value: T): {
|
|
8
9
|
[K in keyof T]: T[K] & RouteOpts;
|
|
9
10
|
};
|
|
@@ -25,8 +26,8 @@ declare class Chain {
|
|
|
25
26
|
setMiddleware(middleware: RouteMiddleware[]): this;
|
|
26
27
|
setKey(key: string): this;
|
|
27
28
|
setId(key: string): this;
|
|
28
|
-
setRun(run: Run): this;
|
|
29
|
-
define(run: Run): this;
|
|
29
|
+
setRun<U extends SimpleObject = {}>(run: Run<U>): this;
|
|
30
|
+
define<U extends SimpleObject = {}>(run: Run<U>): this;
|
|
30
31
|
createRoute(): this;
|
|
31
32
|
}
|
|
32
33
|
declare const util: {
|
package/dist/router.d.ts
CHANGED
|
@@ -112,7 +112,8 @@ type RouteContext<T = {
|
|
|
112
112
|
/** 是否需要序列化 */
|
|
113
113
|
needSerialize?: boolean;
|
|
114
114
|
} & T;
|
|
115
|
-
type
|
|
115
|
+
type SimpleObject$1 = Record<string, any>;
|
|
116
|
+
type Run<T extends SimpleObject$1 = {}> = (ctx: RouteContext<T>) => Promise<typeof ctx | null | void>;
|
|
116
117
|
type NextRoute = Pick<Route, 'id' | 'path' | 'key'>;
|
|
117
118
|
type RouteMiddleware = {
|
|
118
119
|
path: string;
|
|
@@ -581,6 +582,7 @@ declare class WsServer extends WsServerBase {
|
|
|
581
582
|
type RouteObject = {
|
|
582
583
|
[key: string]: RouteOpts$1;
|
|
583
584
|
};
|
|
585
|
+
type SimpleObject = Record<string, any>;
|
|
584
586
|
declare function define<T extends Record<string, RouteOpts$1>>(value: T): {
|
|
585
587
|
[K in keyof T]: T[K] & RouteOpts$1;
|
|
586
588
|
};
|
|
@@ -602,8 +604,8 @@ declare class Chain {
|
|
|
602
604
|
setMiddleware(middleware: RouteMiddleware$1[]): this;
|
|
603
605
|
setKey(key: string): this;
|
|
604
606
|
setId(key: string): this;
|
|
605
|
-
setRun(run: Run$1): this;
|
|
606
|
-
define(run: Run$1): this;
|
|
607
|
+
setRun<U extends SimpleObject = {}>(run: Run$1<U>): this;
|
|
608
|
+
define<U extends SimpleObject = {}>(run: Run$1<U>): this;
|
|
607
609
|
createRoute(): this;
|
|
608
610
|
}
|
|
609
611
|
declare const util: {
|
package/package.json
CHANGED
package/src/route.ts
CHANGED
|
@@ -57,8 +57,8 @@ export type RouteContext<T = { code?: number }, S = any> = {
|
|
|
57
57
|
/** 是否需要序列化 */
|
|
58
58
|
needSerialize?: boolean;
|
|
59
59
|
} & T;
|
|
60
|
-
|
|
61
|
-
export type Run<T =
|
|
60
|
+
export type SimpleObject = Record<string, any>;
|
|
61
|
+
export type Run<T extends SimpleObject = {}> = (ctx: RouteContext<T>) => Promise<typeof ctx | null | void>;
|
|
62
62
|
|
|
63
63
|
export type NextRoute = Pick<Route, 'id' | 'path' | 'key'>;
|
|
64
64
|
export type RouteMiddleware =
|
package/src/router-define.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type { RouteOpts };
|
|
|
7
7
|
export type RouteObject = {
|
|
8
8
|
[key: string]: RouteOpts;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
type SimpleObject = Record<string, any>;
|
|
11
11
|
export function define<T extends Record<string, RouteOpts>>(
|
|
12
12
|
value: T,
|
|
13
13
|
): {
|
|
@@ -57,11 +57,11 @@ class Chain {
|
|
|
57
57
|
this.object.id = key;
|
|
58
58
|
return this;
|
|
59
59
|
}
|
|
60
|
-
setRun(run: Run) {
|
|
60
|
+
setRun<U extends SimpleObject = {}>(run: Run<U>) {
|
|
61
61
|
this.object.run = run;
|
|
62
62
|
return this;
|
|
63
63
|
}
|
|
64
|
-
define(run: Run) {
|
|
64
|
+
define<U extends SimpleObject = {}>(run: Run<U>) {
|
|
65
65
|
this.object.run = run;
|
|
66
66
|
return this;
|
|
67
67
|
}
|