@thi.ng/router 4.0.7 → 4.0.8
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 +7 -1
- package/README.md +2 -2
- package/api.d.ts +2 -2
- package/html.d.ts +1 -1
- package/package.json +6 -6
- package/router.d.ts +5 -5
- package/trie.d.ts +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-04-
|
|
3
|
+
- **Last updated**: 2024-04-20T14:42:45Z
|
|
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,12 @@ 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
|
+
### [4.0.8](https://github.com/thi-ng/umbrella/tree/@thi.ng/router@4.0.8) (2024-04-20)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- update type usage ([835dfb0](https://github.com/thi-ng/umbrella/commit/835dfb0))
|
|
17
|
+
|
|
12
18
|
### [4.0.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/router@4.0.1) (2024-03-13)
|
|
13
19
|
|
|
14
20
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
|
@@ -66,10 +66,10 @@ import * as rou from "@thi.ng/router";
|
|
|
66
66
|
Browser ESM import:
|
|
67
67
|
|
|
68
68
|
```html
|
|
69
|
-
<script type="module" src="https://
|
|
69
|
+
<script type="module" src="https://esm.run/@thi.ng/router"></script>
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
[
|
|
72
|
+
[JSDelivr documentation](https://www.jsdelivr.com/)
|
|
73
73
|
|
|
74
74
|
Package sizes (brotli'd, pre-treeshake): ESM: 1.94 KB
|
|
75
75
|
|
package/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EVENT_ALL, Fn, IObjectOf } from "@thi.ng/api";
|
|
1
|
+
import type { EVENT_ALL, Fn, IObjectOf, Maybe } from "@thi.ng/api";
|
|
2
2
|
/**
|
|
3
3
|
* A validation function for to-be authenticated routes.
|
|
4
4
|
*
|
|
@@ -13,7 +13,7 @@ import type { EVENT_ALL, Fn, IObjectOf } from "@thi.ng/api";
|
|
|
13
13
|
* The optional `ctx` is an arbitrary user provided context value given to
|
|
14
14
|
* {@link Router.route} (e.g. the original request object).
|
|
15
15
|
*/
|
|
16
|
-
export type RouteAuthenticator<T = any> = (match: RouteMatch, route: AugmentedRoute, ctx?: T) => RouteMatch
|
|
16
|
+
export type RouteAuthenticator<T = any> = (match: RouteMatch, route: AugmentedRoute, ctx?: T) => Maybe<RouteMatch>;
|
|
17
17
|
/**
|
|
18
18
|
* Route validator subspecs are optional and used to coerce and/or validate
|
|
19
19
|
* individual route parameters.
|
package/html.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare class HTMLRouter<T = any> extends Router<T> {
|
|
|
22
22
|
* @param ctx -
|
|
23
23
|
* @param pushState -
|
|
24
24
|
*/
|
|
25
|
-
route(src: string, ctx?: T, pushState?: boolean): import("./api.js").RouteMatch
|
|
25
|
+
route(src: string, ctx?: T, pushState?: boolean): import("@thi.ng/api").Maybe<import("./api.js").RouteMatch>;
|
|
26
26
|
routeTo(route: string, ctx?: T): void;
|
|
27
27
|
protected handlePopChange(): Fn<PopStateEvent, void>;
|
|
28
28
|
protected handleHashChange(): EventListener;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/router",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.8",
|
|
4
4
|
"description": "Generic trie-based router with support for wildcards, route param validation/coercion, auth",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.
|
|
40
|
-
"@thi.ng/checks": "^3.6.
|
|
41
|
-
"@thi.ng/equiv": "^2.1.
|
|
42
|
-
"@thi.ng/errors": "^2.5.
|
|
39
|
+
"@thi.ng/api": "^8.11.0",
|
|
40
|
+
"@thi.ng/checks": "^3.6.2",
|
|
41
|
+
"@thi.ng/equiv": "^2.1.56",
|
|
42
|
+
"@thi.ng/errors": "^2.5.5",
|
|
43
43
|
"tslib": "^2.6.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
],
|
|
99
99
|
"year": 2014
|
|
100
100
|
},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "8339d05ecc857e529c7325a9839c0063b89e728d\n"
|
|
102
102
|
}
|
package/router.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Event, INotify, IObjectOf, Listener, SomeRequired } from "@thi.ng/api";
|
|
1
|
+
import type { Event, INotify, IObjectOf, Listener, Maybe, SomeRequired } from "@thi.ng/api";
|
|
2
2
|
import { type AugmentedRoute, type Route, type RouteMatch, type RouteParamValidator, type RouterEventType, type RouterOpts } from "./api.js";
|
|
3
3
|
import { Trie } from "./trie.js";
|
|
4
4
|
export declare class Router<T = any> implements INotify<RouterEventType> {
|
|
5
5
|
opts: RouterOpts<T>;
|
|
6
|
-
current: RouteMatch
|
|
6
|
+
current: Maybe<RouteMatch>;
|
|
7
7
|
protected index: Record<string, AugmentedRoute>;
|
|
8
8
|
protected routes: Trie<AugmentedRoute>;
|
|
9
9
|
constructor(config: RouterOpts<T>);
|
|
@@ -25,7 +25,7 @@ export declare class Router<T = any> implements INotify<RouterEventType> {
|
|
|
25
25
|
* @param src - route path to match
|
|
26
26
|
* @param ctx - arbitrary user context
|
|
27
27
|
*/
|
|
28
|
-
route(src: string, ctx?: T): RouteMatch
|
|
28
|
+
route(src: string, ctx?: T): Maybe<RouteMatch>;
|
|
29
29
|
/**
|
|
30
30
|
* Returns a formatted version of given {@link RouteMatch}, incl. any
|
|
31
31
|
* params, or alternatively a registered route ID (and optional route
|
|
@@ -37,9 +37,9 @@ export declare class Router<T = any> implements INotify<RouterEventType> {
|
|
|
37
37
|
*/
|
|
38
38
|
format(id: string, params?: any, rest?: string[]): string;
|
|
39
39
|
format(match: SomeRequired<RouteMatch, "id">): string;
|
|
40
|
-
routeForID(id: string): AugmentedRoute
|
|
40
|
+
routeForID(id: string): Maybe<AugmentedRoute>;
|
|
41
41
|
protected augmentRoute(route: Route): AugmentedRoute;
|
|
42
|
-
protected matchRoutes(src: string, ctx?: T): RouteMatch
|
|
42
|
+
protected matchRoutes(src: string, ctx?: T): Maybe<RouteMatch>;
|
|
43
43
|
protected validateRouteParams(params: any, validators: IObjectOf<Partial<RouteParamValidator>>): boolean;
|
|
44
44
|
protected handleRouteFailure(): boolean;
|
|
45
45
|
}
|
package/trie.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Maybe } from "@thi.ng/api";
|
|
1
2
|
/**
|
|
2
3
|
* Trie data structure for storing & matching route patterns with wildcards.
|
|
3
4
|
*
|
|
@@ -47,8 +48,8 @@
|
|
|
47
48
|
export declare class Trie<T> {
|
|
48
49
|
n: Record<string, Trie<T>>;
|
|
49
50
|
v?: T;
|
|
50
|
-
constructor(key?: string[], v?: T
|
|
51
|
+
constructor(key?: string[], v?: Maybe<T>, i?: number);
|
|
51
52
|
set(key: string[], v: T, i?: number): void;
|
|
52
|
-
get(key: string[], i?: number): T
|
|
53
|
+
get(key: string[], i?: number): Maybe<T>;
|
|
53
54
|
}
|
|
54
55
|
//# sourceMappingURL=trie.d.ts.map
|