acrylblends 0.8.1 → 0.9.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 (235) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +83 -7
  3. package/dist/index.js.map +1 -1
  4. package/lib/audit-BXnYsLge.d.ts +58 -0
  5. package/lib/cell-ChU41DZD.d.ts +32 -0
  6. package/lib/client-modules-CLvWOjbd.js +267 -0
  7. package/lib/connection-ZLEso7XL.d.ts +25 -0
  8. package/lib/conninfo.d.ts +1 -23
  9. package/lib/cordis/db-sqlite.d.ts +56 -0
  10. package/lib/cordis/db-sqlite.js +58 -0
  11. package/lib/cordis/db.d.ts +8 -0
  12. package/lib/cordis/db.js +1 -0
  13. package/lib/cordis/door.d.ts +159 -0
  14. package/lib/cordis/door.js +757 -0
  15. package/lib/cordis/inspect.d.ts +77 -0
  16. package/lib/cordis/inspect.js +149 -0
  17. package/lib/cordis/kv-db.d.ts +16 -0
  18. package/lib/cordis/kv-db.js +18 -0
  19. package/lib/cordis/kv-json.d.ts +16 -0
  20. package/lib/cordis/kv-json.js +44 -0
  21. package/lib/cordis/kv.d.ts +8 -0
  22. package/lib/cordis/kv.js +1 -0
  23. package/lib/cordis/node-server.d.ts +45 -0
  24. package/lib/cordis/node-server.js +93 -0
  25. package/lib/cordis/router-http.d.ts +56 -0
  26. package/lib/cordis/router-http.js +117 -0
  27. package/lib/cordis/router.d.ts +8 -0
  28. package/lib/cordis/router.js +7 -0
  29. package/lib/cordis/state/react.d.ts +6 -0
  30. package/lib/cordis/state/react.js +11 -0
  31. package/lib/cordis/state.d.ts +33 -0
  32. package/lib/cordis/state.js +163 -0
  33. package/lib/core-CaY8XDZ6.js +19 -0
  34. package/lib/database-DBHdwefi.d.ts +44 -0
  35. package/lib/db/conformance.d.ts +11 -0
  36. package/lib/db/conformance.js +267 -0
  37. package/lib/db/sqlite.d.ts +1 -1
  38. package/lib/db/sqlite.js +1 -196
  39. package/lib/db.d.ts +2 -1
  40. package/lib/{src-0hI7M7cN.js → deprecated-BP4fPt38.js} +0 -17
  41. package/lib/door/host.d.ts +24 -0
  42. package/lib/door/host.js +2 -0
  43. package/lib/door/page.d.ts +105 -0
  44. package/lib/door/page.js +1030 -0
  45. package/lib/door/protocol.d.ts +2 -0
  46. package/lib/door/protocol.js +197 -0
  47. package/lib/error-t4N2js2I.d.ts +8 -0
  48. package/lib/etag-DaKMOjty.js +135 -0
  49. package/lib/etag.js +1 -134
  50. package/lib/helpers-CvTauQT5.js +5 -0
  51. package/lib/http-exception-kpGJkmpi.d.ts +57 -0
  52. package/lib/http-exception.d.ts +1 -56
  53. package/lib/{index-BLTYsyc1.d.ts → index-BnGgRKTv.d.ts} +3 -39
  54. package/lib/index-BqVQkTnu.d.ts +98 -0
  55. package/lib/index-Dmst2QCQ.d.ts +44 -0
  56. package/lib/index.d.ts +1 -1
  57. package/lib/index.js +2 -1
  58. package/lib/jwk-LkzeoaU8.js +117 -0
  59. package/lib/jwk.js +1 -116
  60. package/lib/jwt-CskdhEW9.js +115 -0
  61. package/lib/jwt.js +2 -114
  62. package/lib/kv/conformance.d.ts +13 -0
  63. package/lib/kv/conformance.js +301 -0
  64. package/lib/kv/db.d.ts +2 -2
  65. package/lib/kv/json.d.ts +1 -1
  66. package/lib/kv-9f-AlRKN.d.ts +39 -0
  67. package/lib/kv.d.ts +2 -1
  68. package/lib/language-D9a4zqvn.js +198 -0
  69. package/lib/language.js +1 -197
  70. package/lib/middleware-CPQ8himN.js +12 -0
  71. package/lib/node-server/serve-static.d.ts +0 -1
  72. package/lib/node-server/serve-static.js +1 -1
  73. package/lib/node-server.d.ts +1 -7
  74. package/lib/node-server.js +3 -1586
  75. package/lib/open-CMhnJODn.js +197 -0
  76. package/lib/protocol-BizVt4J6.d.ts +144 -0
  77. package/lib/request-id-CKVvHOO1.js +34 -0
  78. package/lib/request-id.js +1 -33
  79. package/lib/secure-headers-mP3j6Hm6.js +163 -0
  80. package/lib/secure-headers.js +1 -162
  81. package/lib/{serve-static-B849HlX2.js → serve-static-3uo_9rjF.js} +1 -4
  82. package/lib/server-DvgMGtzo.js +1323 -0
  83. package/lib/snapshot-text-D3NspDyT.js +338 -0
  84. package/lib/src-CwABFr6r.js +328 -0
  85. package/lib/timeout.d.ts +1 -1
  86. package/lib/timing-Cky7C1Jf.js +183 -0
  87. package/lib/timing.js +1 -182
  88. package/package.json +89 -1
  89. package/plugins/acryl-db/plugin.json +6 -1
  90. package/plugins/acryl-db-sqlite/plugin.json +4 -0
  91. package/plugins/acryl-db-sqlite/src/facade/node.ts +1 -1
  92. package/plugins/acryl-db-sqlite/src/index.ts +2 -2
  93. package/plugins/acryl-db-sqlite/src/open.ts +2 -2
  94. package/plugins/acryl-door/plugin.json +4 -1
  95. package/plugins/acryl-door/src/host/http.ts +2 -2
  96. package/plugins/acryl-door/src/host/mcp-routes.ts +1 -1
  97. package/plugins/acryl-door/src/host/operator-routes.ts +1 -1
  98. package/plugins/acryl-door/src/host/page-routes.ts +3 -3
  99. package/plugins/acryl-door/src/index.ts +2 -2
  100. package/plugins/acryl-inspect/plugin.json +4 -1
  101. package/plugins/acryl-inspect/src/service.ts +2 -2
  102. package/plugins/acryl-kv/plugin.json +6 -1
  103. package/plugins/acryl-kv-db/plugin.json +4 -0
  104. package/plugins/acryl-kv-db/src/index.ts +1 -1
  105. package/plugins/acryl-kv-db/src/open.ts +3 -3
  106. package/plugins/acryl-kv-json/plugin.json +4 -0
  107. package/plugins/acryl-kv-json/src/index.ts +1 -1
  108. package/plugins/acryl-kv-json/src/open.ts +2 -2
  109. package/plugins/acryl-node-server/plugin.json +5 -1
  110. package/plugins/acryl-node-server/src/adapter/conninfo.ts +1 -1
  111. package/plugins/acryl-node-server/src/adapter/early-hints.ts +1 -1
  112. package/plugins/acryl-node-server/src/adapter/serve-static.ts +2 -2
  113. package/plugins/acryl-node-server/src/adapter/websocket.ts +2 -2
  114. package/plugins/acryl-node-server/src/client-modules.ts +2 -2
  115. package/plugins/acryl-node-server/src/index.ts +1 -1
  116. package/plugins/acryl-router/plugin.json +11 -1
  117. package/plugins/acryl-router/src/connection.d.ts +25 -0
  118. package/plugins/acryl-router/src/core/app-base.d.ts +215 -0
  119. package/plugins/acryl-router/src/core/app.d.ts +19 -0
  120. package/plugins/acryl-router/src/core/client/client.d.ts +4 -0
  121. package/plugins/acryl-router/src/core/client/fetch-result-please.d.ts +35 -0
  122. package/plugins/acryl-router/src/core/client/index.d.ts +7 -0
  123. package/plugins/acryl-router/src/core/client/types.d.ts +229 -0
  124. package/plugins/acryl-router/src/core/client/utils.d.ts +18 -0
  125. package/plugins/acryl-router/src/core/compose.d.ts +14 -0
  126. package/plugins/acryl-router/src/core/context.d.ts +443 -0
  127. package/plugins/acryl-router/src/core/helper/accepts/accepts.d.ts +30 -0
  128. package/plugins/acryl-router/src/core/helper/accepts/index.d.ts +5 -0
  129. package/plugins/acryl-router/src/core/helper/conninfo/index.d.ts +5 -0
  130. package/plugins/acryl-router/src/core/helper/conninfo/types.d.ts +36 -0
  131. package/plugins/acryl-router/src/core/helper/cookie/index.d.ts +25 -0
  132. package/plugins/acryl-router/src/core/helper/css/common.d.ts +59 -0
  133. package/plugins/acryl-router/src/core/helper/css/index.d.ts +80 -0
  134. package/plugins/acryl-router/src/core/helper/dev/index.d.ts +20 -0
  135. package/plugins/acryl-router/src/core/helper/factory/index.d.ts +82 -0
  136. package/plugins/acryl-router/src/core/helper/html/index.d.ts +8 -0
  137. package/plugins/acryl-router/src/core/helper/proxy/index.d.ts +73 -0
  138. package/plugins/acryl-router/src/core/helper/route/index.d.ts +75 -0
  139. package/plugins/acryl-router/src/core/helper/ssg/index.d.ts +7 -0
  140. package/plugins/acryl-router/src/core/helper/ssg/middleware.d.ts +44 -0
  141. package/plugins/acryl-router/src/core/helper/ssg/plugins.d.ts +27 -0
  142. package/plugins/acryl-router/src/core/helper/ssg/ssg.d.ts +91 -0
  143. package/plugins/acryl-router/src/core/helper/ssg/utils.d.ts +16 -0
  144. package/plugins/acryl-router/src/core/helper/streaming/index.d.ts +8 -0
  145. package/plugins/acryl-router/src/core/helper/streaming/sse.d.ts +13 -0
  146. package/plugins/acryl-router/src/core/helper/streaming/stream.d.ts +3 -0
  147. package/plugins/acryl-router/src/core/helper/streaming/text.d.ts +3 -0
  148. package/plugins/acryl-router/src/core/helper/streaming/utils.d.ts +1 -0
  149. package/plugins/acryl-router/src/core/helper/testing/index.d.ts +13 -0
  150. package/plugins/acryl-router/src/core/helper/websocket/index.d.ts +70 -0
  151. package/plugins/acryl-router/src/core/http-exception.d.ts +58 -0
  152. package/plugins/acryl-router/src/core/index.d.ts +37 -0
  153. package/plugins/acryl-router/src/core/jsx/base.d.ts +61 -0
  154. package/plugins/acryl-router/src/core/jsx/children.d.ts +9 -0
  155. package/plugins/acryl-router/src/core/jsx/components.d.ts +15 -0
  156. package/plugins/acryl-router/src/core/jsx/constants.d.ts +6 -0
  157. package/plugins/acryl-router/src/core/jsx/context.d.ts +51 -0
  158. package/plugins/acryl-router/src/core/jsx/dom/components.d.ts +10 -0
  159. package/plugins/acryl-router/src/core/jsx/dom/context.d.ts +3 -0
  160. package/plugins/acryl-router/src/core/jsx/dom/css.d.ts +83 -0
  161. package/plugins/acryl-router/src/core/jsx/dom/hooks/index.d.ts +39 -0
  162. package/plugins/acryl-router/src/core/jsx/dom/intrinsic-element/components.d.ts +16 -0
  163. package/plugins/acryl-router/src/core/jsx/dom/jsx-dev-runtime.d.ts +8 -0
  164. package/plugins/acryl-router/src/core/jsx/dom/jsx-runtime.d.ts +7 -0
  165. package/plugins/acryl-router/src/core/jsx/dom/render.d.ts +73 -0
  166. package/plugins/acryl-router/src/core/jsx/dom/utils.d.ts +1 -0
  167. package/plugins/acryl-router/src/core/jsx/hooks/index.d.ts +47 -0
  168. package/plugins/acryl-router/src/core/jsx/index.d.ts +76 -0
  169. package/plugins/acryl-router/src/core/jsx/intrinsic-element/common.d.ts +6 -0
  170. package/plugins/acryl-router/src/core/jsx/intrinsic-element/components.d.ts +13 -0
  171. package/plugins/acryl-router/src/core/jsx/intrinsic-elements.d.ts +735 -0
  172. package/plugins/acryl-router/src/core/jsx/streaming.d.ts +36 -0
  173. package/plugins/acryl-router/src/core/jsx/types.d.ts +36 -0
  174. package/plugins/acryl-router/src/core/jsx/utils.d.ts +4 -0
  175. package/plugins/acryl-router/src/core/request/constants.d.ts +1 -0
  176. package/plugins/acryl-router/src/core/request.d.ts +306 -0
  177. package/plugins/acryl-router/src/core/router/reg-exp-router/index.d.ts +6 -0
  178. package/plugins/acryl-router/src/core/router/reg-exp-router/matcher.d.ts +7 -0
  179. package/plugins/acryl-router/src/core/router/reg-exp-router/node.d.ts +13 -0
  180. package/plugins/acryl-router/src/core/router/reg-exp-router/prepared-router.d.ts +17 -0
  181. package/plugins/acryl-router/src/core/router/reg-exp-router/router.d.ts +11 -0
  182. package/plugins/acryl-router/src/core/router/reg-exp-router/trie.d.ts +8 -0
  183. package/plugins/acryl-router/src/core/router/smart-router/index.d.ts +5 -0
  184. package/plugins/acryl-router/src/core/router/smart-router/router.d.ts +11 -0
  185. package/plugins/acryl-router/src/core/router/trie-router/index.d.ts +5 -0
  186. package/plugins/acryl-router/src/core/router/trie-router/node.d.ts +6 -0
  187. package/plugins/acryl-router/src/core/router/trie-router/router.d.ts +7 -0
  188. package/plugins/acryl-router/src/core/router/utils.d.ts +1 -0
  189. package/plugins/acryl-router/src/core/router.d.ts +97 -0
  190. package/plugins/acryl-router/src/core/types.d.ts +573 -0
  191. package/plugins/acryl-router/src/core/utils/accept.d.ts +6 -0
  192. package/plugins/acryl-router/src/core/utils/body.d.ts +79 -0
  193. package/plugins/acryl-router/src/core/utils/buffer.d.ts +17 -0
  194. package/plugins/acryl-router/src/core/utils/color.d.ts +21 -0
  195. package/plugins/acryl-router/src/core/utils/concurrent.d.ts +11 -0
  196. package/plugins/acryl-router/src/core/utils/constants.d.ts +4 -0
  197. package/plugins/acryl-router/src/core/utils/cookie.d.ts +41 -0
  198. package/plugins/acryl-router/src/core/utils/crypto.d.ts +15 -0
  199. package/plugins/acryl-router/src/core/utils/handler.d.ts +6 -0
  200. package/plugins/acryl-router/src/core/utils/headers.d.ts +8 -0
  201. package/plugins/acryl-router/src/core/utils/html.d.ts +44 -0
  202. package/plugins/acryl-router/src/core/utils/http-status.d.ts +32 -0
  203. package/plugins/acryl-router/src/core/utils/mime.d.ts +70 -0
  204. package/plugins/acryl-router/src/core/utils/stream.d.ts +31 -0
  205. package/plugins/acryl-router/src/core/utils/types.d.ts +128 -0
  206. package/plugins/acryl-router/src/core/utils/url.d.ts +44 -0
  207. package/plugins/acryl-router/src/core/validator/index.d.ts +7 -0
  208. package/plugins/acryl-router/src/core/validator/utils.d.ts +29 -0
  209. package/plugins/acryl-router/src/core/validator/validator.d.ts +16 -0
  210. package/plugins/acryl-router/src/helpers/index.d.ts +17 -0
  211. package/plugins/acryl-router/src/helpers/schema-validator.d.ts +54 -0
  212. package/plugins/acryl-router-http/plugin.json +4 -1
  213. package/plugins/acryl-router-http/src/index.ts +1 -1
  214. package/plugins/acryl-state/plugin.json +5 -1
  215. package/plugins/acryl-state/src/service.ts +3 -3
  216. package/plugins/tsconfig.json +32 -20
  217. package/docs/framework/UPSTREAM.md +0 -3
  218. package/docs/framework/upstream.json +0 -9
  219. package/lib/index-D4FAsBZu.d.ts +0 -85
  220. package/plugins/acryl-db/upstream.json +0 -18
  221. package/plugins/acryl-db-sqlite/upstream.json +0 -21
  222. package/plugins/acryl-door/upstream.json +0 -28
  223. package/plugins/acryl-inspect/upstream.json +0 -18
  224. package/plugins/acryl-kv/upstream.json +0 -18
  225. package/plugins/acryl-kv-db/upstream.json +0 -21
  226. package/plugins/acryl-kv-json/upstream.json +0 -22
  227. package/plugins/acryl-node-server/upstream.json +0 -21
  228. package/plugins/acryl-router/upstream.json +0 -20
  229. package/plugins/acryl-router-http/upstream.json +0 -22
  230. package/plugins/acryl-state/NOTICE +0 -30
  231. package/plugins/acryl-state/upstream.json +0 -22
  232. package/plugins/desktop/upstream.json +0 -12
  233. package/plugins/desktop-web/upstream.json +0 -12
  234. package/templates/todo/upstream.json +0 -12
  235. /package/lib/{index-CTy4N7ng.d.ts → deprecated-CTy4N7ng.d.ts} +0 -0
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @module
3
+ * This module enables JSX to supports streaming Response.
4
+ */
5
+ import type { HtmlEscapedString } from '../utils/html.ts';
6
+ import type { FC, PropsWithChildren, Context as JSXContext } from './index.ts';
7
+ import { JSXNode } from './base.ts';
8
+ /**
9
+ * Used to specify nonce for scripts generated by `Suspense` and `ErrorBoundary`.
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * <StreamingContext.Provider value={{ scriptNonce: 'test-nonce' }}>
14
+ * <Suspense fallback={<p>Loading...</p>}>
15
+ * <Content />
16
+ * </Suspense>
17
+ * </StreamingContext.Provider>
18
+ * ```
19
+ */
20
+ export declare const StreamingContext: JSXContext<{
21
+ scriptNonce: string;
22
+ } | null>;
23
+ /**
24
+ * @experimental
25
+ * `Suspense` is an experimental feature.
26
+ * The API might be changed.
27
+ */
28
+ export declare const Suspense: FC<PropsWithChildren<{
29
+ fallback: any;
30
+ }>>;
31
+ /**
32
+ * @experimental
33
+ * `renderToReadableStream()` is an experimental feature.
34
+ * The API might be changed.
35
+ */
36
+ export declare const renderToReadableStream: (content: HtmlEscapedString | JSXNode | Promise<HtmlEscapedString>, onError?: (e: unknown) => string | void) => ReadableStream<Uint8Array>;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * All types exported from "acryl-router/jsx" are in this file.
3
+ */
4
+ import type { Child, JSXNode } from './base.ts';
5
+ import type { JSX } from './intrinsic-elements.ts';
6
+ import type { DomEvent } from '../utils/types.ts';
7
+ export type { Child, JSXNode, FC } from './base.ts';
8
+ export type { RefObject } from './hooks/index.ts';
9
+ export type { Context } from './context.ts';
10
+ export type PropsWithChildren<P = unknown> = P & {
11
+ children?: Child | undefined;
12
+ };
13
+ export type CSSProperties = JSX.CSSProperties;
14
+ /**
15
+ * React types
16
+ */
17
+ type ReactElement<P = any, T = string | Function> = JSXNode & {
18
+ type: T;
19
+ props: P;
20
+ key: string | null;
21
+ };
22
+ type ReactNode = ReactElement | string | number | boolean | null | undefined;
23
+ type ComponentClass<_P = {}, _S = {}> = unknown;
24
+ export type { ReactElement, ReactNode, ComponentClass };
25
+ export type Event = globalThis.Event;
26
+ export type MouseEvent = DomEvent<'MouseEvent'>;
27
+ export type KeyboardEvent = DomEvent<'KeyboardEvent'>;
28
+ export type FocusEvent = DomEvent<'FocusEvent'>;
29
+ export type ClipboardEvent = DomEvent<'ClipboardEvent'>;
30
+ export type InputEvent = DomEvent<'InputEvent'>;
31
+ export type PointerEvent = DomEvent<'PointerEvent'>;
32
+ export type TouchEvent = DomEvent<'TouchEvent'>;
33
+ export type WheelEvent = DomEvent<'WheelEvent'>;
34
+ export type AnimationEvent = DomEvent<'AnimationEvent'>;
35
+ export type TransitionEvent = DomEvent<'TransitionEvent'>;
36
+ export type DragEvent = DomEvent<'DragEvent'>;
@@ -0,0 +1,4 @@
1
+ export declare const normalizeIntrinsicElementKey: (key: string) => string;
2
+ export declare const isValidTagName: (name: unknown) => name is string;
3
+ export declare const isValidAttributeName: (name: string) => boolean;
4
+ export declare const styleObjectForEach: (style: Record<string, unknown>, fn: (key: string, value: string | null) => void) => void;
@@ -0,0 +1 @@
1
+ export declare const GET_MATCH_RESULT: unique symbol;
@@ -0,0 +1,306 @@
1
+ import { GET_MATCH_RESULT } from './request/constants.ts';
2
+ import type { Result } from './router.ts';
3
+ import type { Input, InputToDataByTarget, ParamKeyToRecord, ParamKeys, RemoveQuestion, RouterRoute, ValidationTargets } from './types.ts';
4
+ import type { BodyData, ParseBodyOptions } from './utils/body.ts';
5
+ import type { CustomHeader, RequestHeader } from './utils/headers.ts';
6
+ import type { Simplify, UnionToIntersection } from './utils/types.ts';
7
+ type Body = {
8
+ json: any;
9
+ text: string;
10
+ arrayBuffer: ArrayBuffer;
11
+ blob: Blob;
12
+ formData: FormData;
13
+ };
14
+ type BodyCache = Partial<Body>;
15
+ export declare class AcrylRequest<P extends string = '/', I extends Input['out'] = {}> {
16
+ #private;
17
+ /**
18
+ * `.raw` can get the raw Request object.
19
+ *
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * // For Cloudflare Workers
24
+ * app.post('/', async (c) => {
25
+ * const metadata = c.req.raw.cf?.hostMetadata?
26
+ * ...
27
+ * })
28
+ * ```
29
+ */
30
+ raw: Request;
31
+ routeIndex: number;
32
+ /**
33
+ * `.path` can get the pathname of the request.
34
+ *
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * app.get('/about/me', (c) => {
39
+ * const pathname = c.req.path // `/about/me`
40
+ * })
41
+ * ```
42
+ */
43
+ path: string;
44
+ bodyCache: BodyCache;
45
+ constructor(request: Request, path?: string, matchResult?: Result<[unknown, RouterRoute]>);
46
+ /**
47
+ * `.req.param()` gets the path parameters.
48
+ *
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * const name = c.req.param('name')
53
+ * // or all parameters at once
54
+ * const { id, comment_id } = c.req.param()
55
+ * ```
56
+ */
57
+ param<P2 extends ParamKeys<P> = ParamKeys<P>>(key: string extends P ? never : P2 extends `${infer _}?` ? never : P2): string;
58
+ param<P2 extends RemoveQuestion<ParamKeys<P>> = RemoveQuestion<ParamKeys<P>>>(key: P2): string | undefined;
59
+ param(key: string): string | undefined;
60
+ param<P2 extends string = P>(): Simplify<UnionToIntersection<ParamKeyToRecord<ParamKeys<P2>>>>;
61
+ /**
62
+ * `.query()` can get querystring parameters.
63
+ *
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * // Query params
68
+ * app.get('/search', (c) => {
69
+ * const query = c.req.query('q')
70
+ * })
71
+ *
72
+ * // Get all params at once
73
+ * app.get('/search', (c) => {
74
+ * const { q, limit, offset } = c.req.query()
75
+ * })
76
+ * ```
77
+ */
78
+ query(key: string): string | undefined;
79
+ query(): Record<string, string>;
80
+ /**
81
+ * `.queries()` can get multiple querystring parameter values, e.g. /search?tags=A&tags=B
82
+ *
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * app.get('/search', (c) => {
87
+ * // tags will be string[]
88
+ * const tags = c.req.queries('tags')
89
+ * })
90
+ * ```
91
+ */
92
+ queries(key: string): string[] | undefined;
93
+ queries(): Record<string, string[]>;
94
+ /**
95
+ * `.header()` can get the request header value.
96
+ *
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * app.get('/', (c) => {
101
+ * const userAgent = c.req.header('User-Agent')
102
+ * })
103
+ * ```
104
+ */
105
+ header(name: RequestHeader): string | undefined;
106
+ header(name: string): string | undefined;
107
+ header(): Record<RequestHeader | (string & CustomHeader), string>;
108
+ /**
109
+ * `.parseBody()` can parse Request body of type `multipart/form-data` or `application/x-www-form-urlencoded`
110
+ *
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * app.post('/entry', async (c) => {
115
+ * const body = await c.req.parseBody()
116
+ * })
117
+ * ```
118
+ */
119
+ parseBody<Options extends Partial<ParseBodyOptions>, T extends BodyData<Options>>(options?: Options): Promise<T>;
120
+ parseBody<T extends BodyData>(options?: Partial<ParseBodyOptions>): Promise<T>;
121
+ /**
122
+ * `.json()` can parse Request body of type `application/json`
123
+ *
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * app.post('/entry', async (c) => {
128
+ * const body = await c.req.json()
129
+ * })
130
+ * ```
131
+ */
132
+ json<T = any>(): Promise<T>;
133
+ /**
134
+ * `.text()` can parse Request body of type `text/plain`
135
+ *
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * app.post('/entry', async (c) => {
140
+ * const body = await c.req.text()
141
+ * })
142
+ * ```
143
+ */
144
+ text(): Promise<string>;
145
+ /**
146
+ * `.arrayBuffer()` parse Request body as an `ArrayBuffer`
147
+ *
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * app.post('/entry', async (c) => {
152
+ * const body = await c.req.arrayBuffer()
153
+ * })
154
+ * ```
155
+ */
156
+ arrayBuffer(): Promise<ArrayBuffer>;
157
+ /**
158
+ * `.bytes()` parses the request body as a `Uint8Array`.
159
+ *
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * app.post('/entry', async (c) => {
164
+ * const body = await c.req.bytes()
165
+ * })
166
+ * ```
167
+ */
168
+ bytes(): Promise<Uint8Array>;
169
+ /**
170
+ * Parses the request body as a `Blob`.
171
+ * @example
172
+ * ```ts
173
+ * app.post('/entry', async (c) => {
174
+ * const body = await c.req.blob();
175
+ * });
176
+ * ```
177
+ */
178
+ blob(): Promise<Blob>;
179
+ /**
180
+ * Parses the request body as `FormData`.
181
+ * @example
182
+ * ```ts
183
+ * app.post('/entry', async (c) => {
184
+ * const body = await c.req.formData();
185
+ * });
186
+ * ```
187
+ */
188
+ formData(): Promise<FormData>;
189
+ /**
190
+ * Adds validated data to the request.
191
+ *
192
+ * @param target - The target of the validation.
193
+ * @param data - The validated data to add.
194
+ */
195
+ addValidatedData(target: keyof ValidationTargets, data: {}): void;
196
+ /**
197
+ * Gets validated data from the request.
198
+ *
199
+ * @param target - The target of the validation.
200
+ * @returns The validated data.
201
+ *
202
+ */
203
+ valid<T extends keyof I & keyof ValidationTargets>(target: T): InputToDataByTarget<I, T>;
204
+ /**
205
+ * `.url` can get the request url strings.
206
+ *
207
+ *
208
+ * @example
209
+ * ```ts
210
+ * app.get('/about/me', (c) => {
211
+ * const url = c.req.url // `http://localhost:8787/about/me`
212
+ * ...
213
+ * })
214
+ * ```
215
+ */
216
+ get url(): string;
217
+ /**
218
+ * `.method` can get the method name of the request.
219
+ *
220
+ *
221
+ * @example
222
+ * ```ts
223
+ * app.get('/about/me', (c) => {
224
+ * const method = c.req.method // `GET`
225
+ * })
226
+ * ```
227
+ */
228
+ get method(): string;
229
+ get [GET_MATCH_RESULT](): Result<[unknown, RouterRoute]>;
230
+ /**
231
+ * `.matchedRoutes` can return a matched route in the handler
232
+ *
233
+ * @deprecated
234
+ *
235
+ * Use matchedRoutes helper defined in "acryl-router/route" instead.
236
+ *
237
+ *
238
+ * @example
239
+ * ```ts
240
+ * app.use('*', async function logger(c, next) {
241
+ * await next()
242
+ * c.req.matchedRoutes.forEach(({ handler, method, path }, i) => {
243
+ * const name = handler.name || (handler.length < 2 ? '[handler]' : '[middleware]')
244
+ * console.log(
245
+ * method,
246
+ * ' ',
247
+ * path,
248
+ * ' '.repeat(Math.max(10 - path.length, 0)),
249
+ * name,
250
+ * i === c.req.routeIndex ? '<- respond from here' : ''
251
+ * )
252
+ * })
253
+ * })
254
+ * ```
255
+ */
256
+ get matchedRoutes(): RouterRoute[];
257
+ /**
258
+ * `.routePath` can retrieve the path registered within the handler
259
+ *
260
+ * @deprecated
261
+ *
262
+ * Use routePath helper defined in "acryl-router/route" instead.
263
+ *
264
+ *
265
+ * @example
266
+ * ```ts
267
+ * app.get('/posts/:id', (c) => {
268
+ * return c.json({ path: c.req.routePath })
269
+ * })
270
+ * ```
271
+ */
272
+ get routePath(): string;
273
+ }
274
+ /**
275
+ * Clones a AcrylRequest's underlying raw Request object.
276
+ *
277
+ * This utility handles both consumed and unconsumed request bodies:
278
+ * - If the request body hasn't been consumed, it uses the native `clone()` method
279
+ * - If the request body has been consumed, it reconstructs a new Request using cached body data
280
+ *
281
+ * This is particularly useful when you need to:
282
+ * - Process the same request body multiple times
283
+ * - Pass requests to external services after validation
284
+ *
285
+ * @param req - The AcrylRequest object to clone
286
+ * @returns A Promise that resolves to a new Request object with the same properties
287
+ * @throws {HTTPException} If the request body was consumed directly via `req.raw`
288
+ * without using AcrylRequest methods (e.g., `req.json()`, `req.text()`), making it
289
+ * impossible to reconstruct the body from cache
290
+ *
291
+ * @example
292
+ * ```ts
293
+ * // Clone after consuming the body (e.g., after validation)
294
+ * app.post('/forward',
295
+ * validator('json', (data) => data),
296
+ * async (c) => {
297
+ * const validated = c.req.valid('json')
298
+ * // Body has been consumed, but cloneRawRequest still works
299
+ * const clonedReq = await cloneRawRequest(c.req)
300
+ * return fetch('http://backend-service.com', clonedReq)
301
+ * }
302
+ * )
303
+ * ```
304
+ */
305
+ export declare const cloneRawRequest: (req: AcrylRequest) => Promise<Request>;
306
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @module
3
+ * RegExpRouter for Acryl.
4
+ */
5
+ export { RegExpRouter } from './router.ts';
6
+ export { PreparedRegExpRouter, buildInitParams, serializeInitParams } from './prepared-router.ts';
@@ -0,0 +1,7 @@
1
+ import type { ParamIndexMap, Result, Router } from '../../router.ts';
2
+ export type HandlerData<T> = [T, ParamIndexMap][];
3
+ export type StaticMap<T> = Record<string, Result<T>>;
4
+ export type Matcher<T> = [RegExp, HandlerData<T>[], StaticMap<T>];
5
+ export type MatcherMap<T> = Record<string, Matcher<T> | null>;
6
+ export declare const emptyParam: string[];
7
+ export declare function match<R extends Router<T>, T>(this: R, method: string, path: string): Result<T>;
@@ -0,0 +1,13 @@
1
+ export declare const LABEL_REG_EXP_STR = "[^/]+";
2
+ export declare const ONLY_WILDCARD_REG_EXP_STR = ".*";
3
+ export declare const TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
4
+ export declare const PATH_ERROR: unique symbol;
5
+ export type ParamAssocArray = [string, number][];
6
+ export interface Context {
7
+ varIndex: number;
8
+ }
9
+ export declare class Node {
10
+ #private;
11
+ insert(tokens: readonly string[], index: number, paramMap: ParamAssocArray, context: Context, isStatic: boolean): void;
12
+ buildRegExpStr(): string;
13
+ }
@@ -0,0 +1,17 @@
1
+ import type { ParamIndexMap, Router } from '../../router.ts';
2
+ import type { MatcherMap } from './matcher.ts';
3
+ import { match } from './matcher.ts';
4
+ type RelocateMap = Record<string, ([(number | string)[], ParamIndexMap] | [(number | string)[]])[]>;
5
+ export declare class PreparedRegExpRouter<T> implements Router<T> {
6
+ #private;
7
+ name: string;
8
+ constructor(matchers: MatcherMap<T>, relocateMap: RelocateMap);
9
+ add(method: string, path: string, handler: T): void;
10
+ protected buildAllMatchers(): MatcherMap<T>;
11
+ match: typeof match<Router<T>, T>;
12
+ }
13
+ export declare const buildInitParams: (params: {
14
+ paths: string[];
15
+ }) => ConstructorParameters<typeof PreparedRegExpRouter>;
16
+ export declare const serializeInitParams: (params: ConstructorParameters<typeof PreparedRegExpRouter>) => string;
17
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { Router } from '../../router.ts';
2
+ import type { MatcherMap } from './matcher.ts';
3
+ import { match } from './matcher.ts';
4
+ export declare class RegExpRouter<T> implements Router<T> {
5
+ #private;
6
+ name: string;
7
+ constructor();
8
+ add(method: string, path: string, handler: T): void;
9
+ match: typeof match<Router<T>, T>;
10
+ protected buildAllMatchers(): MatcherMap<T>;
11
+ }
@@ -0,0 +1,8 @@
1
+ import type { ParamAssocArray } from './node.ts';
2
+ export type ReplacementMap = number[];
3
+ export declare class Trie {
4
+ #private;
5
+ paths: Record<string, [number, ParamAssocArray]>;
6
+ insert(path: string, isStatic: boolean): void;
7
+ buildRegExp(): [RegExp, ReplacementMap, ReplacementMap];
8
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @module
3
+ * SmartRouter for Acryl.
4
+ */
5
+ export { SmartRouter } from './router.ts';
@@ -0,0 +1,11 @@
1
+ import type { Result, Router } from '../../router.ts';
2
+ export declare class SmartRouter<T> implements Router<T> {
3
+ #private;
4
+ name: string;
5
+ constructor(init: {
6
+ routers: Router<T>[];
7
+ });
8
+ add(method: string, path: string, handler: T): void;
9
+ match(method: string, path: string): Result<T>;
10
+ get activeRouter(): Router<T>;
11
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @module
3
+ * TrieRouter for Acryl.
4
+ */
5
+ export { TrieRouter } from './router.ts';
@@ -0,0 +1,6 @@
1
+ import type { Params } from '../../router.ts';
2
+ export declare class Node<T> {
3
+ #private;
4
+ insert(method: string, path: string, handler: T): void;
5
+ search(method: string, path: string): [[T, Params][]];
6
+ }
@@ -0,0 +1,7 @@
1
+ import type { Result, Router } from '../../router.ts';
2
+ export declare class TrieRouter<T> implements Router<T> {
3
+ #private;
4
+ name: string;
5
+ add(method: string, path: string, handler: T): void;
6
+ match(method: string, path: string): Result<T>;
7
+ }
@@ -0,0 +1 @@
1
+ export declare const createNullObject: () => any;
@@ -0,0 +1,97 @@
1
+ /**
2
+ * @module
3
+ * This module provides types definitions and variables for the routers.
4
+ */
5
+ /**
6
+ * Constant representing all HTTP methods in uppercase.
7
+ */
8
+ export declare const METHOD_NAME_ALL: "ALL";
9
+ /**
10
+ * Constant representing all HTTP methods in lowercase.
11
+ */
12
+ export declare const METHOD_NAME_ALL_LOWERCASE: "all";
13
+ /**
14
+ * Array of supported HTTP methods.
15
+ */
16
+ export declare const METHODS: readonly ["get", "post", "put", "delete", "options", "patch", "query"];
17
+ /**
18
+ * Error message indicating that a route cannot be added because the matcher is already built.
19
+ */
20
+ export declare const MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
21
+ /**
22
+ * Interface representing a router.
23
+ *
24
+ * @template T - The type of the handler.
25
+ */
26
+ export interface Router<T> {
27
+ /**
28
+ * The name of the router.
29
+ */
30
+ name: string;
31
+ /**
32
+ * Adds a route to the router.
33
+ *
34
+ * @param method - The HTTP method (e.g., 'get', 'post').
35
+ * @param path - The path for the route.
36
+ * @param handler - The handler for the route.
37
+ */
38
+ add(method: string, path: string, handler: T): void;
39
+ /**
40
+ * Matches a route based on the given method and path.
41
+ *
42
+ * @param method - The HTTP method (e.g., 'get', 'post').
43
+ * @param path - The path to match.
44
+ * @returns The result of the match.
45
+ */
46
+ match(method: string, path: string): Result<T>;
47
+ }
48
+ /**
49
+ * Type representing a map of parameter indices.
50
+ */
51
+ export type ParamIndexMap = Record<string, number>;
52
+ /**
53
+ * Type representing a stash of parameters.
54
+ */
55
+ export type ParamStash = string[];
56
+ /**
57
+ * Type representing a map of parameters.
58
+ */
59
+ export type Params = Record<string, string>;
60
+ /**
61
+ * Type representing the result of a route match.
62
+ *
63
+ * The result can be in one of two formats:
64
+ * 1. An array of handlers with their corresponding parameter index maps, followed by a parameter stash.
65
+ * 2. An array of handlers with their corresponding parameter maps.
66
+ *
67
+ * Example:
68
+ *
69
+ * [[handler, paramIndexMap][], paramArray]
70
+ * ```typescript
71
+ * [
72
+ * [
73
+ * [middlewareA, {}], // '*'
74
+ * [funcA, {'id': 0}], // '/user/:id/*'
75
+ * [funcB, {'id': 0, 'action': 1}], // '/user/:id/:action'
76
+ * ],
77
+ * ['123', 'abc']
78
+ * ]
79
+ * ```
80
+ *
81
+ * [[handler, params][]]
82
+ * ```typescript
83
+ * [
84
+ * [
85
+ * [middlewareA, {}], // '*'
86
+ * [funcA, {'id': '123'}], // '/user/:id/*'
87
+ * [funcB, {'id': '123', 'action': 'abc'}], // '/user/:id/:action'
88
+ * ]
89
+ * ]
90
+ * ```
91
+ */
92
+ export type Result<T> = [[T, ParamIndexMap][], ParamStash] | [[T, Params][]];
93
+ /**
94
+ * Error class representing an unsupported path error.
95
+ */
96
+ export declare class UnsupportedPathError extends Error {
97
+ }