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 +1 -1
- package/bin/router.js +7 -4
- package/bin/shared.d.ts +1 -0
- package/bin/shared.js +1 -0
- package/package.json +1 -1
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
package/bin/shared.js
CHANGED