acrylblends 1.0.4 → 1.0.6
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/docs/framework/agents/index.md +7 -5
- package/lib/accept-CNNHu4Cf.js +193 -0
- package/lib/{accepts-XBuZPVRI.js → accepts-Btq83xPd.js} +1 -1
- package/lib/accepts.js +1 -1
- package/lib/acryl-base.js +1 -331
- package/lib/adapter-CaZ6FZUU.js +37 -0
- package/lib/adapter.js +1 -36
- package/lib/{app-BM0rTCp7.js → app-CQcGWjrk.js} +4 -4
- package/lib/app-base-CpRMZL4v.js +332 -0
- package/lib/{audit-D5z9uwOP.d.ts → audit-GcLtvNLV.d.ts} +4 -2
- package/lib/{base-NSN_SNv-.js → base-D_6kfOr-.js} +1 -1
- package/lib/basic-auth-C0HTRpXh.js +20 -0
- package/lib/basic-auth-DFLflXNe.js +95 -0
- package/lib/basic-auth.js +1 -94
- package/lib/bearer-auth-Cwxt-vgS.js +94 -0
- package/lib/bearer-auth.js +1 -93
- package/lib/body-D7f4e7w_.js +94 -0
- package/lib/body-limit-WmIjWRLt.js +66 -0
- package/lib/body-limit.js +1 -65
- package/lib/buffer-CkEOJCcY.js +51 -0
- package/lib/bun.js +3 -3
- package/lib/cache-B0bHH7s5.js +169 -0
- package/lib/cache.js +1 -168
- package/lib/{client-DDLXwhBo.js → client-BrMFnMEd.js} +1 -1
- package/lib/{client-modules-CLvWOjbd.js → client-modules-drj4mjhj.js} +4 -4
- package/lib/client.js +1 -1
- package/lib/color-COa3DplO.js +37 -0
- package/lib/combine-TWuGdcbC.js +137 -0
- package/lib/combine.js +1 -136
- package/lib/{components-cEW3ovK0.js → components-B2ka9Ax1.js} +4 -4
- package/lib/{components-JXVm45kK.js → components-PVXwaOaC.js} +2 -2
- package/lib/compress-BzWqsHF1.js +79 -0
- package/lib/compress-C-9vK4B2.d.ts +11 -0
- package/lib/compress-DCyrrQ5D.js +11 -0
- package/lib/compress.d.ts +1 -1
- package/lib/compress.js +2 -78
- package/lib/concurrent-DrF3d2c-.js +30 -0
- package/lib/conninfo-BCROmdnf.d.ts +11 -0
- package/lib/conninfo-CWJwieh4.js +19 -0
- package/lib/constants-CBSEudrb.js +7 -0
- package/lib/{context-DDO0cfuP.js → context-CkOh7Ygv.js} +2 -2
- package/lib/context-storage-iuPoI_CR.js +52 -0
- package/lib/context-storage.js +1 -51
- package/lib/cookie-B1LlkzOe.js +125 -0
- package/lib/cookie-BHIduy2T.js +82 -0
- package/lib/cookie.js +1 -81
- package/lib/cordis/db-sqlite.d.ts +1 -1
- package/lib/cordis/door.d.ts +99 -5
- package/lib/cordis/door.js +562 -20
- package/lib/cordis/inspect.js +4 -4
- package/lib/cordis/kv-db.d.ts +1 -1
- package/lib/cordis/kv-db.js +1 -1
- package/lib/cordis/kv-json.d.ts +1 -1
- package/lib/cordis/kv-json.js +1 -1
- package/lib/cordis/node-server.d.ts +1 -1
- package/lib/cordis/node-server.js +3 -116
- package/lib/cordis/router-http.js +2 -2
- package/lib/cordis/router.js +4 -4
- package/lib/cordis/state.js +7 -7
- package/lib/{core-CaY8XDZ6.js → core-BOu1jYua.js} +1 -1
- package/lib/cors-CbAQ-8qU.js +106 -0
- package/lib/cors.js +1 -105
- package/lib/crypto-iVP-N-tS.js +34 -0
- package/lib/csrf-DqqOZtgy.js +101 -0
- package/lib/csrf.js +1 -100
- package/lib/css-C5CPVMvM.js +134 -0
- package/lib/css.js +2 -133
- package/lib/db/sqlite.d.ts +1 -25
- package/lib/dev-CLgu-JRe.js +50 -0
- package/lib/dev.js +1 -49
- package/lib/dom-YjND9Jt3.js +74 -0
- package/lib/door/host.d.ts +2 -2
- package/lib/door/host.js +1 -1
- package/lib/door/page.d.ts +3 -1
- package/lib/door/page.js +2 -2
- package/lib/door/protocol.d.ts +1 -1
- package/lib/door/protocol.js +1 -212
- package/lib/encode-BhbNLrjp.js +33 -0
- package/lib/factory-CLdSf-xS.js +30 -0
- package/lib/factory.js +1 -29
- package/lib/handler-C0wZ0KwO.js +12 -0
- package/lib/helpers-BEjcdbgw.js +5 -0
- package/lib/{hooks-w72iLeFR.js → hooks-CfC07ri0.js} +1 -1
- package/lib/html-CgNa89xw.js +31 -0
- package/lib/html-DGExBFNg.js +103 -0
- package/lib/html.d.ts +2 -5
- package/lib/html.js +2 -30
- package/lib/http-exception-MjWkT89V.js +54 -0
- package/lib/http-exception.js +1 -53
- package/lib/index-dAzQsJG9.d.ts +6 -0
- package/lib/index.js +3 -3
- package/lib/ip-restriction-jKtKCRM_.js +166 -0
- package/lib/ip-restriction.js +1 -165
- package/lib/ipaddr-DCoIo528.js +238 -0
- package/lib/jsx/dom/client.js +1 -1
- package/lib/jsx/dom/jsx-dev-runtime.js +1 -1
- package/lib/jsx/dom/jsx-runtime.js +2 -1
- package/lib/jsx/dom/server.js +3 -3
- package/lib/jsx/dom.js +5 -73
- package/lib/jsx/jsx-dev-runtime.d.ts +2 -5
- package/lib/jsx/jsx-dev-runtime.js +2 -13
- package/lib/jsx/jsx-runtime.d.ts +2 -2
- package/lib/jsx/jsx-runtime.js +4 -4
- package/lib/jsx/streaming.js +1 -1
- package/lib/jsx-CUQgttxU.js +47 -0
- package/lib/jsx-dev-runtime-B4WTyq8r.js +14 -0
- package/lib/{jsx-dev-runtime-CWLRA2F3.js → jsx-dev-runtime-BLfA-EhI.js} +2 -2
- package/lib/jsx-dev-runtime-CGt4kNYr.d.ts +6 -0
- package/lib/jsx-renderer-CfifM4hT.js +99 -0
- package/lib/jsx-renderer.js +1 -98
- package/lib/jsx-runtime-COCRWBJ9.js +2 -0
- package/lib/jsx.js +5 -46
- package/lib/{jwk-LkzeoaU8.js → jwk-CDPpYQpD.js} +3 -3
- package/lib/jwk.js +1 -1
- package/lib/{jwt-BGJBw5AF.js → jwt-BXoIA2fQ.js} +2 -2
- package/lib/{jwt-CskdhEW9.js → jwt-lyS4Q3mT.js} +3 -3
- package/lib/jwt.js +2 -2
- package/lib/kv/db.d.ts +1 -10
- package/lib/kv/db.js +1 -56
- package/lib/kv/json.d.ts +1 -9
- package/lib/kv/json.js +1 -223
- package/lib/{language-D9a4zqvn.js → language-DeGRtLJt.js} +2 -2
- package/lib/language.js +1 -1
- package/lib/{linear-router-C3FPib6h.js → linear-router-CmZn_JLV.js} +2 -2
- package/lib/logger-Ckxu8diz.js +54 -0
- package/lib/logger.js +1 -53
- package/lib/loopback-only-BbasoF7R.js +90 -0
- package/lib/loopback-only.js +1 -89
- package/lib/method-not-allowed-TO2_hnfl.js +82 -0
- package/lib/method-not-allowed.js +1 -81
- package/lib/method-override-DnZKfJbV.js +103 -0
- package/lib/method-override.js +1 -102
- package/lib/middleware-BfG_fp8P.js +12 -0
- package/lib/mime-BnScXkQn.js +77 -0
- package/lib/mount-QkK_3NtJ.js +67 -0
- package/lib/mount.js +1 -66
- package/lib/node-server/conninfo.d.ts +1 -10
- package/lib/node-server/conninfo.js +1 -18
- package/lib/node-server/register.js +25 -2
- package/lib/node-server/serve-static.d.ts +1 -17
- package/lib/node-server/serve-static.js +1 -1
- package/lib/node-server.d.ts +2 -2
- package/lib/node-server.js +4 -4
- package/lib/open-BqK4D2Wn.d.ts +11 -0
- package/lib/open-But9E2rL.js +57 -0
- package/lib/open-CULVJgOc.d.ts +12 -0
- package/lib/open-Dp4sxspc.js +224 -0
- package/lib/open-T7kgbO2O.d.ts +27 -0
- package/lib/{pattern-router-HZxjDGEQ.js → pattern-router-CJBecJBd.js} +1 -1
- package/lib/powered-by-CXQNjNIX.js +24 -0
- package/lib/powered-by.js +1 -23
- package/lib/pretty-json-CeC1yvYt.js +39 -0
- package/lib/pretty-json.js +1 -38
- package/lib/{protocol-C37gPePD.d.ts → protocol-CR31M7K_.d.ts} +2 -0
- package/lib/protocol-Dt0AZBOz.js +213 -0
- package/lib/proxy-C2w_mH7k.js +121 -0
- package/lib/proxy.js +1 -120
- package/lib/quick.js +4 -4
- package/lib/{reg-exp-router-DC1R3qoY.js → reg-exp-router-C_WV84eV.js} +2 -2
- package/lib/request-DvMgGtlW.js +323 -0
- package/lib/request.js +1 -322
- package/lib/route-D8m-a2I1.js +126 -0
- package/lib/route.js +1 -125
- package/lib/router/linear-router.js +1 -1
- package/lib/router/pattern-router.js +1 -1
- package/lib/router/reg-exp-router.js +1 -1
- package/lib/router/smart-router.js +1 -1
- package/lib/router/trie-router.js +1 -1
- package/lib/router-Be_o6nFu.js +35 -0
- package/lib/router.js +1 -34
- package/lib/schema-validator-EK3cUUCt.js +22 -0
- package/lib/schema-validator.js +1 -21
- package/lib/{secure-headers-mP3j6Hm6.js → secure-headers-C5ZOcXqk.js} +1 -1
- package/lib/secure-headers.js +1 -1
- package/lib/serve-static-B7sqnftW.d.ts +18 -0
- package/lib/{serve-static-3uo_9rjF.js → serve-static-C1Nkj_xB.js} +2 -2
- package/lib/{serve-static-Cp5adzGo.js → serve-static-EiJf1zkO.js} +4 -4
- package/lib/serve-static.js +1 -1
- package/lib/{smart-router-C5CZ5XSM.js → smart-router-BjxkDQCE.js} +1 -1
- package/lib/{snapshot-text-BLz8nlSc.js → snapshot-text-CtQm3n8n.js} +23 -14
- package/lib/{src-dy3Fk9tA.js → src-BTBm4OPD.js} +6 -6
- package/lib/src-LX0E4ec4.js +117 -0
- package/lib/{ssg-BwjcA-Ge.js → ssg-BEl7MHqg.js} +5 -5
- package/lib/ssg.js +1 -1
- package/lib/stream-CzM_SHkq.js +88 -0
- package/lib/{streaming-DHST3Scg.js → streaming-BlDaph8U.js} +3 -3
- package/lib/streaming.js +1 -1
- package/lib/{test-websocket-D8WWqE5G.js → test-websocket-BLeEvybj.js} +2 -2
- package/lib/testing-BQx5T_UX.js +17 -0
- package/lib/testing.js +1 -16
- package/lib/timeout-FeqZ9A-0.js +42 -0
- package/lib/timeout.js +1 -41
- package/lib/tiny.js +2 -2
- package/lib/trailing-slash-DwTx-1sk.js +85 -0
- package/lib/trailing-slash.js +1 -84
- package/lib/{trie-router-CfFbapzL.js → trie-router-JydLKUa2.js} +2 -2
- package/lib/url-BPh4d6j-.js +197 -0
- package/lib/utils/accept.js +1 -192
- package/lib/utils/basic-auth.js +1 -19
- package/lib/utils/body.js +1 -93
- package/lib/utils/buffer.js +1 -50
- package/lib/utils/color.js +1 -36
- package/lib/utils/compress.d.ts +1 -10
- package/lib/utils/compress.js +1 -10
- package/lib/utils/concurrent.js +1 -29
- package/lib/utils/constants.js +1 -6
- package/lib/utils/cookie.js +1 -124
- package/lib/utils/crypto.js +1 -33
- package/lib/utils/encode.js +1 -32
- package/lib/utils/handler.js +1 -11
- package/lib/utils/html.js +1 -102
- package/lib/utils/ipaddr.js +1 -237
- package/lib/utils/jwt.js +1 -1
- package/lib/utils/mime.js +1 -76
- package/lib/utils/stream.js +1 -87
- package/lib/utils/url.js +1 -196
- package/lib/{validator-D84mq-dO.js → validator-Btiyt5VJ.js} +3 -3
- package/lib/validator.js +1 -1
- package/lib/websocket-DsyBIKVA.js +56 -0
- package/lib/ws.js +1 -55
- package/package.json +1 -1
- package/plugins/acryl-door/src/cli/acryl.ts +36 -5
- package/plugins/acryl-door/src/host/channel.ts +14 -6
- package/plugins/acryl-door/src/host/chat-tools.ts +2 -0
- package/plugins/acryl-door/src/host/door.ts +97 -12
- package/plugins/acryl-door/src/host/page-routes.ts +3 -1
- package/plugins/acryl-door/src/host/shell.ts +147 -0
- package/plugins/acryl-door/src/host/shim.ts +39 -3
- package/plugins/acryl-door/src/host/verbs.ts +39 -2
- package/plugins/acryl-door/src/index.ts +22 -3
- package/plugins/acryl-door/src/page/channel.ts +3 -1
- package/plugins/acryl-door/src/page/index.ts +2 -1
- package/plugins/acryl-door/src/page/protocol.ts +2 -0
- package/plugins/acryl-door/src/shell/protocol.ts +130 -0
- package/plugins/acryl-node-server/src/register.ts +29 -2
- package/plugins/agent/model.ts +6 -1
- package/plugins/agent/tools.ts +12 -2
- package/plugins/agent-panel/client/describe.ts +44 -0
- package/plugins/agent-panel/client/main.ts +4 -1
- package/plugins/agent-panel/headless.ts +29 -8
- package/plugins/agent-panel/index.ts +22 -10
- package/plugins/agent-panel/launch.ts +67 -0
- package/plugins/desktop/attach.ts +72 -0
- package/plugins/desktop/door-shell.ts +379 -0
- package/plugins/desktop/main.ts +82 -15
- package/plugins/extensions/index.ts +3 -4
- package/plugins/extensions/stage.ts +33 -5
- package/plugins/openai/index.ts +1 -1
- package/templates/agent/AGENTS.md +4 -0
- package/templates/agent/blend.yaml +4 -1
- package/templates/agent/src/app.ts +2 -0
- package/templates/agent/src/routes.ts +1 -1
- package/templates/agent/template.json +1 -0
- package/templates/agent/test/builder.test.ts +26 -21
- package/lib/helpers-CvTauQT5.js +0 -5
- package/lib/middleware-CPQ8himN.js +0 -12
- package/plugins/acryl-router/src/connection.d.ts +0 -25
- package/plugins/acryl-router/src/core/app-base.d.ts +0 -215
- package/plugins/acryl-router/src/core/app.d.ts +0 -19
- package/plugins/acryl-router/src/core/client/client.d.ts +0 -4
- package/plugins/acryl-router/src/core/client/fetch-result-please.d.ts +0 -35
- package/plugins/acryl-router/src/core/client/index.d.ts +0 -7
- package/plugins/acryl-router/src/core/client/types.d.ts +0 -229
- package/plugins/acryl-router/src/core/client/utils.d.ts +0 -18
- package/plugins/acryl-router/src/core/compose.d.ts +0 -14
- package/plugins/acryl-router/src/core/context.d.ts +0 -443
- package/plugins/acryl-router/src/core/helper/accepts/accepts.d.ts +0 -30
- package/plugins/acryl-router/src/core/helper/accepts/index.d.ts +0 -5
- package/plugins/acryl-router/src/core/helper/conninfo/index.d.ts +0 -5
- package/plugins/acryl-router/src/core/helper/conninfo/types.d.ts +0 -36
- package/plugins/acryl-router/src/core/helper/cookie/index.d.ts +0 -25
- package/plugins/acryl-router/src/core/helper/css/common.d.ts +0 -59
- package/plugins/acryl-router/src/core/helper/css/index.d.ts +0 -80
- package/plugins/acryl-router/src/core/helper/dev/index.d.ts +0 -20
- package/plugins/acryl-router/src/core/helper/factory/index.d.ts +0 -82
- package/plugins/acryl-router/src/core/helper/html/index.d.ts +0 -8
- package/plugins/acryl-router/src/core/helper/proxy/index.d.ts +0 -73
- package/plugins/acryl-router/src/core/helper/route/index.d.ts +0 -75
- package/plugins/acryl-router/src/core/helper/ssg/index.d.ts +0 -7
- package/plugins/acryl-router/src/core/helper/ssg/middleware.d.ts +0 -44
- package/plugins/acryl-router/src/core/helper/ssg/plugins.d.ts +0 -27
- package/plugins/acryl-router/src/core/helper/ssg/ssg.d.ts +0 -91
- package/plugins/acryl-router/src/core/helper/ssg/utils.d.ts +0 -16
- package/plugins/acryl-router/src/core/helper/streaming/index.d.ts +0 -8
- package/plugins/acryl-router/src/core/helper/streaming/sse.d.ts +0 -13
- package/plugins/acryl-router/src/core/helper/streaming/stream.d.ts +0 -3
- package/plugins/acryl-router/src/core/helper/streaming/text.d.ts +0 -3
- package/plugins/acryl-router/src/core/helper/streaming/utils.d.ts +0 -1
- package/plugins/acryl-router/src/core/helper/testing/index.d.ts +0 -13
- package/plugins/acryl-router/src/core/helper/websocket/index.d.ts +0 -70
- package/plugins/acryl-router/src/core/http-exception.d.ts +0 -58
- package/plugins/acryl-router/src/core/index.d.ts +0 -37
- package/plugins/acryl-router/src/core/jsx/base.d.ts +0 -61
- package/plugins/acryl-router/src/core/jsx/children.d.ts +0 -9
- package/plugins/acryl-router/src/core/jsx/components.d.ts +0 -15
- package/plugins/acryl-router/src/core/jsx/constants.d.ts +0 -6
- package/plugins/acryl-router/src/core/jsx/context.d.ts +0 -51
- package/plugins/acryl-router/src/core/jsx/dom/components.d.ts +0 -10
- package/plugins/acryl-router/src/core/jsx/dom/context.d.ts +0 -3
- package/plugins/acryl-router/src/core/jsx/dom/css.d.ts +0 -83
- package/plugins/acryl-router/src/core/jsx/dom/hooks/index.d.ts +0 -39
- package/plugins/acryl-router/src/core/jsx/dom/intrinsic-element/components.d.ts +0 -16
- package/plugins/acryl-router/src/core/jsx/dom/jsx-dev-runtime.d.ts +0 -8
- package/plugins/acryl-router/src/core/jsx/dom/jsx-runtime.d.ts +0 -7
- package/plugins/acryl-router/src/core/jsx/dom/render.d.ts +0 -73
- package/plugins/acryl-router/src/core/jsx/dom/utils.d.ts +0 -1
- package/plugins/acryl-router/src/core/jsx/hooks/index.d.ts +0 -47
- package/plugins/acryl-router/src/core/jsx/index.d.ts +0 -76
- package/plugins/acryl-router/src/core/jsx/intrinsic-element/common.d.ts +0 -6
- package/plugins/acryl-router/src/core/jsx/intrinsic-element/components.d.ts +0 -13
- package/plugins/acryl-router/src/core/jsx/intrinsic-elements.d.ts +0 -735
- package/plugins/acryl-router/src/core/jsx/streaming.d.ts +0 -36
- package/plugins/acryl-router/src/core/jsx/types.d.ts +0 -36
- package/plugins/acryl-router/src/core/jsx/utils.d.ts +0 -4
- package/plugins/acryl-router/src/core/request/constants.d.ts +0 -1
- package/plugins/acryl-router/src/core/request.d.ts +0 -306
- package/plugins/acryl-router/src/core/router/reg-exp-router/index.d.ts +0 -6
- package/plugins/acryl-router/src/core/router/reg-exp-router/matcher.d.ts +0 -7
- package/plugins/acryl-router/src/core/router/reg-exp-router/node.d.ts +0 -13
- package/plugins/acryl-router/src/core/router/reg-exp-router/prepared-router.d.ts +0 -17
- package/plugins/acryl-router/src/core/router/reg-exp-router/router.d.ts +0 -11
- package/plugins/acryl-router/src/core/router/reg-exp-router/trie.d.ts +0 -8
- package/plugins/acryl-router/src/core/router/smart-router/index.d.ts +0 -5
- package/plugins/acryl-router/src/core/router/smart-router/router.d.ts +0 -11
- package/plugins/acryl-router/src/core/router/trie-router/index.d.ts +0 -5
- package/plugins/acryl-router/src/core/router/trie-router/node.d.ts +0 -6
- package/plugins/acryl-router/src/core/router/trie-router/router.d.ts +0 -7
- package/plugins/acryl-router/src/core/router/utils.d.ts +0 -1
- package/plugins/acryl-router/src/core/router.d.ts +0 -97
- package/plugins/acryl-router/src/core/types.d.ts +0 -573
- package/plugins/acryl-router/src/core/utils/accept.d.ts +0 -6
- package/plugins/acryl-router/src/core/utils/body.d.ts +0 -79
- package/plugins/acryl-router/src/core/utils/buffer.d.ts +0 -17
- package/plugins/acryl-router/src/core/utils/color.d.ts +0 -21
- package/plugins/acryl-router/src/core/utils/concurrent.d.ts +0 -11
- package/plugins/acryl-router/src/core/utils/constants.d.ts +0 -4
- package/plugins/acryl-router/src/core/utils/cookie.d.ts +0 -41
- package/plugins/acryl-router/src/core/utils/crypto.d.ts +0 -15
- package/plugins/acryl-router/src/core/utils/handler.d.ts +0 -6
- package/plugins/acryl-router/src/core/utils/headers.d.ts +0 -8
- package/plugins/acryl-router/src/core/utils/html.d.ts +0 -44
- package/plugins/acryl-router/src/core/utils/http-status.d.ts +0 -32
- package/plugins/acryl-router/src/core/utils/mime.d.ts +0 -70
- package/plugins/acryl-router/src/core/utils/stream.d.ts +0 -31
- package/plugins/acryl-router/src/core/utils/types.d.ts +0 -128
- package/plugins/acryl-router/src/core/utils/url.d.ts +0 -44
- package/plugins/acryl-router/src/core/validator/index.d.ts +0 -7
- package/plugins/acryl-router/src/core/validator/utils.d.ts +0 -29
- package/plugins/acryl-router/src/core/validator/validator.d.ts +0 -16
- package/plugins/acryl-router/src/helpers/index.d.ts +0 -17
- package/plugins/acryl-router/src/helpers/schema-validator.d.ts +0 -54
package/lib/door/protocol.js
CHANGED
|
@@ -1,213 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* The one shape of a door call, shared by the Host and the in-page driver (moved from `acryl-agent-control`, spec 041).
|
|
4
|
-
*
|
|
5
|
-
* The Host turns a verb's arguments into a {@link UiRequest}, sends it to the page over the channel, and gets a {@link UiResult} back.
|
|
6
|
-
* Everything crossing the channel is validated here once, so neither side trusts the other's JSON. The page imports this file too, so it
|
|
7
|
-
* lives with the page code and has no Node imports.
|
|
8
|
-
*/
|
|
9
|
-
/** The operations the driver performs on the page. */
|
|
10
|
-
const UI_OPS = [
|
|
11
|
-
"snapshot",
|
|
12
|
-
"click",
|
|
13
|
-
"type",
|
|
14
|
-
"select",
|
|
15
|
-
"press",
|
|
16
|
-
"scroll",
|
|
17
|
-
"wait",
|
|
18
|
-
"reload",
|
|
19
|
-
"navigate"
|
|
20
|
-
];
|
|
21
|
-
/** Operations that change the page, so each call needs approval. `snapshot`, `scroll` and `wait` only look. */
|
|
22
|
-
const MUTATING_OPS = [
|
|
23
|
-
"click",
|
|
24
|
-
"type",
|
|
25
|
-
"select",
|
|
26
|
-
"press",
|
|
27
|
-
"reload",
|
|
28
|
-
"navigate"
|
|
29
|
-
];
|
|
30
|
-
/** A place in the app to go to: a path on the page's own origin (`/demo`, `/notes?q=a#top`), never another site and never a `//host` address. */
|
|
31
|
-
const APP_PATH = /^\/(?![/\\])[^\0\\]{0,2000}$/u;
|
|
32
|
-
const MAX_TEXT_LENGTH = 1e4;
|
|
33
|
-
const MAX_WAIT_MS = 1e4;
|
|
34
|
-
const MAX_SNAPSHOT_NODES = 1e3;
|
|
35
|
-
const DEFAULT_SNAPSHOT_NODES = 300;
|
|
36
|
-
var UiControlError = class extends Error {
|
|
37
|
-
code;
|
|
38
|
-
constructor(code, message) {
|
|
39
|
-
super(message);
|
|
40
|
-
this.code = code;
|
|
41
|
-
this.name = "UiControlError";
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const KEYS = /^(?:[A-Za-z0-9]|Enter|Escape|Tab|Backspace|Delete|Space|Arrow(?:Up|Down|Left|Right)|Home|End|PageUp|PageDown)$/;
|
|
45
|
-
const REF = /^\d{1,9}\.\d{1,6}$/;
|
|
46
|
-
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
47
|
-
const invalid = (message) => {
|
|
48
|
-
throw new UiControlError("invalid", message);
|
|
49
|
-
};
|
|
50
|
-
function ref(value) {
|
|
51
|
-
if (typeof value !== "string" || !REF.test(value)) return invalid("ref must look like 3.17, from the latest snapshot");
|
|
52
|
-
return value;
|
|
53
|
-
}
|
|
54
|
-
function text(value, max = MAX_TEXT_LENGTH) {
|
|
55
|
-
if (typeof value !== "string" || value.length > max || value.includes("\0")) return invalid(`text must be a string of at most ${String(max)} characters`);
|
|
56
|
-
return value;
|
|
57
|
-
}
|
|
58
|
-
/** @param value - untrusted JSON. @throws UiControlError `invalid`. */
|
|
59
|
-
function parseUiRequest(value) {
|
|
60
|
-
if (!isRecord(value) || typeof value.op !== "string") return invalid("a call needs an op");
|
|
61
|
-
const op = value.op;
|
|
62
|
-
const only = (allowed) => {
|
|
63
|
-
const extra = Object.keys(value).find((key) => key !== "op" && !allowed.includes(key));
|
|
64
|
-
if (extra !== void 0) invalid(`unknown field ${extra}`);
|
|
65
|
-
};
|
|
66
|
-
switch (op) {
|
|
67
|
-
case "snapshot": {
|
|
68
|
-
only(["cursor", "maxNodes"]);
|
|
69
|
-
const cursor = value.cursor === void 0 ? void 0 : Number(value.cursor);
|
|
70
|
-
const maxNodes = value.maxNodes === void 0 ? void 0 : Number(value.maxNodes);
|
|
71
|
-
if (cursor !== void 0 && (!Number.isInteger(cursor) || cursor < 0) || maxNodes !== void 0 && (!Number.isInteger(maxNodes) || maxNodes < 1 || maxNodes > 1e3)) return invalid("cursor and maxNodes must be small positive integers");
|
|
72
|
-
return {
|
|
73
|
-
op,
|
|
74
|
-
...cursor === void 0 ? {} : { cursor },
|
|
75
|
-
...maxNodes === void 0 ? {} : { maxNodes }
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
case "click":
|
|
79
|
-
only(["ref"]);
|
|
80
|
-
return {
|
|
81
|
-
op,
|
|
82
|
-
ref: ref(value.ref)
|
|
83
|
-
};
|
|
84
|
-
case "type":
|
|
85
|
-
only([
|
|
86
|
-
"ref",
|
|
87
|
-
"text",
|
|
88
|
-
"submit",
|
|
89
|
-
"clear"
|
|
90
|
-
]);
|
|
91
|
-
if (value.submit !== void 0 && typeof value.submit !== "boolean" || value.clear !== void 0 && typeof value.clear !== "boolean") return invalid("submit and clear must be true or false");
|
|
92
|
-
return {
|
|
93
|
-
op,
|
|
94
|
-
ref: ref(value.ref),
|
|
95
|
-
text: text(value.text),
|
|
96
|
-
...value.submit === void 0 ? {} : { submit: value.submit },
|
|
97
|
-
...value.clear === void 0 ? {} : { clear: value.clear }
|
|
98
|
-
};
|
|
99
|
-
case "select":
|
|
100
|
-
only(["ref", "option"]);
|
|
101
|
-
return {
|
|
102
|
-
op,
|
|
103
|
-
ref: ref(value.ref),
|
|
104
|
-
option: text(value.option, 500)
|
|
105
|
-
};
|
|
106
|
-
case "press":
|
|
107
|
-
only(["key", "ref"]);
|
|
108
|
-
if (typeof value.key !== "string" || !KEYS.test(value.key)) return invalid("key must be a single character or a name such as Enter, Escape, Tab or ArrowDown");
|
|
109
|
-
return {
|
|
110
|
-
op,
|
|
111
|
-
key: value.key,
|
|
112
|
-
...value.ref === void 0 ? {} : { ref: ref(value.ref) }
|
|
113
|
-
};
|
|
114
|
-
case "scroll": {
|
|
115
|
-
only([
|
|
116
|
-
"direction",
|
|
117
|
-
"ref",
|
|
118
|
-
"amount"
|
|
119
|
-
]);
|
|
120
|
-
if (value.direction !== "up" && value.direction !== "down" && value.direction !== "left" && value.direction !== "right") return invalid("direction must be up, down, left or right");
|
|
121
|
-
const amount = value.amount === void 0 ? void 0 : Number(value.amount);
|
|
122
|
-
if (amount !== void 0 && (!Number.isFinite(amount) || amount <= 0 || amount > 1e4)) return invalid("amount must be between 1 and 10000 pixels");
|
|
123
|
-
return {
|
|
124
|
-
op,
|
|
125
|
-
direction: value.direction,
|
|
126
|
-
...value.ref === void 0 ? {} : { ref: ref(value.ref) },
|
|
127
|
-
...amount === void 0 ? {} : { amount }
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
case "wait": {
|
|
131
|
-
only([
|
|
132
|
-
"text",
|
|
133
|
-
"role",
|
|
134
|
-
"name",
|
|
135
|
-
"gone",
|
|
136
|
-
"timeoutMs"
|
|
137
|
-
]);
|
|
138
|
-
const timeoutMs = value.timeoutMs === void 0 ? void 0 : Number(value.timeoutMs);
|
|
139
|
-
if (timeoutMs !== void 0 && (!Number.isFinite(timeoutMs) || timeoutMs < 0 || timeoutMs > 1e4)) return invalid(`timeoutMs must be between 0 and ${String(MAX_WAIT_MS)}`);
|
|
140
|
-
if (value.gone !== void 0 && typeof value.gone !== "boolean") return invalid("gone must be true or false");
|
|
141
|
-
if (value.text === void 0 && value.role === void 0 && value.name === void 0) return invalid("wait needs text, or a role and name");
|
|
142
|
-
return {
|
|
143
|
-
op,
|
|
144
|
-
...value.text === void 0 ? {} : { text: text(value.text, 500) },
|
|
145
|
-
...value.role === void 0 ? {} : { role: text(value.role, 60) },
|
|
146
|
-
...value.name === void 0 ? {} : { name: text(value.name, 500) },
|
|
147
|
-
...value.gone === void 0 ? {} : { gone: value.gone },
|
|
148
|
-
...timeoutMs === void 0 ? {} : { timeoutMs }
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
case "reload":
|
|
152
|
-
only([]);
|
|
153
|
-
return { op };
|
|
154
|
-
case "navigate":
|
|
155
|
-
only(["path"]);
|
|
156
|
-
if (typeof value.path !== "string" || !APP_PATH.test(value.path)) return invalid("path must be a path of this app, such as /demo (it starts with one /, and names no other site)");
|
|
157
|
-
return {
|
|
158
|
-
op,
|
|
159
|
-
path: value.path
|
|
160
|
-
};
|
|
161
|
-
default: return invalid(`unknown op ${String(op)}`);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
/** @param text - one `call` event's data from the Host. @throws when it is not a well-formed call. */
|
|
165
|
-
function parseChannelToPage(text) {
|
|
166
|
-
const value = JSON.parse(text);
|
|
167
|
-
if (isRecord(value) && value.t === "call" && typeof value.id === "number" && Number.isSafeInteger(value.id)) return {
|
|
168
|
-
t: "call",
|
|
169
|
-
id: value.id,
|
|
170
|
-
request: parseUiRequest(value.request)
|
|
171
|
-
};
|
|
172
|
-
throw new UiControlError("invalid", "not a channel call");
|
|
173
|
-
}
|
|
174
|
-
/** Every code a {@link UiControlError} can carry, so a code read off the wire is validated, not cast. */
|
|
175
|
-
const UI_ERROR_CODES = [
|
|
176
|
-
"no-window",
|
|
177
|
-
"stale-ref",
|
|
178
|
-
"unknown-ref",
|
|
179
|
-
"sensitive",
|
|
180
|
-
"protected",
|
|
181
|
-
"not-actionable",
|
|
182
|
-
"not-found",
|
|
183
|
-
"killed",
|
|
184
|
-
"timeout",
|
|
185
|
-
"aborted",
|
|
186
|
-
"unloaded",
|
|
187
|
-
"disconnected",
|
|
188
|
-
"invalid"
|
|
189
|
-
];
|
|
190
|
-
/** A window id the page chose: short, printable, so it can travel in a query string and a log line. */
|
|
191
|
-
const WINDOW_ID = /^[A-Za-z0-9-]{1,80}$/u;
|
|
192
|
-
/** @param value - one parsed message from the page; null when it is not a well-formed message. */
|
|
193
|
-
function parseChannelToHost(value) {
|
|
194
|
-
if (!isRecord(value)) return null;
|
|
195
|
-
if (value.t === "focus" && typeof value.focused === "boolean") return {
|
|
196
|
-
t: "focus",
|
|
197
|
-
focused: value.focused
|
|
198
|
-
};
|
|
199
|
-
if (value.t === "result" && typeof value.id === "number" && isRecord(value.value)) return {
|
|
200
|
-
t: "result",
|
|
201
|
-
id: value.id,
|
|
202
|
-
value: value.value
|
|
203
|
-
};
|
|
204
|
-
if (value.t === "error" && typeof value.id === "number" && typeof value.message === "string" && UI_ERROR_CODES.includes(value.code)) return {
|
|
205
|
-
t: "error",
|
|
206
|
-
id: value.id,
|
|
207
|
-
code: value.code,
|
|
208
|
-
message: value.message.slice(0, 500)
|
|
209
|
-
};
|
|
210
|
-
return null;
|
|
211
|
-
}
|
|
212
|
-
//#endregion
|
|
1
|
+
import { a as MAX_WAIT_MS, c as UI_OPS, d as parseChannelToHost, f as parseChannelToPage, i as MAX_TEXT_LENGTH, l as UiControlError, n as DEFAULT_SNAPSHOT_NODES, o as MUTATING_OPS, p as parseUiRequest, r as MAX_SNAPSHOT_NODES, s as UI_ERROR_CODES, t as APP_PATH, u as WINDOW_ID } from "../protocol-Dt0AZBOz.js";
|
|
213
2
|
export { APP_PATH, DEFAULT_SNAPSHOT_NODES, MAX_SNAPSHOT_NODES, MAX_TEXT_LENGTH, MAX_WAIT_MS, MUTATING_OPS, UI_ERROR_CODES, UI_OPS, UiControlError, WINDOW_ID, parseChannelToHost, parseChannelToPage, parseUiRequest };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region ../../plugins/acryl-router/src/core/utils/encode.ts
|
|
2
|
+
/**
|
|
3
|
+
* @module
|
|
4
|
+
* Encode utility.
|
|
5
|
+
*/
|
|
6
|
+
const decodeBase64Url = (str) => {
|
|
7
|
+
return decodeBase64(str.replace(/_|-/g, (m) => ({
|
|
8
|
+
_: "/",
|
|
9
|
+
"-": "+"
|
|
10
|
+
})[m] ?? m));
|
|
11
|
+
};
|
|
12
|
+
const encodeBase64Url = (buf) => encodeBase64(buf).replace(/\/|\+/g, (m) => ({
|
|
13
|
+
"/": "_",
|
|
14
|
+
"+": "-"
|
|
15
|
+
})[m] ?? m);
|
|
16
|
+
const encodeBase64 = (buf) => {
|
|
17
|
+
let binary = "";
|
|
18
|
+
const bytes = new Uint8Array(buf);
|
|
19
|
+
for (let i = 0, len = bytes.length; i < len; i++) binary += String.fromCharCode(bytes[i]);
|
|
20
|
+
return btoa(binary);
|
|
21
|
+
};
|
|
22
|
+
const decodeBase64 = (str) => {
|
|
23
|
+
const binary = atob(str);
|
|
24
|
+
const bytes = new Uint8Array(new ArrayBuffer(binary.length));
|
|
25
|
+
const half = binary.length / 2;
|
|
26
|
+
for (let i = 0, j = binary.length - 1; i <= half; i++, j--) {
|
|
27
|
+
bytes[i] = binary.charCodeAt(i);
|
|
28
|
+
bytes[j] = binary.charCodeAt(j);
|
|
29
|
+
}
|
|
30
|
+
return bytes;
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { encodeBase64Url as i, decodeBase64Url as n, encodeBase64 as r, decodeBase64 as t };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { t as Acryl } from "./app-CQcGWjrk.js";
|
|
2
|
+
//#region ../../plugins/acryl-router/src/core/helper/factory/index.ts
|
|
3
|
+
/**
|
|
4
|
+
* @module
|
|
5
|
+
* Factory Helper for Acryl.
|
|
6
|
+
*/
|
|
7
|
+
var Factory = class {
|
|
8
|
+
initApp;
|
|
9
|
+
#defaultAppOptions;
|
|
10
|
+
constructor(init) {
|
|
11
|
+
this.initApp = init?.initApp;
|
|
12
|
+
this.#defaultAppOptions = init?.defaultAppOptions;
|
|
13
|
+
}
|
|
14
|
+
createApp = (options) => {
|
|
15
|
+
const app = new Acryl(options && this.#defaultAppOptions ? {
|
|
16
|
+
...this.#defaultAppOptions,
|
|
17
|
+
...options
|
|
18
|
+
} : options ?? this.#defaultAppOptions);
|
|
19
|
+
if (this.initApp) this.initApp(app);
|
|
20
|
+
return app;
|
|
21
|
+
};
|
|
22
|
+
createMiddleware = (middleware) => middleware;
|
|
23
|
+
createHandlers = (...handlers) => {
|
|
24
|
+
return handlers.filter((handler) => handler !== void 0);
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const createFactory = (init) => new Factory(init);
|
|
28
|
+
const createMiddleware = (middleware) => middleware;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { createFactory as n, createMiddleware as r, Factory as t };
|
package/lib/factory.js
CHANGED
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
//#region ../../plugins/acryl-router/src/core/helper/factory/index.ts
|
|
3
|
-
/**
|
|
4
|
-
* @module
|
|
5
|
-
* Factory Helper for Acryl.
|
|
6
|
-
*/
|
|
7
|
-
var Factory = class {
|
|
8
|
-
initApp;
|
|
9
|
-
#defaultAppOptions;
|
|
10
|
-
constructor(init) {
|
|
11
|
-
this.initApp = init?.initApp;
|
|
12
|
-
this.#defaultAppOptions = init?.defaultAppOptions;
|
|
13
|
-
}
|
|
14
|
-
createApp = (options) => {
|
|
15
|
-
const app = new Acryl(options && this.#defaultAppOptions ? {
|
|
16
|
-
...this.#defaultAppOptions,
|
|
17
|
-
...options
|
|
18
|
-
} : options ?? this.#defaultAppOptions);
|
|
19
|
-
if (this.initApp) this.initApp(app);
|
|
20
|
-
return app;
|
|
21
|
-
};
|
|
22
|
-
createMiddleware = (middleware) => middleware;
|
|
23
|
-
createHandlers = (...handlers) => {
|
|
24
|
-
return handlers.filter((handler) => handler !== void 0);
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
const createFactory = (init) => new Factory(init);
|
|
28
|
-
const createMiddleware = (middleware) => middleware;
|
|
29
|
-
//#endregion
|
|
1
|
+
import { n as createFactory, r as createMiddleware, t as Factory } from "./factory-CLdSf-xS.js";
|
|
30
2
|
export { Factory, createFactory, createMiddleware };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { t as COMPOSED_HANDLER } from "./constants-CBSEudrb.js";
|
|
2
|
+
//#region ../../plugins/acryl-router/src/core/utils/handler.ts
|
|
3
|
+
/**
|
|
4
|
+
* @module
|
|
5
|
+
* Handler utility.
|
|
6
|
+
*/
|
|
7
|
+
const isMiddleware = (handler) => handler.length > 1;
|
|
8
|
+
const findTargetHandler = (handler) => {
|
|
9
|
+
return handler["__COMPOSED_HANDLER"] ? findTargetHandler(handler[COMPOSED_HANDLER]) : handler;
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isMiddleware as n, findTargetHandler as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as createContext, E as useContext, T as globalContexts, _ as toArray, h as styleObjectForEach, m as normalizeIntrinsicElementKey } from "./base-
|
|
1
|
+
import { D as createContext, E as useContext, T as globalContexts, _ as toArray, h as styleObjectForEach, m as normalizeIntrinsicElementKey } from "./base-D_6kfOr-.js";
|
|
2
2
|
import { a as DOM_STASH, i as DOM_RENDERER, n as DOM_INTERNAL_TAG, r as DOM_MEMO, t as DOM_ERROR_HANDLER } from "./constants-BR9jM9BC.js";
|
|
3
3
|
//#region ../../plugins/acryl-router/src/core/jsx/dom/render.ts
|
|
4
4
|
const ACRYL_PORTAL_ELEMENT = "_hp";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { a as resolveCallbackSync, n as escapeToBuffer, o as stringBufferToString, r as raw } from "./html-DGExBFNg.js";
|
|
2
|
+
//#region ../../plugins/acryl-router/src/core/helper/html/index.ts
|
|
3
|
+
/**
|
|
4
|
+
* @module
|
|
5
|
+
* html Helper for Acryl.
|
|
6
|
+
*/
|
|
7
|
+
const html = (strings, ...values) => {
|
|
8
|
+
const buffer = [""];
|
|
9
|
+
for (let i = 0, len = strings.length - 1; i < len; i++) {
|
|
10
|
+
buffer[0] += strings[i];
|
|
11
|
+
const children = Array.isArray(values[i]) ? values[i].flat(Infinity) : [values[i]];
|
|
12
|
+
for (let i = 0, len = children.length; i < len; i++) {
|
|
13
|
+
const child = children[i];
|
|
14
|
+
if (typeof child === "string") escapeToBuffer(child, buffer);
|
|
15
|
+
else if (typeof child === "number") buffer[0] += child;
|
|
16
|
+
else if (typeof child === "boolean" || child === null || child === void 0) continue;
|
|
17
|
+
else if (typeof child === "object" && child.isEscaped) if (child.callbacks) buffer.unshift("", child);
|
|
18
|
+
else {
|
|
19
|
+
const tmp = child.toString();
|
|
20
|
+
if (tmp instanceof Promise) buffer.unshift("", tmp);
|
|
21
|
+
else buffer[0] += tmp;
|
|
22
|
+
}
|
|
23
|
+
else if (child instanceof Promise) buffer.unshift("", child);
|
|
24
|
+
else escapeToBuffer(child.toString(), buffer);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
buffer[0] += strings.at(-1);
|
|
28
|
+
return buffer.length === 1 ? "callbacks" in buffer ? raw(resolveCallbackSync(raw(buffer[0], buffer.callbacks))) : raw(buffer[0]) : stringBufferToString(buffer, buffer.callbacks);
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { html as t };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
//#region ../../plugins/acryl-router/src/core/utils/html.ts
|
|
2
|
+
/**
|
|
3
|
+
* @module
|
|
4
|
+
* HTML utility.
|
|
5
|
+
*/
|
|
6
|
+
const HtmlEscapedCallbackPhase = {
|
|
7
|
+
Stringify: 1,
|
|
8
|
+
BeforeStream: 2,
|
|
9
|
+
Stream: 3
|
|
10
|
+
};
|
|
11
|
+
const raw = (value, callbacks) => {
|
|
12
|
+
const escapedString = new String(value);
|
|
13
|
+
escapedString.isEscaped = true;
|
|
14
|
+
escapedString.callbacks = callbacks;
|
|
15
|
+
return escapedString;
|
|
16
|
+
};
|
|
17
|
+
const escapeRe = /[&<>'"]/;
|
|
18
|
+
const stringBufferToString = async (buffer, callbacks) => {
|
|
19
|
+
let str = "";
|
|
20
|
+
callbacks ||= [];
|
|
21
|
+
const resolvedBuffer = await Promise.all(buffer);
|
|
22
|
+
for (let i = resolvedBuffer.length - 1;; i--) {
|
|
23
|
+
str += resolvedBuffer[i];
|
|
24
|
+
i--;
|
|
25
|
+
if (i < 0) break;
|
|
26
|
+
let r = resolvedBuffer[i];
|
|
27
|
+
if (typeof r === "object") callbacks.push(...r.callbacks || []);
|
|
28
|
+
const isEscaped = r.isEscaped;
|
|
29
|
+
r = await (typeof r === "object" ? r.toString() : r);
|
|
30
|
+
if (typeof r === "object") callbacks.push(...r.callbacks || []);
|
|
31
|
+
if (r.isEscaped ?? isEscaped) str += r;
|
|
32
|
+
else {
|
|
33
|
+
const buf = [str];
|
|
34
|
+
escapeToBuffer(r, buf);
|
|
35
|
+
str = buf[0];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return raw(str, callbacks);
|
|
39
|
+
};
|
|
40
|
+
const escapeToBuffer = (str, buffer) => {
|
|
41
|
+
const match = str.search(escapeRe);
|
|
42
|
+
if (match === -1) {
|
|
43
|
+
buffer[0] += str;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
let escape;
|
|
47
|
+
let index;
|
|
48
|
+
let lastIndex = 0;
|
|
49
|
+
for (index = match; index < str.length; index++) {
|
|
50
|
+
switch (str.charCodeAt(index)) {
|
|
51
|
+
case 34:
|
|
52
|
+
escape = """;
|
|
53
|
+
break;
|
|
54
|
+
case 39:
|
|
55
|
+
escape = "'";
|
|
56
|
+
break;
|
|
57
|
+
case 38:
|
|
58
|
+
escape = "&";
|
|
59
|
+
break;
|
|
60
|
+
case 60:
|
|
61
|
+
escape = "<";
|
|
62
|
+
break;
|
|
63
|
+
case 62:
|
|
64
|
+
escape = ">";
|
|
65
|
+
break;
|
|
66
|
+
default: continue;
|
|
67
|
+
}
|
|
68
|
+
buffer[0] += str.substring(lastIndex, index) + escape;
|
|
69
|
+
lastIndex = index + 1;
|
|
70
|
+
}
|
|
71
|
+
buffer[0] += str.substring(lastIndex, index);
|
|
72
|
+
};
|
|
73
|
+
const resolveCallbackSync = (str) => {
|
|
74
|
+
const callbacks = str.callbacks;
|
|
75
|
+
if (!callbacks?.length) return str;
|
|
76
|
+
const buffer = [str];
|
|
77
|
+
const context = {};
|
|
78
|
+
callbacks.forEach((c) => c({
|
|
79
|
+
phase: HtmlEscapedCallbackPhase.Stringify,
|
|
80
|
+
buffer,
|
|
81
|
+
context
|
|
82
|
+
}));
|
|
83
|
+
return buffer[0];
|
|
84
|
+
};
|
|
85
|
+
const resolveCallback = async (str, phase, preserveCallbacks, context, buffer) => {
|
|
86
|
+
if (typeof str === "object" && !(str instanceof String)) {
|
|
87
|
+
if (!(str instanceof Promise)) str = str.toString();
|
|
88
|
+
if (str instanceof Promise) str = await str;
|
|
89
|
+
}
|
|
90
|
+
const callbacks = str.callbacks;
|
|
91
|
+
if (!callbacks?.length) return Promise.resolve(str);
|
|
92
|
+
if (buffer) buffer[0] += str;
|
|
93
|
+
else buffer = [str];
|
|
94
|
+
const resStr = Promise.all(callbacks.map((c) => c({
|
|
95
|
+
phase,
|
|
96
|
+
buffer,
|
|
97
|
+
context
|
|
98
|
+
}))).then((res) => Promise.all(res.filter(Boolean).map((str) => resolveCallback(str, phase, false, context, buffer))).then(() => buffer[0]));
|
|
99
|
+
if (preserveCallbacks) return raw(await resStr, callbacks);
|
|
100
|
+
else return resStr;
|
|
101
|
+
};
|
|
102
|
+
//#endregion
|
|
103
|
+
export { resolveCallbackSync as a, resolveCallback as i, escapeToBuffer as n, stringBufferToString as o, raw as r, HtmlEscapedCallbackPhase as t };
|
package/lib/html.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { c as raw
|
|
2
|
-
|
|
3
|
-
//#region ../../plugins/acryl-router/src/core/helper/html/index.d.ts
|
|
4
|
-
declare const html: (strings: TemplateStringsArray, ...values: unknown[]) => HtmlEscapedString | Promise<HtmlEscapedString>;
|
|
5
|
-
//#endregion
|
|
1
|
+
import { c as raw } from "./html-SllAe0YT.js";
|
|
2
|
+
import { t as html } from "./index-dAzQsJG9.js";
|
|
6
3
|
export { html, raw };
|
package/lib/html.js
CHANGED
|
@@ -1,31 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @module
|
|
5
|
-
* html Helper for Acryl.
|
|
6
|
-
*/
|
|
7
|
-
const html = (strings, ...values) => {
|
|
8
|
-
const buffer = [""];
|
|
9
|
-
for (let i = 0, len = strings.length - 1; i < len; i++) {
|
|
10
|
-
buffer[0] += strings[i];
|
|
11
|
-
const children = Array.isArray(values[i]) ? values[i].flat(Infinity) : [values[i]];
|
|
12
|
-
for (let i = 0, len = children.length; i < len; i++) {
|
|
13
|
-
const child = children[i];
|
|
14
|
-
if (typeof child === "string") escapeToBuffer(child, buffer);
|
|
15
|
-
else if (typeof child === "number") buffer[0] += child;
|
|
16
|
-
else if (typeof child === "boolean" || child === null || child === void 0) continue;
|
|
17
|
-
else if (typeof child === "object" && child.isEscaped) if (child.callbacks) buffer.unshift("", child);
|
|
18
|
-
else {
|
|
19
|
-
const tmp = child.toString();
|
|
20
|
-
if (tmp instanceof Promise) buffer.unshift("", tmp);
|
|
21
|
-
else buffer[0] += tmp;
|
|
22
|
-
}
|
|
23
|
-
else if (child instanceof Promise) buffer.unshift("", child);
|
|
24
|
-
else escapeToBuffer(child.toString(), buffer);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
buffer[0] += strings.at(-1);
|
|
28
|
-
return buffer.length === 1 ? "callbacks" in buffer ? raw(resolveCallbackSync(raw(buffer[0], buffer.callbacks))) : raw(buffer[0]) : stringBufferToString(buffer, buffer.callbacks);
|
|
29
|
-
};
|
|
30
|
-
//#endregion
|
|
1
|
+
import { r as raw } from "./html-DGExBFNg.js";
|
|
2
|
+
import { t as html } from "./html-CgNa89xw.js";
|
|
31
3
|
export { html, raw };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//#region ../../plugins/acryl-router/src/core/http-exception.ts
|
|
2
|
+
/**
|
|
3
|
+
* `HTTPException` must be used when a fatal error such as authentication failure occurs.
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* @param {StatusCode} status - status code of HTTPException
|
|
7
|
+
* @param {HTTPExceptionOptions} options - options of HTTPException
|
|
8
|
+
* @param {HTTPExceptionOptions["res"]} options.res - response of options of HTTPException
|
|
9
|
+
* @param {HTTPExceptionOptions["message"]} options.message - message of options of HTTPException
|
|
10
|
+
* @param {HTTPExceptionOptions["cause"]} options.cause - cause of options of HTTPException
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { HTTPException } from 'acrylblends/http-exception'
|
|
15
|
+
*
|
|
16
|
+
* // ...
|
|
17
|
+
*
|
|
18
|
+
* app.post('/auth', async (c, next) => {
|
|
19
|
+
* // authentication
|
|
20
|
+
* if (authorized === false) {
|
|
21
|
+
* throw new HTTPException(401, { message: 'Custom error message' })
|
|
22
|
+
* }
|
|
23
|
+
* await next()
|
|
24
|
+
* })
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
var HTTPException = class extends Error {
|
|
28
|
+
res;
|
|
29
|
+
status;
|
|
30
|
+
/**
|
|
31
|
+
* Creates an instance of `HTTPException`.
|
|
32
|
+
* @param status - HTTP status code for the exception. Defaults to 500.
|
|
33
|
+
* @param options - Additional options for the exception.
|
|
34
|
+
*/
|
|
35
|
+
constructor(status = 500, options) {
|
|
36
|
+
super(options?.message, { cause: options?.cause });
|
|
37
|
+
this.res = options?.res;
|
|
38
|
+
this.status = status;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Returns the response object associated with the exception.
|
|
42
|
+
* If a response object is not provided, a new response is created with the error message and status code.
|
|
43
|
+
* @returns The response object.
|
|
44
|
+
*/
|
|
45
|
+
getResponse() {
|
|
46
|
+
if (this.res) return new Response(this.res.body, {
|
|
47
|
+
status: this.status,
|
|
48
|
+
headers: this.res.headers
|
|
49
|
+
});
|
|
50
|
+
return new Response(this.message, { status: this.status });
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
//#endregion
|
|
54
|
+
export { HTTPException as t };
|
package/lib/http-exception.js
CHANGED
|
@@ -1,54 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* `HTTPException` must be used when a fatal error such as authentication failure occurs.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @param {StatusCode} status - status code of HTTPException
|
|
7
|
-
* @param {HTTPExceptionOptions} options - options of HTTPException
|
|
8
|
-
* @param {HTTPExceptionOptions["res"]} options.res - response of options of HTTPException
|
|
9
|
-
* @param {HTTPExceptionOptions["message"]} options.message - message of options of HTTPException
|
|
10
|
-
* @param {HTTPExceptionOptions["cause"]} options.cause - cause of options of HTTPException
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* import { HTTPException } from 'acrylblends/http-exception'
|
|
15
|
-
*
|
|
16
|
-
* // ...
|
|
17
|
-
*
|
|
18
|
-
* app.post('/auth', async (c, next) => {
|
|
19
|
-
* // authentication
|
|
20
|
-
* if (authorized === false) {
|
|
21
|
-
* throw new HTTPException(401, { message: 'Custom error message' })
|
|
22
|
-
* }
|
|
23
|
-
* await next()
|
|
24
|
-
* })
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
var HTTPException = class extends Error {
|
|
28
|
-
res;
|
|
29
|
-
status;
|
|
30
|
-
/**
|
|
31
|
-
* Creates an instance of `HTTPException`.
|
|
32
|
-
* @param status - HTTP status code for the exception. Defaults to 500.
|
|
33
|
-
* @param options - Additional options for the exception.
|
|
34
|
-
*/
|
|
35
|
-
constructor(status = 500, options) {
|
|
36
|
-
super(options?.message, { cause: options?.cause });
|
|
37
|
-
this.res = options?.res;
|
|
38
|
-
this.status = status;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Returns the response object associated with the exception.
|
|
42
|
-
* If a response object is not provided, a new response is created with the error message and status code.
|
|
43
|
-
* @returns The response object.
|
|
44
|
-
*/
|
|
45
|
-
getResponse() {
|
|
46
|
-
if (this.res) return new Response(this.res.body, {
|
|
47
|
-
status: this.status,
|
|
48
|
-
headers: this.res.headers
|
|
49
|
-
});
|
|
50
|
-
return new Response(this.message, { status: this.status });
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
//#endregion
|
|
1
|
+
import { t as HTTPException } from "./http-exception-MjWkT89V.js";
|
|
54
2
|
export { HTTPException };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { i as HtmlEscapedString } from "./html-SllAe0YT.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../plugins/acryl-router/src/core/helper/html/index.d.ts
|
|
4
|
+
declare const html: (strings: TemplateStringsArray, ...values: unknown[]) => HtmlEscapedString | Promise<HtmlEscapedString>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { html as t };
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Context } from "./context-
|
|
2
|
-
import { t as Acryl } from "./app-
|
|
3
|
-
import "./core-
|
|
1
|
+
import { t as Context } from "./context-CkOh7Ygv.js";
|
|
2
|
+
import { t as Acryl } from "./app-CQcGWjrk.js";
|
|
3
|
+
import "./core-BOu1jYua.js";
|
|
4
4
|
export { Acryl, Context };
|