@esportsplus/routing 0.1.23 → 0.1.24
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.js +3 -8
- package/package.json +5 -5
- package/src/browser.ts +4 -10
package/build/browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { computed, reactive, root } from '@esportsplus/reactivity';
|
|
2
2
|
import { next } from '@esportsplus/pipeline';
|
|
3
3
|
import factory from './router/index.js';
|
|
4
4
|
let cache = [];
|
|
@@ -53,13 +53,12 @@ function middleware(request, router) {
|
|
|
53
53
|
host.match = (fallback) => {
|
|
54
54
|
let state = reactive({
|
|
55
55
|
parameters: undefined,
|
|
56
|
-
root: undefined,
|
|
57
56
|
route: undefined
|
|
58
57
|
});
|
|
59
58
|
if (fallback === undefined) {
|
|
60
59
|
throw new Error('Routing: fallback route does not exist');
|
|
61
60
|
}
|
|
62
|
-
|
|
61
|
+
computed(() => {
|
|
63
62
|
let { parameters, route } = match(request, router);
|
|
64
63
|
state.parameters = parameters;
|
|
65
64
|
state.route = route || fallback;
|
|
@@ -68,15 +67,11 @@ function middleware(request, router) {
|
|
|
68
67
|
if (state.route === undefined) {
|
|
69
68
|
throw new Error('Routing: route is undefined');
|
|
70
69
|
}
|
|
71
|
-
|
|
72
|
-
state.root.dispose();
|
|
73
|
-
}
|
|
74
|
-
return root((root) => {
|
|
70
|
+
return root(() => {
|
|
75
71
|
request.data = {
|
|
76
72
|
parameters: state.parameters,
|
|
77
73
|
route: state.route
|
|
78
74
|
};
|
|
79
|
-
state.root = root;
|
|
80
75
|
return next(request);
|
|
81
76
|
});
|
|
82
77
|
};
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "ICJR",
|
|
3
3
|
"dependencies": {
|
|
4
|
-
"@esportsplus/pipeline": "^1.1.
|
|
5
|
-
"@esportsplus/reactivity": "^0.
|
|
6
|
-
"@esportsplus/utilities": "^0.
|
|
4
|
+
"@esportsplus/pipeline": "^1.1.5",
|
|
5
|
+
"@esportsplus/reactivity": "^0.6.1",
|
|
6
|
+
"@esportsplus/utilities": "^0.21.0"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@esportsplus/typescript": "^0.9.
|
|
9
|
+
"@esportsplus/typescript": "^0.9.2"
|
|
10
10
|
},
|
|
11
11
|
"main": "./build/index.js",
|
|
12
12
|
"name": "@esportsplus/routing",
|
|
13
13
|
"private": false,
|
|
14
14
|
"type": "module",
|
|
15
15
|
"types": "./build/index.d.ts",
|
|
16
|
-
"version": "0.1.
|
|
16
|
+
"version": "0.1.24",
|
|
17
17
|
"scripts": {
|
|
18
18
|
"build": "tsc && tsc-alias",
|
|
19
19
|
"-": "-"
|
package/src/browser.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { computed, reactive, root } from '@esportsplus/reactivity';
|
|
2
2
|
import { Middleware, Next, Request, Route, Router } from './types';
|
|
3
3
|
import { next } from '@esportsplus/pipeline';
|
|
4
4
|
import factory from './router';
|
|
@@ -69,9 +69,8 @@ function middleware<T>(request: Request<T>, router: Router<T>) {
|
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
host.match = (fallback: Route<T>) => {
|
|
72
|
-
let state = reactive<ReturnType<typeof router.match
|
|
72
|
+
let state = reactive<ReturnType<typeof router.match>>({
|
|
73
73
|
parameters: undefined,
|
|
74
|
-
root: undefined,
|
|
75
74
|
route: undefined
|
|
76
75
|
});
|
|
77
76
|
|
|
@@ -79,7 +78,7 @@ function middleware<T>(request: Request<T>, router: Router<T>) {
|
|
|
79
78
|
throw new Error('Routing: fallback route does not exist');
|
|
80
79
|
}
|
|
81
80
|
|
|
82
|
-
|
|
81
|
+
computed(() => {
|
|
83
82
|
let { parameters, route } = match(request, router);
|
|
84
83
|
|
|
85
84
|
state.parameters = parameters;
|
|
@@ -91,16 +90,11 @@ function middleware<T>(request: Request<T>, router: Router<T>) {
|
|
|
91
90
|
throw new Error('Routing: route is undefined');
|
|
92
91
|
}
|
|
93
92
|
|
|
94
|
-
|
|
95
|
-
state.root.dispose();
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return root((root) => {
|
|
93
|
+
return root(() => {
|
|
99
94
|
request.data = {
|
|
100
95
|
parameters: state.parameters,
|
|
101
96
|
route: state.route
|
|
102
97
|
};
|
|
103
|
-
state.root = root;
|
|
104
98
|
|
|
105
99
|
return next(request);
|
|
106
100
|
});
|