@acryldev/blends 0.0.0-stage → 1.7.1
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.
- package/LICENSE +73 -0
- package/README.md +424 -2
- package/bin/acrylblends.js +12 -0
- package/dist/index.d.ts +231 -0
- package/dist/index.js +4505 -0
- package/dist/index.js.map +1 -0
- package/lib/accept-B13wFRkc.js +193 -0
- package/lib/accepts-BN4uue4T.js +52 -0
- package/lib/accepts.d.ts +33 -0
- package/lib/accepts.js +2 -0
- package/lib/acryl-base.d.ts +2 -0
- package/lib/acryl-base.js +2 -0
- package/lib/adapter-Wt9Ntyhx.js +37 -0
- package/lib/adapter.d.ts +12 -0
- package/lib/adapter.js +2 -0
- package/lib/app-CM-rDcw6.js +26 -0
- package/lib/app-DGqSNBSd.d.ts +21 -0
- package/lib/app-base-BwplqlWX.js +332 -0
- package/lib/audit-B2H3sUfg.d.ts +136 -0
- package/lib/base-N-QVQhMZ.d.ts +783 -0
- package/lib/base-kl8P-za0.js +722 -0
- package/lib/basic-auth-ByZGvWGz.js +95 -0
- package/lib/basic-auth-CzulvSad.js +20 -0
- package/lib/basic-auth.d.ts +72 -0
- package/lib/basic-auth.js +2 -0
- package/lib/bearer-auth-CfR6YNqy.js +94 -0
- package/lib/bearer-auth.d.ts +89 -0
- package/lib/bearer-auth.js +2 -0
- package/lib/body-BQ-J23GI.js +94 -0
- package/lib/body-limit-DyO82Wes.js +66 -0
- package/lib/body-limit.d.ts +42 -0
- package/lib/body-limit.js +2 -0
- package/lib/browser/client.js +307 -0
- package/lib/browser/jsx-dom.js +1432 -0
- package/lib/browser/read-sse.js +84 -0
- package/lib/buffer-CWpxJrvI.js +51 -0
- package/lib/bun.d.ts +75 -0
- package/lib/bun.js +134 -0
- package/lib/cache-DllEV7kz.js +169 -0
- package/lib/cache.d.ts +43 -0
- package/lib/cache.js +2 -0
- package/lib/cell-wEBQA3d0.d.ts +32 -0
- package/lib/client-BMFCUlHG.js +143 -0
- package/lib/client-modules-ChLgW0l9.js +267 -0
- package/lib/client.d.ts +3 -0
- package/lib/client.js +3 -0
- package/lib/color-C26GR4OI.js +37 -0
- package/lib/combine-rXRCRMJx.js +137 -0
- package/lib/combine.d.ts +85 -0
- package/lib/combine.js +2 -0
- package/lib/common-CaqP5LIh.d.ts +46 -0
- package/lib/components-BZ8vBk_7.js +268 -0
- package/lib/components-Cq4hcRbo.js +24 -0
- package/lib/compose-DbuvN1rE.js +50 -0
- package/lib/compress-C7QjZM5f.js +11 -0
- package/lib/compress-CdDuP9-S.d.ts +11 -0
- package/lib/compress-T36YxGla.js +79 -0
- package/lib/compress.d.ts +38 -0
- package/lib/compress.js +3 -0
- package/lib/concurrent-B7z-2cwF.js +30 -0
- package/lib/connection-CzRPq1RP.d.ts +25 -0
- package/lib/connection-DLPx5pxD.js +24 -0
- package/lib/conninfo-BbxlV2HK.d.ts +11 -0
- package/lib/conninfo-CNYXEtnA.js +19 -0
- package/lib/conninfo.d.ts +3 -0
- package/lib/conninfo.js +2 -0
- package/lib/constants-D914mQY7.js +7 -0
- package/lib/constants-nJj4XhwC.js +4 -0
- package/lib/constants-vv1oZD_p.js +9 -0
- package/lib/context-BVI2RzT7.js +365 -0
- package/lib/context-Ca3uX_bh.d.ts +1234 -0
- package/lib/context-Dre4P1UW.d.ts +250 -0
- package/lib/context-storage-ClUlVtCZ.js +52 -0
- package/lib/context-storage.d.ts +38 -0
- package/lib/context-storage.js +2 -0
- package/lib/cookie-BqeGZ43j.d.ts +40 -0
- package/lib/cookie-DktnJ0tJ.js +82 -0
- package/lib/cookie-uMH6wAF3.js +125 -0
- package/lib/cookie.d.ts +24 -0
- package/lib/cookie.js +2 -0
- package/lib/cordis/db-sqlite.d.ts +56 -0
- package/lib/cordis/db-sqlite.js +66 -0
- package/lib/cordis/db.d.ts +8 -0
- package/lib/cordis/db.js +1 -0
- package/lib/cordis/door.d.ts +404 -0
- package/lib/cordis/door.js +1812 -0
- package/lib/cordis/inspect.d.ts +77 -0
- package/lib/cordis/inspect.js +149 -0
- package/lib/cordis/kv-db.d.ts +16 -0
- package/lib/cordis/kv-db.js +18 -0
- package/lib/cordis/kv-json.d.ts +16 -0
- package/lib/cordis/kv-json.js +52 -0
- package/lib/cordis/kv.d.ts +8 -0
- package/lib/cordis/kv.js +1 -0
- package/lib/cordis/node-server.d.ts +155 -0
- package/lib/cordis/node-server.js +4 -0
- package/lib/cordis/router-http.d.ts +85 -0
- package/lib/cordis/router-http.js +206 -0
- package/lib/cordis/router.d.ts +7 -0
- package/lib/cordis/router.js +6 -0
- package/lib/cordis/state/react.d.ts +6 -0
- package/lib/cordis/state/react.js +11 -0
- package/lib/cordis/state.d.ts +34 -0
- package/lib/cordis/state.js +527 -0
- package/lib/core-4oDBzv4Q.js +19 -0
- package/lib/cors-C0qqZ-O-.js +106 -0
- package/lib/cors.d.ts +52 -0
- package/lib/cors.js +2 -0
- package/lib/crypto-ciSjk9n3.js +34 -0
- package/lib/csrf-rMr2nM2c.js +101 -0
- package/lib/csrf.d.ts +75 -0
- package/lib/csrf.js +2 -0
- package/lib/css-Bd6tj88A.js +320 -0
- package/lib/css-CLgKjBuO.js +134 -0
- package/lib/css.d.ts +82 -0
- package/lib/css.js +3 -0
- package/lib/database-CyKvumAn.d.ts +44 -0
- package/lib/db/conformance.d.ts +15 -0
- package/lib/db/conformance.js +279 -0
- package/lib/db/sqlite.d.ts +3 -0
- package/lib/db/sqlite.js +2 -0
- package/lib/db.d.ts +3 -0
- package/lib/db.js +2 -0
- package/lib/dev-h25puJmg.js +50 -0
- package/lib/dev.d.ts +19 -0
- package/lib/dev.js +2 -0
- package/lib/dom-MsnhZjjn.js +74 -0
- package/lib/door/host.d.ts +24 -0
- package/lib/door/host.js +2 -0
- package/lib/door/page.d.ts +160 -0
- package/lib/door/page.js +1257 -0
- package/lib/door/protocol.d.ts +2 -0
- package/lib/door/protocol.js +2 -0
- package/lib/drivers.d.ts +77 -0
- package/lib/drivers.js +16 -0
- package/lib/encode-BbgU91Gc.js +33 -0
- package/lib/etag-DevxEjyU.js +135 -0
- package/lib/etag.d.ts +40 -0
- package/lib/etag.js +2 -0
- package/lib/factory-d6WBwm2j.js +30 -0
- package/lib/factory.d.ts +35 -0
- package/lib/factory.js +2 -0
- package/lib/handler-DXCHa3NV.js +12 -0
- package/lib/headers-DbujLUIi.d.ts +11 -0
- package/lib/helpers-qmReU164.js +5 -0
- package/lib/hooks-Bs7lFRjW.js +762 -0
- package/lib/html-1jTa7KN1.js +103 -0
- package/lib/html-CNr9FLdV.d.ts +46 -0
- package/lib/html-CoWdxS1u.js +31 -0
- package/lib/html.d.ts +3 -0
- package/lib/html.js +3 -0
- package/lib/http-exception-BKMYq4x6.js +54 -0
- package/lib/http-exception-Cm8QD9Fl.d.ts +57 -0
- package/lib/http-exception.d.ts +2 -0
- package/lib/http-exception.js +2 -0
- package/lib/http-status-uBFmbzzM.d.ts +35 -0
- package/lib/index-B_g6ECnm.d.ts +57 -0
- package/lib/index-BaOiJMWK.d.ts +31 -0
- package/lib/index-C5RhEyXO.d.ts +45 -0
- package/lib/index-C8xOqNUW.d.ts +71 -0
- package/lib/index-D1HlwHSL.d.ts +129 -0
- package/lib/index-DUYLk7OD.d.ts +44 -0
- package/lib/index-DYBSr8yW.d.ts +156 -0
- package/lib/index-Dv4qFsro.d.ts +94 -0
- package/lib/index-jdWVs88B.d.ts +6 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +4 -0
- package/lib/ip-restriction-C4TZKPKl.js +166 -0
- package/lib/ip-restriction.d.ts +68 -0
- package/lib/ip-restriction.js +2 -0
- package/lib/ipaddr-CTeN6kNw.js +238 -0
- package/lib/jsx/dom/client.d.ts +30 -0
- package/lib/jsx/dom/client.js +49 -0
- package/lib/jsx/dom/css.d.ts +84 -0
- package/lib/jsx/dom/css.js +2 -0
- package/lib/jsx/dom/jsx-dev-runtime.d.ts +3 -0
- package/lib/jsx/dom/jsx-dev-runtime.js +2 -0
- package/lib/jsx/dom/jsx-runtime.d.ts +3 -0
- package/lib/jsx/dom/jsx-runtime.js +3 -0
- package/lib/jsx/dom/server.d.ts +105 -0
- package/lib/jsx/dom/server.js +37 -0
- package/lib/jsx/dom.d.ts +5 -0
- package/lib/jsx/dom.js +6 -0
- package/lib/jsx/jsx-dev-runtime.d.ts +3 -0
- package/lib/jsx/jsx-dev-runtime.js +3 -0
- package/lib/jsx/jsx-runtime.d.ts +10 -0
- package/lib/jsx/jsx-runtime.js +30 -0
- package/lib/jsx/streaming.d.ts +2 -0
- package/lib/jsx/streaming.js +2 -0
- package/lib/jsx-C5-YJG0l.js +47 -0
- package/lib/jsx-dev-runtime-CPsrmbgy.d.ts +7 -0
- package/lib/jsx-dev-runtime-Cs-uV30u.js +14 -0
- package/lib/jsx-dev-runtime-DK4z4RD3.js +354 -0
- package/lib/jsx-dev-runtime-DSQ8vSCY.d.ts +6 -0
- package/lib/jsx-renderer-B2wHa9Y8.js +99 -0
- package/lib/jsx-renderer.d.ts +75 -0
- package/lib/jsx-renderer.js +2 -0
- package/lib/jsx-runtime-BVVgDSdq.d.ts +1 -0
- package/lib/jsx-runtime-brX0UliB.js +2 -0
- package/lib/jsx.d.ts +3 -0
- package/lib/jsx.js +6 -0
- package/lib/jwk-BbiXIYhg.js +117 -0
- package/lib/jwk.d.ts +52 -0
- package/lib/jwk.js +2 -0
- package/lib/jwt-BCS5hH1O.d.ts +51 -0
- package/lib/jwt-Culfq-8m.js +403 -0
- package/lib/jwt-DaOoWaF3.js +115 -0
- package/lib/jwt.d.ts +72 -0
- package/lib/jwt.js +3 -0
- package/lib/kv/conformance.d.ts +17 -0
- package/lib/kv/conformance.js +313 -0
- package/lib/kv/db.d.ts +3 -0
- package/lib/kv/db.js +2 -0
- package/lib/kv/json.d.ts +3 -0
- package/lib/kv/json.js +2 -0
- package/lib/kv-Kv6J9zqu.d.ts +39 -0
- package/lib/kv.d.ts +3 -0
- package/lib/kv.js +2 -0
- package/lib/language-anRiLd9a.js +198 -0
- package/lib/language.d.ts +88 -0
- package/lib/language.js +2 -0
- package/lib/linear-router-BUrYQxcv.js +96 -0
- package/lib/logger-CLvaB463.js +54 -0
- package/lib/logger.d.ts +22 -0
- package/lib/logger.js +2 -0
- package/lib/loopback-only-0nTL30Zt.js +131 -0
- package/lib/loopback-only.d.ts +73 -0
- package/lib/loopback-only.js +2 -0
- package/lib/method-not-allowed-B3nMAp1f.js +82 -0
- package/lib/method-not-allowed.d.ts +47 -0
- package/lib/method-not-allowed.js +2 -0
- package/lib/method-override-Dhd_EJD9.js +103 -0
- package/lib/method-override.d.ts +46 -0
- package/lib/method-override.js +2 -0
- package/lib/middleware-B8gJUDgl.js +12 -0
- package/lib/mime-B9GbsqnN.d.ts +72 -0
- package/lib/mime-C-r9WxjH.js +77 -0
- package/lib/mount-RGiNYj2l.js +67 -0
- package/lib/mount.d.ts +44 -0
- package/lib/mount.js +2 -0
- package/lib/node-server/conninfo.d.ts +2 -0
- package/lib/node-server/conninfo.js +2 -0
- package/lib/node-server/register.d.ts +1 -0
- package/lib/node-server/register.js +59 -0
- package/lib/node-server/serve-static.d.ts +2 -0
- package/lib/node-server/serve-static.js +2 -0
- package/lib/node-server.d.ts +134 -0
- package/lib/node-server.js +5 -0
- package/lib/open-BC_BGIQt.d.ts +12 -0
- package/lib/open-BpnCtiKf.js +224 -0
- package/lib/open-CEE2hyrs.d.ts +11 -0
- package/lib/open-CwA_ZiPl.js +57 -0
- package/lib/open-DFt0lT26.js +197 -0
- package/lib/open-DXxlFxS0.d.ts +27 -0
- package/lib/pattern-router-DlkDNR9e.js +41 -0
- package/lib/powered-by-B9ufDvKH.js +24 -0
- package/lib/powered-by.d.ts +28 -0
- package/lib/powered-by.js +2 -0
- package/lib/pretty-json-B_5MzYgk.js +39 -0
- package/lib/pretty-json.d.ts +40 -0
- package/lib/pretty-json.js +2 -0
- package/lib/protocol-8HjYa5OX.js +217 -0
- package/lib/protocol-DdQgl224.d.ts +160 -0
- package/lib/proxy-C02n8qaX.js +121 -0
- package/lib/proxy.d.ts +72 -0
- package/lib/proxy.js +2 -0
- package/lib/quick.d.ts +8 -0
- package/lib/quick.js +17 -0
- package/lib/read-sse.d.ts +33 -0
- package/lib/read-sse.js +84 -0
- package/lib/reg-exp-router-DT_H6W_j.js +363 -0
- package/lib/request-PoZjfrb4.js +323 -0
- package/lib/request-id-CWyCgzyD.js +34 -0
- package/lib/request-id.d.ts +45 -0
- package/lib/request-id.js +2 -0
- package/lib/request.d.ts +2 -0
- package/lib/request.js +2 -0
- package/lib/route-D1WQ4cOh.js +126 -0
- package/lib/route.d.ts +78 -0
- package/lib/route.js +2 -0
- package/lib/router/linear-router.d.ts +11 -0
- package/lib/router/linear-router.js +2 -0
- package/lib/router/pattern-router.d.ts +11 -0
- package/lib/router/pattern-router.js +2 -0
- package/lib/router/reg-exp-router.d.ts +35 -0
- package/lib/router/reg-exp-router.js +2 -0
- package/lib/router/smart-router.d.ts +15 -0
- package/lib/router/smart-router.js +2 -0
- package/lib/router/trie-router.d.ts +11 -0
- package/lib/router/trie-router.js +2 -0
- package/lib/router-0TlTAMdt.d.ts +99 -0
- package/lib/router-wWGf3FlK.js +35 -0
- package/lib/router.d.ts +2 -0
- package/lib/router.js +2 -0
- package/lib/schema-validator-DGAFbTcN.js +22 -0
- package/lib/schema-validator.d.ts +54 -0
- package/lib/schema-validator.js +2 -0
- package/lib/secure-headers-eLrZcjSr.js +163 -0
- package/lib/secure-headers.d.ts +125 -0
- package/lib/secure-headers.js +2 -0
- package/lib/serve-static-D97E4ERX.d.ts +18 -0
- package/lib/serve-static-YoUetEZ8.js +212 -0
- package/lib/serve-static-cnLZvaYu.js +77 -0
- package/lib/serve-static.d.ts +2 -0
- package/lib/serve-static.js +2 -0
- package/lib/smart-router-BF56Yf23.js +49 -0
- package/lib/snapshot-text-Cyl69OKv.js +597 -0
- package/lib/src-6T1gCSq3.js +427 -0
- package/lib/src-BycZ1HUQ.js +407 -0
- package/lib/src-CZ1JoBaO.js +90 -0
- package/lib/src-C_00jcuj.js +85 -0
- package/lib/ssg-D_StqyTO.js +389 -0
- package/lib/ssg.d.ts +2 -0
- package/lib/ssg.js +2 -0
- package/lib/stream-CJ_0BMG2.js +88 -0
- package/lib/stream-Oxo9JHC6.d.ts +34 -0
- package/lib/streaming-CL2i3hX_.js +96 -0
- package/lib/streaming.d.ts +23 -0
- package/lib/streaming.js +2 -0
- package/lib/testing-DnLmBGle.js +17 -0
- package/lib/testing.d.ts +10 -0
- package/lib/testing.js +2 -0
- package/lib/timeout-Bib1sxFc.js +42 -0
- package/lib/timeout.d.ts +30 -0
- package/lib/timeout.js +2 -0
- package/lib/timing-CkkBmV23.js +183 -0
- package/lib/timing.d.ts +130 -0
- package/lib/timing.js +2 -0
- package/lib/tiny.d.ts +8 -0
- package/lib/tiny.js +15 -0
- package/lib/trailing-slash-qJLAJrAH.js +85 -0
- package/lib/trailing-slash.d.ts +91 -0
- package/lib/trailing-slash.js +2 -0
- package/lib/transpile-Bc6rZPK-.js +105 -0
- package/lib/trie-router-DhF3wn5_.js +146 -0
- package/lib/types-Zy1OzMX7.d.ts +29 -0
- package/lib/types-akvg9vbH.d.ts +40 -0
- package/lib/types-cu7acft5.d.ts +195 -0
- package/lib/types-nO2Jov17.d.ts +114 -0
- package/lib/types.d.ts +2 -0
- package/lib/types.js +4 -0
- package/lib/upgrade-hub-7og-sHcQ.d.ts +138 -0
- package/lib/upgrade-hub-B4hca91Y.js +1554 -0
- package/lib/url-Cyyh7Fiw.js +197 -0
- package/lib/utils/accept.d.ts +9 -0
- package/lib/utils/accept.js +2 -0
- package/lib/utils/basic-auth.d.ts +8 -0
- package/lib/utils/basic-auth.js +2 -0
- package/lib/utils/body.d.ts +2 -0
- package/lib/utils/body.js +2 -0
- package/lib/utils/buffer.d.ts +19 -0
- package/lib/utils/buffer.js +2 -0
- package/lib/utils/color.d.ts +24 -0
- package/lib/utils/color.js +2 -0
- package/lib/utils/compress.d.ts +2 -0
- package/lib/utils/compress.js +2 -0
- package/lib/utils/concurrent.d.ts +17 -0
- package/lib/utils/concurrent.js +2 -0
- package/lib/utils/constants.d.ts +7 -0
- package/lib/utils/constants.js +2 -0
- package/lib/utils/cookie.d.ts +2 -0
- package/lib/utils/cookie.js +2 -0
- package/lib/utils/crypto.d.ts +14 -0
- package/lib/utils/crypto.js +2 -0
- package/lib/utils/encode.d.ts +11 -0
- package/lib/utils/encode.js +2 -0
- package/lib/utils/filepath.d.ts +14 -0
- package/lib/utils/filepath.js +25 -0
- package/lib/utils/handler.d.ts +9 -0
- package/lib/utils/handler.js +2 -0
- package/lib/utils/headers.d.ts +2 -0
- package/lib/utils/headers.js +1 -0
- package/lib/utils/html.d.ts +2 -0
- package/lib/utils/html.js +2 -0
- package/lib/utils/http-status.d.ts +2 -0
- package/lib/utils/http-status.js +1 -0
- package/lib/utils/ipaddr.d.ts +56 -0
- package/lib/utils/ipaddr.js +2 -0
- package/lib/utils/jwt.d.ts +24 -0
- package/lib/utils/jwt.js +2 -0
- package/lib/utils/mime.d.ts +2 -0
- package/lib/utils/mime.js +2 -0
- package/lib/utils/stream.d.ts +2 -0
- package/lib/utils/stream.js +2 -0
- package/lib/utils/types.d.ts +2 -0
- package/lib/utils/types.js +1 -0
- package/lib/utils/url.d.ts +46 -0
- package/lib/utils/url.js +2 -0
- package/lib/utils-CYdUlhw1.js +125 -0
- package/lib/utils-CnUrxRO-.js +4 -0
- package/lib/validator-DkpCsiJC.js +65 -0
- package/lib/validator.d.ts +42 -0
- package/lib/validator.js +2 -0
- package/lib/vitest-binding-CctNu3jT.d.ts +15 -0
- package/lib/vitest-binding-CrH7rKg2.js +17 -0
- package/lib/websocket-Cy4jtqHv.js +56 -0
- package/lib/ws.d.ts +2 -0
- package/lib/ws.js +2 -0
- package/package.json +463 -3
- package/shared/AGENTS.core.md +84 -0
- package/shared/DEFAULTS.md +49 -0
- package/shared/library-history-versions.json +48 -0
- package/shared/library-history.json +786 -0
- package/shared/skills/acryl-add-ui/SKILL.md +19 -0
- package/shared/skills/acryl-app/SKILL.md +13 -0
- package/shared/skills/acryl-build-plugin/SKILL.md +22 -0
- package/shared/skills/acryl-change-plugin/SKILL.md +14 -0
- package/shared/skills/acryl-diagnose-plugin/SKILL.md +13 -0
- package/shared/skills/acryl-fix-plugin/SKILL.md +13 -0
- package/shared/skills/acryl-remove-plugin/SKILL.md +12 -0
- package/shared/skills/acryl-share-plugin/SKILL.md +16 -0
- package/shared/skills/cordis-plugin/SKILL.md +26 -0
- package/templates/agent/.gitattributes +2 -0
- package/templates/agent/AGENTS.md +20 -0
- package/templates/agent/Dockerfile +15 -0
- package/templates/agent/README.md +52 -0
- package/templates/agent/blend.yaml +71 -0
- package/templates/agent/dockerignore +3 -0
- package/templates/agent/gitignore +6 -0
- package/templates/agent/package.json +31 -0
- package/templates/agent/src/app.ts +293 -0
- package/templates/agent/src/frame.ts +17 -0
- package/templates/agent/src/main.ts +27 -0
- package/templates/agent/src/routes.ts +163 -0
- package/templates/agent/template.json +22 -0
- package/templates/agent/test/agent.test.ts +51 -0
- package/templates/agent/test/app.test.ts +270 -0
- package/templates/agent/test/builder.test.ts +210 -0
- package/templates/agent/test/model.test.ts +94 -0
- package/templates/agent/tsconfig.json +68 -0
- package/templates/blank/.gitattributes +2 -0
- package/templates/blank/AGENTS.md +6 -0
- package/templates/blank/README.md +26 -0
- package/templates/blank/blend.yaml +37 -0
- package/templates/blank/gitignore +6 -0
- package/templates/blank/package.json +31 -0
- package/templates/blank/src/about.tsx +14 -0
- package/templates/blank/src/app.ts +160 -0
- package/templates/blank/src/door.ts +7 -0
- package/templates/blank/src/first-page.ts +5 -0
- package/templates/blank/src/frame.ts +17 -0
- package/templates/blank/src/main.ts +20 -0
- package/templates/blank/src/routes.ts +79 -0
- package/templates/blank/template.json +15 -0
- package/templates/blank/test/app.test.ts +177 -0
- package/templates/blank/tsconfig.json +19 -0
- package/templates/chat/.gitattributes +2 -0
- package/templates/chat/AGENTS.md +16 -0
- package/templates/chat/blend.yaml +36 -0
- package/templates/chat/gitignore +9 -0
- package/templates/chat/migrations/001-chat.sql +12 -0
- package/templates/chat/package.json +35 -0
- package/templates/chat/src/access.ts +110 -0
- package/templates/chat/src/app.ts +165 -0
- package/templates/chat/src/chat-app.ts +120 -0
- package/templates/chat/src/client/chat.tsx +117 -0
- package/templates/chat/src/client/tsconfig.json +26 -0
- package/templates/chat/src/db.ts +43 -0
- package/templates/chat/src/door.ts +7 -0
- package/templates/chat/src/frame.ts +17 -0
- package/templates/chat/src/llm.ts +48 -0
- package/templates/chat/src/main.ts +23 -0
- package/templates/chat/src/page.tsx +42 -0
- package/templates/chat/src/routes.ts +29 -0
- package/templates/chat/src/runtime.ts +23 -0
- package/templates/chat/template.json +15 -0
- package/templates/chat/test/chat.test.ts +322 -0
- package/templates/chat/test/server.test.ts +92 -0
- package/templates/chat/tsconfig.json +20 -0
- package/templates/nodejs/.gitattributes +2 -0
- package/templates/nodejs/AGENTS.md +9 -0
- package/templates/nodejs/blend.yaml +33 -0
- package/templates/nodejs/gitignore +6 -0
- package/templates/nodejs/package.json +32 -0
- package/templates/nodejs/src/app.ts +158 -0
- package/templates/nodejs/src/client/counter.tsx +12 -0
- package/templates/nodejs/src/client/tsconfig.json +26 -0
- package/templates/nodejs/src/door.ts +7 -0
- package/templates/nodejs/src/frame.ts +17 -0
- package/templates/nodejs/src/main.ts +20 -0
- package/templates/nodejs/src/page.tsx +29 -0
- package/templates/nodejs/src/routes.ts +59 -0
- package/templates/nodejs/template.json +14 -0
- package/templates/nodejs/test/app.test.ts +112 -0
- package/templates/nodejs/test/server.test.ts +97 -0
- package/templates/nodejs/tsconfig.json +20 -0
- package/templates/notes/.gitattributes +2 -0
- package/templates/notes/AGENTS.md +26 -0
- package/templates/notes/blend.yaml +36 -0
- package/templates/notes/gitignore +9 -0
- package/templates/notes/migrations/001-notes.sql +18 -0
- package/templates/notes/package.json +35 -0
- package/templates/notes/src/app.ts +165 -0
- package/templates/notes/src/auth.ts +57 -0
- package/templates/notes/src/client/counter.tsx +21 -0
- package/templates/notes/src/client/tsconfig.json +26 -0
- package/templates/notes/src/db.ts +50 -0
- package/templates/notes/src/door.ts +7 -0
- package/templates/notes/src/frame.ts +17 -0
- package/templates/notes/src/main.ts +23 -0
- package/templates/notes/src/notes-app.ts +212 -0
- package/templates/notes/src/routes.ts +21 -0
- package/templates/notes/src/runtime.ts +23 -0
- package/templates/notes/src/schema.ts +38 -0
- package/templates/notes/src/views.tsx +145 -0
- package/templates/notes/template.json +15 -0
- package/templates/notes/test/notes.test.ts +318 -0
- package/templates/notes/test/server.test.ts +92 -0
- package/templates/notes/tsconfig.json +20 -0
- package/templates/todo/.gitattributes +2 -0
- package/templates/todo/AGENTS.md +5 -0
- package/templates/todo/README.md +27 -0
- package/templates/todo/blend.yaml +28 -0
- package/templates/todo/gitignore +6 -0
- package/templates/todo/package.json +31 -0
- package/templates/todo/src/app.ts +145 -0
- package/templates/todo/src/door.ts +7 -0
- package/templates/todo/src/frame.ts +17 -0
- package/templates/todo/src/main.ts +21 -0
- package/templates/todo/src/page.ts +35 -0
- package/templates/todo/src/todo.ts +137 -0
- package/templates/todo/template.json +14 -0
- package/templates/todo/test/todo.test.ts +228 -0
- package/templates/todo/tsconfig.json +19 -0
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import "./router-wWGf3FlK.js";
|
|
2
|
+
import { t as html } from "./html-CoWdxS1u.js";
|
|
3
|
+
import { n as getExtension } from "./mime-C-r9WxjH.js";
|
|
4
|
+
import { n as isMiddleware, t as findTargetHandler } from "./handler-DXCHa3NV.js";
|
|
5
|
+
import { o as replaceUrlParam } from "./utils-CYdUlhw1.js";
|
|
6
|
+
import { t as createPool } from "./concurrent-B7z-2cwF.js";
|
|
7
|
+
//#region ../../../plugins/router/src/core/helper/ssg/utils.ts
|
|
8
|
+
/**
|
|
9
|
+
* Get dirname
|
|
10
|
+
* @param path File Path
|
|
11
|
+
* @returns Parent dir path
|
|
12
|
+
*/
|
|
13
|
+
const dirname = (path) => {
|
|
14
|
+
return path.split(/[\/\\]/).slice(0, -1).join("/");
|
|
15
|
+
};
|
|
16
|
+
const normalizePath = (path) => {
|
|
17
|
+
return path.replace(/(\\)/g, "/").replace(/\/$/g, "");
|
|
18
|
+
};
|
|
19
|
+
const getUncRoot = (path) => {
|
|
20
|
+
const uncRoot = path.replace(/\\/g, "/").match(/^\/\/([^/]+)\/([^/]+)/);
|
|
21
|
+
if (uncRoot) return `${uncRoot[1].toLowerCase()}/${uncRoot[2].toLowerCase()}`;
|
|
22
|
+
};
|
|
23
|
+
const handleParent = (resultPaths) => {
|
|
24
|
+
if (resultPaths.length === 0 || resultPaths[resultPaths.length - 1] === "..") resultPaths.push("..");
|
|
25
|
+
else resultPaths.pop();
|
|
26
|
+
};
|
|
27
|
+
const handleNonDot = (path, resultPaths) => {
|
|
28
|
+
path = path.replace(/^\.(?!.)/, "");
|
|
29
|
+
if (path !== "") resultPaths.push(path);
|
|
30
|
+
};
|
|
31
|
+
const handleSegments = (paths, resultPaths) => {
|
|
32
|
+
for (const path of paths) if (path === "..") handleParent(resultPaths);
|
|
33
|
+
else handleNonDot(path, resultPaths);
|
|
34
|
+
};
|
|
35
|
+
const joinPaths = (...paths) => {
|
|
36
|
+
const hasUncPrefix = getUncRoot(paths[0]) !== void 0;
|
|
37
|
+
paths = paths.map(normalizePath);
|
|
38
|
+
const resultPaths = [];
|
|
39
|
+
handleSegments(paths.join("/").split("/"), resultPaths);
|
|
40
|
+
return (hasUncPrefix ? "//" : paths[0][0] === "/" ? "/" : "") + resultPaths.join("/");
|
|
41
|
+
};
|
|
42
|
+
const filterStaticGenerateRoutes = (acryl) => {
|
|
43
|
+
return acryl.routes.reduce((acc, { method, handler, path }) => {
|
|
44
|
+
const targetHandler = findTargetHandler(handler);
|
|
45
|
+
if (["GET", "ALL"].includes(method) && !isMiddleware(targetHandler)) acc.push({ path });
|
|
46
|
+
return acc;
|
|
47
|
+
}, []);
|
|
48
|
+
};
|
|
49
|
+
const isDynamicRoute = (path) => {
|
|
50
|
+
return path.split("/").some((segment) => segment.startsWith(":") || segment.includes("*"));
|
|
51
|
+
};
|
|
52
|
+
const toSegments = (path) => path === "" ? [] : path.split("/");
|
|
53
|
+
const getPathRoot = (path) => {
|
|
54
|
+
const normalizedPath = path.replace(/\\/g, "/");
|
|
55
|
+
const uncRoot = getUncRoot(normalizedPath);
|
|
56
|
+
if (uncRoot) return `unc:${uncRoot}`;
|
|
57
|
+
const driveRoot = normalizedPath.match(/^([A-Za-z]):/);
|
|
58
|
+
if (driveRoot) return `${normalizedPath[2] === "/" ? "drive-absolute" : "drive-relative"}:${driveRoot[1].toLowerCase()}`;
|
|
59
|
+
return normalizedPath.startsWith("/") ? "absolute" : "relative";
|
|
60
|
+
};
|
|
61
|
+
const ensureWithinOutDir = (outDir, filePath) => {
|
|
62
|
+
const outDirSegments = toSegments(joinPaths(outDir));
|
|
63
|
+
const filePathSegments = toSegments(joinPaths(filePath));
|
|
64
|
+
const hasMismatchedPathRoot = getPathRoot(outDir) !== getPathRoot(filePath);
|
|
65
|
+
const climbsAboveOutDir = filePathSegments[outDirSegments.length] === "..";
|
|
66
|
+
if (hasMismatchedPathRoot || filePathSegments.length <= outDirSegments.length || !outDirSegments.every((segment, i) => segment === filePathSegments[i]) || climbsAboveOutDir) throw new Error(`Path traversal detected: "${filePath}" is outside the output directory`);
|
|
67
|
+
};
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region ../../../plugins/router/src/core/helper/ssg/middleware.ts
|
|
70
|
+
const SSG_CONTEXT = "ACRYL_SSG_CONTEXT";
|
|
71
|
+
const X_ACRYL_DISABLE_SSG_HEADER_KEY = "x-acryl-disable-ssg";
|
|
72
|
+
(() => {
|
|
73
|
+
try {
|
|
74
|
+
return new Response("SSG is disabled", {
|
|
75
|
+
status: 404,
|
|
76
|
+
headers: { [X_ACRYL_DISABLE_SSG_HEADER_KEY]: "true" }
|
|
77
|
+
});
|
|
78
|
+
} catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
})();
|
|
82
|
+
/**
|
|
83
|
+
* Define SSG Route
|
|
84
|
+
*/
|
|
85
|
+
const ssgParams = (params) => async (c, next) => {
|
|
86
|
+
if (isDynamicRoute(c.req.path)) {
|
|
87
|
+
c.req.raw.ssgParams = Array.isArray(params) ? params : await params(c);
|
|
88
|
+
return c.notFound();
|
|
89
|
+
}
|
|
90
|
+
await next();
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* @experimental
|
|
94
|
+
* `isSSGContext` is an experimental feature.
|
|
95
|
+
* The API might be changed.
|
|
96
|
+
*/
|
|
97
|
+
const isSSGContext = (c) => !!c.env?.[SSG_CONTEXT];
|
|
98
|
+
/**
|
|
99
|
+
* @experimental
|
|
100
|
+
* `disableSSG` is an experimental feature.
|
|
101
|
+
* The API might be changed.
|
|
102
|
+
*/
|
|
103
|
+
const disableSSG = () => async function disableSSG(c, next) {
|
|
104
|
+
if (isSSGContext(c)) {
|
|
105
|
+
c.header(X_ACRYL_DISABLE_SSG_HEADER_KEY, "true");
|
|
106
|
+
return c.notFound();
|
|
107
|
+
}
|
|
108
|
+
await next();
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* @experimental
|
|
112
|
+
* `onlySSG` is an experimental feature.
|
|
113
|
+
* The API might be changed.
|
|
114
|
+
*/
|
|
115
|
+
const onlySSG = () => async function onlySSG(c, next) {
|
|
116
|
+
if (!isSSGContext(c)) return c.notFound();
|
|
117
|
+
await next();
|
|
118
|
+
};
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region ../../../plugins/router/src/core/helper/ssg/plugins.ts
|
|
121
|
+
/**
|
|
122
|
+
* The default plugin that defines the recommended behavior.
|
|
123
|
+
*
|
|
124
|
+
* @experimental
|
|
125
|
+
* `defaultPlugin` is an experimental feature.
|
|
126
|
+
* The API might be changed.
|
|
127
|
+
*/
|
|
128
|
+
const defaultPlugin = () => {
|
|
129
|
+
return { afterResponseHook: (res) => {
|
|
130
|
+
if (res.status !== 200) return false;
|
|
131
|
+
return res;
|
|
132
|
+
} };
|
|
133
|
+
};
|
|
134
|
+
const REDIRECT_STATUS_CODES = /* @__PURE__ */ new Set([
|
|
135
|
+
301,
|
|
136
|
+
302,
|
|
137
|
+
303,
|
|
138
|
+
307,
|
|
139
|
+
308
|
|
140
|
+
]);
|
|
141
|
+
const generateRedirectHtml = (location) => {
|
|
142
|
+
return html`<!DOCTYPE html>
|
|
143
|
+
<title>Redirecting to: ${location}</title>
|
|
144
|
+
<meta http-equiv="refresh" content="0;url=${location}" />
|
|
145
|
+
<meta name="robots" content="noindex" />
|
|
146
|
+
<link rel="canonical" href="${location}" />
|
|
147
|
+
<body>
|
|
148
|
+
<a href="${location}">Redirecting to <code>${location}</code></a>
|
|
149
|
+
</body>
|
|
150
|
+
`.toString().replace(/\n/g, "");
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* The redirect plugin that generates HTML redirect pages for HTTP redirect responses for status codes 301, 302, 303, 307 and 308.
|
|
154
|
+
*
|
|
155
|
+
* When used with `defaultPlugin`, place `redirectPlugin` before it, because `defaultPlugin` skips non-200 responses.
|
|
156
|
+
*
|
|
157
|
+
* ```ts
|
|
158
|
+
* // ✅ Will work as expected
|
|
159
|
+
* toSSG(app, fs, { plugins: [redirectPlugin(), defaultPlugin()] })
|
|
160
|
+
*
|
|
161
|
+
* // ❌ Will not work as expected
|
|
162
|
+
* toSSG(app, fs, { plugins: [defaultPlugin(), redirectPlugin()] })
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
* @experimental
|
|
166
|
+
* `redirectPlugin` is an experimental feature.
|
|
167
|
+
* The API might be changed.
|
|
168
|
+
*/
|
|
169
|
+
const redirectPlugin = () => {
|
|
170
|
+
return { afterResponseHook: (res) => {
|
|
171
|
+
if (REDIRECT_STATUS_CODES.has(res.status)) {
|
|
172
|
+
const location = res.headers.get("Location");
|
|
173
|
+
if (!location) return false;
|
|
174
|
+
const htmlBody = generateRedirectHtml(location);
|
|
175
|
+
return new Response(htmlBody, {
|
|
176
|
+
status: 200,
|
|
177
|
+
headers: { "Content-Type": "text/html; charset=utf-8" }
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
return res;
|
|
181
|
+
} };
|
|
182
|
+
};
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region ../../../plugins/router/src/core/helper/ssg/ssg.ts
|
|
185
|
+
const DEFAULT_CONCURRENCY = 2;
|
|
186
|
+
const DEFAULT_CONTENT_TYPE = "text/plain";
|
|
187
|
+
const DEFAULT_OUTPUT_DIR = "./static";
|
|
188
|
+
const generateFilePath = (routePath, outDir, mimeType, extensionMap) => {
|
|
189
|
+
const extension = determineExtension(mimeType, extensionMap);
|
|
190
|
+
let filePath;
|
|
191
|
+
if (routePath.endsWith(`.${extension}`)) filePath = joinPaths(outDir, routePath);
|
|
192
|
+
else if (routePath === "/") filePath = joinPaths(outDir, `index.${extension}`);
|
|
193
|
+
else if (routePath.endsWith("/")) filePath = joinPaths(outDir, routePath, `index.${extension}`);
|
|
194
|
+
else filePath = joinPaths(outDir, `${routePath}.${extension}`);
|
|
195
|
+
ensureWithinOutDir(outDir, filePath);
|
|
196
|
+
return filePath;
|
|
197
|
+
};
|
|
198
|
+
const parseResponseContent = async (response) => {
|
|
199
|
+
const contentType = response.headers.get("Content-Type");
|
|
200
|
+
try {
|
|
201
|
+
if (contentType?.includes("text") || contentType?.includes("json")) return await response.text();
|
|
202
|
+
else return await response.arrayBuffer();
|
|
203
|
+
} catch (error) {
|
|
204
|
+
throw new Error(`Error processing response: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
const defaultExtensionMap = {
|
|
208
|
+
"text/html": "html",
|
|
209
|
+
"text/xml": "xml",
|
|
210
|
+
"application/xml": "xml",
|
|
211
|
+
"application/atom+xml": "xml",
|
|
212
|
+
"application/rss+xml": "xml",
|
|
213
|
+
"application/yaml": "yaml"
|
|
214
|
+
};
|
|
215
|
+
const determineExtension = (mimeType, userExtensionMap) => {
|
|
216
|
+
const extensionMap = userExtensionMap || defaultExtensionMap;
|
|
217
|
+
if (mimeType in extensionMap) return extensionMap[mimeType];
|
|
218
|
+
return getExtension(mimeType) || "html";
|
|
219
|
+
};
|
|
220
|
+
const combineBeforeRequestHooks = (hooks) => {
|
|
221
|
+
if (!Array.isArray(hooks)) return hooks;
|
|
222
|
+
return async (req) => {
|
|
223
|
+
let currentReq = req;
|
|
224
|
+
for (const hook of hooks) {
|
|
225
|
+
const result = await hook(currentReq);
|
|
226
|
+
if (result === false) return false;
|
|
227
|
+
if (result instanceof Request) currentReq = result;
|
|
228
|
+
}
|
|
229
|
+
return currentReq;
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
const combineAfterResponseHooks = (hooks) => {
|
|
233
|
+
if (!Array.isArray(hooks)) return hooks;
|
|
234
|
+
return async (res) => {
|
|
235
|
+
let currentRes = res;
|
|
236
|
+
for (const hook of hooks) {
|
|
237
|
+
const result = await hook(currentRes);
|
|
238
|
+
if (result === false) return false;
|
|
239
|
+
if (result instanceof Response) currentRes = result;
|
|
240
|
+
}
|
|
241
|
+
return currentRes;
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
const combineAfterGenerateHooks = (hooks, fsModule, options) => {
|
|
245
|
+
if (!Array.isArray(hooks)) return hooks;
|
|
246
|
+
return async (result) => {
|
|
247
|
+
for (const hook of hooks) await hook(result, fsModule, options);
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* @experimental
|
|
252
|
+
* `fetchRoutesContent` is an experimental feature.
|
|
253
|
+
* The API might be changed.
|
|
254
|
+
*/
|
|
255
|
+
const fetchRoutesContent = function* (app, beforeRequestHook, afterResponseHook, concurrency) {
|
|
256
|
+
const baseURL = "http://localhost";
|
|
257
|
+
const pool = createPool({ concurrency });
|
|
258
|
+
for (const route of filterStaticGenerateRoutes(app)) {
|
|
259
|
+
const thisRouteBaseURL = new URL(route.path, baseURL).toString();
|
|
260
|
+
let forGetInfoURLRequest = new Request(thisRouteBaseURL);
|
|
261
|
+
yield new Promise(async (resolveGetInfo, rejectGetInfo) => {
|
|
262
|
+
try {
|
|
263
|
+
if (beforeRequestHook) {
|
|
264
|
+
const maybeRequest = await beforeRequestHook(forGetInfoURLRequest);
|
|
265
|
+
if (!maybeRequest) {
|
|
266
|
+
resolveGetInfo(void 0);
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
forGetInfoURLRequest = maybeRequest;
|
|
270
|
+
}
|
|
271
|
+
await pool.run(() => app.fetch(forGetInfoURLRequest, { [SSG_CONTEXT]: true }));
|
|
272
|
+
if (!forGetInfoURLRequest.ssgParams) {
|
|
273
|
+
if (isDynamicRoute(route.path)) {
|
|
274
|
+
resolveGetInfo(void 0);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
forGetInfoURLRequest.ssgParams = [{}];
|
|
278
|
+
}
|
|
279
|
+
const requestInit = {
|
|
280
|
+
method: forGetInfoURLRequest.method,
|
|
281
|
+
headers: forGetInfoURLRequest.headers
|
|
282
|
+
};
|
|
283
|
+
resolveGetInfo((function* () {
|
|
284
|
+
for (const param of forGetInfoURLRequest.ssgParams) yield new Promise(async (resolveReq, rejectReq) => {
|
|
285
|
+
try {
|
|
286
|
+
const replacedUrlParam = replaceUrlParam(route.path, param);
|
|
287
|
+
let response = await pool.run(() => app.request(replacedUrlParam, requestInit, { [SSG_CONTEXT]: true }));
|
|
288
|
+
if (response.headers.get("x-acryl-disable-ssg")) {
|
|
289
|
+
resolveReq(void 0);
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
if (afterResponseHook) {
|
|
293
|
+
const maybeResponse = await afterResponseHook(response);
|
|
294
|
+
if (!maybeResponse) {
|
|
295
|
+
resolveReq(void 0);
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
response = maybeResponse;
|
|
299
|
+
}
|
|
300
|
+
resolveReq({
|
|
301
|
+
routePath: replacedUrlParam,
|
|
302
|
+
mimeType: response.headers.get("Content-Type")?.split(";")[0] || DEFAULT_CONTENT_TYPE,
|
|
303
|
+
content: await parseResponseContent(response)
|
|
304
|
+
});
|
|
305
|
+
} catch (error) {
|
|
306
|
+
rejectReq(error);
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
})());
|
|
310
|
+
} catch (error) {
|
|
311
|
+
rejectGetInfo(error);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
/**
|
|
317
|
+
* @experimental
|
|
318
|
+
* `saveContentToFile` is an experimental feature.
|
|
319
|
+
* The API might be changed.
|
|
320
|
+
*/
|
|
321
|
+
const createdDirs = /* @__PURE__ */ new Set();
|
|
322
|
+
const saveContentToFile = async (data, fsModule, outDir, extensionMap) => {
|
|
323
|
+
const awaitedData = await data;
|
|
324
|
+
if (!awaitedData) return;
|
|
325
|
+
const { routePath, content, mimeType } = awaitedData;
|
|
326
|
+
const filePath = generateFilePath(routePath, outDir, mimeType, extensionMap);
|
|
327
|
+
const dirPath = dirname(filePath);
|
|
328
|
+
if (dirPath !== "" && !createdDirs.has(dirPath)) {
|
|
329
|
+
await fsModule.mkdir(dirPath, { recursive: true });
|
|
330
|
+
createdDirs.add(dirPath);
|
|
331
|
+
}
|
|
332
|
+
if (typeof content === "string") await fsModule.writeFile(filePath, content);
|
|
333
|
+
else if (content instanceof ArrayBuffer) await fsModule.writeFile(filePath, new Uint8Array(content));
|
|
334
|
+
return filePath;
|
|
335
|
+
};
|
|
336
|
+
/**
|
|
337
|
+
* @experimental
|
|
338
|
+
* `toSSG` is an experimental feature.
|
|
339
|
+
* The API might be changed.
|
|
340
|
+
*/
|
|
341
|
+
const toSSG = async (app, fs, options) => {
|
|
342
|
+
let result;
|
|
343
|
+
const getInfoPromises = [];
|
|
344
|
+
const savePromises = [];
|
|
345
|
+
const plugins = options?.plugins || [defaultPlugin()];
|
|
346
|
+
const beforeRequestHooks = [];
|
|
347
|
+
const afterResponseHooks = [];
|
|
348
|
+
const afterGenerateHooks = [];
|
|
349
|
+
if (options?.beforeRequestHook) beforeRequestHooks.push(...Array.isArray(options.beforeRequestHook) ? options.beforeRequestHook : [options.beforeRequestHook]);
|
|
350
|
+
if (options?.afterResponseHook) afterResponseHooks.push(...Array.isArray(options.afterResponseHook) ? options.afterResponseHook : [options.afterResponseHook]);
|
|
351
|
+
if (options?.afterGenerateHook) afterGenerateHooks.push(...Array.isArray(options.afterGenerateHook) ? options.afterGenerateHook : [options.afterGenerateHook]);
|
|
352
|
+
for (const plugin of plugins) {
|
|
353
|
+
if (plugin.beforeRequestHook) beforeRequestHooks.push(...Array.isArray(plugin.beforeRequestHook) ? plugin.beforeRequestHook : [plugin.beforeRequestHook]);
|
|
354
|
+
if (plugin.afterResponseHook) afterResponseHooks.push(...Array.isArray(plugin.afterResponseHook) ? plugin.afterResponseHook : [plugin.afterResponseHook]);
|
|
355
|
+
if (plugin.afterGenerateHook) afterGenerateHooks.push(...Array.isArray(plugin.afterGenerateHook) ? plugin.afterGenerateHook : [plugin.afterGenerateHook]);
|
|
356
|
+
}
|
|
357
|
+
try {
|
|
358
|
+
const outputDir = options?.dir ?? "./static";
|
|
359
|
+
const concurrency = options?.concurrency ?? DEFAULT_CONCURRENCY;
|
|
360
|
+
const combinedBeforeRequestHook = combineBeforeRequestHooks(beforeRequestHooks.length > 0 ? beforeRequestHooks : [(req) => req]);
|
|
361
|
+
const combinedAfterResponseHook = combineAfterResponseHooks(afterResponseHooks.length > 0 ? afterResponseHooks : [(req) => req]);
|
|
362
|
+
const getInfoGen = fetchRoutesContent(app, combinedBeforeRequestHook, combinedAfterResponseHook, concurrency);
|
|
363
|
+
for (const getInfo of getInfoGen) getInfoPromises.push(getInfo.then((getContentGen) => {
|
|
364
|
+
if (!getContentGen) return;
|
|
365
|
+
for (const content of getContentGen) savePromises.push(saveContentToFile(content, fs, outputDir, options?.extensionMap).catch((e) => e));
|
|
366
|
+
}));
|
|
367
|
+
await Promise.all(getInfoPromises);
|
|
368
|
+
const files = [];
|
|
369
|
+
for (const savePromise of savePromises) {
|
|
370
|
+
const fileOrError = await savePromise;
|
|
371
|
+
if (typeof fileOrError === "string") files.push(fileOrError);
|
|
372
|
+
else if (fileOrError) throw fileOrError;
|
|
373
|
+
}
|
|
374
|
+
result = {
|
|
375
|
+
success: true,
|
|
376
|
+
files
|
|
377
|
+
};
|
|
378
|
+
} catch (error) {
|
|
379
|
+
result = {
|
|
380
|
+
success: false,
|
|
381
|
+
files: [],
|
|
382
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
if (afterGenerateHooks.length > 0) await combineAfterGenerateHooks(afterGenerateHooks, fs, options)(result, fs, options);
|
|
386
|
+
return result;
|
|
387
|
+
};
|
|
388
|
+
//#endregion
|
|
389
|
+
export { defaultExtensionMap as a, toSSG as c, X_ACRYL_DISABLE_SSG_HEADER_KEY as d, disableSSG as f, ssgParams as h, combineBeforeRequestHooks as i, defaultPlugin as l, onlySSG as m, combineAfterGenerateHooks as n, fetchRoutesContent as o, isSSGContext as p, combineAfterResponseHooks as r, saveContentToFile as s, DEFAULT_OUTPUT_DIR as t, redirectPlugin as u };
|
package/lib/ssg.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { C as saveContentToFile, S as fetchRoutesContent, _ as ToSSGResult, a as isSSGContext, b as combineBeforeRequestHooks, c as AfterGenerateHook, d as DEFAULT_OUTPUT_DIR, f as FileSystemModule, g as ToSSGOptions, h as ToSSGInterface, i as disableSSG, l as AfterResponseHook, m as ToSSGAdaptorInterface, n as redirectPlugin, o as onlySSG, p as SSGPlugin, r as X_ACRYL_DISABLE_SSG_HEADER_KEY, s as ssgParams, t as defaultPlugin, u as BeforeRequestHook, v as combineAfterGenerateHooks, w as toSSG, x as defaultExtensionMap, y as combineAfterResponseHooks } from "./index-DYBSr8yW.js";
|
|
2
|
+
export { AfterGenerateHook, AfterResponseHook, BeforeRequestHook, DEFAULT_OUTPUT_DIR, FileSystemModule, SSGPlugin, ToSSGAdaptorInterface, ToSSGInterface, ToSSGOptions, ToSSGResult, X_ACRYL_DISABLE_SSG_HEADER_KEY, combineAfterGenerateHooks, combineAfterResponseHooks, combineBeforeRequestHooks, defaultExtensionMap, defaultPlugin, disableSSG, fetchRoutesContent, isSSGContext, onlySSG, redirectPlugin, saveContentToFile, ssgParams, toSSG };
|
package/lib/ssg.js
ADDED
|
@@ -0,0 +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-D_StqyTO.js";
|
|
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/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 };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region ../../../plugins/router/src/core/utils/stream.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* @module
|
|
4
|
+
* Stream utility.
|
|
5
|
+
*/
|
|
6
|
+
declare class StreamingApi {
|
|
7
|
+
private writer;
|
|
8
|
+
private encoder;
|
|
9
|
+
private writable;
|
|
10
|
+
private abortSubscribers;
|
|
11
|
+
responseReadable: ReadableStream;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the stream has been aborted.
|
|
14
|
+
*/
|
|
15
|
+
aborted: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the stream has been closed normally.
|
|
18
|
+
*/
|
|
19
|
+
closed: boolean;
|
|
20
|
+
constructor(writable: WritableStream, _readable: ReadableStream);
|
|
21
|
+
write(input: Uint8Array | string): Promise<StreamingApi>;
|
|
22
|
+
writeln(input: string): Promise<StreamingApi>;
|
|
23
|
+
sleep(ms: number): Promise<unknown>;
|
|
24
|
+
close(): Promise<void>;
|
|
25
|
+
pipe(body: ReadableStream): Promise<void>;
|
|
26
|
+
onAbort(listener: () => void | Promise<void>): void;
|
|
27
|
+
/**
|
|
28
|
+
* Abort the stream.
|
|
29
|
+
* You can call this method when stream is aborted by external event.
|
|
30
|
+
*/
|
|
31
|
+
abort(): void;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { StreamingApi as t };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { i as resolveCallback, t as HtmlEscapedCallbackPhase } from "./html-1jTa7KN1.js";
|
|
2
|
+
import { n as TEXT_PLAIN } from "./context-BVI2RzT7.js";
|
|
3
|
+
import { t as StreamingApi } from "./stream-CJ_0BMG2.js";
|
|
4
|
+
//#region ../../../plugins/router/src/core/helper/streaming/utils.ts
|
|
5
|
+
let isOldBunVersion = () => {
|
|
6
|
+
const version = typeof Bun !== "undefined" ? Bun.version : void 0;
|
|
7
|
+
if (version === void 0) return false;
|
|
8
|
+
const result = version.startsWith("1.1") || version.startsWith("1.0") || version.startsWith("0.");
|
|
9
|
+
isOldBunVersion = () => result;
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region ../../../plugins/router/src/core/helper/streaming/stream.ts
|
|
14
|
+
const contextStash$1 = /* @__PURE__ */ new WeakMap();
|
|
15
|
+
const stream = (c, cb, onError) => {
|
|
16
|
+
const { readable, writable } = new TransformStream();
|
|
17
|
+
const stream = new StreamingApi(writable, readable);
|
|
18
|
+
if (isOldBunVersion()) c.req.raw.signal.addEventListener("abort", () => {
|
|
19
|
+
if (!stream.closed) stream.abort();
|
|
20
|
+
});
|
|
21
|
+
contextStash$1.set(stream.responseReadable, c);
|
|
22
|
+
(async () => {
|
|
23
|
+
try {
|
|
24
|
+
await cb(stream);
|
|
25
|
+
} catch (e) {
|
|
26
|
+
if (e === void 0) {} else if (e instanceof Error && onError) await onError(e, stream);
|
|
27
|
+
else console.error(e);
|
|
28
|
+
} finally {
|
|
29
|
+
stream.close();
|
|
30
|
+
}
|
|
31
|
+
})();
|
|
32
|
+
return c.newResponse(stream.responseReadable);
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region ../../../plugins/router/src/core/helper/streaming/sse.ts
|
|
36
|
+
var SSEStreamingApi = class extends StreamingApi {
|
|
37
|
+
constructor(writable, readable) {
|
|
38
|
+
super(writable, readable);
|
|
39
|
+
}
|
|
40
|
+
async writeSSE(message) {
|
|
41
|
+
const dataLines = (await resolveCallback(message.data, HtmlEscapedCallbackPhase.Stringify, false, {})).split(/\r\n|\r|\n/).map((line) => {
|
|
42
|
+
return `data: ${line}`;
|
|
43
|
+
}).join("\n");
|
|
44
|
+
for (const key of ["event", "id"]) {
|
|
45
|
+
const value = message[key];
|
|
46
|
+
if (value && /[\r\n]/.test(value)) throw new Error(`${key} must not contain "\\r" or "\\n"`);
|
|
47
|
+
}
|
|
48
|
+
const sseData = [
|
|
49
|
+
message.event && `event: ${message.event}`,
|
|
50
|
+
dataLines,
|
|
51
|
+
message.id !== void 0 && `id: ${message.id}`,
|
|
52
|
+
message.retry !== void 0 && `retry: ${message.retry}`
|
|
53
|
+
].filter(Boolean).join("\n") + "\n\n";
|
|
54
|
+
await this.write(sseData);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const run = async (stream, cb, onError) => {
|
|
58
|
+
try {
|
|
59
|
+
await cb(stream);
|
|
60
|
+
} catch (e) {
|
|
61
|
+
if (e instanceof Error && onError) {
|
|
62
|
+
await onError(e, stream);
|
|
63
|
+
await stream.writeSSE({
|
|
64
|
+
event: "error",
|
|
65
|
+
data: e.message
|
|
66
|
+
});
|
|
67
|
+
} else console.error(e);
|
|
68
|
+
} finally {
|
|
69
|
+
stream.close();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const contextStash = /* @__PURE__ */ new WeakMap();
|
|
73
|
+
const streamSSE = (c, cb, onError) => {
|
|
74
|
+
const { readable, writable } = new TransformStream();
|
|
75
|
+
const stream = new SSEStreamingApi(writable, readable);
|
|
76
|
+
if (isOldBunVersion()) c.req.raw.signal.addEventListener("abort", () => {
|
|
77
|
+
if (!stream.closed) stream.abort();
|
|
78
|
+
});
|
|
79
|
+
contextStash.set(stream.responseReadable, c);
|
|
80
|
+
c.header("Transfer-Encoding", "chunked");
|
|
81
|
+
c.header("Content-Type", "text/event-stream");
|
|
82
|
+
c.header("Cache-Control", "no-cache");
|
|
83
|
+
c.header("Connection", "keep-alive");
|
|
84
|
+
run(stream, cb, onError);
|
|
85
|
+
return c.newResponse(stream.responseReadable);
|
|
86
|
+
};
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region ../../../plugins/router/src/core/helper/streaming/text.ts
|
|
89
|
+
const streamText = (c, cb, onError) => {
|
|
90
|
+
c.header("Content-Type", TEXT_PLAIN);
|
|
91
|
+
c.header("X-Content-Type-Options", "nosniff");
|
|
92
|
+
c.header("Transfer-Encoding", "chunked");
|
|
93
|
+
return stream(c, cb, onError);
|
|
94
|
+
};
|
|
95
|
+
//#endregion
|
|
96
|
+
export { stream as i, SSEStreamingApi as n, streamSSE as r, streamText as t };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { t as Context } from "./context-Ca3uX_bh.js";
|
|
2
|
+
import { t as StreamingApi } from "./stream-Oxo9JHC6.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../../plugins/router/src/core/helper/streaming/stream.d.ts
|
|
5
|
+
declare const stream: (c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: (e: Error, stream: StreamingApi) => Promise<void>) => Response;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region ../../../plugins/router/src/core/helper/streaming/sse.d.ts
|
|
8
|
+
interface SSEMessage {
|
|
9
|
+
data: string | Promise<string>;
|
|
10
|
+
event?: string;
|
|
11
|
+
id?: string;
|
|
12
|
+
retry?: number;
|
|
13
|
+
}
|
|
14
|
+
declare class SSEStreamingApi extends StreamingApi {
|
|
15
|
+
constructor(writable: WritableStream, readable: ReadableStream);
|
|
16
|
+
writeSSE(message: SSEMessage): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
declare const streamSSE: (c: Context, cb: (stream: SSEStreamingApi) => Promise<void>, onError?: (e: Error, stream: SSEStreamingApi) => Promise<void>) => Response;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region ../../../plugins/router/src/core/helper/streaming/text.d.ts
|
|
21
|
+
declare const streamText: (c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: (e: Error, stream: StreamingApi) => Promise<void>) => Response;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { type SSEMessage, SSEStreamingApi, stream, streamSSE, streamText };
|
package/lib/streaming.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { t as hc } from "./client-BMFCUlHG.js";
|
|
2
|
+
//#region ../../../plugins/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.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Y as Schema, a as ExecutionContext } from "./context-Ca3uX_bh.js";
|
|
2
|
+
import { D as UnionToIntersection } from "./types-nO2Jov17.js";
|
|
3
|
+
import { t as Acryl } from "./app-DGqSNBSd.js";
|
|
4
|
+
import { i as ClientRequestOptions, n as Client } from "./types-cu7acft5.js";
|
|
5
|
+
|
|
6
|
+
//#region ../../../plugins/router/src/core/helper/testing/index.d.ts
|
|
7
|
+
type ExtractEnv<T> = T extends Acryl<infer E, Schema, string> ? E : never;
|
|
8
|
+
declare const testClient: <T extends Acryl<any, Schema, string>>(app: T, Env?: ExtractEnv<T>["Bindings"] | {}, executionCtx?: ExecutionContext, options?: Omit<ClientRequestOptions, "fetch">) => UnionToIntersection<Client<T, "http://localhost">>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { testClient };
|
package/lib/testing.js
ADDED