@almadar/std 17.0.2 → 17.1.0
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/behaviors/lolo/auth/atoms/std-dev-personas.lolo +27 -2
- package/behaviors/lolo/cli/atoms/std-orb-goldens.lolo +6 -3
- package/behaviors/lolo/cli/atoms/std-orb-lint-mem-handles.lolo +54 -34
- package/behaviors/lolo/cli/atoms/std-orb-lint-os-grants.lolo +4 -4
- package/behaviors/lolo/cli/atoms/std-orb-mcp.lolo +16 -21
- package/behaviors/lolo/cli/atoms/std-orb-packages.lolo +26 -16
- package/behaviors/lolo/cli/atoms/std-orb-serve.lolo +24 -4
- package/behaviors/lolo/codec/atoms/std-lolo-kotlin.lolo +26 -3
- package/behaviors/lolo/codec/atoms/std-lolo-python.lolo +15 -2
- package/behaviors/lolo/codec/atoms/std-lolo-rust.lolo +27 -2
- package/behaviors/lolo/codec/atoms/std-lolo-source.lolo +251 -60
- package/behaviors/lolo/codec/atoms/std-lolo-swift.lolo +24 -1
- package/behaviors/lolo/codec/atoms/std-lolo-typescript.lolo +24 -3
- package/behaviors/lolo/connect/atoms/std-meta-ads.lolo +4 -4
- package/behaviors/lolo/connect/atoms/std-stdio-lines.lolo +7 -4
- package/behaviors/lolo/connect/atoms/std-youtube.lolo +9 -9
- package/behaviors/lolo/dev/atoms/std-guest-session.lolo +122 -10
- package/behaviors/lolo/dev/atoms/std-mock-seed-marks.lolo +66 -0
- package/behaviors/lolo/dev/organisms/std-behavior-playground.lolo +5 -2
- package/behaviors/lolo/dev/organisms/std-launchpad.lolo +4 -3
- package/behaviors/lolo/gpu/atoms/std-gpu-compute.lolo +329 -0
- package/behaviors/lolo/net/atoms/std-http-client.lolo +4 -4
- package/behaviors/lolo/net/atoms/std-http-fetch.lolo +6 -6
- package/behaviors/lolo/net/atoms/std-npm-lookup.lolo +1 -1
- package/behaviors/lolo/net/atoms/std-npm-registry.lolo +2 -2
- package/behaviors/lolo/spec/auth/dev-personas.replay.goldens.json +263 -2
- package/behaviors/lolo/spec/cli/lint-all.lolo +1 -0
- package/behaviors/lolo/spec/cli/lint-item-action-event.replay.goldens.json +9 -9
- package/behaviors/lolo/spec/cli/lint-mem-handles.replay.goldens.json +3021 -1
- package/behaviors/lolo/spec/cli/lint-os-grants.replay.goldens.json +284 -12
- package/behaviors/lolo/spec/cli/mcp-server.replay.goldens.json +51 -55
- package/behaviors/lolo/spec/cli/orb-compile.replay.goldens.json +10 -4
- package/behaviors/lolo/spec/cli/orb-packages.lolo +1 -1
- package/behaviors/lolo/spec/codec/lolo-kotlin.replay.goldens.json +7496 -7497
- package/behaviors/lolo/spec/codec/lolo-python.replay.goldens.json +341 -3
- package/behaviors/lolo/spec/codec/lolo-rust.replay.goldens.json +18931 -6142
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/compose-pair.lolo +44 -0
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/config-read.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/divide-default.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/divide-plain.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/get-past-end.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/list-call.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/list-plain.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/minus-binary.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/minus-unary.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/nested-let.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/no-machine.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/no-template.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/nth-past-end.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/nth-raw.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/ports-call.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/range-one.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/range-two.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/router-trio.lolo +88 -0
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/store-pair.lolo +62 -0
- package/behaviors/lolo/spec/codec/lolo-source.fixtures/string-literal.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.gen/knobs.py +27 -1
- package/behaviors/lolo/spec/codec/lolo-source.gen/src_assemble.in +54 -2
- package/behaviors/lolo/spec/codec/lolo-source.gen/src_finish.in +1 -1
- package/behaviors/lolo/spec/codec/lolo-source.gen/src_fold.in +24 -4
- package/behaviors/lolo/spec/codec/lolo-source.gen/src_head.in +8 -3
- package/behaviors/lolo/spec/codec/lolo-source.gen/src_prepare.in +6 -2
- package/behaviors/lolo/spec/codec/lolo-source.gen/src_trait.in +12 -2
- package/behaviors/lolo/spec/codec/lolo-source.parity/agent-step.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.parity/agent-step.server.lolo +1 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/chunk.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.parity/chunk.server.lolo +1 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/compose-pair.events.json +36 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/compose-pair.replay.goldens.json +91 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/cosine.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.parity/cosine.server.lolo +1 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/drivers/kotlin/compose-pair.kt +31 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/drivers/kotlin/router-trio.kt +31 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/drivers/kotlin/store-pair.kt +31 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/drivers/python/compose-pair.py +18 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/drivers/python/router-trio.py +18 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/drivers/python/store-pair.py +17 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/drivers/rust/compose-pair.rs +37 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/drivers/rust/router-trio.rs +37 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/drivers/rust/store-pair.rs +36 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/drivers/swift/compose-pair.swift +24 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/drivers/swift/router-trio.swift +24 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/drivers/swift/store-pair.swift +23 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/drivers/typescript/compose-pair.mts +24 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/drivers/typescript/router-trio.mts +24 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/drivers/typescript/store-pair.mts +22 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/recall-at-k.lolo +2 -1
- package/behaviors/lolo/spec/codec/lolo-source.parity/recall-at-k.server.lolo +1 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/router-trio.events.json +18 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/router-trio.replay.goldens.json +87 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/store-pair.events.json +58 -0
- package/behaviors/lolo/spec/codec/lolo-source.parity/store-pair.replay.goldens.json +238 -0
- package/behaviors/lolo/spec/codec/lolo-swift.replay.goldens.json +15599 -2204
- package/behaviors/lolo/spec/codec/lolo-typescript.replay.goldens.json +28930 -28929
- package/behaviors/lolo/spec/connect/bearer-api.replay.goldens.json +1 -1
- package/behaviors/lolo/spec/connect/esign.replay.goldens.json +3 -3
- package/behaviors/lolo/spec/connect/github.replay.goldens.json +13 -13
- package/behaviors/lolo/spec/connect/google-calendar.replay.goldens.json +2 -2
- package/behaviors/lolo/spec/connect/image.replay.goldens.json +1 -1
- package/behaviors/lolo/spec/connect/meta-ads.replay.goldens.json +2 -2
- package/behaviors/lolo/spec/connect/stdio-lines.replay.goldens.json +90 -0
- package/behaviors/lolo/spec/connect/twilio.replay.goldens.json +2 -2
- package/behaviors/lolo/spec/connect/youtube.replay.goldens.json +1 -1
- package/behaviors/lolo/spec/dev/guest-session.replay.goldens.json +824 -0
- package/behaviors/lolo/spec/dev/mock-seed-marks.replay.goldens.json +365 -0
- package/behaviors/lolo/spec/dev/verify-walk.replay.goldens.json +2 -1
- package/behaviors/lolo/spec/gpu/gpu-compute.replay.goldens.json +784 -0
- package/behaviors/lolo/spec/mem/mem-buffer.replay.goldens.json +97 -1
- package/behaviors/lolo/spec/ml/vector-write.goldens.json +1 -1
- package/behaviors/lolo/spec/ml/vector-write.replay.goldens.json +2 -2
- package/behaviors/lolo/spec/net/http-client-call-host.replay.goldens.json +3 -3
- package/behaviors/lolo/spec/net/http-client-env-host.replay.goldens.json +3 -3
- package/behaviors/lolo/spec/net/http-client.replay.goldens.json +56 -56
- package/behaviors/lolo/spec/net/http-fetch.replay.goldens.json +2 -2
- package/behaviors/lolo/spec/net/npm-lookup.replay.goldens.json +1 -1
- package/behaviors/lolo/spec/net/npm-registry.replay.goldens.json +2 -2
- package/behaviors/lolo/spec/net/server-declared-traits.replay.goldens.json +6 -3
- package/behaviors/lolo/spec/net/server-external-inputs.replay.goldens.json +16 -8
- package/behaviors/lolo/spec/net/server-retargeted-leg.replay.goldens.json +4 -2
- package/behaviors/lolo/spec/net/server-untargeted-discovery.replay.goldens.json +50 -45
- package/behaviors/lolo/spec/ops/llm-spend-board.replay.goldens.json +112 -16
- package/behaviors/lolo/spec/store/firestore-twin.replay.goldens.json +1 -1
- package/behaviors/lolo/spec/store/row-store-postgres.gen/record_real_sql.py +1 -1
- package/behaviors/lolo/spec/ui/game/fx-particles.replay.goldens.json +37 -0
- package/behaviors/lolo/ui/avl/atoms/std-avl-cosmic-zoom.lolo +2 -2
- package/behaviors/lolo/ui/game/atoms/std-fx-particles.lolo +10 -1
- package/behaviors/lolo/ui/game/atoms/ui-draw-fx-layer.lolo +4 -4
- package/behaviors/lolo/ui/game/organisms/std-arcade-board-3d.lolo +9 -9
- package/behaviors/lolo/ui/game/organisms/std-crew-board-2d.lolo +4 -4
- package/behaviors/lolo/ui/game/organisms/std-dungeon-board-2d.lolo +5 -5
- package/behaviors/lolo/ui/game/organisms/std-market-board-3d.lolo +9 -9
- package/behaviors/lolo/ui/game/organisms/std-objective-board-3d.lolo +9 -9
- package/behaviors/lolo/ui/game/organisms/std-platformer-board-2d.lolo +5 -5
- package/behaviors/lolo/ui/game/organisms/std-platformer-puzzle.lolo +4 -4
- package/behaviors/lolo/ui/game/organisms/std-survival-board-3d.lolo +9 -9
- package/behaviors/lolo/ui/game/organisms/std-tactics-board-2d.lolo +5 -5
- package/behaviors/lolo/ui/game/organisms/std-tactics-board-3d.lolo +9 -9
- package/behaviors/registry/auth/atoms/std-dev-personas.orb +1 -1
- package/behaviors/registry/cli/atoms/std-orb-goldens.orb +1 -1
- package/behaviors/registry/cli/atoms/std-orb-lint-mem-handles.orb +1 -1
- package/behaviors/registry/cli/atoms/std-orb-lint-os-grants.orb +1 -1
- package/behaviors/registry/cli/atoms/std-orb-mcp.orb +1 -1
- package/behaviors/registry/cli/atoms/std-orb-packages.orb +1 -1
- package/behaviors/registry/cli/atoms/std-orb-serve.orb +1 -1
- package/behaviors/registry/codec/atoms/std-lolo-kotlin.orb +1 -1
- package/behaviors/registry/codec/atoms/std-lolo-python.orb +1 -1
- package/behaviors/registry/codec/atoms/std-lolo-rust.orb +1 -1
- package/behaviors/registry/codec/atoms/std-lolo-source.orb +1 -1
- package/behaviors/registry/codec/atoms/std-lolo-swift.orb +1 -1
- package/behaviors/registry/codec/atoms/std-lolo-typescript.orb +1 -1
- package/behaviors/registry/connect/atoms/std-meta-ads.orb +1 -1
- package/behaviors/registry/connect/atoms/std-stdio-lines.orb +1 -1
- package/behaviors/registry/connect/atoms/std-youtube.orb +1 -1
- package/behaviors/registry/dev/atoms/std-guest-session.orb +1 -1
- package/behaviors/registry/dev/atoms/std-mock-seed-marks.orb +1 -0
- package/behaviors/registry/dev/organisms/std-behavior-playground.orb +37 -0
- package/behaviors/registry/dev/organisms/std-launchpad.orb +25 -0
- package/behaviors/registry/gpu/atoms/std-gpu-compute.orb +1 -0
- package/behaviors/registry/net/atoms/std-http-client.orb +1 -1
- package/behaviors/registry/net/atoms/std-http-fetch.orb +1 -1
- package/behaviors/registry/net/atoms/std-npm-lookup.orb +1 -1
- package/behaviors/registry/net/atoms/std-npm-registry.orb +1 -1
- package/behaviors/registry/spec/cli/lint-all.orb +1 -1
- package/behaviors/registry/spec/cli/orb-packages.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.fixtures/compose-pair.orb +1 -0
- package/behaviors/registry/spec/codec/lolo-source.fixtures/config-read.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.fixtures/divide-default.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.fixtures/divide-plain.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.fixtures/get-past-end.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.fixtures/list-call.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.fixtures/list-plain.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.fixtures/minus-binary.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.fixtures/minus-unary.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.fixtures/nested-let.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.fixtures/no-machine.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.fixtures/no-template.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.fixtures/nth-past-end.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.fixtures/nth-raw.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.fixtures/ports-call.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.fixtures/range-one.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.fixtures/range-two.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.fixtures/router-trio.orb +1 -0
- package/behaviors/registry/spec/codec/lolo-source.fixtures/store-pair.orb +1 -0
- package/behaviors/registry/spec/codec/lolo-source.fixtures/string-literal.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.parity/agent-step.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.parity/agent-step.server.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.parity/chunk.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.parity/chunk.server.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.parity/cosine.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.parity/cosine.server.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.parity/recall-at-k.orb +1 -1
- package/behaviors/registry/spec/codec/lolo-source.parity/recall-at-k.server.orb +1 -1
- package/behaviors/registry/ui/avl/atoms/std-avl-cosmic-zoom.orb +1 -1
- package/behaviors/registry/ui/game/atoms/std-fx-particles.orb +1 -1
- package/behaviors/registry/ui/game/atoms/ui-draw-fx-layer.orb +1 -1
- package/behaviors/registry/ui/game/organisms/std-arcade-board-3d.orb +20 -13
- package/behaviors/registry/ui/game/organisms/std-crew-board-2d.orb +9 -5
- package/behaviors/registry/ui/game/organisms/std-dungeon-board-2d.orb +17 -7
- package/behaviors/registry/ui/game/organisms/std-market-board-3d.orb +19 -15
- package/behaviors/registry/ui/game/organisms/std-objective-board-3d.orb +15 -12
- package/behaviors/registry/ui/game/organisms/std-platformer-board-2d.orb +17 -7
- package/behaviors/registry/ui/game/organisms/std-platformer-puzzle.orb +4 -0
- package/behaviors/registry/ui/game/organisms/std-survival-board-3d.orb +15 -12
- package/behaviors/registry/ui/game/organisms/std-tactics-board-2d.orb +13 -6
- package/behaviors/registry/ui/game/organisms/std-tactics-board-3d.orb +14 -12
- package/canonical-operators.json +1426 -103
- package/dist/{chunk-EK22WRB6.js → chunk-2UGHBVU2.js} +2 -2
- package/dist/{chunk-GDMH5T4J.js → chunk-3DK7GI2C.js} +2 -2
- package/dist/chunk-3MDASC5C.js +26 -0
- package/dist/{chunk-K5ZI27PB.js → chunk-3PHO4RRF.js} +1 -1
- package/dist/{chunk-7IEMMYM6.js → chunk-4MJCLAZW.js} +1 -1
- package/dist/{chunk-W4IEV4BY.js → chunk-55JPIL7A.js} +2 -2
- package/dist/{chunk-RUGBZTV3.js → chunk-66BLZLFI.js} +1 -1
- package/dist/{chunk-YWFISV7L.js → chunk-66RAJFOD.js} +1 -1
- package/dist/{chunk-JWOWWGNZ.js → chunk-6ED4SUC6.js} +1 -1
- package/dist/{chunk-LL7P6EII.js → chunk-6KFCHNE2.js} +2 -2
- package/dist/{chunk-GFBL2TW6.js → chunk-A4QB3Y6L.js} +1 -1
- package/dist/chunk-BVWMLS32.js +123 -0
- package/dist/{chunk-5KQCGSNC.js → chunk-CRKVDCY7.js} +1 -1
- package/dist/{chunk-WHQDLLC3.js → chunk-EKWEY4OJ.js} +1 -1
- package/dist/{chunk-Y3BRVNYK.js → chunk-EU22GCGV.js} +2 -2
- package/dist/{chunk-XQPYTDZ4.js → chunk-FB6PKNRS.js} +1 -1
- package/dist/{chunk-UX3MDFX6.js → chunk-FSVOJQLP.js} +1 -1
- package/dist/{chunk-LDBD2FBQ.js → chunk-GAKLBWBR.js} +1 -1
- package/dist/{chunk-C3IEMPRZ.js → chunk-GO3FKBV2.js} +2 -2
- package/dist/{chunk-LZSPEHSM.js → chunk-GPDTJHYY.js} +1 -1
- package/dist/{chunk-W5ABMOXU.js → chunk-JQBWLH5V.js} +1 -1
- package/dist/{chunk-63X6RNY6.js → chunk-KKW3JHTC.js} +1 -1
- package/dist/{chunk-5PLJE42Q.js → chunk-LF2EZVAM.js} +1 -1
- package/dist/{chunk-RXWBYWQB.js → chunk-LGCKOZP3.js} +2 -2
- package/dist/{chunk-JJEADYP7.js → chunk-LMZ6XJFB.js} +2 -2
- package/dist/{chunk-CWYSQZJU.js → chunk-M2YQNSAZ.js} +2 -2
- package/dist/{chunk-GNCKJV3P.js → chunk-MKWHYBIS.js} +1 -1
- package/dist/{chunk-ZB2CLGEG.js → chunk-MXBGYTYF.js} +1 -1
- package/dist/{chunk-UN76TRSK.js → chunk-NH6MXHZR.js} +41 -41
- package/dist/{chunk-II2VW7T6.js → chunk-ODBIX4DB.js} +1 -1
- package/dist/{chunk-3F3CNWOG.js → chunk-OYDQR6DT.js} +2 -2
- package/dist/{chunk-FVL6BT6L.js → chunk-PD6POR44.js} +1 -1
- package/dist/{chunk-U6USXZ5M.js → chunk-PHFT3QNS.js} +2 -2
- package/dist/{chunk-RJYKIZMS.js → chunk-PQZ6PVKG.js} +2 -2
- package/dist/{chunk-TQPQXCSZ.js → chunk-Q6NHXIOZ.js} +2 -2
- package/dist/{chunk-KYGWVCTM.js → chunk-QMDVYTB7.js} +1 -1
- package/dist/{chunk-XKTATY45.js → chunk-RW2KMSG5.js} +4 -4
- package/dist/{chunk-UHNSPTFT.js → chunk-SA2ZS24W.js} +1 -1
- package/dist/{chunk-6YPUQK36.js → chunk-SFWP4UMK.js} +2 -2
- package/dist/{chunk-ZZYLFHBU.js → chunk-TLNEQA4D.js} +1 -1
- package/dist/{chunk-RGTBRWWA.js → chunk-TOODE5AD.js} +2 -2
- package/dist/{chunk-QGWAHOFR.js → chunk-U57GY7SM.js} +2 -2
- package/dist/{chunk-FDJZKB7J.js → chunk-UIDQQJSX.js} +1 -1
- package/dist/{chunk-LLH3WXM3.js → chunk-UVFP2B7I.js} +1 -1
- package/dist/{chunk-4OF7727E.js → chunk-VEGZPCTZ.js} +2 -2
- package/dist/{chunk-73YUPNIT.js → chunk-VXN4V7LC.js} +1 -1
- package/dist/{chunk-4D3W6AAE.js → chunk-YHQVZWPG.js} +1 -1
- package/dist/{chunk-XXYBHYLM.js → chunk-YQO3TO66.js} +2 -2
- package/dist/{chunk-YZAYFR5A.js → chunk-ZSJ3GEOJ.js} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +50 -50
- package/dist/modules/anim.js +2 -2
- package/dist/modules/array.js +2 -2
- package/dist/modules/auth.js +3 -3
- package/dist/modules/behavior.js +2 -2
- package/dist/modules/bit.js +2 -2
- package/dist/modules/browser.js +2 -2
- package/dist/modules/bytes.js +2 -2
- package/dist/modules/codec.js +3 -3
- package/dist/modules/composition.js +2 -2
- package/dist/modules/core.js +2 -2
- package/dist/modules/csv.js +2 -2
- package/dist/modules/ffi.js +3 -3
- package/dist/modules/format.js +2 -2
- package/dist/modules/geo.js +2 -2
- package/dist/modules/gpu.d.ts +12 -0
- package/dist/modules/gpu.js +3 -0
- package/dist/modules/grid.js +2 -2
- package/dist/modules/i18n.js +2 -2
- package/dist/modules/index.d.ts +1 -2
- package/dist/modules/index.js +45 -46
- package/dist/modules/json.js +2 -2
- package/dist/modules/kernel.js +3 -3
- package/dist/modules/kv.js +3 -3
- package/dist/modules/llm.js +2 -2
- package/dist/modules/math.js +2 -2
- package/dist/modules/mem.js +3 -3
- package/dist/modules/object.js +2 -2
- package/dist/modules/os-common.d.ts +1 -1
- package/dist/modules/os-common.js +2 -2
- package/dist/modules/os-desktop.js +3 -3
- package/dist/modules/os-dev.js +3 -3
- package/dist/modules/os-dir.js +3 -3
- package/dist/modules/os-env-stdio.js +3 -3
- package/dist/modules/os-fs.js +3 -3
- package/dist/modules/os-net.js +3 -3
- package/dist/modules/os-path.js +3 -3
- package/dist/modules/os-process.js +3 -3
- package/dist/modules/os-sys.js +3 -3
- package/dist/modules/os-time-users.js +3 -3
- package/dist/modules/os.js +13 -13
- package/dist/modules/path.js +2 -2
- package/dist/modules/prob.js +2 -2
- package/dist/modules/program.js +2 -2
- package/dist/modules/session.js +2 -2
- package/dist/modules/str.js +2 -2
- package/dist/modules/time.js +2 -2
- package/dist/modules/validate.js +2 -2
- package/dist/modules/vector.js +2 -2
- package/dist/modules/workspace.js +2 -2
- package/dist/modules/xml.js +2 -2
- package/dist/modules/yaml.js +2 -2
- package/dist/registry.d.ts +2 -2
- package/dist/registry.js +49 -49
- package/dist/{types-BA4LkhNJ.d.ts → types-CgiGhK6t.d.ts} +17 -3
- package/package.json +5 -5
- package/dist/chunk-F5TP25JA.js +0 -26
- package/dist/chunk-NE4WSTN7.js +0 -26
- package/dist/modules/trace.d.ts +0 -15
- package/dist/modules/trace.js +0 -2
- /package/dist/{chunk-SHSBTDDX.js → chunk-QUQ33UXH.js} +0 -0
|
@@ -137,6 +137,8 @@ orbital LoloSwiftOrbital {
|
|
|
137
137
|
unsupportedForm: "_unsupported({{op}})"
|
|
138
138
|
unsupportedWarn: "no {{language}} template for operator {{op}}"
|
|
139
139
|
helpers: {
|
|
140
|
+
"store": ["fileprivate protocol _Eq { func _same(_ o: Self) -> Bool }\nextension String: _Eq { fileprivate func _same(_ o: String) -> Bool { unicodeScalars.elementsEqual(o.unicodeScalars) } }\nextension Double: _Eq { fileprivate func _same(_ o: Double) -> Bool { self == o } }\nextension Bool: _Eq { fileprivate func _same(_ o: Bool) -> Bool { self == o } }\nextension Array: _Eq where Element: _Eq { fileprivate func _same(_ o: [Element]) -> Bool { count == o.count && zip(self, o).allSatisfy { $0._same($1) } } }\nextension Optional: _Eq where Wrapped: _Eq {\n fileprivate func _same(_ o: Wrapped?) -> Bool {\n switch (self, o) {\n case (nil, nil): return true\n case let (a?, b?): return a._same(b)\n default: return false\n }\n }\n}\nextension Dictionary: _Eq where Value: _Eq { fileprivate func _same(_ o: [Key: Value]) -> Bool { count == o.count && allSatisfy { kv in o[kv.key].map { kv.value._same($0) } ?? false } } }\nfileprivate func _eq<T: _Eq>(_ a: T, _ b: T) -> Bool { a._same(b) }", "enum _JV: Codable, Equatable, ExpressibleByStringLiteral, ExpressibleByFloatLiteral, ExpressibleByIntegerLiteral, ExpressibleByBooleanLiteral {\n case null, bool(Bool), number(Double), string(String), array([_JV]), object([String: _JV])\n\n init(stringLiteral v: String) { self = .string(v) }\n init(floatLiteral v: Double) { self = .number(v) }\n init(integerLiteral v: Int) { self = .number(Double(v)) }\n init(booleanLiteral v: Bool) { self = .bool(v) }\n\n init(from decoder: Decoder) throws {\n let c = try decoder.singleValueContainer()\n if c.decodeNil() { self = .null }\n else if let b = try? c.decode(Bool.self) { self = .bool(b) }\n else if let n = try? c.decode(Double.self) { self = .number(n) }\n else if let v = try? c.decode(String.self) { self = .string(v) }\n else if let a = try? c.decode([_JV].self) { self = .array(a) }\n else { self = .object(try c.decode([String: _JV].self)) }\n }\n\n func encode(to encoder: Encoder) throws {\n var c = encoder.singleValueContainer()\n switch self {\n case .null: try c.encodeNil()\n case .bool(let b): try c.encode(b)\n case .number(let n): try c.encode(n)\n case .string(let v): try c.encode(v)\n case .array(let a): try c.encode(a)\n case .object(let o): try c.encode(o)\n }\n }\n}\n\nextension _JV: _Eq { fileprivate func _same(_ o: _JV) -> Bool { self == o } }\n\nstruct Answer {\n let ok: Bool\n let payload: [String: _JV]\n}\n\nprotocol Store: AnyObject {\n func persist(_ op: String, _ entity: String, _ data: any Encodable) -> Answer\n func fetch(_ entity: String, _ keep: (([String: _JV]) -> Bool)?) -> Answer\n}\n\nfileprivate func _before(_ a: [String: _JV], _ b: [String: _JV]) -> Bool {\n let sa = a[\"createdAt\"].flatMap { $0 == .null ? nil : $0 }\n let sb = b[\"createdAt\"].flatMap { $0 == .null ? nil : $0 }\n switch (sa, sb) {\n case (.some, nil): return true\n case (nil, .some): return false\n case let (.number(x)?, .number(y)?) where x != y: return x < y\n case let (.string(x)?, .string(y)?) where x != y: return x.unicodeScalars.lexicographicallyPrecedes(y.unicodeScalars)\n default: break\n }\n guard case .string(let ia)? = a[\"id\"], case .string(let ib)? = b[\"id\"] else { return false }\n return ia.unicodeScalars.lexicographicallyPrecedes(ib.unicodeScalars)\n}\n\nfinal class MemoryStore: Store {\n private var tables: [String: [(String, [String: _JV])]] = [:]\n private var minted = 0\n\n func persist(_ op: String, _ entity: String, _ data: any Encodable) -> Answer {\n var rows = tables[entity] ?? []\n defer { tables[entity] = rows }\n let value = _decode(_JV.self, _encode(data))\n if op == \"create\", case .object(var row) = value {\n let id: String\n if case .string(let given)? = row[\"id\"], !given.isEmpty {\n id = given\n } else {\n minted += 1\n id = entity + \"-\" + String(minted)\n }\n row[\"id\"] = .string(id)\n rows.append((id, row))\n return Answer(ok: true, payload: row)\n }\n var key = \"\"\n if case .string(let v) = value { key = v }\n if case .object(let o) = value, case .string(let v)? = o[\"id\"] { key = v }\n guard let pos = rows.firstIndex(where: { $0.0 == key }) else {\n return Answer(ok: false, payload: [\"error\": .string(entity + \" \" + key + \" not found\"), \"code\": \"not-found\"])\n }\n if op == \"delete\" {\n rows.remove(at: pos)\n return Answer(ok: true, payload: [\"id\": .string(key), \"deleted\": true])\n }\n if case .object(let o) = value {\n for (k, v) in o { rows[pos].1[k] = v }\n }\n return Answer(ok: true, payload: rows[pos].1)\n }\n\n func fetch(_ entity: String, _ keep: (([String: _JV]) -> Bool)?) -> Answer {\n var rows = (tables[entity] ?? []).map { $0.1 }.filter { keep?($0) ?? true }\n rows.sort(by: _before)\n return Answer(ok: true, payload: [\"data\": .array(rows.map { .object($0) }), \"totalCount\": .number(Double(rows.count))])\n }\n}"],
|
|
141
|
+
"router": ["typealias _Guard = (Data) -> Bool\ntypealias _Map = (Data) -> Data\n\nstruct _Entry {\n let key: String\n let trait: AnyObject\n let state: () -> String\n let entity: () -> Data\n let count: () -> Int\n let from: (Int) -> [(String, Data, Bool)]\n}\n\nstruct _Item {\n let target: String\n let event: String\n let payload: Data\n let source: Data\n let guard_: _Guard?\n let fans: Bool\n let completion: Bool\n}\n\nfunc _encode(_ value: any Encodable) -> Data {\n let encoder = JSONEncoder()\n encoder.outputFormatting = [.sortedKeys]\n return (try? encoder.encode(value)) ?? Data(\"{}\".utf8)\n}\n\nfunc _decode<T: Decodable>(_ type: T.Type, _ data: Data) -> T {\n do {\n return try JSONDecoder().decode(type, from: data)\n } catch {\n fatalError(\"a payload of the declared shape: \\(error)\")\n }\n}\n\nclass _Router {\n var entries: [_Entry] = []\n var handles: [String: [String: [String]]] = [:]\n var rows: [(source: String, event: String, target: String, trigger: String, guard_: _Guard?, mapping: _Map?)] = []\n var log: [(trait: String, event: String, payload: Data)] = []\n\n func add(_ key: String, _ trait: AnyObject, state: @escaping () -> String, entity: @escaping () -> Data, count: @escaping () -> Int, from: @escaping (Int) -> [(String, Data, Bool)]) {\n entries.append(_Entry(key: key, trait: trait, state: state, entity: entity, count: count, from: from))\n }\n\n func row(_ source: String, _ event: String, _ target: String, _ trigger: String, _ guard_: _Guard?, _ mapping: _Map?) {\n rows.append((source: source, event: event, target: target, trigger: trigger, guard_: guard_, mapping: mapping))\n }\n\n func entry(_ key: String) -> _Entry? {\n entries.first { $0.key == key }\n }\n\n func trait(_ key: String) -> AnyObject? {\n entry(key)?.trait\n }\n\n func deliver(_ target: String, _ event: String, _ payload: Data) {}\n\n func targets(_ source: String, _ event: String, _ payload: Data, _ completion: Bool) -> [_Item] {\n rows.filter { $0.source == source && $0.event == event }.map {\n _Item(target: $0.target, event: $0.trigger, payload: $0.mapping.map { m in m(payload) } ?? payload, source: payload, guard_: $0.guard_, fans: false, completion: completion)\n }\n }\n\n func dispatch(_ trait: String, _ event: String, _ payload: Data) {\n var queue = [_Item(target: trait, event: event, payload: payload, source: payload, guard_: nil, fans: true, completion: false)]\n var seen = Set<String>()\n var steps = 0\n while !queue.isEmpty {\n let item = queue.removeFirst()\n guard let e = entry(item.target) else { continue }\n let key = [item.target, item.event, e.state(), String(decoding: item.payload, as: UTF8.self), String(decoding: e.entity(), as: UTF8.self)].joined(separator: \"\\u{1f}\")\n if !item.completion && seen.contains(key) { continue }\n if let g = item.guard_, !g(item.source) { continue }\n if steps >= 2000 { break }\n steps += 1\n seen.insert(key)\n let n = e.count()\n deliver(item.target, item.event, item.payload)\n var fanned = item.fans ? targets(item.target, item.event, item.payload, false) : []\n var own: [_Item] = []\n let newState = e.state()\n for (ev, out, completion) in e.from(n) {\n log.append((trait: item.target, event: ev, payload: out))\n if handles[item.target]?[newState]?.contains(ev) ?? false {\n own.append(_Item(target: item.target, event: ev, payload: out, source: out, guard_: nil, fans: false, completion: completion))\n }\n fanned += targets(item.target, ev, out, completion)\n }\n queue.insert(contentsOf: own, at: 0)\n queue += fanned\n }\n }\n}"],
|
|
140
142
|
"/": ["fileprivate func _div(_ a: Double, _ b: Double) -> Double? { b == 0 ? nil : a / b }"],
|
|
141
143
|
"%": ["fileprivate func _mod(_ a: Double, _ b: Double) -> Double? { b == 0 ? nil : fmod(a, b) }"],
|
|
142
144
|
"math/mod": ["fileprivate func _mod(_ a: Double, _ b: Double) -> Double? { b == 0 ? nil : fmod(a, b) }"],
|
|
@@ -307,6 +309,22 @@ orbital LoloSwiftOrbital {
|
|
|
307
309
|
recordField: "{{name}}: {{value}}"
|
|
308
310
|
unionArmForm: "{{union}}.{{arm}}({{inner}})"
|
|
309
311
|
unionArmCase: "lower-camel"
|
|
312
|
+
programOpen: ["final class Program: _Router {", "{{i}}init({{entities}}{{store}}) {", "{{i}}{{i}}super.init()"]
|
|
313
|
+
programEntity: "_ e{{n}}: {{entity}}"
|
|
314
|
+
programEntitySep: ", "
|
|
315
|
+
programTrait: "{{i}}{{i}}let t{{n}} = {{class}}(entity: e{{n}}); add({{key}}, t{{n}}, state: { t{{n}}.state }, entity: { _encode(t{{n}}.entity) }, count: { t{{n}}.emitted.count }, from: { n in t{{n}}.emitted[n...].map { ($0.event, _encode($0.payload), false) } })"
|
|
316
|
+
programHandles: "{{i}}{{i}}handles[{{key}}] = {{table}}"
|
|
317
|
+
programRow: "{{i}}{{i}}row({{source}}, {{event}}, {{target}}, {{trigger}}, {{guard}}, {{map}})"
|
|
318
|
+
deliverOpen: ["{{i}}}", "", "{{i}}override func deliver(_ target: String, _ event: String, _ payload: Data) {"]
|
|
319
|
+
deliverCase: "{{i}}{{i}}if target == {{target}} && event == {{event}}, let t = trait(target) as? {{class}} { t.{{method}}({{arg}}); return }"
|
|
320
|
+
deliverCasePlain: "{{i}}{{i}}if target == {{target}} && event == {{event}}, let t = trait(target) as? {{class}} { t.{{method}}(); return }"
|
|
321
|
+
deliverClose: ["{{i}}}"]
|
|
322
|
+
programClose: ["}"]
|
|
323
|
+
payloadDecode: "_decode({{type}}.self, {{value}})"
|
|
324
|
+
guardForm: ["", "func {{name}}(_ payload_json: Data) -> Bool {", "{{i}}let payload = {{decode}}", "{{i}}return {{expr}}", "}"]
|
|
325
|
+
mapForm: ["", "func {{name}}(_ payload_json: Data) -> Data {", "{{i}}let payload = {{decode}}", "{{i}}return _encode({{expr}})", "}"]
|
|
326
|
+
guardName: "_guard{{n}}"
|
|
327
|
+
mapName: "_map{{n}}"
|
|
310
328
|
enumForm: "{{enum}}.{{member}}"
|
|
311
329
|
enumMemberCase: "split-camel"
|
|
312
330
|
payloadType: "{{trait}}{{event}}Payload"
|
|
@@ -331,8 +349,13 @@ orbital LoloSwiftOrbital {
|
|
|
331
349
|
classOpen: "final class {{class}} {"
|
|
332
350
|
classClose: "}"
|
|
333
351
|
classEmpty: ""
|
|
334
|
-
constructor: ["{{i}}var state: String", "{{i}}var entity: {{entity}}", "{{i}}var ports: [String: ([Any]) -> Void]", "{{i}}var config = {{configType}}()", "{{i}}private(set) var emitted: [(event: String, payload: any Encodable)] = []", "", "{{i}}init(entity: {{entity}}, ports: [String: ([Any]) -> Void] = [:]) {", "{{i}}{{i}}self.state = {{initial}}", "{{i}}{{i}}self.entity = entity", "{{i}}{{i}}self.ports = ports", "{{i}}}"]
|
|
352
|
+
constructor: ["{{i}}var state: String", "{{i}}var entity: {{entity}}", "{{i}}var ports: [String: ([Any]) -> Void]", "{{i}}var config = {{configType}}()", "{{i}}private(set) var emitted: [(event: String, payload: any Encodable)] = []", "{{withStore}}{{i}}var store: Store? = nil", "{{withStore}}{{i}}var completed = Set<Int>()", "", "{{i}}init(entity: {{entity}}, ports: [String: ([Any]) -> Void] = [:]) {", "{{i}}{{i}}self.state = {{initial}}", "{{i}}{{i}}self.entity = entity", "{{i}}{{i}}self.ports = ports", "{{i}}}"]
|
|
335
353
|
emitMethod: ["{{i}}func emit(_ event: String, _ payload: any Encodable) {", "{{i}}{{i}}emitted.append((event: event, payload: payload))", "{{i}}}"]
|
|
354
|
+
completeMethod: ["", "{{i}}func complete(_ answer: Answer, _ success: String?, _ failure: String?) {", "{{i}}{{i}}guard let route = answer.ok ? success : failure else { return }", "{{i}}{{i}}completed.insert(emitted.count)", "{{i}}{{i}}emitted.append((event: route, payload: answer.payload))", "{{i}}}", "", "{{i}}func useStore() -> Store {", "{{i}}{{i}}guard let store else { fatalError(\"no store\") }", "{{i}}{{i}}return store", "{{i}}}"]
|
|
355
|
+
routedEffects: {"persist": "self.complete(self.useStore().persist({{0}}, {{1}}, {{2}}), {{success}}, {{failure}})", "fetch": "self.complete(self.useStore().fetch({{entity}}, {{filter}}), {{success}}, {{failure}})"}
|
|
356
|
+
fetchAll: "nil"
|
|
357
|
+
programStoreParam: ", store: Store"
|
|
358
|
+
programTraitStore: "{{i}}{{i}}let t{{n}} = {{class}}(entity: e{{n}}); t{{n}}.store = store; add({{key}}, t{{n}}, state: { t{{n}}.state }, entity: { _encode(t{{n}}.entity) }, count: { t{{n}}.emitted.count }, from: { n in t{{n}}.emitted[n...].enumerated().map { ($0.element.event, _encode($0.element.payload), t{{n}}.completed.contains(n + $0.offset)) } })"
|
|
336
359
|
methodOpen: "{{i}}func {{method}}(_ payload: {{payloadType}}) {"
|
|
337
360
|
methodOpenPlain: "{{i}}func {{method}}() {"
|
|
338
361
|
methodClose: "{{i}}}"
|
|
@@ -31,7 +31,7 @@ orbital LoloTypescriptOrbital {
|
|
|
31
31
|
calleeForm: "{{callee}}({{*}})"
|
|
32
32
|
unsupportedForm: "_unsupported({{op}})"
|
|
33
33
|
unsupportedWarn: "no {{language}} template for operator {{op}}"
|
|
34
|
-
helpers: { "/": ["function _div(a: number, b: number): number | null {\n return b === 0 ? null : a / b;\n}"], "%": ["function _mod(a: number, b: number): number | null {\n return b === 0 ? null : a % b;\n}"], "math/mod": ["function _mod(a: number, b: number): number | null {\n return b === 0 ? null : a % b;\n}"], "=": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _eq(a: Json | undefined, b: Json | undefined): boolean {\n const x = a ?? null;\n const y = b ?? null;\n if (x === y) return true;\n if (Array.isArray(x) && Array.isArray(y)) return x.length === y.length && x.every((v, i) => _eq(v, y[i]));\n if (x !== null && y !== null && typeof x === 'object' && typeof y === 'object' && !Array.isArray(x) && !Array.isArray(y)) {\n const kx = Object.keys(x);\n return kx.length === Object.keys(y).length && kx.every((k) => Object.hasOwn(y, k) && _eq(x[k], y[k]));\n }\n return false;\n}"], "==": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _eq(a: Json | undefined, b: Json | undefined): boolean {\n const x = a ?? null;\n const y = b ?? null;\n if (x === y) return true;\n if (Array.isArray(x) && Array.isArray(y)) return x.length === y.length && x.every((v, i) => _eq(v, y[i]));\n if (x !== null && y !== null && typeof x === 'object' && typeof y === 'object' && !Array.isArray(x) && !Array.isArray(y)) {\n const kx = Object.keys(x);\n return kx.length === Object.keys(y).length && kx.every((k) => Object.hasOwn(y, k) && _eq(x[k], y[k]));\n }\n return false;\n}"], "!=": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _eq(a: Json | undefined, b: Json | undefined): boolean {\n const x = a ?? null;\n const y = b ?? null;\n if (x === y) return true;\n if (Array.isArray(x) && Array.isArray(y)) return x.length === y.length && x.every((v, i) => _eq(v, y[i]));\n if (x !== null && y !== null && typeof x === 'object' && typeof y === 'object' && !Array.isArray(x) && !Array.isArray(y)) {\n const kx = Object.keys(x);\n return kx.length === Object.keys(y).length && kx.every((k) => Object.hasOwn(y, k) && _eq(x[k], y[k]));\n }\n return false;\n}"], "str/split": ["function _split(s: string, d: string): string[] {\n return d === '' ? [...s] : s.split(d);\n}"], "str/join": ["function _text(v: string | number | boolean): string {\n return String(v);\n}", "function _join(a: ReadonlyArray<string | number | boolean>, d: string): string {\n return a.map(_text).join(d);\n}"], "str/concat": ["function _text(v: string | number | boolean): string {\n return String(v);\n}"], "str/replace": ["function _replace(s: string, a: string, b: string): string {\n const i = s.indexOf(a);\n return i < 0 ? s : s.slice(0, i) + b + s.slice(i + a.length);\n}"], "str/replaceAll": ["function _replaceAll(s: string, a: string, b: string): string {\n return a === '' ? b + [...s].map((c) => c + b).join('') : s.split(a).join(b);\n}"], "str/repeat": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _repeat(s: string, n: number): string {\n return s.repeat(_nat(n));\n}"], "str/capitalize": ["function _capitalize(s: string): string {\n const cs = [...s];\n return (cs[0] ?? '').toUpperCase() + cs.slice(1).join('').toLowerCase();\n}"], "str/slice": ["function _whole(n: number): number {\n if (!Number.isInteger(n)) throw new RangeError('expected a whole number, got ' + n);\n return n;\n}", "function _strSlice(s: string, a: number, b?: number): string {\n _whole(a);\n if (b !== undefined) _whole(b);\n return [...s].slice(a, b).join('');\n}"], "str/padStart": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _padStart(s: string, n: number, p: string = ' '): string {\n if ([...p].length !== 1) throw new RangeError('expected a single padding character');\n const k = [...s].length;\n return k >= _nat(n) ? s : p.repeat(n - k) + s;\n}"], "str/padEnd": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _padEnd(s: string, n: number, p: string = ' '): string {\n if ([...p].length !== 1) throw new RangeError('expected a single padding character');\n const k = [...s].length;\n return k >= _nat(n) ? s : s + p.repeat(n - k);\n}"], "str/truncate": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _truncate(s: string, n: number, suffix: string = '...'): string {\n const cs = [...s];\n return cs.length <= _nat(n) ? s : cs.slice(0, n).join('') + suffix;\n}"], "str/to-int": ["function _toInt(s: string): number | null {\n if (!/^[+-]?[0-9]+$/.test(s)) return null;\n const v = BigInt(s);\n return v >= -(2n ** 63n) && v < 2n ** 63n ? Number(v) : null;\n}"], "array/sum": ["type Row = Readonly<Record<string, number>>;\n\nfunction _nums(a: ReadonlyArray<number | Row>, k?: string): number[] {\n const out: number[] = [];\n for (const x of a) {\n if (k === undefined) {\n if (typeof x !== 'number') throw new TypeError('expected number');\n out.push(x);\n } else if (typeof x !== 'number') {\n const v = x[k];\n if (v !== undefined) out.push(v);\n }\n }\n return out;\n}", "function _sum(a: ReadonlyArray<number | Row>, k?: string): number {\n return _nums(a, k).reduce((x, y) => x + y, 0);\n}"], "array/avg": ["type Row = Readonly<Record<string, number>>;\n\nfunction _nums(a: ReadonlyArray<number | Row>, k?: string): number[] {\n const out: number[] = [];\n for (const x of a) {\n if (k === undefined) {\n if (typeof x !== 'number') throw new TypeError('expected number');\n out.push(x);\n } else if (typeof x !== 'number') {\n const v = x[k];\n if (v !== undefined) out.push(v);\n }\n }\n return out;\n}", "function _avg(a: ReadonlyArray<number | Row>, k?: string): number | null {\n const v = _nums(a, k);\n return v.length === 0 ? null : v.reduce((x, y) => x + y, 0) / v.length;\n}"], "array/max": ["type Row = Readonly<Record<string, number>>;\n\nfunction _nums(a: ReadonlyArray<number | Row>, k?: string): number[] {\n const out: number[] = [];\n for (const x of a) {\n if (k === undefined) {\n if (typeof x !== 'number') throw new TypeError('expected number');\n out.push(x);\n } else if (typeof x !== 'number') {\n const v = x[k];\n if (v !== undefined) out.push(v);\n }\n }\n return out;\n}", "function _amax(a: ReadonlyArray<number | Row>, k?: string): number | null {\n const v = _nums(a, k);\n return v.length === 0 ? null : Math.max(...v);\n}"], "array/min": ["type Row = Readonly<Record<string, number>>;\n\nfunction _nums(a: ReadonlyArray<number | Row>, k?: string): number[] {\n const out: number[] = [];\n for (const x of a) {\n if (k === undefined) {\n if (typeof x !== 'number') throw new TypeError('expected number');\n out.push(x);\n } else if (typeof x !== 'number') {\n const v = x[k];\n if (v !== undefined) out.push(v);\n }\n }\n return out;\n}", "function _amin(a: ReadonlyArray<number | Row>, k?: string): number | null {\n const v = _nums(a, k);\n return v.length === 0 ? null : Math.min(...v);\n}"], "array/first": ["function _first<T>(a: readonly T[]): T | null {\n return a.length > 0 ? (a[0] as T) : null;\n}"], "array/last": ["function _last<T>(a: readonly T[]): T | null {\n return a.length > 0 ? (a[a.length - 1] as T) : null;\n}"], "array/nth": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _nth<T>(a: readonly T[], i: number): T | null {\n return _nat(i) < a.length ? (a[i] as T) : null;\n}"], "array/range": ["function _range(a: number, b?: number, step: number = 1): number[] {\n if (step === 0 || !Number.isFinite(step)) throw new RangeError('range: step 0 must be a non-zero finite number');\n const start = b === undefined ? 0 : a;\n const end = b === undefined ? a : b;\n const out: number[] = [];\n for (let x = start; step > 0 ? x < end : x > end; x += step) out.push(x);\n return out;\n}"], "array/slice": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _slice<T>(a: readonly T[], s: number, e?: number): T[] {\n _nat(s);\n if (e !== undefined) _nat(e);\n return a.slice(s, e);\n}"], "array/take": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _take<T>(a: readonly T[], n: number): T[] {\n return a.slice(0, _nat(n));\n}"], "array/drop": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _drop<T>(a: readonly T[], n: number): T[] {\n return a.slice(_nat(n));\n}"], "array/takeLast": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _takeLast<T>(a: readonly T[], n: number): T[] {\n return _nat(n) < a.length ? a.slice(a.length - n) : a.slice();\n}"], "array/dropLast": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _dropLast<T>(a: readonly T[], n: number): T[] {\n return _nat(n) < a.length ? a.slice(0, a.length - n) : [];\n}"], "array/includes": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _eq(a: Json | undefined, b: Json | undefined): boolean {\n const x = a ?? null;\n const y = b ?? null;\n if (x === y) return true;\n if (Array.isArray(x) && Array.isArray(y)) return x.length === y.length && x.every((v, i) => _eq(v, y[i]));\n if (x !== null && y !== null && typeof x === 'object' && typeof y === 'object' && !Array.isArray(x) && !Array.isArray(y)) {\n const kx = Object.keys(x);\n return kx.length === Object.keys(y).length && kx.every((k) => Object.hasOwn(y, k) && _eq(x[k], y[k]));\n }\n return false;\n}", "function _includes(a: readonly Json[], x: Json): boolean {\n return a.some((y) => _eq(y, x));\n}"], "array/indexOf": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _eq(a: Json | undefined, b: Json | undefined): boolean {\n const x = a ?? null;\n const y = b ?? null;\n if (x === y) return true;\n if (Array.isArray(x) && Array.isArray(y)) return x.length === y.length && x.every((v, i) => _eq(v, y[i]));\n if (x !== null && y !== null && typeof x === 'object' && typeof y === 'object' && !Array.isArray(x) && !Array.isArray(y)) {\n const kx = Object.keys(x);\n return kx.length === Object.keys(y).length && kx.every((k) => Object.hasOwn(y, k) && _eq(x[k], y[k]));\n }\n return false;\n}", "function _indexOf(a: readonly Json[], x: Json): number {\n return a.findIndex((y) => _eq(y, x));\n}"], "array/unique": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _eq(a: Json | undefined, b: Json | undefined): boolean {\n const x = a ?? null;\n const y = b ?? null;\n if (x === y) return true;\n if (Array.isArray(x) && Array.isArray(y)) return x.length === y.length && x.every((v, i) => _eq(v, y[i]));\n if (x !== null && y !== null && typeof x === 'object' && typeof y === 'object' && !Array.isArray(x) && !Array.isArray(y)) {\n const kx = Object.keys(x);\n return kx.length === Object.keys(y).length && kx.every((k) => Object.hasOwn(y, k) && _eq(x[k], y[k]));\n }\n return false;\n}", "function _unique<T extends Json>(a: readonly T[]): T[] {\n const out: T[] = [];\n for (const x of a) if (!out.some((y) => _eq(y, x))) out.push(x);\n return out;\n}"], "array/zip": ["function _zip<A, B>(a: readonly A[], b: readonly B[]): Array<[A, B]> {\n const n = Math.min(a.length, b.length);\n const out: Array<[A, B]> = [];\n for (let i = 0; i < n; i++) out.push([a[i] as A, b[i] as B]);\n return out;\n}"], "array/concat": ["function _concat<T>(...parts: ReadonlyArray<readonly T[]>): T[] {\n return parts.flat();\n}"], "array/sort": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _cmp(a: Json | undefined, b: Json | undefined): number {\n const x = a ?? null;\n const y = b ?? null;\n if (x === null || y === null) return x === y ? 0 : x === null ? -1 : 1;\n if (typeof x === 'number' && typeof y === 'number') return x < y ? -1 : x > y ? 1 : 0;\n if (typeof x === 'string' && typeof y === 'string') {\n const p = [...x];\n const q = [...y];\n for (let i = 0; i < Math.min(p.length, q.length); i++) {\n const d = ((p[i] ?? '').codePointAt(0) ?? 0) - ((q[i] ?? '').codePointAt(0) ?? 0);\n if (d !== 0) return d < 0 ? -1 : 1;\n }\n return p.length < q.length ? -1 : p.length > q.length ? 1 : 0;\n }\n if (typeof x === 'boolean' && typeof y === 'boolean') return x === y ? 0 : x ? 1 : -1;\n if (typeof x === 'object' && typeof y === 'object') return 0;\n throw new TypeError('cannot compare these values');\n}", "function _sort<T extends Json>(a: readonly T[], k?: string | null, o: string = 'asc'): T[] {\n const key = (x: T): Json | undefined => (k === undefined || k === null ? x : typeof x === 'object' && x !== null && !Array.isArray(x) ? x[k] : null);\n return [...a].sort((x, y) => (o === 'desc' ? _cmp(key(y), key(x)) : _cmp(key(x), key(y))));\n}"], "object/get": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _isObject(v: Json | undefined): v is { [k: string]: Json } {\n return v !== null && v !== undefined && typeof v === 'object' && !Array.isArray(v);\n}", "function _path(p: string): string[] {\n const out: string[] = [];\n let cur = '';\n const cs = [...p];\n for (let i = 0; i < cs.length; i++) {\n const c = cs[i] ?? '';\n if (c === String.fromCharCode(92) && cs[i + 1] === '.') {\n cur += '.';\n i++;\n } else if (c === '.') {\n out.push(cur);\n cur = '';\n } else {\n cur += c;\n }\n }\n out.push(cur);\n return out;\n}", "function _get(o: Json | undefined, p: string, d: Json = null): Json {\n let cur: Json | undefined = o;\n for (const s of _path(p)) {\n if (_isObject(cur)) {\n if (!Object.hasOwn(cur, s)) return d;\n cur = cur[s];\n } else if (Array.isArray(cur) && /^[0-9]+$/.test(s) && Number(s) < cur.length) {\n cur = cur[Number(s)];\n } else {\n return d;\n }\n }\n return cur ?? null;\n}"], "object/has": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _isObject(v: Json | undefined): v is { [k: string]: Json } {\n return v !== null && v !== undefined && typeof v === 'object' && !Array.isArray(v);\n}", "function _path(p: string): string[] {\n const out: string[] = [];\n let cur = '';\n const cs = [...p];\n for (let i = 0; i < cs.length; i++) {\n const c = cs[i] ?? '';\n if (c === String.fromCharCode(92) && cs[i + 1] === '.') {\n cur += '.';\n i++;\n } else if (c === '.') {\n out.push(cur);\n cur = '';\n } else {\n cur += c;\n }\n }\n out.push(cur);\n return out;\n}", "function _has(o: Json | undefined, p: string): boolean {\n let cur: Json | undefined = o;\n for (const s of _path(p)) {\n if (_isObject(cur)) {\n if (!Object.hasOwn(cur, s)) return false;\n cur = cur[s];\n } else if (Array.isArray(cur) && /^[0-9]+$/.test(s) && Number(s) < cur.length) {\n cur = cur[Number(s)];\n } else {\n return false;\n }\n }\n return true;\n}"], "object/set": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _isObject(v: Json | undefined): v is { [k: string]: Json } {\n return v !== null && v !== undefined && typeof v === 'object' && !Array.isArray(v);\n}", "function _setPath(cur: Json | undefined, segs: readonly string[], v: Json): Json | undefined {\n const [head, ...rest] = segs;\n if (head === undefined) return v;\n if (cur === undefined) return { [head]: _setPath(undefined, rest, v) ?? null };\n if (_isObject(cur)) {\n const n = _setPath(Object.hasOwn(cur, head) ? cur[head] : undefined, rest, v);\n return n === undefined ? undefined : { ...cur, [head]: n };\n }\n if (Array.isArray(cur) && /^[0-9]+$/.test(head) && Number(head) < cur.length) {\n const n = _setPath(cur[Number(head)], rest, v);\n return n === undefined ? undefined : cur.map((x, i) => (i === Number(head) ? n : x));\n }\n return undefined;\n}", "function _path(p: string): string[] {\n const out: string[] = [];\n let cur = '';\n const cs = [...p];\n for (let i = 0; i < cs.length; i++) {\n const c = cs[i] ?? '';\n if (c === String.fromCharCode(92) && cs[i + 1] === '.') {\n cur += '.';\n i++;\n } else if (c === '.') {\n out.push(cur);\n cur = '';\n } else {\n cur += c;\n }\n }\n out.push(cur);\n return out;\n}", "function _set(o: { [k: string]: Json }, p: string, v: Json): Json | null {\n return _setPath(o, _path(p), v) ?? null;\n}"], "object/pick": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _pick(o: { [k: string]: Json }, ks: readonly string[]): { [k: string]: Json } {\n const out: { [k: string]: Json } = {};\n for (const k of ks) if (Object.hasOwn(o, k)) out[k] = o[k] ?? null;\n return out;\n}"], "object/omit": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _omit(o: { [k: string]: Json }, ks: readonly string[]): { [k: string]: Json } {\n const out: { [k: string]: Json } = {};\n for (const k of Object.keys(o)) if (!ks.includes(k)) out[k] = o[k] ?? null;\n return out;\n}"], "object/fromEntries": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _fromEntries(es: ReadonlyArray<readonly [string, Json]>): { [k: string]: Json } {\n return Object.fromEntries(es);\n}"], "json/parse": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _jsonParse(t: string): Json {\n try {\n return JSON.parse(t) as Json;\n } catch {\n return null;\n }\n}"], "math/round": ["function _round(x: number, d: number = 0): number {\n const m = 10 ** d;\n const r = Math.floor(Math.abs(x) * m + 0.5) / m;\n return x < 0 ? -r : r;\n}"], "math/sqrt": ["function _sqrt(x: number): number | null {\n return x < 0 ? null : Math.sqrt(x);\n}"], "math/ln": ["function _ln(x: number): number | null {\n return x <= 0 ? null : Math.log(x);\n}"], "math/log10": ["function _log10(x: number): number | null {\n return x <= 0 ? null : Math.log10(x);\n}"], "math/pow": ["function _pow(a: number, b: number): number | null {\n const r = Math.pow(a, b);\n return Number.isFinite(r) ? r : null;\n}"], "math/clamp": ["function _clamp(v: number, lo: number, hi: number): number {\n return Math.min(Math.max(v, lo), hi);\n}"], "validate/required": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _required(v: Json | undefined): boolean {\n return v !== null && v !== undefined && v !== '';\n}"], "validate/object": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _isObject(v: Json | undefined): v is { [k: string]: Json } {\n return v !== null && v !== undefined && typeof v === 'object' && !Array.isArray(v);\n}"], "validate/length": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _length(v: string | readonly Json[]): number {\n return typeof v === 'string' ? [...v].length : v.length;\n}"], "validate/minLength": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _length(v: string | readonly Json[]): number {\n return typeof v === 'string' ? [...v].length : v.length;\n}"], "validate/maxLength": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _length(v: string | readonly Json[]): number {\n return typeof v === 'string' ? [...v].length : v.length;\n}"], "validate/oneOf": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _eq(a: Json | undefined, b: Json | undefined): boolean {\n const x = a ?? null;\n const y = b ?? null;\n if (x === y) return true;\n if (Array.isArray(x) && Array.isArray(y)) return x.length === y.length && x.every((v, i) => _eq(v, y[i]));\n if (x !== null && y !== null && typeof x === 'object' && typeof y === 'object' && !Array.isArray(x) && !Array.isArray(y)) {\n const kx = Object.keys(x);\n return kx.length === Object.keys(y).length && kx.every((k) => Object.hasOwn(y, k) && _eq(x[k], y[k]));\n }\n return false;\n}", "function _includes(a: readonly Json[], x: Json): boolean {\n return a.some((y) => _eq(y, x));\n}"], "validate/equals": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _eq(a: Json | undefined, b: Json | undefined): boolean {\n const x = a ?? null;\n const y = b ?? null;\n if (x === y) return true;\n if (Array.isArray(x) && Array.isArray(y)) return x.length === y.length && x.every((v, i) => _eq(v, y[i]));\n if (x !== null && y !== null && typeof x === 'object' && typeof y === 'object' && !Array.isArray(x) && !Array.isArray(y)) {\n const kx = Object.keys(x);\n return kx.length === Object.keys(y).length && kx.every((k) => Object.hasOwn(y, k) && _eq(x[k], y[k]));\n }\n return false;\n}"], "unsupported": ["function _unsupported(name: string): never {\n throw new Error('no native template for operator ' + name);\n}"], "array/find": ["function _find<T>(a: readonly T[], f: (x: T, i: number) => boolean): T | null {\n const i = a.findIndex(f);\n return i < 0 ? null : (a[i] as T);\n}"], "object/merge": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _merge(...os: Array<{ [k: string]: Json }>): { [k: string]: Json } {\n return Object.assign({}, ...os) as { [k: string]: Json };\n}"] }
|
|
34
|
+
helpers: { "payload": ["function _opt<T extends {} | null>(v: T): T;\nfunction _opt<T extends {} | null>(v: T | undefined): T | null;\nfunction _opt<T>(v: T | undefined): T | null {\n return v === undefined ? null : v;\n}"], "store": ["export interface Answer {\n ok: boolean;\n payload: EventPayload;\n}\nexport interface Store {\n persist(op: string, entity: string, data: EventPayload | string): Answer;\n fetch(entity: string, keep: ((row: EventPayload) => boolean) | null): Answer;\n}\nfunction _order(a: EventPayload, b: EventPayload): number {\n const sa = a['createdAt'];\n const sb = b['createdAt'];\n const ha = sa !== undefined && sa !== null;\n const hb = sb !== undefined && sb !== null;\n if (ha !== hb) return ha ? -1 : 1;\n if (typeof sa === 'number' && typeof sb === 'number' && sa !== sb) return sa < sb ? -1 : 1;\n if (typeof sa === 'string' && typeof sb === 'string' && sa !== sb) return sa < sb ? -1 : 1;\n const ia = String(a['id']);\n const ib = String(b['id']);\n return ia < ib ? -1 : ia > ib ? 1 : 0;\n}\nexport class MemoryStore implements Store {\n readonly tables: Record<string, Map<string, EventPayload>> = {};\n minted = 0;\n\n private table(entity: string): Map<string, EventPayload> {\n const t = this.tables[entity] ?? new Map<string, EventPayload>();\n this.tables[entity] = t;\n return t;\n }\n\n persist(op: string, entity: string, data: EventPayload | string): Answer {\n const rows = this.table(entity);\n if (op === 'create' && typeof data !== 'string') {\n const row: EventPayload = { ...data };\n const given = row['id'];\n const id = typeof given === 'string' && given !== '' ? given : entity + '-' + String((this.minted += 1));\n row['id'] = id;\n rows.set(id, row);\n return { ok: true, payload: { ...row } };\n }\n const key = typeof data === 'string' ? data : String(data['id'] ?? '');\n const found = rows.get(key);\n if (found === undefined) return { ok: false, payload: { error: entity + ' ' + key + ' not found', code: 'not-found' } };\n if (op === 'delete') {\n rows.delete(key);\n return { ok: true, payload: { id: key, deleted: true } };\n }\n const next: EventPayload = typeof data === 'string' ? { ...found } : { ...found, ...data };\n rows.set(key, next);\n return { ok: true, payload: { ...next } };\n }\n\n fetch(entity: string, keep: ((row: EventPayload) => boolean) | null): Answer {\n const rows = [...this.table(entity).values()].filter((r) => keep === null || keep({ ...r })).map((r) => ({ ...r }));\n rows.sort(_order);\n return { ok: true, payload: { data: rows, totalCount: rows.length } };\n }\n}"], "router": ["type _Guard = (payload: EventPayload) => boolean;\ntype _Map = (payload: EventPayload) => EventPayload;\ninterface _Routed {\n readonly state: string;\n readonly entity: object;\n readonly emitted: ReadonlyArray<{ event: string; payload: EventPayload; completion?: boolean }>;\n}\ninterface _Item {\n trait: string;\n event: string;\n payload: EventPayload;\n source: EventPayload;\n guard: _Guard | null;\n fans: boolean;\n completion: boolean;\n}\nfunction _decode<T extends EventPayload>(payload: EventPayload): T {\n return payload as T;\n}\nfunction _canon(value: object): string {\n return JSON.stringify(value, (_key: string, v: object | null) =>\n v !== null && typeof v === 'object' && !Array.isArray(v)\n ? Object.fromEntries(Object.entries(v).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)))\n : v,\n );\n}\nabstract class _Router {\n readonly traits: Record<string, _Routed> = {};\n readonly handles: Record<string, Record<string, string[]>> = {};\n readonly rows: Array<{ source: string; event: string; target: string; trigger: string; guard: _Guard | null; mapping: _Map | null }> = [];\n readonly log: Array<{ trait: string; event: string; payload: EventPayload }> = [];\n\n add(key: string, trait: _Routed): void {\n this.traits[key] = trait;\n }\n\n row(source: string, event: string, target: string, trigger: string, guard: _Guard | null, mapping: _Map | null): void {\n this.rows.push({ source, event, target, trigger, guard, mapping });\n }\n\n abstract deliver(target: string, event: string, payload: EventPayload): void;\n\n targets(source: string, event: string, payload: EventPayload, completion: boolean): _Item[] {\n return this.rows\n .filter((r) => r.source === source && r.event === event)\n .map((r) => ({ trait: r.target, event: r.trigger, payload: r.mapping ? r.mapping(payload) : payload, source: payload, guard: r.guard, fans: false, completion }));\n }\n\n dispatch(trait: string, event: string, payload: EventPayload): void {\n const queue: _Item[] = [{ trait, event, payload, source: payload, guard: null, fans: true, completion: false }];\n const seen = new Set<string>();\n let steps = 0;\n for (let item = queue.shift(); item !== undefined; item = queue.shift()) {\n const t = this.traits[item.trait];\n if (t === undefined) continue;\n const key = _canon([item.trait, item.event, t.state, item.payload, t.entity]);\n if (!item.completion && seen.has(key)) continue;\n if (item.guard !== null && !item.guard(item.source)) continue;\n if (steps >= 2000) break;\n steps += 1;\n seen.add(key);\n const n = t.emitted.length;\n this.deliver(item.trait, item.event, item.payload);\n const own: _Item[] = [];\n const fanned: _Item[] = item.fans ? this.targets(item.trait, item.event, item.payload, false) : [];\n for (const e of t.emitted.slice(n)) {\n this.log.push({ trait: item.trait, event: e.event, payload: e.payload });\n if ((this.handles[item.trait]?.[t.state] ?? []).includes(e.event)) {\n own.push({ trait: item.trait, event: e.event, payload: e.payload, source: e.payload, guard: null, fans: false, completion: e.completion === true });\n }\n fanned.push(...this.targets(item.trait, e.event, e.payload, e.completion === true));\n }\n queue.unshift(...own);\n queue.push(...fanned);\n }\n }\n}"], "/": ["function _div(a: number, b: number): number | null {\n return b === 0 ? null : a / b;\n}"], "%": ["function _mod(a: number, b: number): number | null {\n return b === 0 ? null : a % b;\n}"], "math/mod": ["function _mod(a: number, b: number): number | null {\n return b === 0 ? null : a % b;\n}"], "=": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _eq(a: Json | undefined, b: Json | undefined): boolean {\n const x = a ?? null;\n const y = b ?? null;\n if (x === y) return true;\n if (Array.isArray(x) && Array.isArray(y)) return x.length === y.length && x.every((v, i) => _eq(v, y[i]));\n if (x !== null && y !== null && typeof x === 'object' && typeof y === 'object' && !Array.isArray(x) && !Array.isArray(y)) {\n const kx = Object.keys(x);\n return kx.length === Object.keys(y).length && kx.every((k) => Object.hasOwn(y, k) && _eq(x[k], y[k]));\n }\n return false;\n}"], "==": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _eq(a: Json | undefined, b: Json | undefined): boolean {\n const x = a ?? null;\n const y = b ?? null;\n if (x === y) return true;\n if (Array.isArray(x) && Array.isArray(y)) return x.length === y.length && x.every((v, i) => _eq(v, y[i]));\n if (x !== null && y !== null && typeof x === 'object' && typeof y === 'object' && !Array.isArray(x) && !Array.isArray(y)) {\n const kx = Object.keys(x);\n return kx.length === Object.keys(y).length && kx.every((k) => Object.hasOwn(y, k) && _eq(x[k], y[k]));\n }\n return false;\n}"], "!=": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _eq(a: Json | undefined, b: Json | undefined): boolean {\n const x = a ?? null;\n const y = b ?? null;\n if (x === y) return true;\n if (Array.isArray(x) && Array.isArray(y)) return x.length === y.length && x.every((v, i) => _eq(v, y[i]));\n if (x !== null && y !== null && typeof x === 'object' && typeof y === 'object' && !Array.isArray(x) && !Array.isArray(y)) {\n const kx = Object.keys(x);\n return kx.length === Object.keys(y).length && kx.every((k) => Object.hasOwn(y, k) && _eq(x[k], y[k]));\n }\n return false;\n}"], "str/split": ["function _split(s: string, d: string): string[] {\n return d === '' ? [...s] : s.split(d);\n}"], "str/join": ["function _text(v: string | number | boolean): string {\n return String(v);\n}", "function _join(a: ReadonlyArray<string | number | boolean>, d: string): string {\n return a.map(_text).join(d);\n}"], "str/concat": ["function _text(v: string | number | boolean): string {\n return String(v);\n}"], "str/replace": ["function _replace(s: string, a: string, b: string): string {\n const i = s.indexOf(a);\n return i < 0 ? s : s.slice(0, i) + b + s.slice(i + a.length);\n}"], "str/replaceAll": ["function _replaceAll(s: string, a: string, b: string): string {\n return a === '' ? b + [...s].map((c) => c + b).join('') : s.split(a).join(b);\n}"], "str/repeat": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _repeat(s: string, n: number): string {\n return s.repeat(_nat(n));\n}"], "str/capitalize": ["function _capitalize(s: string): string {\n const cs = [...s];\n return (cs[0] ?? '').toUpperCase() + cs.slice(1).join('').toLowerCase();\n}"], "str/slice": ["function _whole(n: number): number {\n if (!Number.isInteger(n)) throw new RangeError('expected a whole number, got ' + n);\n return n;\n}", "function _strSlice(s: string, a: number, b?: number): string {\n _whole(a);\n if (b !== undefined) _whole(b);\n return [...s].slice(a, b).join('');\n}"], "str/padStart": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _padStart(s: string, n: number, p: string = ' '): string {\n if ([...p].length !== 1) throw new RangeError('expected a single padding character');\n const k = [...s].length;\n return k >= _nat(n) ? s : p.repeat(n - k) + s;\n}"], "str/padEnd": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _padEnd(s: string, n: number, p: string = ' '): string {\n if ([...p].length !== 1) throw new RangeError('expected a single padding character');\n const k = [...s].length;\n return k >= _nat(n) ? s : s + p.repeat(n - k);\n}"], "str/truncate": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _truncate(s: string, n: number, suffix: string = '...'): string {\n const cs = [...s];\n return cs.length <= _nat(n) ? s : cs.slice(0, n).join('') + suffix;\n}"], "str/to-int": ["function _toInt(s: string): number | null {\n if (!/^[+-]?[0-9]+$/.test(s)) return null;\n const v = BigInt(s);\n return v >= -(2n ** 63n) && v < 2n ** 63n ? Number(v) : null;\n}"], "array/sum": ["type Row = Readonly<Record<string, number>>;\n\nfunction _nums(a: ReadonlyArray<number | Row>, k?: string): number[] {\n const out: number[] = [];\n for (const x of a) {\n if (k === undefined) {\n if (typeof x !== 'number') throw new TypeError('expected number');\n out.push(x);\n } else if (typeof x !== 'number') {\n const v = x[k];\n if (v !== undefined) out.push(v);\n }\n }\n return out;\n}", "function _sum(a: ReadonlyArray<number | Row>, k?: string): number {\n return _nums(a, k).reduce((x, y) => x + y, 0);\n}"], "array/avg": ["type Row = Readonly<Record<string, number>>;\n\nfunction _nums(a: ReadonlyArray<number | Row>, k?: string): number[] {\n const out: number[] = [];\n for (const x of a) {\n if (k === undefined) {\n if (typeof x !== 'number') throw new TypeError('expected number');\n out.push(x);\n } else if (typeof x !== 'number') {\n const v = x[k];\n if (v !== undefined) out.push(v);\n }\n }\n return out;\n}", "function _avg(a: ReadonlyArray<number | Row>, k?: string): number | null {\n const v = _nums(a, k);\n return v.length === 0 ? null : v.reduce((x, y) => x + y, 0) / v.length;\n}"], "array/max": ["type Row = Readonly<Record<string, number>>;\n\nfunction _nums(a: ReadonlyArray<number | Row>, k?: string): number[] {\n const out: number[] = [];\n for (const x of a) {\n if (k === undefined) {\n if (typeof x !== 'number') throw new TypeError('expected number');\n out.push(x);\n } else if (typeof x !== 'number') {\n const v = x[k];\n if (v !== undefined) out.push(v);\n }\n }\n return out;\n}", "function _amax(a: ReadonlyArray<number | Row>, k?: string): number | null {\n const v = _nums(a, k);\n return v.length === 0 ? null : Math.max(...v);\n}"], "array/min": ["type Row = Readonly<Record<string, number>>;\n\nfunction _nums(a: ReadonlyArray<number | Row>, k?: string): number[] {\n const out: number[] = [];\n for (const x of a) {\n if (k === undefined) {\n if (typeof x !== 'number') throw new TypeError('expected number');\n out.push(x);\n } else if (typeof x !== 'number') {\n const v = x[k];\n if (v !== undefined) out.push(v);\n }\n }\n return out;\n}", "function _amin(a: ReadonlyArray<number | Row>, k?: string): number | null {\n const v = _nums(a, k);\n return v.length === 0 ? null : Math.min(...v);\n}"], "array/first": ["function _first<T>(a: readonly T[]): T | null {\n return a.length > 0 ? (a[0] as T) : null;\n}"], "array/last": ["function _last<T>(a: readonly T[]): T | null {\n return a.length > 0 ? (a[a.length - 1] as T) : null;\n}"], "array/nth": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _nth<T>(a: readonly T[], i: number): T | null {\n return _nat(i) < a.length ? (a[i] as T) : null;\n}"], "array/range": ["function _range(a: number, b?: number, step: number = 1): number[] {\n if (step === 0 || !Number.isFinite(step)) throw new RangeError('range: step 0 must be a non-zero finite number');\n const start = b === undefined ? 0 : a;\n const end = b === undefined ? a : b;\n const out: number[] = [];\n for (let x = start; step > 0 ? x < end : x > end; x += step) out.push(x);\n return out;\n}"], "array/slice": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _slice<T>(a: readonly T[], s: number, e?: number): T[] {\n _nat(s);\n if (e !== undefined) _nat(e);\n return a.slice(s, e);\n}"], "array/take": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _take<T>(a: readonly T[], n: number): T[] {\n return a.slice(0, _nat(n));\n}"], "array/drop": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _drop<T>(a: readonly T[], n: number): T[] {\n return a.slice(_nat(n));\n}"], "array/takeLast": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _takeLast<T>(a: readonly T[], n: number): T[] {\n return _nat(n) < a.length ? a.slice(a.length - n) : a.slice();\n}"], "array/dropLast": ["function _nat(n: number): number {\n if (!Number.isInteger(n) || n < 0) throw new RangeError('expected a whole number from 0, got ' + n);\n return n;\n}", "function _dropLast<T>(a: readonly T[], n: number): T[] {\n return _nat(n) < a.length ? a.slice(0, a.length - n) : [];\n}"], "array/includes": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _eq(a: Json | undefined, b: Json | undefined): boolean {\n const x = a ?? null;\n const y = b ?? null;\n if (x === y) return true;\n if (Array.isArray(x) && Array.isArray(y)) return x.length === y.length && x.every((v, i) => _eq(v, y[i]));\n if (x !== null && y !== null && typeof x === 'object' && typeof y === 'object' && !Array.isArray(x) && !Array.isArray(y)) {\n const kx = Object.keys(x);\n return kx.length === Object.keys(y).length && kx.every((k) => Object.hasOwn(y, k) && _eq(x[k], y[k]));\n }\n return false;\n}", "function _includes(a: readonly Json[], x: Json): boolean {\n return a.some((y) => _eq(y, x));\n}"], "array/indexOf": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _eq(a: Json | undefined, b: Json | undefined): boolean {\n const x = a ?? null;\n const y = b ?? null;\n if (x === y) return true;\n if (Array.isArray(x) && Array.isArray(y)) return x.length === y.length && x.every((v, i) => _eq(v, y[i]));\n if (x !== null && y !== null && typeof x === 'object' && typeof y === 'object' && !Array.isArray(x) && !Array.isArray(y)) {\n const kx = Object.keys(x);\n return kx.length === Object.keys(y).length && kx.every((k) => Object.hasOwn(y, k) && _eq(x[k], y[k]));\n }\n return false;\n}", "function _indexOf(a: readonly Json[], x: Json): number {\n return a.findIndex((y) => _eq(y, x));\n}"], "array/unique": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _eq(a: Json | undefined, b: Json | undefined): boolean {\n const x = a ?? null;\n const y = b ?? null;\n if (x === y) return true;\n if (Array.isArray(x) && Array.isArray(y)) return x.length === y.length && x.every((v, i) => _eq(v, y[i]));\n if (x !== null && y !== null && typeof x === 'object' && typeof y === 'object' && !Array.isArray(x) && !Array.isArray(y)) {\n const kx = Object.keys(x);\n return kx.length === Object.keys(y).length && kx.every((k) => Object.hasOwn(y, k) && _eq(x[k], y[k]));\n }\n return false;\n}", "function _unique<T extends Json>(a: readonly T[]): T[] {\n const out: T[] = [];\n for (const x of a) if (!out.some((y) => _eq(y, x))) out.push(x);\n return out;\n}"], "array/zip": ["function _zip<A, B>(a: readonly A[], b: readonly B[]): Array<[A, B]> {\n const n = Math.min(a.length, b.length);\n const out: Array<[A, B]> = [];\n for (let i = 0; i < n; i++) out.push([a[i] as A, b[i] as B]);\n return out;\n}"], "array/concat": ["function _concat<T>(...parts: ReadonlyArray<readonly T[]>): T[] {\n return parts.flat();\n}"], "array/sort": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _cmp(a: Json | undefined, b: Json | undefined): number {\n const x = a ?? null;\n const y = b ?? null;\n if (x === null || y === null) return x === y ? 0 : x === null ? -1 : 1;\n if (typeof x === 'number' && typeof y === 'number') return x < y ? -1 : x > y ? 1 : 0;\n if (typeof x === 'string' && typeof y === 'string') {\n const p = [...x];\n const q = [...y];\n for (let i = 0; i < Math.min(p.length, q.length); i++) {\n const d = ((p[i] ?? '').codePointAt(0) ?? 0) - ((q[i] ?? '').codePointAt(0) ?? 0);\n if (d !== 0) return d < 0 ? -1 : 1;\n }\n return p.length < q.length ? -1 : p.length > q.length ? 1 : 0;\n }\n if (typeof x === 'boolean' && typeof y === 'boolean') return x === y ? 0 : x ? 1 : -1;\n if (typeof x === 'object' && typeof y === 'object') return 0;\n throw new TypeError('cannot compare these values');\n}", "function _sort<T extends Json>(a: readonly T[], k?: string | null, o: string = 'asc'): T[] {\n const key = (x: T): Json | undefined => (k === undefined || k === null ? x : typeof x === 'object' && x !== null && !Array.isArray(x) ? x[k] : null);\n return [...a].sort((x, y) => (o === 'desc' ? _cmp(key(y), key(x)) : _cmp(key(x), key(y))));\n}"], "object/get": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _isObject(v: Json | undefined): v is { [k: string]: Json } {\n return v !== null && v !== undefined && typeof v === 'object' && !Array.isArray(v);\n}", "function _path(p: string): string[] {\n const out: string[] = [];\n let cur = '';\n const cs = [...p];\n for (let i = 0; i < cs.length; i++) {\n const c = cs[i] ?? '';\n if (c === String.fromCharCode(92) && cs[i + 1] === '.') {\n cur += '.';\n i++;\n } else if (c === '.') {\n out.push(cur);\n cur = '';\n } else {\n cur += c;\n }\n }\n out.push(cur);\n return out;\n}", "function _get(o: Json | undefined, p: string, d: Json = null): Json {\n let cur: Json | undefined = o;\n for (const s of _path(p)) {\n if (_isObject(cur)) {\n if (!Object.hasOwn(cur, s)) return d;\n cur = cur[s];\n } else if (Array.isArray(cur) && /^[0-9]+$/.test(s) && Number(s) < cur.length) {\n cur = cur[Number(s)];\n } else {\n return d;\n }\n }\n return cur ?? null;\n}"], "object/has": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _isObject(v: Json | undefined): v is { [k: string]: Json } {\n return v !== null && v !== undefined && typeof v === 'object' && !Array.isArray(v);\n}", "function _path(p: string): string[] {\n const out: string[] = [];\n let cur = '';\n const cs = [...p];\n for (let i = 0; i < cs.length; i++) {\n const c = cs[i] ?? '';\n if (c === String.fromCharCode(92) && cs[i + 1] === '.') {\n cur += '.';\n i++;\n } else if (c === '.') {\n out.push(cur);\n cur = '';\n } else {\n cur += c;\n }\n }\n out.push(cur);\n return out;\n}", "function _has(o: Json | undefined, p: string): boolean {\n let cur: Json | undefined = o;\n for (const s of _path(p)) {\n if (_isObject(cur)) {\n if (!Object.hasOwn(cur, s)) return false;\n cur = cur[s];\n } else if (Array.isArray(cur) && /^[0-9]+$/.test(s) && Number(s) < cur.length) {\n cur = cur[Number(s)];\n } else {\n return false;\n }\n }\n return true;\n}"], "object/set": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _isObject(v: Json | undefined): v is { [k: string]: Json } {\n return v !== null && v !== undefined && typeof v === 'object' && !Array.isArray(v);\n}", "function _setPath(cur: Json | undefined, segs: readonly string[], v: Json): Json | undefined {\n const [head, ...rest] = segs;\n if (head === undefined) return v;\n if (cur === undefined) return { [head]: _setPath(undefined, rest, v) ?? null };\n if (_isObject(cur)) {\n const n = _setPath(Object.hasOwn(cur, head) ? cur[head] : undefined, rest, v);\n return n === undefined ? undefined : { ...cur, [head]: n };\n }\n if (Array.isArray(cur) && /^[0-9]+$/.test(head) && Number(head) < cur.length) {\n const n = _setPath(cur[Number(head)], rest, v);\n return n === undefined ? undefined : cur.map((x, i) => (i === Number(head) ? n : x));\n }\n return undefined;\n}", "function _path(p: string): string[] {\n const out: string[] = [];\n let cur = '';\n const cs = [...p];\n for (let i = 0; i < cs.length; i++) {\n const c = cs[i] ?? '';\n if (c === String.fromCharCode(92) && cs[i + 1] === '.') {\n cur += '.';\n i++;\n } else if (c === '.') {\n out.push(cur);\n cur = '';\n } else {\n cur += c;\n }\n }\n out.push(cur);\n return out;\n}", "function _set(o: { [k: string]: Json }, p: string, v: Json): Json | null {\n return _setPath(o, _path(p), v) ?? null;\n}"], "object/pick": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _pick(o: { [k: string]: Json }, ks: readonly string[]): { [k: string]: Json } {\n const out: { [k: string]: Json } = {};\n for (const k of ks) if (Object.hasOwn(o, k)) out[k] = o[k] ?? null;\n return out;\n}"], "object/omit": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _omit(o: { [k: string]: Json }, ks: readonly string[]): { [k: string]: Json } {\n const out: { [k: string]: Json } = {};\n for (const k of Object.keys(o)) if (!ks.includes(k)) out[k] = o[k] ?? null;\n return out;\n}"], "object/fromEntries": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _fromEntries(es: ReadonlyArray<readonly [string, Json]>): { [k: string]: Json } {\n return Object.fromEntries(es);\n}"], "json/parse": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _jsonParse(t: string): Json {\n try {\n return JSON.parse(t) as Json;\n } catch {\n return null;\n }\n}"], "math/round": ["function _round(x: number, d: number = 0): number {\n const m = 10 ** d;\n const r = Math.floor(Math.abs(x) * m + 0.5) / m;\n return x < 0 ? -r : r;\n}"], "math/sqrt": ["function _sqrt(x: number): number | null {\n return x < 0 ? null : Math.sqrt(x);\n}"], "math/ln": ["function _ln(x: number): number | null {\n return x <= 0 ? null : Math.log(x);\n}"], "math/log10": ["function _log10(x: number): number | null {\n return x <= 0 ? null : Math.log10(x);\n}"], "math/pow": ["function _pow(a: number, b: number): number | null {\n const r = Math.pow(a, b);\n return Number.isFinite(r) ? r : null;\n}"], "math/clamp": ["function _clamp(v: number, lo: number, hi: number): number {\n return Math.min(Math.max(v, lo), hi);\n}"], "validate/required": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _required(v: Json | undefined): boolean {\n return v !== null && v !== undefined && v !== '';\n}"], "validate/object": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _isObject(v: Json | undefined): v is { [k: string]: Json } {\n return v !== null && v !== undefined && typeof v === 'object' && !Array.isArray(v);\n}"], "validate/length": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _length(v: string | readonly Json[]): number {\n return typeof v === 'string' ? [...v].length : v.length;\n}"], "validate/minLength": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _length(v: string | readonly Json[]): number {\n return typeof v === 'string' ? [...v].length : v.length;\n}"], "validate/maxLength": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _length(v: string | readonly Json[]): number {\n return typeof v === 'string' ? [...v].length : v.length;\n}"], "validate/oneOf": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _eq(a: Json | undefined, b: Json | undefined): boolean {\n const x = a ?? null;\n const y = b ?? null;\n if (x === y) return true;\n if (Array.isArray(x) && Array.isArray(y)) return x.length === y.length && x.every((v, i) => _eq(v, y[i]));\n if (x !== null && y !== null && typeof x === 'object' && typeof y === 'object' && !Array.isArray(x) && !Array.isArray(y)) {\n const kx = Object.keys(x);\n return kx.length === Object.keys(y).length && kx.every((k) => Object.hasOwn(y, k) && _eq(x[k], y[k]));\n }\n return false;\n}", "function _includes(a: readonly Json[], x: Json): boolean {\n return a.some((y) => _eq(y, x));\n}"], "validate/equals": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _eq(a: Json | undefined, b: Json | undefined): boolean {\n const x = a ?? null;\n const y = b ?? null;\n if (x === y) return true;\n if (Array.isArray(x) && Array.isArray(y)) return x.length === y.length && x.every((v, i) => _eq(v, y[i]));\n if (x !== null && y !== null && typeof x === 'object' && typeof y === 'object' && !Array.isArray(x) && !Array.isArray(y)) {\n const kx = Object.keys(x);\n return kx.length === Object.keys(y).length && kx.every((k) => Object.hasOwn(y, k) && _eq(x[k], y[k]));\n }\n return false;\n}"], "unsupported": ["function _unsupported(name: string): never {\n throw new Error('no native template for operator ' + name);\n}"], "array/find": ["function _find<T>(a: readonly T[], f: (x: T, i: number) => boolean): T | null {\n const i = a.findIndex(f);\n return i < 0 ? null : (a[i] as T);\n}"], "object/merge": ["type Json = null | boolean | number | string | Json[] | { [k: string]: Json };", "function _merge(...os: Array<{ [k: string]: Json }>): { [k: string]: Json } {\n return Object.assign({}, ...os) as { [k: string]: Json };\n}"] }
|
|
35
35
|
helperGap: "\n\n"
|
|
36
36
|
imports: { }
|
|
37
37
|
portEffects: ["persist", "fetch", "fetch-stream", "notify", "navigate", "navigate-back", "call-service", "cancel-call", "send-server", "spawn", "despawn", "log"]
|
|
@@ -67,9 +67,25 @@ orbital LoloTypescriptOrbital {
|
|
|
67
67
|
setAssign: "{{target}} = {{value}}"
|
|
68
68
|
emitForm: "this.emit({{event}}, {{payload}})"
|
|
69
69
|
voidPayload: "{}"
|
|
70
|
+
programOpen: ["export class Program extends _Router {", "{{i}}constructor(entities: { {{entities}} }{{store}}) {", "{{i}}{{i}}super();"]
|
|
71
|
+
programEntity: "{{key}}: {{entity}}"
|
|
72
|
+
programEntitySep: "; "
|
|
73
|
+
programTrait: "{{i}}{{i}}this.add({{key}}, new {{class}}(entities[{{key}}]));"
|
|
74
|
+
programHandles: "{{i}}{{i}}this.handles[{{key}}] = {{table}};"
|
|
75
|
+
programRow: "{{i}}{{i}}this.row({{source}}, {{event}}, {{target}}, {{trigger}}, {{guard}}, {{map}});"
|
|
76
|
+
deliverOpen: ["{{i}}}", "", "{{i}}deliver(target: string, event: string, payload: EventPayload): void {", "{{i}}{{i}}const t = this.traits[target];"]
|
|
77
|
+
deliverCase: "{{i}}{{i}}if (target === {{target}} && event === {{event}} && t instanceof {{class}}) return t.{{method}}({{arg}});"
|
|
78
|
+
deliverCasePlain: "{{i}}{{i}}if (target === {{target}} && event === {{event}} && t instanceof {{class}}) return t.{{method}}();"
|
|
79
|
+
deliverClose: ["{{i}}}"]
|
|
80
|
+
programClose: ["}"]
|
|
81
|
+
payloadDecode: "_decode<{{type}}>({{value}})"
|
|
82
|
+
guardForm: ["", "function {{name}}(payload_json: EventPayload): boolean {", "{{i}}const payload = {{decode}};", "{{i}}return {{expr}};", "}"]
|
|
83
|
+
mapForm: ["", "function {{name}}(payload_json: EventPayload): EventPayload {", "{{i}}const payload = {{decode}};", "{{i}}return {{expr}};", "}"]
|
|
84
|
+
guardName: "_guard{{n}}"
|
|
85
|
+
mapName: "_map{{n}}"
|
|
70
86
|
payloadType: "{{trait}}{{event}}Payload"
|
|
71
87
|
payloadCtor: "({ {{fields}} } satisfies {{type}})"
|
|
72
|
-
payloadField: "{{name}}: {{value}}"
|
|
88
|
+
payloadField: "{{name}}: _opt({{value}})"
|
|
73
89
|
payloadSep: ", "
|
|
74
90
|
commentForm: "// {{text}}"
|
|
75
91
|
indent: " "
|
|
@@ -86,8 +102,13 @@ orbital LoloTypescriptOrbital {
|
|
|
86
102
|
classOpen: "export class {{class}} {"
|
|
87
103
|
classClose: "}"
|
|
88
104
|
classEmpty: ""
|
|
89
|
-
constructor: ["{{i}}state: string = {{initial}};", "{{i}}entity: {{entity}};", "{{i}}readonly ports: Record<string, (...args: EventPayload[string][]) => void>;", "{{i}}readonly config = {{config}};", "{{i}}readonly emitted: Array<{ event: string; payload: EventPayload }> = [];", "", "{{i}}constructor(entity: {{entity}}, ports: Record<string, (...args: EventPayload[string][]) => void> = {}, config: Partial<{{class}}['config']> = {}) {", "{{i}}{{i}}this.entity = entity;", "{{i}}{{i}}this.ports = ports;", "{{i}}{{i}}this.config = { ...this.config, ...config };", "{{i}}}"]
|
|
105
|
+
constructor: ["{{i}}state: string = {{initial}};", "{{i}}entity: {{entity}};", "{{i}}readonly ports: Record<string, (...args: EventPayload[string][]) => void>;", "{{i}}readonly config = {{config}};", "{{i}}readonly emitted: Array<{ event: string; payload: EventPayload; completion?: boolean }> = [];", "", "{{i}}constructor(entity: {{entity}}, ports: Record<string, (...args: EventPayload[string][]) => void> = {}, config: Partial<{{class}}['config']> = {}) {", "{{i}}{{i}}this.entity = entity;", "{{i}}{{i}}this.ports = ports;", "{{i}}{{i}}this.config = { ...this.config, ...config };", "{{i}}}"]
|
|
90
106
|
emitMethod: ["{{i}}emit(event: string, payload: EventPayload): void {", "{{i}}{{i}}this.emitted.push({ event, payload });", "{{i}}}", "", "{{i}}callPort(name: string, ...args: EventPayload[string][]): void {", "{{i}}{{i}}const port = this.ports[name];", "{{i}}{{i}}if (port === undefined) throw new Error('no port named ' + name);", "{{i}}{{i}}port(...args);", "{{i}}}"]
|
|
107
|
+
completeMethod: ["", "{{i}}store: Store | null = null;", "", "{{i}}complete(answer: Answer, success: string | null, failure: string | null): void {", "{{i}}{{i}}const route = answer.ok ? success : failure;", "{{i}}{{i}}if (route !== null) this.emitted.push({ event: route, payload: answer.payload, completion: true });", "{{i}}}", "", "{{i}}useStore(): Store {", "{{i}}{{i}}if (this.store === null) throw new Error('no store');", "{{i}}{{i}}return this.store;", "{{i}}}"]
|
|
108
|
+
routedEffects: {"persist": "this.complete(this.useStore().persist({{args}}), {{success}}, {{failure}})", "fetch": "this.complete(this.useStore().fetch({{entity}}, {{filter}}), {{success}}, {{failure}})"}
|
|
109
|
+
fetchAll: "null"
|
|
110
|
+
programStoreParam: ", store: Store = new MemoryStore()"
|
|
111
|
+
programTraitStore: "{{i}}{{i}}const t{{n}} = new {{class}}(entities[{{key}}]);\n{{i}}{{i}}t{{n}}.store = store;\n{{i}}{{i}}this.add({{key}}, t{{n}});"
|
|
91
112
|
methodOpen: "{{i}}{{method}}(payload: {{payloadType}}): void {"
|
|
92
113
|
methodOpenPlain: "{{i}}{{method}}(): void {"
|
|
93
114
|
methodClose: "{{i}}}"
|
|
@@ -77,11 +77,11 @@ orbital MetaAdsOrbital {
|
|
|
77
77
|
(if (or (= @sp null) (= @im null) (= @cl null))
|
|
78
78
|
(emit META_ADS_FAILED { code: "MALFORMED_REPLY", message: "Meta Graph API replied with an insights row whose counts are not numbers" })
|
|
79
79
|
(emit META_ADS_SPEND_RESULT { spend: @sp, currency: (object/get @row account_currency ""), impressions: @im, clicks: @cl })))))))
|
|
80
|
-
META_ADS_SPEND_FAILED -> idle when (
|
|
80
|
+
META_ADS_SPEND_FAILED -> idle when (array/includes ["denied", "unsupported"] @payload.kind)
|
|
81
81
|
(emit META_ADS_FAILED { message: @payload.error })
|
|
82
82
|
META_ADS_SPEND_FAILED -> idle when (= @payload.kind "timeout")
|
|
83
83
|
(emit META_ADS_FAILED { message: "The operation was aborted due to timeout" })
|
|
84
|
-
META_ADS_SPEND_FAILED -> idle when (and (!= @payload.kind "denied") (!= @payload.kind "timeout"))
|
|
84
|
+
META_ADS_SPEND_FAILED -> idle when (and (!= @payload.kind "denied") (!= @payload.kind "unsupported") (!= @payload.kind "timeout"))
|
|
85
85
|
(emit META_ADS_FAILED { message: "fetch failed" })
|
|
86
86
|
|
|
87
87
|
META_ADS_LIST_CAMPAIGNS -> idle when (= (if (!= (default @payload.accountId "") "") (default @payload.accountId "") @config.defaultAccountId) "")
|
|
@@ -111,11 +111,11 @@ orbital MetaAdsOrbital {
|
|
|
111
111
|
(if (array/some @rows (fn r (= @r.dailyBudget null)))
|
|
112
112
|
(emit META_ADS_FAILED { code: "MALFORMED_REPLY", message: "Meta Graph API replied with a campaign whose daily budget is not a number" })
|
|
113
113
|
(emit META_ADS_CAMPAIGNS_RESULT { campaigns: @rows })))
|
|
114
|
-
META_ADS_CAMPAIGNS_FAILED -> idle when (
|
|
114
|
+
META_ADS_CAMPAIGNS_FAILED -> idle when (array/includes ["denied", "unsupported"] @payload.kind)
|
|
115
115
|
(emit META_ADS_FAILED { message: @payload.error })
|
|
116
116
|
META_ADS_CAMPAIGNS_FAILED -> idle when (= @payload.kind "timeout")
|
|
117
117
|
(emit META_ADS_FAILED { message: "The operation was aborted due to timeout" })
|
|
118
|
-
META_ADS_CAMPAIGNS_FAILED -> idle when (and (!= @payload.kind "denied") (!= @payload.kind "timeout"))
|
|
118
|
+
META_ADS_CAMPAIGNS_FAILED -> idle when (and (!= @payload.kind "denied") (!= @payload.kind "unsupported") (!= @payload.kind "timeout"))
|
|
119
119
|
(emit META_ADS_FAILED { message: "fetch failed" })
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -10,6 +10,7 @@ orbital StdioLinesOrbital {
|
|
|
10
10
|
inputBuffer : bytes = ""
|
|
11
11
|
inputEof : boolean = false
|
|
12
12
|
awaitingAck : boolean = false
|
|
13
|
+
delivered : number = 0
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
trait StdioLines -> StdioLinesSession [optimistic] {
|
|
@@ -37,13 +38,15 @@ orbital StdioLinesOrbital {
|
|
|
37
38
|
STDIO_PUMP -> closed when (and (and (not @entity.awaitingAck) (>= (bytes/index-of @entity.inputBuffer (bytes/from-string "\n")) 0)) (= (bytes/to-string (bytes/slice @entity.inputBuffer 0 (bytes/index-of @entity.inputBuffer (bytes/from-string "\n")))) null))
|
|
38
39
|
(emit STDIO_ERROR { error: "standard input line is not valid UTF-8" })
|
|
39
40
|
STDIO_PUMP -> active when (and (and (not @entity.awaitingAck) (>= (bytes/index-of @entity.inputBuffer (bytes/from-string "\n")) 0)) (!= (bytes/to-string (bytes/slice @entity.inputBuffer 0 (bytes/index-of @entity.inputBuffer (bytes/from-string "\n")))) null))
|
|
40
|
-
(emit INPUT_LINE { line: (bytes/to-string (bytes/slice @entity.inputBuffer 0 (bytes/index-of @entity.inputBuffer (bytes/from-string "\n")))) })
|
|
41
|
+
(emit INPUT_LINE { line: (bytes/to-string (bytes/slice @entity.inputBuffer 0 (bytes/index-of @entity.inputBuffer (bytes/from-string "\n")))) seq: @entity.delivered })
|
|
42
|
+
(set @entity.delivered (+ @entity.delivered 1))
|
|
41
43
|
(set @entity.inputBuffer (bytes/slice @entity.inputBuffer (+ (bytes/index-of @entity.inputBuffer (bytes/from-string "\n")) 1)))
|
|
42
44
|
(set @entity.awaitingAck true)
|
|
43
45
|
STDIO_PUMP -> closed when (and (and (not @entity.awaitingAck) (= (bytes/index-of @entity.inputBuffer (bytes/from-string "\n")) -1) @entity.inputEof (> (bytes/length @entity.inputBuffer) 0)) (= (bytes/to-string @entity.inputBuffer) null))
|
|
44
46
|
(emit STDIO_ERROR { error: "standard input line is not valid UTF-8" })
|
|
45
47
|
STDIO_PUMP -> active when (and (and (not @entity.awaitingAck) (= (bytes/index-of @entity.inputBuffer (bytes/from-string "\n")) -1) @entity.inputEof (> (bytes/length @entity.inputBuffer) 0)) (!= (bytes/to-string @entity.inputBuffer) null))
|
|
46
|
-
(emit INPUT_LINE { line: (bytes/to-string @entity.inputBuffer) })
|
|
48
|
+
(emit INPUT_LINE { line: (bytes/to-string @entity.inputBuffer) seq: @entity.delivered })
|
|
49
|
+
(set @entity.delivered (+ @entity.delivered 1))
|
|
47
50
|
(set @entity.inputBuffer (bytes/from-string ""))
|
|
48
51
|
(set @entity.awaitingAck true)
|
|
49
52
|
STDIO_PUMP -> closed when (and (not @entity.awaitingAck) @entity.inputEof (= (bytes/length @entity.inputBuffer) 0))
|
|
@@ -65,8 +68,8 @@ orbital StdioLinesOrbital {
|
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
emits {
|
|
68
|
-
INPUT_LINE -> external { line : string! }
|
|
69
|
-
@description "One UTF-8 line without its LF delimiter; acknowledge with INPUT_NEXT after processing."
|
|
71
|
+
INPUT_LINE -> external { line : string! seq : number! }
|
|
72
|
+
@description "One UTF-8 line without its LF delimiter and its 0-based delivery number, so two equal lines are distinct deliveries (EXEC-QUEUE-4); acknowledge with INPUT_NEXT after processing."
|
|
70
73
|
STDIO_ERROR -> external { error : string! }
|
|
71
74
|
@description "A native standard input or output operation failed."
|
|
72
75
|
STDIO_CLOSED -> external {}
|
|
@@ -204,48 +204,48 @@ orbital YoutubeOrbital {
|
|
|
204
204
|
(if (>= @payload.status 400) @payload.body (str/concat "Request failed with status code " @payload.status))))
|
|
205
205
|
}))))
|
|
206
206
|
|
|
207
|
-
YOUTUBE_UNREACHED -> idle when (and (!= @payload.kind "refused") (!= @payload.kind "denied") (array/some @entity.pending (fn p (and (= @p.key @payload.key) (= @p.job.kind "search") (< @p.job.attempt 2)))))
|
|
207
|
+
YOUTUBE_UNREACHED -> idle when (and (!= @payload.kind "refused") (!= @payload.kind "denied") (!= @payload.kind "unsupported") (array/some @entity.pending (fn p (and (= @p.key @payload.key) (= @p.job.kind "search") (< @p.job.attempt 2)))))
|
|
208
208
|
(let ((e (array/find @entity.pending (fn p (= @p.key @payload.key)))))
|
|
209
209
|
(do
|
|
210
210
|
(set @entity.pending (array/filter @entity.pending (fn p (!= @p.key @payload.key))))
|
|
211
211
|
(if (= @e null)
|
|
212
212
|
(emit YOUTUBE_SEARCH_FAILED { message: "YouTube replied for a request that is no longer pending" })
|
|
213
213
|
(emit YOUTUBE_REQUEST { kind: @e.job.kind, attempt: (+ @e.job.attempt 1), query: @e.job.query, maxResults: @e.job.maxResults, type: @e.job.type, id: @e.job.id }))))
|
|
214
|
-
YOUTUBE_UNREACHED -> idle when (and (!= @payload.kind "denied") (or (= @payload.kind "refused") (array/some @entity.pending (fn p (and (= @p.key @payload.key) (>= @p.job.attempt 2))))) (array/some @entity.pending (fn p (and (= @p.key @payload.key) (= @p.job.kind "search")))))
|
|
214
|
+
YOUTUBE_UNREACHED -> idle when (and (!= @payload.kind "denied") (!= @payload.kind "unsupported") (or (= @payload.kind "refused") (array/some @entity.pending (fn p (and (= @p.key @payload.key) (>= @p.job.attempt 2))))) (array/some @entity.pending (fn p (and (= @p.key @payload.key) (= @p.job.kind "search")))))
|
|
215
215
|
(do
|
|
216
216
|
(set @entity.pending (array/filter @entity.pending (fn p (!= @p.key @payload.key))))
|
|
217
217
|
(emit YOUTUBE_REJECTED { kind: "search", message: @payload.error }))
|
|
218
|
-
YOUTUBE_UNREACHED -> idle when (and (
|
|
218
|
+
YOUTUBE_UNREACHED -> idle when (and (array/includes ["denied", "unsupported"] @payload.kind) (array/some @entity.pending (fn p (and (= @p.key @payload.key) (= @p.job.kind "search")))))
|
|
219
219
|
(do
|
|
220
220
|
(set @entity.pending (array/filter @entity.pending (fn p (!= @p.key @payload.key))))
|
|
221
221
|
(emit YOUTUBE_REJECTED { kind: "search", message: @payload.error }))
|
|
222
|
-
YOUTUBE_UNREACHED -> idle when (and (!= @payload.kind "refused") (!= @payload.kind "denied") (array/some @entity.pending (fn p (and (= @p.key @payload.key) (= @p.job.kind "video") (< @p.job.attempt 2)))))
|
|
222
|
+
YOUTUBE_UNREACHED -> idle when (and (!= @payload.kind "refused") (!= @payload.kind "denied") (!= @payload.kind "unsupported") (array/some @entity.pending (fn p (and (= @p.key @payload.key) (= @p.job.kind "video") (< @p.job.attempt 2)))))
|
|
223
223
|
(let ((e (array/find @entity.pending (fn p (= @p.key @payload.key)))))
|
|
224
224
|
(do
|
|
225
225
|
(set @entity.pending (array/filter @entity.pending (fn p (!= @p.key @payload.key))))
|
|
226
226
|
(if (= @e null)
|
|
227
227
|
(emit YOUTUBE_VIDEO_FAILED { message: "YouTube replied for a request that is no longer pending" })
|
|
228
228
|
(emit YOUTUBE_REQUEST { kind: @e.job.kind, attempt: (+ @e.job.attempt 1), query: @e.job.query, maxResults: @e.job.maxResults, type: @e.job.type, id: @e.job.id }))))
|
|
229
|
-
YOUTUBE_UNREACHED -> idle when (and (!= @payload.kind "denied") (or (= @payload.kind "refused") (array/some @entity.pending (fn p (and (= @p.key @payload.key) (>= @p.job.attempt 2))))) (array/some @entity.pending (fn p (and (= @p.key @payload.key) (= @p.job.kind "video")))))
|
|
229
|
+
YOUTUBE_UNREACHED -> idle when (and (!= @payload.kind "denied") (!= @payload.kind "unsupported") (or (= @payload.kind "refused") (array/some @entity.pending (fn p (and (= @p.key @payload.key) (>= @p.job.attempt 2))))) (array/some @entity.pending (fn p (and (= @p.key @payload.key) (= @p.job.kind "video")))))
|
|
230
230
|
(do
|
|
231
231
|
(set @entity.pending (array/filter @entity.pending (fn p (!= @p.key @payload.key))))
|
|
232
232
|
(emit YOUTUBE_REJECTED { kind: "video", message: @payload.error }))
|
|
233
|
-
YOUTUBE_UNREACHED -> idle when (and (
|
|
233
|
+
YOUTUBE_UNREACHED -> idle when (and (array/includes ["denied", "unsupported"] @payload.kind) (array/some @entity.pending (fn p (and (= @p.key @payload.key) (= @p.job.kind "video")))))
|
|
234
234
|
(do
|
|
235
235
|
(set @entity.pending (array/filter @entity.pending (fn p (!= @p.key @payload.key))))
|
|
236
236
|
(emit YOUTUBE_REJECTED { kind: "video", message: @payload.error }))
|
|
237
|
-
YOUTUBE_UNREACHED -> idle when (and (!= @payload.kind "refused") (!= @payload.kind "denied") (array/some @entity.pending (fn p (and (= @p.key @payload.key) (= @p.job.kind "channel") (< @p.job.attempt 2)))))
|
|
237
|
+
YOUTUBE_UNREACHED -> idle when (and (!= @payload.kind "refused") (!= @payload.kind "denied") (!= @payload.kind "unsupported") (array/some @entity.pending (fn p (and (= @p.key @payload.key) (= @p.job.kind "channel") (< @p.job.attempt 2)))))
|
|
238
238
|
(let ((e (array/find @entity.pending (fn p (= @p.key @payload.key)))))
|
|
239
239
|
(do
|
|
240
240
|
(set @entity.pending (array/filter @entity.pending (fn p (!= @p.key @payload.key))))
|
|
241
241
|
(if (= @e null)
|
|
242
242
|
(emit YOUTUBE_CHANNEL_FAILED { message: "YouTube replied for a request that is no longer pending" })
|
|
243
243
|
(emit YOUTUBE_REQUEST { kind: @e.job.kind, attempt: (+ @e.job.attempt 1), query: @e.job.query, maxResults: @e.job.maxResults, type: @e.job.type, id: @e.job.id }))))
|
|
244
|
-
YOUTUBE_UNREACHED -> idle when (and (!= @payload.kind "denied") (or (= @payload.kind "refused") (array/some @entity.pending (fn p (and (= @p.key @payload.key) (>= @p.job.attempt 2))))) (array/some @entity.pending (fn p (and (= @p.key @payload.key) (= @p.job.kind "channel")))))
|
|
244
|
+
YOUTUBE_UNREACHED -> idle when (and (!= @payload.kind "denied") (!= @payload.kind "unsupported") (or (= @payload.kind "refused") (array/some @entity.pending (fn p (and (= @p.key @payload.key) (>= @p.job.attempt 2))))) (array/some @entity.pending (fn p (and (= @p.key @payload.key) (= @p.job.kind "channel")))))
|
|
245
245
|
(do
|
|
246
246
|
(set @entity.pending (array/filter @entity.pending (fn p (!= @p.key @payload.key))))
|
|
247
247
|
(emit YOUTUBE_REJECTED { kind: "channel", message: @payload.error }))
|
|
248
|
-
YOUTUBE_UNREACHED -> idle when (and (
|
|
248
|
+
YOUTUBE_UNREACHED -> idle when (and (array/includes ["denied", "unsupported"] @payload.kind) (array/some @entity.pending (fn p (and (= @p.key @payload.key) (= @p.job.kind "channel")))))
|
|
249
249
|
(do
|
|
250
250
|
(set @entity.pending (array/filter @entity.pending (fn p (!= @p.key @payload.key))))
|
|
251
251
|
(emit YOUTUBE_REJECTED { kind: "channel", message: @payload.error }))
|