hono 3.8.1 → 3.8.3

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.
@@ -21,7 +21,6 @@ __export(context_exports, {
21
21
  Context: () => Context
22
22
  });
23
23
  module.exports = __toCommonJS(context_exports);
24
- var import_types = require("./types");
25
24
  var import_cookie = require("./utils/cookie");
26
25
  var import_stream = require("./utils/stream");
27
26
  const TEXT_PLAIN = "text/plain; charset=UTF-8";
@@ -200,7 +199,7 @@ class Context {
200
199
  }
201
200
  }
202
201
  get event() {
203
- if (this._exCtx instanceof import_types.FetchEvent) {
202
+ if (this._exCtx && "respondWith" in this._exCtx) {
204
203
  return this._exCtx;
205
204
  } else {
206
205
  throw Error("This context has no FetchEvent");
@@ -109,7 +109,10 @@ class JSXNode {
109
109
  const key = propsKeys[i];
110
110
  const v = props[key];
111
111
  if (key === "style" && typeof v === "object") {
112
- const styles = Object.keys(v).map((k) => `${k}:${v[k]}`).join(";").replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
112
+ const styles = Object.keys(v).map((k) => {
113
+ const property = k.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
114
+ return `${property}:${v[k]}`;
115
+ }).join(";");
113
116
  buffer[0] += ` style="${styles}"`;
114
117
  } else if (typeof v === "string") {
115
118
  buffer[0] += ` ${key}="`;
package/dist/cjs/types.js CHANGED
@@ -18,16 +18,12 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var types_exports = {};
20
20
  __export(types_exports, {
21
- FetchEvent: () => FetchEvent,
22
21
  FetchEventLike: () => FetchEventLike
23
22
  });
24
23
  module.exports = __toCommonJS(types_exports);
25
24
  class FetchEventLike {
26
25
  }
27
- class FetchEvent extends FetchEventLike {
28
- }
29
26
  // Annotate the CommonJS export names for ESM import in node:
30
27
  0 && (module.exports = {
31
- FetchEvent,
32
28
  FetchEventLike
33
29
  });
package/dist/context.js CHANGED
@@ -1,5 +1,4 @@
1
1
  // src/context.ts
2
- import { FetchEvent } from "./types.js";
3
2
  import { serialize } from "./utils/cookie.js";
4
3
  import { StreamingApi } from "./utils/stream.js";
5
4
  var TEXT_PLAIN = "text/plain; charset=UTF-8";
@@ -178,7 +177,7 @@ var Context = class {
178
177
  }
179
178
  }
180
179
  get event() {
181
- if (this._exCtx instanceof FetchEvent) {
180
+ if (this._exCtx && "respondWith" in this._exCtx) {
182
181
  return this._exCtx;
183
182
  } else {
184
183
  throw Error("This context has no FetchEvent");
package/dist/jsx/index.js CHANGED
@@ -82,7 +82,10 @@ var JSXNode = class {
82
82
  const key = propsKeys[i];
83
83
  const v = props[key];
84
84
  if (key === "style" && typeof v === "object") {
85
- const styles = Object.keys(v).map((k) => `${k}:${v[k]}`).join(";").replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
85
+ const styles = Object.keys(v).map((k) => {
86
+ const property = k.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
87
+ return `${property}:${v[k]}`;
88
+ }).join(";");
86
89
  buffer[0] += ` style="${styles}"`;
87
90
  } else if (typeof v === "string") {
88
91
  buffer[0] += ` ${key}="`;
@@ -1,3 +1,3 @@
1
1
  import type { Hono } from '../../hono';
2
- import type { FetchEvent } from '../../types';
3
- export declare const handle: (app: Hono<any, any, any>) => (req: Request, requestContext: FetchEvent) => Response | Promise<Response>;
2
+ import type { FetchEventLike } from '../../types';
3
+ export declare const handle: (app: Hono<any, any, any>) => (req: Request, requestContext: FetchEventLike) => Response | Promise<Response>;
@@ -13,7 +13,7 @@ declare type ClientRequest<S extends Schema> = {
13
13
  [M in keyof S]: S[M] extends {
14
14
  input: infer R;
15
15
  output: infer O;
16
- } ? RemoveBlankRecord<R> extends never ? (args?: {}, options?: ClientRequestOptions) => Promise<ClientResponse<O>> : (args: R, options?: ClientRequestOptions) => Promise<ClientResponse<O>> : never;
16
+ } ? RemoveBlankRecord<Required<R>> extends never ? (args?: {}, options?: ClientRequestOptions) => Promise<ClientResponse<O>> : (args: R, options?: ClientRequestOptions) => Promise<ClientResponse<O>> : never;
17
17
  } & {
18
18
  $url: () => URL;
19
19
  };
@@ -1,6 +1,5 @@
1
1
  import type { HonoRequest } from './request';
2
- import type { Env, NotFoundHandler, Input, TypedResponse } from './types';
3
- import { FetchEvent } from './types';
2
+ import type { Env, FetchEventLike, NotFoundHandler, Input, TypedResponse } from './types';
4
3
  import type { CookieOptions } from './utils/cookie';
5
4
  import type { StatusCode } from './utils/http-status';
6
5
  import { StreamingApi } from './utils/stream';
@@ -52,7 +51,7 @@ interface HTMLRespond {
52
51
  }
53
52
  declare type ContextOptions<E extends Env> = {
54
53
  env: E['Bindings'];
55
- executionCtx?: FetchEvent | ExecutionContext | undefined;
54
+ executionCtx?: FetchEventLike | ExecutionContext | undefined;
56
55
  notFoundHandler?: NotFoundHandler<E>;
57
56
  };
58
57
  export declare class Context<E extends Env = any, P extends string = any, I extends Input = {}> {
@@ -70,7 +69,7 @@ export declare class Context<E extends Env = any, P extends string = any, I exte
70
69
  private _renderer;
71
70
  private notFoundHandler;
72
71
  constructor(req: HonoRequest<P, I['out']>, options?: ContextOptions<E>);
73
- get event(): FetchEvent;
72
+ get event(): FetchEventLike;
74
73
  get executionCtx(): ExecutionContext;
75
74
  get res(): Response;
76
75
  set res(_res: Response | undefined);
@@ -2,7 +2,7 @@ import type { Context, Renderer } from '../../context';
2
2
  import type { FC } from '../../jsx';
3
3
  import type { Env, Input, MiddlewareHandler } from '../../types';
4
4
  export declare const RequestContext: import("../../jsx").Context<Context<any, any, {}> | null>;
5
- declare type PropsForRenderer = [...Parameters<Renderer>] extends [unknown, infer Props] ? Props : unknown;
5
+ declare type PropsForRenderer = [...Required<Parameters<Renderer>>] extends [unknown, infer Props] ? Props : unknown;
6
6
  export declare const jsxRenderer: (component?: FC<PropsForRenderer>) => MiddlewareHandler;
7
7
  export declare const useRequestContext: <E extends Env = any, P extends string = any, I extends Input = {}>() => Context<E, P, I>;
8
8
  export {};
@@ -146,6 +146,4 @@ export declare abstract class FetchEventLike {
146
146
  abstract passThroughOnException(): void;
147
147
  abstract waitUntil(promise: Promise<void>): void;
148
148
  }
149
- export declare abstract class FetchEvent extends FetchEventLike {
150
- }
151
149
  export {};
package/dist/types.js CHANGED
@@ -1,9 +1,6 @@
1
1
  // src/types.ts
2
2
  var FetchEventLike = class {
3
3
  };
4
- var FetchEvent = class extends FetchEventLike {
5
- };
6
4
  export {
7
- FetchEvent,
8
5
  FetchEventLike
9
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "3.8.1",
3
+ "version": "3.8.3",
4
4
  "description": "Ultrafast web framework for the Edges",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",
@@ -39,6 +39,11 @@
39
39
  "import": "./dist/index.js",
40
40
  "require": "./dist/cjs/index.js"
41
41
  },
42
+ "./hono-base": {
43
+ "types": "./dist/types/hono-base.d.ts",
44
+ "import": "./dist/hono-base.js",
45
+ "require": "./dist/cjs/hono-base.js"
46
+ },
42
47
  "./tiny": {
43
48
  "types": "./dist/types/preset/tiny.d.ts",
44
49
  "import": "./dist/preset/tiny.js",