@esportsplus/routing 0.0.34 → 0.0.36
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 +3 -3
- 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 -2
- package/src/router/route.ts +2 -2
- package/src/types.ts +3 -4
package/build/browser.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Scheduler } from '@esportsplus/reactivity';
|
|
2
|
-
import { Middleware, Next,
|
|
2
|
+
import { Middleware, Next, Request, Route, Router } from './types';
|
|
3
3
|
declare function back(): void;
|
|
4
4
|
declare function forward(): void;
|
|
5
5
|
declare const _default: <T>(instance?: Router<T> | undefined) => {
|
|
6
6
|
back: typeof back;
|
|
7
7
|
forward: typeof forward;
|
|
8
8
|
middleware: {
|
|
9
|
-
(...middleware: Middleware<T>[]): () =>
|
|
10
|
-
dispatch(request: Request<T>):
|
|
9
|
+
(...middleware: Middleware<T>[]): () => T;
|
|
10
|
+
dispatch(request: Request<T>): T;
|
|
11
11
|
match(fallback: Route<T>, scheduler: Scheduler, subdomain?: string | undefined): (request: Request<T>, next: Next<T>) => import("@esportsplus/template/build/types").Template;
|
|
12
12
|
};
|
|
13
13
|
redirect: (path: string, values?: unknown[]) => void;
|
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.9",
|
|
6
|
+
"@esportsplus/template": "^0.1.7"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@esportsplus/typescript": "^0.0.
|
|
9
|
+
"@esportsplus/typescript": "^0.0.11"
|
|
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.36"
|
|
22
22
|
}
|
package/src/browser.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { effect, reactive, root, Scheduler } from '@esportsplus/reactivity';
|
|
2
2
|
import { html } from '@esportsplus/template';
|
|
3
|
-
import { Middleware, Next,
|
|
3
|
+
import { Middleware, Next, Request, Route, Router } from './types';
|
|
4
4
|
import pipeline from '@esportsplus/pipeline';
|
|
5
5
|
import factory from './router';
|
|
6
6
|
|
|
@@ -55,7 +55,7 @@ function middleware<T>(request: Request<T>, router: Router<T>) {
|
|
|
55
55
|
return () => instance(request);
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
host.dispatch = (request: Request<T>)
|
|
58
|
+
host.dispatch = (request: Request<T>) => {
|
|
59
59
|
let { route } = request.data;
|
|
60
60
|
|
|
61
61
|
if (route === undefined) {
|
|
@@ -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;
|
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 };
|