@esportsplus/routing 0.0.36 → 0.0.37
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 +8 -3
- package/package.json +4 -4
- package/src/browser.ts +12 -6
package/build/browser.js
CHANGED
|
@@ -51,7 +51,8 @@ function middleware(request, router) {
|
|
|
51
51
|
host.match = (fallback, scheduler, subdomain) => {
|
|
52
52
|
let state = reactive({
|
|
53
53
|
parameters: undefined,
|
|
54
|
-
route: undefined
|
|
54
|
+
route: undefined,
|
|
55
|
+
root: undefined
|
|
55
56
|
});
|
|
56
57
|
if (fallback === undefined) {
|
|
57
58
|
throw new Error('Middleware: fallback route does not exist');
|
|
@@ -66,11 +67,15 @@ function middleware(request, router) {
|
|
|
66
67
|
if (state.route === undefined) {
|
|
67
68
|
throw new Error('Routing: route is undefined');
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
+
if (state.root !== undefined) {
|
|
71
|
+
state.root.dispose();
|
|
72
|
+
}
|
|
73
|
+
return root((instance) => {
|
|
70
74
|
request.data.parameters = state.parameters;
|
|
71
75
|
request.data.route = state.route;
|
|
76
|
+
state.root = instance;
|
|
72
77
|
return next(request);
|
|
73
|
-
},
|
|
78
|
+
}, scheduler);
|
|
74
79
|
}}`;
|
|
75
80
|
};
|
|
76
81
|
};
|
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.13",
|
|
6
|
+
"@esportsplus/template": "^0.1.8"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@esportsplus/typescript": "^0.0.
|
|
9
|
+
"@esportsplus/typescript": "^0.0.13"
|
|
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.37"
|
|
22
22
|
}
|
package/src/browser.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { effect, reactive, root, Scheduler } from '@esportsplus/reactivity';
|
|
1
|
+
import { effect, reactive, root, Root, Scheduler } from '@esportsplus/reactivity';
|
|
2
2
|
import { html } from '@esportsplus/template';
|
|
3
3
|
import { Middleware, Next, Request, Route, Router } from './types';
|
|
4
4
|
import pipeline from '@esportsplus/pipeline';
|
|
@@ -66,9 +66,10 @@ function middleware<T>(request: Request<T>, router: Router<T>) {
|
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
host.match = (fallback: Route<T>, scheduler: Scheduler, subdomain?: string) => {
|
|
69
|
-
let state = reactive<ReturnType<typeof router.match
|
|
69
|
+
let state = reactive<ReturnType<typeof router.match> & { root?: Root }>({
|
|
70
70
|
parameters: undefined,
|
|
71
|
-
route: undefined
|
|
71
|
+
route: undefined,
|
|
72
|
+
root: undefined
|
|
72
73
|
});
|
|
73
74
|
|
|
74
75
|
if (fallback === undefined) {
|
|
@@ -88,13 +89,18 @@ function middleware<T>(request: Request<T>, router: Router<T>) {
|
|
|
88
89
|
throw new Error('Routing: route is undefined');
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
if (state.root !== undefined) {
|
|
93
|
+
state.root.dispose();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return root((instance) => {
|
|
93
97
|
request.data.parameters = state.parameters;
|
|
94
98
|
request.data.route = state.route;
|
|
95
99
|
|
|
100
|
+
state.root = instance;
|
|
101
|
+
|
|
96
102
|
return next(request);
|
|
97
|
-
},
|
|
103
|
+
}, scheduler);
|
|
98
104
|
}}`;
|
|
99
105
|
};
|
|
100
106
|
};
|