@@ -351,6 +351,3 @@ // src/adapter/aws-lambda/handler.ts | ||
| var isContentEncodingBinary = (contentEncoding) => { | ||
| if (contentEncoding === null) { | ||
| return false; | ||
| } | ||
| return /^(gzip|deflate|compress|br)/.test(contentEncoding); | ||
| return !!contentEncoding && !/^identity$/i.test(contentEncoding); | ||
| }; | ||
@@ -357,0 +354,0 @@ export { |
@@ -18,2 +18,4 @@ // src/adapter/lambda-edge/handler.ts | ||
| const [context, callback] = args; | ||
| let callbackError = null; | ||
| let callbackResult; | ||
| const res = await app.fetch(createRequest(event), { | ||
@@ -23,2 +25,6 @@ event, | ||
| callback: (err, result) => { | ||
| if (!callbackError && !callbackResult) { | ||
| callbackError = err; | ||
| callbackResult = result; | ||
| } | ||
| callback?.(err, result); | ||
@@ -30,7 +36,11 @@ }, | ||
| }); | ||
| return createResult(res); | ||
| if (callbackError) { | ||
| throw callbackError; | ||
| } | ||
| return callbackResult ?? createResult(res); | ||
| }; | ||
| }; | ||
| var createResult = async (res) => { | ||
| const isBase64Encoded = isContentTypeBinary(res.headers.get("content-type") || ""); | ||
| const contentEncoding = res.headers.get("content-encoding"); | ||
| const isBase64Encoded = isContentTypeBinary(res.headers.get("content-type") || "") || !!contentEncoding && !/^identity$/i.test(contentEncoding); | ||
| const body = isBase64Encoded ? encodeBase64(await res.arrayBuffer()) : await res.text(); | ||
@@ -37,0 +47,0 @@ return { |
@@ -381,6 +381,3 @@ var __defProp = Object.defineProperty; | ||
| const isContentEncodingBinary = (contentEncoding) => { | ||
| if (contentEncoding === null) { | ||
| return false; | ||
| } | ||
| return /^(gzip|deflate|compress|br)/.test(contentEncoding); | ||
| return !!contentEncoding && !/^identity$/i.test(contentEncoding); | ||
| }; | ||
@@ -387,0 +384,0 @@ // Annotate the CommonJS export names for ESM import in node: |
@@ -51,2 +51,4 @@ var __create = Object.create; | ||
| const [context, callback] = args; | ||
| let callbackError = null; | ||
| let callbackResult; | ||
| const res = await app.fetch(createRequest(event), { | ||
@@ -56,2 +58,6 @@ event, | ||
| callback: (err, result) => { | ||
| if (!callbackError && !callbackResult) { | ||
| callbackError = err; | ||
| callbackResult = result; | ||
| } | ||
| callback?.(err, result); | ||
@@ -63,7 +69,11 @@ }, | ||
| }); | ||
| return createResult(res); | ||
| if (callbackError) { | ||
| throw callbackError; | ||
| } | ||
| return callbackResult ?? createResult(res); | ||
| }; | ||
| }; | ||
| const createResult = async (res) => { | ||
| const isBase64Encoded = isContentTypeBinary(res.headers.get("content-type") || ""); | ||
| const contentEncoding = res.headers.get("content-encoding"); | ||
| const isBase64Encoded = isContentTypeBinary(res.headers.get("content-type") || "") || !!contentEncoding && !/^identity$/i.test(contentEncoding); | ||
| const body = isBase64Encoded ? (0, import_encode.encodeBase64)(await res.arrayBuffer()) : await res.text(); | ||
@@ -70,0 +80,0 @@ return { |
@@ -187,3 +187,12 @@ var __defProp = Object.defineProperty; | ||
| options ??= {}; | ||
| const args = (0, import_utils.deepMerge)(options, { ...opts.args[1] }); | ||
| const reqOptions = { ...opts.args[1] }; | ||
| const baseHeaders = options.headers; | ||
| const reqHeaders = reqOptions.headers; | ||
| if (baseHeaders && reqHeaders) { | ||
| reqOptions.headers = async () => ({ | ||
| ...typeof baseHeaders === "function" ? await baseHeaders() : baseHeaders, | ||
| ...typeof reqHeaders === "function" ? await reqHeaders() : reqHeaders | ||
| }); | ||
| } | ||
| const args = (0, import_utils.deepMerge)(options, reqOptions); | ||
| return req.fetch(opts.args[0], args); | ||
@@ -190,0 +199,0 @@ } |
@@ -73,3 +73,4 @@ var __defProp = Object.defineProperty; | ||
| } | ||
| if (etagMatches(etag3, ifNoneMatch)) { | ||
| const matched = ifNoneMatch === "*" ? (c.req.method === "GET" || c.req.method === "HEAD") && res.ok : etagMatches(etag3, ifNoneMatch); | ||
| if (matched) { | ||
| c.res = new Response(null, { | ||
@@ -76,0 +77,0 @@ status: 304, |
@@ -158,2 +158,11 @@ var __defProp = Object.defineProperty; | ||
| this.#pushHandlerSets(handlerSets, child, method, node.#params, params); | ||
| if (m[0].length === restPathString.length && child.#children["*"]) { | ||
| this.#pushHandlerSets( | ||
| handlerSets, | ||
| child.#children["*"], | ||
| method, | ||
| node.#params, | ||
| params | ||
| ); | ||
| } | ||
| if (hasChildren(child.#children)) { | ||
@@ -160,0 +169,0 @@ child.#params = params; |
@@ -173,3 +173,12 @@ // src/client/client.ts | ||
| options ??= {}; | ||
| const args = deepMerge(options, { ...opts.args[1] }); | ||
| const reqOptions = { ...opts.args[1] }; | ||
| const baseHeaders = options.headers; | ||
| const reqHeaders = reqOptions.headers; | ||
| if (baseHeaders && reqHeaders) { | ||
| reqOptions.headers = async () => ({ | ||
| ...typeof baseHeaders === "function" ? await baseHeaders() : baseHeaders, | ||
| ...typeof reqHeaders === "function" ? await reqHeaders() : reqHeaders | ||
| }); | ||
| } | ||
| const args = deepMerge(options, reqOptions); | ||
| return req.fetch(opts.args[0], args); | ||
@@ -176,0 +185,0 @@ } |
@@ -51,3 +51,4 @@ // src/middleware/etag/index.ts | ||
| } | ||
| if (etagMatches(etag3, ifNoneMatch)) { | ||
| const matched = ifNoneMatch === "*" ? (c.req.method === "GET" || c.req.method === "HEAD") && res.ok : etagMatches(etag3, ifNoneMatch); | ||
| if (matched) { | ||
| c.res = new Response(null, { | ||
@@ -54,0 +55,0 @@ status: 304, |
@@ -137,2 +137,11 @@ // src/router/trie-router/node.ts | ||
| this.#pushHandlerSets(handlerSets, child, method, node.#params, params); | ||
| if (m[0].length === restPathString.length && child.#children["*"]) { | ||
| this.#pushHandlerSets( | ||
| handlerSets, | ||
| child.#children["*"], | ||
| method, | ||
| node.#params, | ||
| params | ||
| ); | ||
| } | ||
| if (hasChildren(child.#children)) { | ||
@@ -139,0 +148,0 @@ child.#params = params; |
@@ -84,5 +84,5 @@ import type { Hono } from '../../hono'; | ||
| } | ||
| export declare const handle: (app: Hono<any>) => ((event: CloudFrontEdgeEvent, context?: CloudFrontContext, callback?: Callback) => Promise<CloudFrontResult>); | ||
| export declare const handle: (app: Hono<any>) => ((event: CloudFrontEdgeEvent, context?: CloudFrontContext, callback?: Callback) => Promise<CloudFrontResult | CloudFrontRequest>); | ||
| export declare const createBody: (method: string, requestBody: CloudFrontRequest["body"]) => string | Uint8Array<ArrayBuffer> | undefined; | ||
| export declare const isContentTypeBinary: (contentType: string) => boolean; | ||
| export {}; |
@@ -101,3 +101,21 @@ /** | ||
| * @returns Hono middleware function | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * type Variables = LanguageVariables | ||
| * const app = new Hono<{ Variables: Variables }>() | ||
| * | ||
| * app.use( | ||
| * languageDetector({ | ||
| * supportedLanguages: ['en', 'ja'], // Must include fallback | ||
| * fallbackLanguage: 'en', // Required | ||
| * }) | ||
| * ) | ||
| * | ||
| * app.get('/', (c) => { | ||
| * const lang = c.get('language') | ||
| * return c.text(`Current language: ${lang}`) | ||
| * }) | ||
| * ``` | ||
| */ | ||
| export declare const languageDetector: (userOptions: Partial<DetectorOptions>) => MiddlewareHandler; |
@@ -45,3 +45,3 @@ /** | ||
| [K in keyof T]: JSONParsed<InvalidToNull<T[K]>, TError>; | ||
| } : T extends Set<unknown> | Map<unknown, unknown> | Record<string, never> ? {} : T extends object ? T[keyof T] extends TError ? never : { | ||
| } extends infer A ? A extends ReadonlyArray<unknown> ? A : JSONParsed<InvalidToNull<T[number]>, TError>[] : never : T extends Set<unknown> | Map<unknown, unknown> | Record<string, never> ? {} : T extends object ? T[keyof T] extends TError ? never : { | ||
| [K in keyof OmitSymbolKeys<T> as IsInvalid<T[K]> extends true ? never : K]: boolean extends IsInvalid<T[K]> ? JSONParsed<T[K], TError> | undefined : JSONParsed<T[K], TError>; | ||
@@ -48,0 +48,0 @@ } : T extends unknown ? T extends TError ? never : JSONValue : never; |
+2
-2
| { | ||
| "name": "hono", | ||
| "version": "4.12.28", | ||
| "version": "4.12.29", | ||
| "description": "Web framework built on Web Standards", | ||
@@ -14,3 +14,3 @@ "main": "dist/cjs/index.js", | ||
| "scripts": { | ||
| "test": "tsc --noEmit && vitest --run", | ||
| "test": "tsc -p tsconfig.spec.json && vitest --run", | ||
| "test:watch": "vitest --watch", | ||
@@ -17,0 +17,0 @@ "test:deno": "deno test --allow-read --allow-env --allow-write --allow-net -c runtime-tests/deno/deno.json runtime-tests/deno && deno test --no-lock -c runtime-tests/deno-jsx/deno.precompile.json runtime-tests/deno-jsx && deno test --no-lock -c runtime-tests/deno-jsx/deno.react-jsx.json runtime-tests/deno-jsx", |
1354706
0.21%37644
0.19%