@thi.ng/router 4.0.2 → 4.0.3

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/api.d.ts CHANGED
@@ -83,7 +83,8 @@ export interface Route {
83
83
  auth?: boolean;
84
84
  }
85
85
  export interface AugmentedRoute {
86
- spec: Route;
86
+ spec: Readonly<Route>;
87
+ id: string;
87
88
  match: string[];
88
89
  params?: Record<number, string>;
89
90
  rest: number;
package/html.js CHANGED
@@ -18,7 +18,7 @@ class HTMLRouter extends Router {
18
18
  }
19
19
  if (this.opts.initial) {
20
20
  const route = this.routeForID(this.opts.initial);
21
- this.route(this.format({ id: route.spec.id }));
21
+ this.route(this.format({ id: route.id }));
22
22
  } else {
23
23
  this.route(this.useFragment ? location.hash : location.pathname);
24
24
  }
@@ -80,7 +80,7 @@ class HTMLRouter extends Router {
80
80
  handleRouteFailure() {
81
81
  this.ignoreHashChange = true;
82
82
  location.hash = this.format({
83
- id: this.routeForID(this.opts.default).spec.id
83
+ id: this.routeForID(this.opts.default).id
84
84
  });
85
85
  this.ignoreHashChange = false;
86
86
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/router",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
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",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@thi.ng/api": "^8.9.30",
40
- "@thi.ng/checks": "^3.5.3",
40
+ "@thi.ng/checks": "^3.5.4",
41
41
  "@thi.ng/equiv": "^2.1.52",
42
42
  "@thi.ng/errors": "^2.5.1",
43
43
  "tslib": "^2.6.2"
@@ -98,5 +98,5 @@
98
98
  ],
99
99
  "year": 2014
100
100
  },
101
- "gitHead": "bc0f3cb07d6f1cab6dbdc5ff57428f5484e711bb\n"
101
+ "gitHead": "4b3d4ab6ce373ca817ad780f679572169a9ed733\n"
102
102
  }
package/router.js CHANGED
@@ -62,7 +62,7 @@ let Router = class {
62
62
  start() {
63
63
  if (this.opts.initial) {
64
64
  const route = this.routeForID(this.opts.initial);
65
- this.current = { id: route.spec.id, params: {} };
65
+ this.current = { id: route.id, params: {} };
66
66
  this.notify({ id: EVENT_ROUTE_CHANGED, value: this.current });
67
67
  }
68
68
  }
@@ -71,7 +71,7 @@ let Router = class {
71
71
  try {
72
72
  const route = this.augmentRoute(r);
73
73
  this.routes.set(route.match, route);
74
- this.index[r.id] = route;
74
+ this.index[route.id] = route;
75
75
  } catch (e) {
76
76
  illegalArgs(
77
77
  `error in route "${r.id}": ${e.origMessage}`
@@ -104,7 +104,7 @@ let Router = class {
104
104
  return;
105
105
  }
106
106
  const route = this.routeForID(this.opts.default);
107
- match = { id: route.spec.id, redirect: true };
107
+ match = { id: route.id, redirect: true };
108
108
  }
109
109
  if (!equiv(match, this.current)) {
110
110
  this.current = match;
@@ -157,7 +157,7 @@ let Router = class {
157
157
  const existing = this.routes.get(match);
158
158
  if (existing) {
159
159
  illegalArgs(
160
- `duplicate route: ${match} (id: ${route.id}, conflicts with: ${existing.spec.id})`
160
+ `duplicate route: ${match} (id: ${route.id}, conflicts with: ${existing.id})`
161
161
  );
162
162
  }
163
163
  let hasParams = false;
@@ -170,6 +170,7 @@ let Router = class {
170
170
  }, {});
171
171
  return {
172
172
  spec: route,
173
+ id: route.id,
173
174
  match,
174
175
  params: hasParams ? params : void 0,
175
176
  rest: match.indexOf("+")
@@ -193,7 +194,7 @@ let Router = class {
193
194
  }
194
195
  const rest = route.rest >= 0 ? curr.slice(route.rest) : void 0;
195
196
  let match = {
196
- id: route.spec.id,
197
+ id: route.id,
197
198
  params,
198
199
  rest
199
200
  };