htmv 0.0.50 → 0.0.52
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/dist/http/response.js +0 -4
- package/dist/views.d.ts +2 -1
- package/dist/views.js +2 -3
- package/package.json +1 -1
package/dist/http/response.js
CHANGED
|
@@ -19,10 +19,6 @@ function isHttpResponse(value) {
|
|
|
19
19
|
return false;
|
|
20
20
|
if (!("status" in value) || typeof value.status !== "number")
|
|
21
21
|
return false;
|
|
22
|
-
if (!("headers" in value) || typeof value.headers !== "object")
|
|
23
|
-
return false;
|
|
24
|
-
if (!("body" in value) || typeof value.body !== "string")
|
|
25
|
-
return false;
|
|
26
22
|
return true;
|
|
27
23
|
}
|
|
28
24
|
export function requestHelper(status, body, headers) {
|
package/dist/views.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import type { HttpResponse } from "./http/response";
|
|
1
2
|
export declare function setViewsPath(path: string): void;
|
|
2
|
-
export declare function view(view: string, props: Record<string, unknown>): Promise<
|
|
3
|
+
export declare function view(view: string, props: Record<string, unknown>): Promise<HttpResponse>;
|
package/dist/views.js
CHANGED
|
@@ -3,7 +3,6 @@ import path from "node:path";
|
|
|
3
3
|
import { parse } from "./compiler/parser";
|
|
4
4
|
import { render } from "./compiler/renderer";
|
|
5
5
|
import { tokenize } from "./compiler/tokenizer";
|
|
6
|
-
import { resolveResponse } from "./http/response";
|
|
7
6
|
let viewsPath = "";
|
|
8
7
|
export function setViewsPath(path) {
|
|
9
8
|
viewsPath = path;
|
|
@@ -16,9 +15,9 @@ export async function view(view, props) {
|
|
|
16
15
|
const tokens = tokenize(code);
|
|
17
16
|
const root = parse(tokens);
|
|
18
17
|
const rendered = render(root, props);
|
|
19
|
-
return
|
|
18
|
+
return {
|
|
20
19
|
status: 200,
|
|
21
20
|
body: rendered,
|
|
22
21
|
headers: { "Content-Type": "text/html; charset=utf-8" },
|
|
23
|
-
}
|
|
22
|
+
};
|
|
24
23
|
}
|