@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,125 @@
|
|
|
1
|
+
//#region ../../../plugins/router/src/core/client/fetch-result-please.ts
|
|
2
|
+
/**
|
|
3
|
+
* @description This file is a modified version of `fetch-result-please` (`ofetch`), minimalized and adapted to Acryl's custom needs.
|
|
4
|
+
*
|
|
5
|
+
* @link https://www.npmjs.com/package/fetch-result-please
|
|
6
|
+
*/
|
|
7
|
+
const nullBodyResponses = /* @__PURE__ */ new Set([
|
|
8
|
+
101,
|
|
9
|
+
204,
|
|
10
|
+
205,
|
|
11
|
+
304
|
|
12
|
+
]);
|
|
13
|
+
/**
|
|
14
|
+
* Smartly parses and return the consumable result from a fetch `Response`.
|
|
15
|
+
*
|
|
16
|
+
* Throwing a structured error if the response is not `ok`. ({@link DetailedError})
|
|
17
|
+
*/
|
|
18
|
+
async function fetchRP(fetchRes) {
|
|
19
|
+
const _fetchRes = await fetchRes;
|
|
20
|
+
if ((_fetchRes.body || _fetchRes._bodyInit) && !nullBodyResponses.has(_fetchRes.status)) _fetchRes._data = await _fetchRes[detectResponseType(_fetchRes)]();
|
|
21
|
+
if (!_fetchRes.ok) throw new DetailedError(`${_fetchRes.status} ${_fetchRes.statusText}`, {
|
|
22
|
+
statusCode: _fetchRes?.status,
|
|
23
|
+
detail: {
|
|
24
|
+
data: _fetchRes?._data,
|
|
25
|
+
statusText: _fetchRes?.statusText
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return _fetchRes._data;
|
|
29
|
+
}
|
|
30
|
+
var DetailedError = class extends Error {
|
|
31
|
+
/**
|
|
32
|
+
* Additional `message` that will be logged AND returned to client
|
|
33
|
+
*/
|
|
34
|
+
detail;
|
|
35
|
+
/**
|
|
36
|
+
* Additional `code` that will be logged AND returned to client
|
|
37
|
+
*/
|
|
38
|
+
code;
|
|
39
|
+
/**
|
|
40
|
+
* Additional value that will be logged AND NOT returned to client
|
|
41
|
+
*/
|
|
42
|
+
log;
|
|
43
|
+
/**
|
|
44
|
+
* Optionally set the status code to return, in a web server context
|
|
45
|
+
*/
|
|
46
|
+
statusCode;
|
|
47
|
+
constructor(message, options = {}) {
|
|
48
|
+
super(message);
|
|
49
|
+
this.name = "DetailedError";
|
|
50
|
+
this.log = options.log;
|
|
51
|
+
this.detail = options.detail;
|
|
52
|
+
this.code = options.code;
|
|
53
|
+
this.statusCode = options.statusCode;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const jsonRegex = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(?:;.+)?$/i;
|
|
57
|
+
function detectResponseType(response) {
|
|
58
|
+
const _contentType = response.headers.get("content-type");
|
|
59
|
+
if (!_contentType) return "text";
|
|
60
|
+
const contentType = _contentType.split(";").shift();
|
|
61
|
+
if (jsonRegex.test(contentType)) return "json";
|
|
62
|
+
return "text";
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region ../../../plugins/router/src/core/client/utils.ts
|
|
66
|
+
const mergePath = (base, path) => {
|
|
67
|
+
base = base.replace(/\/+$/, "");
|
|
68
|
+
base = base + "/";
|
|
69
|
+
path = path.replace(/^\/+/, "");
|
|
70
|
+
return base + path;
|
|
71
|
+
};
|
|
72
|
+
const replaceUrlParam = (urlString, params) => {
|
|
73
|
+
for (const [k, v] of Object.entries(params)) {
|
|
74
|
+
const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??(?=/|$)");
|
|
75
|
+
urlString = urlString.replace(reg, () => v ? `/${v}` : "");
|
|
76
|
+
}
|
|
77
|
+
return urlString;
|
|
78
|
+
};
|
|
79
|
+
const buildSearchParams = (query) => {
|
|
80
|
+
const searchParams = new URLSearchParams();
|
|
81
|
+
for (const [k, v] of Object.entries(query)) {
|
|
82
|
+
if (v === void 0) continue;
|
|
83
|
+
if (Array.isArray(v)) for (const v2 of v) {
|
|
84
|
+
if (v2 === void 0) continue;
|
|
85
|
+
searchParams.append(k, v2);
|
|
86
|
+
}
|
|
87
|
+
else searchParams.set(k, v);
|
|
88
|
+
}
|
|
89
|
+
return searchParams;
|
|
90
|
+
};
|
|
91
|
+
const replaceUrlProtocol = (urlString, protocol) => {
|
|
92
|
+
switch (protocol) {
|
|
93
|
+
case "ws": return urlString.replace(/^http/, "ws");
|
|
94
|
+
case "http": return urlString.replace(/^ws/, "http");
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const removeIndexString = (urlString) => {
|
|
98
|
+
if (/^https?:\/\/[^\/]+?\/index(?=\?|$)/.test(urlString)) return urlString.replace(/\/index(?=\?|$)/, "/");
|
|
99
|
+
return urlString.replace(/\/index(?=\?|$)/, "");
|
|
100
|
+
};
|
|
101
|
+
function isObject(item) {
|
|
102
|
+
return typeof item === "object" && item !== null && !Array.isArray(item);
|
|
103
|
+
}
|
|
104
|
+
function deepMerge(target, source) {
|
|
105
|
+
if (!isObject(target) && !isObject(source)) return source;
|
|
106
|
+
const merged = { ...target };
|
|
107
|
+
for (const key in source) {
|
|
108
|
+
const value = source[key];
|
|
109
|
+
if (isObject(merged[key]) && isObject(value)) merged[key] = deepMerge(merged[key], value);
|
|
110
|
+
else merged[key] = value;
|
|
111
|
+
}
|
|
112
|
+
return merged;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Shortcut to get a consumable response from `hc`'s fetch calls (Response), with types inference.
|
|
116
|
+
*
|
|
117
|
+
* Smartly parse the response data, throwing a structured error if the response is not `ok`. ({@link DetailedError})
|
|
118
|
+
*
|
|
119
|
+
* @example const result = await parseResponse(client.posts.$get())
|
|
120
|
+
*/
|
|
121
|
+
async function parseResponse(fetchRes) {
|
|
122
|
+
return fetchRP(fetchRes);
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { removeIndexString as a, DetailedError as c, parseResponse as i, deepMerge as n, replaceUrlParam as o, mergePath as r, replaceUrlProtocol as s, buildSearchParams as t };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { t as HTTPException } from "./http-exception-BKMYq4x6.js";
|
|
2
|
+
import { t as bufferToFormData } from "./buffer-CWpxJrvI.js";
|
|
3
|
+
import { i as getCookie } from "./cookie-DktnJ0tJ.js";
|
|
4
|
+
//#region ../../../plugins/router/src/core/validator/validator.ts
|
|
5
|
+
const jsonRegex = /^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/i;
|
|
6
|
+
const multipartRegex = /^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/i;
|
|
7
|
+
const urlencodedRegex = /^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/i;
|
|
8
|
+
const validator = (target, validationFunc) => {
|
|
9
|
+
return async (c, next) => {
|
|
10
|
+
let value = {};
|
|
11
|
+
const contentType = c.req.header("Content-Type");
|
|
12
|
+
switch (target) {
|
|
13
|
+
case "json":
|
|
14
|
+
if (!contentType || !jsonRegex.test(contentType)) break;
|
|
15
|
+
try {
|
|
16
|
+
value = await c.req.json();
|
|
17
|
+
} catch {
|
|
18
|
+
throw new HTTPException(400, { message: "Malformed JSON in request body" });
|
|
19
|
+
}
|
|
20
|
+
break;
|
|
21
|
+
case "form": {
|
|
22
|
+
if (!contentType || !(multipartRegex.test(contentType) || urlencodedRegex.test(contentType))) break;
|
|
23
|
+
let formData;
|
|
24
|
+
if (c.req.bodyCache.formData) formData = await c.req.bodyCache.formData;
|
|
25
|
+
else try {
|
|
26
|
+
formData = await bufferToFormData(await c.req.arrayBuffer(), contentType);
|
|
27
|
+
c.req.bodyCache.formData = formData;
|
|
28
|
+
} catch (e) {
|
|
29
|
+
let message = "Malformed FormData request.";
|
|
30
|
+
message += e instanceof Error ? ` ${e.message}` : ` ${String(e)}`;
|
|
31
|
+
throw new HTTPException(400, { message });
|
|
32
|
+
}
|
|
33
|
+
const form = Object.create(null);
|
|
34
|
+
formData.forEach((value, key) => {
|
|
35
|
+
if (key.endsWith("[]")) (form[key] ??= []).push(value);
|
|
36
|
+
else if (Array.isArray(form[key])) form[key].push(value);
|
|
37
|
+
else if (Object.hasOwn(form, key)) form[key] = [form[key], value];
|
|
38
|
+
else form[key] = value;
|
|
39
|
+
});
|
|
40
|
+
value = form;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case "query":
|
|
44
|
+
value = Object.fromEntries(Object.entries(c.req.queries()).map(([k, v]) => {
|
|
45
|
+
return v.length === 1 ? [k, v[0]] : [k, v];
|
|
46
|
+
}));
|
|
47
|
+
break;
|
|
48
|
+
case "param":
|
|
49
|
+
value = c.req.param();
|
|
50
|
+
break;
|
|
51
|
+
case "header":
|
|
52
|
+
value = c.req.header();
|
|
53
|
+
break;
|
|
54
|
+
case "cookie":
|
|
55
|
+
value = getCookie(c);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
const res = await validationFunc(value, c);
|
|
59
|
+
if (res instanceof Response) return res;
|
|
60
|
+
c.req.addValidatedData(target, res);
|
|
61
|
+
return await next();
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
export { validator as t };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { G as ParsedFormValue, L as MiddlewareHandler, Q as ValidationTargets, T as FormValue, Z as TypedResponse, t as Context, v as Env } from "./context-Ca3uX_bh.js";
|
|
2
|
+
import { D as UnionToIntersection } from "./types-nO2Jov17.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../../plugins/router/src/core/validator/utils.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Checks if T is a literal union type (e.g., 'asc' | 'desc')
|
|
7
|
+
* that should be preserved in input types.
|
|
8
|
+
* Returns true for union literals, false for single literals or wide types.
|
|
9
|
+
*/
|
|
10
|
+
type IsLiteralUnion<T, Base> = [Exclude<T, undefined>] extends [Base] ? [Exclude<T, undefined>] extends [UnionToIntersection<Exclude<T, undefined>>] ? false : true : false;
|
|
11
|
+
type IsOptionalUnion<T> = [unknown] extends [T] ? false : undefined extends T ? true : false;
|
|
12
|
+
type SimplifyDeep<T> = { [K in keyof T]: T[K] } & {};
|
|
13
|
+
type InferInputInner<Output, Target extends keyof ValidationTargets, T extends FormValue> = SimplifyDeep<{ [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 }>;
|
|
14
|
+
/**
|
|
15
|
+
* Utility type to infer input types for validation targets.
|
|
16
|
+
* Preserves literal union types (e.g., 'asc' | 'desc') while using
|
|
17
|
+
* the default ValidationTargets type for other values.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* // In @acryl-router/zod-validator or similar:
|
|
22
|
+
* type Input = InferInput<z.input<Schema>, 'query'>
|
|
23
|
+
* // { orderBy: 'asc' | 'desc', page: string | string[] }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
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>> : {};
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region ../../../plugins/router/src/core/validator/validator.d.ts
|
|
29
|
+
type ValidationTargetKeysWithBody = 'form' | 'json';
|
|
30
|
+
type ValidationTargetByMethod<M> = M extends 'get' | 'head' ? Exclude<keyof ValidationTargets, ValidationTargetKeysWithBody> : keyof ValidationTargets;
|
|
31
|
+
type ValidationFunction<InputType, OutputType, E extends Env = {}, P extends string = string> = (value: InputType, c: Context<E, P>) => OutputType | TypedResponse | Promise<OutputType> | Promise<TypedResponse>;
|
|
32
|
+
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;
|
|
33
|
+
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 {
|
|
34
|
+
in: { [K in U]: K extends "json" ? unknown extends InputType ? ExtractValidatorOutput<VF> : InputType : InferInput<ExtractValidatorOutput<VF>, K, FormValue> };
|
|
35
|
+
out: { [K in U]: ExtractValidatorOutput<VF> };
|
|
36
|
+
} = {
|
|
37
|
+
in: { [K in U]: K extends "json" ? unknown extends InputType ? ExtractValidatorOutput<VF> : InputType : InferInput<ExtractValidatorOutput<VF>, K, FormValue> };
|
|
38
|
+
out: { [K in U]: ExtractValidatorOutput<VF> };
|
|
39
|
+
}, E extends Env = any>(target: U, validationFunc: VF) => MiddlewareHandler<E, P, V, ExtractValidationResponse<VF>>;
|
|
40
|
+
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;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { type InferInput, type ValidationFunction, validator };
|
package/lib/validator.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/vitest-binding.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The conformance suites (`acrylblends/db/conformance`, `acrylblends/kv/conformance`) run on the test runner's own vitest, which the test hands them. In the package build their
|
|
4
|
+
* `import ... from 'vitest'` is pointed here (`tsdown.config.ts`), so the package imports no vitest and does not declare one: it cannot put vitest, vite, rolldown or lightningcss into
|
|
5
|
+
* a production install, and the suite can never see a second copy of vitest that is not the one running the test.
|
|
6
|
+
*/
|
|
7
|
+
/** The four functions of vitest the suites use; a test passes `import * as vitest from 'vitest'`. */
|
|
8
|
+
interface VitestApi {
|
|
9
|
+
readonly afterEach: (...args: never[]) => unknown;
|
|
10
|
+
readonly describe: (...args: never[]) => unknown;
|
|
11
|
+
readonly expect: (...args: never[]) => unknown;
|
|
12
|
+
readonly it: (...args: never[]) => unknown;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { VitestApi as t };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/vitest-binding.ts
|
|
2
|
+
let bound;
|
|
3
|
+
/** Use `api` for the suites that run next. They register their cases synchronously, so one call per suite is enough. */
|
|
4
|
+
function bind(api) {
|
|
5
|
+
if (api === void 0 || typeof api.describe !== "function" || typeof api.it !== "function" || typeof api.expect !== "function" || typeof api.afterEach !== "function") throw new Error("the conformance suite needs the vitest your tests run on: pass it as the third argument, `import * as vitest from 'vitest'` then `describeKvConformance(name, open, vitest)`");
|
|
6
|
+
bound = api;
|
|
7
|
+
}
|
|
8
|
+
const use = () => {
|
|
9
|
+
if (bound === void 0) throw new Error("the conformance suite ran before it was given vitest");
|
|
10
|
+
return bound;
|
|
11
|
+
};
|
|
12
|
+
const afterEach = (...args) => Reflect.apply(use().afterEach, void 0, args);
|
|
13
|
+
const describe = (...args) => Reflect.apply(use().describe, void 0, args);
|
|
14
|
+
const expect = (...args) => Reflect.apply(use().expect, void 0, args);
|
|
15
|
+
const it = (...args) => Reflect.apply(use().it, void 0, args);
|
|
16
|
+
//#endregion
|
|
17
|
+
export { it as a, expect as i, bind as n, describe as r, afterEach as t };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//#region ../../../plugins/router/src/core/helper/websocket/index.ts
|
|
2
|
+
/**
|
|
3
|
+
* A context for controlling WebSockets
|
|
4
|
+
*/
|
|
5
|
+
var WSContext = class {
|
|
6
|
+
#init;
|
|
7
|
+
constructor(init) {
|
|
8
|
+
this.#init = init;
|
|
9
|
+
this.raw = init.raw;
|
|
10
|
+
this.url = init.url ? new URL(init.url) : null;
|
|
11
|
+
this.protocol = init.protocol ?? null;
|
|
12
|
+
}
|
|
13
|
+
send(source, options) {
|
|
14
|
+
this.#init.send(source, options ?? {});
|
|
15
|
+
}
|
|
16
|
+
raw;
|
|
17
|
+
binaryType = "arraybuffer";
|
|
18
|
+
get readyState() {
|
|
19
|
+
return this.#init.readyState;
|
|
20
|
+
}
|
|
21
|
+
get bufferedAmount() {
|
|
22
|
+
return this.#init.bufferedAmount ?? 0;
|
|
23
|
+
}
|
|
24
|
+
url;
|
|
25
|
+
protocol;
|
|
26
|
+
close(code, reason) {
|
|
27
|
+
this.#init.close(code, reason);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const createWSMessageEvent = (source) => {
|
|
31
|
+
return new MessageEvent("message", { data: source });
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Create a WebSocket adapter/helper
|
|
35
|
+
*/
|
|
36
|
+
const defineWebSocketHelper = (handler) => {
|
|
37
|
+
return ((...args) => {
|
|
38
|
+
if (typeof args[0] === "function") {
|
|
39
|
+
const [createEvents, options] = args;
|
|
40
|
+
return async function upgradeWebSocket(c, next) {
|
|
41
|
+
const result = await handler(c, await createEvents(c), options);
|
|
42
|
+
if (result) return result;
|
|
43
|
+
await next();
|
|
44
|
+
};
|
|
45
|
+
} else {
|
|
46
|
+
const [c, events, options] = args;
|
|
47
|
+
return (async () => {
|
|
48
|
+
const upgraded = await handler(c, events, options);
|
|
49
|
+
if (!upgraded) throw new Error("Failed to upgrade WebSocket");
|
|
50
|
+
return upgraded;
|
|
51
|
+
})();
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
//#endregion
|
|
56
|
+
export { createWSMessageEvent as n, defineWebSocketHelper as r, WSContext as t };
|
package/lib/ws.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as WSEvents, c as WebSocketHelperDefineContext, d as defineWebSocketHelper, i as WSContextInit, l as WebSocketHelperDefineHandler, n as UpgradeWebSocket, o as WSMessageReceive, r as WSContext, s as WSReadyState, t as SendOptions, u as createWSMessageEvent } from "./index-C8xOqNUW.js";
|
|
2
|
+
export { SendOptions, UpgradeWebSocket, WSContext, WSContextInit, WSEvents, WSMessageReceive, WSReadyState, WebSocketHelperDefineContext, WebSocketHelperDefineHandler, createWSMessageEvent, defineWebSocketHelper };
|
package/lib/ws.js
ADDED