hono 4.13.13 → 5.0.0-rc.1

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 (516) hide show
  1. package/README.md +2 -2
  2. package/dist/client/fetch-result-please.js +0 -22
  3. package/dist/client/utils.js +0 -7
  4. package/dist/{types/compose.d.ts → compose.d.ts} +5 -3
  5. package/dist/compose.js +18 -31
  6. package/dist/context/constants.d.ts +3 -0
  7. package/dist/context/constants.js +4 -0
  8. package/dist/{types/context.d.ts → context.d.ts} +56 -15
  9. package/dist/context.js +83 -277
  10. package/dist/helper/accepts/accepts.js +0 -13
  11. package/dist/helper/css/common.js +0 -10
  12. package/dist/helper/css/index.js +0 -38
  13. package/dist/{types/helper → helper}/dev/index.d.ts +5 -2
  14. package/dist/helper/dev/index.js +3 -3
  15. package/dist/helper/factory/define-handler.d.ts +150 -0
  16. package/dist/helper/factory/define-handler.js +117 -0
  17. package/dist/{types/helper → helper}/factory/index.d.ts +30 -1
  18. package/dist/helper/factory/index.js +7 -7
  19. package/dist/helper/html/index.js +0 -4
  20. package/dist/helper/proxy/index.js +0 -49
  21. package/dist/helper/route/index.js +0 -90
  22. package/dist/{types/helper → helper}/ssg/middleware.d.ts +0 -6
  23. package/dist/helper/ssg/middleware.js +1 -34
  24. package/dist/helper/ssg/plugins.js +0 -24
  25. package/dist/{types/helper → helper}/ssg/ssg.d.ts +0 -12
  26. package/dist/helper/ssg/ssg.js +0 -18
  27. package/dist/helper/ssg/utils.js +0 -5
  28. package/dist/helper/testing/index.js +0 -4
  29. package/dist/helper/websocket/index.js +0 -6
  30. package/dist/{types/hono-base.d.ts → hono-base.d.ts} +47 -95
  31. package/dist/hono-base.js +63 -228
  32. package/dist/{types/hono.d.ts → hono.d.ts} +1 -1
  33. package/dist/hono.js +0 -13
  34. package/dist/http-exception.js +0 -36
  35. package/dist/index.js +0 -15
  36. package/dist/jsx/components.js +0 -5
  37. package/dist/jsx/context.js +0 -34
  38. package/dist/jsx/dom/client.js +0 -14
  39. package/dist/jsx/dom/css.js +0 -34
  40. package/dist/jsx/dom/hooks/index.js +0 -21
  41. package/dist/jsx/dom/index.js +0 -4
  42. package/dist/jsx/dom/server.js +0 -12
  43. package/dist/jsx/index.js +0 -4
  44. package/dist/jsx/streaming.js +0 -26
  45. package/dist/{types/middleware → middleware}/basic-auth/index.d.ts +4 -3
  46. package/dist/middleware/basic-auth/index.js +0 -49
  47. package/dist/{types/middleware → middleware}/bearer-auth/index.d.ts +4 -27
  48. package/dist/middleware/bearer-auth/index.js +3 -39
  49. package/dist/middleware/body-limit/index.js +0 -32
  50. package/dist/middleware/cache/index.js +0 -31
  51. package/dist/middleware/combine/index.js +0 -80
  52. package/dist/middleware/compress/index.js +0 -24
  53. package/dist/middleware/context-storage/index.js +0 -35
  54. package/dist/middleware/cors/index.js +0 -39
  55. package/dist/middleware/csrf/index.js +0 -62
  56. package/dist/middleware/etag/index.js +0 -29
  57. package/dist/middleware/ip-restriction/index.js +0 -41
  58. package/dist/middleware/jsx-renderer/index.js +0 -58
  59. package/dist/middleware/jwk/jwk.js +0 -31
  60. package/dist/middleware/jwt/jwt.js +0 -32
  61. package/dist/middleware/language/language.js +0 -60
  62. package/dist/middleware/logger/index.js +6 -24
  63. package/dist/middleware/method-not-allowed/index.js +1 -36
  64. package/dist/middleware/method-override/index.js +0 -25
  65. package/dist/middleware/mount/index.js +0 -32
  66. package/dist/middleware/powered-by/index.js +0 -15
  67. package/dist/middleware/pretty-json/index.js +0 -18
  68. package/dist/middleware/request-id/request-id.js +0 -22
  69. package/dist/middleware/secure-headers/secure-headers.js +0 -32
  70. package/dist/{types/middleware → middleware}/serve-static/index.d.ts +0 -4
  71. package/dist/middleware/serve-static/index.js +0 -3
  72. package/dist/middleware/serve-static/path.js +0 -4
  73. package/dist/middleware/timeout/index.js +0 -22
  74. package/dist/middleware/timing/timing.js +0 -95
  75. package/dist/middleware/trailing-slash/index.js +0 -50
  76. package/dist/{types/preset → preset}/quick.d.ts +1 -1
  77. package/dist/preset/quick.js +0 -4
  78. package/dist/{types/preset → preset}/tiny.d.ts +1 -1
  79. package/dist/preset/tiny.js +0 -4
  80. package/dist/{types/request.d.ts → request.d.ts} +3 -48
  81. package/dist/request.js +0 -205
  82. package/dist/router/linear-router/router.js +19 -13
  83. package/dist/router/pattern-router/router.js +3 -3
  84. package/dist/router/reg-exp-router/node.js +9 -11
  85. package/dist/router/reg-exp-router/trie.js +0 -5
  86. package/dist/router/trie-router/node.js +5 -5
  87. package/dist/router.js +0 -19
  88. package/dist/{types/types.d.ts → types.d.ts} +33 -2
  89. package/dist/utils/body.js +0 -30
  90. package/dist/utils/buffer.d.ts +11 -0
  91. package/dist/utils/buffer.js +1 -12
  92. package/dist/utils/color.d.ts +16 -0
  93. package/dist/utils/color.js +4 -33
  94. package/dist/utils/compress.js +0 -7
  95. package/dist/utils/concurrent.js +0 -4
  96. package/dist/utils/constants.js +0 -3
  97. package/dist/utils/cookie.js +0 -4
  98. package/dist/utils/encode.js +0 -4
  99. package/dist/utils/handler.js +0 -4
  100. package/dist/utils/html.js +0 -4
  101. package/dist/{types/utils → utils}/http-status.d.ts +1 -9
  102. package/dist/utils/ipaddr.js +0 -39
  103. package/dist/utils/jwt/index.js +0 -4
  104. package/dist/utils/jwt/jwa.js +0 -5
  105. package/dist/utils/jwt/jws.js +0 -5
  106. package/dist/utils/jwt/jwt.js +0 -5
  107. package/dist/utils/jwt/types.js +0 -4
  108. package/dist/utils/jwt/utf8.js +0 -4
  109. package/dist/utils/mime.js +0 -4
  110. package/dist/utils/stream.js +0 -14
  111. package/dist/{types/utils → utils}/url.d.ts +0 -5
  112. package/dist/utils/url.js +1 -30
  113. package/dist/{types/validator → validator}/validator.d.ts +5 -0
  114. package/dist/validator/validator.js +42 -49
  115. package/package.json +142 -488
  116. package/dist/adapter/aws-lambda/conninfo.js +0 -43
  117. package/dist/adapter/aws-lambda/handler.js +0 -342
  118. package/dist/adapter/aws-lambda/index.js +0 -3
  119. package/dist/adapter/aws-lambda/types.js +0 -1
  120. package/dist/adapter/bun/conninfo.js +0 -22
  121. package/dist/adapter/bun/index.js +0 -6
  122. package/dist/adapter/bun/serve-static.js +0 -30
  123. package/dist/adapter/bun/server.js +0 -11
  124. package/dist/adapter/bun/ssg.js +0 -27
  125. package/dist/adapter/bun/websocket.js +0 -66
  126. package/dist/adapter/cloudflare-pages/conninfo.js +0 -24
  127. package/dist/adapter/cloudflare-pages/handler.js +0 -64
  128. package/dist/adapter/cloudflare-pages/index.js +0 -3
  129. package/dist/adapter/cloudflare-workers/conninfo.js +0 -7
  130. package/dist/adapter/cloudflare-workers/index.js +0 -4
  131. package/dist/adapter/cloudflare-workers/serve-static-module.js +0 -7
  132. package/dist/adapter/cloudflare-workers/serve-static.js +0 -28
  133. package/dist/adapter/cloudflare-workers/utils.js +0 -22
  134. package/dist/adapter/cloudflare-workers/websocket.js +0 -33
  135. package/dist/adapter/deno/conninfo.js +0 -17
  136. package/dist/adapter/deno/deno.d.js +0 -1
  137. package/dist/adapter/deno/index.js +0 -5
  138. package/dist/adapter/deno/serve-static.js +0 -35
  139. package/dist/adapter/deno/ssg.js +0 -29
  140. package/dist/adapter/deno/websocket.js +0 -32
  141. package/dist/adapter/lambda-edge/conninfo.js +0 -7
  142. package/dist/adapter/lambda-edge/handler.js +0 -111
  143. package/dist/adapter/lambda-edge/index.js +0 -3
  144. package/dist/adapter/netlify/conninfo.js +0 -24
  145. package/dist/adapter/netlify/handler.js +0 -11
  146. package/dist/adapter/netlify/index.js +0 -3
  147. package/dist/adapter/netlify/mod.js +0 -3
  148. package/dist/adapter/service-worker/handler.js +0 -16
  149. package/dist/adapter/service-worker/index.js +0 -25
  150. package/dist/adapter/service-worker/types.js +0 -1
  151. package/dist/adapter/vercel/conninfo.js +0 -7
  152. package/dist/adapter/vercel/handler.js +0 -9
  153. package/dist/adapter/vercel/index.js +0 -3
  154. package/dist/cjs/_virtual/_rolldown/runtime.js +0 -33
  155. package/dist/cjs/adapter/aws-lambda/conninfo.js +0 -44
  156. package/dist/cjs/adapter/aws-lambda/handler.js +0 -352
  157. package/dist/cjs/adapter/aws-lambda/index.js +0 -7
  158. package/dist/cjs/adapter/aws-lambda/types.js +0 -0
  159. package/dist/cjs/adapter/bun/conninfo.js +0 -23
  160. package/dist/cjs/adapter/bun/index.js +0 -14
  161. package/dist/cjs/adapter/bun/serve-static.js +0 -31
  162. package/dist/cjs/adapter/bun/server.js +0 -12
  163. package/dist/cjs/adapter/bun/ssg.js +0 -29
  164. package/dist/cjs/adapter/bun/websocket.js +0 -70
  165. package/dist/cjs/adapter/cloudflare-pages/conninfo.js +0 -25
  166. package/dist/cjs/adapter/cloudflare-pages/handler.js +0 -67
  167. package/dist/cjs/adapter/cloudflare-pages/index.js +0 -7
  168. package/dist/cjs/adapter/cloudflare-workers/conninfo.js +0 -8
  169. package/dist/cjs/adapter/cloudflare-workers/index.js +0 -7
  170. package/dist/cjs/adapter/cloudflare-workers/serve-static-module.js +0 -8
  171. package/dist/cjs/adapter/cloudflare-workers/serve-static.js +0 -29
  172. package/dist/cjs/adapter/cloudflare-workers/utils.js +0 -23
  173. package/dist/cjs/adapter/cloudflare-workers/websocket.js +0 -34
  174. package/dist/cjs/adapter/deno/conninfo.js +0 -18
  175. package/dist/cjs/adapter/deno/deno.d.js +0 -0
  176. package/dist/cjs/adapter/deno/index.js +0 -10
  177. package/dist/cjs/adapter/deno/serve-static.js +0 -36
  178. package/dist/cjs/adapter/deno/ssg.js +0 -31
  179. package/dist/cjs/adapter/deno/websocket.js +0 -33
  180. package/dist/cjs/adapter/lambda-edge/conninfo.js +0 -8
  181. package/dist/cjs/adapter/lambda-edge/handler.js +0 -116
  182. package/dist/cjs/adapter/lambda-edge/index.js +0 -5
  183. package/dist/cjs/adapter/netlify/conninfo.js +0 -25
  184. package/dist/cjs/adapter/netlify/handler.js +0 -12
  185. package/dist/cjs/adapter/netlify/index.js +0 -5
  186. package/dist/cjs/adapter/netlify/mod.js +0 -5
  187. package/dist/cjs/adapter/service-worker/handler.js +0 -17
  188. package/dist/cjs/adapter/service-worker/index.js +0 -27
  189. package/dist/cjs/adapter/service-worker/types.js +0 -0
  190. package/dist/cjs/adapter/vercel/conninfo.js +0 -8
  191. package/dist/cjs/adapter/vercel/handler.js +0 -10
  192. package/dist/cjs/adapter/vercel/index.js +0 -5
  193. package/dist/cjs/client/client.js +0 -145
  194. package/dist/cjs/client/fetch-result-please.js +0 -67
  195. package/dist/cjs/client/index.js +0 -7
  196. package/dist/cjs/client/types.js +0 -0
  197. package/dist/cjs/client/utils.js +0 -70
  198. package/dist/cjs/compose.js +0 -51
  199. package/dist/cjs/context.js +0 -383
  200. package/dist/cjs/helper/accepts/accepts.js +0 -54
  201. package/dist/cjs/helper/accepts/index.js +0 -3
  202. package/dist/cjs/helper/adapter/index.js +0 -41
  203. package/dist/cjs/helper/conninfo/index.js +0 -0
  204. package/dist/cjs/helper/conninfo/types.js +0 -0
  205. package/dist/cjs/helper/cookie/index.js +0 -89
  206. package/dist/cjs/helper/css/common.js +0 -194
  207. package/dist/cjs/helper/css/index.js +0 -142
  208. package/dist/cjs/helper/dev/index.js +0 -53
  209. package/dist/cjs/helper/factory/index.js +0 -33
  210. package/dist/cjs/helper/html/index.js +0 -34
  211. package/dist/cjs/helper/proxy/index.js +0 -122
  212. package/dist/cjs/helper/route/index.js +0 -128
  213. package/dist/cjs/helper/ssg/index.js +0 -19
  214. package/dist/cjs/helper/ssg/middleware.js +0 -65
  215. package/dist/cjs/helper/ssg/plugins.js +0 -68
  216. package/dist/cjs/helper/ssg/ssg.js +0 -220
  217. package/dist/cjs/helper/ssg/utils.js +0 -70
  218. package/dist/cjs/helper/streaming/index.js +0 -8
  219. package/dist/cjs/helper/streaming/sse.js +0 -59
  220. package/dist/cjs/helper/streaming/stream.js +0 -26
  221. package/dist/cjs/helper/streaming/text.js +0 -12
  222. package/dist/cjs/helper/streaming/utils.js +0 -16
  223. package/dist/cjs/helper/testing/index.js +0 -18
  224. package/dist/cjs/helper/websocket/index.js +0 -56
  225. package/dist/cjs/hono-base.js +0 -351
  226. package/dist/cjs/hono.js +0 -29
  227. package/dist/cjs/http-exception.js +0 -56
  228. package/dist/cjs/index.js +0 -22
  229. package/dist/cjs/jsx/base.js +0 -266
  230. package/dist/cjs/jsx/children.js +0 -19
  231. package/dist/cjs/jsx/components.js +0 -147
  232. package/dist/cjs/jsx/constants.js +0 -15
  233. package/dist/cjs/jsx/context.js +0 -170
  234. package/dist/cjs/jsx/dom/client.js +0 -56
  235. package/dist/cjs/jsx/dom/components.js +0 -26
  236. package/dist/cjs/jsx/dom/context.js +0 -43
  237. package/dist/cjs/jsx/dom/css.js +0 -153
  238. package/dist/cjs/jsx/dom/hooks/index.js +0 -65
  239. package/dist/cjs/jsx/dom/index.js +0 -122
  240. package/dist/cjs/jsx/dom/intrinsic-element/components.js +0 -306
  241. package/dist/cjs/jsx/dom/jsx-dev-runtime.js +0 -17
  242. package/dist/cjs/jsx/dom/jsx-runtime.js +0 -5
  243. package/dist/cjs/jsx/dom/render.js +0 -525
  244. package/dist/cjs/jsx/dom/server.js +0 -44
  245. package/dist/cjs/jsx/dom/utils.js +0 -9
  246. package/dist/cjs/jsx/hooks/index.js +0 -280
  247. package/dist/cjs/jsx/index.js +0 -89
  248. package/dist/cjs/jsx/intrinsic-element/common.js +0 -27
  249. package/dist/cjs/jsx/intrinsic-element/components.js +0 -138
  250. package/dist/cjs/jsx/intrinsic-elements.js +0 -0
  251. package/dist/cjs/jsx/jsx-dev-runtime.js +0 -16
  252. package/dist/cjs/jsx/jsx-runtime.js +0 -37
  253. package/dist/cjs/jsx/streaming.js +0 -135
  254. package/dist/cjs/jsx/types.js +0 -0
  255. package/dist/cjs/jsx/utils.js +0 -116
  256. package/dist/cjs/middleware/basic-auth/index.js +0 -100
  257. package/dist/cjs/middleware/bearer-auth/index.js +0 -97
  258. package/dist/cjs/middleware/body-limit/index.js +0 -69
  259. package/dist/cjs/middleware/cache/index.js +0 -173
  260. package/dist/cjs/middleware/combine/index.js +0 -141
  261. package/dist/cjs/middleware/compress/index.js +0 -82
  262. package/dist/cjs/middleware/context-storage/index.js +0 -55
  263. package/dist/cjs/middleware/cors/index.js +0 -109
  264. package/dist/cjs/middleware/csrf/index.js +0 -106
  265. package/dist/cjs/middleware/etag/digest.js +0 -62
  266. package/dist/cjs/middleware/etag/index.js +0 -79
  267. package/dist/cjs/middleware/ip-restriction/index.js +0 -168
  268. package/dist/cjs/middleware/jsx-renderer/index.js +0 -104
  269. package/dist/cjs/middleware/jwk/index.js +0 -3
  270. package/dist/cjs/middleware/jwk/jwk.js +0 -122
  271. package/dist/cjs/middleware/jwt/index.js +0 -9
  272. package/dist/cjs/middleware/jwt/jwt.js +0 -124
  273. package/dist/cjs/middleware/language/index.js +0 -7
  274. package/dist/cjs/middleware/language/language.js +0 -208
  275. package/dist/cjs/middleware/logger/index.js +0 -51
  276. package/dist/cjs/middleware/method-not-allowed/index.js +0 -84
  277. package/dist/cjs/middleware/method-override/index.js +0 -105
  278. package/dist/cjs/middleware/mount/index.js +0 -71
  279. package/dist/cjs/middleware/powered-by/index.js +0 -25
  280. package/dist/cjs/middleware/pretty-json/index.js +0 -41
  281. package/dist/cjs/middleware/request-id/index.js +0 -3
  282. package/dist/cjs/middleware/request-id/request-id.js +0 -35
  283. package/dist/cjs/middleware/secure-headers/index.js +0 -4
  284. package/dist/cjs/middleware/secure-headers/permissions-policy.js +0 -0
  285. package/dist/cjs/middleware/secure-headers/secure-headers.js +0 -166
  286. package/dist/cjs/middleware/serve-static/index.js +0 -62
  287. package/dist/cjs/middleware/serve-static/path.js +0 -17
  288. package/dist/cjs/middleware/timeout/index.js +0 -42
  289. package/dist/cjs/middleware/timing/index.js +0 -7
  290. package/dist/cjs/middleware/timing/timing.js +0 -189
  291. package/dist/cjs/middleware/trailing-slash/index.js +0 -89
  292. package/dist/cjs/package.json +0 -3
  293. package/dist/cjs/preset/quick.js +0 -19
  294. package/dist/cjs/preset/tiny.js +0 -16
  295. package/dist/cjs/request/constants.js +0 -5
  296. package/dist/cjs/request.js +0 -337
  297. package/dist/cjs/router/linear-router/index.js +0 -3
  298. package/dist/cjs/router/linear-router/router.js +0 -97
  299. package/dist/cjs/router/pattern-router/index.js +0 -3
  300. package/dist/cjs/router/pattern-router/router.js +0 -42
  301. package/dist/cjs/router/reg-exp-router/index.js +0 -7
  302. package/dist/cjs/router/reg-exp-router/matcher.js +0 -21
  303. package/dist/cjs/router/reg-exp-router/node.js +0 -96
  304. package/dist/cjs/router/reg-exp-router/prepared-router.js +0 -97
  305. package/dist/cjs/router/reg-exp-router/router.js +0 -102
  306. package/dist/cjs/router/reg-exp-router/trie.js +0 -74
  307. package/dist/cjs/router/smart-router/index.js +0 -3
  308. package/dist/cjs/router/smart-router/router.js +0 -50
  309. package/dist/cjs/router/trie-router/index.js +0 -3
  310. package/dist/cjs/router/trie-router/node.js +0 -135
  311. package/dist/cjs/router/trie-router/router.js +0 -16
  312. package/dist/cjs/router/utils.js +0 -5
  313. package/dist/cjs/router.js +0 -40
  314. package/dist/cjs/types.js +0 -5
  315. package/dist/cjs/utils/accept.js +0 -194
  316. package/dist/cjs/utils/basic-auth.js +0 -21
  317. package/dist/cjs/utils/body.js +0 -97
  318. package/dist/cjs/utils/buffer.js +0 -55
  319. package/dist/cjs/utils/color.js +0 -39
  320. package/dist/cjs/utils/compress.js +0 -12
  321. package/dist/cjs/utils/concurrent.js +0 -31
  322. package/dist/cjs/utils/constants.js +0 -8
  323. package/dist/cjs/utils/cookie.js +0 -129
  324. package/dist/cjs/utils/crypto.js +0 -38
  325. package/dist/cjs/utils/encode.js +0 -37
  326. package/dist/cjs/utils/filepath.js +0 -27
  327. package/dist/cjs/utils/handler.js +0 -14
  328. package/dist/cjs/utils/headers.js +0 -0
  329. package/dist/cjs/utils/html.js +0 -109
  330. package/dist/cjs/utils/http-status.js +0 -0
  331. package/dist/cjs/utils/ipaddr.js +0 -247
  332. package/dist/cjs/utils/jwt/index.js +0 -15
  333. package/dist/cjs/utils/jwt/jwa.js +0 -25
  334. package/dist/cjs/utils/jwt/jws.js +0 -135
  335. package/dist/cjs/utils/jwt/jwt.js +0 -136
  336. package/dist/cjs/utils/jwt/types.js +0 -124
  337. package/dist/cjs/utils/jwt/utf8.js +0 -11
  338. package/dist/cjs/utils/mime.js +0 -80
  339. package/dist/cjs/utils/stream.js +0 -89
  340. package/dist/cjs/utils/types.js +0 -0
  341. package/dist/cjs/utils/url.js +0 -215
  342. package/dist/cjs/validator/index.js +0 -3
  343. package/dist/cjs/validator/utils.js +0 -0
  344. package/dist/cjs/validator/validator.js +0 -65
  345. package/dist/types/adapter/aws-lambda/conninfo.d.ts +0 -30
  346. package/dist/types/adapter/aws-lambda/handler.d.ts +0 -230
  347. package/dist/types/adapter/aws-lambda/index.d.ts +0 -4
  348. package/dist/types/adapter/aws-lambda/types.d.ts +0 -183
  349. package/dist/types/adapter/bun/conninfo.d.ts +0 -10
  350. package/dist/types/adapter/bun/index.d.ts +0 -6
  351. package/dist/types/adapter/bun/serve-static.d.ts +0 -8
  352. package/dist/types/adapter/bun/server.d.ts +0 -11
  353. package/dist/types/adapter/bun/ssg.d.ts +0 -17
  354. package/dist/types/adapter/bun/websocket.d.ts +0 -54
  355. package/dist/types/adapter/cloudflare-pages/conninfo.d.ts +0 -24
  356. package/dist/types/adapter/cloudflare-pages/handler.d.ts +0 -45
  357. package/dist/types/adapter/cloudflare-pages/index.d.ts +0 -3
  358. package/dist/types/adapter/cloudflare-workers/conninfo.d.ts +0 -7
  359. package/dist/types/adapter/cloudflare-workers/index.d.ts +0 -4
  360. package/dist/types/adapter/cloudflare-workers/serve-static-module.d.ts +0 -7
  361. package/dist/types/adapter/cloudflare-workers/serve-static.d.ts +0 -21
  362. package/dist/types/adapter/cloudflare-workers/utils.d.ts +0 -13
  363. package/dist/types/adapter/cloudflare-workers/websocket.d.ts +0 -7
  364. package/dist/types/adapter/deno/conninfo.d.ts +0 -10
  365. package/dist/types/adapter/deno/deno.d.ts +0 -1
  366. package/dist/types/adapter/deno/index.d.ts +0 -5
  367. package/dist/types/adapter/deno/serve-static.d.ts +0 -8
  368. package/dist/types/adapter/deno/ssg.d.ts +0 -17
  369. package/dist/types/adapter/deno/websocket.d.ts +0 -7
  370. package/dist/types/adapter/lambda-edge/conninfo.d.ts +0 -7
  371. package/dist/types/adapter/lambda-edge/handler.d.ts +0 -113
  372. package/dist/types/adapter/lambda-edge/index.d.ts +0 -3
  373. package/dist/types/adapter/netlify/conninfo.d.ts +0 -24
  374. package/dist/types/adapter/netlify/handler.d.ts +0 -7
  375. package/dist/types/adapter/netlify/index.d.ts +0 -3
  376. package/dist/types/adapter/netlify/mod.d.ts +0 -3
  377. package/dist/types/adapter/service-worker/handler.d.ts +0 -18
  378. package/dist/types/adapter/service-worker/index.d.ts +0 -26
  379. package/dist/types/adapter/service-worker/types.d.ts +0 -17
  380. package/dist/types/adapter/vercel/conninfo.d.ts +0 -7
  381. package/dist/types/adapter/vercel/handler.d.ts +0 -7
  382. package/dist/types/adapter/vercel/index.d.ts +0 -3
  383. package/dist/types/package.json +0 -3
  384. package/dist/types/utils/buffer.d.ts +0 -19
  385. package/dist/types/utils/color.d.ts +0 -23
  386. package/dist/{types/client → client}/client.d.ts +0 -0
  387. package/dist/{types/client → client}/fetch-result-please.d.ts +0 -0
  388. package/dist/{types/client → client}/index.d.ts +0 -0
  389. package/dist/{types/client → client}/types.d.ts +1 -1
  390. /package/dist/{types/client → client}/utils.d.ts +0 -0
  391. /package/dist/{types/helper → helper}/accepts/accepts.d.ts +0 -0
  392. /package/dist/{types/helper → helper}/accepts/index.d.ts +0 -0
  393. /package/dist/{types/helper → helper}/adapter/index.d.ts +0 -0
  394. /package/dist/{types/helper → helper}/conninfo/index.d.ts +0 -0
  395. /package/dist/{types/helper → helper}/conninfo/types.d.ts +0 -0
  396. /package/dist/{types/helper → helper}/cookie/index.d.ts +0 -0
  397. /package/dist/{types/helper → helper}/css/common.d.ts +0 -0
  398. /package/dist/{types/helper → helper}/css/index.d.ts +0 -0
  399. /package/dist/{types/helper → helper}/html/index.d.ts +0 -0
  400. /package/dist/{types/helper → helper}/proxy/index.d.ts +0 -0
  401. /package/dist/{types/helper → helper}/route/index.d.ts +0 -0
  402. /package/dist/{types/helper → helper}/ssg/index.d.ts +0 -0
  403. /package/dist/{types/helper → helper}/ssg/plugins.d.ts +0 -0
  404. /package/dist/{types/helper → helper}/ssg/utils.d.ts +0 -0
  405. /package/dist/{types/helper → helper}/streaming/index.d.ts +0 -0
  406. /package/dist/{types/helper → helper}/streaming/sse.d.ts +0 -0
  407. /package/dist/{types/helper → helper}/streaming/stream.d.ts +0 -0
  408. /package/dist/{types/helper → helper}/streaming/text.d.ts +0 -0
  409. /package/dist/{types/helper → helper}/streaming/utils.d.ts +0 -0
  410. /package/dist/{types/helper → helper}/testing/index.d.ts +0 -0
  411. /package/dist/{types/helper → helper}/websocket/index.d.ts +0 -0
  412. /package/dist/{types/http-exception.d.ts → http-exception.d.ts} +0 -0
  413. /package/dist/{types/index.d.ts → index.d.ts} +0 -0
  414. /package/dist/{types/jsx → jsx}/base.d.ts +0 -0
  415. /package/dist/{types/jsx → jsx}/children.d.ts +0 -0
  416. /package/dist/{types/jsx → jsx}/components.d.ts +0 -0
  417. /package/dist/{types/jsx → jsx}/constants.d.ts +0 -0
  418. /package/dist/{types/jsx → jsx}/context.d.ts +0 -0
  419. /package/dist/{types/jsx → jsx}/dom/client.d.ts +0 -0
  420. /package/dist/{types/jsx → jsx}/dom/components.d.ts +0 -0
  421. /package/dist/{types/jsx → jsx}/dom/context.d.ts +0 -0
  422. /package/dist/{types/jsx → jsx}/dom/css.d.ts +0 -0
  423. /package/dist/{types/jsx → jsx}/dom/hooks/index.d.ts +0 -0
  424. /package/dist/{types/jsx → jsx}/dom/index.d.ts +0 -0
  425. /package/dist/{types/jsx → jsx}/dom/intrinsic-element/components.d.ts +0 -0
  426. /package/dist/{types/jsx → jsx}/dom/jsx-dev-runtime.d.ts +0 -0
  427. /package/dist/{types/jsx → jsx}/dom/jsx-runtime.d.ts +0 -0
  428. /package/dist/{types/jsx → jsx}/dom/render.d.ts +0 -0
  429. /package/dist/{types/jsx → jsx}/dom/server.d.ts +0 -0
  430. /package/dist/{types/jsx → jsx}/dom/utils.d.ts +0 -0
  431. /package/dist/{types/jsx → jsx}/hooks/index.d.ts +0 -0
  432. /package/dist/{types/jsx → jsx}/index.d.ts +0 -0
  433. /package/dist/{types/jsx → jsx}/intrinsic-element/common.d.ts +0 -0
  434. /package/dist/{types/jsx → jsx}/intrinsic-element/components.d.ts +0 -0
  435. /package/dist/{types/jsx → jsx}/intrinsic-elements.d.ts +0 -0
  436. /package/dist/{types/jsx → jsx}/jsx-dev-runtime.d.ts +0 -0
  437. /package/dist/{types/jsx → jsx}/jsx-runtime.d.ts +0 -0
  438. /package/dist/{types/jsx → jsx}/streaming.d.ts +0 -0
  439. /package/dist/{types/jsx → jsx}/types.d.ts +0 -0
  440. /package/dist/{types/jsx → jsx}/utils.d.ts +0 -0
  441. /package/dist/{types/middleware → middleware}/body-limit/index.d.ts +0 -0
  442. /package/dist/{types/middleware → middleware}/cache/index.d.ts +0 -0
  443. /package/dist/{types/middleware → middleware}/combine/index.d.ts +0 -0
  444. /package/dist/{types/middleware → middleware}/compress/index.d.ts +0 -0
  445. /package/dist/{types/middleware → middleware}/context-storage/index.d.ts +0 -0
  446. /package/dist/{types/middleware → middleware}/cors/index.d.ts +0 -0
  447. /package/dist/{types/middleware → middleware}/csrf/index.d.ts +0 -0
  448. /package/dist/{types/middleware → middleware}/etag/digest.d.ts +0 -0
  449. /package/dist/{types/middleware → middleware}/etag/index.d.ts +0 -0
  450. /package/dist/{types/middleware → middleware}/ip-restriction/index.d.ts +0 -0
  451. /package/dist/{types/middleware → middleware}/jsx-renderer/index.d.ts +0 -0
  452. /package/dist/{types/middleware → middleware}/jwk/index.d.ts +0 -0
  453. /package/dist/{types/middleware → middleware}/jwk/jwk.d.ts +0 -0
  454. /package/dist/{types/middleware → middleware}/jwt/index.d.ts +0 -0
  455. /package/dist/{types/middleware → middleware}/jwt/jwt.d.ts +0 -0
  456. /package/dist/{types/middleware → middleware}/language/index.d.ts +0 -0
  457. /package/dist/{types/middleware → middleware}/language/language.d.ts +0 -0
  458. /package/dist/{types/middleware → middleware}/logger/index.d.ts +0 -0
  459. /package/dist/{types/middleware → middleware}/method-not-allowed/index.d.ts +0 -0
  460. /package/dist/{types/middleware → middleware}/method-override/index.d.ts +0 -0
  461. /package/dist/{types/middleware → middleware}/mount/index.d.ts +0 -0
  462. /package/dist/{types/middleware → middleware}/powered-by/index.d.ts +0 -0
  463. /package/dist/{types/middleware → middleware}/pretty-json/index.d.ts +0 -0
  464. /package/dist/{types/middleware → middleware}/request-id/index.d.ts +0 -0
  465. /package/dist/{types/middleware → middleware}/request-id/request-id.d.ts +0 -0
  466. /package/dist/{types/middleware → middleware}/secure-headers/index.d.ts +0 -0
  467. /package/dist/{types/middleware → middleware}/secure-headers/permissions-policy.d.ts +0 -0
  468. /package/dist/{types/middleware → middleware}/secure-headers/secure-headers.d.ts +0 -0
  469. /package/dist/{types/middleware → middleware}/serve-static/path.d.ts +0 -0
  470. /package/dist/{types/middleware → middleware}/timeout/index.d.ts +0 -0
  471. /package/dist/{types/middleware → middleware}/timing/index.d.ts +0 -0
  472. /package/dist/{types/middleware → middleware}/timing/timing.d.ts +0 -0
  473. /package/dist/{types/middleware → middleware}/trailing-slash/index.d.ts +0 -0
  474. /package/dist/{types/request → request}/constants.d.ts +0 -0
  475. /package/dist/{types/router → router}/linear-router/index.d.ts +0 -0
  476. /package/dist/{types/router → router}/linear-router/router.d.ts +0 -0
  477. /package/dist/{types/router → router}/pattern-router/index.d.ts +0 -0
  478. /package/dist/{types/router → router}/pattern-router/router.d.ts +0 -0
  479. /package/dist/{types/router → router}/reg-exp-router/index.d.ts +0 -0
  480. /package/dist/{types/router → router}/reg-exp-router/matcher.d.ts +0 -0
  481. /package/dist/{types/router → router}/reg-exp-router/node.d.ts +0 -0
  482. /package/dist/{types/router → router}/reg-exp-router/prepared-router.d.ts +0 -0
  483. /package/dist/{types/router → router}/reg-exp-router/router.d.ts +0 -0
  484. /package/dist/{types/router → router}/reg-exp-router/trie.d.ts +0 -0
  485. /package/dist/{types/router → router}/smart-router/index.d.ts +0 -0
  486. /package/dist/{types/router → router}/smart-router/router.d.ts +0 -0
  487. /package/dist/{types/router → router}/trie-router/index.d.ts +0 -0
  488. /package/dist/{types/router → router}/trie-router/node.d.ts +0 -0
  489. /package/dist/{types/router → router}/trie-router/router.d.ts +0 -0
  490. /package/dist/{types/router → router}/utils.d.ts +0 -0
  491. /package/dist/{types/router.d.ts → router.d.ts} +0 -0
  492. /package/dist/{types/utils → utils}/accept.d.ts +0 -0
  493. /package/dist/{types/utils → utils}/basic-auth.d.ts +0 -0
  494. /package/dist/{types/utils → utils}/body.d.ts +0 -0
  495. /package/dist/{types/utils → utils}/compress.d.ts +0 -0
  496. /package/dist/{types/utils → utils}/concurrent.d.ts +0 -0
  497. /package/dist/{types/utils → utils}/constants.d.ts +0 -0
  498. /package/dist/{types/utils → utils}/cookie.d.ts +0 -0
  499. /package/dist/{types/utils → utils}/crypto.d.ts +0 -0
  500. /package/dist/{types/utils → utils}/encode.d.ts +0 -0
  501. /package/dist/{types/utils → utils}/filepath.d.ts +0 -0
  502. /package/dist/{types/utils → utils}/handler.d.ts +0 -0
  503. /package/dist/{types/utils → utils}/headers.d.ts +0 -0
  504. /package/dist/{types/utils → utils}/html.d.ts +0 -0
  505. /package/dist/{types/utils → utils}/ipaddr.d.ts +0 -0
  506. /package/dist/{types/utils → utils}/jwt/index.d.ts +0 -0
  507. /package/dist/{types/utils → utils}/jwt/jwa.d.ts +0 -0
  508. /package/dist/{types/utils → utils}/jwt/jws.d.ts +0 -0
  509. /package/dist/{types/utils → utils}/jwt/jwt.d.ts +0 -0
  510. /package/dist/{types/utils → utils}/jwt/types.d.ts +0 -0
  511. /package/dist/{types/utils → utils}/jwt/utf8.d.ts +0 -0
  512. /package/dist/{types/utils → utils}/mime.d.ts +0 -0
  513. /package/dist/{types/utils → utils}/stream.d.ts +0 -0
  514. /package/dist/{types/utils → utils}/types.d.ts +0 -0
  515. /package/dist/{types/validator → validator}/index.d.ts +0 -0
  516. /package/dist/{types/validator → validator}/utils.d.ts +0 -0
@@ -1,48 +1,12 @@
1
1
  //#region src/http-exception.ts
2
- /**
3
- * `HTTPException` must be used when a fatal error such as authentication failure occurs.
4
- *
5
- * @see {@link https://hono.dev/docs/api/exception}
6
- *
7
- * @param {StatusCode} status - status code of HTTPException
8
- * @param {HTTPExceptionOptions} options - options of HTTPException
9
- * @param {HTTPExceptionOptions["res"]} options.res - response of options of HTTPException
10
- * @param {HTTPExceptionOptions["message"]} options.message - message of options of HTTPException
11
- * @param {HTTPExceptionOptions["cause"]} options.cause - cause of options of HTTPException
12
- *
13
- * @example
14
- * ```ts
15
- * import { HTTPException } from 'hono/http-exception'
16
- *
17
- * // ...
18
- *
19
- * app.post('/auth', async (c, next) => {
20
- * // authentication
21
- * if (authorized === false) {
22
- * throw new HTTPException(401, { message: 'Custom error message' })
23
- * }
24
- * await next()
25
- * })
26
- * ```
27
- */
28
2
  var HTTPException = class extends Error {
29
3
  res;
30
4
  status;
31
- /**
32
- * Creates an instance of `HTTPException`.
33
- * @param status - HTTP status code for the exception. Defaults to 500.
34
- * @param options - Additional options for the exception.
35
- */
36
5
  constructor(status = 500, options) {
37
6
  super(options?.message, { cause: options?.cause });
38
7
  this.res = options?.res;
39
8
  this.status = status;
40
9
  }
41
- /**
42
- * Returns the response object associated with the exception.
43
- * If a response object is not provided, a new response is created with the error message and status code.
44
- * @returns The response object.
45
- */
46
10
  getResponse() {
47
11
  if (this.res) return new Response(this.res.body, {
48
12
  status: this.status,
package/dist/index.js CHANGED
@@ -1,20 +1,5 @@
1
1
  import { Context } from "./context.js";
2
2
  import { Hono } from "./hono.js";
3
3
  //#region src/index.ts
4
- /**
5
- * @module
6
- *
7
- * Hono - Web Framework built on Web Standards
8
- *
9
- * @example
10
- * ```ts
11
- * import { Hono } from 'hono'
12
- * const app = new Hono()
13
- *
14
- * app.get('/', (c) => c.text('Hono!'))
15
- *
16
- * export default app
17
- * ```
18
- */
19
4
  //#endregion
20
5
  export { Context, Hono };
@@ -26,11 +26,6 @@ const resolveChildEarly = (child) => {
26
26
  return str instanceof Promise ? str : raw(str);
27
27
  }
28
28
  };
29
- /**
30
- * @experimental
31
- * `ErrorBoundary` is an experimental feature.
32
- * The API might be changed.
33
- */
34
29
  const ErrorBoundary = async ({ children, fallback, fallbackRender, onError }) => {
35
30
  if (!children) return raw("");
36
31
  if (!Array.isArray(children)) children = [children];
@@ -75,18 +75,6 @@ const resumeWithContextValues = (callback, store, contexts) => runWithRenderCont
75
75
  throw e;
76
76
  }
77
77
  }, store);
78
- /**
79
- * Establish the request-scoped context store for a render.
80
- *
81
- * `resumeStore` continues a suspended subtree in the same store on the fallback
82
- * path (ignored when `AsyncLocalStorage` is available, where isolation is
83
- * automatic).
84
- *
85
- * Without `AsyncLocalStorage` a render can't be followed across `await`, so the
86
- * store lives in `fallbackStore` only during synchronous work (mirroring
87
- * React's request storage). Reading context after `await` then finds no store
88
- * and falls back to the default value — never another request's value.
89
- */
90
78
  const runWithRenderContext = (callback, resumeStore) => {
91
79
  if (getCurrentStore()) return callback();
92
80
  const store = resumeStore ?? /* @__PURE__ */ new WeakMap();
@@ -107,27 +95,11 @@ const runWithRenderContext = (callback, resumeStore) => {
107
95
  }
108
96
  return result;
109
97
  };
110
- /**
111
- * Capture the current render store and return a resumer that re-establishes it
112
- * around a deferred continuation (e.g. a re-render after a suspended promise
113
- * settles). Shared by every suspension point so none reimplements it.
114
- */
115
98
  const captureRenderContext = () => {
116
99
  const store = getCurrentStore();
117
100
  const contexts = captureContextValues(store);
118
101
  return (callback) => resumeWithContextValues(callback, store, contexts);
119
102
  };
120
- /**
121
- * Create a context whose value can be provided with `<Context.Provider>` and
122
- * read with {@link useContext}.
123
- *
124
- * Server-side renders are isolated per request, so a provided value never leaks
125
- * into a concurrent request — even across `await` in an async component, when
126
- * `AsyncLocalStorage` is available (Node.js >= 20.16, Deno, Bun, Cloudflare
127
- * Workers with `nodejs_compat`). Without it, reading context after `await`
128
- * returns the default value; synchronous components and `use()`-based
129
- * suspension are unaffected.
130
- */
131
103
  const createContext = (defaultValue) => {
132
104
  const values = [defaultValue];
133
105
  const context = ((props) => {
@@ -152,12 +124,6 @@ const createContext = (defaultValue) => {
152
124
  globalContexts.push(context);
153
125
  return context;
154
126
  };
155
- /**
156
- * Read the current value of a context created with {@link createContext}.
157
- *
158
- * Safe to call from async components after `await`. See {@link createContext}
159
- * for the per-runtime isolation guarantees.
160
- */
161
127
  const useContext = (context) => {
162
128
  return readContextValueIn(getCurrentStore(), context);
163
129
  };
@@ -1,12 +1,6 @@
1
1
  import { buildNode, renderNode } from "./render.js";
2
2
  import { useState } from "../hooks/index.js";
3
3
  //#region src/jsx/dom/client.ts
4
- /**
5
- * Create a root object for rendering
6
- * @param element Render target
7
- * @param options Options for createRoot (not supported yet)
8
- * @returns Root object has `render` and `unmount` methods
9
- */
10
4
  const createRoot = (element, options = {}) => {
11
5
  let setJsxNode = void 0;
12
6
  if (Object.keys(options).length > 0) console.warn("createRoot options are not supported yet");
@@ -29,14 +23,6 @@ const createRoot = (element, options = {}) => {
29
23
  }
30
24
  };
31
25
  };
32
- /**
33
- * Create a root object and hydrate app to the target element.
34
- * In hono/jsx/dom, hydrate is equivalent to render.
35
- * @param element Render target
36
- * @param reactNode A JSXNode to render
37
- * @param options Options for createRoot (not supported yet)
38
- * @returns Root object has `render` and `unmount` methods
39
- */
40
26
  const hydrateRoot = (element, reactNode, options = {}) => {
41
27
  const root = createRoot(element, options);
42
28
  root.render(reactNode);
@@ -76,15 +76,6 @@ const createCssJsxDomObjects = ({ id }) => {
76
76
  });
77
77
  return [cssObject, Style];
78
78
  };
79
- /**
80
- * @experimental
81
- * `createCssContext` is an experimental feature.
82
- * The API might be changed.
83
- *
84
- * @param options.id - The ID for the style element
85
- * @param options.classNameSlug - Optional function to customize generated CSS class names
86
- * @param options.onInvalidSlug - Optional callback function called when an invalid slug is returned from ClassNameSlug
87
- */
88
79
  const createCssContext = ({ id, classNameSlug, onInvalidSlug }) => {
89
80
  const [cssObject, Style] = createCssJsxDomObjects({ id });
90
81
  const newCssClassNameObject = (cssClassName) => {
@@ -111,35 +102,10 @@ const createCssContext = ({ id, classNameSlug, onInvalidSlug }) => {
111
102
  };
112
103
  };
113
104
  const defaultContext = createCssContext({ id: DEFAULT_STYLE_ID });
114
- /**
115
- * @experimental
116
- * `css` is an experimental feature.
117
- * The API might be changed.
118
- */
119
105
  const css = defaultContext.css;
120
- /**
121
- * @experimental
122
- * `cx` is an experimental feature.
123
- * The API might be changed.
124
- */
125
106
  const cx = defaultContext.cx;
126
- /**
127
- * @experimental
128
- * `keyframes` is an experimental feature.
129
- * The API might be changed.
130
- */
131
107
  const keyframes = defaultContext.keyframes;
132
- /**
133
- * @experimental
134
- * `viewTransition` is an experimental feature.
135
- * The API might be changed.
136
- */
137
108
  const viewTransition = defaultContext.viewTransition;
138
- /**
139
- * @experimental
140
- * `Style` is an experimental feature.
141
- * The API might be changed.
142
- */
143
109
  const Style = defaultContext.Style;
144
110
  //#endregion
145
111
  export { Style, createCssContext, createCssJsxDomObjects, css, cx, keyframes, rawCssString, viewTransition };
@@ -3,9 +3,6 @@ import { createContext } from "../context.js";
3
3
  import { useContext } from "../../context.js";
4
4
  import { useCallback, useState } from "../../hooks/index.js";
5
5
  //#region src/jsx/dom/hooks/index.ts
6
- /**
7
- * Provide hooks used only in jsx/dom
8
- */
9
6
  const FormContext = createContext({
10
7
  pending: false,
11
8
  data: null,
@@ -17,20 +14,9 @@ const registerAction = (action) => {
17
14
  actions.add(action);
18
15
  action.finally(() => actions.delete(action));
19
16
  };
20
- /**
21
- * This hook returns the current form status
22
- * @returns FormStatus
23
- */
24
17
  const useFormStatus = () => {
25
18
  return useContext(FormContext);
26
19
  };
27
- /**
28
- * This hook returns the current state and a function to update the state optimistically
29
- * The current state is updated optimistically and then reverted to the original state when all actions are resolved
30
- * @param state
31
- * @param updateState
32
- * @returns [T, (action: N) => void]
33
- */
34
20
  const useOptimistic = (state, updateState) => {
35
21
  const [optimisticState, setOptimisticState] = useState(state);
36
22
  if (actions.size > 0) Promise.all(actions).finally(() => {
@@ -41,13 +27,6 @@ const useOptimistic = (state, updateState) => {
41
27
  setOptimisticState((currentState) => updateState(currentState, newData));
42
28
  }, [])];
43
29
  };
44
- /**
45
- * This hook returns the current state and a function to update the state by form action
46
- * @param fn
47
- * @param initialState
48
- * @param permalink
49
- * @returns [T, (data: FormData) => void]
50
- */
51
30
  const useActionState = (fn, initialState, permalink) => {
52
31
  const [state, setState] = useState(initialState);
53
32
  const actionState = async (data) => {
@@ -10,10 +10,6 @@ import { Fragment, jsxDEV } from "./jsx-dev-runtime.js";
10
10
  import "./jsx-runtime.js";
11
11
  import { ErrorBoundary, Suspense } from "./components.js";
12
12
  //#region src/jsx/dom/index.ts
13
- /**
14
- * @module
15
- * This module provides APIs for `hono/jsx/dom`.
16
- */
17
13
  const createElement = (tag, props, ...children) => {
18
14
  const jsxProps = props ? { ...props } : {};
19
15
  if (children.length) jsxProps.children = children.length === 1 ? children[0] : children;
@@ -3,12 +3,6 @@ import { renderToReadableStream as renderToReadableStream$1 } from "../streaming
3
3
  import dom_default from "./index.js";
4
4
  //#region src/jsx/dom/server.ts
5
5
  const prepareRoot = (element) => typeof element === "string" || Array.isArray(element) ? renderChildren([element]) : element;
6
- /**
7
- * Render JSX element to string.
8
- * @param element JSX element to render.
9
- * @param options Options for rendering.
10
- * @returns Rendered string.
11
- */
12
6
  const renderToString = (element, options = {}) => {
13
7
  if (Object.keys(options).length > 0) console.warn("options are not supported yet");
14
8
  element = prepareRoot(element);
@@ -16,12 +10,6 @@ const renderToString = (element, options = {}) => {
16
10
  if (typeof res !== "string") throw new Error("Async component is not supported in renderToString");
17
11
  return res;
18
12
  };
19
- /**
20
- * Render JSX element to readable stream.
21
- * @param element JSX element to render.
22
- * @param options Options for rendering.
23
- * @returns Rendered readable stream.
24
- */
25
13
  const renderToReadableStream = async (element, options = {}) => {
26
14
  if (Object.keys(options).some((key) => key !== "onError")) console.warn("options are not supported yet, except onError");
27
15
  element = prepareRoot(element);
package/dist/jsx/index.js CHANGED
@@ -6,10 +6,6 @@ import { useActionState, useOptimistic } from "./dom/hooks/index.js";
6
6
  import { Suspense } from "./streaming.js";
7
7
  import { ErrorBoundary } from "./components.js";
8
8
  //#region src/jsx/index.ts
9
- /**
10
- * @module
11
- * JSX for Hono.
12
- */
13
9
  var jsx_default = {
14
10
  version: reactAPICompatVersion,
15
11
  memo,
@@ -6,30 +6,9 @@ import { buildDataStack } from "./dom/render.js";
6
6
  import { Suspense as Suspense$1 } from "./dom/components.js";
7
7
  import { childrenToString } from "./components.js";
8
8
  //#region src/jsx/streaming.ts
9
- /**
10
- * @module
11
- * This module enables JSX to supports streaming Response.
12
- */
13
- /**
14
- * Used to specify nonce for scripts generated by `Suspense` and `ErrorBoundary`.
15
- *
16
- * @example
17
- * ```tsx
18
- * <StreamingContext.Provider value={{ scriptNonce: 'test-nonce' }}>
19
- * <Suspense fallback={<p>Loading...</p>}>
20
- * <Content />
21
- * </Suspense>
22
- * </StreamingContext.Provider>
23
- * ```
24
- */
25
9
  const StreamingContext = createContext(null);
26
10
  let suspenseCounter = 0;
27
11
  const serializeBoundaryChild = (child) => typeof child === "string" || Array.isArray(child) ? renderChildren([child]) : child == null || typeof child === "boolean" ? "" : isUntrustedObject(child) ? renderUntrustedObject(child) : child.toString();
28
- /**
29
- * @experimental
30
- * `Suspense` is an experimental feature.
31
- * The API might be changed.
32
- */
33
12
  const Suspense = async ({ children, fallback }) => {
34
13
  if (!Array.isArray(children)) children = [children];
35
14
  const nonce = useContext(StreamingContext)?.scriptNonce;
@@ -82,11 +61,6 @@ d.replaceWith(c.content)
82
61
  };
83
62
  Suspense[DOM_RENDERER] = Suspense$1;
84
63
  const textEncoder = new TextEncoder();
85
- /**
86
- * @experimental
87
- * `renderToReadableStream()` is an experimental feature.
88
- * The API might be changed.
89
- */
90
64
  const renderToReadableStream = (content, onError = console.trace) => {
91
65
  let cancelled = false;
92
66
  return new ReadableStream({
@@ -1,18 +1,19 @@
1
1
  import { MiddlewareHandler } from "../../types.js";
2
2
  import { Context } from "../../context.js";
3
+ import { StringHashFunction } from "../../utils/buffer.js";
3
4
  //#region src/middleware/basic-auth/index.d.ts
4
5
  type MessageFunction = (c: Context) => string | object | Promise<string | object>;
5
6
  type BasicAuthOptions = {
6
7
  username: string;
7
8
  password: string;
8
9
  realm?: string;
9
- hashFunction?: Function;
10
+ hashFunction?: StringHashFunction;
10
11
  invalidUserMessage?: string | object | MessageFunction;
11
12
  onAuthSuccess?: (c: Context, username: string) => void | Promise<void>;
12
13
  } | {
13
14
  verifyUser: (username: string, password: string, c: Context) => boolean | Promise<boolean>;
14
15
  realm?: string;
15
- hashFunction?: Function;
16
+ hashFunction?: StringHashFunction;
16
17
  invalidUserMessage?: string | object | MessageFunction;
17
18
  onAuthSuccess?: (c: Context, username: string) => void | Promise<void>;
18
19
  };
@@ -25,7 +26,7 @@ type BasicAuthOptions = {
25
26
  * @param {string} options.username - The username for authentication.
26
27
  * @param {string} options.password - The password for authentication.
27
28
  * @param {string} [options.realm="Secure Area"] - The realm attribute for the WWW-Authenticate header.
28
- * @param {Function} [options.hashFunction] - The hash function used for secure comparison.
29
+ * @param {StringHashFunction} [options.hashFunction] - The hash function used for secure comparison.
29
30
  * @param {Function} [options.verifyUser] - The function to verify user credentials.
30
31
  * @param {string | object | MessageFunction} [options.invalidUserMessage="Unauthorized"] - The invalid user message.
31
32
  * @param {Function} [options.onAuthSuccess] - Callback function called on successful authentication.
@@ -2,55 +2,6 @@ import { HTTPException } from "../../http-exception.js";
2
2
  import { timingSafeEqual } from "../../utils/buffer.js";
3
3
  import { auth } from "../../utils/basic-auth.js";
4
4
  //#region src/middleware/basic-auth/index.ts
5
- /**
6
- * Basic Auth Middleware for Hono.
7
- *
8
- * @see {@link https://hono.dev/docs/middleware/builtin/basic-auth}
9
- *
10
- * @param {BasicAuthOptions} options - The options for the basic authentication middleware.
11
- * @param {string} options.username - The username for authentication.
12
- * @param {string} options.password - The password for authentication.
13
- * @param {string} [options.realm="Secure Area"] - The realm attribute for the WWW-Authenticate header.
14
- * @param {Function} [options.hashFunction] - The hash function used for secure comparison.
15
- * @param {Function} [options.verifyUser] - The function to verify user credentials.
16
- * @param {string | object | MessageFunction} [options.invalidUserMessage="Unauthorized"] - The invalid user message.
17
- * @param {Function} [options.onAuthSuccess] - Callback function called on successful authentication.
18
- * @returns {MiddlewareHandler} The middleware handler function.
19
- * @throws {HTTPException} If neither "username and password" nor "verifyUser" options are provided.
20
- *
21
- * @example
22
- * ```ts
23
- * const app = new Hono()
24
- *
25
- * app.use(
26
- * '/auth/*',
27
- * basicAuth({
28
- * username: 'hono',
29
- * password: 'ahotproject',
30
- * })
31
- * )
32
- *
33
- * app.get('/auth/page', (c) => {
34
- * return c.text('You are authorized')
35
- * })
36
- * ```
37
- *
38
- * @example
39
- * ```ts
40
- * // With onAuthSuccess callback
41
- * app.use(
42
- * '/auth/*',
43
- * basicAuth({
44
- * username: 'hono',
45
- * password: 'ahotproject',
46
- * onAuthSuccess: (c, username) => {
47
- * c.set('user', { name: username, role: 'admin' })
48
- * console.log(`User ${username} authenticated`)
49
- * },
50
- * })
51
- * )
52
- * ```
53
- */
54
5
  const basicAuth = (options, ...users) => {
55
6
  const usernamePasswordInOptions = "username" in options && "password" in options;
56
7
  const verifyUserInOptions = "verifyUser" in options;
@@ -1,5 +1,6 @@
1
1
  import { Env, MiddlewareHandler } from "../../types.js";
2
2
  import { Context } from "../../context.js";
3
+ import { StringHashFunction } from "../../utils/buffer.js";
3
4
  //#region src/middleware/bearer-auth/index.d.ts
4
5
  type MessageFunction = (c: Context) => string | object | Promise<string | object>;
5
6
  type CustomizedErrorResponseOptions = {
@@ -11,42 +12,18 @@ type BearerAuthOptions<E extends Env = Env> = {
11
12
  realm?: string;
12
13
  prefix?: string;
13
14
  headerName?: string;
14
- hashFunction?: Function;
15
- /**
16
- * @deprecated Use noAuthenticationHeader.message instead
17
- */
18
- noAuthenticationHeaderMessage?: string | object | MessageFunction;
15
+ hashFunction?: StringHashFunction;
19
16
  noAuthenticationHeader?: CustomizedErrorResponseOptions;
20
- /**
21
- * @deprecated Use invalidAuthenticationHeader.message instead
22
- */
23
- invalidAuthenticationHeaderMessage?: string | object | MessageFunction;
24
17
  invalidAuthenticationHeader?: CustomizedErrorResponseOptions;
25
- /**
26
- * @deprecated Use invalidToken.message instead
27
- */
28
- invalidTokenMessage?: string | object | MessageFunction;
29
18
  invalidToken?: CustomizedErrorResponseOptions;
30
19
  } | {
31
20
  realm?: string;
32
21
  prefix?: string;
33
22
  headerName?: string;
34
23
  verifyToken: (token: string, c: Context<E>) => boolean | Promise<boolean>;
35
- hashFunction?: Function;
36
- /**
37
- * @deprecated Use noAuthenticationHeader.message instead
38
- */
39
- noAuthenticationHeaderMessage?: string | object | MessageFunction;
24
+ hashFunction?: StringHashFunction;
40
25
  noAuthenticationHeader?: CustomizedErrorResponseOptions;
41
- /**
42
- * @deprecated Use invalidAuthenticationHeader.message instead
43
- */
44
- invalidAuthenticationHeaderMessage?: string | object | MessageFunction;
45
26
  invalidAuthenticationHeader?: CustomizedErrorResponseOptions;
46
- /**
47
- * @deprecated Use invalidToken.message instead
48
- */
49
- invalidTokenMessage?: string | object | MessageFunction;
50
27
  invalidToken?: CustomizedErrorResponseOptions;
51
28
  };
52
29
  /**
@@ -61,7 +38,7 @@ type BearerAuthOptions<E extends Env = Env> = {
61
38
  * @param {string} [options.realm=""] - The domain name of the realm, as part of the returned WWW-Authenticate challenge header.
62
39
  * @param {string} [options.prefix="Bearer"] - The prefix (or known as `schema`) for the Authorization header value. If set to the empty string, no prefix is expected.
63
40
  * @param {string} [options.headerName=Authorization] - The header name.
64
- * @param {Function} [options.hashFunction] - A function to handle hashing for safe comparison of authentication tokens.
41
+ * @param {StringHashFunction} [options.hashFunction] - A function to handle hashing for safe comparison of authentication tokens.
65
42
  * @param {string | object | MessageFunction} [options.noAuthenticationHeader.message="Unauthorized"] - The no authentication header message.
66
43
  * @param {string | object | MessageFunction} [options.noAuthenticationHeader.wwwAuthenticateHeader="Bearer realm=\"\""] - The response header value for the WWW-Authenticate header when no authentication header is provided.
67
44
  * @param {string | object | MessageFunction} [options.invalidAuthenticationHeader.message="Bad Request"] - The invalid authentication header message.
@@ -4,42 +4,6 @@ import { timingSafeEqual } from "../../utils/buffer.js";
4
4
  const TOKEN_STRINGS = "[A-Za-z0-9._~+/-]+=*";
5
5
  const PREFIX = "Bearer";
6
6
  const HEADER = "Authorization";
7
- /**
8
- * Bearer Auth Middleware for Hono.
9
- *
10
- * @see {@link https://hono.dev/docs/middleware/builtin/bearer-auth}
11
- *
12
- * @template E - The environment type.
13
- * @param {BearerAuthOptions} options - The options for the bearer authentication middleware.
14
- * @param {string | string[]} [options.token] - The string or array of strings to validate the incoming bearer token against.
15
- * @param {Function} [options.verifyToken] - The function to verify the token.
16
- * @param {string} [options.realm=""] - The domain name of the realm, as part of the returned WWW-Authenticate challenge header.
17
- * @param {string} [options.prefix="Bearer"] - The prefix (or known as `schema`) for the Authorization header value. If set to the empty string, no prefix is expected.
18
- * @param {string} [options.headerName=Authorization] - The header name.
19
- * @param {Function} [options.hashFunction] - A function to handle hashing for safe comparison of authentication tokens.
20
- * @param {string | object | MessageFunction} [options.noAuthenticationHeader.message="Unauthorized"] - The no authentication header message.
21
- * @param {string | object | MessageFunction} [options.noAuthenticationHeader.wwwAuthenticateHeader="Bearer realm=\"\""] - The response header value for the WWW-Authenticate header when no authentication header is provided.
22
- * @param {string | object | MessageFunction} [options.invalidAuthenticationHeader.message="Bad Request"] - The invalid authentication header message.
23
- * @param {string | object | MessageFunction} [options.invalidAuthenticationHeader.wwwAuthenticateHeader="Bearer error=\"invalid_request\""] - The response header value for the WWW-Authenticate header when authentication header is invalid.
24
- * @param {string | object | MessageFunction} [options.invalidToken.message="Unauthorized"] - The invalid token message.
25
- * @param {string | object | MessageFunction} [options.invalidToken.wwwAuthenticateHeader="Bearer error=\"invalid_token\""] - The response header value for the WWW-Authenticate header when token is invalid.
26
- * @returns {MiddlewareHandler<E>} The middleware handler function.
27
- * @throws {Error} If neither "token" nor "verifyToken" options are provided.
28
- * @throws {HTTPException} If authentication fails, with 401 status code for missing or invalid token, or 400 status code for invalid request.
29
- *
30
- * @example
31
- * ```ts
32
- * const app = new Hono()
33
- *
34
- * const token = 'honoishot'
35
- *
36
- * app.use('/api/*', bearerAuth({ token }))
37
- *
38
- * app.get('/api/page', (c) => {
39
- * return c.json({ message: 'You are authorized' })
40
- * })
41
- * ```
42
- */
43
7
  const bearerAuth = (options) => {
44
8
  if (!("token" in options || "verifyToken" in options)) throw new Error("bearer auth middleware requires options for \"token\" or \"verifyToken\"");
45
9
  if (!options.realm) options.realm = "";
@@ -66,7 +30,7 @@ const bearerAuth = (options) => {
66
30
  };
67
31
  return async function bearerAuth(c, next) {
68
32
  const headerToken = c.req.header(options.headerName || HEADER);
69
- if (!headerToken) await throwHTTPException(c, 401, options.noAuthenticationHeader?.wwwAuthenticateHeader || `${wwwAuthenticatePrefix}realm="${realm}"`, options.noAuthenticationHeader?.message || options.noAuthenticationHeaderMessage || "Unauthorized");
33
+ if (!headerToken) await throwHTTPException(c, 401, options.noAuthenticationHeader?.wwwAuthenticateHeader || `${wwwAuthenticatePrefix}realm="${realm}"`, options.noAuthenticationHeader?.message || "Unauthorized");
70
34
  else {
71
35
  let tokenValue;
72
36
  if (prefix === "") tokenValue = headerToken;
@@ -75,7 +39,7 @@ const bearerAuth = (options) => {
75
39
  const prefixLower = prefix.toLowerCase();
76
40
  if (headerLower.startsWith(prefixLower) && headerToken[prefix.length] === " ") tokenValue = headerToken.slice(prefix.length).trimStart();
77
41
  }
78
- if (!tokenValue || !tokenRegexp.test(tokenValue)) await throwHTTPException(c, 400, options.invalidAuthenticationHeader?.wwwAuthenticateHeader || `${wwwAuthenticatePrefix}error="invalid_request"`, options.invalidAuthenticationHeader?.message || options.invalidAuthenticationHeaderMessage || "Bad Request");
42
+ if (!tokenValue || !tokenRegexp.test(tokenValue)) await throwHTTPException(c, 400, options.invalidAuthenticationHeader?.wwwAuthenticateHeader || `${wwwAuthenticatePrefix}error="invalid_request"`, options.invalidAuthenticationHeader?.message || "Bad Request");
79
43
  else {
80
44
  let equal = false;
81
45
  if ("verifyToken" in options) equal = await options.verifyToken(tokenValue, c);
@@ -86,7 +50,7 @@ const bearerAuth = (options) => {
86
50
  break;
87
51
  }
88
52
  }
89
- if (!equal) await throwHTTPException(c, 401, options.invalidToken?.wwwAuthenticateHeader || `${wwwAuthenticatePrefix}error="invalid_token"`, options.invalidToken?.message || options.invalidTokenMessage || "Unauthorized");
53
+ if (!equal) await throwHTTPException(c, 401, options.invalidToken?.wwwAuthenticateHeader || `${wwwAuthenticatePrefix}error="invalid_token"`, options.invalidToken?.message || "Unauthorized");
90
54
  }
91
55
  }
92
56
  await next();
@@ -1,38 +1,6 @@
1
1
  import { HTTPException } from "../../http-exception.js";
2
2
  //#region src/middleware/body-limit/index.ts
3
3
  const ERROR_MESSAGE = "Payload Too Large";
4
- /**
5
- * Body Limit Middleware for Hono.
6
- *
7
- * @see {@link https://hono.dev/docs/middleware/builtin/body-limit}
8
- *
9
- * @param {BodyLimitOptions} options - The options for the body limit middleware.
10
- * @param {number} options.maxSize - The maximum body size allowed.
11
- * @param {OnError} [options.onError] - The error handler to be invoked if the specified body size is exceeded.
12
- * @returns {MiddlewareHandler} The middleware handler function.
13
- *
14
- * @example
15
- * ```ts
16
- * const app = new Hono()
17
- *
18
- * app.post(
19
- * '/upload',
20
- * bodyLimit({
21
- * maxSize: 50 * 1024, // 50kb
22
- * onError: (c) => {
23
- * return c.text('overflow :(', 413)
24
- * },
25
- * }),
26
- * async (c) => {
27
- * const body = await c.req.parseBody()
28
- * if (body['file'] instanceof File) {
29
- * console.log(`Got file sized: ${body['file'].size}`)
30
- * }
31
- * return c.text('pass :)')
32
- * }
33
- * )
34
- * ```
35
- */
36
4
  const bodyLimit = (options) => {
37
5
  const onError = options.onError || (() => {
38
6
  const res = new Response(ERROR_MESSAGE, { status: 413 });
@@ -1,9 +1,6 @@
1
1
  import { sha256 } from "../../utils/crypto.js";
2
2
  import { cloneRawRequest } from "../../request.js";
3
3
  //#region src/middleware/cache/index.ts
4
- /**
5
- * status codes that can be cached by default.
6
- */
7
4
  const defaultCacheableStatusCodes = [200];
8
5
  const defaultMaxQueryBodySize = 65536;
9
6
  const cacheKeyPath = "/.hono/cache";
@@ -69,34 +66,6 @@ const createQueryDigest = async (c, maxQueryBodySize) => {
69
66
  return;
70
67
  }
71
68
  };
72
- /**
73
- * Cache Middleware for Hono.
74
- *
75
- * @see {@link https://hono.dev/docs/middleware/builtin/cache}
76
- *
77
- * @param {Object} options - The options for the cache middleware.
78
- * @param {string | Function} options.cacheName - The name of the cache. Can be used to store multiple caches with different identifiers.
79
- * @param {boolean} [options.wait=false] - A boolean indicating if Hono should wait for the Promise of the `cache.put` function to resolve before continuing with the request. Required to be true for the Deno environment.
80
- * @param {string} [options.cacheControl] - A string of directives for the `Cache-Control` header.
81
- * @param {string | string[]} [options.vary] - Adds the configured request headers to the cache key variants and sets the `Vary` header in the response. If the original response header already contains a `Vary` header, the values are merged, removing any duplicates.
82
- * @param {Function} [options.keyGenerator] - Generates keys for every request in the `cacheName` store. This can be used to cache data based on request parameters or context parameters. QUERY keys additionally include a digest of the request content and its representation metadata.
83
- * @param {number} [options.maxQueryBodySize=65536] - The maximum QUERY request body size in bytes that can be cached. Larger QUERY requests bypass the cache.
84
- * @param {number[]} [options.cacheableStatusCodes=[200]] - An array of status codes that can be cached.
85
- * @param {Function | false} [options.onCacheNotAvailable] - A callback invoked with the reason when `globalThis.caches` is not available or QUERY caching cannot use Web Crypto. By default, the reason is logged to the console. Set to `false` to suppress the log, or provide a custom function.
86
- * @returns {MiddlewareHandler} The middleware handler function.
87
- * @throws {Error} If the `vary` option includes "*".
88
- *
89
- * @example
90
- * ```ts
91
- * app.use(
92
- * '*',
93
- * cache({
94
- * cacheName: 'my-app',
95
- * cacheControl: 'max-age=3600',
96
- * })
97
- * )
98
- * ```
99
- */
100
69
  const cache = (options) => {
101
70
  if (!globalThis.caches) {
102
71
  reportCacheNotAvailable(options.onCacheNotAvailable, "Cache Middleware is not enabled because caches is not defined.");