hono 4.2.1 → 4.2.2
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/cjs/client/client.js +2 -2
- package/dist/cjs/middleware/jsx-renderer/index.js +2 -2
- package/dist/client/client.js +2 -2
- package/dist/middleware/jsx-renderer/index.js +2 -2
- package/dist/types/client/types.d.ts +3 -3
- package/dist/types/middleware/jsx-renderer/index.d.ts +4 -2
- package/package.json +1 -1
|
@@ -52,7 +52,7 @@ class ClientRequestImpl {
|
|
|
52
52
|
this.url = url;
|
|
53
53
|
this.method = method;
|
|
54
54
|
}
|
|
55
|
-
fetch = (args, opt) => {
|
|
55
|
+
fetch = async (args, opt) => {
|
|
56
56
|
if (args) {
|
|
57
57
|
if (args.query) {
|
|
58
58
|
for (const [k, v] of Object.entries(args.query)) {
|
|
@@ -88,7 +88,7 @@ class ClientRequestImpl {
|
|
|
88
88
|
let setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD");
|
|
89
89
|
const headerValues = {
|
|
90
90
|
...args?.header ?? {},
|
|
91
|
-
...opt?.headers ? opt.headers : {}
|
|
91
|
+
...typeof opt?.headers === "function" ? await opt.headers() : opt?.headers ? opt.headers : {}
|
|
92
92
|
};
|
|
93
93
|
if (args?.cookie) {
|
|
94
94
|
const cookies = [];
|
|
@@ -30,7 +30,7 @@ const RequestContext = (0, import_jsx.createContext)(null);
|
|
|
30
30
|
const createRenderer = (c, Layout, component, options) => (children, props) => {
|
|
31
31
|
const docType = typeof options?.docType === "string" ? options.docType : options?.docType === false ? "" : "<!DOCTYPE html>";
|
|
32
32
|
const currentLayout = component ? (0, import_jsx.jsx)(
|
|
33
|
-
component,
|
|
33
|
+
(props2) => component(props2, c),
|
|
34
34
|
{
|
|
35
35
|
...{ Layout, ...props }
|
|
36
36
|
},
|
|
@@ -59,7 +59,7 @@ const jsxRenderer = (component, options) => function jsxRenderer2(c, next) {
|
|
|
59
59
|
const Layout = c.getLayout() ?? import_jsx.Fragment;
|
|
60
60
|
if (component) {
|
|
61
61
|
c.setLayout((props) => {
|
|
62
|
-
return component({ ...props, Layout });
|
|
62
|
+
return component({ ...props, Layout }, c);
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
c.setRenderer(createRenderer(c, Layout, component, options));
|
package/dist/client/client.js
CHANGED
|
@@ -30,7 +30,7 @@ var ClientRequestImpl = class {
|
|
|
30
30
|
this.url = url;
|
|
31
31
|
this.method = method;
|
|
32
32
|
}
|
|
33
|
-
fetch = (args, opt) => {
|
|
33
|
+
fetch = async (args, opt) => {
|
|
34
34
|
if (args) {
|
|
35
35
|
if (args.query) {
|
|
36
36
|
for (const [k, v] of Object.entries(args.query)) {
|
|
@@ -66,7 +66,7 @@ var ClientRequestImpl = class {
|
|
|
66
66
|
let setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD");
|
|
67
67
|
const headerValues = {
|
|
68
68
|
...args?.header ?? {},
|
|
69
|
-
...opt?.headers ? opt.headers : {}
|
|
69
|
+
...typeof opt?.headers === "function" ? await opt.headers() : opt?.headers ? opt.headers : {}
|
|
70
70
|
};
|
|
71
71
|
if (args?.cookie) {
|
|
72
72
|
const cookies = [];
|
|
@@ -6,7 +6,7 @@ var RequestContext = createContext(null);
|
|
|
6
6
|
var createRenderer = (c, Layout, component, options) => (children, props) => {
|
|
7
7
|
const docType = typeof options?.docType === "string" ? options.docType : options?.docType === false ? "" : "<!DOCTYPE html>";
|
|
8
8
|
const currentLayout = component ? jsx(
|
|
9
|
-
component,
|
|
9
|
+
(props2) => component(props2, c),
|
|
10
10
|
{
|
|
11
11
|
...{ Layout, ...props }
|
|
12
12
|
},
|
|
@@ -35,7 +35,7 @@ var jsxRenderer = (component, options) => function jsxRenderer2(c, next) {
|
|
|
35
35
|
const Layout = c.getLayout() ?? Fragment;
|
|
36
36
|
if (component) {
|
|
37
37
|
c.setLayout((props) => {
|
|
38
|
-
return component({ ...props, Layout });
|
|
38
|
+
return component({ ...props, Layout }, c);
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
c.setRenderer(createRenderer(c, Layout, component, options));
|
|
@@ -4,10 +4,10 @@ import type { Schema } from '../types';
|
|
|
4
4
|
import type { HasRequiredKeys } from '../utils/types';
|
|
5
5
|
type HonoRequest = (typeof Hono.prototype)['request'];
|
|
6
6
|
export type ClientRequestOptions<T = unknown> = keyof T extends never ? {
|
|
7
|
-
headers?: Record<string, string
|
|
7
|
+
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
8
8
|
fetch?: typeof fetch | HonoRequest;
|
|
9
9
|
} : {
|
|
10
|
-
headers: T;
|
|
10
|
+
headers: T | (() => T | Promise<T>);
|
|
11
11
|
fetch?: typeof fetch | HonoRequest;
|
|
12
12
|
};
|
|
13
13
|
export type ClientRequest<S extends Schema> = {
|
|
@@ -32,7 +32,7 @@ export type ClientRequest<S extends Schema> = {
|
|
|
32
32
|
input: infer I;
|
|
33
33
|
} ? (args?: Omit<I, 'json'>) => WebSocket : never : never;
|
|
34
34
|
};
|
|
35
|
-
type BlankRecordToNever<T> = T extends any ?
|
|
35
|
+
type BlankRecordToNever<T> = T extends any ? T extends null ? null : keyof T extends never ? never : T : never;
|
|
36
36
|
export interface ClientResponse<T> {
|
|
37
37
|
readonly body: ReadableStream | null;
|
|
38
38
|
readonly bodyUsed: boolean;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { Context, PropsForRenderer } from '../../context';
|
|
2
2
|
import type { FC, PropsWithChildren } from '../../jsx';
|
|
3
3
|
import type { Env, Input, MiddlewareHandler } from '../../types';
|
|
4
|
+
import type { HtmlEscapedString } from '../../utils/html';
|
|
4
5
|
export declare const RequestContext: import("../../jsx").Context<Context<any, any, {}> | null>;
|
|
5
6
|
type RendererOptions = {
|
|
6
7
|
docType?: boolean | string;
|
|
7
8
|
stream?: boolean | Record<string, string>;
|
|
8
9
|
};
|
|
9
|
-
|
|
10
|
+
type ComponentWithChildren = (props: PropsWithChildren<PropsForRenderer & {
|
|
10
11
|
Layout: FC;
|
|
11
|
-
}
|
|
12
|
+
}>, c: Context) => HtmlEscapedString | Promise<HtmlEscapedString>;
|
|
13
|
+
export declare const jsxRenderer: (component?: ComponentWithChildren, options?: RendererOptions) => MiddlewareHandler;
|
|
12
14
|
export declare const useRequestContext: <E extends Env = any, P extends string = any, I extends Input = {}>() => Context<E, P, I>;
|
|
13
15
|
export {};
|