@depup/hono 4.12.8-depup.0

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 (564) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -0
  3. package/changes.json +5 -0
  4. package/dist/adapter/aws-lambda/conninfo.js +24 -0
  5. package/dist/adapter/aws-lambda/handler.js +366 -0
  6. package/dist/adapter/aws-lambda/index.js +9 -0
  7. package/dist/adapter/aws-lambda/types.js +0 -0
  8. package/dist/adapter/bun/conninfo.js +27 -0
  9. package/dist/adapter/bun/index.js +16 -0
  10. package/dist/adapter/bun/serve-static.js +30 -0
  11. package/dist/adapter/bun/server.js +5 -0
  12. package/dist/adapter/bun/ssg.js +17 -0
  13. package/dist/adapter/bun/websocket.js +71 -0
  14. package/dist/adapter/cloudflare-pages/conninfo.js +9 -0
  15. package/dist/adapter/cloudflare-pages/handler.js +67 -0
  16. package/dist/adapter/cloudflare-pages/index.js +9 -0
  17. package/dist/adapter/cloudflare-workers/conninfo.js +9 -0
  18. package/dist/adapter/cloudflare-workers/index.js +9 -0
  19. package/dist/adapter/cloudflare-workers/serve-static-module.js +8 -0
  20. package/dist/adapter/cloudflare-workers/serve-static.js +22 -0
  21. package/dist/adapter/cloudflare-workers/utils.js +35 -0
  22. package/dist/adapter/cloudflare-workers/websocket.js +41 -0
  23. package/dist/adapter/deno/conninfo.js +14 -0
  24. package/dist/adapter/deno/deno.d.js +0 -0
  25. package/dist/adapter/deno/index.js +12 -0
  26. package/dist/adapter/deno/serve-static.js +40 -0
  27. package/dist/adapter/deno/ssg.js +18 -0
  28. package/dist/adapter/deno/websocket.js +28 -0
  29. package/dist/adapter/lambda-edge/conninfo.js +9 -0
  30. package/dist/adapter/lambda-edge/handler.js +80 -0
  31. package/dist/adapter/lambda-edge/index.js +7 -0
  32. package/dist/adapter/netlify/conninfo.js +9 -0
  33. package/dist/adapter/netlify/handler.js +9 -0
  34. package/dist/adapter/netlify/index.js +2 -0
  35. package/dist/adapter/netlify/mod.js +7 -0
  36. package/dist/adapter/service-worker/handler.js +20 -0
  37. package/dist/adapter/service-worker/index.js +11 -0
  38. package/dist/adapter/service-worker/types.js +0 -0
  39. package/dist/adapter/vercel/conninfo.js +10 -0
  40. package/dist/adapter/vercel/handler.js +7 -0
  41. package/dist/adapter/vercel/index.js +7 -0
  42. package/dist/cjs/adapter/aws-lambda/conninfo.js +46 -0
  43. package/dist/cjs/adapter/aws-lambda/handler.js +397 -0
  44. package/dist/cjs/adapter/aws-lambda/index.js +34 -0
  45. package/dist/cjs/adapter/aws-lambda/types.js +15 -0
  46. package/dist/cjs/adapter/bun/conninfo.js +49 -0
  47. package/dist/cjs/adapter/bun/index.js +45 -0
  48. package/dist/cjs/adapter/bun/serve-static.js +52 -0
  49. package/dist/cjs/adapter/bun/server.js +27 -0
  50. package/dist/cjs/adapter/bun/ssg.js +40 -0
  51. package/dist/cjs/adapter/bun/websocket.js +96 -0
  52. package/dist/cjs/adapter/cloudflare-pages/conninfo.js +31 -0
  53. package/dist/cjs/adapter/cloudflare-pages/handler.js +91 -0
  54. package/dist/cjs/adapter/cloudflare-pages/index.js +34 -0
  55. package/dist/cjs/adapter/cloudflare-workers/conninfo.js +31 -0
  56. package/dist/cjs/adapter/cloudflare-workers/index.js +33 -0
  57. package/dist/cjs/adapter/cloudflare-workers/serve-static-module.js +30 -0
  58. package/dist/cjs/adapter/cloudflare-workers/serve-static.js +44 -0
  59. package/dist/cjs/adapter/cloudflare-workers/utils.js +57 -0
  60. package/dist/cjs/adapter/cloudflare-workers/websocket.js +63 -0
  61. package/dist/cjs/adapter/deno/conninfo.js +36 -0
  62. package/dist/cjs/adapter/deno/deno.d.js +0 -0
  63. package/dist/cjs/adapter/deno/index.js +38 -0
  64. package/dist/cjs/adapter/deno/serve-static.js +62 -0
  65. package/dist/cjs/adapter/deno/ssg.js +41 -0
  66. package/dist/cjs/adapter/deno/websocket.js +50 -0
  67. package/dist/cjs/adapter/lambda-edge/conninfo.js +31 -0
  68. package/dist/cjs/adapter/lambda-edge/handler.js +114 -0
  69. package/dist/cjs/adapter/lambda-edge/index.js +30 -0
  70. package/dist/cjs/adapter/netlify/conninfo.js +31 -0
  71. package/dist/cjs/adapter/netlify/handler.js +31 -0
  72. package/dist/cjs/adapter/netlify/index.js +21 -0
  73. package/dist/cjs/adapter/netlify/mod.js +30 -0
  74. package/dist/cjs/adapter/service-worker/handler.js +42 -0
  75. package/dist/cjs/adapter/service-worker/index.js +34 -0
  76. package/dist/cjs/adapter/service-worker/types.js +15 -0
  77. package/dist/cjs/adapter/vercel/conninfo.js +32 -0
  78. package/dist/cjs/adapter/vercel/handler.js +29 -0
  79. package/dist/cjs/adapter/vercel/index.js +30 -0
  80. package/dist/cjs/client/client.js +195 -0
  81. package/dist/cjs/client/fetch-result-please.js +85 -0
  82. package/dist/cjs/client/index.js +32 -0
  83. package/dist/cjs/client/types.js +15 -0
  84. package/dist/cjs/client/utils.js +105 -0
  85. package/dist/cjs/compose.js +68 -0
  86. package/dist/cjs/context.js +435 -0
  87. package/dist/cjs/helper/accepts/accepts.js +43 -0
  88. package/dist/cjs/helper/accepts/index.js +27 -0
  89. package/dist/cjs/helper/adapter/index.js +81 -0
  90. package/dist/cjs/helper/conninfo/index.js +15 -0
  91. package/dist/cjs/helper/conninfo/types.js +15 -0
  92. package/dist/cjs/helper/cookie/index.js +130 -0
  93. package/dist/cjs/helper/css/common.js +222 -0
  94. package/dist/cjs/helper/css/index.js +142 -0
  95. package/dist/cjs/helper/dev/index.js +79 -0
  96. package/dist/cjs/helper/factory/index.js +54 -0
  97. package/dist/cjs/helper/html/index.js +64 -0
  98. package/dist/cjs/helper/proxy/index.js +111 -0
  99. package/dist/cjs/helper/route/index.js +71 -0
  100. package/dist/cjs/helper/ssg/index.js +43 -0
  101. package/dist/cjs/helper/ssg/middleware.js +73 -0
  102. package/dist/cjs/helper/ssg/plugins.js +70 -0
  103. package/dist/cjs/helper/ssg/ssg.js +316 -0
  104. package/dist/cjs/helper/ssg/utils.js +84 -0
  105. package/dist/cjs/helper/streaming/index.js +35 -0
  106. package/dist/cjs/helper/streaming/sse.js +90 -0
  107. package/dist/cjs/helper/streaming/stream.js +56 -0
  108. package/dist/cjs/helper/streaming/text.js +34 -0
  109. package/dist/cjs/helper/streaming/utils.js +35 -0
  110. package/dist/cjs/helper/testing/index.js +33 -0
  111. package/dist/cjs/helper/websocket/index.js +81 -0
  112. package/dist/cjs/hono-base.js +400 -0
  113. package/dist/cjs/hono.js +43 -0
  114. package/dist/cjs/http-exception.js +57 -0
  115. package/dist/cjs/index.js +27 -0
  116. package/dist/cjs/jsx/base.js +374 -0
  117. package/dist/cjs/jsx/children.js +44 -0
  118. package/dist/cjs/jsx/components.js +201 -0
  119. package/dist/cjs/jsx/constants.js +42 -0
  120. package/dist/cjs/jsx/context.js +62 -0
  121. package/dist/cjs/jsx/dom/client.js +76 -0
  122. package/dist/cjs/jsx/dom/components.js +55 -0
  123. package/dist/cjs/jsx/dom/context.js +71 -0
  124. package/dist/cjs/jsx/dom/css.js +161 -0
  125. package/dist/cjs/jsx/dom/hooks/index.js +74 -0
  126. package/dist/cjs/jsx/dom/index.js +181 -0
  127. package/dist/cjs/jsx/dom/intrinsic-element/components.js +399 -0
  128. package/dist/cjs/jsx/dom/jsx-dev-runtime.js +52 -0
  129. package/dist/cjs/jsx/dom/jsx-runtime.js +32 -0
  130. package/dist/cjs/jsx/dom/render.js +619 -0
  131. package/dist/cjs/jsx/dom/server.js +67 -0
  132. package/dist/cjs/jsx/dom/utils.js +32 -0
  133. package/dist/cjs/jsx/hooks/index.js +370 -0
  134. package/dist/cjs/jsx/index.js +138 -0
  135. package/dist/cjs/jsx/intrinsic-element/common.js +50 -0
  136. package/dist/cjs/jsx/intrinsic-element/components.js +189 -0
  137. package/dist/cjs/jsx/intrinsic-elements.js +15 -0
  138. package/dist/cjs/jsx/jsx-dev-runtime.js +41 -0
  139. package/dist/cjs/jsx/jsx-runtime.js +68 -0
  140. package/dist/cjs/jsx/streaming.js +177 -0
  141. package/dist/cjs/jsx/types.js +15 -0
  142. package/dist/cjs/jsx/utils.js +50 -0
  143. package/dist/cjs/middleware/basic-auth/index.js +88 -0
  144. package/dist/cjs/middleware/bearer-auth/index.js +114 -0
  145. package/dist/cjs/middleware/body-limit/index.js +84 -0
  146. package/dist/cjs/middleware/cache/index.js +111 -0
  147. package/dist/cjs/middleware/combine/index.js +101 -0
  148. package/dist/cjs/middleware/compress/index.js +61 -0
  149. package/dist/cjs/middleware/context-storage/index.js +47 -0
  150. package/dist/cjs/middleware/cors/index.js +109 -0
  151. package/dist/cjs/middleware/csrf/index.js +77 -0
  152. package/dist/cjs/middleware/etag/digest.js +55 -0
  153. package/dist/cjs/middleware/etag/index.js +95 -0
  154. package/dist/cjs/middleware/ip-restriction/index.js +124 -0
  155. package/dist/cjs/middleware/jsx-renderer/index.js +82 -0
  156. package/dist/cjs/middleware/jwk/index.js +27 -0
  157. package/dist/cjs/middleware/jwk/jwk.js +134 -0
  158. package/dist/cjs/middleware/jwt/index.js +38 -0
  159. package/dist/cjs/middleware/jwt/jwt.js +140 -0
  160. package/dist/cjs/middleware/language/index.js +35 -0
  161. package/dist/cjs/middleware/language/language.js +221 -0
  162. package/dist/cjs/middleware/logger/index.js +72 -0
  163. package/dist/cjs/middleware/method-override/index.js +104 -0
  164. package/dist/cjs/middleware/powered-by/index.js +32 -0
  165. package/dist/cjs/middleware/pretty-json/index.js +37 -0
  166. package/dist/cjs/middleware/request-id/index.js +27 -0
  167. package/dist/cjs/middleware/request-id/request-id.js +43 -0
  168. package/dist/cjs/middleware/secure-headers/index.js +29 -0
  169. package/dist/cjs/middleware/secure-headers/permissions-policy.js +15 -0
  170. package/dist/cjs/middleware/secure-headers/secure-headers.js +189 -0
  171. package/dist/cjs/middleware/serve-static/index.js +99 -0
  172. package/dist/cjs/middleware/serve-static/path.js +40 -0
  173. package/dist/cjs/middleware/timeout/index.js +47 -0
  174. package/dist/cjs/middleware/timing/index.js +35 -0
  175. package/dist/cjs/middleware/timing/timing.js +128 -0
  176. package/dist/cjs/middleware/trailing-slash/index.js +62 -0
  177. package/dist/cjs/package.json +3 -0
  178. package/dist/cjs/preset/quick.js +38 -0
  179. package/dist/cjs/preset/tiny.js +34 -0
  180. package/dist/cjs/request/constants.js +27 -0
  181. package/dist/cjs/request.js +324 -0
  182. package/dist/cjs/router/linear-router/index.js +27 -0
  183. package/dist/cjs/router/linear-router/router.js +140 -0
  184. package/dist/cjs/router/pattern-router/index.js +27 -0
  185. package/dist/cjs/router/pattern-router/router.js +70 -0
  186. package/dist/cjs/router/reg-exp-router/index.js +34 -0
  187. package/dist/cjs/router/reg-exp-router/matcher.js +48 -0
  188. package/dist/cjs/router/reg-exp-router/node.js +134 -0
  189. package/dist/cjs/router/reg-exp-router/prepared-router.js +166 -0
  190. package/dist/cjs/router/reg-exp-router/router.js +208 -0
  191. package/dist/cjs/router/reg-exp-router/trie.js +81 -0
  192. package/dist/cjs/router/smart-router/index.js +27 -0
  193. package/dist/cjs/router/smart-router/router.js +80 -0
  194. package/dist/cjs/router/trie-router/index.js +27 -0
  195. package/dist/cjs/router/trie-router/node.js +201 -0
  196. package/dist/cjs/router/trie-router/router.js +48 -0
  197. package/dist/cjs/router.js +40 -0
  198. package/dist/cjs/types.js +28 -0
  199. package/dist/cjs/utils/accept.js +245 -0
  200. package/dist/cjs/utils/basic-auth.js +45 -0
  201. package/dist/cjs/utils/body.js +97 -0
  202. package/dist/cjs/utils/buffer.js +102 -0
  203. package/dist/cjs/utils/color.js +48 -0
  204. package/dist/cjs/utils/compress.js +27 -0
  205. package/dist/cjs/utils/concurrent.js +61 -0
  206. package/dist/cjs/utils/constants.js +27 -0
  207. package/dist/cjs/utils/cookie.js +177 -0
  208. package/dist/cjs/utils/crypto.js +69 -0
  209. package/dist/cjs/utils/encode.js +54 -0
  210. package/dist/cjs/utils/filepath.js +58 -0
  211. package/dist/cjs/utils/handler.js +36 -0
  212. package/dist/cjs/utils/headers.js +15 -0
  213. package/dist/cjs/utils/html.js +150 -0
  214. package/dist/cjs/utils/http-status.js +15 -0
  215. package/dist/cjs/utils/ipaddr.js +129 -0
  216. package/dist/cjs/utils/jwt/index.js +28 -0
  217. package/dist/cjs/utils/jwt/jwa.js +42 -0
  218. package/dist/cjs/utils/jwt/jws.js +215 -0
  219. package/dist/cjs/utils/jwt/jwt.js +213 -0
  220. package/dist/cjs/utils/jwt/types.js +161 -0
  221. package/dist/cjs/utils/jwt/utf8.js +30 -0
  222. package/dist/cjs/utils/mime.js +108 -0
  223. package/dist/cjs/utils/stream.js +101 -0
  224. package/dist/cjs/utils/types.js +15 -0
  225. package/dist/cjs/utils/url.js +256 -0
  226. package/dist/cjs/validator/index.js +27 -0
  227. package/dist/cjs/validator/utils.js +15 -0
  228. package/dist/cjs/validator/validator.js +108 -0
  229. package/dist/client/client.js +180 -0
  230. package/dist/client/fetch-result-please.js +62 -0
  231. package/dist/client/index.js +8 -0
  232. package/dist/client/types.js +0 -0
  233. package/dist/client/utils.js +76 -0
  234. package/dist/compose.js +46 -0
  235. package/dist/context.js +412 -0
  236. package/dist/helper/accepts/accepts.js +20 -0
  237. package/dist/helper/accepts/index.js +5 -0
  238. package/dist/helper/adapter/index.js +56 -0
  239. package/dist/helper/conninfo/index.js +0 -0
  240. package/dist/helper/conninfo/types.js +0 -0
  241. package/dist/helper/cookie/index.js +102 -0
  242. package/dist/helper/css/common.js +185 -0
  243. package/dist/helper/css/index.js +125 -0
  244. package/dist/helper/dev/index.js +55 -0
  245. package/dist/helper/factory/index.js +30 -0
  246. package/dist/helper/html/index.js +41 -0
  247. package/dist/helper/proxy/index.js +89 -0
  248. package/dist/helper/route/index.js +46 -0
  249. package/dist/helper/ssg/index.js +19 -0
  250. package/dist/helper/ssg/middleware.js +45 -0
  251. package/dist/helper/ssg/plugins.js +47 -0
  252. package/dist/helper/ssg/ssg.js +287 -0
  253. package/dist/helper/ssg/utils.js +59 -0
  254. package/dist/helper/streaming/index.js +10 -0
  255. package/dist/helper/streaming/sse.js +67 -0
  256. package/dist/helper/streaming/stream.js +34 -0
  257. package/dist/helper/streaming/text.js +12 -0
  258. package/dist/helper/streaming/utils.js +13 -0
  259. package/dist/helper/testing/index.js +11 -0
  260. package/dist/helper/websocket/index.js +57 -0
  261. package/dist/hono-base.js +378 -0
  262. package/dist/hono.js +21 -0
  263. package/dist/http-exception.js +35 -0
  264. package/dist/index.js +5 -0
  265. package/dist/jsx/base.js +331 -0
  266. package/dist/jsx/children.js +21 -0
  267. package/dist/jsx/components.js +178 -0
  268. package/dist/jsx/constants.js +15 -0
  269. package/dist/jsx/context.js +38 -0
  270. package/dist/jsx/dom/client.js +53 -0
  271. package/dist/jsx/dom/components.js +32 -0
  272. package/dist/jsx/dom/context.js +48 -0
  273. package/dist/jsx/dom/css.js +143 -0
  274. package/dist/jsx/dom/hooks/index.js +48 -0
  275. package/dist/jsx/dom/index.js +142 -0
  276. package/dist/jsx/dom/intrinsic-element/components.js +374 -0
  277. package/dist/jsx/dom/jsx-dev-runtime.js +19 -0
  278. package/dist/jsx/dom/jsx-runtime.js +8 -0
  279. package/dist/jsx/dom/render.js +595 -0
  280. package/dist/jsx/dom/server.js +33 -0
  281. package/dist/jsx/dom/utils.js +10 -0
  282. package/dist/jsx/hooks/index.js +328 -0
  283. package/dist/jsx/index.js +103 -0
  284. package/dist/jsx/intrinsic-element/common.js +24 -0
  285. package/dist/jsx/intrinsic-element/components.js +165 -0
  286. package/dist/jsx/intrinsic-elements.js +0 -0
  287. package/dist/jsx/jsx-dev-runtime.js +18 -0
  288. package/dist/jsx/jsx-runtime.js +41 -0
  289. package/dist/jsx/streaming.js +153 -0
  290. package/dist/jsx/types.js +0 -0
  291. package/dist/jsx/utils.js +27 -0
  292. package/dist/middleware/basic-auth/index.js +66 -0
  293. package/dist/middleware/bearer-auth/index.js +92 -0
  294. package/dist/middleware/body-limit/index.js +62 -0
  295. package/dist/middleware/cache/index.js +89 -0
  296. package/dist/middleware/combine/index.js +77 -0
  297. package/dist/middleware/compress/index.js +39 -0
  298. package/dist/middleware/context-storage/index.js +23 -0
  299. package/dist/middleware/cors/index.js +87 -0
  300. package/dist/middleware/csrf/index.js +55 -0
  301. package/dist/middleware/etag/digest.js +33 -0
  302. package/dist/middleware/etag/index.js +72 -0
  303. package/dist/middleware/ip-restriction/index.js +107 -0
  304. package/dist/middleware/jsx-renderer/index.js +58 -0
  305. package/dist/middleware/jwk/index.js +5 -0
  306. package/dist/middleware/jwk/jwk.js +112 -0
  307. package/dist/middleware/jwt/index.js +11 -0
  308. package/dist/middleware/jwt/jwt.js +114 -0
  309. package/dist/middleware/language/index.js +15 -0
  310. package/dist/middleware/language/language.js +190 -0
  311. package/dist/middleware/logger/index.js +44 -0
  312. package/dist/middleware/method-override/index.js +82 -0
  313. package/dist/middleware/powered-by/index.js +10 -0
  314. package/dist/middleware/pretty-json/index.js +15 -0
  315. package/dist/middleware/request-id/index.js +5 -0
  316. package/dist/middleware/request-id/request-id.js +21 -0
  317. package/dist/middleware/secure-headers/index.js +6 -0
  318. package/dist/middleware/secure-headers/permissions-policy.js +0 -0
  319. package/dist/middleware/secure-headers/secure-headers.js +166 -0
  320. package/dist/middleware/serve-static/index.js +77 -0
  321. package/dist/middleware/serve-static/path.js +18 -0
  322. package/dist/middleware/timeout/index.js +25 -0
  323. package/dist/middleware/timing/index.js +9 -0
  324. package/dist/middleware/timing/timing.js +102 -0
  325. package/dist/middleware/trailing-slash/index.js +39 -0
  326. package/dist/preset/quick.js +16 -0
  327. package/dist/preset/tiny.js +12 -0
  328. package/dist/request/constants.js +5 -0
  329. package/dist/request.js +301 -0
  330. package/dist/router/linear-router/index.js +5 -0
  331. package/dist/router/linear-router/router.js +118 -0
  332. package/dist/router/pattern-router/index.js +5 -0
  333. package/dist/router/pattern-router/router.js +48 -0
  334. package/dist/router/reg-exp-router/index.js +9 -0
  335. package/dist/router/reg-exp-router/matcher.js +25 -0
  336. package/dist/router/reg-exp-router/node.js +111 -0
  337. package/dist/router/reg-exp-router/prepared-router.js +142 -0
  338. package/dist/router/reg-exp-router/router.js +190 -0
  339. package/dist/router/reg-exp-router/trie.js +59 -0
  340. package/dist/router/smart-router/index.js +5 -0
  341. package/dist/router/smart-router/router.js +58 -0
  342. package/dist/router/trie-router/index.js +5 -0
  343. package/dist/router/trie-router/node.js +179 -0
  344. package/dist/router/trie-router/router.js +26 -0
  345. package/dist/router.js +14 -0
  346. package/dist/tsconfig.build.tsbuildinfo +1 -0
  347. package/dist/types/adapter/aws-lambda/conninfo.d.ts +27 -0
  348. package/dist/types/adapter/aws-lambda/handler.d.ts +184 -0
  349. package/dist/types/adapter/aws-lambda/index.d.ts +8 -0
  350. package/dist/types/adapter/aws-lambda/types.d.ts +144 -0
  351. package/dist/types/adapter/bun/conninfo.d.ts +7 -0
  352. package/dist/types/adapter/bun/index.d.ts +10 -0
  353. package/dist/types/adapter/bun/serve-static.d.ts +3 -0
  354. package/dist/types/adapter/bun/server.d.ts +12 -0
  355. package/dist/types/adapter/bun/ssg.d.ts +13 -0
  356. package/dist/types/adapter/bun/websocket.d.ts +39 -0
  357. package/dist/types/adapter/cloudflare-pages/conninfo.d.ts +21 -0
  358. package/dist/types/adapter/cloudflare-pages/handler.d.ts +33 -0
  359. package/dist/types/adapter/cloudflare-pages/index.d.ts +7 -0
  360. package/dist/types/adapter/cloudflare-workers/conninfo.d.ts +2 -0
  361. package/dist/types/adapter/cloudflare-workers/index.d.ts +7 -0
  362. package/dist/types/adapter/cloudflare-workers/serve-static-module.d.ts +4 -0
  363. package/dist/types/adapter/cloudflare-workers/serve-static.d.ts +16 -0
  364. package/dist/types/adapter/cloudflare-workers/utils.d.ts +5 -0
  365. package/dist/types/adapter/cloudflare-workers/websocket.d.ts +2 -0
  366. package/dist/types/adapter/deno/conninfo.d.ts +7 -0
  367. package/dist/types/adapter/deno/index.d.ts +8 -0
  368. package/dist/types/adapter/deno/serve-static.d.ts +3 -0
  369. package/dist/types/adapter/deno/ssg.d.ts +13 -0
  370. package/dist/types/adapter/deno/websocket.d.ts +2 -0
  371. package/dist/types/adapter/lambda-edge/conninfo.d.ts +2 -0
  372. package/dist/types/adapter/lambda-edge/handler.d.ts +87 -0
  373. package/dist/types/adapter/lambda-edge/index.d.ts +7 -0
  374. package/dist/types/adapter/netlify/conninfo.d.ts +21 -0
  375. package/dist/types/adapter/netlify/handler.d.ts +2 -0
  376. package/dist/types/adapter/netlify/index.d.ts +5 -0
  377. package/dist/types/adapter/netlify/mod.d.ts +2 -0
  378. package/dist/types/adapter/service-worker/handler.d.ts +16 -0
  379. package/dist/types/adapter/service-worker/index.d.ts +28 -0
  380. package/dist/types/adapter/service-worker/types.d.ts +12 -0
  381. package/dist/types/adapter/vercel/conninfo.d.ts +2 -0
  382. package/dist/types/adapter/vercel/handler.d.ts +2 -0
  383. package/dist/types/adapter/vercel/index.d.ts +6 -0
  384. package/dist/types/client/client.d.ts +4 -0
  385. package/dist/types/client/fetch-result-please.d.ts +35 -0
  386. package/dist/types/client/index.d.ts +7 -0
  387. package/dist/types/client/types.d.ts +209 -0
  388. package/dist/types/client/utils.d.ts +18 -0
  389. package/dist/types/compose.d.ts +14 -0
  390. package/dist/types/context.d.ts +455 -0
  391. package/dist/types/helper/accepts/accepts.d.ts +30 -0
  392. package/dist/types/helper/accepts/index.d.ts +5 -0
  393. package/dist/types/helper/adapter/index.d.ts +12 -0
  394. package/dist/types/helper/conninfo/index.d.ts +5 -0
  395. package/dist/types/helper/conninfo/types.d.ts +36 -0
  396. package/dist/types/helper/cookie/index.d.ts +24 -0
  397. package/dist/types/helper/css/common.d.ts +42 -0
  398. package/dist/types/helper/css/index.d.ts +73 -0
  399. package/dist/types/helper/dev/index.d.ts +20 -0
  400. package/dist/types/helper/factory/index.d.ts +82 -0
  401. package/dist/types/helper/html/index.d.ts +8 -0
  402. package/dist/types/helper/proxy/index.d.ts +72 -0
  403. package/dist/types/helper/route/index.d.ts +75 -0
  404. package/dist/types/helper/ssg/index.d.ts +7 -0
  405. package/dist/types/helper/ssg/middleware.d.ts +44 -0
  406. package/dist/types/helper/ssg/plugins.d.ts +27 -0
  407. package/dist/types/helper/ssg/ssg.d.ts +91 -0
  408. package/dist/types/helper/ssg/utils.d.ts +15 -0
  409. package/dist/types/helper/streaming/index.d.ts +8 -0
  410. package/dist/types/helper/streaming/sse.d.ts +13 -0
  411. package/dist/types/helper/streaming/stream.d.ts +3 -0
  412. package/dist/types/helper/streaming/text.d.ts +3 -0
  413. package/dist/types/helper/streaming/utils.d.ts +1 -0
  414. package/dist/types/helper/testing/index.d.ts +12 -0
  415. package/dist/types/helper/websocket/index.d.ts +69 -0
  416. package/dist/types/hono-base.d.ts +220 -0
  417. package/dist/types/hono.d.ts +19 -0
  418. package/dist/types/http-exception.d.ts +59 -0
  419. package/dist/types/index.d.ts +36 -0
  420. package/dist/types/jsx/base.d.ts +58 -0
  421. package/dist/types/jsx/children.d.ts +9 -0
  422. package/dist/types/jsx/components.d.ts +15 -0
  423. package/dist/types/jsx/constants.d.ts +6 -0
  424. package/dist/types/jsx/context.d.ts +12 -0
  425. package/dist/types/jsx/dom/client.d.ts +31 -0
  426. package/dist/types/jsx/dom/components.d.ts +10 -0
  427. package/dist/types/jsx/dom/context.d.ts +3 -0
  428. package/dist/types/jsx/dom/css.d.ts +77 -0
  429. package/dist/types/jsx/dom/hooks/index.d.ts +39 -0
  430. package/dist/types/jsx/dom/index.d.ts +88 -0
  431. package/dist/types/jsx/dom/intrinsic-element/components.d.ts +16 -0
  432. package/dist/types/jsx/dom/jsx-dev-runtime.d.ts +8 -0
  433. package/dist/types/jsx/dom/jsx-runtime.d.ts +7 -0
  434. package/dist/types/jsx/dom/render.d.ts +73 -0
  435. package/dist/types/jsx/dom/server.d.ts +106 -0
  436. package/dist/types/jsx/dom/utils.d.ts +1 -0
  437. package/dist/types/jsx/hooks/index.d.ts +45 -0
  438. package/dist/types/jsx/index.d.ts +75 -0
  439. package/dist/types/jsx/intrinsic-element/common.d.ts +6 -0
  440. package/dist/types/jsx/intrinsic-element/components.d.ts +13 -0
  441. package/dist/types/jsx/intrinsic-elements.d.ts +722 -0
  442. package/dist/types/jsx/jsx-dev-runtime.d.ts +8 -0
  443. package/dist/types/jsx/jsx-runtime.d.ts +12 -0
  444. package/dist/types/jsx/streaming.d.ts +36 -0
  445. package/dist/types/jsx/types.d.ts +35 -0
  446. package/dist/types/jsx/utils.d.ts +2 -0
  447. package/dist/types/middleware/basic-auth/index.d.ts +75 -0
  448. package/dist/types/middleware/bearer-auth/index.d.ts +91 -0
  449. package/dist/types/middleware/body-limit/index.d.ts +45 -0
  450. package/dist/types/middleware/cache/index.d.ts +41 -0
  451. package/dist/types/middleware/combine/index.d.ts +85 -0
  452. package/dist/types/middleware/compress/index.d.ts +29 -0
  453. package/dist/types/middleware/context-storage/index.d.ts +40 -0
  454. package/dist/types/middleware/cors/index.d.ts +55 -0
  455. package/dist/types/middleware/csrf/index.d.ts +78 -0
  456. package/dist/types/middleware/etag/digest.d.ts +1 -0
  457. package/dist/types/middleware/etag/index.d.ts +42 -0
  458. package/dist/types/middleware/ip-restriction/index.d.ts +31 -0
  459. package/dist/types/middleware/jsx-renderer/index.d.ts +77 -0
  460. package/dist/types/middleware/jwk/index.d.ts +1 -0
  461. package/dist/types/middleware/jwk/jwk.d.ts +54 -0
  462. package/dist/types/middleware/jwt/index.d.ts +8 -0
  463. package/dist/types/middleware/jwt/jwt.d.ts +67 -0
  464. package/dist/types/middleware/language/index.d.ts +7 -0
  465. package/dist/types/middleware/language/language.d.ts +102 -0
  466. package/dist/types/middleware/logger/index.d.ts +24 -0
  467. package/dist/types/middleware/method-override/index.d.ts +48 -0
  468. package/dist/types/middleware/powered-by/index.d.ts +29 -0
  469. package/dist/types/middleware/pretty-json/index.d.ts +42 -0
  470. package/dist/types/middleware/request-id/index.d.ts +7 -0
  471. package/dist/types/middleware/request-id/request-id.d.ts +37 -0
  472. package/dist/types/middleware/secure-headers/index.d.ts +8 -0
  473. package/dist/types/middleware/secure-headers/permissions-policy.d.ts +14 -0
  474. package/dist/types/middleware/secure-headers/secure-headers.d.ts +109 -0
  475. package/dist/types/middleware/serve-static/index.d.ts +31 -0
  476. package/dist/types/middleware/serve-static/path.d.ts +5 -0
  477. package/dist/types/middleware/timeout/index.d.ts +31 -0
  478. package/dist/types/middleware/timing/index.d.ts +7 -0
  479. package/dist/types/middleware/timing/timing.d.ts +129 -0
  480. package/dist/types/middleware/trailing-slash/index.d.ts +78 -0
  481. package/dist/types/package.json +3 -0
  482. package/dist/types/preset/quick.d.ts +10 -0
  483. package/dist/types/preset/tiny.d.ts +10 -0
  484. package/dist/types/request/constants.d.ts +1 -0
  485. package/dist/types/request.d.ts +313 -0
  486. package/dist/types/router/linear-router/index.d.ts +5 -0
  487. package/dist/types/router/linear-router/router.d.ts +7 -0
  488. package/dist/types/router/pattern-router/index.d.ts +5 -0
  489. package/dist/types/router/pattern-router/router.d.ts +7 -0
  490. package/dist/types/router/reg-exp-router/index.d.ts +6 -0
  491. package/dist/types/router/reg-exp-router/matcher.d.ts +7 -0
  492. package/dist/types/router/reg-exp-router/node.d.ts +10 -0
  493. package/dist/types/router/reg-exp-router/prepared-router.d.ts +17 -0
  494. package/dist/types/router/reg-exp-router/router.d.ts +11 -0
  495. package/dist/types/router/reg-exp-router/trie.d.ts +7 -0
  496. package/dist/types/router/smart-router/index.d.ts +5 -0
  497. package/dist/types/router/smart-router/router.d.ts +11 -0
  498. package/dist/types/router/trie-router/index.d.ts +5 -0
  499. package/dist/types/router/trie-router/node.d.ts +7 -0
  500. package/dist/types/router/trie-router/router.d.ts +8 -0
  501. package/dist/types/router.d.ts +97 -0
  502. package/dist/types/types.d.ts +573 -0
  503. package/dist/types/utils/accept.d.ts +6 -0
  504. package/dist/types/utils/basic-auth.d.ts +5 -0
  505. package/dist/types/utils/body.d.ts +79 -0
  506. package/dist/types/utils/buffer.d.ts +17 -0
  507. package/dist/types/utils/color.d.ts +21 -0
  508. package/dist/types/utils/compress.d.ts +8 -0
  509. package/dist/types/utils/concurrent.d.ts +11 -0
  510. package/dist/types/utils/constants.d.ts +4 -0
  511. package/dist/types/utils/cookie.d.ts +40 -0
  512. package/dist/types/utils/crypto.d.ts +15 -0
  513. package/dist/types/utils/encode.d.ts +8 -0
  514. package/dist/types/utils/filepath.d.ts +12 -0
  515. package/dist/types/utils/handler.d.ts +6 -0
  516. package/dist/types/utils/headers.d.ts +8 -0
  517. package/dist/types/utils/html.d.ts +44 -0
  518. package/dist/types/utils/http-status.d.ts +32 -0
  519. package/dist/types/utils/ipaddr.d.ts +40 -0
  520. package/dist/types/utils/jwt/index.d.ts +18 -0
  521. package/dist/types/utils/jwt/jwa.d.ts +23 -0
  522. package/dist/types/utils/jwt/jws.d.ts +12 -0
  523. package/dist/types/utils/jwt/jwt.d.ts +43 -0
  524. package/dist/types/utils/jwt/types.d.ts +86 -0
  525. package/dist/types/utils/jwt/utf8.d.ts +6 -0
  526. package/dist/types/utils/mime.d.ts +70 -0
  527. package/dist/types/utils/stream.d.ts +31 -0
  528. package/dist/types/utils/types.d.ts +74 -0
  529. package/dist/types/utils/url.d.ts +39 -0
  530. package/dist/types/validator/index.d.ts +7 -0
  531. package/dist/types/validator/utils.d.ts +29 -0
  532. package/dist/types/validator/validator.d.ts +16 -0
  533. package/dist/types.js +6 -0
  534. package/dist/utils/accept.js +223 -0
  535. package/dist/utils/basic-auth.js +23 -0
  536. package/dist/utils/body.js +75 -0
  537. package/dist/utils/buffer.js +77 -0
  538. package/dist/utils/color.js +25 -0
  539. package/dist/utils/compress.js +5 -0
  540. package/dist/utils/concurrent.js +39 -0
  541. package/dist/utils/constants.js +5 -0
  542. package/dist/utils/cookie.js +152 -0
  543. package/dist/utils/crypto.js +44 -0
  544. package/dist/utils/encode.js +29 -0
  545. package/dist/utils/filepath.js +35 -0
  546. package/dist/utils/handler.js +13 -0
  547. package/dist/utils/headers.js +0 -0
  548. package/dist/utils/html.js +123 -0
  549. package/dist/utils/http-status.js +0 -0
  550. package/dist/utils/ipaddr.js +102 -0
  551. package/dist/utils/jwt/index.js +6 -0
  552. package/dist/utils/jwt/jwa.js +20 -0
  553. package/dist/utils/jwt/jws.js +192 -0
  554. package/dist/utils/jwt/jwt.js +201 -0
  555. package/dist/utils/jwt/types.js +124 -0
  556. package/dist/utils/jwt/utf8.js +7 -0
  557. package/dist/utils/mime.js +84 -0
  558. package/dist/utils/stream.js +79 -0
  559. package/dist/utils/types.js +0 -0
  560. package/dist/utils/url.js +222 -0
  561. package/dist/validator/index.js +5 -0
  562. package/dist/validator/utils.js +0 -0
  563. package/dist/validator/validator.js +86 -0
  564. package/package.json +702 -0
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @module
3
+ * Stream utility.
4
+ */
5
+ export declare class StreamingApi {
6
+ private writer;
7
+ private encoder;
8
+ private writable;
9
+ private abortSubscribers;
10
+ responseReadable: ReadableStream;
11
+ /**
12
+ * Whether the stream has been aborted.
13
+ */
14
+ aborted: boolean;
15
+ /**
16
+ * Whether the stream has been closed normally.
17
+ */
18
+ closed: boolean;
19
+ constructor(writable: WritableStream, _readable: ReadableStream);
20
+ write(input: Uint8Array | string): Promise<StreamingApi>;
21
+ writeln(input: string): Promise<StreamingApi>;
22
+ sleep(ms: number): Promise<unknown>;
23
+ close(): Promise<void>;
24
+ pipe(body: ReadableStream): Promise<void>;
25
+ onAbort(listener: () => void | Promise<void>): void;
26
+ /**
27
+ * Abort the stream.
28
+ * You can call this method when stream is aborted by external event.
29
+ */
30
+ abort(): void;
31
+ }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @module
3
+ * Types utility.
4
+ */
5
+ export type Expect<T extends true> = T;
6
+ export type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
7
+ export type NotEqual<X, Y> = true extends Equal<X, Y> ? false : true;
8
+ export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
9
+ export type RemoveBlankRecord<T> = T extends Record<infer K, unknown> ? (K extends string ? T : never) : never;
10
+ export type IfAnyThenEmptyObject<T> = 0 extends 1 & T ? {} : T;
11
+ export type JSONPrimitive = string | boolean | number | null;
12
+ export type JSONArray = (JSONPrimitive | JSONObject | JSONArray)[];
13
+ export type JSONObject = {
14
+ [key: string]: JSONPrimitive | JSONArray | JSONObject | object | InvalidJSONValue;
15
+ };
16
+ export type InvalidJSONValue = undefined | symbol | ((...args: unknown[]) => unknown);
17
+ type InvalidToNull<T> = T extends InvalidJSONValue ? null : T;
18
+ type IsInvalid<T> = T extends InvalidJSONValue ? true : false;
19
+ /**
20
+ * symbol keys are omitted through `JSON.stringify`
21
+ */
22
+ type OmitSymbolKeys<T> = {
23
+ [K in keyof T as K extends symbol ? never : K]: T[K];
24
+ };
25
+ export type JSONValue = JSONObject | JSONArray | JSONPrimitive;
26
+ /**
27
+ * Convert a type to a JSON-compatible type.
28
+ *
29
+ * Non-JSON values such as `Date` implement `.toJSON()`,
30
+ * so they can be transformed to a value assignable to `JSONObject`
31
+ *
32
+ * `JSON.stringify()` throws a `TypeError` when it encounters a `bigint` value,
33
+ * unless a custom `replacer` function or `.toJSON()` method is provided.
34
+ *
35
+ * This behaviour can be controlled by the `TError` generic type parameter,
36
+ * which defaults to `bigint | ReadonlyArray<bigint>`.
37
+ * You can set it to `never` to disable this check.
38
+ */
39
+ export type JSONParsed<T, TError = bigint | ReadonlyArray<bigint>> = T extends {
40
+ toJSON(): infer J;
41
+ } ? (() => J) extends () => JSONPrimitive ? J : (() => J) extends () => {
42
+ toJSON(): unknown;
43
+ } ? {} : JSONParsed<J, TError> : T extends JSONPrimitive ? T : T extends InvalidJSONValue ? never : T extends ReadonlyArray<unknown> ? {
44
+ [K in keyof T]: JSONParsed<InvalidToNull<T[K]>, TError>;
45
+ } : T extends Set<unknown> | Map<unknown, unknown> | Record<string, never> ? {} : T extends object ? T[keyof T] extends TError ? never : {
46
+ [K in keyof OmitSymbolKeys<T> as IsInvalid<T[K]> extends true ? never : K]: boolean extends IsInvalid<T[K]> ? JSONParsed<T[K], TError> | undefined : JSONParsed<T[K], TError>;
47
+ } : T extends unknown ? T extends TError ? never : JSONValue : never;
48
+ /**
49
+ * Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
50
+ * @copyright from sindresorhus/type-fest
51
+ */
52
+ export type Simplify<T> = {
53
+ [KeyType in keyof T]: T[KeyType];
54
+ } & {};
55
+ /**
56
+ * A simple extension of Simplify that will deeply traverse array elements.
57
+ */
58
+ export type SimplifyDeepArray<T> = T extends any[] ? {
59
+ [E in keyof T]: SimplifyDeepArray<T[E]>;
60
+ } : Simplify<T>;
61
+ export type InterfaceToType<T> = T extends Function ? T : {
62
+ [K in keyof T]: InterfaceToType<T[K]>;
63
+ };
64
+ export type RequiredKeysOf<BaseType extends object> = Exclude<{
65
+ [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]> ? Key : never;
66
+ }[keyof BaseType], undefined>;
67
+ export type HasRequiredKeys<BaseType extends object> = RequiredKeysOf<BaseType> extends never ? false : true;
68
+ export type IsAny<T> = boolean extends (T extends never ? true : false) ? true : false;
69
+ /**
70
+ * String literal types with auto-completion
71
+ * @see https://github.com/Microsoft/TypeScript/issues/29729
72
+ */
73
+ export type StringLiteralUnion<T> = T | (string & Record<never, never>);
74
+ export {};
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @module
3
+ * URL utility.
4
+ */
5
+ export type Pattern = readonly [string, string, RegExp | true] | '*';
6
+ export declare const splitPath: (path: string) => string[];
7
+ export declare const splitRoutingPath: (routePath: string) => string[];
8
+ export declare const getPattern: (label: string, next?: string) => Pattern | null;
9
+ type Decoder = (str: string) => string;
10
+ export declare const tryDecode: (str: string, decoder: Decoder) => string;
11
+ /**
12
+ * Try to apply decodeURI() to given string.
13
+ * If it fails, skip invalid percent encoding or invalid UTF-8 sequences, and apply decodeURI() to the rest as much as possible.
14
+ * @param str The string to decode.
15
+ * @returns The decoded string that sometimes contains undecodable percent encoding.
16
+ * @example
17
+ * tryDecodeURI('Hello%20World') // 'Hello World'
18
+ * tryDecodeURI('Hello%20World/%A4%A2') // 'Hello World/%A4%A2'
19
+ */
20
+ export declare const tryDecodeURI: (str: string) => string;
21
+ export declare const getPath: (request: Request) => string;
22
+ export declare const getQueryStrings: (url: string) => string;
23
+ export declare const getPathNoStrict: (request: Request) => string;
24
+ /**
25
+ * Merge paths.
26
+ * @param {string[]} ...paths - The paths to merge.
27
+ * @returns {string} The merged path.
28
+ * @example
29
+ * mergePath('/api', '/users') // '/api/users'
30
+ * mergePath('/api/', '/users') // '/api/users'
31
+ * mergePath('/api', '/') // '/api'
32
+ * mergePath('/api/', '/') // '/api/'
33
+ */
34
+ export declare const mergePath: (...paths: string[]) => string;
35
+ export declare const checkOptionalParameter: (path: string) => string[] | null;
36
+ export declare const getQueryParam: (url: string, key?: string) => string | undefined | Record<string, string>;
37
+ export declare const getQueryParams: (url: string, key?: string) => string[] | undefined | Record<string, string[]>;
38
+ export declare const decodeURIComponent_: typeof decodeURIComponent;
39
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @module
3
+ * Validator for Hono.
4
+ */
5
+ export { validator } from './validator';
6
+ export type { ValidationFunction } from './validator';
7
+ export type { InferInput } from './utils';
@@ -0,0 +1,29 @@
1
+ import type { FormValue, ParsedFormValue, ValidationTargets } from '../types';
2
+ import type { UnionToIntersection } from '../utils/types';
3
+ /**
4
+ * Checks if T is a literal union type (e.g., 'asc' | 'desc')
5
+ * that should be preserved in input types.
6
+ * Returns true for union literals, false for single literals or wide types.
7
+ */
8
+ export type IsLiteralUnion<T, Base> = [Exclude<T, undefined>] extends [Base] ? [Exclude<T, undefined>] extends [UnionToIntersection<Exclude<T, undefined>>] ? false : true : false;
9
+ type IsOptionalUnion<T> = [unknown] extends [T] ? false : undefined extends T ? true : false;
10
+ type SimplifyDeep<T> = {
11
+ [K in keyof T]: T[K];
12
+ } & {};
13
+ type InferInputInner<Output, Target extends keyof ValidationTargets, T extends FormValue> = SimplifyDeep<{
14
+ [K in keyof Output]: IsLiteralUnion<Output[K], string> extends true ? Output[K] : IsOptionalUnion<Output[K]> extends true ? Output[K] : Target extends 'form' ? T | T[] : Target extends 'query' ? string | string[] : Target extends 'param' ? string : Target extends 'header' ? string : Target extends 'cookie' ? string : unknown;
15
+ }>;
16
+ /**
17
+ * Utility type to infer input types for validation targets.
18
+ * Preserves literal union types (e.g., 'asc' | 'desc') while using
19
+ * the default ValidationTargets type for other values.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * // In @hono/zod-validator or similar:
24
+ * type Input = InferInput<z.input<Schema>, 'query'>
25
+ * // { orderBy: 'asc' | 'desc', page: string | string[] }
26
+ * ```
27
+ */
28
+ export type InferInput<Output, Target extends keyof ValidationTargets, T extends FormValue = ParsedFormValue> = [Exclude<Output, undefined>] extends [never] ? {} : [Exclude<Output, undefined>] extends [object] ? undefined extends Output ? SimplifyDeep<InferInputInner<Exclude<Output, undefined>, Target, T>> | undefined : SimplifyDeep<InferInputInner<Output, Target, T>> : {};
29
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { Context } from '../context';
2
+ import type { Env, MiddlewareHandler, TypedResponse, ValidationTargets, FormValue } from '../types';
3
+ import type { InferInput } from './utils';
4
+ type ValidationTargetKeysWithBody = 'form' | 'json';
5
+ type ValidationTargetByMethod<M> = M extends 'get' | 'head' ? Exclude<keyof ValidationTargets, ValidationTargetKeysWithBody> : keyof ValidationTargets;
6
+ export type ValidationFunction<InputType, OutputType, E extends Env = {}, P extends string = string> = (value: InputType, c: Context<E, P>) => OutputType | TypedResponse | Promise<OutputType> | Promise<TypedResponse>;
7
+ export type ExtractValidationResponse<VF> = VF extends (value: any, c: any) => infer R ? R extends Promise<infer PR> ? PR extends TypedResponse<infer T, infer S, infer F> ? TypedResponse<T, S, F> : PR extends Response ? PR : PR extends undefined ? never : never : R extends TypedResponse<infer T, infer S, infer F> ? TypedResponse<T, S, F> : R extends Response ? R : R extends undefined ? never : never : never;
8
+ export declare const validator: <InputType, P extends string, M extends string, U extends ValidationTargetByMethod<M>, P2 extends string = P, VF extends (value: unknown extends InputType ? ValidationTargets[U] : InputType, c: Context<any, P2>) => any = (value: unknown extends InputType ? ValidationTargets[U] : InputType, c: Context<any, P2>) => any, V extends {
9
+ in: { [K in U]: K extends "json" ? unknown extends InputType ? ExtractValidatorOutput<VF> : InputType : InferInput<ExtractValidatorOutput<VF>, K, FormValue>; };
10
+ out: { [K in U]: ExtractValidatorOutput<VF>; };
11
+ } = {
12
+ in: { [K in U]: K extends "json" ? unknown extends InputType ? ExtractValidatorOutput<VF> : InputType : InferInput<ExtractValidatorOutput<VF>, K, FormValue>; };
13
+ out: { [K in U]: ExtractValidatorOutput<VF>; };
14
+ }, E extends Env = any>(target: U, validationFunc: VF) => MiddlewareHandler<E, P, V, ExtractValidationResponse<VF>>;
15
+ export type ExtractValidatorOutput<VF> = VF extends (value: any, c: any) => infer R ? R extends Promise<infer PR> ? PR extends Response | TypedResponse<any, any, any> ? never : PR : R extends Response | TypedResponse<any, any, any> ? never : R : never;
16
+ export {};
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ // src/types.ts
2
+ var FetchEventLike = class {
3
+ };
4
+ export {
5
+ FetchEventLike
6
+ };
@@ -0,0 +1,223 @@
1
+ // src/utils/accept.ts
2
+ var isWhitespace = (char) => char === 32 || char === 9 || char === 10 || char === 13;
3
+ var consumeWhitespace = (acceptHeader, startIndex) => {
4
+ while (startIndex < acceptHeader.length) {
5
+ if (!isWhitespace(acceptHeader.charCodeAt(startIndex))) {
6
+ break;
7
+ }
8
+ startIndex++;
9
+ }
10
+ return startIndex;
11
+ };
12
+ var ignoreTrailingWhitespace = (acceptHeader, startIndex) => {
13
+ while (startIndex > 0) {
14
+ if (!isWhitespace(acceptHeader.charCodeAt(startIndex - 1))) {
15
+ break;
16
+ }
17
+ startIndex--;
18
+ }
19
+ return startIndex;
20
+ };
21
+ var skipInvalidParam = (acceptHeader, startIndex) => {
22
+ while (startIndex < acceptHeader.length) {
23
+ const char = acceptHeader.charCodeAt(startIndex);
24
+ if (char === 59) {
25
+ return [startIndex + 1, true];
26
+ }
27
+ if (char === 44) {
28
+ return [startIndex + 1, false];
29
+ }
30
+ startIndex++;
31
+ }
32
+ return [startIndex, false];
33
+ };
34
+ var skipInvalidAcceptValue = (acceptHeader, startIndex) => {
35
+ let i = startIndex;
36
+ let inQuotes = false;
37
+ while (i < acceptHeader.length) {
38
+ const char = acceptHeader.charCodeAt(i);
39
+ if (inQuotes && char === 92) {
40
+ i++;
41
+ } else if (char === 34) {
42
+ inQuotes = !inQuotes;
43
+ } else if (!inQuotes && char === 44) {
44
+ return i + 1;
45
+ }
46
+ i++;
47
+ }
48
+ return i;
49
+ };
50
+ var getNextParam = (acceptHeader, startIndex) => {
51
+ startIndex = consumeWhitespace(acceptHeader, startIndex);
52
+ let i = startIndex;
53
+ let key;
54
+ let value;
55
+ let hasNext = false;
56
+ while (i < acceptHeader.length) {
57
+ const char = acceptHeader.charCodeAt(i);
58
+ if (char === 61) {
59
+ key = acceptHeader.slice(startIndex, ignoreTrailingWhitespace(acceptHeader, i));
60
+ i++;
61
+ break;
62
+ }
63
+ if (char === 59) {
64
+ return [i + 1, void 0, void 0, true];
65
+ }
66
+ if (char === 44) {
67
+ return [i + 1, void 0, void 0, false];
68
+ }
69
+ i++;
70
+ }
71
+ if (key === void 0) {
72
+ return [i, void 0, void 0, false];
73
+ }
74
+ i = consumeWhitespace(acceptHeader, i);
75
+ if (acceptHeader.charCodeAt(i) === 61) {
76
+ const skipResult = skipInvalidParam(acceptHeader, i + 1);
77
+ return [skipResult[0], key, void 0, skipResult[1]];
78
+ }
79
+ let inQuotes = false;
80
+ const paramStartIndex = i;
81
+ while (i < acceptHeader.length) {
82
+ const char = acceptHeader.charCodeAt(i);
83
+ if (inQuotes && char === 92) {
84
+ i++;
85
+ } else if (char === 34) {
86
+ if (inQuotes) {
87
+ let nextIndex = consumeWhitespace(acceptHeader, i + 1);
88
+ const nextChar = acceptHeader.charCodeAt(nextIndex);
89
+ if (nextIndex < acceptHeader.length && !(nextChar === 59 || nextChar === 44)) {
90
+ const skipResult = skipInvalidParam(acceptHeader, nextIndex);
91
+ return [skipResult[0], key, void 0, skipResult[1]];
92
+ }
93
+ value = acceptHeader.slice(paramStartIndex + 1, i);
94
+ if (value.includes("\\")) {
95
+ value = value.replace(/\\(.)/g, "$1");
96
+ }
97
+ if (nextChar === 44) {
98
+ return [nextIndex + 1, key, value, false];
99
+ }
100
+ if (nextChar === 59) {
101
+ hasNext = true;
102
+ nextIndex++;
103
+ }
104
+ i = nextIndex;
105
+ break;
106
+ }
107
+ inQuotes = true;
108
+ } else if (!inQuotes && (char === 59 || char === 44)) {
109
+ value = acceptHeader.slice(paramStartIndex, ignoreTrailingWhitespace(acceptHeader, i));
110
+ if (char === 59) {
111
+ hasNext = true;
112
+ }
113
+ i++;
114
+ break;
115
+ }
116
+ i++;
117
+ }
118
+ return [
119
+ i,
120
+ key,
121
+ value ?? acceptHeader.slice(paramStartIndex, ignoreTrailingWhitespace(acceptHeader, i)),
122
+ hasNext
123
+ ];
124
+ };
125
+ var getNextAcceptValue = (acceptHeader, startIndex) => {
126
+ const accept = {
127
+ type: "",
128
+ params: {},
129
+ q: 1
130
+ };
131
+ startIndex = consumeWhitespace(acceptHeader, startIndex);
132
+ let i = startIndex;
133
+ while (i < acceptHeader.length) {
134
+ const char = acceptHeader.charCodeAt(i);
135
+ if (char === 59 || char === 44) {
136
+ accept.type = acceptHeader.slice(startIndex, ignoreTrailingWhitespace(acceptHeader, i));
137
+ i++;
138
+ if (char === 44) {
139
+ return [i, accept.type ? accept : void 0];
140
+ }
141
+ if (!accept.type) {
142
+ return [skipInvalidAcceptValue(acceptHeader, i), void 0];
143
+ }
144
+ break;
145
+ }
146
+ i++;
147
+ }
148
+ if (!accept.type) {
149
+ accept.type = acceptHeader.slice(
150
+ startIndex,
151
+ ignoreTrailingWhitespace(acceptHeader, acceptHeader.length)
152
+ );
153
+ return [acceptHeader.length, accept.type ? accept : void 0];
154
+ }
155
+ let param;
156
+ let value;
157
+ let hasNext;
158
+ while (i < acceptHeader.length) {
159
+ ;
160
+ [i, param, value, hasNext] = getNextParam(acceptHeader, i);
161
+ if (param && value) {
162
+ accept.params[param] = value;
163
+ }
164
+ if (!hasNext) {
165
+ break;
166
+ }
167
+ }
168
+ return [i, accept];
169
+ };
170
+ var parseAccept = (acceptHeader) => {
171
+ if (!acceptHeader) {
172
+ return [];
173
+ }
174
+ const values = [];
175
+ let i = 0;
176
+ let accept;
177
+ let requiresSort = false;
178
+ let lastAccept;
179
+ while (i < acceptHeader.length) {
180
+ ;
181
+ [i, accept] = getNextAcceptValue(acceptHeader, i);
182
+ if (accept) {
183
+ accept.q = parseQuality(accept.params.q);
184
+ values.push(accept);
185
+ if (lastAccept && lastAccept.q < accept.q) {
186
+ requiresSort = true;
187
+ }
188
+ lastAccept = accept;
189
+ }
190
+ }
191
+ if (requiresSort) {
192
+ values.sort((a, b) => b.q - a.q);
193
+ }
194
+ return values;
195
+ };
196
+ var parseQuality = (qVal) => {
197
+ if (qVal === void 0) {
198
+ return 1;
199
+ }
200
+ if (qVal === "") {
201
+ return 1;
202
+ }
203
+ if (qVal === "NaN") {
204
+ return 0;
205
+ }
206
+ const num = Number(qVal);
207
+ if (num === Infinity) {
208
+ return 1;
209
+ }
210
+ if (num === -Infinity) {
211
+ return 0;
212
+ }
213
+ if (Number.isNaN(num)) {
214
+ return 1;
215
+ }
216
+ if (num < 0 || num > 1) {
217
+ return 1;
218
+ }
219
+ return num;
220
+ };
221
+ export {
222
+ parseAccept
223
+ };
@@ -0,0 +1,23 @@
1
+ // src/utils/basic-auth.ts
2
+ import { decodeBase64 } from "./encode.js";
3
+ var CREDENTIALS_REGEXP = /^ *(?:[Bb][Aa][Ss][Ii][Cc]) +([A-Za-z0-9._~+/-]+=*) *$/;
4
+ var USER_PASS_REGEXP = /^([^:]*):(.*)$/;
5
+ var utf8Decoder = new TextDecoder();
6
+ var auth = (req) => {
7
+ const match = CREDENTIALS_REGEXP.exec(req.headers.get("Authorization") || "");
8
+ if (!match) {
9
+ return void 0;
10
+ }
11
+ let userPass = void 0;
12
+ try {
13
+ userPass = USER_PASS_REGEXP.exec(utf8Decoder.decode(decodeBase64(match[1])));
14
+ } catch {
15
+ }
16
+ if (!userPass) {
17
+ return void 0;
18
+ }
19
+ return { username: userPass[1], password: userPass[2] };
20
+ };
21
+ export {
22
+ auth
23
+ };
@@ -0,0 +1,75 @@
1
+ // src/utils/body.ts
2
+ import { HonoRequest } from "../request.js";
3
+ var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
4
+ const { all = false, dot = false } = options;
5
+ const headers = request instanceof HonoRequest ? request.raw.headers : request.headers;
6
+ const contentType = headers.get("Content-Type");
7
+ if (contentType?.startsWith("multipart/form-data") || contentType?.startsWith("application/x-www-form-urlencoded")) {
8
+ return parseFormData(request, { all, dot });
9
+ }
10
+ return {};
11
+ };
12
+ async function parseFormData(request, options) {
13
+ const formData = await request.formData();
14
+ if (formData) {
15
+ return convertFormDataToBodyData(formData, options);
16
+ }
17
+ return {};
18
+ }
19
+ function convertFormDataToBodyData(formData, options) {
20
+ const form = /* @__PURE__ */ Object.create(null);
21
+ formData.forEach((value, key) => {
22
+ const shouldParseAllValues = options.all || key.endsWith("[]");
23
+ if (!shouldParseAllValues) {
24
+ form[key] = value;
25
+ } else {
26
+ handleParsingAllValues(form, key, value);
27
+ }
28
+ });
29
+ if (options.dot) {
30
+ Object.entries(form).forEach(([key, value]) => {
31
+ const shouldParseDotValues = key.includes(".");
32
+ if (shouldParseDotValues) {
33
+ handleParsingNestedValues(form, key, value);
34
+ delete form[key];
35
+ }
36
+ });
37
+ }
38
+ return form;
39
+ }
40
+ var handleParsingAllValues = (form, key, value) => {
41
+ if (form[key] !== void 0) {
42
+ if (Array.isArray(form[key])) {
43
+ ;
44
+ form[key].push(value);
45
+ } else {
46
+ form[key] = [form[key], value];
47
+ }
48
+ } else {
49
+ if (!key.endsWith("[]")) {
50
+ form[key] = value;
51
+ } else {
52
+ form[key] = [value];
53
+ }
54
+ }
55
+ };
56
+ var handleParsingNestedValues = (form, key, value) => {
57
+ if (/(?:^|\.)__proto__\./.test(key)) {
58
+ return;
59
+ }
60
+ let nestedForm = form;
61
+ const keys = key.split(".");
62
+ keys.forEach((key2, index) => {
63
+ if (index === keys.length - 1) {
64
+ nestedForm[key2] = value;
65
+ } else {
66
+ if (!nestedForm[key2] || typeof nestedForm[key2] !== "object" || Array.isArray(nestedForm[key2]) || nestedForm[key2] instanceof File) {
67
+ nestedForm[key2] = /* @__PURE__ */ Object.create(null);
68
+ }
69
+ nestedForm = nestedForm[key2];
70
+ }
71
+ });
72
+ };
73
+ export {
74
+ parseBody
75
+ };
@@ -0,0 +1,77 @@
1
+ // src/utils/buffer.ts
2
+ import { sha256 } from "./crypto.js";
3
+ var equal = (a, b) => {
4
+ if (a === b) {
5
+ return true;
6
+ }
7
+ if (a.byteLength !== b.byteLength) {
8
+ return false;
9
+ }
10
+ const va = new DataView(a);
11
+ const vb = new DataView(b);
12
+ let i = va.byteLength;
13
+ while (i--) {
14
+ if (va.getUint8(i) !== vb.getUint8(i)) {
15
+ return false;
16
+ }
17
+ }
18
+ return true;
19
+ };
20
+ var constantTimeEqualString = (a, b) => {
21
+ const aLen = a.length;
22
+ const bLen = b.length;
23
+ const maxLen = Math.max(aLen, bLen);
24
+ let out = aLen ^ bLen;
25
+ for (let i = 0; i < maxLen; i++) {
26
+ const aChar = i < aLen ? a.charCodeAt(i) : 0;
27
+ const bChar = i < bLen ? b.charCodeAt(i) : 0;
28
+ out |= aChar ^ bChar;
29
+ }
30
+ return out === 0;
31
+ };
32
+ var timingSafeEqualString = async (a, b, hashFunction) => {
33
+ if (!hashFunction) {
34
+ hashFunction = sha256;
35
+ }
36
+ const [sa, sb] = await Promise.all([hashFunction(a), hashFunction(b)]);
37
+ if (sa == null || sb == null || typeof sa !== "string" || typeof sb !== "string") {
38
+ return false;
39
+ }
40
+ const hashEqual = constantTimeEqualString(sa, sb);
41
+ const originalEqual = constantTimeEqualString(a, b);
42
+ return hashEqual && originalEqual;
43
+ };
44
+ var timingSafeEqual = async (a, b, hashFunction) => {
45
+ if (typeof a === "string" && typeof b === "string") {
46
+ return timingSafeEqualString(a, b, hashFunction);
47
+ }
48
+ if (!hashFunction) {
49
+ hashFunction = sha256;
50
+ }
51
+ const [sa, sb] = await Promise.all([hashFunction(a), hashFunction(b)]);
52
+ if (!sa || !sb || typeof sa !== "string" || typeof sb !== "string") {
53
+ return false;
54
+ }
55
+ return timingSafeEqualString(sa, sb);
56
+ };
57
+ var bufferToString = (buffer) => {
58
+ if (buffer instanceof ArrayBuffer) {
59
+ const enc = new TextDecoder("utf-8");
60
+ return enc.decode(buffer);
61
+ }
62
+ return buffer;
63
+ };
64
+ var bufferToFormData = (arrayBuffer, contentType) => {
65
+ const response = new Response(arrayBuffer, {
66
+ headers: {
67
+ "Content-Type": contentType
68
+ }
69
+ });
70
+ return response.formData();
71
+ };
72
+ export {
73
+ bufferToFormData,
74
+ bufferToString,
75
+ equal,
76
+ timingSafeEqual
77
+ };
@@ -0,0 +1,25 @@
1
+ // src/utils/color.ts
2
+ function getColorEnabled() {
3
+ const { process, Deno } = globalThis;
4
+ const isNoColor = typeof Deno?.noColor === "boolean" ? Deno.noColor : process !== void 0 ? (
5
+ // eslint-disable-next-line no-unsafe-optional-chaining
6
+ "NO_COLOR" in process?.env
7
+ ) : false;
8
+ return !isNoColor;
9
+ }
10
+ async function getColorEnabledAsync() {
11
+ const { navigator } = globalThis;
12
+ const cfWorkers = "cloudflare:workers";
13
+ const isNoColor = navigator !== void 0 && navigator.userAgent === "Cloudflare-Workers" ? await (async () => {
14
+ try {
15
+ return "NO_COLOR" in ((await import(cfWorkers)).env ?? {});
16
+ } catch {
17
+ return false;
18
+ }
19
+ })() : !getColorEnabled();
20
+ return !isNoColor;
21
+ }
22
+ export {
23
+ getColorEnabled,
24
+ getColorEnabledAsync
25
+ };
@@ -0,0 +1,5 @@
1
+ // src/utils/compress.ts
2
+ var COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/(?!event-stream(?:[;\s]|$))[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|wasm|x-httpd-php|x-javascript|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml))(?:[;\s]|$)/i;
3
+ export {
4
+ COMPRESSIBLE_CONTENT_TYPE_REGEX
5
+ };
@@ -0,0 +1,39 @@
1
+ // src/utils/concurrent.ts
2
+ var DEFAULT_CONCURRENCY = 1024;
3
+ var createPool = ({
4
+ concurrency,
5
+ interval
6
+ } = {}) => {
7
+ concurrency ||= DEFAULT_CONCURRENCY;
8
+ if (concurrency === Infinity) {
9
+ return {
10
+ run: async (fn) => fn()
11
+ };
12
+ }
13
+ const pool = /* @__PURE__ */ new Set();
14
+ const run = async (fn, promise, resolve) => {
15
+ if (pool.size >= concurrency) {
16
+ promise ||= new Promise((r) => resolve = r);
17
+ setTimeout(() => run(fn, promise, resolve));
18
+ return promise;
19
+ }
20
+ const marker = {};
21
+ pool.add(marker);
22
+ const result = await fn();
23
+ if (interval) {
24
+ setTimeout(() => pool.delete(marker), interval);
25
+ } else {
26
+ pool.delete(marker);
27
+ }
28
+ if (resolve) {
29
+ resolve(result);
30
+ return promise;
31
+ } else {
32
+ return result;
33
+ }
34
+ };
35
+ return { run };
36
+ };
37
+ export {
38
+ createPool
39
+ };