@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,134 @@
|
|
|
1
|
+
import { t as Acryl } from "./app-DGqSNBSd.js";
|
|
2
|
+
import { a as UpgradeRouter, c as TestWebSocketResult, d as upgradeWebSocket, f as WebSocketData, i as UpgradeHubOptions, l as testWebSocket, m as WebSocketServerLike, n as UpgradeEmitter, o as TestSocket, p as WebSocketLike, r as UpgradeHub, s as TestWebSocketOptions, t as Owner, u as RequestError } from "./upgrade-hub-7og-sHcQ.js";
|
|
3
|
+
import { n as serveStatic, t as ServeStaticOptions } from "./serve-static-D97E4ERX.js";
|
|
4
|
+
import { t as getConnInfo } from "./conninfo-BbxlV2HK.js";
|
|
5
|
+
import { AddressInfo } from "node:net";
|
|
6
|
+
import { IncomingMessage, Server, ServerOptions, ServerResponse, createServer } from "node:http";
|
|
7
|
+
import { Http2SecureServer, Http2Server, Http2ServerRequest, Http2ServerResponse, SecureServerOptions, ServerOptions as ServerOptions$1, createSecureServer, createServer as createServer$1 } from "node:http2";
|
|
8
|
+
import { Server as Server$1, ServerOptions as ServerOptions$2, createServer as createServer$2 } from "node:https";
|
|
9
|
+
|
|
10
|
+
//#region ../../../plugins/node-server/src/adapter/types.d.ts
|
|
11
|
+
type HttpBindings = {
|
|
12
|
+
incoming: IncomingMessage;
|
|
13
|
+
outgoing: ServerResponse;
|
|
14
|
+
};
|
|
15
|
+
type Http2Bindings = {
|
|
16
|
+
incoming: Http2ServerRequest;
|
|
17
|
+
outgoing: Http2ServerResponse;
|
|
18
|
+
};
|
|
19
|
+
type FetchCallback = (request: Request, env: HttpBindings | Http2Bindings) => Promise<unknown> | unknown;
|
|
20
|
+
type ServerType = Server | Http2Server | Http2SecureServer;
|
|
21
|
+
type createHttpOptions = {
|
|
22
|
+
serverOptions?: ServerOptions;
|
|
23
|
+
createServer?: typeof createServer;
|
|
24
|
+
};
|
|
25
|
+
type createHttpsOptions = {
|
|
26
|
+
serverOptions?: ServerOptions$2;
|
|
27
|
+
createServer?: typeof createServer$2;
|
|
28
|
+
};
|
|
29
|
+
type createHttp2Options = {
|
|
30
|
+
serverOptions?: ServerOptions$1;
|
|
31
|
+
createServer?: typeof createServer$1;
|
|
32
|
+
};
|
|
33
|
+
type createSecureHttp2Options = {
|
|
34
|
+
serverOptions?: SecureServerOptions;
|
|
35
|
+
createServer?: typeof createSecureServer;
|
|
36
|
+
};
|
|
37
|
+
type ServerOptions$3 = createHttpOptions | createHttpsOptions | createHttp2Options | createSecureHttp2Options;
|
|
38
|
+
type BaseOptions = {
|
|
39
|
+
fetch: FetchCallback;
|
|
40
|
+
overrideGlobalObjects?: boolean;
|
|
41
|
+
autoCleanupIncoming?: boolean;
|
|
42
|
+
port?: number; /** The interface to listen on; `serve` uses `127.0.0.1` when it is not given. */
|
|
43
|
+
hostname?: string;
|
|
44
|
+
websocket?: {
|
|
45
|
+
server: WebSocketServerLike;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
type Options = BaseOptions & ServerOptions$3;
|
|
49
|
+
/** Options for the default HTTP/1 server: `serve` and `createAdaptorServer` return an `http.Server`. */
|
|
50
|
+
type HttpOptions = BaseOptions & createHttpOptions;
|
|
51
|
+
/** Options naming `https.createServer`: an `https.Server`. */
|
|
52
|
+
type HttpsOptions = BaseOptions & {
|
|
53
|
+
serverOptions?: ServerOptions$2;
|
|
54
|
+
createServer: typeof createServer$2;
|
|
55
|
+
};
|
|
56
|
+
/** Options naming `http2.createServer`: an `Http2Server`. */
|
|
57
|
+
type Http2Options = BaseOptions & {
|
|
58
|
+
serverOptions?: ServerOptions$1;
|
|
59
|
+
createServer: typeof createServer$1;
|
|
60
|
+
};
|
|
61
|
+
/** Options naming `http2.createSecureServer`: an `Http2SecureServer`. */
|
|
62
|
+
type SecureHttp2Options = BaseOptions & {
|
|
63
|
+
serverOptions?: SecureServerOptions;
|
|
64
|
+
createServer: typeof createSecureServer;
|
|
65
|
+
};
|
|
66
|
+
type CustomErrorHandler = (err: unknown) => void | Response | Promise<void | Response>;
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region ../../../plugins/node-server/src/adapter/server.d.ts
|
|
69
|
+
declare function createAdaptorServer(options: SecureHttp2Options): Http2SecureServer;
|
|
70
|
+
declare function createAdaptorServer(options: Http2Options): Http2Server;
|
|
71
|
+
declare function createAdaptorServer(options: HttpsOptions): Server$1;
|
|
72
|
+
declare function createAdaptorServer(options: HttpOptions): Server;
|
|
73
|
+
declare function createAdaptorServer(options: Options): ServerType;
|
|
74
|
+
declare function serve(options: SecureHttp2Options, listeningListener?: (info: AddressInfo) => void): Http2SecureServer;
|
|
75
|
+
declare function serve(options: Http2Options, listeningListener?: (info: AddressInfo) => void): Http2Server;
|
|
76
|
+
declare function serve(options: HttpsOptions, listeningListener?: (info: AddressInfo) => void): Server$1;
|
|
77
|
+
declare function serve(options: HttpOptions, listeningListener?: (info: AddressInfo) => void): Server;
|
|
78
|
+
declare function serve(options: Options, listeningListener?: (info: AddressInfo) => void): ServerType;
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region ../../../plugins/node-server/src/adapter/listener.d.ts
|
|
81
|
+
declare const getRequestListener: (fetchCallback: FetchCallback, options?: {
|
|
82
|
+
hostname?: string;
|
|
83
|
+
errorHandler?: CustomErrorHandler;
|
|
84
|
+
overrideGlobalObjects?: boolean;
|
|
85
|
+
autoCleanupIncoming?: boolean;
|
|
86
|
+
}) => (incoming: IncomingMessage | Http2ServerRequest, outgoing: ServerResponse | Http2ServerResponse) => Promise<void>;
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region ../../../plugins/node-server/src/client-modules.d.ts
|
|
89
|
+
/** Options of {@link clientModules}. */
|
|
90
|
+
interface ClientModulesOptions {
|
|
91
|
+
/** The folder of client modules, absolute or relative to the working directory. */
|
|
92
|
+
readonly root: string;
|
|
93
|
+
/**
|
|
94
|
+
* The URL prefix the app is mounted at, when the caller knows it. A host can compose app plugins under its own router, and under a
|
|
95
|
+
* Host whose router is a different copy of this package the request's match result is not visible here, so `basePath(c)` throws; the
|
|
96
|
+
* explicit prefix is then the only reliable way to know where the mount starts. Omitted, the router's `basePath(c)` is used.
|
|
97
|
+
*/
|
|
98
|
+
readonly mount?: string | undefined;
|
|
99
|
+
/** The folder {@link buildClientModules} wrote; with `NODE_ENV=production` it is served instead of compiling, which needs no `typescript`. */
|
|
100
|
+
readonly compiled?: string | undefined;
|
|
101
|
+
/** At most this many bytes of compiled modules are kept in memory (least recently served first out); 16 MiB when not given. */
|
|
102
|
+
readonly cacheBytes?: number | undefined;
|
|
103
|
+
/** The folder holding `jsx-dom.js`, `client.js` and `read-sse.js`; the framework's own when not given. */
|
|
104
|
+
readonly runtimeDir?: string | undefined;
|
|
105
|
+
}
|
|
106
|
+
/** Options of {@link buildClientModules}. */
|
|
107
|
+
interface BuildClientModulesOptions {
|
|
108
|
+
/** The folder of client modules, absolute or relative to the working directory. */
|
|
109
|
+
readonly root: string;
|
|
110
|
+
/** Where the compiled modules go, at the same relative paths and file names; it must not lie inside `root`. */
|
|
111
|
+
readonly outDir: string;
|
|
112
|
+
/** The folder holding `jsx-dom.js`, `client.js` and `read-sse.js`; the framework's own when not given. */
|
|
113
|
+
readonly runtimeDir?: string | undefined;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* An app serving a folder of client modules to the browser. Route it where the page's script tags point: `app.route('/client',
|
|
117
|
+
* clientModules({ root: 'src/client' }))` serves `src/client/counter.tsx` at `/client/counter.tsx`. Files are compiled on request and
|
|
118
|
+
* cached until they change (bounded by `cacheBytes`); a response carries an ETag and `Cache-Control: no-cache`, so an edit shows on the
|
|
119
|
+
* next reload. With `NODE_ENV=production` and `compiled` set, only the `compiled` folder is served and nothing is compiled.
|
|
120
|
+
* @param options - the folder, the precompiled folder, and the cache bound.
|
|
121
|
+
* @returns the app.
|
|
122
|
+
*/
|
|
123
|
+
declare function clientModules(options: ClientModulesOptions): Acryl;
|
|
124
|
+
/**
|
|
125
|
+
* Compile a folder of client modules once, for a production that has no `typescript`: each module is written to `outDir` at the same
|
|
126
|
+
* relative path and file name (so the page's URLs stay the same), compiled exactly as {@link clientModules} compiles it, and the three
|
|
127
|
+
* browser files are copied to `outDir/@acryldev/`. Files already in `outDir` that no source produces are left there.
|
|
128
|
+
* @param options - the source folder and the output folder.
|
|
129
|
+
* @returns the paths written, relative to `outDir`.
|
|
130
|
+
* @throws MissingTypeScriptError when the app has no `typescript`; an error when `outDir` lies inside `root`.
|
|
131
|
+
*/
|
|
132
|
+
declare function buildClientModules(options: BuildClientModulesOptions): string[];
|
|
133
|
+
//#endregion
|
|
134
|
+
export { type BuildClientModulesOptions, type ClientModulesOptions, type Http2Bindings, type HttpBindings, type Owner, RequestError, type ServeStaticOptions, type ServerType, type TestSocket, type TestWebSocketOptions, type TestWebSocketResult, UpgradeEmitter, UpgradeHub, type UpgradeHubOptions, type UpgradeRouter, type WebSocketData, type WebSocketLike, type WebSocketServerLike, buildClientModules, clientModules, createAdaptorServer, getConnInfo, getRequestListener, serve, serveStatic, testWebSocket, upgradeWebSocket };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { a as serve, d as RequestError, i as createAdaptorServer, n as UpgradeHub, o as upgradeWebSocket, r as testWebSocket, s as getRequestListener, t as UpgradeEmitter } from "./upgrade-hub-B4hca91Y.js";
|
|
2
|
+
import { t as serveStatic } from "./serve-static-YoUetEZ8.js";
|
|
3
|
+
import { n as clientModules, t as buildClientModules } from "./client-modules-ChLgW0l9.js";
|
|
4
|
+
import { t as getConnInfo } from "./conninfo-CNYXEtnA.js";
|
|
5
|
+
export { RequestError, UpgradeEmitter, UpgradeHub, buildClientModules, clientModules, createAdaptorServer, getConnInfo, getRequestListener, serve, serveStatic, testWebSocket, upgradeWebSocket };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { t as Db } from "./database-CyKvumAn.js";
|
|
2
|
+
import { n as Kv } from "./kv-Kv6J9zqu.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../../plugins/kv-db/src/open.d.ts
|
|
5
|
+
interface KvOnDbOptions {
|
|
6
|
+
/** The table that holds the documents. Defaults to `kv`; a plain SQL identifier. */
|
|
7
|
+
readonly table?: string;
|
|
8
|
+
}
|
|
9
|
+
/** The `kv` port over a `db`. It does not own the database: whoever opened it closes it, and calls after that reject. */
|
|
10
|
+
declare function kvOnDb(db: Db, options?: KvOnDbOptions): Kv;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { kvOnDb as n, KvOnDbOptions as t };
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { a as compareKeys, c as runChange, o as decodeValue, r as checkKey, s as encodeValue } from "./src-CZ1JoBaO.js";
|
|
2
|
+
import { mkdir, open, readFile, readdir, rename, rm } from "node:fs/promises";
|
|
3
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
4
|
+
//#region ../../../plugins/kv-json/src/open.ts
|
|
5
|
+
/**
|
|
6
|
+
* The plain way to open the JSON-file provider, for code without Cordis (an acrylblends app): `openKv({ path })` reads one JSON file into
|
|
7
|
+
* memory and resolves the `kv` port with the function that closes it. The Cordis plugin is a thin wrapper over this, so both run one code
|
|
8
|
+
* path. This entry imports nothing from Cordis.
|
|
9
|
+
*
|
|
10
|
+
* Every write persists the whole map: serialize to a temporary file in the same folder, flush it, rename it over the file, and flush the
|
|
11
|
+
* folder where the platform allows. The call resolves after the rename, so a crash leaves the old file or the new one, never half of one.
|
|
12
|
+
* Writes are grouped: the calls made in one turn of the event loop, and those that queue while a file write is in flight, are applied in
|
|
13
|
+
* call order and persisted together by one write, so a burst of calls costs one flush and one rename, not one each (on Windows each costs
|
|
14
|
+
* tens of milliseconds). One process owns the
|
|
15
|
+
* file: two writers would overwrite each other.
|
|
16
|
+
*/
|
|
17
|
+
/** The file's own format version, for a later change of layout. */
|
|
18
|
+
const FORMAT = 1;
|
|
19
|
+
/** Stray temporary files from a crash end in `.tmp` and start with the file's name. */
|
|
20
|
+
const tempPrefix = (file) => `${basename(file)}.`;
|
|
21
|
+
/** The file content for a map of key to JSON text, keys in code point order, so the same data is the same bytes. */
|
|
22
|
+
function serialize(entries) {
|
|
23
|
+
const body = [...entries.keys()].sort(compareKeys).map((key) => `${JSON.stringify(key)}:${entries.get(key)}`).join(",");
|
|
24
|
+
return `{"version":${FORMAT},"entries":{${body}}}\n`;
|
|
25
|
+
}
|
|
26
|
+
function unreadable(file, reason) {
|
|
27
|
+
return /* @__PURE__ */ new Error(`@acryldev/kv-json: ${file} is not a readable kv file (${reason}); it was not changed`);
|
|
28
|
+
}
|
|
29
|
+
/** The entries of a file, or none when it does not exist. A file that exists and does not parse is an error: it is never started over. */
|
|
30
|
+
async function load(file) {
|
|
31
|
+
let text;
|
|
32
|
+
try {
|
|
33
|
+
text = await readFile(file, "utf8");
|
|
34
|
+
} catch (error) {
|
|
35
|
+
if (error.code === "ENOENT") return /* @__PURE__ */ new Map();
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
let parsed;
|
|
39
|
+
try {
|
|
40
|
+
parsed = JSON.parse(text);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throw unreadable(file, error.message);
|
|
43
|
+
}
|
|
44
|
+
if (typeof parsed !== "object" || parsed === null || parsed.version !== FORMAT) throw unreadable(file, "not a version 1 kv file");
|
|
45
|
+
const entries = parsed.entries;
|
|
46
|
+
if (typeof entries !== "object" || entries === null || Array.isArray(entries)) throw unreadable(file, "no entries object");
|
|
47
|
+
return new Map(Object.entries(entries).map(([key, value]) => [key, JSON.stringify(value)]));
|
|
48
|
+
}
|
|
49
|
+
/** Remove the temporary files an earlier crash left beside the file. */
|
|
50
|
+
async function removeStrays(file) {
|
|
51
|
+
const prefix = tempPrefix(file);
|
|
52
|
+
for (const name of await readdir(dirname(file))) if (name.startsWith(prefix) && name.endsWith(".tmp")) await rm(join(dirname(file), name), { force: true });
|
|
53
|
+
}
|
|
54
|
+
const RENAME_RETRIES = 8;
|
|
55
|
+
/** Rename over the target. Windows refuses while a scanner or an indexer holds the target for a moment, so it is retried briefly. */
|
|
56
|
+
async function replace(from, to) {
|
|
57
|
+
for (let attempt = 0;; attempt += 1) try {
|
|
58
|
+
await rename(from, to);
|
|
59
|
+
return;
|
|
60
|
+
} catch (error) {
|
|
61
|
+
const code = error.code;
|
|
62
|
+
if (attempt >= RENAME_RETRIES || code !== "EPERM" && code !== "EBUSY" && code !== "EACCES") throw error;
|
|
63
|
+
await new Promise((resolveWait) => setTimeout(resolveWait, 10 * (attempt + 1)));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** Flush the folder entry of a renamed file (POSIX); Windows cannot open a folder, and a filesystem that refuses is no worse than before. */
|
|
67
|
+
async function flushFolder(folder) {
|
|
68
|
+
if (process.platform === "win32") return;
|
|
69
|
+
try {
|
|
70
|
+
const handle = await open(folder, "r");
|
|
71
|
+
try {
|
|
72
|
+
await handle.sync();
|
|
73
|
+
} finally {
|
|
74
|
+
await handle.close();
|
|
75
|
+
}
|
|
76
|
+
} catch {}
|
|
77
|
+
}
|
|
78
|
+
/** Open (and create, when missing) a JSON-file store. @throws when the file exists and is not a readable kv file. */
|
|
79
|
+
async function openKv(options) {
|
|
80
|
+
const file = resolve(options.path);
|
|
81
|
+
await mkdir(dirname(file), { recursive: true });
|
|
82
|
+
await removeStrays(file);
|
|
83
|
+
let state = await load(file);
|
|
84
|
+
let closed = false;
|
|
85
|
+
let sequence = 0;
|
|
86
|
+
/** Calls waiting for the next file write, in call order. */
|
|
87
|
+
let queue = [];
|
|
88
|
+
/** Whether the loop that writes the queue runs; cleared by the loop itself, so a call queued after it ends starts a new one. */
|
|
89
|
+
let draining = false;
|
|
90
|
+
/** The latest loop, for `close` to wait on. */
|
|
91
|
+
let drained = Promise.resolve();
|
|
92
|
+
const guard = () => {
|
|
93
|
+
if (closed) throw new Error(`@acryldev/kv-json: ${file} is closed`);
|
|
94
|
+
};
|
|
95
|
+
/** Persist a map: the file is the old one or this one, never between. */
|
|
96
|
+
const persist = async (next) => {
|
|
97
|
+
sequence += 1;
|
|
98
|
+
const temp = join(dirname(file), `${tempPrefix(file)}${process.pid}.${sequence}.tmp`);
|
|
99
|
+
try {
|
|
100
|
+
const handle = await open(temp, "w");
|
|
101
|
+
try {
|
|
102
|
+
await handle.writeFile(serialize(next), "utf8");
|
|
103
|
+
await handle.sync();
|
|
104
|
+
} finally {
|
|
105
|
+
await handle.close();
|
|
106
|
+
}
|
|
107
|
+
await replace(temp, file);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
await rm(temp, { force: true });
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
await flushFolder(dirname(file));
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Write the queue until it is empty. Each round takes every call queued so far and applies them in order to one copy of the state. A call
|
|
116
|
+
* whose change throws rejects with its error and changes nothing, and the others in the round still apply. The copy becomes the state
|
|
117
|
+
* only once it is on disk. A failed file write rejects every call in its round and leaves the state as it was.
|
|
118
|
+
*/
|
|
119
|
+
const drain = async () => {
|
|
120
|
+
try {
|
|
121
|
+
await Promise.resolve();
|
|
122
|
+
await rounds();
|
|
123
|
+
} finally {
|
|
124
|
+
draining = false;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const rounds = async () => {
|
|
128
|
+
while (queue.length > 0) {
|
|
129
|
+
const round = queue;
|
|
130
|
+
queue = [];
|
|
131
|
+
const draft = new Map(state);
|
|
132
|
+
const applied = [];
|
|
133
|
+
for (const call of round) {
|
|
134
|
+
let change;
|
|
135
|
+
try {
|
|
136
|
+
change = call.change((key) => draft.get(key));
|
|
137
|
+
} catch (error) {
|
|
138
|
+
call.reject(error);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (change.text === void 0) draft.delete(change.key);
|
|
142
|
+
else draft.set(change.key, change.text);
|
|
143
|
+
applied.push({
|
|
144
|
+
call,
|
|
145
|
+
result: change.result
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
if (applied.length === 0) continue;
|
|
149
|
+
try {
|
|
150
|
+
await persist(draft);
|
|
151
|
+
} catch (error) {
|
|
152
|
+
for (const { call } of applied) call.reject(error);
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
state = draft;
|
|
156
|
+
for (const { call, result } of applied) call.resolve(result);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
/** Queue one change behind every earlier call; it resolves once a file write that contains it is on disk. */
|
|
160
|
+
const write = (change) => {
|
|
161
|
+
guard();
|
|
162
|
+
const done = new Promise((resolveCall, rejectCall) => {
|
|
163
|
+
queue.push({
|
|
164
|
+
change,
|
|
165
|
+
resolve: resolveCall,
|
|
166
|
+
reject: rejectCall
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
if (!draining) {
|
|
170
|
+
draining = true;
|
|
171
|
+
drained = drain();
|
|
172
|
+
}
|
|
173
|
+
return done;
|
|
174
|
+
};
|
|
175
|
+
return {
|
|
176
|
+
kv: {
|
|
177
|
+
async get(key) {
|
|
178
|
+
guard();
|
|
179
|
+
checkKey(key);
|
|
180
|
+
const text = state.get(key);
|
|
181
|
+
return text === void 0 ? void 0 : decodeValue(text);
|
|
182
|
+
},
|
|
183
|
+
async set(key, value) {
|
|
184
|
+
checkKey(key);
|
|
185
|
+
const text = encodeValue(value);
|
|
186
|
+
await write(() => ({
|
|
187
|
+
key,
|
|
188
|
+
text,
|
|
189
|
+
result: void 0
|
|
190
|
+
}));
|
|
191
|
+
},
|
|
192
|
+
async update(key, change) {
|
|
193
|
+
checkKey(key);
|
|
194
|
+
return write((read) => {
|
|
195
|
+
const text = read(key);
|
|
196
|
+
const encoded = encodeValue(runChange(change, text === void 0 ? void 0 : decodeValue(text)));
|
|
197
|
+
return {
|
|
198
|
+
key,
|
|
199
|
+
text: encoded,
|
|
200
|
+
result: decodeValue(encoded)
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
async delete(key) {
|
|
205
|
+
checkKey(key);
|
|
206
|
+
await write(() => ({
|
|
207
|
+
key,
|
|
208
|
+
text: void 0,
|
|
209
|
+
result: void 0
|
|
210
|
+
}));
|
|
211
|
+
},
|
|
212
|
+
async list(prefix = "") {
|
|
213
|
+
guard();
|
|
214
|
+
return [...state.keys()].filter((key) => key.startsWith(prefix)).sort(compareKeys);
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
close: async () => {
|
|
218
|
+
closed = true;
|
|
219
|
+
await drained;
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
224
|
+
export { openKv as t };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { r as KvOpened } from "./kv-Kv6J9zqu.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../../plugins/kv-json/src/open.d.ts
|
|
4
|
+
interface OpenKvOptions {
|
|
5
|
+
/** The JSON file; its folder is created if missing. */
|
|
6
|
+
readonly path: string;
|
|
7
|
+
}
|
|
8
|
+
/** Open (and create, when missing) a JSON-file store. @throws when the file exists and is not a readable kv file. */
|
|
9
|
+
declare function openKv(options: OpenKvOptions): Promise<KvOpened>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { openKv as n, OpenKvOptions as t };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { a as compareKeys, c as runChange, i as codePoints, o as decodeValue, r as checkKey, s as encodeValue } from "./src-CZ1JoBaO.js";
|
|
2
|
+
//#region ../../../plugins/kv-db/src/open.ts
|
|
3
|
+
const IDENTIFIER = /^[a-z_][a-z0-9_]*$/u;
|
|
4
|
+
/** The `kv` port over a `db`. It does not own the database: whoever opened it closes it, and calls after that reject. */
|
|
5
|
+
function kvOnDb(db, options = {}) {
|
|
6
|
+
const table = options.table ?? "kv";
|
|
7
|
+
if (!IDENTIFIER.test(table)) throw new TypeError(`@acryldev/kv-db: the table name must be a plain lower case SQL identifier, got ${JSON.stringify(table)}`);
|
|
8
|
+
let ready;
|
|
9
|
+
const ensure = () => {
|
|
10
|
+
ready ??= db.exec(`CREATE TABLE IF NOT EXISTS ${table} (key TEXT PRIMARY KEY, value TEXT NOT NULL)`).catch((error) => {
|
|
11
|
+
ready = void 0;
|
|
12
|
+
throw error;
|
|
13
|
+
});
|
|
14
|
+
return ready;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Run a statement after the table exists. The table's statement and this one are both handed to the database at once (its queue keeps
|
|
18
|
+
* their order), so a `close()` called right after a write cannot slip between them and leave the write on a closed database.
|
|
19
|
+
*/
|
|
20
|
+
const after = async (work) => {
|
|
21
|
+
const created = ensure();
|
|
22
|
+
const result = work();
|
|
23
|
+
const [, value] = await Promise.all([created, result]);
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
const upsert = `INSERT INTO ${table} (key, value) VALUES (?, ?) ON CONFLICT (key) DO UPDATE SET value = excluded.value`;
|
|
27
|
+
return {
|
|
28
|
+
async get(key) {
|
|
29
|
+
checkKey(key);
|
|
30
|
+
const row = await after(() => db.get(`SELECT value FROM ${table} WHERE key = ?`, key));
|
|
31
|
+
return row === void 0 ? void 0 : decodeValue(row.value);
|
|
32
|
+
},
|
|
33
|
+
async set(key, value) {
|
|
34
|
+
checkKey(key);
|
|
35
|
+
const text = encodeValue(value);
|
|
36
|
+
await after(() => db.run(upsert, key, text));
|
|
37
|
+
},
|
|
38
|
+
async update(key, change) {
|
|
39
|
+
checkKey(key);
|
|
40
|
+
return after(() => db.transaction(async (tx) => {
|
|
41
|
+
const row = await tx.get(`SELECT value FROM ${table} WHERE key = ?`, key);
|
|
42
|
+
const text = encodeValue(runChange(change, row === void 0 ? void 0 : decodeValue(row.value)));
|
|
43
|
+
await tx.run(upsert, key, text);
|
|
44
|
+
return decodeValue(text);
|
|
45
|
+
}));
|
|
46
|
+
},
|
|
47
|
+
async delete(key) {
|
|
48
|
+
checkKey(key);
|
|
49
|
+
await after(() => db.run(`DELETE FROM ${table} WHERE key = ?`, key));
|
|
50
|
+
},
|
|
51
|
+
async list(prefix = "") {
|
|
52
|
+
return (await after(() => prefix === "" ? db.all(`SELECT key FROM ${table}`) : db.all(`SELECT key FROM ${table} WHERE substr(key, 1, ?) = ?`, codePoints(prefix), prefix))).map((row) => row.key).sort(compareKeys);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { kvOnDb as t };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { i as applyMigrations, n as MIGRATIONS_TABLE, r as readMigrationFiles } from "./src-C_00jcuj.js";
|
|
2
|
+
import { mkdir } from "node:fs/promises";
|
|
3
|
+
import { dirname } from "node:path";
|
|
4
|
+
import { DatabaseSync } from "node:sqlite";
|
|
5
|
+
//#region ../../../plugins/db-sqlite/src/facade/node.ts
|
|
6
|
+
const DEFAULT_WAL_AUTO_CHECKPOINT_PAGES = 1e3;
|
|
7
|
+
const DEFAULT_BUSY_TIMEOUT_MS = 5e3;
|
|
8
|
+
const ignore = () => {};
|
|
9
|
+
/**
|
|
10
|
+
* Runs operations in call order. An operation starts immediately when nothing is running or waiting;
|
|
11
|
+
* otherwise it waits for everything before it. An asynchronous operation holds the queue until it settles.
|
|
12
|
+
*/
|
|
13
|
+
var SerialOperationQueue = class {
|
|
14
|
+
tail = Promise.resolve();
|
|
15
|
+
pending = 0;
|
|
16
|
+
run(operation) {
|
|
17
|
+
if (this.pending > 0) return this.enqueue(operation);
|
|
18
|
+
try {
|
|
19
|
+
return Promise.resolve(operation());
|
|
20
|
+
} catch (error) {
|
|
21
|
+
return Promise.reject(error);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
runAsync(operation) {
|
|
25
|
+
if (this.pending > 0) return this.enqueue(operation);
|
|
26
|
+
this.pending++;
|
|
27
|
+
const { promise: barrier, resolve: releaseBarrier } = Promise.withResolvers();
|
|
28
|
+
this.tail = barrier;
|
|
29
|
+
let started;
|
|
30
|
+
try {
|
|
31
|
+
started = operation();
|
|
32
|
+
} catch (error) {
|
|
33
|
+
started = Promise.reject(error);
|
|
34
|
+
}
|
|
35
|
+
return started.finally(() => {
|
|
36
|
+
this.pending--;
|
|
37
|
+
releaseBarrier();
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
enqueue(operation) {
|
|
41
|
+
this.pending++;
|
|
42
|
+
return this.release(this.tail.then(operation));
|
|
43
|
+
}
|
|
44
|
+
release(operation) {
|
|
45
|
+
const settled = operation.finally(() => {
|
|
46
|
+
this.pending--;
|
|
47
|
+
});
|
|
48
|
+
this.tail = settled.then(ignore, ignore);
|
|
49
|
+
return settled;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Executes SQL on one connection. Prepared statements are cached per connection by SQL text, so the
|
|
54
|
+
* database and its transaction handles share them across transactions.
|
|
55
|
+
*/
|
|
56
|
+
var NodeSqliteExecutor = class {
|
|
57
|
+
database;
|
|
58
|
+
statements;
|
|
59
|
+
constructor(database, statements) {
|
|
60
|
+
this.database = database;
|
|
61
|
+
this.statements = statements;
|
|
62
|
+
}
|
|
63
|
+
exec(sql) {
|
|
64
|
+
return this.runOperation(() => {
|
|
65
|
+
this.database.exec(sql);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
run(sql, ...params) {
|
|
69
|
+
return this.runOperation(() => ({ changes: Number(this.statement(sql).run(...params).changes) }));
|
|
70
|
+
}
|
|
71
|
+
get(sql, ...params) {
|
|
72
|
+
return this.runOperation(() => this.statement(sql).get(...params));
|
|
73
|
+
}
|
|
74
|
+
all(sql, ...params) {
|
|
75
|
+
return this.runOperation(() => this.statement(sql).all(...params));
|
|
76
|
+
}
|
|
77
|
+
statement(sql) {
|
|
78
|
+
let statement = this.statements.get(sql);
|
|
79
|
+
if (statement === void 0) {
|
|
80
|
+
statement = this.database.prepare(sql);
|
|
81
|
+
this.statements.set(sql, statement);
|
|
82
|
+
}
|
|
83
|
+
return statement;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var NodeSqliteTransaction = class extends NodeSqliteExecutor {
|
|
87
|
+
scope;
|
|
88
|
+
constructor(database, statements, scope) {
|
|
89
|
+
super(database, statements);
|
|
90
|
+
this.scope = scope;
|
|
91
|
+
}
|
|
92
|
+
async runOperation(operation) {
|
|
93
|
+
if (!this.scope.active) throw new Error("SQLite transaction handle is no longer active");
|
|
94
|
+
return operation();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
/** `Db` adapter backed by Node's built-in `node:sqlite`. */
|
|
98
|
+
var NodeSqliteDatabase = class extends NodeSqliteExecutor {
|
|
99
|
+
access = new SerialOperationQueue();
|
|
100
|
+
closed = false;
|
|
101
|
+
constructor(database) {
|
|
102
|
+
super(database, /* @__PURE__ */ new Map());
|
|
103
|
+
}
|
|
104
|
+
transaction(callback) {
|
|
105
|
+
return this.access.runAsync(async () => {
|
|
106
|
+
this.database.exec("BEGIN IMMEDIATE");
|
|
107
|
+
const scope = { active: true };
|
|
108
|
+
try {
|
|
109
|
+
const result = await callback(new NodeSqliteTransaction(this.database, this.statements, scope));
|
|
110
|
+
scope.active = false;
|
|
111
|
+
this.database.exec("COMMIT");
|
|
112
|
+
return result;
|
|
113
|
+
} catch (error) {
|
|
114
|
+
scope.active = false;
|
|
115
|
+
try {
|
|
116
|
+
this.database.exec("ROLLBACK");
|
|
117
|
+
} catch (rollbackError) {
|
|
118
|
+
throw new AggregateError([error, rollbackError], "SQLite transaction failed and rollback failed");
|
|
119
|
+
}
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
close() {
|
|
125
|
+
return this.access.run(() => {
|
|
126
|
+
if (this.closed) return;
|
|
127
|
+
this.closed = true;
|
|
128
|
+
this.statements.clear();
|
|
129
|
+
try {
|
|
130
|
+
this.database.exec("PRAGMA wal_checkpoint(TRUNCATE)");
|
|
131
|
+
} finally {
|
|
132
|
+
this.database.close();
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
runOperation(operation) {
|
|
137
|
+
return this.access.run(operation);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
/** Open and configure a Node-backed SQLite database facade. */
|
|
141
|
+
async function openNodeSqliteDatabase(path, options = {}) {
|
|
142
|
+
const checkpointPages = options.walAutoCheckpointPages ?? DEFAULT_WAL_AUTO_CHECKPOINT_PAGES;
|
|
143
|
+
const timeout = options.busyTimeoutMs ?? DEFAULT_BUSY_TIMEOUT_MS;
|
|
144
|
+
if (path !== ":memory:") await mkdir(dirname(path), { recursive: true });
|
|
145
|
+
const adapter = new NodeSqliteDatabase(new DatabaseSync(path, { timeout }));
|
|
146
|
+
try {
|
|
147
|
+
await adapter.exec("PRAGMA journal_mode = WAL");
|
|
148
|
+
await adapter.exec("PRAGMA synchronous = NORMAL");
|
|
149
|
+
await adapter.exec(`PRAGMA wal_autocheckpoint = ${checkpointPages}`);
|
|
150
|
+
return adapter;
|
|
151
|
+
} catch (error) {
|
|
152
|
+
try {
|
|
153
|
+
await adapter.close();
|
|
154
|
+
} catch {}
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region ../../../plugins/db-sqlite/src/open.ts
|
|
160
|
+
/**
|
|
161
|
+
* The plain way to open the SQLite provider, for code without Cordis (an acrylblends app): `openDb({ path, migrations })` opens one
|
|
162
|
+
* `node:sqlite` file with the ported facade's settings (WAL, `synchronous = NORMAL`, a busy timeout) and foreign keys enforced, applies the
|
|
163
|
+
* numbered migrations, and resolves the `db` port with the function that closes it. The Cordis plugin is a thin wrapper over this, so both
|
|
164
|
+
* run one code path.
|
|
165
|
+
* This entry imports nothing from Cordis.
|
|
166
|
+
*/
|
|
167
|
+
/**
|
|
168
|
+
* Open, configure and migrate a SQLite database.
|
|
169
|
+
* @throws when the migration files are misnamed or misnumbered, or a migration fails (the file is closed, and unchanged), or the
|
|
170
|
+
* database's schema is newer than the migrations.
|
|
171
|
+
*/
|
|
172
|
+
async function openDb(options) {
|
|
173
|
+
const migrations = options.migrations === void 0 ? [] : await readMigrationFiles(options.migrations);
|
|
174
|
+
const database = await openNodeSqliteDatabase(options.path, {
|
|
175
|
+
...options.busyTimeoutMs === void 0 ? {} : { busyTimeoutMs: options.busyTimeoutMs },
|
|
176
|
+
...options.walAutoCheckpointPages === void 0 ? {} : { walAutoCheckpointPages: options.walAutoCheckpointPages }
|
|
177
|
+
});
|
|
178
|
+
try {
|
|
179
|
+
await database.exec("PRAGMA foreign_keys = ON");
|
|
180
|
+
await applyMigrations(database, migrations, { table: MIGRATIONS_TABLE });
|
|
181
|
+
} catch (error) {
|
|
182
|
+
await database.close();
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
db: {
|
|
187
|
+
exec: (sql) => database.exec(sql),
|
|
188
|
+
run: (sql, ...params) => database.run(sql, ...params),
|
|
189
|
+
get: (sql, ...params) => database.get(sql, ...params),
|
|
190
|
+
all: (sql, ...params) => database.all(sql, ...params),
|
|
191
|
+
transaction: (work) => database.transaction(work)
|
|
192
|
+
},
|
|
193
|
+
close: () => database.close()
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
//#endregion
|
|
197
|
+
export { NodeSqliteDatabase as n, openNodeSqliteDatabase as r, openDb as t };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { t as Db } from "./database-CyKvumAn.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../../plugins/db-sqlite/src/open.d.ts
|
|
4
|
+
interface OpenDbOptions {
|
|
5
|
+
/** The database file, its folder created if missing; `:memory:` for a database that lives until `close`. */
|
|
6
|
+
readonly path: string;
|
|
7
|
+
/** A folder of `NNN-name.sql` files numbered from 1, as a path or a file URL, applied in order before `openDb` resolves. */
|
|
8
|
+
readonly migrations?: string | URL;
|
|
9
|
+
/** How long SQLite waits for a competing file lock, in milliseconds. Defaults to 5000. */
|
|
10
|
+
readonly busyTimeoutMs?: number;
|
|
11
|
+
/** The WAL auto-checkpoint threshold in pages; 0 disables it. Defaults to 1000. */
|
|
12
|
+
readonly walAutoCheckpointPages?: number;
|
|
13
|
+
}
|
|
14
|
+
/** An open database: the port, and the one function that closes it. */
|
|
15
|
+
interface OpenDb {
|
|
16
|
+
readonly db: Db;
|
|
17
|
+
/** Waits for running operations and transactions, checkpoints the WAL and releases the file. Calling it again does nothing. */
|
|
18
|
+
close(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Open, configure and migrate a SQLite database.
|
|
22
|
+
* @throws when the migration files are misnamed or misnumbered, or a migration fails (the file is closed, and unchanged), or the
|
|
23
|
+
* database's schema is newer than the migrations.
|
|
24
|
+
*/
|
|
25
|
+
declare function openDb(options: OpenDbOptions): Promise<OpenDb>;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { OpenDbOptions as n, openDb as r, OpenDb as t };
|