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,6 @@
1
+ export interface Accept {
2
+ type: string;
3
+ params: Record<string, string>;
4
+ q: number;
5
+ }
6
+ export declare const parseAccept: (acceptHeader: string) => Accept[];
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @module
3
+ * Body utility.
4
+ */
5
+ import type { AcrylRequest } from '../request.ts';
6
+ type BodyDataValueDot = {
7
+ [x: string]: string | File | BodyDataValueDot;
8
+ };
9
+ type BodyDataValueDotAll = {
10
+ [x: string]: string | File | (string | File)[] | BodyDataValueDotAll;
11
+ };
12
+ type SimplifyBodyData<T> = {
13
+ [K in keyof T]: string | File | (string | File)[] | BodyDataValueDotAll extends T[K] ? string | File | (string | File)[] | BodyDataValueDotAll : string | File | BodyDataValueDot extends T[K] ? string | File | BodyDataValueDot : string | File | (string | File)[] extends T[K] ? string | File | (string | File)[] : string | File;
14
+ } & {};
15
+ type BodyDataValueComponent<T> = string | File | (T extends {
16
+ all: false;
17
+ } ? never : T extends {
18
+ all: true;
19
+ } | {
20
+ all: boolean;
21
+ } ? (string | File)[] : never);
22
+ type BodyDataValueObject<T> = {
23
+ [key: string]: BodyDataValueComponent<T> | BodyDataValueObject<T>;
24
+ };
25
+ type BodyDataValue<T> = BodyDataValueComponent<T> | (T extends {
26
+ dot: false;
27
+ } ? never : T extends {
28
+ dot: true;
29
+ } | {
30
+ dot: boolean;
31
+ } ? BodyDataValueObject<T> : never);
32
+ export type BodyData<T extends Partial<ParseBodyOptions> = {}> = SimplifyBodyData<Record<string, BodyDataValue<T>>>;
33
+ export type ParseBodyOptions = {
34
+ /**
35
+ * Determines whether all fields with multiple values should be parsed as arrays.
36
+ * @default false
37
+ * @example
38
+ * const data = new FormData()
39
+ * data.append('file', 'aaa')
40
+ * data.append('file', 'bbb')
41
+ * data.append('message', 'hello')
42
+ *
43
+ * If all is false:
44
+ * parseBody should return { file: 'bbb', message: 'hello' }
45
+ *
46
+ * If all is true:
47
+ * parseBody should return { file: ['aaa', 'bbb'], message: 'hello' }
48
+ */
49
+ all: boolean;
50
+ /**
51
+ * Determines whether all fields with dot notation should be parsed as nested objects.
52
+ * @default false
53
+ * @example
54
+ * const data = new FormData()
55
+ * data.append('obj.key1', 'value1')
56
+ * data.append('obj.key2', 'value2')
57
+ *
58
+ * If dot is false:
59
+ * parseBody should return { 'obj.key1': 'value1', 'obj.key2': 'value2' }
60
+ *
61
+ * If dot is true:
62
+ * parseBody should return { obj: { key1: 'value1', key2: 'value2' } }
63
+ */
64
+ dot: boolean;
65
+ };
66
+ /**
67
+ * Parses the body of a request based on the provided options.
68
+ *
69
+ * @template T - The type of the parsed body data.
70
+ * @param {AcrylRequest | Request} request - The request object to parse.
71
+ * @param {Partial<ParseBodyOptions>} [options] - Options for parsing the body.
72
+ * @returns {Promise<T>} The parsed body data.
73
+ */
74
+ interface ParseBody {
75
+ <Options extends Partial<ParseBodyOptions>, T extends BodyData<Options>>(request: AcrylRequest | Request, options?: Options): Promise<T>;
76
+ <T extends BodyData>(request: AcrylRequest | Request, options?: Partial<ParseBodyOptions>): Promise<T>;
77
+ }
78
+ export declare const parseBody: ParseBody;
79
+ export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @module
3
+ * Buffer utility.
4
+ */
5
+ export declare const equal: (a: ArrayBuffer, b: ArrayBuffer) => boolean;
6
+ type StringHashFunction = (input: string) => string | null | Promise<string | null>;
7
+ type TimingSafeEqual = {
8
+ (a: string, b: string, hashFunction?: StringHashFunction): Promise<boolean>;
9
+ /**
10
+ * @deprecated object and boolean signatures that take boolean as first and second arguments, and functions with signatures that take non-string arguments have been deprecated
11
+ */
12
+ (a: string | object | boolean, b: string | object | boolean, hashFunction?: Function): Promise<boolean>;
13
+ };
14
+ export declare const timingSafeEqual: TimingSafeEqual;
15
+ export declare const bufferToString: (buffer: ArrayBuffer) => string;
16
+ export declare const bufferToFormData: (arrayBuffer: ArrayBuffer, contentType: string) => Promise<FormData>;
17
+ export {};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @module
3
+ * Color utility.
4
+ */
5
+ /**
6
+ * Get whether color change on terminal is enabled or disabled.
7
+ * If `NO_COLOR` environment variable is set, this function returns `false`.
8
+ * Unlike getColorEnabledAsync(), this cannot check Cloudflare environment variables.
9
+ * @see {@link https://no-color.org/}
10
+ *
11
+ * @returns {boolean}
12
+ */
13
+ export declare function getColorEnabled(): boolean;
14
+ /**
15
+ * Get whether color change on terminal is enabled or disabled.
16
+ * If `NO_COLOR` environment variable is set, this function returns `false`.
17
+ * @see {@link https://no-color.org/}
18
+ *
19
+ * @returns {boolean}
20
+ */
21
+ export declare function getColorEnabledAsync(): Promise<boolean>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @module
3
+ * Concurrent utility.
4
+ */
5
+ export interface Pool {
6
+ run<T>(fn: () => T): Promise<T>;
7
+ }
8
+ export declare const createPool: ({ concurrency, interval, }?: {
9
+ concurrency?: number;
10
+ interval?: number;
11
+ }) => Pool;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Constant used to mark a composed handler.
3
+ */
4
+ export declare const COMPOSED_HANDLER = "__COMPOSED_HANDLER";
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @module
3
+ * Cookie utility.
4
+ */
5
+ import type { BufferSource } from './types.ts';
6
+ export type Cookie = Record<string, string>;
7
+ export type SignedCookie = Record<string, string | false>;
8
+ type PartitionedCookieConstraint = {
9
+ partitioned: true;
10
+ secure: true;
11
+ } | {
12
+ partitioned?: boolean;
13
+ secure?: boolean;
14
+ };
15
+ type SecureCookieConstraint = {
16
+ secure: true;
17
+ };
18
+ type HostCookieConstraint = {
19
+ secure: true;
20
+ path: '/';
21
+ domain?: undefined;
22
+ };
23
+ export type CookieOptions = {
24
+ domain?: string;
25
+ expires?: Date;
26
+ httpOnly?: boolean;
27
+ maxAge?: number;
28
+ path?: string;
29
+ secure?: boolean;
30
+ sameSite?: 'Strict' | 'Lax' | 'None' | 'strict' | 'lax' | 'none';
31
+ partitioned?: boolean;
32
+ priority?: 'Low' | 'Medium' | 'High' | 'low' | 'medium' | 'high';
33
+ prefix?: CookiePrefixOptions;
34
+ } & PartitionedCookieConstraint;
35
+ export type CookiePrefixOptions = 'host' | 'secure';
36
+ export type CookieConstraint<Name> = Name extends `__Secure-${string}` ? CookieOptions & SecureCookieConstraint : Name extends `__Host-${string}` ? CookieOptions & HostCookieConstraint : CookieOptions;
37
+ export declare const parse: (cookie: string, name?: string) => Cookie;
38
+ export declare const parseSigned: (cookie: string, secret: string | BufferSource, name?: string) => Promise<SignedCookie>;
39
+ export declare const serialize: <Name extends string>(name: Name, value: string, opt?: CookieConstraint<Name>) => string;
40
+ export declare const serializeSigned: (name: string, value: string, secret: string | BufferSource, opt?: CookieOptions) => Promise<string>;
41
+ export {};
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module
3
+ * Crypto utility.
4
+ */
5
+ import type { JSONValue } from './types.ts';
6
+ type Algorithm = {
7
+ name: string;
8
+ alias: string;
9
+ };
10
+ type Data = string | boolean | number | JSONValue | ArrayBufferView | ArrayBuffer;
11
+ export declare const sha256: (data: Data) => Promise<string | null>;
12
+ export declare const sha1: (data: Data) => Promise<string | null>;
13
+ export declare const md5: (data: Data) => Promise<string | null>;
14
+ export declare const createHash: (data: Data, algorithm: Algorithm) => Promise<string | null>;
15
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @module
3
+ * Handler utility.
4
+ */
5
+ export declare const isMiddleware: (handler: Function) => boolean;
6
+ export declare const findTargetHandler: (handler: Function) => Function;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @module
3
+ * HTTP Headers utility.
4
+ */
5
+ export type RequestHeader = 'A-IM' | 'Accept' | 'Accept-Additions' | 'Accept-CH' | 'Accept-Charset' | 'Accept-Datetime' | 'Accept-Encoding' | 'Accept-Features' | 'Accept-Language' | 'Accept-Patch' | 'Accept-Post' | 'Accept-Query' | 'Accept-Ranges' | 'Accept-Signature' | 'Access-Control' | 'Access-Control-Allow-Credentials' | 'Access-Control-Allow-Headers' | 'Access-Control-Allow-Methods' | 'Access-Control-Allow-Origin' | 'Access-Control-Expose-Headers' | 'Access-Control-Max-Age' | 'Access-Control-Request-Headers' | 'Access-Control-Request-Method' | 'Activate-Storage-Access' | 'Age' | 'Allow' | 'ALPN' | 'Alt-Svc' | 'Alt-Used' | 'Alternates' | 'AMP-Cache-Transform' | 'Apply-To-Redirect-Ref' | 'Authentication-Control' | 'Authentication-Info' | 'Authorization' | 'Available-Dictionary' | 'C-Ext' | 'C-Man' | 'C-Opt' | 'C-PEP' | 'C-PEP-Info' | 'Cache-Control' | 'Cache-Group-Invalidation' | 'Cache-Groups' | 'Cache-Status' | 'Cal-Managed-ID' | 'CalDAV-Timezones' | 'Capsule-Protocol' | 'CDN-Cache-Control' | 'CDN-Loop' | 'Cert-Not-After' | 'Cert-Not-Before' | 'Clear-Site-Data' | 'Client-Cert' | 'Client-Cert-Chain' | 'Close' | 'CMCD-Object' | 'CMCD-Request' | 'CMCD-Session' | 'CMCD-Status' | 'CMSD-Dynamic' | 'CMSD-Static' | 'Concealed-Auth-Export' | 'Configuration-Context' | 'Connection' | 'Content-Base' | 'Content-Digest' | 'Content-Disposition' | 'Content-Encoding' | 'Content-ID' | 'Content-Language' | 'Content-Length' | 'Content-Location' | 'Content-MD5' | 'Content-Range' | 'Content-Script-Type' | 'Content-Security-Policy' | 'Content-Security-Policy-Report-Only' | 'Content-Style-Type' | 'Content-Type' | 'Content-Version' | 'Cookie' | 'Cookie2' | 'Cross-Origin-Embedder-Policy' | 'Cross-Origin-Embedder-Policy-Report-Only' | 'Cross-Origin-Opener-Policy' | 'Cross-Origin-Opener-Policy-Report-Only' | 'Cross-Origin-Resource-Policy' | 'CTA-Common-Access-Token' | 'DASL' | 'Date' | 'DAV' | 'Default-Style' | 'Delta-Base' | 'Deprecation' | 'Depth' | 'Derived-From' | 'Destination' | 'Detached-JWS' | 'Differential-ID' | 'Dictionary-ID' | 'Digest' | 'DPoP' | 'DPoP-Nonce' | 'Early-Data' | 'EDIINT-Features' | 'ETag' | 'Expect' | 'Expect-CT' | 'Expires' | 'Ext' | 'Forwarded' | 'From' | 'GetProfile' | 'Hobareg' | 'Host' | 'HTTP2-Settings' | 'If' | 'If-Match' | 'If-Modified-Since' | 'If-None-Match' | 'If-Range' | 'If-Schedule-Tag-Match' | 'If-Unmodified-Since' | 'IM' | 'Include-Referred-Token-Binding-ID' | 'Incremental' | 'Isolation' | 'Keep-Alive' | 'Label' | 'Last-Event-ID' | 'Last-Modified' | 'Link' | 'Link-Template' | 'Location' | 'Lock-Token' | 'Man' | 'Max-Forwards' | 'Memento-Datetime' | 'Meter' | 'Method-Check' | 'Method-Check-Expires' | 'MIME-Version' | 'Negotiate' | 'NEL' | 'OData-EntityId' | 'OData-Isolation' | 'OData-MaxVersion' | 'OData-Version' | 'Opt' | 'Optional-WWW-Authenticate' | 'Ordering-Type' | 'Origin' | 'Origin-Agent-Cluster' | 'OSCORE' | 'OSLC-Core-Version' | 'Overwrite' | 'P3P' | 'PEP' | 'PEP-Info' | 'Permissions-Policy' | 'PICS-Label' | 'Ping-From' | 'Ping-To' | 'Position' | 'Pragma' | 'Prefer' | 'Preference-Applied' | 'Priority' | 'ProfileObject' | 'Protocol' | 'Protocol-Info' | 'Protocol-Query' | 'Protocol-Request' | 'Proxy-Authenticate' | 'Proxy-Authentication-Info' | 'Proxy-Authorization' | 'Proxy-Features' | 'Proxy-Instruction' | 'Proxy-Status' | 'Public' | 'Public-Key-Pins' | 'Public-Key-Pins-Report-Only' | 'Range' | 'Redirect-Ref' | 'Referer' | 'Referer-Root' | 'Referrer-Policy' | 'Refresh' | 'Repeatability-Client-ID' | 'Repeatability-First-Sent' | 'Repeatability-Request-ID' | 'Repeatability-Result' | 'Replay-Nonce' | 'Reporting-Endpoints' | 'Repr-Digest' | 'Retry-After' | 'Safe' | 'Schedule-Reply' | 'Schedule-Tag' | 'Sec-Fetch-Dest' | 'Sec-Fetch-Mode' | 'Sec-Fetch-Site' | 'Sec-Fetch-Storage-Access' | 'Sec-Fetch-User' | 'Sec-GPC' | 'Sec-Purpose' | 'Sec-Token-Binding' | 'Sec-WebSocket-Accept' | 'Sec-WebSocket-Extensions' | 'Sec-WebSocket-Key' | 'Sec-WebSocket-Protocol' | 'Sec-WebSocket-Version' | 'Security-Scheme' | 'Server' | 'Server-Timing' | 'Set-Cookie' | 'Set-Cookie2' | 'Set-Txn' | 'SetProfile' | 'Signature' | 'Signature-Input' | 'SLUG' | 'SoapAction' | 'Status-URI' | 'Strict-Transport-Security' | 'Sunset' | 'Surrogate-Capability' | 'Surrogate-Control' | 'TCN' | 'TE' | 'Timeout' | 'Timing-Allow-Origin' | 'Topic' | 'Traceparent' | 'Tracestate' | 'Trailer' | 'Transfer-Encoding' | 'TTL' | 'Unencoded-Digest' | 'Upgrade' | 'Urgency' | 'URI' | 'Use-As-Dictionary' | 'User-Agent' | 'Variant-Vary' | 'Vary' | 'Via' | 'Want-Content-Digest' | 'Want-Digest' | 'Want-Repr-Digest' | 'Want-Unencoded-Digest' | 'Warning' | 'WWW-Authenticate' | 'X-Content-Type-Options' | 'X-Frame-Options';
6
+ export type ResponseHeader = 'Accept-Query' | 'Access-Control-Allow-Credentials' | 'Access-Control-Allow-Headers' | 'Access-Control-Allow-Methods' | 'Access-Control-Allow-Origin' | 'Access-Control-Expose-Headers' | 'Access-Control-Max-Age' | 'Activate-Storage-Access' | 'Age' | 'Allow' | 'Cache-Control' | 'Cache-Group-Invalidation' | 'Cache-Groups' | 'Clear-Site-Data' | 'Content-Disposition' | 'Content-Encoding' | 'Content-Language' | 'Content-Length' | 'Content-Location' | 'Content-Range' | 'Content-Security-Policy' | 'Content-Security-Policy-Report-Only' | 'Content-Type' | 'Cookie' | 'Cross-Origin-Embedder-Policy' | 'Cross-Origin-Opener-Policy' | 'Cross-Origin-Resource-Policy' | 'Date' | 'ETag' | 'Expires' | 'Incremental' | 'Last-Modified' | 'Location' | 'Permissions-Policy' | 'Pragma' | 'Retry-After' | 'Save-Data' | 'Sec-CH-Prefers-Color-Scheme' | 'Sec-CH-Prefers-Reduced-Motion' | 'Sec-CH-UA' | 'Sec-CH-UA-Arch' | 'Sec-CH-UA-Bitness' | 'Sec-CH-UA-Form-Factor' | 'Sec-CH-UA-Full-Version' | 'Sec-CH-UA-Full-Version-List' | 'Sec-CH-UA-Mobile' | 'Sec-CH-UA-Model' | 'Sec-CH-UA-Platform' | 'Sec-CH-UA-Platform-Version' | 'Sec-CH-UA-WoW64' | 'Sec-Fetch-Dest' | 'Sec-Fetch-Mode' | 'Sec-Fetch-Site' | 'Sec-Fetch-User' | 'Sec-GPC' | 'Server' | 'Server-Timing' | 'Service-Worker-Navigation-Preload' | 'Set-Cookie' | 'Set-Txn' | 'Strict-Transport-Security' | 'Timing-Allow-Origin' | 'Trailer' | 'Transfer-Encoding' | 'Unencoded-Digest' | 'Upgrade' | 'Vary' | 'Want-Unencoded-Digest' | 'Warning' | 'WWW-Authenticate' | 'X-Content-Type-Options' | 'X-DNS-Prefetch-Control' | 'X-Frame-Options' | 'X-Permitted-Cross-Domain-Policies' | 'X-Powered-By' | 'X-Robots-Tag' | 'X-XSS-Protection';
7
+ export type AcceptHeader = 'Accept' | 'Accept-Charset' | 'Accept-Encoding' | 'Accept-Language' | 'Accept-Patch' | 'Accept-Post' | 'Accept-Ranges';
8
+ export type CustomHeader = string & {};
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @module
3
+ * HTML utility.
4
+ */
5
+ export declare const HtmlEscapedCallbackPhase: {
6
+ readonly Stringify: 1;
7
+ readonly BeforeStream: 2;
8
+ readonly Stream: 3;
9
+ };
10
+ type HtmlEscapedCallbackOpts = {
11
+ buffer?: [string];
12
+ phase: (typeof HtmlEscapedCallbackPhase)[keyof typeof HtmlEscapedCallbackPhase];
13
+ context: Readonly<object>;
14
+ };
15
+ export type HtmlEscapedCallback = (opts: HtmlEscapedCallbackOpts) => Promise<string> | undefined;
16
+ export type HtmlEscaped = {
17
+ isEscaped: true;
18
+ callbacks?: HtmlEscapedCallback[];
19
+ };
20
+ export type HtmlEscapedString = string & HtmlEscaped;
21
+ /**
22
+ * StringBuffer contains string and Promise<string> alternately
23
+ * The length of the array will be odd, the odd numbered element will be a string,
24
+ * and the even numbered element will be a Promise<string>.
25
+ * When concatenating into a single string, it must be processed from the tail.
26
+ * @example
27
+ * [
28
+ * 'framework.',
29
+ * Promise.resolve('ultra fast'),
30
+ * 'a ',
31
+ * Promise.resolve('is '),
32
+ * 'Acryl',
33
+ * ]
34
+ */
35
+ export type StringBuffer = (string | Promise<string>)[];
36
+ export type StringBufferWithCallbacks = StringBuffer & {
37
+ callbacks: HtmlEscapedCallback[];
38
+ };
39
+ export declare const raw: (value: unknown, callbacks?: HtmlEscapedCallback[]) => HtmlEscapedString;
40
+ export declare const stringBufferToString: (buffer: StringBuffer, callbacks: HtmlEscapedCallback[] | undefined) => Promise<HtmlEscapedString>;
41
+ export declare const escapeToBuffer: (str: string, buffer: StringBuffer) => void;
42
+ export declare const resolveCallbackSync: (str: string | HtmlEscapedString) => string;
43
+ export declare const resolveCallback: (str: string | HtmlEscapedString | Promise<string>, phase: (typeof HtmlEscapedCallbackPhase)[keyof typeof HtmlEscapedCallbackPhase], preserveCallbacks: boolean, context: object, buffer?: [string]) => Promise<string>;
44
+ export {};
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @module
3
+ * HTTP Status utility.
4
+ */
5
+ export type InfoStatusCode = 100 | 101 | 102 | 103;
6
+ export type SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226;
7
+ export type DeprecatedStatusCode = 305 | 306;
8
+ export type RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308;
9
+ export type ClientErrorStatusCode = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451;
10
+ export type ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
11
+ /**
12
+ * `UnofficialStatusCode` can be used to specify an unofficial status code.
13
+ * @example
14
+ *
15
+ * ```ts
16
+ * app.get('/unknown', (c) => {
17
+ * return c.text("Unknown Error", 520 as UnofficialStatusCode)
18
+ * })
19
+ * ```
20
+ */
21
+ export type UnofficialStatusCode = -1;
22
+ /**
23
+ * @deprecated
24
+ * Use `UnofficialStatusCode` instead.
25
+ */
26
+ export type UnOfficalStatusCode = UnofficialStatusCode;
27
+ /**
28
+ * If you want to use an unofficial status, use `UnofficialStatusCode`.
29
+ */
30
+ export type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | UnofficialStatusCode;
31
+ export type ContentlessStatusCode = 101 | 204 | 205 | 304;
32
+ export type ContentfulStatusCode = Exclude<StatusCode, ContentlessStatusCode>;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @module
3
+ * MIME utility.
4
+ */
5
+ export declare const getMimeType: (filename: string, mimes?: Record<string, string>) => string | undefined;
6
+ export declare const getExtension: (mimeType: string) => string | undefined;
7
+ export { baseMimes as mimes };
8
+ /**
9
+ * Union types for BaseMime
10
+ */
11
+ export type BaseMime = (typeof _baseMimes)[keyof typeof _baseMimes];
12
+ declare const _baseMimes: {
13
+ readonly aac: "audio/aac";
14
+ readonly avi: "video/x-msvideo";
15
+ readonly avif: "image/avif";
16
+ readonly av1: "video/av1";
17
+ readonly bin: "application/octet-stream";
18
+ readonly bmp: "image/bmp";
19
+ readonly css: "text/css; charset=utf-8";
20
+ readonly csv: "text/csv; charset=utf-8";
21
+ readonly eot: "application/vnd.ms-fontobject";
22
+ readonly epub: "application/epub+zip";
23
+ readonly gif: "image/gif";
24
+ readonly gz: "application/gzip";
25
+ readonly htm: "text/html; charset=utf-8";
26
+ readonly html: "text/html; charset=utf-8";
27
+ readonly ico: "image/x-icon";
28
+ readonly ics: "text/calendar; charset=utf-8";
29
+ readonly jpeg: "image/jpeg";
30
+ readonly jpg: "image/jpeg";
31
+ readonly js: "text/javascript; charset=utf-8";
32
+ readonly json: "application/json";
33
+ readonly jsonld: "application/ld+json";
34
+ readonly map: "application/json";
35
+ readonly mid: "audio/x-midi";
36
+ readonly midi: "audio/x-midi";
37
+ readonly mjs: "text/javascript; charset=utf-8";
38
+ readonly mp3: "audio/mpeg";
39
+ readonly mp4: "video/mp4";
40
+ readonly mpeg: "video/mpeg";
41
+ readonly oga: "audio/ogg";
42
+ readonly ogv: "video/ogg";
43
+ readonly ogx: "application/ogg";
44
+ readonly opus: "audio/opus";
45
+ readonly otf: "font/otf";
46
+ readonly pdf: "application/pdf";
47
+ readonly png: "image/png";
48
+ readonly rtf: "application/rtf";
49
+ readonly svg: "image/svg+xml; charset=utf-8";
50
+ readonly tif: "image/tiff";
51
+ readonly tiff: "image/tiff";
52
+ readonly ts: "video/mp2t";
53
+ readonly ttf: "font/ttf";
54
+ readonly txt: "text/plain; charset=utf-8";
55
+ readonly wasm: "application/wasm";
56
+ readonly webm: "video/webm";
57
+ readonly weba: "audio/webm";
58
+ readonly webmanifest: "application/manifest+json";
59
+ readonly webp: "image/webp";
60
+ readonly woff: "font/woff";
61
+ readonly woff2: "font/woff2";
62
+ readonly xhtml: "application/xhtml+xml; charset=utf-8";
63
+ readonly xml: "application/xml; charset=utf-8";
64
+ readonly zip: "application/zip";
65
+ readonly '3gp': "video/3gpp";
66
+ readonly '3g2': "video/3gpp2";
67
+ readonly gltf: "model/gltf+json";
68
+ readonly glb: "model/gltf-binary";
69
+ };
70
+ declare const baseMimes: Record<string, BaseMime>;
@@ -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,128 @@
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 behavior 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
+ } extends infer A ? A extends ReadonlyArray<unknown> ? A : JSONParsed<InvalidToNull<T[number]>, TError>[] : never : 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
+ /** Bytes a Web Crypto call accepts; declared here so the public types do not need the DOM library. */
75
+ export type BufferSource = ArrayBufferView<ArrayBuffer> | ArrayBuffer;
76
+ /** A Web Crypto key, named from the runtime's own `crypto` so the public types do not need the DOM library. */
77
+ export type CryptoKey = Awaited<ReturnType<typeof crypto.subtle.importKey>>;
78
+ /** What the Web `Headers` constructor accepts, named from the runtime's own `Headers` so the public types do not need the DOM library. */
79
+ export type HeadersInit = NonNullable<ConstructorParameters<typeof Headers>[0]>;
80
+ /** How a WebSocket hands binary data to `onmessage`; declared here so the public types do not need the DOM library. */
81
+ export type BinaryType = 'arraybuffer' | 'blob';
82
+ /** The members of a WebSocket `message` event the helpers hand out (the Web `MessageEvent`, whose Node global is not generic); declared here so the public types do not need the DOM library. */
83
+ export interface MessageEvent<T = unknown> extends Event {
84
+ readonly data: T;
85
+ readonly lastEventId: string;
86
+ readonly origin: string;
87
+ }
88
+ /** The members of a WebSocket `close` event the helpers hand out (the Web `CloseEvent`, which Node has no global type for); declared here so the public types do not need the DOM library. */
89
+ export interface CloseEvent extends Event {
90
+ readonly code: number;
91
+ readonly reason: string;
92
+ readonly wasClean: boolean;
93
+ }
94
+ /** A JSON Web Key (RFC 7517), the same members as the Web Crypto dictionary; declared here so the public types do not need the DOM library. */
95
+ export interface JsonWebKey {
96
+ alg?: string;
97
+ crv?: string;
98
+ d?: string;
99
+ dp?: string;
100
+ dq?: string;
101
+ e?: string;
102
+ ext?: boolean;
103
+ k?: string;
104
+ key_ops?: string[];
105
+ kty?: string;
106
+ n?: string;
107
+ oth?: {
108
+ d?: string;
109
+ r?: string;
110
+ t?: string;
111
+ }[];
112
+ p?: string;
113
+ q?: string;
114
+ qi?: string;
115
+ use?: string;
116
+ x?: string;
117
+ y?: string;
118
+ }
119
+ /**
120
+ * A DOM event type by its global name: the DOM library's own type when it is loaded (a browser project), otherwise the runtime's `Event`,
121
+ * so the JSX types (event handler props) do not need the DOM library on a server.
122
+ */
123
+ export type DomEvent<Name extends string> = typeof globalThis extends {
124
+ readonly [K in Name]: {
125
+ readonly prototype: infer E;
126
+ };
127
+ } ? E : Event;
128
+ export {};
@@ -0,0 +1,44 @@
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
+ /**
23
+ * @deprecated
24
+ * Use the `URL` API instead.
25
+ */
26
+ export declare const getQueryStrings: (url: string) => string;
27
+ export declare const getPathNoStrict: (request: Request) => string;
28
+ /**
29
+ * Merge paths.
30
+ * @param {string[]} ...paths - The paths to merge.
31
+ * @returns {string} The merged path.
32
+ * @example
33
+ * mergePath('/api', '/users') // '/api/users'
34
+ * mergePath('/api/', '/users') // '/api/users'
35
+ * mergePath('/api', '/') // '/api'
36
+ * mergePath('/api/', '/') // '/api/'
37
+ */
38
+ export declare const mergePath: (...paths: string[]) => string;
39
+ export declare const checkOptionalParameter: (path: string) => string[] | null;
40
+ export declare const tryDecodeURIComponent: (str: string) => string;
41
+ export declare const getQueryParam: (url: string, key?: string) => string | undefined | Record<string, string>;
42
+ export declare const getQueryParams: (url: string, key?: string) => string[] | undefined | Record<string, string[]>;
43
+ export declare const decodeURIComponent_: typeof decodeURIComponent;
44
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @module
3
+ * Validator for Acryl.
4
+ */
5
+ export { validator } from './validator.ts';
6
+ export type { ValidationFunction } from './validator.ts';
7
+ export type { InferInput } from './utils.ts';
@@ -0,0 +1,29 @@
1
+ import type { FormValue, ParsedFormValue, ValidationTargets } from '../types.ts';
2
+ import type { UnionToIntersection } from '../utils/types.ts';
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 @acryl-router/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.ts';
2
+ import type { Env, MiddlewareHandler, TypedResponse, ValidationTargets, FormValue } from '../types.ts';
3
+ import type { InferInput } from './utils.ts';
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 {};