htmx-router 1.0.2 → 1.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/defer.d.ts +1 -1
- package/defer.js +2 -7
- package/endpoint.d.ts +1 -1
- package/endpoint.js +1 -6
- package/package.json +1 -1
- package/router.js +1 -1
package/defer.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export declare const path = "_/defer/$";
|
|
|
10
10
|
export declare const parameters: {
|
|
11
11
|
$: StringConstructor;
|
|
12
12
|
};
|
|
13
|
-
export declare function loader(ctx: RouteContext<typeof parameters>): Promise<
|
|
13
|
+
export declare function loader(ctx: RouteContext<typeof parameters>): Promise<JSX.Element | null>;
|
|
14
14
|
export declare const action: typeof loader;
|
package/defer.js
CHANGED
|
@@ -68,13 +68,8 @@ export async function loader(ctx) {
|
|
|
68
68
|
console.warn(`Warn: Function ${endpoint.name} was not registered for defer use`);
|
|
69
69
|
return null;
|
|
70
70
|
}
|
|
71
|
-
const forward = new RouteContext(ctx, prelude, entry.shape);
|
|
72
|
-
const res = await endpoint(forward);
|
|
73
|
-
if (res instanceof Response)
|
|
74
|
-
return res;
|
|
75
|
-
if (res === null)
|
|
76
|
-
return null;
|
|
77
71
|
ctx.headers.set("X-Partial", "true");
|
|
78
|
-
|
|
72
|
+
const forward = new RouteContext(ctx, prelude, entry.shape);
|
|
73
|
+
return await endpoint(forward);
|
|
79
74
|
}
|
|
80
75
|
export const action = loader;
|
package/endpoint.d.ts
CHANGED
|
@@ -16,5 +16,5 @@ export declare const path = "_/endpoint/$";
|
|
|
16
16
|
export declare const parameters: {
|
|
17
17
|
$: StringConstructor;
|
|
18
18
|
};
|
|
19
|
-
export declare function loader(ctx: RouteContext<typeof parameters>): Promise<
|
|
19
|
+
export declare function loader(ctx: RouteContext<typeof parameters>): Promise<JSX.Element | null>;
|
|
20
20
|
export declare const action: typeof loader;
|
package/endpoint.js
CHANGED
|
@@ -30,11 +30,6 @@ export async function loader(ctx) {
|
|
|
30
30
|
const endpoint = registry.get(ctx.params["$"]);
|
|
31
31
|
if (!endpoint)
|
|
32
32
|
return null;
|
|
33
|
-
|
|
34
|
-
if (res === null)
|
|
35
|
-
return null;
|
|
36
|
-
if (res instanceof Response)
|
|
37
|
-
return res;
|
|
38
|
-
return ctx.render(res, ctx.headers);
|
|
33
|
+
return await endpoint.render(ctx);
|
|
39
34
|
}
|
|
40
35
|
export const action = loader;
|
package/package.json
CHANGED
package/router.js
CHANGED
|
@@ -164,7 +164,7 @@ export class RouteTree {
|
|
|
164
164
|
async unwrap(ctx, res) {
|
|
165
165
|
if (!this.slug)
|
|
166
166
|
throw res;
|
|
167
|
-
|
|
167
|
+
const caught = await this.slug.error(ctx, res);
|
|
168
168
|
if (caught instanceof Response) {
|
|
169
169
|
caught.headers.set("X-Caught", "true");
|
|
170
170
|
return caught;
|