hono 4.8.0 → 4.8.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.
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,10 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
19
  var color_exports = {};
26
20
  __export(color_exports, {
@@ -35,7 +29,14 @@ function getColorEnabled() {
35
29
  }
36
30
  async function getColorEnabledAsync() {
37
31
  const { navigator } = globalThis;
38
- const isNoColor = navigator !== void 0 && navigator.userAgent === "Cloudflare-Workers" ? "NO_COLOR" in ((await import("cloudflare:workers")).env ?? {}) : !getColorEnabled();
32
+ const cfWorkers = "cloudflare:workers";
33
+ const isNoColor = navigator !== void 0 && navigator.userAgent === "Cloudflare-Workers" ? await (async () => {
34
+ try {
35
+ return "NO_COLOR" in ((await import(cfWorkers)).env ?? {});
36
+ } catch {
37
+ return false;
38
+ }
39
+ })() : !getColorEnabled();
39
40
  return !isNoColor;
40
41
  }
41
42
  // Annotate the CommonJS export names for ESM import in node:
@@ -6,7 +6,7 @@ import type { Context } from '../../context';
6
6
  export type Runtime = "node" | "deno" | "bun" | "workerd" | "fastly" | "edge-light" | "other";
7
7
  export declare const env: <T extends Record<string, unknown>, C extends Context = Context<{
8
8
  Bindings: T;
9
- }, any, {}>>(c: T extends Record<string, unknown> ? Context : C, runtime?: Runtime) => T & C["env"];
9
+ }>>(c: T extends Record<string, unknown> ? Context : C, runtime?: Runtime) => T & C["env"];
10
10
  export declare const knownUserAgents: Partial<Record<Runtime, string>>;
11
11
  export declare const getRuntimeKey: () => Runtime;
12
12
  export declare const checkUserAgentEquals: (platform: string) => boolean;
@@ -37,7 +37,7 @@ type BearerAuthOptions = {
37
37
  * @param {string} [options.headerName=Authorization] - The header name.
38
38
  * @param {Function} [options.hashFunction] - A function to handle hashing for safe comparison of authentication tokens.
39
39
  * @param {string | object | MessageFunction} [options.noAuthenticationHeaderMessage="Unauthorized"] - The no authentication header message.
40
- * @param {string | object | MessageFunction} [options.invalidAuthenticationHeaderMeasage="Bad Request"] - The invalid authentication header message.
40
+ * @param {string | object | MessageFunction} [options.invalidAuthenticationHeaderMessage="Bad Request"] - The invalid authentication header message.
41
41
  * @param {string | object | MessageFunction} [options.invalidTokenMessage="Unauthorized"] - The invalid token message.
42
42
  * @returns {MiddlewareHandler} The middleware handler function.
43
43
  * @throws {Error} If neither "token" nor "verifyToken" options are provided.
@@ -1,3 +1,4 @@
1
+ import { GET_MATCH_RESULT } from './request/constants';
1
2
  import type { Result } from './router';
2
3
  import type { Input, InputToDataByTarget, ParamKeyToRecord, ParamKeys, RemoveQuestion, RouterRoute, ValidationTargets } from './types';
3
4
  import type { BodyData, ParseBodyOptions } from './utils/body';
@@ -14,6 +15,10 @@ type BodyCache = Partial<Body & {
14
15
  parsedBody: BodyData;
15
16
  }>;
16
17
  export declare class HonoRequest<P extends string = "/", I extends Input["out"] = {}> {
18
+ [GET_MATCH_RESULT]: Result<[
19
+ unknown,
20
+ RouterRoute
21
+ ]>;
17
22
  /**
18
23
  * `.raw` can get the raw Request object.
19
24
  *
@@ -6,7 +6,14 @@ function getColorEnabled() {
6
6
  }
7
7
  async function getColorEnabledAsync() {
8
8
  const { navigator } = globalThis;
9
- const isNoColor = navigator !== void 0 && navigator.userAgent === "Cloudflare-Workers" ? "NO_COLOR" in ((await import("cloudflare:workers")).env ?? {}) : !getColorEnabled();
9
+ const cfWorkers = "cloudflare:workers";
10
+ const isNoColor = navigator !== void 0 && navigator.userAgent === "Cloudflare-Workers" ? await (async () => {
11
+ try {
12
+ return "NO_COLOR" in ((await import(cfWorkers)).env ?? {});
13
+ } catch {
14
+ return false;
15
+ }
16
+ })() : !getColorEnabled();
10
17
  return !isNoColor;
11
18
  }
12
19
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "4.8.0",
3
+ "version": "4.8.2",
4
4
  "description": "Web framework built on Web Standards",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",
@@ -13,7 +13,7 @@
13
13
  "test": "tsc --noEmit && vitest --run && vitest -c .vitest.config/jsx-runtime-default.ts --run && vitest -c .vitest.config/jsx-runtime-dom.ts --run",
14
14
  "test:watch": "vitest --watch",
15
15
  "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",
16
- "test:bun": "bun test --jsx-import-source ../../src/jsx runtime-tests/bun/index.test.tsx",
16
+ "test:bun": "bun test --jsx-import-source ../../src/jsx runtime-tests/bun/*",
17
17
  "test:fastly": "vitest --run --config ./runtime-tests/fastly/vitest.config.ts",
18
18
  "test:node": "vitest --run --config ./runtime-tests/node/vitest.config.ts",
19
19
  "test:workerd": "vitest --run --config ./runtime-tests/workerd/vitest.config.ts",