acrylblends 1.0.4 → 1.0.6

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 (351) hide show
  1. package/docs/framework/agents/index.md +7 -5
  2. package/lib/accept-CNNHu4Cf.js +193 -0
  3. package/lib/{accepts-XBuZPVRI.js → accepts-Btq83xPd.js} +1 -1
  4. package/lib/accepts.js +1 -1
  5. package/lib/acryl-base.js +1 -331
  6. package/lib/adapter-CaZ6FZUU.js +37 -0
  7. package/lib/adapter.js +1 -36
  8. package/lib/{app-BM0rTCp7.js → app-CQcGWjrk.js} +4 -4
  9. package/lib/app-base-CpRMZL4v.js +332 -0
  10. package/lib/{audit-D5z9uwOP.d.ts → audit-GcLtvNLV.d.ts} +4 -2
  11. package/lib/{base-NSN_SNv-.js → base-D_6kfOr-.js} +1 -1
  12. package/lib/basic-auth-C0HTRpXh.js +20 -0
  13. package/lib/basic-auth-DFLflXNe.js +95 -0
  14. package/lib/basic-auth.js +1 -94
  15. package/lib/bearer-auth-Cwxt-vgS.js +94 -0
  16. package/lib/bearer-auth.js +1 -93
  17. package/lib/body-D7f4e7w_.js +94 -0
  18. package/lib/body-limit-WmIjWRLt.js +66 -0
  19. package/lib/body-limit.js +1 -65
  20. package/lib/buffer-CkEOJCcY.js +51 -0
  21. package/lib/bun.js +3 -3
  22. package/lib/cache-B0bHH7s5.js +169 -0
  23. package/lib/cache.js +1 -168
  24. package/lib/{client-DDLXwhBo.js → client-BrMFnMEd.js} +1 -1
  25. package/lib/{client-modules-CLvWOjbd.js → client-modules-drj4mjhj.js} +4 -4
  26. package/lib/client.js +1 -1
  27. package/lib/color-COa3DplO.js +37 -0
  28. package/lib/combine-TWuGdcbC.js +137 -0
  29. package/lib/combine.js +1 -136
  30. package/lib/{components-cEW3ovK0.js → components-B2ka9Ax1.js} +4 -4
  31. package/lib/{components-JXVm45kK.js → components-PVXwaOaC.js} +2 -2
  32. package/lib/compress-BzWqsHF1.js +79 -0
  33. package/lib/compress-C-9vK4B2.d.ts +11 -0
  34. package/lib/compress-DCyrrQ5D.js +11 -0
  35. package/lib/compress.d.ts +1 -1
  36. package/lib/compress.js +2 -78
  37. package/lib/concurrent-DrF3d2c-.js +30 -0
  38. package/lib/conninfo-BCROmdnf.d.ts +11 -0
  39. package/lib/conninfo-CWJwieh4.js +19 -0
  40. package/lib/constants-CBSEudrb.js +7 -0
  41. package/lib/{context-DDO0cfuP.js → context-CkOh7Ygv.js} +2 -2
  42. package/lib/context-storage-iuPoI_CR.js +52 -0
  43. package/lib/context-storage.js +1 -51
  44. package/lib/cookie-B1LlkzOe.js +125 -0
  45. package/lib/cookie-BHIduy2T.js +82 -0
  46. package/lib/cookie.js +1 -81
  47. package/lib/cordis/db-sqlite.d.ts +1 -1
  48. package/lib/cordis/door.d.ts +99 -5
  49. package/lib/cordis/door.js +562 -20
  50. package/lib/cordis/inspect.js +4 -4
  51. package/lib/cordis/kv-db.d.ts +1 -1
  52. package/lib/cordis/kv-db.js +1 -1
  53. package/lib/cordis/kv-json.d.ts +1 -1
  54. package/lib/cordis/kv-json.js +1 -1
  55. package/lib/cordis/node-server.d.ts +1 -1
  56. package/lib/cordis/node-server.js +3 -116
  57. package/lib/cordis/router-http.js +2 -2
  58. package/lib/cordis/router.js +4 -4
  59. package/lib/cordis/state.js +7 -7
  60. package/lib/{core-CaY8XDZ6.js → core-BOu1jYua.js} +1 -1
  61. package/lib/cors-CbAQ-8qU.js +106 -0
  62. package/lib/cors.js +1 -105
  63. package/lib/crypto-iVP-N-tS.js +34 -0
  64. package/lib/csrf-DqqOZtgy.js +101 -0
  65. package/lib/csrf.js +1 -100
  66. package/lib/css-C5CPVMvM.js +134 -0
  67. package/lib/css.js +2 -133
  68. package/lib/db/sqlite.d.ts +1 -25
  69. package/lib/dev-CLgu-JRe.js +50 -0
  70. package/lib/dev.js +1 -49
  71. package/lib/dom-YjND9Jt3.js +74 -0
  72. package/lib/door/host.d.ts +2 -2
  73. package/lib/door/host.js +1 -1
  74. package/lib/door/page.d.ts +3 -1
  75. package/lib/door/page.js +2 -2
  76. package/lib/door/protocol.d.ts +1 -1
  77. package/lib/door/protocol.js +1 -212
  78. package/lib/encode-BhbNLrjp.js +33 -0
  79. package/lib/factory-CLdSf-xS.js +30 -0
  80. package/lib/factory.js +1 -29
  81. package/lib/handler-C0wZ0KwO.js +12 -0
  82. package/lib/helpers-BEjcdbgw.js +5 -0
  83. package/lib/{hooks-w72iLeFR.js → hooks-CfC07ri0.js} +1 -1
  84. package/lib/html-CgNa89xw.js +31 -0
  85. package/lib/html-DGExBFNg.js +103 -0
  86. package/lib/html.d.ts +2 -5
  87. package/lib/html.js +2 -30
  88. package/lib/http-exception-MjWkT89V.js +54 -0
  89. package/lib/http-exception.js +1 -53
  90. package/lib/index-dAzQsJG9.d.ts +6 -0
  91. package/lib/index.js +3 -3
  92. package/lib/ip-restriction-jKtKCRM_.js +166 -0
  93. package/lib/ip-restriction.js +1 -165
  94. package/lib/ipaddr-DCoIo528.js +238 -0
  95. package/lib/jsx/dom/client.js +1 -1
  96. package/lib/jsx/dom/jsx-dev-runtime.js +1 -1
  97. package/lib/jsx/dom/jsx-runtime.js +2 -1
  98. package/lib/jsx/dom/server.js +3 -3
  99. package/lib/jsx/dom.js +5 -73
  100. package/lib/jsx/jsx-dev-runtime.d.ts +2 -5
  101. package/lib/jsx/jsx-dev-runtime.js +2 -13
  102. package/lib/jsx/jsx-runtime.d.ts +2 -2
  103. package/lib/jsx/jsx-runtime.js +4 -4
  104. package/lib/jsx/streaming.js +1 -1
  105. package/lib/jsx-CUQgttxU.js +47 -0
  106. package/lib/jsx-dev-runtime-B4WTyq8r.js +14 -0
  107. package/lib/{jsx-dev-runtime-CWLRA2F3.js → jsx-dev-runtime-BLfA-EhI.js} +2 -2
  108. package/lib/jsx-dev-runtime-CGt4kNYr.d.ts +6 -0
  109. package/lib/jsx-renderer-CfifM4hT.js +99 -0
  110. package/lib/jsx-renderer.js +1 -98
  111. package/lib/jsx-runtime-COCRWBJ9.js +2 -0
  112. package/lib/jsx.js +5 -46
  113. package/lib/{jwk-LkzeoaU8.js → jwk-CDPpYQpD.js} +3 -3
  114. package/lib/jwk.js +1 -1
  115. package/lib/{jwt-BGJBw5AF.js → jwt-BXoIA2fQ.js} +2 -2
  116. package/lib/{jwt-CskdhEW9.js → jwt-lyS4Q3mT.js} +3 -3
  117. package/lib/jwt.js +2 -2
  118. package/lib/kv/db.d.ts +1 -10
  119. package/lib/kv/db.js +1 -56
  120. package/lib/kv/json.d.ts +1 -9
  121. package/lib/kv/json.js +1 -223
  122. package/lib/{language-D9a4zqvn.js → language-DeGRtLJt.js} +2 -2
  123. package/lib/language.js +1 -1
  124. package/lib/{linear-router-C3FPib6h.js → linear-router-CmZn_JLV.js} +2 -2
  125. package/lib/logger-Ckxu8diz.js +54 -0
  126. package/lib/logger.js +1 -53
  127. package/lib/loopback-only-BbasoF7R.js +90 -0
  128. package/lib/loopback-only.js +1 -89
  129. package/lib/method-not-allowed-TO2_hnfl.js +82 -0
  130. package/lib/method-not-allowed.js +1 -81
  131. package/lib/method-override-DnZKfJbV.js +103 -0
  132. package/lib/method-override.js +1 -102
  133. package/lib/middleware-BfG_fp8P.js +12 -0
  134. package/lib/mime-BnScXkQn.js +77 -0
  135. package/lib/mount-QkK_3NtJ.js +67 -0
  136. package/lib/mount.js +1 -66
  137. package/lib/node-server/conninfo.d.ts +1 -10
  138. package/lib/node-server/conninfo.js +1 -18
  139. package/lib/node-server/register.js +25 -2
  140. package/lib/node-server/serve-static.d.ts +1 -17
  141. package/lib/node-server/serve-static.js +1 -1
  142. package/lib/node-server.d.ts +2 -2
  143. package/lib/node-server.js +4 -4
  144. package/lib/open-BqK4D2Wn.d.ts +11 -0
  145. package/lib/open-But9E2rL.js +57 -0
  146. package/lib/open-CULVJgOc.d.ts +12 -0
  147. package/lib/open-Dp4sxspc.js +224 -0
  148. package/lib/open-T7kgbO2O.d.ts +27 -0
  149. package/lib/{pattern-router-HZxjDGEQ.js → pattern-router-CJBecJBd.js} +1 -1
  150. package/lib/powered-by-CXQNjNIX.js +24 -0
  151. package/lib/powered-by.js +1 -23
  152. package/lib/pretty-json-CeC1yvYt.js +39 -0
  153. package/lib/pretty-json.js +1 -38
  154. package/lib/{protocol-C37gPePD.d.ts → protocol-CR31M7K_.d.ts} +2 -0
  155. package/lib/protocol-Dt0AZBOz.js +213 -0
  156. package/lib/proxy-C2w_mH7k.js +121 -0
  157. package/lib/proxy.js +1 -120
  158. package/lib/quick.js +4 -4
  159. package/lib/{reg-exp-router-DC1R3qoY.js → reg-exp-router-C_WV84eV.js} +2 -2
  160. package/lib/request-DvMgGtlW.js +323 -0
  161. package/lib/request.js +1 -322
  162. package/lib/route-D8m-a2I1.js +126 -0
  163. package/lib/route.js +1 -125
  164. package/lib/router/linear-router.js +1 -1
  165. package/lib/router/pattern-router.js +1 -1
  166. package/lib/router/reg-exp-router.js +1 -1
  167. package/lib/router/smart-router.js +1 -1
  168. package/lib/router/trie-router.js +1 -1
  169. package/lib/router-Be_o6nFu.js +35 -0
  170. package/lib/router.js +1 -34
  171. package/lib/schema-validator-EK3cUUCt.js +22 -0
  172. package/lib/schema-validator.js +1 -21
  173. package/lib/{secure-headers-mP3j6Hm6.js → secure-headers-C5ZOcXqk.js} +1 -1
  174. package/lib/secure-headers.js +1 -1
  175. package/lib/serve-static-B7sqnftW.d.ts +18 -0
  176. package/lib/{serve-static-3uo_9rjF.js → serve-static-C1Nkj_xB.js} +2 -2
  177. package/lib/{serve-static-Cp5adzGo.js → serve-static-EiJf1zkO.js} +4 -4
  178. package/lib/serve-static.js +1 -1
  179. package/lib/{smart-router-C5CZ5XSM.js → smart-router-BjxkDQCE.js} +1 -1
  180. package/lib/{snapshot-text-BLz8nlSc.js → snapshot-text-CtQm3n8n.js} +23 -14
  181. package/lib/{src-dy3Fk9tA.js → src-BTBm4OPD.js} +6 -6
  182. package/lib/src-LX0E4ec4.js +117 -0
  183. package/lib/{ssg-BwjcA-Ge.js → ssg-BEl7MHqg.js} +5 -5
  184. package/lib/ssg.js +1 -1
  185. package/lib/stream-CzM_SHkq.js +88 -0
  186. package/lib/{streaming-DHST3Scg.js → streaming-BlDaph8U.js} +3 -3
  187. package/lib/streaming.js +1 -1
  188. package/lib/{test-websocket-D8WWqE5G.js → test-websocket-BLeEvybj.js} +2 -2
  189. package/lib/testing-BQx5T_UX.js +17 -0
  190. package/lib/testing.js +1 -16
  191. package/lib/timeout-FeqZ9A-0.js +42 -0
  192. package/lib/timeout.js +1 -41
  193. package/lib/tiny.js +2 -2
  194. package/lib/trailing-slash-DwTx-1sk.js +85 -0
  195. package/lib/trailing-slash.js +1 -84
  196. package/lib/{trie-router-CfFbapzL.js → trie-router-JydLKUa2.js} +2 -2
  197. package/lib/url-BPh4d6j-.js +197 -0
  198. package/lib/utils/accept.js +1 -192
  199. package/lib/utils/basic-auth.js +1 -19
  200. package/lib/utils/body.js +1 -93
  201. package/lib/utils/buffer.js +1 -50
  202. package/lib/utils/color.js +1 -36
  203. package/lib/utils/compress.d.ts +1 -10
  204. package/lib/utils/compress.js +1 -10
  205. package/lib/utils/concurrent.js +1 -29
  206. package/lib/utils/constants.js +1 -6
  207. package/lib/utils/cookie.js +1 -124
  208. package/lib/utils/crypto.js +1 -33
  209. package/lib/utils/encode.js +1 -32
  210. package/lib/utils/handler.js +1 -11
  211. package/lib/utils/html.js +1 -102
  212. package/lib/utils/ipaddr.js +1 -237
  213. package/lib/utils/jwt.js +1 -1
  214. package/lib/utils/mime.js +1 -76
  215. package/lib/utils/stream.js +1 -87
  216. package/lib/utils/url.js +1 -196
  217. package/lib/{validator-D84mq-dO.js → validator-Btiyt5VJ.js} +3 -3
  218. package/lib/validator.js +1 -1
  219. package/lib/websocket-DsyBIKVA.js +56 -0
  220. package/lib/ws.js +1 -55
  221. package/package.json +1 -1
  222. package/plugins/acryl-door/src/cli/acryl.ts +36 -5
  223. package/plugins/acryl-door/src/host/channel.ts +14 -6
  224. package/plugins/acryl-door/src/host/chat-tools.ts +2 -0
  225. package/plugins/acryl-door/src/host/door.ts +97 -12
  226. package/plugins/acryl-door/src/host/page-routes.ts +3 -1
  227. package/plugins/acryl-door/src/host/shell.ts +147 -0
  228. package/plugins/acryl-door/src/host/shim.ts +39 -3
  229. package/plugins/acryl-door/src/host/verbs.ts +39 -2
  230. package/plugins/acryl-door/src/index.ts +22 -3
  231. package/plugins/acryl-door/src/page/channel.ts +3 -1
  232. package/plugins/acryl-door/src/page/index.ts +2 -1
  233. package/plugins/acryl-door/src/page/protocol.ts +2 -0
  234. package/plugins/acryl-door/src/shell/protocol.ts +130 -0
  235. package/plugins/acryl-node-server/src/register.ts +29 -2
  236. package/plugins/agent/model.ts +6 -1
  237. package/plugins/agent/tools.ts +12 -2
  238. package/plugins/agent-panel/client/describe.ts +44 -0
  239. package/plugins/agent-panel/client/main.ts +4 -1
  240. package/plugins/agent-panel/headless.ts +29 -8
  241. package/plugins/agent-panel/index.ts +22 -10
  242. package/plugins/agent-panel/launch.ts +67 -0
  243. package/plugins/desktop/attach.ts +72 -0
  244. package/plugins/desktop/door-shell.ts +379 -0
  245. package/plugins/desktop/main.ts +82 -15
  246. package/plugins/extensions/index.ts +3 -4
  247. package/plugins/extensions/stage.ts +33 -5
  248. package/plugins/openai/index.ts +1 -1
  249. package/templates/agent/AGENTS.md +4 -0
  250. package/templates/agent/blend.yaml +4 -1
  251. package/templates/agent/src/app.ts +2 -0
  252. package/templates/agent/src/routes.ts +1 -1
  253. package/templates/agent/template.json +1 -0
  254. package/templates/agent/test/builder.test.ts +26 -21
  255. package/lib/helpers-CvTauQT5.js +0 -5
  256. package/lib/middleware-CPQ8himN.js +0 -12
  257. package/plugins/acryl-router/src/connection.d.ts +0 -25
  258. package/plugins/acryl-router/src/core/app-base.d.ts +0 -215
  259. package/plugins/acryl-router/src/core/app.d.ts +0 -19
  260. package/plugins/acryl-router/src/core/client/client.d.ts +0 -4
  261. package/plugins/acryl-router/src/core/client/fetch-result-please.d.ts +0 -35
  262. package/plugins/acryl-router/src/core/client/index.d.ts +0 -7
  263. package/plugins/acryl-router/src/core/client/types.d.ts +0 -229
  264. package/plugins/acryl-router/src/core/client/utils.d.ts +0 -18
  265. package/plugins/acryl-router/src/core/compose.d.ts +0 -14
  266. package/plugins/acryl-router/src/core/context.d.ts +0 -443
  267. package/plugins/acryl-router/src/core/helper/accepts/accepts.d.ts +0 -30
  268. package/plugins/acryl-router/src/core/helper/accepts/index.d.ts +0 -5
  269. package/plugins/acryl-router/src/core/helper/conninfo/index.d.ts +0 -5
  270. package/plugins/acryl-router/src/core/helper/conninfo/types.d.ts +0 -36
  271. package/plugins/acryl-router/src/core/helper/cookie/index.d.ts +0 -25
  272. package/plugins/acryl-router/src/core/helper/css/common.d.ts +0 -59
  273. package/plugins/acryl-router/src/core/helper/css/index.d.ts +0 -80
  274. package/plugins/acryl-router/src/core/helper/dev/index.d.ts +0 -20
  275. package/plugins/acryl-router/src/core/helper/factory/index.d.ts +0 -82
  276. package/plugins/acryl-router/src/core/helper/html/index.d.ts +0 -8
  277. package/plugins/acryl-router/src/core/helper/proxy/index.d.ts +0 -73
  278. package/plugins/acryl-router/src/core/helper/route/index.d.ts +0 -75
  279. package/plugins/acryl-router/src/core/helper/ssg/index.d.ts +0 -7
  280. package/plugins/acryl-router/src/core/helper/ssg/middleware.d.ts +0 -44
  281. package/plugins/acryl-router/src/core/helper/ssg/plugins.d.ts +0 -27
  282. package/plugins/acryl-router/src/core/helper/ssg/ssg.d.ts +0 -91
  283. package/plugins/acryl-router/src/core/helper/ssg/utils.d.ts +0 -16
  284. package/plugins/acryl-router/src/core/helper/streaming/index.d.ts +0 -8
  285. package/plugins/acryl-router/src/core/helper/streaming/sse.d.ts +0 -13
  286. package/plugins/acryl-router/src/core/helper/streaming/stream.d.ts +0 -3
  287. package/plugins/acryl-router/src/core/helper/streaming/text.d.ts +0 -3
  288. package/plugins/acryl-router/src/core/helper/streaming/utils.d.ts +0 -1
  289. package/plugins/acryl-router/src/core/helper/testing/index.d.ts +0 -13
  290. package/plugins/acryl-router/src/core/helper/websocket/index.d.ts +0 -70
  291. package/plugins/acryl-router/src/core/http-exception.d.ts +0 -58
  292. package/plugins/acryl-router/src/core/index.d.ts +0 -37
  293. package/plugins/acryl-router/src/core/jsx/base.d.ts +0 -61
  294. package/plugins/acryl-router/src/core/jsx/children.d.ts +0 -9
  295. package/plugins/acryl-router/src/core/jsx/components.d.ts +0 -15
  296. package/plugins/acryl-router/src/core/jsx/constants.d.ts +0 -6
  297. package/plugins/acryl-router/src/core/jsx/context.d.ts +0 -51
  298. package/plugins/acryl-router/src/core/jsx/dom/components.d.ts +0 -10
  299. package/plugins/acryl-router/src/core/jsx/dom/context.d.ts +0 -3
  300. package/plugins/acryl-router/src/core/jsx/dom/css.d.ts +0 -83
  301. package/plugins/acryl-router/src/core/jsx/dom/hooks/index.d.ts +0 -39
  302. package/plugins/acryl-router/src/core/jsx/dom/intrinsic-element/components.d.ts +0 -16
  303. package/plugins/acryl-router/src/core/jsx/dom/jsx-dev-runtime.d.ts +0 -8
  304. package/plugins/acryl-router/src/core/jsx/dom/jsx-runtime.d.ts +0 -7
  305. package/plugins/acryl-router/src/core/jsx/dom/render.d.ts +0 -73
  306. package/plugins/acryl-router/src/core/jsx/dom/utils.d.ts +0 -1
  307. package/plugins/acryl-router/src/core/jsx/hooks/index.d.ts +0 -47
  308. package/plugins/acryl-router/src/core/jsx/index.d.ts +0 -76
  309. package/plugins/acryl-router/src/core/jsx/intrinsic-element/common.d.ts +0 -6
  310. package/plugins/acryl-router/src/core/jsx/intrinsic-element/components.d.ts +0 -13
  311. package/plugins/acryl-router/src/core/jsx/intrinsic-elements.d.ts +0 -735
  312. package/plugins/acryl-router/src/core/jsx/streaming.d.ts +0 -36
  313. package/plugins/acryl-router/src/core/jsx/types.d.ts +0 -36
  314. package/plugins/acryl-router/src/core/jsx/utils.d.ts +0 -4
  315. package/plugins/acryl-router/src/core/request/constants.d.ts +0 -1
  316. package/plugins/acryl-router/src/core/request.d.ts +0 -306
  317. package/plugins/acryl-router/src/core/router/reg-exp-router/index.d.ts +0 -6
  318. package/plugins/acryl-router/src/core/router/reg-exp-router/matcher.d.ts +0 -7
  319. package/plugins/acryl-router/src/core/router/reg-exp-router/node.d.ts +0 -13
  320. package/plugins/acryl-router/src/core/router/reg-exp-router/prepared-router.d.ts +0 -17
  321. package/plugins/acryl-router/src/core/router/reg-exp-router/router.d.ts +0 -11
  322. package/plugins/acryl-router/src/core/router/reg-exp-router/trie.d.ts +0 -8
  323. package/plugins/acryl-router/src/core/router/smart-router/index.d.ts +0 -5
  324. package/plugins/acryl-router/src/core/router/smart-router/router.d.ts +0 -11
  325. package/plugins/acryl-router/src/core/router/trie-router/index.d.ts +0 -5
  326. package/plugins/acryl-router/src/core/router/trie-router/node.d.ts +0 -6
  327. package/plugins/acryl-router/src/core/router/trie-router/router.d.ts +0 -7
  328. package/plugins/acryl-router/src/core/router/utils.d.ts +0 -1
  329. package/plugins/acryl-router/src/core/router.d.ts +0 -97
  330. package/plugins/acryl-router/src/core/types.d.ts +0 -573
  331. package/plugins/acryl-router/src/core/utils/accept.d.ts +0 -6
  332. package/plugins/acryl-router/src/core/utils/body.d.ts +0 -79
  333. package/plugins/acryl-router/src/core/utils/buffer.d.ts +0 -17
  334. package/plugins/acryl-router/src/core/utils/color.d.ts +0 -21
  335. package/plugins/acryl-router/src/core/utils/concurrent.d.ts +0 -11
  336. package/plugins/acryl-router/src/core/utils/constants.d.ts +0 -4
  337. package/plugins/acryl-router/src/core/utils/cookie.d.ts +0 -41
  338. package/plugins/acryl-router/src/core/utils/crypto.d.ts +0 -15
  339. package/plugins/acryl-router/src/core/utils/handler.d.ts +0 -6
  340. package/plugins/acryl-router/src/core/utils/headers.d.ts +0 -8
  341. package/plugins/acryl-router/src/core/utils/html.d.ts +0 -44
  342. package/plugins/acryl-router/src/core/utils/http-status.d.ts +0 -32
  343. package/plugins/acryl-router/src/core/utils/mime.d.ts +0 -70
  344. package/plugins/acryl-router/src/core/utils/stream.d.ts +0 -31
  345. package/plugins/acryl-router/src/core/utils/types.d.ts +0 -128
  346. package/plugins/acryl-router/src/core/utils/url.d.ts +0 -44
  347. package/plugins/acryl-router/src/core/validator/index.d.ts +0 -7
  348. package/plugins/acryl-router/src/core/validator/utils.d.ts +0 -29
  349. package/plugins/acryl-router/src/core/validator/validator.d.ts +0 -16
  350. package/plugins/acryl-router/src/helpers/index.d.ts +0 -17
  351. package/plugins/acryl-router/src/helpers/schema-validator.d.ts +0 -54
@@ -0,0 +1,85 @@
1
+ //#region ../../plugins/acryl-router/src/core/middleware/trailing-slash/index.ts
2
+ /**
3
+ * Trailing Slash Middleware for Acryl.
4
+ *
5
+ *
6
+ * @param {TrimTrailingSlashOptions} options - The options for the middleware.
7
+ * @returns {MiddlewareHandler} The middleware handler function.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const app = new Acryl()
12
+ *
13
+ * app.use(trimTrailingSlash())
14
+ * app.get('/about/me/', (c) => c.text('With Trailing Slash'))
15
+ * ```
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * // With alwaysRedirect option for wildcard routes
20
+ * const app = new Acryl()
21
+ *
22
+ * app.use(trimTrailingSlash({ alwaysRedirect: true }))
23
+ * app.get('/my-path/*', (c) => c.text('Wildcard route'))
24
+ * ```
25
+ */
26
+ const trimTrailingSlash = (options) => {
27
+ return async function trimTrailingSlash(c, next) {
28
+ if (options?.alwaysRedirect) {
29
+ if ((c.req.method === "GET" || c.req.method === "HEAD") && c.req.path !== "/" && c.req.path.at(-1) === "/") {
30
+ const url = new URL(c.req.url);
31
+ url.pathname = url.pathname.substring(0, url.pathname.length - 1);
32
+ return c.redirect(url.toString(), 301);
33
+ }
34
+ }
35
+ await next();
36
+ if (!options?.alwaysRedirect && c.res.status === 404 && (c.req.method === "GET" || c.req.method === "HEAD") && c.req.path !== "/" && c.req.path.at(-1) === "/") {
37
+ const url = new URL(c.req.url);
38
+ url.pathname = url.pathname.substring(0, url.pathname.length - 1);
39
+ c.res = c.redirect(url.toString(), 301);
40
+ }
41
+ };
42
+ };
43
+ /**
44
+ * Append trailing slash middleware for Acryl.
45
+ * Append a trailing slash to the URL if it doesn't have one. For example, `/path/to/page` will be redirected to `/path/to/page/`.
46
+ *
47
+ *
48
+ * @param {AppendTrailingSlashOptions} options - The options for the middleware.
49
+ * @returns {MiddlewareHandler} The middleware handler function.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * const app = new Acryl()
54
+ *
55
+ * app.use(appendTrailingSlash())
56
+ * ```
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * // With alwaysRedirect option for wildcard routes
61
+ * const app = new Acryl()
62
+ *
63
+ * app.use(appendTrailingSlash({ alwaysRedirect: true }))
64
+ * app.get('/my-path/*', (c) => c.text('Wildcard route'))
65
+ * ```
66
+ */
67
+ const appendTrailingSlash = (options) => {
68
+ return async function appendTrailingSlash(c, next) {
69
+ if (options?.alwaysRedirect) {
70
+ if ((c.req.method === "GET" || c.req.method === "HEAD") && c.req.path.at(-1) !== "/" && !options.skip?.(c.req.path)) {
71
+ const url = new URL(c.req.url);
72
+ url.pathname += "/";
73
+ return c.redirect(url.toString(), 301);
74
+ }
75
+ }
76
+ await next();
77
+ if (!options?.alwaysRedirect && c.res.status === 404 && (c.req.method === "GET" || c.req.method === "HEAD") && c.req.path.at(-1) !== "/" && !options?.skip?.(c.req.path)) {
78
+ const url = new URL(c.req.url);
79
+ url.pathname += "/";
80
+ c.res = c.redirect(url.toString(), 301);
81
+ }
82
+ };
83
+ };
84
+ //#endregion
85
+ export { trimTrailingSlash as n, appendTrailingSlash as t };
@@ -1,85 +1,2 @@
1
- //#region ../../plugins/acryl-router/src/core/middleware/trailing-slash/index.ts
2
- /**
3
- * Trailing Slash Middleware for Acryl.
4
- *
5
- *
6
- * @param {TrimTrailingSlashOptions} options - The options for the middleware.
7
- * @returns {MiddlewareHandler} The middleware handler function.
8
- *
9
- * @example
10
- * ```ts
11
- * const app = new Acryl()
12
- *
13
- * app.use(trimTrailingSlash())
14
- * app.get('/about/me/', (c) => c.text('With Trailing Slash'))
15
- * ```
16
- *
17
- * @example
18
- * ```ts
19
- * // With alwaysRedirect option for wildcard routes
20
- * const app = new Acryl()
21
- *
22
- * app.use(trimTrailingSlash({ alwaysRedirect: true }))
23
- * app.get('/my-path/*', (c) => c.text('Wildcard route'))
24
- * ```
25
- */
26
- const trimTrailingSlash = (options) => {
27
- return async function trimTrailingSlash(c, next) {
28
- if (options?.alwaysRedirect) {
29
- if ((c.req.method === "GET" || c.req.method === "HEAD") && c.req.path !== "/" && c.req.path.at(-1) === "/") {
30
- const url = new URL(c.req.url);
31
- url.pathname = url.pathname.substring(0, url.pathname.length - 1);
32
- return c.redirect(url.toString(), 301);
33
- }
34
- }
35
- await next();
36
- if (!options?.alwaysRedirect && c.res.status === 404 && (c.req.method === "GET" || c.req.method === "HEAD") && c.req.path !== "/" && c.req.path.at(-1) === "/") {
37
- const url = new URL(c.req.url);
38
- url.pathname = url.pathname.substring(0, url.pathname.length - 1);
39
- c.res = c.redirect(url.toString(), 301);
40
- }
41
- };
42
- };
43
- /**
44
- * Append trailing slash middleware for Acryl.
45
- * Append a trailing slash to the URL if it doesn't have one. For example, `/path/to/page` will be redirected to `/path/to/page/`.
46
- *
47
- *
48
- * @param {AppendTrailingSlashOptions} options - The options for the middleware.
49
- * @returns {MiddlewareHandler} The middleware handler function.
50
- *
51
- * @example
52
- * ```ts
53
- * const app = new Acryl()
54
- *
55
- * app.use(appendTrailingSlash())
56
- * ```
57
- *
58
- * @example
59
- * ```ts
60
- * // With alwaysRedirect option for wildcard routes
61
- * const app = new Acryl()
62
- *
63
- * app.use(appendTrailingSlash({ alwaysRedirect: true }))
64
- * app.get('/my-path/*', (c) => c.text('Wildcard route'))
65
- * ```
66
- */
67
- const appendTrailingSlash = (options) => {
68
- return async function appendTrailingSlash(c, next) {
69
- if (options?.alwaysRedirect) {
70
- if ((c.req.method === "GET" || c.req.method === "HEAD") && c.req.path.at(-1) !== "/" && !options.skip?.(c.req.path)) {
71
- const url = new URL(c.req.url);
72
- url.pathname += "/";
73
- return c.redirect(url.toString(), 301);
74
- }
75
- }
76
- await next();
77
- if (!options?.alwaysRedirect && c.res.status === 404 && (c.req.method === "GET" || c.req.method === "HEAD") && c.req.path.at(-1) !== "/" && !options?.skip?.(c.req.path)) {
78
- const url = new URL(c.req.url);
79
- url.pathname += "/";
80
- c.res = c.redirect(url.toString(), 301);
81
- }
82
- };
83
- };
84
- //#endregion
1
+ import { n as trimTrailingSlash, t as appendTrailingSlash } from "./trailing-slash-DwTx-1sk.js";
85
2
  export { appendTrailingSlash, trimTrailingSlash };
@@ -1,5 +1,5 @@
1
- import { checkOptionalParameter, getPattern, splitPath, splitRoutingPath } from "./utils/url.js";
2
- import "./router.js";
1
+ import { a as getPattern, d as splitRoutingPath, t as checkOptionalParameter, u as splitPath } from "./url-BPh4d6j-.js";
2
+ import "./router-Be_o6nFu.js";
3
3
  import { t as createNullObject } from "./utils-dw8lxqjL.js";
4
4
  //#region ../../plugins/acryl-router/src/core/router/trie-router/node.ts
5
5
  const emptyParams = createNullObject();
@@ -0,0 +1,197 @@
1
+ //#region ../../plugins/acryl-router/src/core/utils/url.ts
2
+ const splitPath = (path) => {
3
+ const paths = path.split("/");
4
+ if (paths[0] === "") paths.shift();
5
+ return paths;
6
+ };
7
+ const splitRoutingPath = (routePath) => {
8
+ const { groups, path } = extractGroupsFromPath(routePath);
9
+ const paths = splitPath(path);
10
+ return replaceGroupMarks(paths, groups);
11
+ };
12
+ const extractGroupsFromPath = (path) => {
13
+ const groups = [];
14
+ path = path.replace(/\{[^}]+\}/g, (match, index) => {
15
+ const mark = `@${index}`;
16
+ groups.push([mark, match]);
17
+ return mark;
18
+ });
19
+ return {
20
+ groups,
21
+ path
22
+ };
23
+ };
24
+ const replaceGroupMarks = (paths, groups) => {
25
+ for (let i = groups.length - 1; i >= 0; i--) {
26
+ const [mark] = groups[i];
27
+ for (let j = paths.length - 1; j >= 0; j--) if (paths[j].includes(mark)) {
28
+ paths[j] = paths[j].replace(mark, groups[i][1]);
29
+ break;
30
+ }
31
+ }
32
+ return paths;
33
+ };
34
+ const patternCache = {};
35
+ const getPattern = (label, next) => {
36
+ if (label === "*") return "*";
37
+ const match = label.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
38
+ if (match) {
39
+ const cacheKey = `${label}#${next}`;
40
+ if (!patternCache[cacheKey]) if (match[2]) patternCache[cacheKey] = next && next[0] !== ":" && next[0] !== "*" ? [
41
+ cacheKey,
42
+ match[1],
43
+ new RegExp(`^${match[2]}(?=/${next})`)
44
+ ] : [
45
+ label,
46
+ match[1],
47
+ new RegExp(`^${match[2]}$`)
48
+ ];
49
+ else patternCache[cacheKey] = [
50
+ label,
51
+ match[1],
52
+ true
53
+ ];
54
+ return patternCache[cacheKey];
55
+ }
56
+ return null;
57
+ };
58
+ const tryDecode = (str, decoder) => {
59
+ try {
60
+ return decoder(str);
61
+ } catch {
62
+ return str.replace(/(?:%[0-9A-Fa-f]{2})+/g, (match) => {
63
+ try {
64
+ return decoder(match);
65
+ } catch {
66
+ return match;
67
+ }
68
+ });
69
+ }
70
+ };
71
+ /**
72
+ * Try to apply decodeURI() to given string.
73
+ * If it fails, skip invalid percent encoding or invalid UTF-8 sequences, and apply decodeURI() to the rest as much as possible.
74
+ * @param str The string to decode.
75
+ * @returns The decoded string that sometimes contains undecodable percent encoding.
76
+ * @example
77
+ * tryDecodeURI('Hello%20World') // 'Hello World'
78
+ * tryDecodeURI('Hello%20World/%A4%A2') // 'Hello World/%A4%A2'
79
+ */
80
+ const tryDecodeURI = (str) => tryDecode(str, decodeURI);
81
+ const getPath = (request) => {
82
+ const url = request.url;
83
+ const start = url.indexOf("/", url.indexOf(":") + 4);
84
+ let i = start;
85
+ for (; i < url.length; i++) {
86
+ const charCode = url.charCodeAt(i);
87
+ if (charCode === 37) {
88
+ const queryIndex = url.indexOf("?", i);
89
+ const hashIndex = url.indexOf("#", i);
90
+ const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
91
+ const path = url.slice(start, end);
92
+ return tryDecodeURI(path.includes("%25") ? path.replace(/%25/g, "%2525") : path);
93
+ } else if (charCode === 63 || charCode === 35) break;
94
+ }
95
+ return url.slice(start, i);
96
+ };
97
+ /**
98
+ * @deprecated
99
+ * Use the `URL` API instead.
100
+ */
101
+ const getQueryStrings = (url) => {
102
+ const queryIndex = url.indexOf("?", 8);
103
+ if (queryIndex === -1) return "";
104
+ const hashIndex = url.indexOf("#", 8);
105
+ return hashIndex === -1 ? url.slice(queryIndex) : queryIndex < hashIndex ? url.slice(queryIndex, hashIndex) : "";
106
+ };
107
+ const getPathNoStrict = (request) => {
108
+ const result = getPath(request);
109
+ return result.length > 1 && result.at(-1) === "/" ? result.slice(0, -1) : result;
110
+ };
111
+ /**
112
+ * Merge paths.
113
+ * @param {string[]} ...paths - The paths to merge.
114
+ * @returns {string} The merged path.
115
+ * @example
116
+ * mergePath('/api', '/users') // '/api/users'
117
+ * mergePath('/api/', '/users') // '/api/users'
118
+ * mergePath('/api', '/') // '/api'
119
+ * mergePath('/api/', '/') // '/api/'
120
+ */
121
+ const mergePath = (base, sub, ...rest) => {
122
+ if (rest.length) sub = mergePath(sub, ...rest);
123
+ return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
124
+ };
125
+ const checkOptionalParameter = (path) => {
126
+ if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":")) return null;
127
+ const segments = path.split("/");
128
+ const results = [];
129
+ let basePath = "";
130
+ segments.forEach((segment) => {
131
+ if (segment !== "" && !/\:/.test(segment)) basePath += "/" + segment;
132
+ else if (/\:/.test(segment)) if (segment.charCodeAt(segment.length - 1) === 63) {
133
+ if (results.length === 0 && basePath === "") results.push("/");
134
+ else results.push(basePath);
135
+ const optionalSegment = segment.slice(0, -1);
136
+ basePath += "/" + optionalSegment;
137
+ results.push(basePath);
138
+ } else basePath += "/" + segment;
139
+ });
140
+ return results.filter((v, i, a) => a.indexOf(v) === i);
141
+ };
142
+ const tryDecodeURIComponent = (str) => str.indexOf("%") !== -1 ? tryDecode(str, decodeURIComponent_) : str;
143
+ const _decodeURI = (value) => {
144
+ if (value.indexOf("+") !== -1) value = value.replace(/\+/g, " ");
145
+ return tryDecodeURIComponent(value);
146
+ };
147
+ const _getQueryParam = (url, key, multiple) => {
148
+ const hashIndex = url.indexOf("#", 8);
149
+ if (hashIndex !== -1) url = url.slice(0, hashIndex);
150
+ let encoded;
151
+ if (!multiple && key && key.indexOf("%") === -1 && key.indexOf("+") === -1) {
152
+ let keyIndex = url.indexOf("?", 8);
153
+ if (keyIndex === -1) return;
154
+ if (!url.startsWith(key, keyIndex + 1)) keyIndex = url.indexOf(`&${key}`, keyIndex + 1);
155
+ while (keyIndex !== -1) {
156
+ const trailingKeyCode = url.charCodeAt(keyIndex + key.length + 1);
157
+ if (trailingKeyCode === 61) {
158
+ const valueIndex = keyIndex + key.length + 2;
159
+ const endIndex = url.indexOf("&", valueIndex);
160
+ return _decodeURI(url.slice(valueIndex, endIndex === -1 ? void 0 : endIndex));
161
+ } else if (trailingKeyCode == 38 || isNaN(trailingKeyCode)) return "";
162
+ keyIndex = url.indexOf(`&${key}`, keyIndex + 1);
163
+ }
164
+ encoded = /[%+]/.test(url);
165
+ if (!encoded) return;
166
+ }
167
+ const results = Object.create(null);
168
+ encoded ??= /[%+]/.test(url);
169
+ let keyIndex = url.indexOf("?", 8);
170
+ while (keyIndex !== -1) {
171
+ const nextKeyIndex = url.indexOf("&", keyIndex + 1);
172
+ let valueIndex = url.indexOf("=", keyIndex);
173
+ if (valueIndex > nextKeyIndex && nextKeyIndex !== -1) valueIndex = -1;
174
+ let name = url.slice(keyIndex + 1, valueIndex === -1 ? nextKeyIndex === -1 ? void 0 : nextKeyIndex : valueIndex);
175
+ if (encoded) name = _decodeURI(name);
176
+ keyIndex = nextKeyIndex;
177
+ if (name === "") continue;
178
+ let value;
179
+ if (valueIndex === -1) value = "";
180
+ else {
181
+ value = url.slice(valueIndex + 1, nextKeyIndex === -1 ? void 0 : nextKeyIndex);
182
+ if (encoded) value = _decodeURI(value);
183
+ }
184
+ if (multiple) {
185
+ if (!(results[name] && Array.isArray(results[name]))) results[name] = [];
186
+ results[name].push(value);
187
+ } else results[name] ??= value;
188
+ }
189
+ return key ? results[key] : results;
190
+ };
191
+ const getQueryParam = _getQueryParam;
192
+ const getQueryParams = (url, key) => {
193
+ return _getQueryParam(url, key, true);
194
+ };
195
+ const decodeURIComponent_ = decodeURIComponent;
196
+ //#endregion
197
+ export { getPattern as a, getQueryStrings as c, splitRoutingPath as d, tryDecode as f, getPathNoStrict as i, mergePath as l, tryDecodeURIComponent as m, decodeURIComponent_ as n, getQueryParam as o, tryDecodeURI as p, getPath as r, getQueryParams as s, checkOptionalParameter as t, splitPath as u };
@@ -1,193 +1,2 @@
1
- //#region ../../plugins/acryl-router/src/core/utils/accept.ts
2
- const isWhitespace = (char) => char === 32 || char === 9 || char === 10 || char === 13;
3
- const consumeWhitespace = (acceptHeader, startIndex) => {
4
- while (startIndex < acceptHeader.length) {
5
- if (!isWhitespace(acceptHeader.charCodeAt(startIndex))) break;
6
- startIndex++;
7
- }
8
- return startIndex;
9
- };
10
- const ignoreTrailingWhitespace = (acceptHeader, startIndex) => {
11
- while (startIndex > 0) {
12
- if (!isWhitespace(acceptHeader.charCodeAt(startIndex - 1))) break;
13
- startIndex--;
14
- }
15
- return startIndex;
16
- };
17
- const skipInvalidParam = (acceptHeader, startIndex) => {
18
- while (startIndex < acceptHeader.length) {
19
- const char = acceptHeader.charCodeAt(startIndex);
20
- if (char === 59) return [startIndex + 1, true];
21
- if (char === 44) return [startIndex + 1, false];
22
- startIndex++;
23
- }
24
- return [startIndex, false];
25
- };
26
- const skipInvalidAcceptValue = (acceptHeader, startIndex) => {
27
- let i = startIndex;
28
- let inQuotes = false;
29
- while (i < acceptHeader.length) {
30
- const char = acceptHeader.charCodeAt(i);
31
- if (inQuotes && char === 92) i++;
32
- else if (char === 34) inQuotes = !inQuotes;
33
- else if (!inQuotes && char === 44) return i + 1;
34
- i++;
35
- }
36
- return i;
37
- };
38
- const getNextParam = (acceptHeader, startIndex) => {
39
- startIndex = consumeWhitespace(acceptHeader, startIndex);
40
- let i = startIndex;
41
- let key;
42
- let value;
43
- let hasNext = false;
44
- while (i < acceptHeader.length) {
45
- const char = acceptHeader.charCodeAt(i);
46
- if (char === 61) {
47
- key = acceptHeader.slice(startIndex, ignoreTrailingWhitespace(acceptHeader, i));
48
- i++;
49
- break;
50
- }
51
- if (char === 59) return [
52
- i + 1,
53
- void 0,
54
- void 0,
55
- true
56
- ];
57
- if (char === 44) return [
58
- i + 1,
59
- void 0,
60
- void 0,
61
- false
62
- ];
63
- i++;
64
- }
65
- if (key === void 0) return [
66
- i,
67
- void 0,
68
- void 0,
69
- false
70
- ];
71
- i = consumeWhitespace(acceptHeader, i);
72
- if (acceptHeader.charCodeAt(i) === 61) {
73
- const skipResult = skipInvalidParam(acceptHeader, i + 1);
74
- return [
75
- skipResult[0],
76
- key,
77
- void 0,
78
- skipResult[1]
79
- ];
80
- }
81
- let inQuotes = false;
82
- const paramStartIndex = i;
83
- while (i < acceptHeader.length) {
84
- const char = acceptHeader.charCodeAt(i);
85
- if (inQuotes && char === 92) i++;
86
- else if (char === 34) {
87
- if (inQuotes) {
88
- let nextIndex = consumeWhitespace(acceptHeader, i + 1);
89
- const nextChar = acceptHeader.charCodeAt(nextIndex);
90
- if (nextIndex < acceptHeader.length && !(nextChar === 59 || nextChar === 44)) {
91
- const skipResult = skipInvalidParam(acceptHeader, nextIndex);
92
- return [
93
- skipResult[0],
94
- key,
95
- void 0,
96
- skipResult[1]
97
- ];
98
- }
99
- value = acceptHeader.slice(paramStartIndex + 1, i);
100
- if (value.includes("\\")) value = value.replace(/\\(.)/g, "$1");
101
- if (nextChar === 44) return [
102
- nextIndex + 1,
103
- key,
104
- value,
105
- false
106
- ];
107
- if (nextChar === 59) {
108
- hasNext = true;
109
- nextIndex++;
110
- }
111
- i = nextIndex;
112
- break;
113
- }
114
- inQuotes = true;
115
- } else if (!inQuotes && (char === 59 || char === 44)) {
116
- value = acceptHeader.slice(paramStartIndex, ignoreTrailingWhitespace(acceptHeader, i));
117
- if (char === 59) hasNext = true;
118
- i++;
119
- break;
120
- }
121
- i++;
122
- }
123
- return [
124
- i,
125
- key,
126
- value ?? acceptHeader.slice(paramStartIndex, ignoreTrailingWhitespace(acceptHeader, i)),
127
- hasNext
128
- ];
129
- };
130
- const getNextAcceptValue = (acceptHeader, startIndex) => {
131
- const accept = {
132
- type: "",
133
- params: Object.create(null),
134
- q: 1
135
- };
136
- startIndex = consumeWhitespace(acceptHeader, startIndex);
137
- let i = startIndex;
138
- while (i < acceptHeader.length) {
139
- const char = acceptHeader.charCodeAt(i);
140
- if (char === 59 || char === 44) {
141
- accept.type = acceptHeader.slice(startIndex, ignoreTrailingWhitespace(acceptHeader, i));
142
- i++;
143
- if (char === 44) return [i, accept.type ? accept : void 0];
144
- if (!accept.type) return [skipInvalidAcceptValue(acceptHeader, i), void 0];
145
- break;
146
- }
147
- i++;
148
- }
149
- if (!accept.type) {
150
- accept.type = acceptHeader.slice(startIndex, ignoreTrailingWhitespace(acceptHeader, acceptHeader.length));
151
- return [acceptHeader.length, accept.type ? accept : void 0];
152
- }
153
- let param;
154
- let value;
155
- let hasNext;
156
- while (i < acceptHeader.length) {
157
- [i, param, value, hasNext] = getNextParam(acceptHeader, i);
158
- if (param && value) accept.params[param] = value;
159
- if (!hasNext) break;
160
- }
161
- return [i, accept];
162
- };
163
- const parseAccept = (acceptHeader) => {
164
- if (!acceptHeader) return [];
165
- const values = [];
166
- let i = 0;
167
- let accept;
168
- let requiresSort = false;
169
- let lastAccept;
170
- while (i < acceptHeader.length) {
171
- [i, accept] = getNextAcceptValue(acceptHeader, i);
172
- if (accept) {
173
- accept.q = parseQuality(accept.params.q ?? accept.params.Q);
174
- values.push(accept);
175
- if (lastAccept && lastAccept.q < accept.q) requiresSort = true;
176
- lastAccept = accept;
177
- }
178
- }
179
- if (requiresSort) values.sort((a, b) => b.q - a.q);
180
- return values;
181
- };
182
- const parseQuality = (qVal) => {
183
- if (qVal === void 0) return 1;
184
- if (qVal === "") return 1;
185
- if (qVal === "NaN") return 0;
186
- const num = Number(qVal);
187
- if (Number.isNaN(num)) return 1;
188
- if (num < 0) return 0;
189
- if (num > 1) return 1;
190
- return num;
191
- };
192
- //#endregion
1
+ import { t as parseAccept } from "../accept-CNNHu4Cf.js";
193
2
  export { parseAccept };
@@ -1,20 +1,2 @@
1
- import { decodeBase64 } from "./encode.js";
2
- //#region ../../plugins/acryl-router/src/core/utils/basic-auth.ts
3
- const CREDENTIALS_REGEXP = /^ *(?:[Bb][Aa][Ss][Ii][Cc]) +([A-Za-z0-9._~+/-]+=*) *$/;
4
- const USER_PASS_REGEXP = /^([^:]*):(.*)$/;
5
- const utf8Decoder = new TextDecoder();
6
- const auth = (req) => {
7
- const match = CREDENTIALS_REGEXP.exec(req.headers.get("Authorization") || "");
8
- if (!match) return;
9
- let userPass = void 0;
10
- try {
11
- userPass = USER_PASS_REGEXP.exec(utf8Decoder.decode(decodeBase64(match[1])));
12
- } catch {}
13
- if (!userPass) return;
14
- return {
15
- username: userPass[1],
16
- password: userPass[2]
17
- };
18
- };
19
- //#endregion
1
+ import { t as auth } from "../basic-auth-C0HTRpXh.js";
20
2
  export { auth };
package/lib/utils/body.js CHANGED
@@ -1,94 +1,2 @@
1
- import { bufferToFormData } from "./buffer.js";
2
- //#region ../../plugins/acryl-router/src/core/utils/body.ts
3
- const MAX_NESTED_OBJECTS = 1e4;
4
- const isRawRequest = (request) => "headers" in request;
5
- const parseBody = async (request, options = Object.create(null)) => {
6
- const { all = false, dot = false } = options;
7
- const mediaType = (isRawRequest(request) ? request.headers : request.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();
8
- if (mediaType === "multipart/form-data" || mediaType === "application/x-www-form-urlencoded") return parseFormData(request, {
9
- all,
10
- dot
11
- });
12
- return {};
13
- };
14
- /**
15
- * Parses form data from a request.
16
- *
17
- * @template T - The type of the parsed body data.
18
- * @param {AcrylRequest | Request} request - The request object containing form data.
19
- * @param {ParseBodyOptions} options - Options for parsing the form data.
20
- * @returns {Promise<T>} The parsed body data.
21
- */
22
- async function parseFormData(request, options) {
23
- if (!isRawRequest(request) && request.bodyCache.formData) return convertFormDataToBodyData(await request.bodyCache.formData, options);
24
- const headers = isRawRequest(request) ? request.headers : request.raw.headers;
25
- const formDataPromise = bufferToFormData(await request.arrayBuffer(), headers.get("Content-Type") || "");
26
- if (!isRawRequest(request)) request.bodyCache.formData = formDataPromise;
27
- const formData = await formDataPromise;
28
- if (formData) return convertFormDataToBodyData(formData, options);
29
- return {};
30
- }
31
- /**
32
- * Converts form data to body data based on the provided options.
33
- *
34
- * @template T - The type of the parsed body data.
35
- * @param {FormData} formData - The form data to convert.
36
- * @param {ParseBodyOptions} options - Options for parsing the form data.
37
- * @returns {T} The converted body data.
38
- */
39
- function convertFormDataToBodyData(formData, options) {
40
- const form = Object.create(null);
41
- const nestingState = { count: 0 };
42
- formData.forEach((value, key) => {
43
- if (!(options.all || key.endsWith("[]"))) form[key] = value;
44
- else handleParsingAllValues(form, key, value);
45
- });
46
- if (options.dot) Object.entries(form).forEach(([key, value]) => {
47
- if (key.includes(".")) {
48
- handleParsingNestedValues(form, key, value, nestingState);
49
- delete form[key];
50
- }
51
- });
52
- return form;
53
- }
54
- /**
55
- * Handles parsing all values for a given key, supporting multiple values as arrays.
56
- *
57
- * @param {BodyData} form - The form data object.
58
- * @param {string} key - The key to parse.
59
- * @param {FormDataEntryValue} value - The value to assign.
60
- */
61
- const handleParsingAllValues = (form, key, value) => {
62
- if (form[key] !== void 0) if (Array.isArray(form[key])) form[key].push(value);
63
- else form[key] = [form[key], value];
64
- else if (!key.endsWith("[]")) form[key] = value;
65
- else form[key] = [value];
66
- };
67
- /**
68
- * Handles parsing nested values using dot notation keys.
69
- *
70
- * @param {BodyData} form - The form data object.
71
- * @param {string} key - The dot notation key.
72
- * @param {BodyDataValue} value - The value to assign.
73
- */
74
- const handleParsingNestedValues = (form, key, value, state) => {
75
- if (/(?:^|\.)__proto__\./.test(key)) return;
76
- let nestedForm = form;
77
- const keys = key.split(".", 34);
78
- if (keys.length > 33) throwNestingLimitExceeded();
79
- keys.forEach((key, index) => {
80
- if (index === keys.length - 1) nestedForm[key] = value;
81
- else {
82
- if (!nestedForm[key] || typeof nestedForm[key] !== "object" || Array.isArray(nestedForm[key]) || nestedForm[key] instanceof File) {
83
- if (state.count++ >= MAX_NESTED_OBJECTS) throwNestingLimitExceeded();
84
- nestedForm[key] = Object.create(null);
85
- }
86
- nestedForm = nestedForm[key];
87
- }
88
- });
89
- };
90
- const throwNestingLimitExceeded = () => {
91
- throw new Error("Nesting limit exceeded");
92
- };
93
- //#endregion
1
+ import { t as parseBody } from "../body-D7f4e7w_.js";
94
2
  export { parseBody };