acrylblends 1.0.3 → 1.0.5

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 (256) hide show
  1. package/docs/framework/agents/index.md +6 -4
  2. package/docs/framework/workshop/README.md +3 -3
  3. package/docs/framework/workshop/facilitator.md +1 -0
  4. package/lib/accept-CNNHu4Cf.js +193 -0
  5. package/lib/{accepts-XBuZPVRI.js → accepts-Btq83xPd.js} +1 -1
  6. package/lib/accepts.js +1 -1
  7. package/lib/acryl-base.js +1 -331
  8. package/lib/adapter-CaZ6FZUU.js +37 -0
  9. package/lib/adapter.js +1 -36
  10. package/lib/{app-BM0rTCp7.js → app-CQcGWjrk.js} +4 -4
  11. package/lib/app-base-CpRMZL4v.js +332 -0
  12. package/lib/{audit-BXnYsLge.d.ts → audit-D5z9uwOP.d.ts} +14 -1
  13. package/lib/{base-NSN_SNv-.js → base-D_6kfOr-.js} +1 -1
  14. package/lib/basic-auth-C0HTRpXh.js +20 -0
  15. package/lib/basic-auth-DFLflXNe.js +95 -0
  16. package/lib/basic-auth.js +1 -94
  17. package/lib/bearer-auth-Cwxt-vgS.js +94 -0
  18. package/lib/bearer-auth.js +1 -93
  19. package/lib/body-D7f4e7w_.js +94 -0
  20. package/lib/body-limit-WmIjWRLt.js +66 -0
  21. package/lib/body-limit.js +1 -65
  22. package/lib/buffer-CkEOJCcY.js +51 -0
  23. package/lib/bun.js +3 -3
  24. package/lib/cache-B0bHH7s5.js +169 -0
  25. package/lib/cache.js +1 -168
  26. package/lib/{client-DDLXwhBo.js → client-BrMFnMEd.js} +1 -1
  27. package/lib/{client-modules-CLvWOjbd.js → client-modules-drj4mjhj.js} +4 -4
  28. package/lib/client.js +1 -1
  29. package/lib/color-COa3DplO.js +37 -0
  30. package/lib/combine-TWuGdcbC.js +137 -0
  31. package/lib/combine.js +1 -136
  32. package/lib/{components-cEW3ovK0.js → components-B2ka9Ax1.js} +4 -4
  33. package/lib/{components-JXVm45kK.js → components-PVXwaOaC.js} +2 -2
  34. package/lib/compress-BzWqsHF1.js +79 -0
  35. package/lib/compress-C-9vK4B2.d.ts +11 -0
  36. package/lib/compress-DCyrrQ5D.js +11 -0
  37. package/lib/compress.d.ts +1 -1
  38. package/lib/compress.js +2 -78
  39. package/lib/concurrent-DrF3d2c-.js +30 -0
  40. package/lib/conninfo-BCROmdnf.d.ts +11 -0
  41. package/lib/conninfo-CWJwieh4.js +19 -0
  42. package/lib/constants-CBSEudrb.js +7 -0
  43. package/lib/{context-DDO0cfuP.js → context-CkOh7Ygv.js} +2 -2
  44. package/lib/context-storage-iuPoI_CR.js +52 -0
  45. package/lib/context-storage.js +1 -51
  46. package/lib/cookie-B1LlkzOe.js +125 -0
  47. package/lib/cookie-BHIduy2T.js +82 -0
  48. package/lib/cookie.js +1 -81
  49. package/lib/cordis/db-sqlite.d.ts +1 -1
  50. package/lib/cordis/door.d.ts +17 -3
  51. package/lib/cordis/door.js +123 -16
  52. package/lib/cordis/inspect.js +4 -4
  53. package/lib/cordis/kv-db.d.ts +1 -1
  54. package/lib/cordis/kv-db.js +1 -1
  55. package/lib/cordis/kv-json.d.ts +1 -1
  56. package/lib/cordis/kv-json.js +1 -1
  57. package/lib/cordis/node-server.d.ts +1 -1
  58. package/lib/cordis/node-server.js +3 -116
  59. package/lib/cordis/router-http.d.ts +1 -1
  60. package/lib/cordis/router-http.js +2 -2
  61. package/lib/cordis/router.d.ts +1 -1
  62. package/lib/cordis/router.js +4 -4
  63. package/lib/cordis/state.js +7 -7
  64. package/lib/{core-CaY8XDZ6.js → core-BOu1jYua.js} +1 -1
  65. package/lib/cors-CbAQ-8qU.js +106 -0
  66. package/lib/cors.js +1 -105
  67. package/lib/crypto-iVP-N-tS.js +34 -0
  68. package/lib/csrf-DqqOZtgy.js +101 -0
  69. package/lib/csrf.js +1 -100
  70. package/lib/css-C5CPVMvM.js +134 -0
  71. package/lib/css.js +2 -133
  72. package/lib/db/sqlite.d.ts +1 -25
  73. package/lib/dev-CLgu-JRe.js +50 -0
  74. package/lib/dev.js +1 -49
  75. package/lib/dom-YjND9Jt3.js +74 -0
  76. package/lib/door/host.d.ts +2 -2
  77. package/lib/door/host.js +1 -1
  78. package/lib/door/page.d.ts +12 -1
  79. package/lib/door/page.js +22 -1
  80. package/lib/door/protocol.d.ts +2 -2
  81. package/lib/door/protocol.js +2 -197
  82. package/lib/encode-BhbNLrjp.js +33 -0
  83. package/lib/factory-CLdSf-xS.js +30 -0
  84. package/lib/factory.js +1 -29
  85. package/lib/handler-C0wZ0KwO.js +12 -0
  86. package/lib/helpers-BEjcdbgw.js +5 -0
  87. package/lib/{hooks-w72iLeFR.js → hooks-CfC07ri0.js} +1 -1
  88. package/lib/html-CgNa89xw.js +31 -0
  89. package/lib/html-DGExBFNg.js +103 -0
  90. package/lib/html.d.ts +2 -5
  91. package/lib/html.js +2 -30
  92. package/lib/http-exception-MjWkT89V.js +54 -0
  93. package/lib/http-exception.js +1 -53
  94. package/lib/{index-D4nVR3wu.d.ts → index-DMOtA-NJ.d.ts} +7 -1
  95. package/lib/index-dAzQsJG9.d.ts +6 -0
  96. package/lib/index.js +3 -3
  97. package/lib/ip-restriction-jKtKCRM_.js +166 -0
  98. package/lib/ip-restriction.js +1 -165
  99. package/lib/ipaddr-DCoIo528.js +238 -0
  100. package/lib/jsx/dom/client.js +1 -1
  101. package/lib/jsx/dom/jsx-dev-runtime.js +1 -1
  102. package/lib/jsx/dom/jsx-runtime.js +2 -1
  103. package/lib/jsx/dom/server.js +3 -3
  104. package/lib/jsx/dom.js +5 -73
  105. package/lib/jsx/jsx-dev-runtime.d.ts +2 -5
  106. package/lib/jsx/jsx-dev-runtime.js +2 -13
  107. package/lib/jsx/jsx-runtime.d.ts +2 -2
  108. package/lib/jsx/jsx-runtime.js +4 -4
  109. package/lib/jsx/streaming.js +1 -1
  110. package/lib/jsx-CUQgttxU.js +47 -0
  111. package/lib/jsx-dev-runtime-B4WTyq8r.js +14 -0
  112. package/lib/{jsx-dev-runtime-CWLRA2F3.js → jsx-dev-runtime-BLfA-EhI.js} +2 -2
  113. package/lib/jsx-dev-runtime-CGt4kNYr.d.ts +6 -0
  114. package/lib/jsx-renderer-CfifM4hT.js +99 -0
  115. package/lib/jsx-renderer.js +1 -98
  116. package/lib/jsx-runtime-COCRWBJ9.js +2 -0
  117. package/lib/jsx.js +5 -46
  118. package/lib/{jwk-LkzeoaU8.js → jwk-CDPpYQpD.js} +3 -3
  119. package/lib/jwk.js +1 -1
  120. package/lib/{jwt-BGJBw5AF.js → jwt-BXoIA2fQ.js} +2 -2
  121. package/lib/{jwt-CskdhEW9.js → jwt-lyS4Q3mT.js} +3 -3
  122. package/lib/jwt.js +2 -2
  123. package/lib/kv/db.d.ts +1 -10
  124. package/lib/kv/db.js +1 -56
  125. package/lib/kv/json.d.ts +1 -9
  126. package/lib/kv/json.js +1 -223
  127. package/lib/{language-D9a4zqvn.js → language-DeGRtLJt.js} +2 -2
  128. package/lib/language.js +1 -1
  129. package/lib/{linear-router-C3FPib6h.js → linear-router-CmZn_JLV.js} +2 -2
  130. package/lib/logger-Ckxu8diz.js +54 -0
  131. package/lib/logger.js +1 -53
  132. package/lib/loopback-only-BbasoF7R.js +90 -0
  133. package/lib/loopback-only.js +1 -89
  134. package/lib/method-not-allowed-TO2_hnfl.js +82 -0
  135. package/lib/method-not-allowed.js +1 -81
  136. package/lib/method-override-DnZKfJbV.js +103 -0
  137. package/lib/method-override.js +1 -102
  138. package/lib/middleware-BfG_fp8P.js +12 -0
  139. package/lib/mime-BnScXkQn.js +77 -0
  140. package/lib/mount-QkK_3NtJ.js +67 -0
  141. package/lib/mount.js +1 -66
  142. package/lib/node-server/conninfo.d.ts +1 -10
  143. package/lib/node-server/conninfo.js +1 -18
  144. package/lib/node-server/register.js +25 -2
  145. package/lib/node-server/serve-static.d.ts +1 -17
  146. package/lib/node-server/serve-static.js +1 -1
  147. package/lib/node-server.d.ts +2 -2
  148. package/lib/node-server.js +4 -4
  149. package/lib/open-BqK4D2Wn.d.ts +11 -0
  150. package/lib/open-But9E2rL.js +57 -0
  151. package/lib/open-CULVJgOc.d.ts +12 -0
  152. package/lib/open-Dp4sxspc.js +224 -0
  153. package/lib/open-T7kgbO2O.d.ts +27 -0
  154. package/lib/{pattern-router-HZxjDGEQ.js → pattern-router-CJBecJBd.js} +1 -1
  155. package/lib/powered-by-CXQNjNIX.js +24 -0
  156. package/lib/powered-by.js +1 -23
  157. package/lib/pretty-json-CeC1yvYt.js +39 -0
  158. package/lib/pretty-json.js +1 -38
  159. package/lib/{protocol-BizVt4J6.d.ts → protocol-C37gPePD.d.ts} +9 -2
  160. package/lib/protocol-Dt0AZBOz.js +213 -0
  161. package/lib/proxy-C2w_mH7k.js +121 -0
  162. package/lib/proxy.js +1 -120
  163. package/lib/quick.js +4 -4
  164. package/lib/{reg-exp-router-DC1R3qoY.js → reg-exp-router-C_WV84eV.js} +2 -2
  165. package/lib/request-DvMgGtlW.js +323 -0
  166. package/lib/request.js +1 -322
  167. package/lib/route-D8m-a2I1.js +126 -0
  168. package/lib/route.js +1 -125
  169. package/lib/router/linear-router.js +1 -1
  170. package/lib/router/pattern-router.js +1 -1
  171. package/lib/router/reg-exp-router.js +1 -1
  172. package/lib/router/smart-router.js +1 -1
  173. package/lib/router/trie-router.js +1 -1
  174. package/lib/router-Be_o6nFu.js +35 -0
  175. package/lib/router.js +1 -34
  176. package/lib/schema-validator-EK3cUUCt.js +22 -0
  177. package/lib/schema-validator.js +1 -21
  178. package/lib/{secure-headers-mP3j6Hm6.js → secure-headers-C5ZOcXqk.js} +1 -1
  179. package/lib/secure-headers.js +1 -1
  180. package/lib/serve-static-B7sqnftW.d.ts +18 -0
  181. package/lib/{serve-static-3uo_9rjF.js → serve-static-C1Nkj_xB.js} +2 -2
  182. package/lib/{serve-static-Cp5adzGo.js → serve-static-EiJf1zkO.js} +4 -4
  183. package/lib/serve-static.js +1 -1
  184. package/lib/{smart-router-C5CZ5XSM.js → smart-router-BjxkDQCE.js} +1 -1
  185. package/lib/{snapshot-text-DmE0YfeZ.js → snapshot-text-Bbx43mN0.js} +57 -9
  186. package/lib/{src-2Z4mJg0x.js → src-BTBm4OPD.js} +22 -6
  187. package/lib/src-LX0E4ec4.js +117 -0
  188. package/lib/{ssg-BwjcA-Ge.js → ssg-BEl7MHqg.js} +5 -5
  189. package/lib/ssg.js +1 -1
  190. package/lib/stream-CzM_SHkq.js +88 -0
  191. package/lib/{streaming-DHST3Scg.js → streaming-BlDaph8U.js} +3 -3
  192. package/lib/streaming.js +1 -1
  193. package/lib/{test-websocket-D8WWqE5G.js → test-websocket-BLeEvybj.js} +2 -2
  194. package/lib/testing-BQx5T_UX.js +17 -0
  195. package/lib/testing.js +1 -16
  196. package/lib/timeout-FeqZ9A-0.js +42 -0
  197. package/lib/timeout.js +1 -41
  198. package/lib/tiny.js +2 -2
  199. package/lib/trailing-slash-DwTx-1sk.js +85 -0
  200. package/lib/trailing-slash.js +1 -84
  201. package/lib/{trie-router-CfFbapzL.js → trie-router-JydLKUa2.js} +2 -2
  202. package/lib/url-BPh4d6j-.js +197 -0
  203. package/lib/utils/accept.js +1 -192
  204. package/lib/utils/basic-auth.js +1 -19
  205. package/lib/utils/body.js +1 -93
  206. package/lib/utils/buffer.js +1 -50
  207. package/lib/utils/color.js +1 -36
  208. package/lib/utils/compress.d.ts +1 -10
  209. package/lib/utils/compress.js +1 -10
  210. package/lib/utils/concurrent.js +1 -29
  211. package/lib/utils/constants.js +1 -6
  212. package/lib/utils/cookie.js +1 -124
  213. package/lib/utils/crypto.js +1 -33
  214. package/lib/utils/encode.js +1 -32
  215. package/lib/utils/handler.js +1 -11
  216. package/lib/utils/html.js +1 -102
  217. package/lib/utils/ipaddr.js +1 -237
  218. package/lib/utils/jwt.js +1 -1
  219. package/lib/utils/mime.js +1 -76
  220. package/lib/utils/stream.js +1 -87
  221. package/lib/utils/url.js +1 -196
  222. package/lib/{validator-D84mq-dO.js → validator-Btiyt5VJ.js} +3 -3
  223. package/lib/validator.js +1 -1
  224. package/lib/websocket-DsyBIKVA.js +56 -0
  225. package/lib/ws.js +1 -55
  226. package/package.json +1 -1
  227. package/plugins/acryl-door/src/cli/acryl.ts +5 -3
  228. package/plugins/acryl-door/src/host/channel.ts +36 -0
  229. package/plugins/acryl-door/src/host/chat-tools.ts +2 -0
  230. package/plugins/acryl-door/src/host/door.ts +44 -5
  231. package/plugins/acryl-door/src/host/shim.ts +23 -0
  232. package/plugins/acryl-door/src/host/verbs.ts +4 -3
  233. package/plugins/acryl-door/src/index.ts +39 -3
  234. package/plugins/acryl-door/src/page/driver/driver.ts +22 -1
  235. package/plugins/acryl-door/src/page/protocol.ts +13 -2
  236. package/plugins/acryl-node-server/src/register.ts +29 -2
  237. package/plugins/acryl-router/src/service.ts +19 -1
  238. package/plugins/agent/model.ts +6 -1
  239. package/plugins/agent/tools.ts +12 -2
  240. package/plugins/agent-panel/client/describe.ts +44 -0
  241. package/plugins/agent-panel/client/main.ts +67 -35
  242. package/plugins/agent-panel/index.ts +137 -35
  243. package/plugins/desktop/attach.ts +72 -0
  244. package/plugins/desktop/main.ts +17 -4
  245. package/plugins/extensions/index.ts +3 -4
  246. package/plugins/extensions/stage.ts +33 -5
  247. package/plugins/openai/index.ts +1 -1
  248. package/shared/DEFAULTS.md +4 -0
  249. package/templates/agent/AGENTS.md +2 -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
@@ -0,0 +1,117 @@
1
+ import { c as Request, i as createAdaptorServer, r as UpgradeHub } from "./test-websocket-BLeEvybj.js";
2
+ import "./serve-static-C1Nkj_xB.js";
3
+ import { Service } from "@deepseek-ai/cordis";
4
+ import z from "@deepseek-ai/schemastery";
5
+ //#region ../../plugins/acryl-node-server/src/index.ts
6
+ /** Stable Cordis plugin name, equal to the package name and the Loader row id. */
7
+ const name = "acryl-node-server";
8
+ const inject = ["router"];
9
+ /** Every field has a default, so a caller passes only what it changes: `ctx.plugin(plugin, { ... })` takes the partial shape. */
10
+ const Config = z.object({
11
+ hostname: z.string().default("127.0.0.1").description("Address to bind. Loopback by default; binding elsewhere exposes the app to the network."),
12
+ port: z.number().min(0).max(65535).default(0).description("Port to listen on; 0 lets the system choose. A taken port is followed by the next free one."),
13
+ scan: z.number().min(0).default(20).description("How many further ports to try when the configured one is taken."),
14
+ websocket: z.object({
15
+ maxPayload: z.number().min(1).default(1024 * 1024).description("The largest WebSocket frame accepted, in bytes; a bigger one closes the socket with 1009."),
16
+ heartbeat: z.number().min(0).default(3e4).description("Milliseconds between pings; a peer that did not answer the last one is terminated. 0 turns it off."),
17
+ grace: z.number().min(0).default(2e3).description("Milliseconds a closing socket gets before it is terminated when its plugin unloads.")
18
+ }).default({})
19
+ });
20
+ var NodeServer = class extends Service {
21
+ hostname;
22
+ config;
23
+ server;
24
+ hub;
25
+ bound = 0;
26
+ constructor(ctx, config) {
27
+ super(ctx, "nodeServer");
28
+ this.config = config;
29
+ this.hostname = config.hostname;
30
+ const router = ctx.router;
31
+ this.server = createAdaptorServer({
32
+ fetch: (request, { incoming }) => router.fetch(new Request(request), {
33
+ remoteAddress: incoming.socket.remoteAddress,
34
+ localPort: incoming.socket.localPort
35
+ }),
36
+ hostname: config.hostname,
37
+ overrideGlobalObjects: false
38
+ });
39
+ ctx.effect(() => async () => {
40
+ await this.hub?.close();
41
+ this.server.closeAllConnections();
42
+ if (this.server.listening) await new Promise((resolve) => {
43
+ this.server.close(() => {
44
+ resolve();
45
+ });
46
+ });
47
+ }, "acryl-node-server: close listener and open connections");
48
+ }
49
+ /**
50
+ * `upgradeWebSocket` for the plugin that asks (call it once, in `apply`): `app.get('/ws', upgrade((c) => ({ onMessage(event, ws) { ... } })))`. Checks go in ordinary middleware on the
51
+ * route, and a handler that returns a `Response` refuses the upgrade with that status before any handshake. Every socket it accepts belongs to the calling plugin: when the plugin
52
+ * unloads they are closed with 1001 within `websocket.grace` and the handler sees `close` once. Pass `{ textOnly: true }` to drop binary frames. Needs the `ws` package.
53
+ */
54
+ upgrades() {
55
+ if (!this.hub) {
56
+ this.hub = new UpgradeHub(this.config.websocket);
57
+ this.hub.attach(this.server, this.ctx.router);
58
+ }
59
+ return this.hub.upgradeWebSocketFor(this.ctx);
60
+ }
61
+ /** How many WebSocket connections are open now. */
62
+ get sockets() {
63
+ return this.hub?.size ?? 0;
64
+ }
65
+ /** The port in use, 0 before the server listens. */
66
+ get port() {
67
+ return this.bound;
68
+ }
69
+ /** The address clients use. */
70
+ get url() {
71
+ return `http://${this.hostname.includes(":") ? `[${this.hostname}]` : this.hostname}:${String(this.bound)}`;
72
+ }
73
+ /** Bind, scanning past taken ports. */
74
+ async listen() {
75
+ const { port, scan, hostname } = this.config;
76
+ const last = port === 0 ? 0 : Math.min(65535, port + scan);
77
+ for (let candidate = port; candidate <= last; candidate += 1) try {
78
+ await new Promise((resolve, reject) => {
79
+ const onError = (error) => {
80
+ reject(error);
81
+ };
82
+ this.server.once("error", onError);
83
+ this.server.listen(candidate, hostname, () => {
84
+ this.server.off("error", onError);
85
+ resolve();
86
+ });
87
+ });
88
+ this.bound = this.server.address().port;
89
+ return;
90
+ } catch (error) {
91
+ if (!isPortUnavailable(error)) throw error;
92
+ }
93
+ throw new Error(`acryl-node-server: no free port from ${String(port)} to ${String(last)} on ${hostname}`);
94
+ }
95
+ };
96
+ /**
97
+ * Whether a failed bind means "this port, try the next one". A port another socket holds answers `EADDRINUSE` everywhere. On Windows a port
98
+ * inside a range the system reserves (Hyper-V, WSL and Docker exclude ranges, `netsh interface ipv4 show excludedportrange`) answers
99
+ * `EACCES`, which is a property of that port too; elsewhere `EACCES` means the process may not bind low ports at all, so moving on would
100
+ * only hide the reason.
101
+ */
102
+ function isPortUnavailable(error, platform = process.platform) {
103
+ const code = error?.code;
104
+ return code === "EADDRINUSE" || platform === "win32" && code === "EACCES";
105
+ }
106
+ /** Loads once the server listens, so a plugin that injects `nodeServer` can rely on `url`. A failure to bind fails the plugin. */
107
+ async function apply(ctx, config = {}) {
108
+ await new NodeServer(ctx, {
109
+ hostname: "127.0.0.1",
110
+ port: 0,
111
+ scan: 20,
112
+ websocket: {},
113
+ ...config
114
+ }).listen();
115
+ }
116
+ //#endregion
117
+ export { isPortUnavailable as a, inject as i, NodeServer as n, name as o, apply as r, Config as t };
@@ -1,9 +1,9 @@
1
- import "./router.js";
2
- import { html } from "./html.js";
3
- import { getExtension } from "./utils/mime.js";
4
- import { findTargetHandler, isMiddleware } from "./utils/handler.js";
1
+ import "./router-Be_o6nFu.js";
2
+ import { t as html } from "./html-CgNa89xw.js";
3
+ import { n as getExtension } from "./mime-BnScXkQn.js";
4
+ import { n as isMiddleware, t as findTargetHandler } from "./handler-C0wZ0KwO.js";
5
5
  import { o as replaceUrlParam } from "./utils-Cx61GFMC.js";
6
- import { createPool } from "./utils/concurrent.js";
6
+ import { t as createPool } from "./concurrent-DrF3d2c-.js";
7
7
  //#region ../../plugins/acryl-router/src/core/helper/ssg/utils.ts
8
8
  /**
9
9
  * Get dirname
package/lib/ssg.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as defaultExtensionMap, c as toSSG, d as X_ACRYL_DISABLE_SSG_HEADER_KEY, f as disableSSG, h as ssgParams, i as combineBeforeRequestHooks, l as defaultPlugin, m as onlySSG, n as combineAfterGenerateHooks, o as fetchRoutesContent, p as isSSGContext, r as combineAfterResponseHooks, s as saveContentToFile, t as DEFAULT_OUTPUT_DIR, u as redirectPlugin } from "./ssg-BwjcA-Ge.js";
1
+ import { a as defaultExtensionMap, c as toSSG, d as X_ACRYL_DISABLE_SSG_HEADER_KEY, f as disableSSG, h as ssgParams, i as combineBeforeRequestHooks, l as defaultPlugin, m as onlySSG, n as combineAfterGenerateHooks, o as fetchRoutesContent, p as isSSGContext, r as combineAfterResponseHooks, s as saveContentToFile, t as DEFAULT_OUTPUT_DIR, u as redirectPlugin } from "./ssg-BEl7MHqg.js";
2
2
  export { DEFAULT_OUTPUT_DIR, X_ACRYL_DISABLE_SSG_HEADER_KEY, combineAfterGenerateHooks, combineAfterResponseHooks, combineBeforeRequestHooks, defaultExtensionMap, defaultPlugin, disableSSG, fetchRoutesContent, isSSGContext, onlySSG, redirectPlugin, saveContentToFile, ssgParams, toSSG };
@@ -0,0 +1,88 @@
1
+ //#region ../../plugins/acryl-router/src/core/utils/stream.ts
2
+ /**
3
+ * @module
4
+ * Stream utility.
5
+ */
6
+ var StreamingApi = class {
7
+ writer;
8
+ encoder;
9
+ writable;
10
+ abortSubscribers = [];
11
+ responseReadable;
12
+ /**
13
+ * Whether the stream has been aborted.
14
+ */
15
+ aborted = false;
16
+ /**
17
+ * Whether the stream has been closed normally.
18
+ */
19
+ closed = false;
20
+ constructor(writable, _readable) {
21
+ this.writable = writable;
22
+ this.writer = writable.getWriter();
23
+ this.encoder = new TextEncoder();
24
+ const reader = _readable.getReader();
25
+ this.abortSubscribers.push(async () => {
26
+ await reader.cancel();
27
+ });
28
+ this.responseReadable = new ReadableStream({
29
+ async pull(controller) {
30
+ const { done, value } = await reader.read();
31
+ done ? controller.close() : controller.enqueue(value);
32
+ },
33
+ cancel: () => {
34
+ if (!this.closed) this.abort();
35
+ }
36
+ });
37
+ }
38
+ async write(input) {
39
+ try {
40
+ if (typeof input === "string") input = this.encoder.encode(input);
41
+ await this.writer.write(input);
42
+ } catch {}
43
+ return this;
44
+ }
45
+ async writeln(input) {
46
+ await this.write(input + "\n");
47
+ return this;
48
+ }
49
+ sleep(ms) {
50
+ return new Promise((res) => setTimeout(res, ms));
51
+ }
52
+ async close() {
53
+ this.closed = true;
54
+ try {
55
+ await this.writer.close();
56
+ } catch {}
57
+ }
58
+ async pipe(body) {
59
+ this.writer.releaseLock();
60
+ try {
61
+ await body.pipeTo(this.writable, {
62
+ preventClose: true,
63
+ preventAbort: true
64
+ });
65
+ } finally {
66
+ this.writer = this.writable.getWriter();
67
+ }
68
+ }
69
+ onAbort(listener) {
70
+ this.abortSubscribers.push(listener);
71
+ }
72
+ /**
73
+ * Abort the stream.
74
+ * You can call this method when stream is aborted by external event.
75
+ */
76
+ abort() {
77
+ if (!this.aborted) {
78
+ this.aborted = true;
79
+ this.abortSubscribers.forEach((subscriber) => {
80
+ try {
81
+ Promise.resolve(subscriber()).catch(() => {});
82
+ } catch {}
83
+ });
84
+ }
85
+ }
86
+ };
87
+ //#endregion
88
+ export { StreamingApi as t };
@@ -1,6 +1,6 @@
1
- import { HtmlEscapedCallbackPhase, resolveCallback } from "./utils/html.js";
2
- import { n as TEXT_PLAIN } from "./context-DDO0cfuP.js";
3
- import { StreamingApi } from "./utils/stream.js";
1
+ import { i as resolveCallback, t as HtmlEscapedCallbackPhase } from "./html-DGExBFNg.js";
2
+ import { n as TEXT_PLAIN } from "./context-CkOh7Ygv.js";
3
+ import { t as StreamingApi } from "./stream-CzM_SHkq.js";
4
4
  //#region ../../plugins/acryl-router/src/core/helper/streaming/utils.ts
5
5
  let isOldBunVersion = () => {
6
6
  const version = typeof Bun !== "undefined" ? Bun.version : void 0;
package/lib/streaming.js CHANGED
@@ -1,2 +1,2 @@
1
- import { i as stream, n as SSEStreamingApi, r as streamSSE, t as streamText } from "./streaming-DHST3Scg.js";
1
+ import { i as stream, n as SSEStreamingApi, r as streamSSE, t as streamText } from "./streaming-BlDaph8U.js";
2
2
  export { SSEStreamingApi, stream, streamSSE, streamText };
@@ -1,5 +1,5 @@
1
- import { defineWebSocketHelper } from "./ws.js";
2
- import "./helpers-CvTauQT5.js";
1
+ import { r as defineWebSocketHelper } from "./websocket-DsyBIKVA.js";
2
+ import "./helpers-BEjcdbgw.js";
3
3
  import { createRequire } from "node:module";
4
4
  import { STATUS_CODES, ServerResponse, createServer } from "node:http";
5
5
  import { Http2ServerRequest, constants } from "node:http2";
@@ -0,0 +1,17 @@
1
+ import { t as hc } from "./client-BrMFnMEd.js";
2
+ //#region ../../plugins/acryl-router/src/core/helper/testing/index.ts
3
+ /**
4
+ * @module
5
+ * Testing Helper for Acryl.
6
+ */
7
+ const testClient = (app, Env, executionCtx, options) => {
8
+ const customFetch = (input, init) => {
9
+ return app.request(input, init, Env, executionCtx);
10
+ };
11
+ return hc("http://localhost", {
12
+ ...options,
13
+ fetch: customFetch
14
+ });
15
+ };
16
+ //#endregion
17
+ export { testClient as t };
package/lib/testing.js CHANGED
@@ -1,17 +1,2 @@
1
- import { t as hc } from "./client-DDLXwhBo.js";
2
- //#region ../../plugins/acryl-router/src/core/helper/testing/index.ts
3
- /**
4
- * @module
5
- * Testing Helper for Acryl.
6
- */
7
- const testClient = (app, Env, executionCtx, options) => {
8
- const customFetch = (input, init) => {
9
- return app.request(input, init, Env, executionCtx);
10
- };
11
- return hc("http://localhost", {
12
- ...options,
13
- fetch: customFetch
14
- });
15
- };
16
- //#endregion
1
+ import { t as testClient } from "./testing-BQx5T_UX.js";
17
2
  export { testClient };
@@ -0,0 +1,42 @@
1
+ import { t as HTTPException } from "./http-exception-MjWkT89V.js";
2
+ //#region ../../plugins/acryl-router/src/core/middleware/timeout/index.ts
3
+ const defaultTimeoutException = new HTTPException(504, { message: "Gateway Timeout" });
4
+ /**
5
+ * Timeout Middleware for Acryl.
6
+ *
7
+ * @param {number} duration - The timeout duration in milliseconds.
8
+ * @param {HTTPExceptionFunction | HTTPException} [exception=defaultTimeoutException] - The exception to throw when the timeout occurs. Can be a function that returns an HTTPException or an HTTPException object.
9
+ * @returns {MiddlewareHandler} The middleware handler function.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const app = new Acryl()
14
+ *
15
+ * app.use(
16
+ * '/long-request',
17
+ * timeout(5000) // Set timeout to 5 seconds
18
+ * )
19
+ *
20
+ * app.get('/long-request', async (c) => {
21
+ * await someLongRunningFunction()
22
+ * return c.text('Completed within time limit')
23
+ * })
24
+ * ```
25
+ */
26
+ const timeout = (duration, exception = defaultTimeoutException) => {
27
+ return async function timeout(context, next) {
28
+ let timer;
29
+ const timeoutPromise = new Promise((_, reject) => {
30
+ timer = setTimeout(() => {
31
+ reject(typeof exception === "function" ? exception(context) : exception);
32
+ }, duration);
33
+ });
34
+ try {
35
+ await Promise.race([next(), timeoutPromise]);
36
+ } finally {
37
+ if (timer !== void 0) clearTimeout(timer);
38
+ }
39
+ };
40
+ };
41
+ //#endregion
42
+ export { timeout as t };
package/lib/timeout.js CHANGED
@@ -1,42 +1,2 @@
1
- import { HTTPException } from "./http-exception.js";
2
- //#region ../../plugins/acryl-router/src/core/middleware/timeout/index.ts
3
- const defaultTimeoutException = new HTTPException(504, { message: "Gateway Timeout" });
4
- /**
5
- * Timeout Middleware for Acryl.
6
- *
7
- * @param {number} duration - The timeout duration in milliseconds.
8
- * @param {HTTPExceptionFunction | HTTPException} [exception=defaultTimeoutException] - The exception to throw when the timeout occurs. Can be a function that returns an HTTPException or an HTTPException object.
9
- * @returns {MiddlewareHandler} The middleware handler function.
10
- *
11
- * @example
12
- * ```ts
13
- * const app = new Acryl()
14
- *
15
- * app.use(
16
- * '/long-request',
17
- * timeout(5000) // Set timeout to 5 seconds
18
- * )
19
- *
20
- * app.get('/long-request', async (c) => {
21
- * await someLongRunningFunction()
22
- * return c.text('Completed within time limit')
23
- * })
24
- * ```
25
- */
26
- const timeout = (duration, exception = defaultTimeoutException) => {
27
- return async function timeout(context, next) {
28
- let timer;
29
- const timeoutPromise = new Promise((_, reject) => {
30
- timer = setTimeout(() => {
31
- reject(typeof exception === "function" ? exception(context) : exception);
32
- }, duration);
33
- });
34
- try {
35
- await Promise.race([next(), timeoutPromise]);
36
- } finally {
37
- if (timer !== void 0) clearTimeout(timer);
38
- }
39
- };
40
- };
41
- //#endregion
1
+ import { t as timeout } from "./timeout-FeqZ9A-0.js";
42
2
  export { timeout };
package/lib/tiny.js CHANGED
@@ -1,5 +1,5 @@
1
- import { AcrylBase as Acryl$1 } from "./acryl-base.js";
2
- import { t as PatternRouter } from "./pattern-router-HZxjDGEQ.js";
1
+ import { t as Acryl$1 } from "./app-base-CpRMZL4v.js";
2
+ import { t as PatternRouter } from "./pattern-router-CJBecJBd.js";
3
3
  //#region ../../plugins/acryl-router/src/core/preset/tiny.ts
4
4
  /**
5
5
  * @module
@@ -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();