@esportsplus/routing 0.7.1 → 0.7.2
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/client/index.js +10 -10
- package/build/client/router/index.js +15 -12
- package/package.json +1 -1
- package/src/client/index.ts +1 -2
- package/src/client/router/index.ts +19 -14
package/build/client/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as reactivity_ffa278ace0bb4e959ff55da8933387190 from '@esportsplus/reactivity';
|
|
2
2
|
import { effect, root } from '@esportsplus/reactivity';
|
|
3
3
|
import { Router } from './router/index.js';
|
|
4
4
|
import { PACKAGE_NAME } from './constants.js';
|
|
5
|
-
class
|
|
5
|
+
class ReactiveObject_ffa278ace0bb4e959ff55da8933387191 extends reactivity_ffa278ace0bb4e959ff55da8933387190.ReactiveObject {
|
|
6
6
|
#parameters;
|
|
7
7
|
#route;
|
|
8
8
|
constructor(_p0, _p1) {
|
|
9
9
|
super(null);
|
|
10
|
-
this.#parameters = this[
|
|
11
|
-
this.#route = this[
|
|
10
|
+
this.#parameters = this[reactivity_ffa278ace0bb4e959ff55da8933387190.SIGNAL](_p0);
|
|
11
|
+
this.#route = this[reactivity_ffa278ace0bb4e959ff55da8933387190.SIGNAL](_p1);
|
|
12
12
|
}
|
|
13
13
|
get parameters() {
|
|
14
|
-
return
|
|
14
|
+
return reactivity_ffa278ace0bb4e959ff55da8933387190.read(this.#parameters);
|
|
15
15
|
}
|
|
16
16
|
set parameters(_v0) {
|
|
17
|
-
|
|
17
|
+
reactivity_ffa278ace0bb4e959ff55da8933387190.write(this.#parameters, _v0);
|
|
18
18
|
}
|
|
19
19
|
get route() {
|
|
20
|
-
return
|
|
20
|
+
return reactivity_ffa278ace0bb4e959ff55da8933387190.read(this.#route);
|
|
21
21
|
}
|
|
22
22
|
set route(_v1) {
|
|
23
|
-
|
|
23
|
+
reactivity_ffa278ace0bb4e959ff55da8933387190.write(this.#route, _v1);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
let cache = [], location = window.location;
|
|
@@ -90,7 +90,7 @@ function middleware(request, router) {
|
|
|
90
90
|
return route.middleware(request);
|
|
91
91
|
};
|
|
92
92
|
host.match = (fallback) => {
|
|
93
|
-
let state = new
|
|
93
|
+
let state = new ReactiveObject_ffa278ace0bb4e959ff55da8933387191(undefined, undefined);
|
|
94
94
|
if (fallback === undefined) {
|
|
95
95
|
throw new Error(`${PACKAGE_NAME}: fallback route does not exist`);
|
|
96
96
|
}
|
|
@@ -130,7 +130,7 @@ function onpopstate() {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
const router = (...factories) => {
|
|
133
|
-
let instance = factories.reduce((r, factory) => factory(r), new Router()), request =
|
|
133
|
+
let instance = factories.reduce((r, factory) => factory(r), new Router()), request = reactivity_ffa278ace0bb4e959ff55da8933387190.reactive(Object.assign(href(), { data: {} }));
|
|
134
134
|
if (cache.push(request) === 1) {
|
|
135
135
|
window.addEventListener('hashchange', onpopstate);
|
|
136
136
|
}
|
|
@@ -16,20 +16,23 @@ function normalize(path) {
|
|
|
16
16
|
}
|
|
17
17
|
function set(route, options) {
|
|
18
18
|
let middleware = route.middleware;
|
|
19
|
-
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
for (let i = 0, n = value.length; i < n; i++) {
|
|
23
|
-
middleware.push(value[i]);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
else if (key === 'responder') {
|
|
27
|
-
middleware.push(value);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
route[key] = (route[key] || '') + value;
|
|
19
|
+
if (options.middleware) {
|
|
20
|
+
for (let i = 0, n = options.middleware.length; i < n; i++) {
|
|
21
|
+
middleware.push(options.middleware[i]);
|
|
31
22
|
}
|
|
32
23
|
}
|
|
24
|
+
if ('responder' in options) {
|
|
25
|
+
middleware.push(options.responder);
|
|
26
|
+
}
|
|
27
|
+
if (options.name) {
|
|
28
|
+
route.name = (route.name || '') + options.name;
|
|
29
|
+
}
|
|
30
|
+
if (options.path) {
|
|
31
|
+
route.path = (route.path || '') + options.path;
|
|
32
|
+
}
|
|
33
|
+
if (options.subdomain) {
|
|
34
|
+
route.subdomain = (route.subdomain || '') + options.subdomain;
|
|
35
|
+
}
|
|
33
36
|
}
|
|
34
37
|
class Router {
|
|
35
38
|
bucket = {};
|
package/package.json
CHANGED
package/src/client/index.ts
CHANGED
|
@@ -24,22 +24,27 @@ function normalize(path: string) {
|
|
|
24
24
|
function set<T>(route: Route<T>, options: Options<T> | RouteOptions<T>) {
|
|
25
25
|
let middleware = route.middleware as Middleware<T>[];
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
if (key === 'middleware') {
|
|
31
|
-
for (let i = 0, n = value.length; i < n; i++) {
|
|
32
|
-
middleware.push(value[i]);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
else if (key === 'responder') {
|
|
36
|
-
middleware.push(value);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
// @ts-ignore
|
|
40
|
-
route[key] = (route[key] || '') + value;
|
|
27
|
+
if (options.middleware) {
|
|
28
|
+
for (let i = 0, n = options.middleware.length; i < n; i++) {
|
|
29
|
+
middleware.push(options.middleware[i]);
|
|
41
30
|
}
|
|
42
31
|
}
|
|
32
|
+
|
|
33
|
+
if ('responder' in options) {
|
|
34
|
+
middleware.push((options as RouteOptions<T>).responder);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (options.name) {
|
|
38
|
+
route.name = (route.name || '') + options.name;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (options.path) {
|
|
42
|
+
route.path = (route.path || '') + options.path;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (options.subdomain) {
|
|
46
|
+
route.subdomain = (route.subdomain || '') + options.subdomain;
|
|
47
|
+
}
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
|