htmx-router 0.0.4 → 0.0.5

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/bin/router.d.ts CHANGED
@@ -6,7 +6,7 @@ declare class RouteLeaf {
6
6
  module: RouteModule;
7
7
  mask: boolean[];
8
8
  constructor(module: RouteModule, mask: boolean[]);
9
- makeOutlet(args: RenderArgs, outlet: Outlet): Outlet;
9
+ makeOutlet(args: RenderArgs, outlet: Outlet, depth: number): Outlet;
10
10
  }
11
11
  export declare class RouteTree {
12
12
  nested: Map<string, RouteTree>;
package/bin/router.js CHANGED
@@ -27,11 +27,12 @@ class RouteLeaf {
27
27
  this.module = module;
28
28
  this.mask = mask;
29
29
  }
30
- makeOutlet(args, outlet) {
30
+ makeOutlet(args, outlet, depth) {
31
31
  const renderer = this.module.Render || blankOutlet;
32
32
  const catcher = this.module.CatchError;
33
33
  return async () => {
34
34
  try {
35
+ args.depth = depth;
35
36
  return await renderer(args, outlet);
36
37
  }
37
38
  catch (e) {
@@ -39,8 +40,10 @@ class RouteLeaf {
39
40
  throw e;
40
41
  const err = (e instanceof shared_1.ErrorResponse) ? e :
41
42
  new shared_1.ErrorResponse(500, "Runtime Error", e);
42
- if (catcher)
43
+ if (catcher) {
44
+ args.depth = depth;
43
45
  return await catcher(args, err);
46
+ }
44
47
  throw err;
45
48
  }
46
49
  };
@@ -137,8 +140,8 @@ class RouteTree {
137
140
  };
138
141
  }
139
142
  else if ((_a = this.default) === null || _a === void 0 ? void 0 : _a.module.Render) {
140
- out.outlet = this.default.makeOutlet(args, out.outlet);
141
143
  out.mask = [...this.default.mask];
144
+ out.outlet = this.default.makeOutlet(args, out.outlet, out.mask.length);
142
145
  }
143
146
  }
144
147
  else {
@@ -160,7 +163,7 @@ class RouteTree {
160
163
  // Is this route masked out?
161
164
  const ignored = out.mask.splice(0, 1)[0] === true;
162
165
  if (!ignored && this.route) {
163
- out.outlet = this.route.makeOutlet(args, out.outlet);
166
+ out.outlet = this.route.makeOutlet(args, out.outlet, out.mask.length);
164
167
  }
165
168
  return out;
166
169
  }
package/bin/shared.d.ts CHANGED
@@ -30,6 +30,7 @@ export declare class RenderArgs {
30
30
  req: http.IncomingMessage;
31
31
  res: http.ServerResponse;
32
32
  params: MetaHTML;
33
+ depth: number;
33
34
  url: URL;
34
35
  links: MetaHTML[];
35
36
  meta: MetaHTML[];
package/bin/shared.js CHANGED
@@ -47,6 +47,7 @@ class RenderArgs {
47
47
  this.res = res;
48
48
  this.url = url;
49
49
  this.params = {};
50
+ this.depth = -1;
50
51
  this.links = [];
51
52
  this.meta = [];
52
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "htmx-router",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "A remix.js style file path router for htmX websites",
5
5
  "main": "./bin/index.js",
6
6
  "scripts": {