hono 4.6.8 → 4.6.10

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 (96) hide show
  1. package/dist/adapter/cloudflare-workers/websocket.js +34 -39
  2. package/dist/adapter/deno/serve-static.js +5 -1
  3. package/dist/adapter/lambda-edge/handler.js +1 -1
  4. package/dist/cjs/adapter/cloudflare-workers/websocket.js +34 -39
  5. package/dist/cjs/adapter/deno/serve-static.js +5 -1
  6. package/dist/cjs/adapter/lambda-edge/handler.js +1 -1
  7. package/dist/cjs/client/client.js +3 -3
  8. package/dist/cjs/compose.js +4 -3
  9. package/dist/cjs/context.js +12 -9
  10. package/dist/cjs/helper/html/index.js +1 -1
  11. package/dist/cjs/helper/ssg/ssg.js +2 -2
  12. package/dist/cjs/helper/ssg/utils.js +2 -2
  13. package/dist/cjs/hono-base.js +38 -41
  14. package/dist/cjs/jsx/base.js +8 -3
  15. package/dist/cjs/jsx/constants.js +3 -0
  16. package/dist/cjs/jsx/dom/index.js +8 -2
  17. package/dist/cjs/jsx/dom/render.js +15 -12
  18. package/dist/cjs/middleware/combine/index.js +15 -9
  19. package/dist/cjs/middleware/etag/digest.js +59 -0
  20. package/dist/cjs/middleware/etag/index.js +5 -2
  21. package/dist/cjs/middleware/ip-restriction/index.js +3 -3
  22. package/dist/cjs/middleware/jsx-renderer/index.js +2 -1
  23. package/dist/cjs/middleware/logger/index.js +13 -11
  24. package/dist/cjs/middleware/timing/timing.js +5 -7
  25. package/dist/cjs/request.js +15 -14
  26. package/dist/cjs/router/linear-router/router.js +4 -4
  27. package/dist/cjs/router/pattern-router/router.js +4 -4
  28. package/dist/cjs/router/reg-exp-router/node.js +18 -18
  29. package/dist/cjs/router/reg-exp-router/router.js +13 -12
  30. package/dist/cjs/router/reg-exp-router/trie.js +6 -6
  31. package/dist/cjs/router/smart-router/router.js +12 -11
  32. package/dist/cjs/router/trie-router/node.js +53 -47
  33. package/dist/cjs/router/trie-router/router.js +5 -5
  34. package/dist/cjs/utils/color.js +1 -1
  35. package/dist/cjs/utils/cookie.js +13 -6
  36. package/dist/cjs/utils/crypto.js +0 -9
  37. package/dist/cjs/utils/jwt/jwt.js +1 -1
  38. package/dist/cjs/utils/mime.js +2 -1
  39. package/dist/cjs/utils/url.js +9 -6
  40. package/dist/client/client.js +3 -3
  41. package/dist/compose.js +4 -3
  42. package/dist/context.js +12 -9
  43. package/dist/helper/html/index.js +1 -1
  44. package/dist/helper/ssg/ssg.js +2 -2
  45. package/dist/helper/ssg/utils.js +2 -2
  46. package/dist/hono-base.js +38 -41
  47. package/dist/jsx/base.js +7 -3
  48. package/dist/jsx/constants.js +2 -0
  49. package/dist/jsx/dom/index.js +7 -1
  50. package/dist/jsx/dom/render.js +22 -13
  51. package/dist/middleware/combine/index.js +15 -9
  52. package/dist/middleware/etag/digest.js +36 -0
  53. package/dist/middleware/etag/index.js +5 -2
  54. package/dist/middleware/ip-restriction/index.js +3 -3
  55. package/dist/middleware/jsx-renderer/index.js +2 -1
  56. package/dist/middleware/logger/index.js +13 -11
  57. package/dist/middleware/timing/timing.js +5 -7
  58. package/dist/request.js +16 -15
  59. package/dist/router/linear-router/router.js +4 -4
  60. package/dist/router/pattern-router/router.js +4 -4
  61. package/dist/router/reg-exp-router/node.js +18 -18
  62. package/dist/router/reg-exp-router/router.js +13 -12
  63. package/dist/router/reg-exp-router/trie.js +6 -6
  64. package/dist/router/smart-router/router.js +12 -11
  65. package/dist/router/trie-router/node.js +53 -47
  66. package/dist/router/trie-router/router.js +5 -5
  67. package/dist/types/adapter/cloudflare-workers/websocket.d.ts +2 -2
  68. package/dist/types/adapter/deno/websocket.d.ts +1 -20
  69. package/dist/types/adapter/service-worker/index.d.ts +1 -1
  70. package/dist/types/compose.d.ts +5 -2
  71. package/dist/types/context.d.ts +1 -1
  72. package/dist/types/helper/websocket/index.d.ts +1 -1
  73. package/dist/types/hono-base.d.ts +1 -1
  74. package/dist/types/jsx/base.d.ts +5 -0
  75. package/dist/types/jsx/constants.d.ts +1 -0
  76. package/dist/types/jsx/dom/index.d.ts +6 -5
  77. package/dist/types/jsx/dom/render.d.ts +1 -0
  78. package/dist/types/middleware/etag/digest.d.ts +1 -0
  79. package/dist/types/router/linear-router/router.d.ts +0 -5
  80. package/dist/types/router/reg-exp-router/node.d.ts +0 -3
  81. package/dist/types/router/reg-exp-router/router.d.ts +0 -7
  82. package/dist/types/router/reg-exp-router/trie.d.ts +1 -4
  83. package/dist/types/router/smart-router/router.d.ts +3 -7
  84. package/dist/types/router/trie-router/node.d.ts +0 -12
  85. package/dist/types/router/trie-router/router.d.ts +0 -2
  86. package/dist/types/utils/body.d.ts +2 -2
  87. package/dist/types/utils/crypto.d.ts +2 -1
  88. package/dist/types/utils/mime.d.ts +58 -1
  89. package/dist/types/utils/url.d.ts +3 -0
  90. package/dist/utils/color.js +1 -1
  91. package/dist/utils/cookie.js +13 -6
  92. package/dist/utils/crypto.js +0 -9
  93. package/dist/utils/jwt/jwt.js +1 -1
  94. package/dist/utils/mime.js +2 -1
  95. package/dist/utils/url.js +7 -5
  96. package/package.json +20 -12
@@ -24,63 +24,60 @@ module.exports = __toCommonJS(node_exports);
24
24
  var import_router = require("../../router");
25
25
  var import_url = require("../../utils/url");
26
26
  class Node {
27
- methods;
28
- children;
29
- patterns;
30
- order = 0;
31
- params = /* @__PURE__ */ Object.create(null);
27
+ #methods;
28
+ #children;
29
+ #patterns;
30
+ #order = 0;
31
+ #params = /* @__PURE__ */ Object.create(null);
32
32
  constructor(method, handler, children) {
33
- this.children = children || /* @__PURE__ */ Object.create(null);
34
- this.methods = [];
33
+ this.#children = children || /* @__PURE__ */ Object.create(null);
34
+ this.#methods = [];
35
35
  if (method && handler) {
36
36
  const m = /* @__PURE__ */ Object.create(null);
37
37
  m[method] = { handler, possibleKeys: [], score: 0 };
38
- this.methods = [m];
38
+ this.#methods = [m];
39
39
  }
40
- this.patterns = [];
40
+ this.#patterns = [];
41
41
  }
42
42
  insert(method, path, handler) {
43
- this.order = ++this.order;
43
+ this.#order = ++this.#order;
44
44
  let curNode = this;
45
45
  const parts = (0, import_url.splitRoutingPath)(path);
46
46
  const possibleKeys = [];
47
47
  for (let i = 0, len = parts.length; i < len; i++) {
48
48
  const p = parts[i];
49
- if (Object.keys(curNode.children).includes(p)) {
50
- curNode = curNode.children[p];
49
+ if (Object.keys(curNode.#children).includes(p)) {
50
+ curNode = curNode.#children[p];
51
51
  const pattern2 = (0, import_url.getPattern)(p);
52
52
  if (pattern2) {
53
53
  possibleKeys.push(pattern2[1]);
54
54
  }
55
55
  continue;
56
56
  }
57
- curNode.children[p] = new Node();
57
+ curNode.#children[p] = new Node();
58
58
  const pattern = (0, import_url.getPattern)(p);
59
59
  if (pattern) {
60
- curNode.patterns.push(pattern);
60
+ curNode.#patterns.push(pattern);
61
61
  possibleKeys.push(pattern[1]);
62
62
  }
63
- curNode = curNode.children[p];
64
- }
65
- if (!curNode.methods.length) {
66
- curNode.methods = [];
63
+ curNode = curNode.#children[p];
67
64
  }
68
65
  const m = /* @__PURE__ */ Object.create(null);
69
66
  const handlerSet = {
70
67
  handler,
71
68
  possibleKeys: possibleKeys.filter((v, i, a) => a.indexOf(v) === i),
72
- score: this.order
69
+ score: this.#order
73
70
  };
74
71
  m[method] = handlerSet;
75
- curNode.methods.push(m);
72
+ curNode.#methods.push(m);
76
73
  return curNode;
77
74
  }
78
- gHSets(node, method, nodeParams, params) {
75
+ #getHandlerSets(node, method, nodeParams, params) {
79
76
  const handlerSets = [];
80
- for (let i = 0, len = node.methods.length; i < len; i++) {
81
- const m = node.methods[i];
77
+ for (let i = 0, len = node.#methods.length; i < len; i++) {
78
+ const m = node.#methods[i];
82
79
  const handlerSet = m[method] || m[import_router.METHOD_NAME_ALL];
83
- const processedSet = /* @__PURE__ */ Object.create(null);
80
+ const processedSet = {};
84
81
  if (handlerSet !== void 0) {
85
82
  handlerSet.params = /* @__PURE__ */ Object.create(null);
86
83
  for (let i2 = 0, len2 = handlerSet.possibleKeys.length; i2 < len2; i2++) {
@@ -96,7 +93,7 @@ class Node {
96
93
  }
97
94
  search(method, path) {
98
95
  const handlerSets = [];
99
- this.params = /* @__PURE__ */ Object.create(null);
96
+ this.#params = /* @__PURE__ */ Object.create(null);
100
97
  const curNode = this;
101
98
  let curNodes = [curNode];
102
99
  const parts = (0, import_url.splitPath)(path);
@@ -106,27 +103,36 @@ class Node {
106
103
  const tempNodes = [];
107
104
  for (let j = 0, len2 = curNodes.length; j < len2; j++) {
108
105
  const node = curNodes[j];
109
- const nextNode = node.children[part];
106
+ const nextNode = node.#children[part];
110
107
  if (nextNode) {
111
- nextNode.params = node.params;
108
+ nextNode.#params = node.#params;
112
109
  if (isLast) {
113
- if (nextNode.children["*"]) {
110
+ if (nextNode.#children["*"]) {
114
111
  handlerSets.push(
115
- ...this.gHSets(nextNode.children["*"], method, node.params, /* @__PURE__ */ Object.create(null))
112
+ ...this.#getHandlerSets(
113
+ nextNode.#children["*"],
114
+ method,
115
+ node.#params,
116
+ /* @__PURE__ */ Object.create(null)
117
+ )
116
118
  );
117
119
  }
118
- handlerSets.push(...this.gHSets(nextNode, method, node.params, /* @__PURE__ */ Object.create(null)));
120
+ handlerSets.push(
121
+ ...this.#getHandlerSets(nextNode, method, node.#params, /* @__PURE__ */ Object.create(null))
122
+ );
119
123
  } else {
120
124
  tempNodes.push(nextNode);
121
125
  }
122
126
  }
123
- for (let k = 0, len3 = node.patterns.length; k < len3; k++) {
124
- const pattern = node.patterns[k];
125
- const params = { ...node.params };
127
+ for (let k = 0, len3 = node.#patterns.length; k < len3; k++) {
128
+ const pattern = node.#patterns[k];
129
+ const params = { ...node.#params };
126
130
  if (pattern === "*") {
127
- const astNode = node.children["*"];
131
+ const astNode = node.#children["*"];
128
132
  if (astNode) {
129
- handlerSets.push(...this.gHSets(astNode, method, node.params, /* @__PURE__ */ Object.create(null)));
133
+ handlerSets.push(
134
+ ...this.#getHandlerSets(astNode, method, node.#params, /* @__PURE__ */ Object.create(null))
135
+ );
130
136
  tempNodes.push(astNode);
131
137
  }
132
138
  continue;
@@ -135,25 +141,25 @@ class Node {
135
141
  continue;
136
142
  }
137
143
  const [key, name, matcher] = pattern;
138
- const child = node.children[key];
144
+ const child = node.#children[key];
139
145
  const restPathString = parts.slice(i).join("/");
140
146
  if (matcher instanceof RegExp && matcher.test(restPathString)) {
141
147
  params[name] = restPathString;
142
- handlerSets.push(...this.gHSets(child, method, node.params, params));
148
+ handlerSets.push(...this.#getHandlerSets(child, method, node.#params, params));
143
149
  continue;
144
150
  }
145
151
  if (matcher === true || matcher.test(part)) {
146
- if (typeof key === "string") {
147
- params[name] = part;
148
- if (isLast) {
149
- handlerSets.push(...this.gHSets(child, method, params, node.params));
150
- if (child.children["*"]) {
151
- handlerSets.push(...this.gHSets(child.children["*"], method, params, node.params));
152
- }
153
- } else {
154
- child.params = params;
155
- tempNodes.push(child);
152
+ params[name] = part;
153
+ if (isLast) {
154
+ handlerSets.push(...this.#getHandlerSets(child, method, params, node.#params));
155
+ if (child.#children["*"]) {
156
+ handlerSets.push(
157
+ ...this.#getHandlerSets(child.#children["*"], method, params, node.#params)
158
+ );
156
159
  }
160
+ } else {
161
+ child.#params = params;
162
+ tempNodes.push(child);
157
163
  }
158
164
  }
159
165
  }
@@ -25,22 +25,22 @@ var import_url = require("../../utils/url");
25
25
  var import_node = require("./node");
26
26
  class TrieRouter {
27
27
  name = "TrieRouter";
28
- node;
28
+ #node;
29
29
  constructor() {
30
- this.node = new import_node.Node();
30
+ this.#node = new import_node.Node();
31
31
  }
32
32
  add(method, path, handler) {
33
33
  const results = (0, import_url.checkOptionalParameter)(path);
34
34
  if (results) {
35
35
  for (let i = 0, len = results.length; i < len; i++) {
36
- this.node.insert(method, results[i], handler);
36
+ this.#node.insert(method, results[i], handler);
37
37
  }
38
38
  return;
39
39
  }
40
- this.node.insert(method, path, handler);
40
+ this.#node.insert(method, path, handler);
41
41
  }
42
42
  match(method, path) {
43
- return this.node.search(method, path);
43
+ return this.#node.search(method, path);
44
44
  }
45
45
  }
46
46
  // Annotate the CommonJS export names for ESM import in node:
@@ -23,7 +23,7 @@ __export(color_exports, {
23
23
  module.exports = __toCommonJS(color_exports);
24
24
  function getColorEnabled() {
25
25
  const { process, Deno } = globalThis;
26
- const isNoColor = typeof Deno?.noColor === "boolean" ? Deno.noColor : typeof process !== "undefined" ? "NO_COLOR" in process?.env : false;
26
+ const isNoColor = typeof Deno?.noColor === "boolean" ? Deno.noColor : process !== void 0 ? "NO_COLOR" in process?.env : false;
27
27
  return !isNoColor;
28
28
  }
29
29
  // Annotate the CommonJS export names for ESM import in node:
@@ -50,16 +50,20 @@ const verifySignature = async (base64Signature, value, secret) => {
50
50
  const validCookieNameRegEx = /^[\w!#$%&'*.^`|~+-]+$/;
51
51
  const validCookieValueRegEx = /^[ !#-:<-[\]-~]*$/;
52
52
  const parse = (cookie, name) => {
53
+ if (name && cookie.indexOf(name) === -1) {
54
+ return {};
55
+ }
53
56
  const pairs = cookie.trim().split(";");
54
- return pairs.reduce((parsedCookie, pairStr) => {
57
+ const parsedCookie = {};
58
+ for (let pairStr of pairs) {
55
59
  pairStr = pairStr.trim();
56
60
  const valueStartPos = pairStr.indexOf("=");
57
61
  if (valueStartPos === -1) {
58
- return parsedCookie;
62
+ continue;
59
63
  }
60
64
  const cookieName = pairStr.substring(0, valueStartPos).trim();
61
65
  if (name && name !== cookieName || !validCookieNameRegEx.test(cookieName)) {
62
- return parsedCookie;
66
+ continue;
63
67
  }
64
68
  let cookieValue = pairStr.substring(valueStartPos + 1).trim();
65
69
  if (cookieValue.startsWith('"') && cookieValue.endsWith('"')) {
@@ -67,9 +71,12 @@ const parse = (cookie, name) => {
67
71
  }
68
72
  if (validCookieValueRegEx.test(cookieValue)) {
69
73
  parsedCookie[cookieName] = (0, import_url.decodeURIComponent_)(cookieValue);
74
+ if (name) {
75
+ break;
76
+ }
70
77
  }
71
- return parsedCookie;
72
- }, {});
78
+ }
79
+ return parsedCookie;
73
80
  };
74
81
  const parseSigned = async (cookie, secret, name) => {
75
82
  const parsedCookie = {};
@@ -111,7 +118,7 @@ const _serialize = (name, value, opt = {}) => {
111
118
  "Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration."
112
119
  );
113
120
  }
114
- cookie += `; Max-Age=${Math.floor(opt.maxAge)}`;
121
+ cookie += `; Max-Age=${opt.maxAge | 0}`;
115
122
  }
116
123
  if (opt.domain && opt.prefix !== "host") {
117
124
  cookie += `; Domain=${opt.domain}`;
@@ -41,15 +41,6 @@ const md5 = async (data) => {
41
41
  };
42
42
  const createHash = async (data, algorithm) => {
43
43
  let sourceBuffer;
44
- if (data instanceof ReadableStream) {
45
- let body = "";
46
- const reader = data.getReader();
47
- await reader?.read().then(async (chuck) => {
48
- const value = await createHash(chuck.value || "", algorithm);
49
- body += value;
50
- });
51
- return body;
52
- }
53
44
  if (ArrayBuffer.isView(data) || data instanceof ArrayBuffer) {
54
45
  sourceBuffer = data;
55
46
  } else {
@@ -56,7 +56,7 @@ const verify = async (token, publicKey, alg = "HS256") => {
56
56
  if (!isTokenHeader(header)) {
57
57
  throw new import_types.JwtHeaderInvalid(header);
58
58
  }
59
- const now = Math.floor(Date.now() / 1e3);
59
+ const now = Date.now() / 1e3 | 0;
60
60
  if (payload.nbf && payload.nbf > now) {
61
61
  throw new import_types.JwtTokenNotBefore(token);
62
62
  }
@@ -42,7 +42,7 @@ const getExtension = (mimeType) => {
42
42
  }
43
43
  }
44
44
  };
45
- const baseMimes = {
45
+ const _baseMimes = {
46
46
  aac: "audio/aac",
47
47
  avi: "video/x-msvideo",
48
48
  avif: "image/avif",
@@ -99,6 +99,7 @@ const baseMimes = {
99
99
  gltf: "model/gltf+json",
100
100
  glb: "model/gltf-binary"
101
101
  };
102
+ const baseMimes = _baseMimes;
102
103
  // Annotate the CommonJS export names for ESM import in node:
103
104
  0 && (module.exports = {
104
105
  getExtension,
@@ -28,7 +28,8 @@ __export(url_exports, {
28
28
  getQueryStrings: () => getQueryStrings,
29
29
  mergePath: () => mergePath,
30
30
  splitPath: () => splitPath,
31
- splitRoutingPath: () => splitRoutingPath
31
+ splitRoutingPath: () => splitRoutingPath,
32
+ tryDecode: () => tryDecode
32
33
  });
33
34
  module.exports = __toCommonJS(url_exports);
34
35
  const splitPath = (path) => {
@@ -82,19 +83,20 @@ const getPattern = (label) => {
82
83
  }
83
84
  return null;
84
85
  };
85
- const tryDecodeURI = (str) => {
86
+ const tryDecode = (str, decoder) => {
86
87
  try {
87
- return decodeURI(str);
88
+ return decoder(str);
88
89
  } catch {
89
90
  return str.replace(/(?:%[0-9A-Fa-f]{2})+/g, (match) => {
90
91
  try {
91
- return decodeURI(match);
92
+ return decoder(match);
92
93
  } catch {
93
94
  return match;
94
95
  }
95
96
  });
96
97
  }
97
98
  };
99
+ const tryDecodeURI = (str) => tryDecode(str, decodeURI);
98
100
  const getPath = (request) => {
99
101
  const url = request.url;
100
102
  const start = url.indexOf("/", 8);
@@ -175,7 +177,7 @@ const _decodeURI = (value) => {
175
177
  if (value.indexOf("+") !== -1) {
176
178
  value = value.replace(/\+/g, " ");
177
179
  }
178
- return /%/.test(value) ? decodeURIComponent_(value) : value;
180
+ return value.indexOf("%") !== -1 ? decodeURIComponent_(value) : value;
179
181
  };
180
182
  const _getQueryParam = (url, key, multiple) => {
181
183
  let encoded;
@@ -258,5 +260,6 @@ const decodeURIComponent_ = decodeURIComponent;
258
260
  getQueryStrings,
259
261
  mergePath,
260
262
  splitPath,
261
- splitRoutingPath
263
+ splitRoutingPath,
264
+ tryDecode
262
265
  });
@@ -65,8 +65,8 @@ var ClientRequestImpl = class {
65
65
  }
66
66
  let methodUpperCase = this.method.toUpperCase();
67
67
  const headerValues = {
68
- ...args?.header ?? {},
69
- ...typeof opt?.headers === "function" ? await opt.headers() : opt?.headers ? opt.headers : {}
68
+ ...args?.header,
69
+ ...typeof opt?.headers === "function" ? await opt.headers() : opt?.headers
70
70
  };
71
71
  if (args?.cookie) {
72
72
  const cookies = [];
@@ -157,7 +157,7 @@ var hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
157
157
  const req = new ClientRequestImpl(url, method);
158
158
  if (method) {
159
159
  options ??= {};
160
- const args = deepMerge(options, { ...opts.args[1] ?? {} });
160
+ const args = deepMerge(options, { ...opts.args[1] });
161
161
  return req.fetch(opts.args[0], args);
162
162
  }
163
163
  return req;
package/dist/compose.js CHANGED
@@ -3,6 +3,7 @@ import { Context } from "./context.js";
3
3
  var compose = (middleware, onError, onNotFound) => {
4
4
  return (context, next) => {
5
5
  let index = -1;
6
+ const isContext = context instanceof Context;
6
7
  return dispatch(0);
7
8
  async function dispatch(i) {
8
9
  if (i <= index) {
@@ -14,14 +15,14 @@ var compose = (middleware, onError, onNotFound) => {
14
15
  let handler;
15
16
  if (middleware[i]) {
16
17
  handler = middleware[i][0][0];
17
- if (context instanceof Context) {
18
+ if (isContext) {
18
19
  context.req.routeIndex = i;
19
20
  }
20
21
  } else {
21
22
  handler = i === middleware.length && next || void 0;
22
23
  }
23
24
  if (!handler) {
24
- if (context instanceof Context && context.finalized === false && onNotFound) {
25
+ if (isContext && context.finalized === false && onNotFound) {
25
26
  res = await onNotFound(context);
26
27
  }
27
28
  } else {
@@ -30,7 +31,7 @@ var compose = (middleware, onError, onNotFound) => {
30
31
  return dispatch(i + 1);
31
32
  });
32
33
  } catch (err) {
33
- if (err instanceof Error && context instanceof Context && onError) {
34
+ if (err instanceof Error && isContext && onError) {
34
35
  context.error = err;
35
36
  res = await onError(err, context);
36
37
  isError = true;
package/dist/context.js CHANGED
@@ -3,7 +3,9 @@ import { HonoRequest } from "./request.js";
3
3
  import { HtmlEscapedCallbackPhase, resolveCallback } from "./utils/html.js";
4
4
  var TEXT_PLAIN = "text/plain; charset=UTF-8";
5
5
  var setHeaders = (headers, map = {}) => {
6
- Object.entries(map).forEach(([key, value]) => headers.set(key, value));
6
+ for (const key of Object.keys(map)) {
7
+ headers.set(key, map[key]);
8
+ }
7
9
  return headers;
8
10
  };
9
11
  var Context = class {
@@ -150,7 +152,7 @@ var Context = class {
150
152
  }
151
153
  return Object.fromEntries(this.#var);
152
154
  }
153
- newResponse = (data, arg, headers) => {
155
+ #newResponse(data, arg, headers) {
154
156
  if (this.#isFresh && !headers && !arg && this.#status === 200) {
155
157
  return new Response(data, {
156
158
  headers: this.#preparedHeaders
@@ -202,9 +204,10 @@ var Context = class {
202
204
  status,
203
205
  headers: this.#headers
204
206
  });
205
- };
207
+ }
208
+ newResponse = (...args) => this.#newResponse(...args);
206
209
  body = (data, arg, headers) => {
207
- return typeof arg === "number" ? this.newResponse(data, arg, headers) : this.newResponse(data, arg);
210
+ return typeof arg === "number" ? this.#newResponse(data, arg, headers) : this.#newResponse(data, arg);
208
211
  };
209
212
  text = (text, arg, headers) => {
210
213
  if (!this.#preparedHeaders) {
@@ -214,27 +217,27 @@ var Context = class {
214
217
  this.#preparedHeaders = {};
215
218
  }
216
219
  this.#preparedHeaders["content-type"] = TEXT_PLAIN;
217
- return typeof arg === "number" ? this.newResponse(text, arg, headers) : this.newResponse(text, arg);
220
+ return typeof arg === "number" ? this.#newResponse(text, arg, headers) : this.#newResponse(text, arg);
218
221
  };
219
222
  json = (object, arg, headers) => {
220
223
  const body = JSON.stringify(object);
221
224
  this.#preparedHeaders ??= {};
222
225
  this.#preparedHeaders["content-type"] = "application/json; charset=UTF-8";
223
- return typeof arg === "number" ? this.newResponse(body, arg, headers) : this.newResponse(body, arg);
226
+ return typeof arg === "number" ? this.#newResponse(body, arg, headers) : this.#newResponse(body, arg);
224
227
  };
225
228
  html = (html, arg, headers) => {
226
229
  this.#preparedHeaders ??= {};
227
230
  this.#preparedHeaders["content-type"] = "text/html; charset=UTF-8";
228
231
  if (typeof html === "object") {
229
232
  return resolveCallback(html, HtmlEscapedCallbackPhase.Stringify, false, {}).then((html2) => {
230
- return typeof arg === "number" ? this.newResponse(html2, arg, headers) : this.newResponse(html2, arg);
233
+ return typeof arg === "number" ? this.#newResponse(html2, arg, headers) : this.#newResponse(html2, arg);
231
234
  });
232
235
  }
233
- return typeof arg === "number" ? this.newResponse(html, arg, headers) : this.newResponse(html, arg);
236
+ return typeof arg === "number" ? this.#newResponse(html, arg, headers) : this.#newResponse(html, arg);
234
237
  };
235
238
  redirect = (location, status) => {
236
239
  this.#headers ??= new Headers();
237
- this.#headers.set("Location", location);
240
+ this.#headers.set("Location", String(location));
238
241
  return this.newResponse(null, status ?? 302);
239
242
  };
240
243
  notFound = () => {
@@ -4,7 +4,7 @@ var html = (strings, ...values) => {
4
4
  const buffer = [""];
5
5
  for (let i = 0, len = strings.length - 1; i < len; i++) {
6
6
  buffer[0] += strings[i];
7
- const children = values[i] instanceof Array ? values[i].flat(Infinity) : [values[i]];
7
+ const children = Array.isArray(values[i]) ? values[i].flat(Infinity) : [values[i]];
8
8
  for (let i2 = 0, len2 = children.length; i2 < len2; i2++) {
9
9
  const child = children[i2];
10
10
  if (typeof child === "string") {
@@ -233,8 +233,8 @@ var toSSG = async (app, fs, options) => {
233
233
  result = { success: false, files: [], error: errorObj };
234
234
  }
235
235
  if (options?.afterGenerateHook) {
236
- const conbinedAfterGenerateHooks = combineAfterGenerateHooks(options?.afterGenerateHook);
237
- await conbinedAfterGenerateHooks(result);
236
+ const combinedAfterGenerateHooks = combineAfterGenerateHooks(options?.afterGenerateHook);
237
+ await combinedAfterGenerateHooks(result);
238
238
  }
239
239
  return result;
240
240
  };
@@ -2,8 +2,8 @@
2
2
  import { METHOD_NAME_ALL } from "../../router.js";
3
3
  import { findTargetHandler, isMiddleware } from "../../utils/handler.js";
4
4
  var dirname = (path) => {
5
- const splittedPath = path.split(/[\/\\]/);
6
- return splittedPath.slice(0, -1).join("/");
5
+ const separatedPath = path.split(/[\/\\]/);
6
+ return separatedPath.slice(0, -1).join("/");
7
7
  };
8
8
  var normalizePath = (path) => {
9
9
  return path.replace(/(\\)/g, "/").replace(/\/$/g, "");