@esportsplus/routing 0.0.40 → 0.0.42
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 +5 -4
- package/package.json +1 -1
- package/src/browser.ts +9 -9
package/build/browser.js
CHANGED
|
@@ -16,7 +16,6 @@ function forward() {
|
|
|
16
16
|
}
|
|
17
17
|
function href() {
|
|
18
18
|
let data = new URL(window.location?.href || ''), path = data.hash ? data.hash.slice(1).split('?') : ['/', ''], request = {
|
|
19
|
-
data: {},
|
|
20
19
|
href: data.href,
|
|
21
20
|
hostname: data.hostname,
|
|
22
21
|
method: 'GET',
|
|
@@ -81,8 +80,10 @@ function middleware(request, router) {
|
|
|
81
80
|
state.root.dispose();
|
|
82
81
|
}
|
|
83
82
|
return (0, reactivity_1.root)((root) => {
|
|
84
|
-
request.data
|
|
85
|
-
|
|
83
|
+
request.data = {
|
|
84
|
+
parameters: state.parameters,
|
|
85
|
+
route: state.route
|
|
86
|
+
};
|
|
86
87
|
state.root = root;
|
|
87
88
|
return next(request);
|
|
88
89
|
}, scheduler);
|
|
@@ -107,7 +108,7 @@ function onpopstate() {
|
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
exports.default = (instance) => {
|
|
110
|
-
let request = (0, reactivity_1.reactive)(href()), router = instance || (0, router_1.default)();
|
|
111
|
+
let request = (0, reactivity_1.reactive)(Object.assign(href(), { data: {} })), router = instance || (0, router_1.default)();
|
|
111
112
|
if (cache.push(request) === 1) {
|
|
112
113
|
window.addEventListener('hashchange', onpopstate);
|
|
113
114
|
}
|
package/package.json
CHANGED
package/src/browser.ts
CHANGED
|
@@ -16,11 +16,10 @@ function forward() {
|
|
|
16
16
|
window.history.forward();
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
function href<T>()
|
|
19
|
+
function href<T>() {
|
|
20
20
|
let data = new URL( window.location?.href || '' ),
|
|
21
21
|
path = data.hash ? data.hash.slice(1).split('?') : ['/', ''],
|
|
22
|
-
request
|
|
23
|
-
data: {},
|
|
22
|
+
request = {
|
|
24
23
|
href: data.href,
|
|
25
24
|
hostname: data.hostname,
|
|
26
25
|
method: 'GET',
|
|
@@ -28,7 +27,7 @@ function href<T>(): Request<T> {
|
|
|
28
27
|
path: path[0],
|
|
29
28
|
port: data.port,
|
|
30
29
|
protocol: data.protocol,
|
|
31
|
-
query: {}
|
|
30
|
+
query: {} as Record<PropertyKey, unknown>
|
|
32
31
|
};
|
|
33
32
|
|
|
34
33
|
if (path[1]) {
|
|
@@ -37,7 +36,7 @@ function href<T>(): Request<T> {
|
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
return request
|
|
39
|
+
return request as Request<T>;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
function match<T>(request: Request<T>, router: Router<T>, subdomain?: string) {
|
|
@@ -101,9 +100,10 @@ function middleware<T>(request: Request<T>, router: Router<T>) {
|
|
|
101
100
|
}
|
|
102
101
|
|
|
103
102
|
return root((root) => {
|
|
104
|
-
request.data
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
request.data = {
|
|
104
|
+
parameters: state.parameters,
|
|
105
|
+
route: state.route
|
|
106
|
+
};
|
|
107
107
|
state.root = root;
|
|
108
108
|
|
|
109
109
|
return next(request);
|
|
@@ -138,7 +138,7 @@ function onpopstate() {
|
|
|
138
138
|
|
|
139
139
|
|
|
140
140
|
export default <T>(instance?: Router<T>) => {
|
|
141
|
-
let request = reactive( href<T>() ),
|
|
141
|
+
let request = reactive( Object.assign(href<T>(), { data: {} }) ),
|
|
142
142
|
router = instance || factory<T>();
|
|
143
143
|
|
|
144
144
|
if (cache.push(request) === 1) {
|