@esportsplus/routing 0.0.33 → 0.0.35
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/build/browser.d.ts +7 -2
- package/build/browser.js +1 -0
- package/build/router/route.d.ts +2 -2
- package/build/types.d.ts +3 -4
- package/package.json +4 -4
- package/src/browser.ts +3 -0
- package/src/router/route.ts +2 -2
- package/src/types.ts +3 -4
package/build/browser.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Scheduler } from '@esportsplus/reactivity';
|
|
2
|
+
import { Middleware, Next, Request, Route, Router } from './types';
|
|
2
3
|
declare function back(): void;
|
|
3
4
|
declare function forward(): void;
|
|
4
5
|
declare const _default: <T>(instance?: Router<T> | undefined) => {
|
|
5
6
|
back: typeof back;
|
|
6
7
|
forward: typeof forward;
|
|
7
|
-
middleware:
|
|
8
|
+
middleware: {
|
|
9
|
+
(...middleware: Middleware<T>[]): () => T;
|
|
10
|
+
dispatch(request: Request<T>): T;
|
|
11
|
+
match(fallback: Route<T>, scheduler: Scheduler, subdomain?: string | undefined): (request: Request<T>, next: Next<T>) => import("@esportsplus/template/build/types").Template;
|
|
12
|
+
};
|
|
8
13
|
redirect: (path: string, values?: unknown[]) => void;
|
|
9
14
|
router: Router<T>;
|
|
10
15
|
uri: (path: string, values?: unknown[]) => string;
|
package/build/browser.js
CHANGED
package/build/router/route.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Middleware, Next,
|
|
1
|
+
import { Middleware, Next, Request } from '../types';
|
|
2
2
|
declare class Route<T> {
|
|
3
3
|
middleware: Middleware<T>[] | null;
|
|
4
4
|
name: string | null;
|
|
@@ -6,6 +6,6 @@ declare class Route<T> {
|
|
|
6
6
|
responder: Next<T>;
|
|
7
7
|
subdomain: string | null;
|
|
8
8
|
constructor(responder: Next<T>);
|
|
9
|
-
dispatch(request: Request<T>):
|
|
9
|
+
dispatch(request: Request<T>): T;
|
|
10
10
|
}
|
|
11
11
|
export { Route };
|
package/build/types.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { NeverAsync } from '@esportsplus/typescript';
|
|
2
|
-
import { Next as N, Stage } from '@esportsplus/pipeline';
|
|
3
2
|
import { Route, Router } from './router';
|
|
4
|
-
type Middleware<T> =
|
|
5
|
-
type Next<T> =
|
|
3
|
+
type Middleware<T> = NeverAsync<(input: Request<T>, next: Next<T>) => T>;
|
|
4
|
+
type Next<T> = NeverAsync<(input: Request<T>) => T>;
|
|
6
5
|
type Options<T> = {
|
|
7
6
|
middleware?: Middleware<T>[];
|
|
8
7
|
name?: string;
|
|
@@ -22,4 +21,4 @@ type Request<T> = {
|
|
|
22
21
|
query: Record<string, unknown>;
|
|
23
22
|
subdomain?: string;
|
|
24
23
|
};
|
|
25
|
-
export { Middleware, Next,
|
|
24
|
+
export { Middleware, Next, Options, Request, Route, Router };
|
package/package.json
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"author": "ICJR",
|
|
3
3
|
"dependencies": {
|
|
4
4
|
"@esportsplus/pipeline": "^0.0.5",
|
|
5
|
-
"@esportsplus/reactivity": "^0.1.
|
|
6
|
-
"@esportsplus/template": "^0.1.
|
|
5
|
+
"@esportsplus/reactivity": "^0.1.8",
|
|
6
|
+
"@esportsplus/template": "^0.1.7"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@esportsplus/typescript": "^0.0.
|
|
9
|
+
"@esportsplus/typescript": "^0.0.9"
|
|
10
10
|
},
|
|
11
11
|
"main": "./build/index.js",
|
|
12
12
|
"name": "@esportsplus/routing",
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
"prepublishOnly": "npm run build"
|
|
19
19
|
},
|
|
20
20
|
"types": "./build/index.d.ts",
|
|
21
|
-
"version": "0.0.
|
|
21
|
+
"version": "0.0.35"
|
|
22
22
|
}
|
package/src/browser.ts
CHANGED
|
@@ -88,6 +88,7 @@ function middleware<T>(request: Request<T>, router: Router<T>) {
|
|
|
88
88
|
throw new Error('Routing: route is undefined');
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
// @ts-ignore
|
|
91
92
|
return root(() => {
|
|
92
93
|
request.data.parameters = state.parameters;
|
|
93
94
|
request.data.route = state.route;
|
|
@@ -97,6 +98,8 @@ function middleware<T>(request: Request<T>, router: Router<T>) {
|
|
|
97
98
|
}}`;
|
|
98
99
|
};
|
|
99
100
|
};
|
|
101
|
+
|
|
102
|
+
return host;
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
function normalize(uri: string) {
|
package/src/router/route.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Middleware, Next,
|
|
1
|
+
import { Middleware, Next, Request } from '~/types';
|
|
2
2
|
import pipeline from '@esportsplus/pipeline';
|
|
3
3
|
|
|
4
4
|
|
|
@@ -15,7 +15,7 @@ class Route<T> {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
dispatch(request: Request<T>)
|
|
18
|
+
dispatch(request: Request<T>) {
|
|
19
19
|
if (this.middleware === null) {
|
|
20
20
|
return this.responder(request);
|
|
21
21
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { NeverAsync } from '@esportsplus/typescript';
|
|
2
|
-
import { Next as N, Stage } from '@esportsplus/pipeline';
|
|
3
2
|
import { Route, Router } from './router';
|
|
4
3
|
|
|
5
4
|
|
|
6
|
-
type Middleware<T> =
|
|
5
|
+
type Middleware<T> = NeverAsync<(input: Request<T>, next: Next<T>) => T>;
|
|
7
6
|
|
|
8
|
-
type Next<T> =
|
|
7
|
+
type Next<T> = NeverAsync<(input: Request<T>) => T>;
|
|
9
8
|
|
|
10
9
|
type Options<T> = {
|
|
11
10
|
middleware?: Middleware<T>[];
|
|
@@ -29,4 +28,4 @@ type Request<T> = {
|
|
|
29
28
|
};
|
|
30
29
|
|
|
31
30
|
|
|
32
|
-
export { Middleware, Next,
|
|
31
|
+
export { Middleware, Next, Options, Request, Route, Router };
|