hono 4.2.0 → 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.
@@ -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));
@@ -22,7 +22,7 @@ __export(jws_exports, {
22
22
  verifying: () => verifying
23
23
  });
24
24
  module.exports = __toCommonJS(jws_exports);
25
- var import_helper = require("../../helper");
25
+ var import_adapter = require("../../helper/adapter");
26
26
  var import_encode = require("../encode");
27
27
  var import_types = require("./types");
28
28
  var import_types2 = require("./types");
@@ -199,7 +199,7 @@ function getKeyAlgorithm(name) {
199
199
  }
200
200
  }
201
201
  function isCryptoKey(key) {
202
- const runtime = (0, import_helper.getRuntimeKey)();
202
+ const runtime = (0, import_adapter.getRuntimeKey)();
203
203
  if (runtime === "node" && !!crypto.webcrypto) {
204
204
  return key instanceof crypto.webcrypto.CryptoKey;
205
205
  }
@@ -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 ? (keyof T extends never ? never : T) : never;
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
- export declare const jsxRenderer: (component?: FC<PropsWithChildren<PropsForRenderer & {
10
+ type ComponentWithChildren = (props: PropsWithChildren<PropsForRenderer & {
10
11
  Layout: FC;
11
- }>>, options?: RendererOptions) => MiddlewareHandler;
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 {};
@@ -1,5 +1,5 @@
1
1
  // src/utils/jwt/jws.ts
2
- import { getRuntimeKey } from "../../helper.js";
2
+ import { getRuntimeKey } from "../../helper/adapter/index.js";
3
3
  import { decodeBase64 } from "../encode.js";
4
4
  import { JwtAlgorithmNotImplemented } from "./types.js";
5
5
  import { CryptoKeyUsage } from "./types.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
4
4
  "description": "Ultrafast web framework for the Edges",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",
@@ -1,12 +0,0 @@
1
- export * from './helper/accepts';
2
- export * from './helper/adapter';
3
- export * from './helper/cookie';
4
- export * from './helper/css';
5
- export * from './helper/factory';
6
- export * from './helper/html';
7
- export * from './helper/streaming';
8
- export * from './helper/testing';
9
- export * from './helper/dev';
10
- export * from './adapter/deno/ssg';
11
- export * from './adapter/deno/websocket';
12
- export { decode as jwtDecode, sign as jwtSign, verify as jwtVerify } from './middleware/jwt';