hono 4.8.3 → 4.8.4

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.
@@ -144,6 +144,7 @@ const hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
144
144
  result = result + "?" + (0, import_utils.buildSearchParams)(opts.args[0].query).toString();
145
145
  }
146
146
  }
147
+ result = (0, import_utils.removeIndexString)(result);
147
148
  return new URL(result);
148
149
  }
149
150
  if (method === "ws") {
@@ -27,6 +27,7 @@ __export(middleware_exports, {
27
27
  ssgParams: () => ssgParams
28
28
  });
29
29
  module.exports = __toCommonJS(middleware_exports);
30
+ var import_utils = require("./utils");
30
31
  const SSG_CONTEXT = "HONO_SSG_CONTEXT";
31
32
  const X_HONO_DISABLE_SSG_HEADER_KEY = "x-hono-disable-ssg";
32
33
  const SSG_DISABLED_RESPONSE = (() => {
@@ -40,8 +41,11 @@ const SSG_DISABLED_RESPONSE = (() => {
40
41
  }
41
42
  })();
42
43
  const ssgParams = (params) => async (c, next) => {
43
- ;
44
- c.req.raw.ssgParams = Array.isArray(params) ? params : await params(c);
44
+ if ((0, import_utils.isDynamicRoute)(c.req.path)) {
45
+ ;
46
+ c.req.raw.ssgParams = Array.isArray(params) ? params : await params(c);
47
+ return c.notFound();
48
+ }
45
49
  await next();
46
50
  };
47
51
  const isSSGContext = (c) => !!c.env?.[SSG_CONTEXT];
@@ -140,7 +140,7 @@ const fetchRoutesContent = function* (app, beforeRequestHook, afterResponseHook,
140
140
  }
141
141
  await pool.run(() => app.fetch(forGetInfoURLRequest));
142
142
  if (!forGetInfoURLRequest.ssgParams) {
143
- if (isDynamicRoute(route.path)) {
143
+ if ((0, import_utils2.isDynamicRoute)(route.path)) {
144
144
  resolveGetInfo(void 0);
145
145
  return;
146
146
  }
@@ -193,9 +193,6 @@ const fetchRoutesContent = function* (app, beforeRequestHook, afterResponseHook,
193
193
  });
194
194
  }
195
195
  };
196
- const isDynamicRoute = (path) => {
197
- return path.split("/").some((segment) => segment.startsWith(":") || segment.includes("*"));
198
- };
199
196
  const createdDirs = /* @__PURE__ */ new Set();
200
197
  const saveContentToFile = async (data, fsModule, outDir, extensionMap) => {
201
198
  const awaitedData = await data;
@@ -20,6 +20,7 @@ var utils_exports = {};
20
20
  __export(utils_exports, {
21
21
  dirname: () => dirname,
22
22
  filterStaticGenerateRoutes: () => filterStaticGenerateRoutes,
23
+ isDynamicRoute: () => isDynamicRoute,
23
24
  joinPaths: () => joinPaths
24
25
  });
25
26
  module.exports = __toCommonJS(utils_exports);
@@ -72,9 +73,13 @@ const filterStaticGenerateRoutes = (hono) => {
72
73
  return acc;
73
74
  }, []);
74
75
  };
76
+ const isDynamicRoute = (path) => {
77
+ return path.split("/").some((segment) => segment.startsWith(":") || segment.includes("*"));
78
+ };
75
79
  // Annotate the CommonJS export names for ESM import in node:
76
80
  0 && (module.exports = {
77
81
  dirname,
78
82
  filterStaticGenerateRoutes,
83
+ isDynamicRoute,
79
84
  joinPaths
80
85
  });
@@ -335,10 +335,17 @@ const isValidElement = (element) => {
335
335
  return !!(element && typeof element === "object" && "tag" in element && "props" in element);
336
336
  };
337
337
  const cloneElement = (element, props, ...children) => {
338
+ let childrenToClone;
339
+ if (children.length > 0) {
340
+ childrenToClone = children;
341
+ } else {
342
+ const c = element.props.children;
343
+ childrenToClone = Array.isArray(c) ? c : [c];
344
+ }
338
345
  return jsx(
339
346
  element.tag,
340
347
  { ...element.props, ...props },
341
- ...children
348
+ ...childrenToClone
342
349
  );
343
350
  };
344
351
  const reactAPICompatVersion = "19.0.0-hono-jsx";
@@ -97,7 +97,7 @@ class HonoRequest {
97
97
  return bodyCache[key] = raw[key]();
98
98
  };
99
99
  json() {
100
- return this.#cachedBody("json");
100
+ return this.#cachedBody("text").then((text) => JSON.parse(text));
101
101
  }
102
102
  text() {
103
103
  return this.#cachedBody("text");
@@ -129,6 +129,7 @@ var hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
129
129
  result = result + "?" + buildSearchParams(opts.args[0].query).toString();
130
130
  }
131
131
  }
132
+ result = removeIndexString(result);
132
133
  return new URL(result);
133
134
  }
134
135
  if (method === "ws") {
@@ -1,4 +1,5 @@
1
1
  // src/helper/ssg/middleware.ts
2
+ import { isDynamicRoute } from "./utils.js";
2
3
  var SSG_CONTEXT = "HONO_SSG_CONTEXT";
3
4
  var X_HONO_DISABLE_SSG_HEADER_KEY = "x-hono-disable-ssg";
4
5
  var SSG_DISABLED_RESPONSE = (() => {
@@ -12,8 +13,11 @@ var SSG_DISABLED_RESPONSE = (() => {
12
13
  }
13
14
  })();
14
15
  var ssgParams = (params) => async (c, next) => {
15
- ;
16
- c.req.raw.ssgParams = Array.isArray(params) ? params : await params(c);
16
+ if (isDynamicRoute(c.req.path)) {
17
+ ;
18
+ c.req.raw.ssgParams = Array.isArray(params) ? params : await params(c);
19
+ return c.notFound();
20
+ }
17
21
  await next();
18
22
  };
19
23
  var isSSGContext = (c) => !!c.env?.[SSG_CONTEXT];
@@ -3,7 +3,7 @@ import { replaceUrlParam } from "../../client/utils.js";
3
3
  import { createPool } from "../../utils/concurrent.js";
4
4
  import { getExtension } from "../../utils/mime.js";
5
5
  import { SSG_CONTEXT, X_HONO_DISABLE_SSG_HEADER_KEY } from "./middleware.js";
6
- import { dirname, filterStaticGenerateRoutes, joinPaths } from "./utils.js";
6
+ import { dirname, filterStaticGenerateRoutes, isDynamicRoute, joinPaths } from "./utils.js";
7
7
  var DEFAULT_CONCURRENCY = 2;
8
8
  var DEFAULT_CONTENT_TYPE = "text/plain";
9
9
  var DEFAULT_OUTPUT_DIR = "./static";
@@ -164,9 +164,6 @@ var fetchRoutesContent = function* (app, beforeRequestHook, afterResponseHook, c
164
164
  });
165
165
  }
166
166
  };
167
- var isDynamicRoute = (path) => {
168
- return path.split("/").some((segment) => segment.startsWith(":") || segment.includes("*"));
169
- };
170
167
  var createdDirs = /* @__PURE__ */ new Set();
171
168
  var saveContentToFile = async (data, fsModule, outDir, extensionMap) => {
172
169
  const awaitedData = await data;
@@ -48,8 +48,12 @@ var filterStaticGenerateRoutes = (hono) => {
48
48
  return acc;
49
49
  }, []);
50
50
  };
51
+ var isDynamicRoute = (path) => {
52
+ return path.split("/").some((segment) => segment.startsWith(":") || segment.includes("*"));
53
+ };
51
54
  export {
52
55
  dirname,
53
56
  filterStaticGenerateRoutes,
57
+ isDynamicRoute,
54
58
  joinPaths
55
59
  };
package/dist/jsx/base.js CHANGED
@@ -296,10 +296,17 @@ var isValidElement = (element) => {
296
296
  return !!(element && typeof element === "object" && "tag" in element && "props" in element);
297
297
  };
298
298
  var cloneElement = (element, props, ...children) => {
299
+ let childrenToClone;
300
+ if (children.length > 0) {
301
+ childrenToClone = children;
302
+ } else {
303
+ const c = element.props.children;
304
+ childrenToClone = Array.isArray(c) ? c : [c];
305
+ }
299
306
  return jsx(
300
307
  element.tag,
301
308
  { ...element.props, ...props },
302
- ...children
309
+ ...childrenToClone
303
310
  );
304
311
  };
305
312
  var reactAPICompatVersion = "19.0.0-hono-jsx";
package/dist/request.js CHANGED
@@ -75,7 +75,7 @@ var HonoRequest = class {
75
75
  return bodyCache[key] = raw[key]();
76
76
  };
77
77
  json() {
78
- return this.#cachedBody("json");
78
+ return this.#cachedBody("text").then((text) => JSON.parse(text));
79
79
  }
80
80
  text() {
81
81
  return this.#cachedBody("text");
@@ -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
- }>>(c: T extends Record<string, unknown> ? Context : C, runtime?: Runtime) => T & C["env"];
9
+ }, any, {}>>(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;
@@ -11,4 +11,5 @@ interface FilterStaticGenerateRouteData {
11
11
  path: string;
12
12
  }
13
13
  export declare const filterStaticGenerateRoutes: <E extends Env>(hono: Hono<E>) => FilterStaticGenerateRouteData[];
14
+ export declare const isDynamicRoute: (path: string) => boolean;
14
15
  export {};
@@ -1,4 +1,3 @@
1
- import { GET_MATCH_RESULT } from './request/constants';
2
1
  import type { Result } from './router';
3
2
  import type { Input, InputToDataByTarget, ParamKeyToRecord, ParamKeys, RemoveQuestion, RouterRoute, ValidationTargets } from './types';
4
3
  import type { BodyData, ParseBodyOptions } from './utils/body';
@@ -15,10 +14,6 @@ type BodyCache = Partial<Body & {
15
14
  parsedBody: BodyData;
16
15
  }>;
17
16
  export declare class HonoRequest<P extends string = "/", I extends Input["out"] = {}> {
18
- [GET_MATCH_RESULT]: Result<[
19
- unknown,
20
- RouterRoute
21
- ]>;
22
17
  /**
23
18
  * `.raw` can get the raw Request object.
24
19
  *
@@ -26,7 +26,6 @@ export type CookieOptions = {
26
26
  maxAge?: number;
27
27
  path?: string;
28
28
  secure?: boolean;
29
- signingSecret?: string;
30
29
  sameSite?: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
31
30
  partitioned?: boolean;
32
31
  priority?: "Low" | "Medium" | "High";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "4.8.3",
3
+ "version": "4.8.4",
4
4
  "description": "Web framework built on Web Standards",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",