hono 4.6.4 → 4.6.6

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.
Files changed (63) hide show
  1. package/dist/adapter/deno/serve-static.js +4 -2
  2. package/dist/cjs/adapter/deno/serve-static.js +4 -2
  3. package/dist/cjs/client/client.js +10 -16
  4. package/dist/cjs/client/utils.js +18 -0
  5. package/dist/cjs/middleware/cors/index.js +6 -2
  6. package/dist/cjs/middleware/csrf/index.js +1 -1
  7. package/dist/cjs/middleware/powered-by/index.js +2 -2
  8. package/dist/cjs/middleware/secure-headers/secure-headers.js +6 -5
  9. package/dist/client/client.js +11 -16
  10. package/dist/client/utils.js +17 -0
  11. package/dist/middleware/cors/index.js +6 -2
  12. package/dist/middleware/csrf/index.js +1 -1
  13. package/dist/middleware/powered-by/index.js +2 -2
  14. package/dist/middleware/secure-headers/secure-headers.js +6 -5
  15. package/dist/types/adapter/cloudflare-pages/handler.d.ts +1 -1
  16. package/dist/types/adapter/lambda-edge/handler.d.ts +2 -2
  17. package/dist/types/client/types.d.ts +18 -8
  18. package/dist/types/client/utils.d.ts +1 -0
  19. package/dist/types/compose.d.ts +7 -1
  20. package/dist/types/context.d.ts +26 -16
  21. package/dist/types/helper/accepts/accepts.d.ts +1 -1
  22. package/dist/types/helper/adapter/index.d.ts +1 -1
  23. package/dist/types/helper/conninfo/types.d.ts +2 -2
  24. package/dist/types/helper/css/common.d.ts +6 -1
  25. package/dist/types/helper/factory/index.d.ts +31 -10
  26. package/dist/types/helper/ssg/ssg.d.ts +1 -1
  27. package/dist/types/helper/websocket/index.d.ts +1 -1
  28. package/dist/types/hono-base.d.ts +19 -22
  29. package/dist/types/hono.d.ts +1 -1
  30. package/dist/types/jsx/base.d.ts +4 -1
  31. package/dist/types/jsx/dom/hooks/index.d.ts +9 -3
  32. package/dist/types/jsx/dom/index.d.ts +28 -7
  33. package/dist/types/jsx/dom/intrinsic-element/components.d.ts +6 -6
  34. package/dist/types/jsx/dom/render.d.ts +28 -4
  35. package/dist/types/jsx/dom/server.d.ts +28 -7
  36. package/dist/types/jsx/hooks/index.d.ts +20 -5
  37. package/dist/types/jsx/index.d.ts +28 -7
  38. package/dist/types/jsx/intrinsic-element/components.d.ts +4 -4
  39. package/dist/types/jsx/intrinsic-elements.d.ts +46 -46
  40. package/dist/types/middleware/compress/index.d.ts +4 -1
  41. package/dist/types/middleware/powered-by/index.d.ts +24 -1
  42. package/dist/types/middleware/secure-headers/permissions-policy.d.ts +3 -3
  43. package/dist/types/middleware/secure-headers/secure-headers.d.ts +1 -1
  44. package/dist/types/preset/quick.d.ts +1 -1
  45. package/dist/types/preset/tiny.d.ts +1 -1
  46. package/dist/types/request.d.ts +5 -7
  47. package/dist/types/router/linear-router/router.d.ts +5 -1
  48. package/dist/types/router/pattern-router/router.d.ts +0 -1
  49. package/dist/types/router/reg-exp-router/node.d.ts +4 -1
  50. package/dist/types/router/reg-exp-router/router.d.ts +4 -3
  51. package/dist/types/router/reg-exp-router/trie.d.ts +5 -1
  52. package/dist/types/router/smart-router/router.d.ts +6 -2
  53. package/dist/types/router/trie-router/node.d.ts +6 -2
  54. package/dist/types/router.d.ts +20 -2
  55. package/dist/types/types.d.ts +908 -120
  56. package/dist/types/utils/cookie.d.ts +3 -3
  57. package/dist/types/utils/html.d.ts +6 -2
  58. package/dist/types/utils/jwt/jwt.d.ts +1 -1
  59. package/dist/types/utils/mime.d.ts +1 -1
  60. package/dist/types/utils/stream.d.ts +0 -4
  61. package/dist/types/utils/url.d.ts +5 -1
  62. package/dist/types/validator/validator.d.ts +18 -6
  63. package/package.json +8 -7
@@ -16,7 +16,7 @@ type SecureCookieConstraint = {
16
16
  };
17
17
  type HostCookieConstraint = {
18
18
  secure: true;
19
- path: '/';
19
+ path: "/";
20
20
  domain?: undefined;
21
21
  };
22
22
  export type CookieOptions = {
@@ -27,11 +27,11 @@ export type CookieOptions = {
27
27
  path?: string;
28
28
  secure?: boolean;
29
29
  signingSecret?: string;
30
- sameSite?: 'Strict' | 'Lax' | 'None' | 'strict' | 'lax' | 'none';
30
+ sameSite?: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
31
31
  partitioned?: boolean;
32
32
  prefix?: CookiePrefixOptions;
33
33
  } & PartitionCookieConstraint;
34
- export type CookiePrefixOptions = 'host' | 'secure';
34
+ export type CookiePrefixOptions = "host" | "secure";
35
35
  export type CookieConstraint<Name> = Name extends `__Secure-${string}` ? CookieOptions & SecureCookieConstraint : Name extends `__Host-${string}` ? CookieOptions & HostCookieConstraint : CookieOptions;
36
36
  export declare const parse: (cookie: string, name?: string) => Cookie;
37
37
  export declare const parseSigned: (cookie: string, secret: string | BufferSource, name?: string) => Promise<SignedCookie>;
@@ -8,7 +8,9 @@ export declare const HtmlEscapedCallbackPhase: {
8
8
  readonly Stream: 3;
9
9
  };
10
10
  type HtmlEscapedCallbackOpts = {
11
- buffer?: [string];
11
+ buffer?: [
12
+ string
13
+ ];
12
14
  phase: (typeof HtmlEscapedCallbackPhase)[keyof typeof HtmlEscapedCallbackPhase];
13
15
  context: object;
14
16
  };
@@ -40,5 +42,7 @@ export declare const raw: (value: unknown, callbacks?: HtmlEscapedCallback[]) =>
40
42
  export declare const stringBufferToString: (buffer: StringBuffer, callbacks: HtmlEscapedCallback[] | undefined) => Promise<HtmlEscapedString>;
41
43
  export declare const escapeToBuffer: (str: string, buffer: StringBuffer) => void;
42
44
  export declare const resolveCallbackSync: (str: string | HtmlEscapedString) => string;
43
- export declare const resolveCallback: (str: string | HtmlEscapedString | Promise<string>, phase: (typeof HtmlEscapedCallbackPhase)[keyof typeof HtmlEscapedCallbackPhase], preserveCallbacks: boolean, context: object, buffer?: [string]) => Promise<string>;
45
+ export declare const resolveCallback: (str: string | HtmlEscapedString | Promise<string>, phase: (typeof HtmlEscapedCallbackPhase)[keyof typeof HtmlEscapedCallbackPhase], preserveCallbacks: boolean, context: object, buffer?: [
46
+ string
47
+ ]) => Promise<string>;
44
48
  export {};
@@ -8,7 +8,7 @@ import type { SignatureKey } from './jws';
8
8
  import type { JWTPayload } from './types';
9
9
  export interface TokenHeader {
10
10
  alg: SignatureAlgorithm;
11
- typ?: 'JWT';
11
+ typ?: "JWT";
12
12
  }
13
13
  export declare function isTokenHeader(obj: unknown): obj is TokenHeader;
14
14
  export declare const sign: (payload: JWTPayload, privateKey: SignatureKey, alg?: SignatureAlgorithm) => Promise<string>;
@@ -8,5 +8,5 @@ export { baseMimes as mimes };
8
8
  /**
9
9
  * Union types for BaseMime
10
10
  */
11
- export type BaseMime = 'audio/aac' | 'video/x-msvideo' | 'image/avif' | 'video/av1' | 'application/octet-stream' | 'image/bmp' | 'text/css' | 'text/csv' | 'application/vnd.ms-fontobject' | 'application/epub+zip' | 'image/gif' | 'application/gzip' | 'text/html' | 'image/x-icon' | 'text/calendar' | 'image/jpeg' | 'text/javascript' | 'application/json' | 'application/ld+json' | 'audio/x-midi' | 'audio/mpeg' | 'video/mp4' | 'video/mpeg' | 'audio/ogg' | 'video/ogg' | 'application/ogg' | 'audio/opus' | 'font/otf' | 'application/pdf' | 'image/png' | 'application/rtf' | 'image/svg+xml' | 'image/tiff' | 'video/mp2t' | 'font/ttf' | 'text/plain' | 'application/wasm' | 'video/webm' | 'audio/webm' | 'image/webp' | 'font/woff' | 'font/woff2' | 'application/xhtml+xml' | 'application/xml' | 'application/zip' | 'video/3gpp' | 'video/3gpp2' | 'model/gltf+json' | 'model/gltf-binary';
11
+ export type BaseMime = "audio/aac" | "video/x-msvideo" | "image/avif" | "video/av1" | "application/octet-stream" | "image/bmp" | "text/css" | "text/csv" | "application/vnd.ms-fontobject" | "application/epub+zip" | "image/gif" | "application/gzip" | "text/html" | "image/x-icon" | "text/calendar" | "image/jpeg" | "text/javascript" | "application/json" | "application/ld+json" | "audio/x-midi" | "audio/mpeg" | "video/mp4" | "video/mpeg" | "audio/ogg" | "video/ogg" | "application/ogg" | "audio/opus" | "font/otf" | "application/pdf" | "image/png" | "application/rtf" | "image/svg+xml" | "image/tiff" | "video/mp2t" | "font/ttf" | "text/plain" | "application/wasm" | "video/webm" | "audio/webm" | "image/webp" | "font/woff" | "font/woff2" | "application/xhtml+xml" | "application/xml" | "application/zip" | "video/3gpp" | "video/3gpp2" | "model/gltf+json" | "model/gltf-binary";
12
12
  declare const baseMimes: Record<string, BaseMime>;
@@ -3,10 +3,6 @@
3
3
  * Stream utility.
4
4
  */
5
5
  export declare class StreamingApi {
6
- private writer;
7
- private encoder;
8
- private writable;
9
- private abortSubscribers;
10
6
  responseReadable: ReadableStream;
11
7
  /**
12
8
  * Whether the stream has been aborted.
@@ -2,7 +2,11 @@
2
2
  * @module
3
3
  * URL utility.
4
4
  */
5
- export type Pattern = readonly [string, string, RegExp | true] | '*';
5
+ export type Pattern = readonly [
6
+ string,
7
+ string,
8
+ RegExp | true
9
+ ] | "*";
6
10
  export declare const splitPath: (path: string) => string[];
7
11
  export declare const splitRoutingPath: (routePath: string) => string[];
8
12
  export declare const getPattern: (label: string) => Pattern | null;
@@ -1,14 +1,26 @@
1
1
  import type { Context } from '../context';
2
2
  import type { Env, MiddlewareHandler, TypedResponse, ValidationTargets } from '../types';
3
- type ValidationTargetKeysWithBody = 'form' | 'json';
4
- type ValidationTargetByMethod<M> = M extends 'get' | 'head' ? Exclude<keyof ValidationTargets, ValidationTargetKeysWithBody> : keyof ValidationTargets;
3
+ type ValidationTargetKeysWithBody = "form" | "json";
4
+ type ValidationTargetByMethod<M> = M extends "get" | "head" ? Exclude<keyof ValidationTargets, ValidationTargetKeysWithBody> : keyof ValidationTargets;
5
5
  export type ValidationFunction<InputType, OutputType, E extends Env = {}, P extends string = string> = (value: InputType, c: Context<E, P>) => OutputType | Response | Promise<OutputType> | Promise<Response>;
6
6
  type ExcludeResponseType<T> = T extends Response & TypedResponse<any> ? never : T;
7
7
  export declare const validator: <InputType, P extends string, M extends string, U extends ValidationTargetByMethod<M>, OutputType = ValidationTargets[U], OutputTypeExcludeResponseType = ExcludeResponseType<OutputType>, P2 extends string = P, V extends {
8
- in: { [K in U]: K extends "json" ? unknown extends InputType ? OutputTypeExcludeResponseType : InputType : { [K2 in keyof OutputTypeExcludeResponseType]: ValidationTargets[K][K2]; }; };
9
- out: { [K in U]: OutputTypeExcludeResponseType; };
8
+ in: {
9
+ [K in U]: K extends "json" ? unknown extends InputType ? OutputTypeExcludeResponseType : InputType : {
10
+ [K2 in keyof OutputTypeExcludeResponseType]: ValidationTargets[K][K2];
11
+ };
12
+ };
13
+ out: {
14
+ [K in U]: OutputTypeExcludeResponseType;
15
+ };
10
16
  } = {
11
- in: { [K in U]: K extends "json" ? unknown extends InputType ? OutputTypeExcludeResponseType : InputType : { [K2 in keyof OutputTypeExcludeResponseType]: ValidationTargets[K][K2]; }; };
12
- out: { [K in U]: OutputTypeExcludeResponseType; };
17
+ in: {
18
+ [K in U]: K extends "json" ? unknown extends InputType ? OutputTypeExcludeResponseType : InputType : {
19
+ [K2 in keyof OutputTypeExcludeResponseType]: ValidationTargets[K][K2];
20
+ };
21
+ };
22
+ out: {
23
+ [K in U]: OutputTypeExcludeResponseType;
24
+ };
13
25
  }, E extends Env = any>(target: U, validationFunc: ValidationFunction<unknown extends InputType ? ValidationTargets[U] : InputType, OutputType, E, P2>) => MiddlewareHandler<E, P, V>;
14
26
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "4.6.4",
3
+ "version": "4.6.6",
4
4
  "description": "Web framework built on Web Standards",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",
@@ -22,12 +22,12 @@
22
22
  "test:all": "bun run test && bun test:deno && bun test:bun && bun test:fastly && bun test:node && bun test:workerd && bun test:lambda && bun test:lambda-edge",
23
23
  "lint": "eslint src runtime-tests",
24
24
  "lint:fix": "eslint src runtime-tests --fix",
25
- "format": "prettier --check --cache \"src/**/*.{js,ts,tsx}\" \"runtime-tests/**/*.{js,ts,tsx}\"",
26
- "format:fix": "prettier --write --cache --cache-strategy metadata \"src/**/*.{js,ts,tsx}\" \"runtime-tests/**/*.{js,ts,tsx}\"",
27
- "copy:package.cjs.json": "cp ./package.cjs.json ./dist/cjs/package.json && cp ./package.cjs.json ./dist/types/package.json ",
28
- "build": "bun run --shell bun remove-dist && bun ./build.ts && bun run copy:package.cjs.json",
25
+ "format": "prettier --check --cache \"src/**/*.{js,ts,tsx}\" \"runtime-tests/**/*.{js,ts,tsx}\" \"build/**/*.{js,ts,tsx}\"",
26
+ "format:fix": "prettier --write --cache --cache-strategy metadata \"src/**/*.{js,ts,tsx}\" \"runtime-tests/**/*.{js,ts,tsx}\" \"build/**/*.{js,ts,tsx}\"",
27
+ "copy:package.cjs.json": "cp ./package.cjs.json ./dist/cjs/package.json && cp ./package.cjs.json ./dist/types/package.json",
28
+ "build": "bun run --shell bun remove-dist && bun ./build/build.ts && bun run copy:package.cjs.json",
29
29
  "postbuild": "publint",
30
- "watch": "bun run --shell bun remove-dist && bun ./build.ts --watch && bun run copy:package.cjs.json",
30
+ "watch": "bun run --shell bun remove-dist && bun ./build/build.ts --watch && bun run copy:package.cjs.json",
31
31
  "coverage": "vitest --run --coverage",
32
32
  "prerelease": "bun test:deno && bun run build",
33
33
  "release": "np",
@@ -626,9 +626,10 @@
626
626
  "@types/supertest": "^2.0.12",
627
627
  "@vitest/coverage-v8": "^2.0.5",
628
628
  "arg": "^5.0.2",
629
+ "bun-types": "^1.1.30",
629
630
  "esbuild": "^0.15.12",
630
631
  "eslint": "^9.10.0",
631
- "glob": "7.2.3",
632
+ "glob": "^11.0.0",
632
633
  "jsdom": "^22.1.0",
633
634
  "msw": "^2.3.0",
634
635
  "np": "7.7.0",