@thi.ng/router 3.2.28 → 3.2.30
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/CHANGELOG.md +8 -1
- package/api.d.ts +2 -1
- package/basic.d.ts +10 -9
- package/basic.js +10 -7
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2023-
|
|
3
|
+
- **Last updated**: 2023-08-04T10:58:19Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,13 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
### [3.2.30](https://github.com/thi-ng/umbrella/tree/@thi.ng/router@3.2.30) (2023-08-04)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- update INotify impl ([d36aca6](https://github.com/thi-ng/umbrella/commit/d36aca6))
|
|
17
|
+
- update INotify impls ([cbdc527](https://github.com/thi-ng/umbrella/commit/cbdc527))
|
|
18
|
+
|
|
12
19
|
### [3.2.14](https://github.com/thi-ng/umbrella/tree/@thi.ng/router@3.2.14) (2022-11-28)
|
|
13
20
|
|
|
14
21
|
#### ♻️ Refactoring
|
package/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Fn, IID, IObjectOf } from "@thi.ng/api";
|
|
1
|
+
import type { EVENT_ALL, Fn, IID, IObjectOf } from "@thi.ng/api";
|
|
2
2
|
/**
|
|
3
3
|
* A validation function for to-be authenticated routes. If this function
|
|
4
4
|
* determines that the user is not allowed to access this route, it should
|
|
@@ -148,4 +148,5 @@ export interface HTMLRouterConfig extends RouterConfig {
|
|
|
148
148
|
*/
|
|
149
149
|
export declare const EVENT_ROUTE_CHANGED = "route-changed";
|
|
150
150
|
export declare const EVENT_ROUTE_FAILED = "route-failed";
|
|
151
|
+
export type RouterEventType = typeof EVENT_ROUTE_CHANGED | typeof EVENT_ROUTE_FAILED | typeof EVENT_ALL;
|
|
151
152
|
//# sourceMappingURL=api.d.ts.map
|
package/basic.d.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import type { Event, INotify, IObjectOf, Listener } from "@thi.ng/api";
|
|
2
|
-
import { type Route, type RouteMatch, type RouteParamValidator, type RouterConfig } from "./api.js";
|
|
3
|
-
export declare class BasicRouter implements INotify {
|
|
2
|
+
import { type Route, type RouteMatch, type RouteParamValidator, type RouterConfig, type RouterEventType } from "./api.js";
|
|
3
|
+
export declare class BasicRouter implements INotify<RouterEventType> {
|
|
4
4
|
config: RouterConfig;
|
|
5
5
|
current: RouteMatch | undefined;
|
|
6
6
|
routeIndex: Record<string, Route>;
|
|
7
7
|
constructor(config: RouterConfig);
|
|
8
8
|
/** {@inheritDoc @thi.ng/api#INotify.addListener} */
|
|
9
|
-
addListener(id:
|
|
9
|
+
addListener(id: RouterEventType, fn: Listener<RouterEventType>, scope?: any): boolean;
|
|
10
10
|
/** {@inheritDoc @thi.ng/api#INotify.removeListener} */
|
|
11
|
-
removeListener(id:
|
|
11
|
+
removeListener(id: RouterEventType, fn: Listener<RouterEventType>, scope?: any): boolean;
|
|
12
12
|
/** {@inheritDoc @thi.ng/api#INotify.notify} */
|
|
13
|
-
notify(event: Event): boolean;
|
|
13
|
+
notify(event: Event<RouterEventType>): boolean;
|
|
14
14
|
start(): void;
|
|
15
15
|
/**
|
|
16
|
-
* Main router function. Attempts to match given input string
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
16
|
+
* Main router function. Attempts to match given input string against all
|
|
17
|
+
* configured routes. Before returning, triggers {@link EVENT_ROUTE_CHANGED}
|
|
18
|
+
* with return value as well. If none of the routes matches, emits
|
|
19
|
+
* {@link EVENT_ROUTE_FAILED} and then falls back to configured default
|
|
20
|
+
* route.
|
|
20
21
|
*
|
|
21
22
|
* @param src - route path to match
|
|
22
23
|
*/
|
package/basic.js
CHANGED
|
@@ -5,8 +5,8 @@ import { equiv } from "@thi.ng/equiv";
|
|
|
5
5
|
import { assert } from "@thi.ng/errors/assert";
|
|
6
6
|
import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
|
|
7
7
|
import { illegalArity } from "@thi.ng/errors/illegal-arity";
|
|
8
|
-
import { EVENT_ROUTE_CHANGED, } from "./api.js";
|
|
9
|
-
let BasicRouter = class BasicRouter {
|
|
8
|
+
import { EVENT_ROUTE_CHANGED, EVENT_ROUTE_FAILED, } from "./api.js";
|
|
9
|
+
export let BasicRouter = class BasicRouter {
|
|
10
10
|
constructor(config) {
|
|
11
11
|
this.config = {
|
|
12
12
|
authenticator: (route, _, params) => ({
|
|
@@ -29,9 +29,11 @@ let BasicRouter = class BasicRouter {
|
|
|
29
29
|
}
|
|
30
30
|
/** {@inheritDoc @thi.ng/api#INotify.addListener} */
|
|
31
31
|
// @ts-ignore: arguments
|
|
32
|
+
// prettier-ignore
|
|
32
33
|
addListener(id, fn, scope) { }
|
|
33
34
|
/** {@inheritDoc @thi.ng/api#INotify.removeListener} */
|
|
34
35
|
// @ts-ignore: arguments
|
|
36
|
+
// prettier-ignore
|
|
35
37
|
removeListener(id, fn, scope) { }
|
|
36
38
|
/** {@inheritDoc @thi.ng/api#INotify.notify} */
|
|
37
39
|
// @ts-ignore: arguments
|
|
@@ -44,10 +46,11 @@ let BasicRouter = class BasicRouter {
|
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
/**
|
|
47
|
-
* Main router function. Attempts to match given input string
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
49
|
+
* Main router function. Attempts to match given input string against all
|
|
50
|
+
* configured routes. Before returning, triggers {@link EVENT_ROUTE_CHANGED}
|
|
51
|
+
* with return value as well. If none of the routes matches, emits
|
|
52
|
+
* {@link EVENT_ROUTE_FAILED} and then falls back to configured default
|
|
53
|
+
* route.
|
|
51
54
|
*
|
|
52
55
|
* @param src - route path to match
|
|
53
56
|
*/
|
|
@@ -59,6 +62,7 @@ let BasicRouter = class BasicRouter {
|
|
|
59
62
|
src = src.substring(this.config.prefix.length);
|
|
60
63
|
let match = this.matchRoutes(src);
|
|
61
64
|
if (!match) {
|
|
65
|
+
this.notify({ id: EVENT_ROUTE_FAILED, value: src });
|
|
62
66
|
if (!this.handleRouteFailure()) {
|
|
63
67
|
return;
|
|
64
68
|
}
|
|
@@ -162,6 +166,5 @@ let BasicRouter = class BasicRouter {
|
|
|
162
166
|
BasicRouter = __decorate([
|
|
163
167
|
INotifyMixin
|
|
164
168
|
], BasicRouter);
|
|
165
|
-
export { BasicRouter };
|
|
166
169
|
const isParametricRoute = (route) => route.match.some(isRouteParam);
|
|
167
170
|
const isRouteParam = (x) => x[0] === "?";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/router",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.30",
|
|
4
4
|
"description": "Generic router for browser & non-browser based applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -34,19 +34,19 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.
|
|
38
|
-
"@thi.ng/checks": "^3.
|
|
39
|
-
"@thi.ng/equiv": "^2.1.
|
|
40
|
-
"@thi.ng/errors": "^2.
|
|
41
|
-
"tslib": "^2.
|
|
37
|
+
"@thi.ng/api": "^8.9.0",
|
|
38
|
+
"@thi.ng/checks": "^3.4.0",
|
|
39
|
+
"@thi.ng/equiv": "^2.1.25",
|
|
40
|
+
"@thi.ng/errors": "^2.3.0",
|
|
41
|
+
"tslib": "^2.6.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@microsoft/api-extractor": "^7.
|
|
45
|
-
"@thi.ng/testament": "^0.3.
|
|
46
|
-
"rimraf": "^5.0.
|
|
44
|
+
"@microsoft/api-extractor": "^7.36.3",
|
|
45
|
+
"@thi.ng/testament": "^0.3.18",
|
|
46
|
+
"rimraf": "^5.0.1",
|
|
47
47
|
"tools": "^0.0.1",
|
|
48
|
-
"typedoc": "^0.24.
|
|
49
|
-
"typescript": "^5.
|
|
48
|
+
"typedoc": "^0.24.8",
|
|
49
|
+
"typescript": "^5.1.6"
|
|
50
50
|
},
|
|
51
51
|
"keywords": [
|
|
52
52
|
"browser",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
],
|
|
92
92
|
"year": 2014
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "9fa3f7f8169efa30e3c71b43c82f77393581c3b5\n"
|
|
95
95
|
}
|