trellis 3.1.34 → 3.2.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/CHANGELOG.md +16 -5
- package/README.md +19 -2
- package/bin/trellis.mjs +2 -75
- package/dist/better-sqlite-backend-2P4F6AOJ.js +209 -0
- package/dist/{better-sqlite-backend-ahx5p0br.js → better-sqlite-backend-PII64VE6.js} +37 -25
- package/dist/better-sqlite-backend-VUBVQ7SN.js +209 -0
- package/dist/better-sqlite-backend-Y3AQN65E.js +159 -0
- package/dist/better-sqlite-backend-Y3M7DXOX.js +159 -0
- package/dist/boot-middleware-FJDGVUM4.js +9 -0
- package/dist/boot-middleware-MHLHFCUC.js +9 -0
- package/dist/boot-middleware-MLJUTLUM.js +9 -0
- package/dist/boot-middleware-ZZPDZNYR.js +9 -0
- package/dist/{index-wncptktd.js → chunk-276LKLZR.js} +126 -59
- package/dist/chunk-2BRTCEHB.js +143 -0
- package/dist/chunk-2CX5UCRV.js +111 -0
- package/dist/chunk-2ESYSVXG.js +48 -0
- package/dist/{index-yp88he8n.js → chunk-2I5JU73Y.js} +88 -64
- package/dist/{index-w5wccer3.js → chunk-2UNSRRNB.js} +10 -5
- package/dist/{index-4wxa8xz4.js → chunk-335UEHQR.js} +158 -22
- package/dist/chunk-36VSSTL7.js +357 -0
- package/dist/chunk-3ETIIPPB.js +1077 -0
- package/dist/chunk-3GDRZTAW.js +45 -0
- package/dist/chunk-44FFQKQX.js +142 -0
- package/dist/chunk-4CF2L46N.js +29 -0
- package/dist/chunk-4HYPLFJD.js +150 -0
- package/dist/chunk-4XIVMVHC.js +361 -0
- package/dist/chunk-5CINODKT.js +41 -0
- package/dist/chunk-5ESGWJ5L.js +45 -0
- package/dist/chunk-5FGLQGMF.js +1676 -0
- package/dist/chunk-5IQZFITY.js +357 -0
- package/dist/{index-wt8rz4gn.js → chunk-5JWFAQDW.js} +41 -23
- package/dist/{index-7pjz3tsy.js → chunk-62UHTVU3.js} +50 -16
- package/dist/{index-h32txmxe.js → chunk-66UJQT2I.js} +6 -13
- package/dist/chunk-6CTA6MCE.js +340 -0
- package/dist/{index-4cdr7x2x.js → chunk-6RNNVOAS.js} +178 -109
- package/dist/chunk-6X23PZ6H.js +969 -0
- package/dist/chunk-7C7LL6MB.js +315 -0
- package/dist/chunk-7F4HM3JG.js +394 -0
- package/dist/chunk-7KJ7T4D3.js +910 -0
- package/dist/chunk-7QQQNUB5.js +92 -0
- package/dist/{index-53f3b8p8.js → chunk-7QWJBS72.js} +210 -165
- package/dist/chunk-7R36OZK3.js +957 -0
- package/dist/chunk-7UPKCOHE.js +946 -0
- package/dist/chunk-7WQGTFVJ.js +7434 -0
- package/dist/chunk-A3BONW34.js +35 -0
- package/dist/chunk-AHMDVHBL.js +141 -0
- package/dist/chunk-AW6A4OZY.js +171 -0
- package/dist/chunk-B3ZIFA2O.js +2240 -0
- package/dist/chunk-BJ5EKCJ5.js +458 -0
- package/dist/chunk-BJ7EZ7FP.js +145 -0
- package/dist/chunk-BQBUVMRN.js +171 -0
- package/dist/chunk-BRGYDO7D.js +223 -0
- package/dist/chunk-BXSTJVE3.js +67 -0
- package/dist/chunk-C5KPSEDN.js +359 -0
- package/dist/chunk-CCTNYTUC.js +940 -0
- package/dist/chunk-CYQ2OVD2.js +35 -0
- package/dist/chunk-DDAK7YOE.js +299 -0
- package/dist/chunk-DRILKBY6.js +965 -0
- package/dist/chunk-DXE24HNN.js +45 -0
- package/dist/chunk-E7ICUNW7.js +945 -0
- package/dist/chunk-EAL2PUOE.js +10022 -0
- package/dist/chunk-ELT7MLZB.js +109 -0
- package/dist/chunk-EO3J7GRP.js +0 -0
- package/dist/chunk-EWEIRF6G.js +171 -0
- package/dist/chunk-F5VDGQJC.js +120 -0
- package/dist/chunk-FCPL3IEQ.js +98 -0
- package/dist/{index-nq520y6k.js → chunk-FDPKYSV7.js} +43 -31
- package/dist/chunk-FES3TC24.js +171 -0
- package/dist/chunk-FF36CQHZ.js +61 -0
- package/dist/chunk-FKQO5A3H.js +35 -0
- package/dist/chunk-FOWKR5TW.js +129 -0
- package/dist/chunk-FZVCXDYW.js +150 -0
- package/dist/chunk-G3XIHPSQ.js +361 -0
- package/dist/chunk-GD5QJXSS.js +98 -0
- package/dist/chunk-GFZCJ4EH.js +108 -0
- package/dist/chunk-GKJLYLVU.js +359 -0
- package/dist/chunk-GLM4HGN4.js +55 -0
- package/dist/chunk-GNXHXNVQ.js +113 -0
- package/dist/chunk-GSR6ILTM.js +277 -0
- package/dist/chunk-GWRIMRSX.js +45 -0
- package/dist/chunk-H72UW2HJ.js +45 -0
- package/dist/chunk-HGI74PXB.js +7417 -0
- package/dist/chunk-HGRA37LO.js +145 -0
- package/dist/chunk-HO4TURXW.js +1078 -0
- package/dist/chunk-HXSRQO3L.js +145 -0
- package/dist/chunk-IG2X2BVO.js +373 -0
- package/dist/chunk-IIJVDD54.js +373 -0
- package/dist/chunk-IUWVEEOX.js +145 -0
- package/dist/chunk-IX4BBOIT.js +394 -0
- package/dist/{index-yhwjgfvj.js → chunk-IXU4RMQM.js} +67 -60
- package/dist/chunk-J3WYZO3Q.js +211 -0
- package/dist/{index-vkpkfwhq.js → chunk-J6OUIION.js} +234 -194
- package/dist/{index-xzym9w0m.js → chunk-JA7AIHRK.js} +12 -7
- package/dist/chunk-JUEMDWLU.js +233 -0
- package/dist/chunk-K46RNFDE.js +171 -0
- package/dist/chunk-KAGU2XMY.js +359 -0
- package/dist/chunk-KCVYJNVX.js +394 -0
- package/dist/chunk-KFQGP6VL.js +33 -0
- package/dist/chunk-KKDRMIV6.js +419 -0
- package/dist/chunk-KQ4A2D2P.js +910 -0
- package/dist/chunk-KSU2GW22.js +958 -0
- package/dist/chunk-KYLIQ3YI.js +399 -0
- package/dist/chunk-KZYJJIRN.js +946 -0
- package/dist/chunk-LFOX744K.js +96 -0
- package/dist/{index-rv1p47gp.js → chunk-LHOVJEWR.js} +2756 -2307
- package/dist/{index-h9e2efx4.js → chunk-LNUIGRDZ.js} +71 -55
- package/dist/chunk-LOPXTPF3.js +120 -0
- package/dist/chunk-LZR3VIFU.js +907 -0
- package/dist/chunk-MBNBTJCR.js +394 -0
- package/dist/chunk-MCKGQKYU.js +15 -0
- package/dist/{index-skhn0agf.js → chunk-MLC5BUYO.js} +19 -20
- package/dist/chunk-MPXUVGT3.js +104 -0
- package/dist/chunk-MU6EOS6F.js +0 -0
- package/dist/chunk-MWRQ2TXT.js +357 -0
- package/dist/{index-nzb3am4f.js → chunk-NO73OK2I.js} +43 -21
- package/dist/chunk-NPE2YJHK.js +394 -0
- package/dist/{index-xhcp6xrn.js → chunk-NSDXU6QX.js} +654 -500
- package/dist/chunk-NXIRDSZ6.js +145 -0
- package/dist/chunk-NZWFNHCS.js +407 -0
- package/dist/chunk-O2AV5WMN.js +48 -0
- package/dist/{index-h7zxhhhh.js → chunk-OB4CMMX6.js} +46 -38
- package/dist/chunk-OBKU74FU.js +7411 -0
- package/dist/chunk-OQNDWRDE.js +145 -0
- package/dist/chunk-OVWAJMB6.js +394 -0
- package/dist/chunk-PDHLBTTD.js +45 -0
- package/dist/chunk-PEQNRKLG.js +210 -0
- package/dist/chunk-QERIS7QY.js +7403 -0
- package/dist/chunk-QHA2DM3C.js +373 -0
- package/dist/chunk-QLM4HSYC.js +45 -0
- package/dist/chunk-RSWUFTO2.js +857 -0
- package/dist/chunk-S2OT3TQJ.js +283 -0
- package/dist/chunk-S5PHSN5K.js +907 -0
- package/dist/chunk-SIAA4J6H.js +21 -0
- package/dist/chunk-SPSPV5BC.js +390 -0
- package/dist/chunk-SQBNLUIA.js +171 -0
- package/dist/chunk-STLN6A6B.js +355 -0
- package/dist/chunk-TCKXSOBP.js +123 -0
- package/dist/chunk-U7HV7GU2.js +17 -0
- package/dist/chunk-UBGUDMUV.js +59 -0
- package/dist/chunk-UGZHOGRA.js +39 -0
- package/dist/chunk-UICF66FS.js +359 -0
- package/dist/chunk-UK3EQREE.js +1078 -0
- package/dist/chunk-UPKPURVY.js +394 -0
- package/dist/chunk-URC74VCN.js +959 -0
- package/dist/chunk-USEINYUL.js +12 -0
- package/dist/{index-bmyt7k8n.js → chunk-UZRUP7QW.js} +12 -4
- package/dist/chunk-V3G7Q3QQ.js +102 -0
- package/dist/chunk-VDAKEOML.js +857 -0
- package/dist/chunk-VUJ6SA55.js +303 -0
- package/dist/chunk-VUJQLIML.js +141 -0
- package/dist/chunk-VWKLKLYB.js +267 -0
- package/dist/chunk-VYC3RZMK.js +277 -0
- package/dist/chunk-WMERMSWI.js +154 -0
- package/dist/chunk-WMR777PO.js +2213 -0
- package/dist/{index-n9f2qyh5.js → chunk-X46IECAC.js} +55 -33
- package/dist/chunk-X5FLTRUB.js +517 -0
- package/dist/chunk-X762XWVC.js +419 -0
- package/dist/chunk-XEN3OEYY.js +2234 -0
- package/dist/chunk-XMQ7G77X.js +260 -0
- package/dist/chunk-XZQ66K7A.js +124 -0
- package/dist/{index-w7ng765c.js → chunk-YCM7ZYEZ.js} +102 -49
- package/dist/chunk-YY3GF7DH.js +7411 -0
- package/dist/chunk-ZE5R3H4C.js +907 -0
- package/dist/chunk-ZHVI7BQN.js +1077 -0
- package/dist/chunk-ZMN5LUB7.js +7411 -0
- package/dist/chunk-ZUV4MD5U.js +94 -0
- package/dist/cli/errors.d.ts +6 -0
- package/dist/cli/errors.d.ts.map +1 -0
- package/dist/cli/examples.d.ts +23 -0
- package/dist/cli/examples.d.ts.map +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2338 -6190
- package/dist/client/index.d.ts +6 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +41 -21
- package/dist/client/live.d.ts +67 -0
- package/dist/client/live.d.ts.map +1 -0
- package/dist/client/reactive.d.ts +31 -0
- package/dist/client/reactive.d.ts.map +1 -0
- package/dist/client/sdk.d.ts +26 -2
- package/dist/client/sdk.d.ts.map +1 -1
- package/dist/client/sdk.js +9 -0
- package/dist/client/vcs-client.d.ts +129 -0
- package/dist/client/vcs-client.d.ts.map +1 -0
- package/dist/cms/index.js +171 -163
- package/dist/{config-8hczw0rs.js → config-KMY6RRK3.js} +8 -9
- package/dist/config-PFTP67TR.js +19 -0
- package/dist/config-VDMK2DUJ.js +19 -0
- package/dist/core/computation/index.d.ts +5 -0
- package/dist/core/computation/index.d.ts.map +1 -0
- package/dist/core/computation/rollup.d.ts +18 -0
- package/dist/core/computation/rollup.d.ts.map +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +168 -101
- package/dist/core/kernel/boot-middleware.d.ts +10 -0
- package/dist/core/kernel/boot-middleware.d.ts.map +1 -0
- package/dist/core/kernel/logic-middleware.d.ts +7 -1
- package/dist/core/kernel/logic-middleware.d.ts.map +1 -1
- package/dist/core/kernel/trellis-kernel.d.ts.map +1 -1
- package/dist/core/ontology/types.d.ts +5 -0
- package/dist/core/ontology/types.d.ts.map +1 -1
- package/dist/core/persist/better-sqlite-backend.d.ts +9 -2
- package/dist/core/persist/better-sqlite-backend.d.ts.map +1 -1
- package/dist/core/persist/factory.d.ts +6 -7
- package/dist/core/persist/factory.d.ts.map +1 -1
- package/dist/core/persist/factory.js +2 -3
- package/dist/core/persist/sqljs-backend.js +2 -3
- package/dist/db/index.d.ts +4 -1
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +69 -56
- package/dist/db/inspector.js +11 -19
- package/dist/decisions/index.js +9 -10
- package/dist/deploy-66EC752W.js +9 -0
- package/dist/deploy-SO7AFK6L.js +9 -0
- package/dist/embeddings/auto-embed.d.ts +2 -2
- package/dist/embeddings/auto-embed.d.ts.map +1 -1
- package/dist/embeddings/index.js +20 -22
- package/dist/embeddings/search.d.ts +2 -1
- package/dist/embeddings/search.d.ts.map +1 -1
- package/dist/embeddings/store.d.ts +25 -4
- package/dist/embeddings/store.d.ts.map +1 -1
- package/dist/engine-7GXBM4IT.js +7 -0
- package/dist/engine-NSR6BIF7.js +7 -0
- package/dist/engine.d.ts +32 -12
- package/dist/engine.d.ts.map +1 -1
- package/dist/factory-2P64OC7M.js +34 -0
- package/dist/factory-YP4ZZK5K.js +34 -0
- package/dist/import-AJLYHFIA.js +10 -0
- package/dist/import-UZEKXU3B.js +10 -0
- package/dist/index.js +102 -93
- package/dist/launch-explorer-AI6L2AWJ.js +91 -0
- package/dist/launch-explorer-HZ4ZJA4X.js +95 -0
- package/dist/links/index.js +24 -26
- package/dist/plugins/agent-memory/index.js +316 -0
- package/dist/plugins/idea-garden/index.js +165 -0
- package/dist/plugins/plan-approval/index.js +579 -0
- package/dist/plugins/proactive-watcher/index.js +194 -0
- package/dist/{index-2r4jxwnb.js → query-GJL3CVGN.js} +14 -15
- package/dist/query-MBJSK3EB.js +31 -0
- package/dist/query-TJHEVSKL.js +31 -0
- package/dist/query-WUIKOHPE.js +524 -0
- package/dist/query-XYLTJYSA.js +31 -0
- package/dist/react/index.js +39 -70
- package/dist/react/realtime.js +11 -0
- package/dist/react/schema-hooks.js +87 -0
- package/dist/realtime/broadcast-channel-transport.d.ts +43 -0
- package/dist/realtime/broadcast-channel-transport.d.ts.map +1 -0
- package/dist/realtime/durable-object-relay-transport.d.ts +96 -0
- package/dist/realtime/durable-object-relay-transport.d.ts.map +1 -0
- package/dist/realtime/index.d.ts +44 -0
- package/dist/realtime/index.d.ts.map +1 -0
- package/dist/realtime/index.js +40 -0
- package/dist/realtime/memory-hub.d.ts +32 -0
- package/dist/realtime/memory-hub.d.ts.map +1 -0
- package/dist/realtime/persistent-channel.d.ts +105 -0
- package/dist/realtime/persistent-channel.d.ts.map +1 -0
- package/dist/realtime/presence.d.ts +73 -0
- package/dist/realtime/presence.d.ts.map +1 -0
- package/dist/realtime/relay-persistence.d.ts +37 -0
- package/dist/realtime/relay-persistence.d.ts.map +1 -0
- package/dist/realtime/relay-persistence.js +107 -0
- package/dist/realtime/relay-server.d.ts +103 -0
- package/dist/realtime/relay-server.d.ts.map +1 -0
- package/dist/realtime/room.d.ts +98 -0
- package/dist/realtime/room.d.ts.map +1 -0
- package/dist/realtime/text.d.ts +73 -0
- package/dist/realtime/text.d.ts.map +1 -0
- package/dist/realtime/types.d.ts +89 -0
- package/dist/realtime/types.d.ts.map +1 -0
- package/dist/realtime/websocket-relay-transport.d.ts +28 -0
- package/dist/realtime/websocket-relay-transport.d.ts.map +1 -0
- package/dist/realtime.bundle.js +1100 -0
- package/dist/remote-manager-BLJZ6KF6.js +224 -0
- package/dist/{remote-manager-xvbg4230.js → remote-manager-BPYE46SI.js} +24 -15
- package/dist/remote-manager-FMESEAFA.js +224 -0
- package/dist/remote-manager-K2WZ5RHY.js +223 -0
- package/dist/remote-manager-SG545WNY.js +224 -0
- package/dist/remote-manager-SG5PQKCH.js +224 -0
- package/dist/remote-manager-WGP6MIQZ.js +224 -0
- package/dist/scaffold/write.d.ts.map +1 -1
- package/dist/schema/define.d.ts +137 -0
- package/dist/schema/define.d.ts.map +1 -0
- package/dist/schema/entity-projection.d.ts +34 -0
- package/dist/schema/entity-projection.d.ts.map +1 -0
- package/dist/schema/eql.d.ts +46 -0
- package/dist/schema/eql.d.ts.map +1 -0
- package/dist/schema/index.d.ts +21 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +45 -0
- package/dist/schema/kernel-resolve.d.ts +21 -0
- package/dist/schema/kernel-resolve.d.ts.map +1 -0
- package/dist/schema/mutations.d.ts +20 -0
- package/dist/schema/mutations.d.ts.map +1 -0
- package/dist/schema/resolve.d.ts +21 -0
- package/dist/schema/resolve.d.ts.map +1 -0
- package/dist/sdk-3KBB3E6V.js +16 -0
- package/dist/sdk-4ZQO6UTU.js +16 -0
- package/dist/sdk-6JA6GV3G.js +16 -0
- package/dist/sdk-6VTP5UTZ.js +16 -0
- package/dist/sdk-7VS6TYCD.js +16 -0
- package/dist/sdk-HQ3FTLRT.js +16 -0
- package/dist/sdk-HZ7NU3XE.js +15 -0
- package/dist/sdk-KBQE2OXT.js +16 -0
- package/dist/sdk-LZ7W3EEY.js +9 -0
- package/dist/sdk-MSCDZ7JU.js +15 -0
- package/dist/sdk-WNZOGO3S.js +15 -0
- package/dist/sdk-YLV33ZCW.js +9 -0
- package/dist/sdk-ZSUD2LLJ.js +16 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +69 -61
- package/dist/server/node-adapter.js +5 -104
- package/dist/server/realtime.d.ts +10 -2
- package/dist/server/realtime.d.ts.map +1 -1
- package/dist/server/server.d.ts +7 -16
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/sprites.d.ts.map +1 -1
- package/dist/server/tenancy.d.ts.map +1 -1
- package/dist/server-AFXFFBWA.js +11 -0
- package/dist/server-AGHC4VUL.js +11 -0
- package/dist/server-BOH7M4TT.js +13 -0
- package/dist/server-DBUY2KY5.js +11 -0
- package/dist/server-GWBQJPRG.js +11 -0
- package/dist/server-IGBIIJSF.js +13 -0
- package/dist/server-JZZFULVU.js +11 -0
- package/dist/server-L5XAF4M5.js +11 -0
- package/dist/server-NYFUHANA.js +12 -0
- package/dist/server-OABUB2LO.js +12 -0
- package/dist/server-P2CKZWWV.js +12 -0
- package/dist/{sprites-vc4qbrp1.js → sprites-RU3E4XQN.js} +6 -7
- package/dist/sprites-XVSMQLSI.js +15 -0
- package/dist/sql-wasm-FORCZFHZ.js +2148 -0
- package/dist/sql-wasm-JZH76RLO.js +2148 -0
- package/dist/sqljs-backend-CJQOIQYE.js +266 -0
- package/dist/sqljs-backend-KWXBUDUO.js +266 -0
- package/dist/state-demo.bundle.js +1033 -0
- package/dist/svelte/index.d.ts +17 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +51 -0
- package/dist/svelte/schema-hooks.d.ts +45 -0
- package/dist/svelte/schema-hooks.d.ts.map +1 -0
- package/dist/svelte/schema-hooks.js +71 -0
- package/dist/svelte/stores.d.ts +78 -0
- package/dist/svelte/stores.d.ts.map +1 -0
- package/dist/sync/http-transport.d.ts +3 -3
- package/dist/sync/http-transport.d.ts.map +1 -1
- package/dist/sync/index.d.ts +15 -1
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +617 -0
- package/dist/sync/memory-room.d.ts +37 -0
- package/dist/sync/memory-room.d.ts.map +1 -0
- package/dist/sync/memory-transport.d.ts +3 -3
- package/dist/sync/memory-transport.d.ts.map +1 -1
- package/dist/sync/partykit-room.d.ts +40 -0
- package/dist/sync/partykit-room.d.ts.map +1 -0
- package/dist/sync/partykit-transport.d.ts +84 -0
- package/dist/sync/partykit-transport.d.ts.map +1 -0
- package/dist/sync/room-core.d.ts +53 -0
- package/dist/sync/room-core.d.ts.map +1 -0
- package/dist/sync/sync-engine.d.ts +40 -2
- package/dist/sync/sync-engine.d.ts.map +1 -1
- package/dist/sync/sync-room-server.d.ts +39 -0
- package/dist/sync/sync-room-server.d.ts.map +1 -0
- package/dist/sync/types.d.ts +70 -3
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/sync/vcs-sync-peer.d.ts +63 -0
- package/dist/sync/vcs-sync-peer.d.ts.map +1 -0
- package/dist/sync/ws-transport.d.ts +2 -2
- package/dist/sync/ws-transport.d.ts.map +1 -1
- package/dist/tenancy-CBWYEVUB.js +11 -0
- package/dist/tenancy-FO6WVYFN.js +13 -0
- package/dist/tenancy-FWDBESMX.js +14 -0
- package/dist/tenancy-HGPIS5QA.js +13 -0
- package/dist/tenancy-HXFALA37.js +14 -0
- package/dist/tenancy-OP34NFFS.js +14 -0
- package/dist/tenancy-S676GLID.js +14 -0
- package/dist/tenancy-V7ARWNNV.js +14 -0
- package/dist/tenancy-ZDN4GXK5.js +13 -0
- package/dist/tenancy-ZT5VMY7B.js +14 -0
- package/dist/ui/client.html +355 -67
- package/dist/ui/launch-explorer.d.ts +22 -0
- package/dist/ui/launch-explorer.d.ts.map +1 -0
- package/dist/ui/server.d.ts +1 -1
- package/dist/ui/server.d.ts.map +1 -1
- package/dist/vcs/blob-store.d.ts.map +1 -1
- package/dist/vcs/idb-op-log.d.ts +67 -0
- package/dist/vcs/idb-op-log.d.ts.map +1 -0
- package/dist/vcs/index.d.ts +1 -0
- package/dist/vcs/index.d.ts.map +1 -1
- package/dist/vcs/index.js +81 -72
- package/dist/vcs/issue.d.ts +22 -5
- package/dist/vcs/issue.d.ts.map +1 -1
- package/dist/vcs/lane-materialize.d.ts +5 -0
- package/dist/vcs/lane-materialize.d.ts.map +1 -1
- package/dist/vcs/op-log.d.ts +28 -2
- package/dist/vcs/op-log.d.ts.map +1 -1
- package/dist/vcs/ops.d.ts +10 -0
- package/dist/vcs/ops.d.ts.map +1 -1
- package/dist/{vm-config-6xhsj6b3.js → vm-config-JI4OXKDQ.js} +9 -10
- package/dist/vm-config-YZRJ3KUB.js +21 -0
- package/dist/vue/hooks.d.ts +64 -0
- package/dist/vue/hooks.d.ts.map +1 -0
- package/dist/vue/index.d.ts +19 -0
- package/dist/vue/index.d.ts.map +1 -0
- package/dist/vue/index.js +59 -0
- package/dist/vue/schema-hooks.d.ts +41 -0
- package/dist/vue/schema-hooks.d.ts.map +1 -0
- package/dist/vue/schema-hooks.js +64 -0
- package/package.json +118 -16
- package/dist/deploy-999q207z.js +0 -10
- package/dist/engine-y0724kjq.js +0 -8
- package/dist/import-s2b8e0ft.js +0 -11
- package/dist/index-a76rekgs.js +0 -67
- package/dist/index-c9h37r6h.js +0 -1
- package/dist/index-hr9qvv77.js +0 -860
- package/dist/index-k5b0xskw.js +0 -1
- package/dist/index-y6a4kj0p.js +0 -43
- package/dist/sdk-bepky0xs.js +0 -16
- package/dist/server-szdjx0nt.js +0 -13
- package/dist/sqlite-backend-0vsmc6qj.js +0 -8
- package/dist/tenancy-pjm32b4v.js +0 -14
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import {
|
|
2
|
+
liveEntities,
|
|
3
|
+
liveEntity
|
|
4
|
+
} from "../chunk-J3WYZO3Q.js";
|
|
5
|
+
import {
|
|
6
|
+
entityMutations
|
|
7
|
+
} from "../chunk-USEINYUL.js";
|
|
8
|
+
import "../chunk-JUEMDWLU.js";
|
|
9
|
+
import {
|
|
10
|
+
useTrellis
|
|
11
|
+
} from "../chunk-GWRIMRSX.js";
|
|
12
|
+
import "../chunk-X762XWVC.js";
|
|
13
|
+
import {
|
|
14
|
+
useSignal
|
|
15
|
+
} from "../chunk-O2AV5WMN.js";
|
|
16
|
+
import {
|
|
17
|
+
Signal
|
|
18
|
+
} from "../chunk-UBGUDMUV.js";
|
|
19
|
+
import "../chunk-KFQGP6VL.js";
|
|
20
|
+
|
|
21
|
+
// src/react/schema-hooks.ts
|
|
22
|
+
import { useEffect, useMemo } from "react";
|
|
23
|
+
var IDLE = new Signal({
|
|
24
|
+
data: [],
|
|
25
|
+
loading: false,
|
|
26
|
+
error: null
|
|
27
|
+
});
|
|
28
|
+
var IDLE_SINGLE = new Signal({
|
|
29
|
+
data: null,
|
|
30
|
+
loading: false,
|
|
31
|
+
error: null
|
|
32
|
+
});
|
|
33
|
+
function parseReadOptions(opts) {
|
|
34
|
+
if (!opts) return {};
|
|
35
|
+
if ("resolve" in opts || "where" in opts) return opts;
|
|
36
|
+
return { where: opts };
|
|
37
|
+
}
|
|
38
|
+
function useLiveEntities(schema, opts) {
|
|
39
|
+
const client = useTrellis();
|
|
40
|
+
const parsed = parseReadOptions(opts);
|
|
41
|
+
const optsKey = JSON.stringify(parsed);
|
|
42
|
+
const res = useMemo(
|
|
43
|
+
() => schema ? liveEntities(client, schema, parsed) : null,
|
|
44
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
45
|
+
[client, schema, optsKey]
|
|
46
|
+
);
|
|
47
|
+
useEffect(() => res?.start(), [res]);
|
|
48
|
+
return useSignal(res?.signal ?? IDLE);
|
|
49
|
+
}
|
|
50
|
+
function useLiveEntity(schema, id, opts) {
|
|
51
|
+
const client = useTrellis();
|
|
52
|
+
const optsKey = JSON.stringify(opts ?? {});
|
|
53
|
+
const res = useMemo(
|
|
54
|
+
() => schema && id ? liveEntity(client, schema, id, opts) : null,
|
|
55
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
56
|
+
[client, schema, id, optsKey]
|
|
57
|
+
);
|
|
58
|
+
useEffect(() => res?.start(), [res]);
|
|
59
|
+
return useSignal(
|
|
60
|
+
res?.signal ?? IDLE_SINGLE
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
function useEntities(schema, opts) {
|
|
64
|
+
const state = useLiveEntities(schema, opts);
|
|
65
|
+
return {
|
|
66
|
+
data: state.data,
|
|
67
|
+
loading: state.loading,
|
|
68
|
+
error: state.error
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function useEntity(schema, id, opts) {
|
|
72
|
+
const state = useLiveEntity(id ? schema : null, id, opts);
|
|
73
|
+
return {
|
|
74
|
+
data: state.data,
|
|
75
|
+
loading: state.loading,
|
|
76
|
+
error: state.error
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function useMutation(schema) {
|
|
80
|
+
const client = useTrellis();
|
|
81
|
+
return useMemo(() => entityMutations(client, schema), [client, schema]);
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
useEntities,
|
|
85
|
+
useEntity,
|
|
86
|
+
useMutation
|
|
87
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serverless cross-tab realtime transport using the browser BroadcastChannel
|
|
3
|
+
* API. All tabs/windows of the same origin that open a channel with the same
|
|
4
|
+
* name form a broadcast mesh — no server required.
|
|
5
|
+
*
|
|
6
|
+
* BroadcastChannel does not deliver a message back to the posting channel
|
|
7
|
+
* object, so the mesh semantics (no self-echo) hold naturally.
|
|
8
|
+
*/
|
|
9
|
+
import type { RealtimeMessage, RealtimeTransport } from './types.js';
|
|
10
|
+
interface BroadcastChannelLike {
|
|
11
|
+
postMessage(message: unknown): void;
|
|
12
|
+
close(): void;
|
|
13
|
+
onmessage: ((event: {
|
|
14
|
+
data: unknown;
|
|
15
|
+
}) => void) | null;
|
|
16
|
+
addEventListener?(type: 'message', listener: (event: {
|
|
17
|
+
data: unknown;
|
|
18
|
+
}) => void): void;
|
|
19
|
+
removeEventListener?(type: 'message', listener: (event: {
|
|
20
|
+
data: unknown;
|
|
21
|
+
}) => void): void;
|
|
22
|
+
}
|
|
23
|
+
type BroadcastChannelCtor = new (name: string) => BroadcastChannelLike;
|
|
24
|
+
export interface BroadcastChannelTransportOptions {
|
|
25
|
+
/** Local peer identity. */
|
|
26
|
+
id: string;
|
|
27
|
+
/** Channel name — all peers in the room share this. */
|
|
28
|
+
channel: string;
|
|
29
|
+
/** Injectable implementation for tests / non-browser hosts. */
|
|
30
|
+
BroadcastChannelImpl?: BroadcastChannelCtor;
|
|
31
|
+
}
|
|
32
|
+
export declare class BroadcastChannelTransport implements RealtimeTransport {
|
|
33
|
+
readonly id: string;
|
|
34
|
+
private bc;
|
|
35
|
+
private handlers;
|
|
36
|
+
private closed;
|
|
37
|
+
constructor(opts: BroadcastChannelTransportOptions);
|
|
38
|
+
send(message: RealtimeMessage): void;
|
|
39
|
+
onMessage(handler: (message: RealtimeMessage) => void): () => void;
|
|
40
|
+
close(): void;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=broadcast-channel-transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broadcast-channel-transport.d.ts","sourceRoot":"","sources":["../../src/realtime/broadcast-channel-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAErE,UAAU,oBAAoB;IAC5B,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACpC,KAAK,IAAI,IAAI,CAAC;IACd,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IACvD,gBAAgB,CAAC,CACf,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,GAC3C,IAAI,CAAC;IACR,mBAAmB,CAAC,CAClB,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,GAC3C,IAAI,CAAC;CACT;AAED,KAAK,oBAAoB,GAAG,KAAK,IAAI,EAAE,MAAM,KAAK,oBAAoB,CAAC;AAEvE,MAAM,WAAW,gCAAgC;IAC/C,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,+DAA+D;IAC/D,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;CAC7C;AAED,qBAAa,yBAA0B,YAAW,iBAAiB;IACjE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,CAAuB;IACjC,OAAO,CAAC,QAAQ,CAAiD;IACjE,OAAO,CAAC,MAAM,CAAS;gBAEX,IAAI,EAAE,gCAAgC;IAgClD,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAKpC,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,GAAG,MAAM,IAAI;IAOlE,KAAK,IAAI,IAAI;CAUd"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser transport for a hosted relay room — the paid-tier accelerator.
|
|
3
|
+
*
|
|
4
|
+
* Functionally a {@link WebSocketRelayTransport} with three additions a hosted
|
|
5
|
+
* deployment needs: a room-aware URL convention, an auth token, and automatic
|
|
6
|
+
* reconnect with backoff. The server it talks to is the same dumb fan-out +
|
|
7
|
+
* disposable replay contract as {@link createRealtimeRelay} — whether that
|
|
8
|
+
* server is a Cloudflare Durable Object, a self-hosted relay, or PartyKit is
|
|
9
|
+
* irrelevant to this code. The name reflects the *recommended* hosted target
|
|
10
|
+
* (DO: single-writer-per-object matches Trellis's per-graph causality), not a
|
|
11
|
+
* hard dependency on it.
|
|
12
|
+
*
|
|
13
|
+
* Telos alignment: this is one swappable {@link RealtimeTransport} behind the
|
|
14
|
+
* stable seam. Local/free presence uses {@link BroadcastChannelTransport}; this
|
|
15
|
+
* is what you inject when "sync" is enabled. An Iroh gossip transport slots in
|
|
16
|
+
* the same way later with zero client change.
|
|
17
|
+
*
|
|
18
|
+
* new DurableObjectRelayTransport({
|
|
19
|
+
* id: peerId,
|
|
20
|
+
* url: 'wss://relay.example.com',
|
|
21
|
+
* room: 'doc:42',
|
|
22
|
+
* auth: sessionToken,
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* Reconnect self-heals presence for free: the room's heartbeat re-announces
|
|
26
|
+
* local presence after the socket comes back, and this transport re-sends a
|
|
27
|
+
* `hello` on every (re)open so the relay replays peers/chat tail immediately.
|
|
28
|
+
*/
|
|
29
|
+
import type { RealtimeMessage, RealtimeTransport } from './types.js';
|
|
30
|
+
interface SocketLike {
|
|
31
|
+
readyState: number;
|
|
32
|
+
send(data: string): void;
|
|
33
|
+
close(): void;
|
|
34
|
+
addEventListener(type: string, listener: (event: unknown) => void): void;
|
|
35
|
+
}
|
|
36
|
+
type SocketCtor = new (url: string) => SocketLike;
|
|
37
|
+
export interface DurableObjectRelayReconnect {
|
|
38
|
+
/** Max reconnect attempts after an unexpected close. 0 = unlimited. Default 0. */
|
|
39
|
+
maxAttempts?: number;
|
|
40
|
+
/** Initial backoff (ms). Default 500. */
|
|
41
|
+
baseDelayMs?: number;
|
|
42
|
+
/** Max backoff (ms). Default 10_000. */
|
|
43
|
+
maxDelayMs?: number;
|
|
44
|
+
}
|
|
45
|
+
export interface DurableObjectRelayTransportOptions {
|
|
46
|
+
/** Local peer identity. */
|
|
47
|
+
id: string;
|
|
48
|
+
/**
|
|
49
|
+
* Base relay URL, e.g. `wss://relay.example.com` or
|
|
50
|
+
* `wss://x.partykit.dev/parties/main`. The room segment and auth token are
|
|
51
|
+
* appended per {@link buildUrl} unless you pass a fully-formed URL and omit
|
|
52
|
+
* `room`/`auth`.
|
|
53
|
+
*/
|
|
54
|
+
url: string;
|
|
55
|
+
/** Logical room id, appended as a path segment (`/{room}`) when set. */
|
|
56
|
+
room?: string;
|
|
57
|
+
/** Auth token, appended as `?token=` (or `&token=`) when set. */
|
|
58
|
+
auth?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Override URL assembly entirely (e.g. a different DO routing convention).
|
|
61
|
+
* Receives the constructor options; returns the final `ws(s)://…` URL.
|
|
62
|
+
*/
|
|
63
|
+
buildUrl?: (opts: {
|
|
64
|
+
url: string;
|
|
65
|
+
room?: string;
|
|
66
|
+
auth?: string;
|
|
67
|
+
}) => string;
|
|
68
|
+
/** Reconnect policy. Pass `false` to disable reconnect. */
|
|
69
|
+
reconnect?: DurableObjectRelayReconnect | false;
|
|
70
|
+
/** Cap on frames buffered while disconnected (oldest dropped). Default 128. */
|
|
71
|
+
maxPending?: number;
|
|
72
|
+
/** Injectable WebSocket for tests / non-browser hosts. */
|
|
73
|
+
WebSocketImpl?: SocketCtor;
|
|
74
|
+
}
|
|
75
|
+
export declare class DurableObjectRelayTransport implements RealtimeTransport {
|
|
76
|
+
readonly id: string;
|
|
77
|
+
private readonly url;
|
|
78
|
+
private readonly WS;
|
|
79
|
+
private readonly reconnect;
|
|
80
|
+
private readonly maxPending;
|
|
81
|
+
private ws;
|
|
82
|
+
private handlers;
|
|
83
|
+
private pending;
|
|
84
|
+
private closed;
|
|
85
|
+
private attempts;
|
|
86
|
+
private reconnectTimer;
|
|
87
|
+
constructor(opts: DurableObjectRelayTransportOptions);
|
|
88
|
+
send(message: RealtimeMessage): void;
|
|
89
|
+
onMessage(handler: (message: RealtimeMessage) => void): () => void;
|
|
90
|
+
close(): void;
|
|
91
|
+
private open;
|
|
92
|
+
private scheduleReconnect;
|
|
93
|
+
private flushPending;
|
|
94
|
+
}
|
|
95
|
+
export {};
|
|
96
|
+
//# sourceMappingURL=durable-object-relay-transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"durable-object-relay-transport.d.ts","sourceRoot":"","sources":["../../src/realtime/durable-object-relay-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAErE,UAAU,UAAU;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,IAAI,IAAI,CAAC;IACd,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAAC;CAC1E;AAED,KAAK,UAAU,GAAG,KAAK,GAAG,EAAE,MAAM,KAAK,UAAU,CAAC;AAElD,MAAM,WAAW,2BAA2B;IAC1C,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,kCAAkC;IACjD,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX;;;;;OAKG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,wEAAwE;IACxE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM,CAAC;IAC3E,2DAA2D;IAC3D,SAAS,CAAC,EAAE,2BAA2B,GAAG,KAAK,CAAC;IAChD,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,UAAU,CAAC;CAC5B;AAmBD,qBAAa,2BAA4B,YAAW,iBAAiB;IACnE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAa;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA+C;IACzE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IAEpC,OAAO,CAAC,EAAE,CAA2B;IACrC,OAAO,CAAC,QAAQ,CAAiD;IACjE,OAAO,CAAC,OAAO,CAAyB;IACxC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,cAAc,CAA8C;gBAExD,IAAI,EAAE,kCAAkC;IAsBpD,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAYpC,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,GAAG,MAAM,IAAI;IAOlE,KAAK,IAAI,IAAI;IAeb,OAAO,CAAC,IAAI;IA+CZ,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,YAAY;CAOrB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trellis Realtime — Public Surface
|
|
3
|
+
*
|
|
4
|
+
* Ephemeral presence + broadcast primitives for multiplayer UI: active-user
|
|
5
|
+
* avatars, chat, live cursors, and collaborative text. Distinct from the
|
|
6
|
+
* persisted VCS op log — realtime data is mesh-broadcast and never written to
|
|
7
|
+
* the causal history.
|
|
8
|
+
*
|
|
9
|
+
* @module trellis/realtime
|
|
10
|
+
*
|
|
11
|
+
* import {
|
|
12
|
+
* RealtimeRoom,
|
|
13
|
+
* BroadcastChannelTransport,
|
|
14
|
+
* WebSocketRelayTransport,
|
|
15
|
+
* } from 'trellis/realtime';
|
|
16
|
+
*
|
|
17
|
+
* const room = RealtimeRoom.join({
|
|
18
|
+
* transport: new BroadcastChannelTransport({ id, channel: 'room:42' }),
|
|
19
|
+
* initialPresence: { name: 'Ada', color: '#6d5bfa' },
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // Or relay across browsers:
|
|
23
|
+
* new WebSocketRelayTransport({ id, url: 'ws://localhost:8231/rt' });
|
|
24
|
+
*/
|
|
25
|
+
export { RealtimeRoom } from './room.js';
|
|
26
|
+
export type { RealtimeRoomOptions } from './room.js';
|
|
27
|
+
export { MemoryHub, MemoryRealtimeTransport } from './memory-hub.js';
|
|
28
|
+
export { BroadcastChannelTransport } from './broadcast-channel-transport.js';
|
|
29
|
+
export type { BroadcastChannelTransportOptions } from './broadcast-channel-transport.js';
|
|
30
|
+
export { WebSocketRelayTransport } from './websocket-relay-transport.js';
|
|
31
|
+
export type { WebSocketRelayTransportOptions } from './websocket-relay-transport.js';
|
|
32
|
+
export { DurableObjectRelayTransport } from './durable-object-relay-transport.js';
|
|
33
|
+
export type { DurableObjectRelayTransportOptions, DurableObjectRelayReconnect, } from './durable-object-relay-transport.js';
|
|
34
|
+
export { joinPresence, createPresenceTransport } from './presence.js';
|
|
35
|
+
export type { PresenceOptions } from './presence.js';
|
|
36
|
+
export { RelayPersistence, DEFAULT_MAX_CHAT, DEFAULT_MAX_TEXT_OPS, } from './relay-persistence.js';
|
|
37
|
+
export type { RelayPersistenceOptions } from './relay-persistence.js';
|
|
38
|
+
export { PersistentChannel, localStorageChannelStore, DEFAULT_MAX_RECORDS, } from './persistent-channel.js';
|
|
39
|
+
export type { ChannelRecord, ChannelStore, PersistentChannelOptions, } from './persistent-channel.js';
|
|
40
|
+
export { RealtimeText } from './text.js';
|
|
41
|
+
export type { RealtimeTextOptions, TextNode, TextOp } from './text.js';
|
|
42
|
+
export { REALTIME_PROTOCOL } from './types.js';
|
|
43
|
+
export type { PresenceState, PresencePeer, BroadcastEvent, RealtimeMessage, RealtimeTransport, } from './types.js';
|
|
44
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/realtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,YAAY,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,YAAY,EAAE,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AAEzF,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,YAAY,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AAErF,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,YAAY,EACV,kCAAkC,EAClC,2BAA2B,GAC5B,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACtE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,aAAa,EACb,YAAY,EACZ,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,YAAY,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,YAAY,EACV,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,EACf,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BroadcastChannelTransport,
|
|
3
|
+
DEFAULT_MAX_RECORDS,
|
|
4
|
+
DurableObjectRelayTransport,
|
|
5
|
+
MemoryHub,
|
|
6
|
+
MemoryRealtimeTransport,
|
|
7
|
+
PersistentChannel,
|
|
8
|
+
REALTIME_PROTOCOL,
|
|
9
|
+
RealtimeRoom,
|
|
10
|
+
RealtimeText,
|
|
11
|
+
WebSocketRelayTransport,
|
|
12
|
+
createPresenceTransport,
|
|
13
|
+
joinPresence,
|
|
14
|
+
localStorageChannelStore
|
|
15
|
+
} from "../chunk-KSU2GW22.js";
|
|
16
|
+
import {
|
|
17
|
+
DEFAULT_MAX_CHAT,
|
|
18
|
+
DEFAULT_MAX_TEXT_OPS,
|
|
19
|
+
RelayPersistence
|
|
20
|
+
} from "../chunk-GFZCJ4EH.js";
|
|
21
|
+
import "../chunk-UBGUDMUV.js";
|
|
22
|
+
import "../chunk-KFQGP6VL.js";
|
|
23
|
+
export {
|
|
24
|
+
BroadcastChannelTransport,
|
|
25
|
+
DEFAULT_MAX_CHAT,
|
|
26
|
+
DEFAULT_MAX_RECORDS,
|
|
27
|
+
DEFAULT_MAX_TEXT_OPS,
|
|
28
|
+
DurableObjectRelayTransport,
|
|
29
|
+
MemoryHub,
|
|
30
|
+
MemoryRealtimeTransport,
|
|
31
|
+
PersistentChannel,
|
|
32
|
+
REALTIME_PROTOCOL,
|
|
33
|
+
RealtimeRoom,
|
|
34
|
+
RealtimeText,
|
|
35
|
+
RelayPersistence,
|
|
36
|
+
WebSocketRelayTransport,
|
|
37
|
+
createPresenceTransport,
|
|
38
|
+
joinPresence,
|
|
39
|
+
localStorageChannelStore
|
|
40
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-process broadcast mesh for realtime presence/broadcast.
|
|
3
|
+
*
|
|
4
|
+
* Useful for tests and for "side-by-side" demos where several simulated peers
|
|
5
|
+
* share one page. Each {@link MemoryRealtimeTransport} delivers messages to
|
|
6
|
+
* every other transport on the same hub (never to itself).
|
|
7
|
+
*/
|
|
8
|
+
import type { RealtimeMessage, RealtimeTransport } from './types.js';
|
|
9
|
+
export declare class MemoryHub {
|
|
10
|
+
private transports;
|
|
11
|
+
/** Create a transport bound to this hub for the given peer id. */
|
|
12
|
+
connect(id: string): MemoryRealtimeTransport;
|
|
13
|
+
/** Number of currently connected transports. */
|
|
14
|
+
size(): number;
|
|
15
|
+
/** @internal */
|
|
16
|
+
_broadcast(from: MemoryRealtimeTransport, message: RealtimeMessage): void;
|
|
17
|
+
/** @internal */
|
|
18
|
+
_remove(transport: MemoryRealtimeTransport): void;
|
|
19
|
+
}
|
|
20
|
+
export declare class MemoryRealtimeTransport implements RealtimeTransport {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
private hub;
|
|
23
|
+
private handlers;
|
|
24
|
+
private closed;
|
|
25
|
+
constructor(hub: MemoryHub, id: string);
|
|
26
|
+
send(message: RealtimeMessage): void;
|
|
27
|
+
onMessage(handler: (message: RealtimeMessage) => void): () => void;
|
|
28
|
+
close(): void;
|
|
29
|
+
/** @internal */
|
|
30
|
+
_deliver(message: RealtimeMessage): void;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=memory-hub.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-hub.d.ts","sourceRoot":"","sources":["../../src/realtime/memory-hub.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAErE,qBAAa,SAAS;IACpB,OAAO,CAAC,UAAU,CAAsC;IAExD,kEAAkE;IAClE,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,uBAAuB;IAM5C,gDAAgD;IAChD,IAAI,IAAI,MAAM;IAId,gBAAgB;IAChB,UAAU,CAAC,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,eAAe,GAAG,IAAI;IAOzE,gBAAgB;IAChB,OAAO,CAAC,SAAS,EAAE,uBAAuB,GAAG,IAAI;CAGlD;AAED,qBAAa,uBAAwB,YAAW,iBAAiB;IAC/D,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,GAAG,CAAY;IACvB,OAAO,CAAC,QAAQ,CAAiD;IACjE,OAAO,CAAC,MAAM,CAAS;gBAEX,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM;IAKtC,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAKpC,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,GAAG,MAAM,IAAI;IAOlE,KAAK,IAAI,IAAI;IAOb,gBAAgB;IAChB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;CAUzC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PersistentChannel — a durable, convergent view over one broadcast channel.
|
|
3
|
+
*
|
|
4
|
+
* Wraps a {@link RealtimeRoom} channel as a **grow-only set** keyed by message
|
|
5
|
+
* id: every record is deduplicated by id and ordered by `(ts, id)`, so the same
|
|
6
|
+
* message arriving from any source (optimistic local send, live broadcast, or a
|
|
7
|
+
* relay replay on reconnect) lands exactly once and in a stable order.
|
|
8
|
+
*
|
|
9
|
+
* There is no single source of truth. Each peer holds its own replica (a
|
|
10
|
+
* pluggable {@link ChannelStore} — `localStorage`, IndexedDB, …) and the relay
|
|
11
|
+
* holds another. They converge on reconnect because union + id-dedup is
|
|
12
|
+
* commutative and idempotent. The store is an instant first-paint cache, not an
|
|
13
|
+
* authority: a refresh repaints from it immediately, then merges whatever the
|
|
14
|
+
* relay replays.
|
|
15
|
+
*
|
|
16
|
+
* const chat = PersistentChannel.create(room, 'chat', {
|
|
17
|
+
* store: localStorageChannelStore(`chat:${roomUrl}`),
|
|
18
|
+
* resolveMeta: (e) => presenceById()[e.from], // capture name/color
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* chat.messages.subscribe((msgs) => render(msgs)); // deduped + sorted
|
|
22
|
+
* chat.send({ text }); // optimistic + broadcast + persist
|
|
23
|
+
*
|
|
24
|
+
* Only the channel's "message" event (configurable) is persisted; transient
|
|
25
|
+
* events like typing indicators stay the caller's concern via `room.on`.
|
|
26
|
+
*/
|
|
27
|
+
import { Signal } from '../client/reactive.js';
|
|
28
|
+
import type { RealtimeRoom } from './room.js';
|
|
29
|
+
import type { BroadcastEvent } from './types.js';
|
|
30
|
+
/** A persisted member of the grow-only set. */
|
|
31
|
+
export interface ChannelRecord<T = unknown> {
|
|
32
|
+
/** Stable dedup key (sender-assigned message id). */
|
|
33
|
+
id: string;
|
|
34
|
+
/** Originating peer id. */
|
|
35
|
+
from: string;
|
|
36
|
+
/** Sender clock (epoch ms) — primary sort key. */
|
|
37
|
+
ts: number;
|
|
38
|
+
/** Application payload (e.g. `{ text }`). */
|
|
39
|
+
payload: T;
|
|
40
|
+
/** Optional sender metadata captured at send/receipt (name, color, …). */
|
|
41
|
+
meta?: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Durable backing store for a peer's local replica. Implementations may be sync
|
|
45
|
+
* (`localStorage`) or async (IndexedDB/OPFS); `load` may return a promise.
|
|
46
|
+
*/
|
|
47
|
+
export interface ChannelStore<T = unknown> {
|
|
48
|
+
load(): ChannelRecord<T>[] | Promise<ChannelRecord<T>[]>;
|
|
49
|
+
save(records: ChannelRecord<T>[]): void | Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
export interface PersistentChannelOptions<T = unknown> {
|
|
52
|
+
/** Broadcast event name treated as a persisted message. Default `'message'`. */
|
|
53
|
+
event?: string;
|
|
54
|
+
/** Durable replica for this peer. Omit for in-memory only. */
|
|
55
|
+
store?: ChannelStore<T>;
|
|
56
|
+
/** Keep at most the N most recent records. Default 200. */
|
|
57
|
+
max?: number;
|
|
58
|
+
/** Capture sender metadata for an inbound message (e.g. from presence). */
|
|
59
|
+
resolveMeta?: (event: BroadcastEvent) => Record<string, unknown> | undefined;
|
|
60
|
+
/** Injectable clock for local sends. Default `Date.now`. */
|
|
61
|
+
now?: () => number;
|
|
62
|
+
}
|
|
63
|
+
export declare const DEFAULT_MAX_RECORDS = 200;
|
|
64
|
+
export declare class PersistentChannel<T = unknown> {
|
|
65
|
+
/** Reactive, deduped, `(ts, id)`-sorted message list. */
|
|
66
|
+
readonly messages: Signal<ChannelRecord<T>[]>;
|
|
67
|
+
private readonly room;
|
|
68
|
+
private readonly channel;
|
|
69
|
+
private readonly event;
|
|
70
|
+
private readonly store?;
|
|
71
|
+
private readonly max;
|
|
72
|
+
private readonly resolveMeta?;
|
|
73
|
+
private readonly now;
|
|
74
|
+
private records;
|
|
75
|
+
private byId;
|
|
76
|
+
private unsubscribe;
|
|
77
|
+
private disposed;
|
|
78
|
+
private constructor();
|
|
79
|
+
/** Create a persistent view over `room`'s `channel`. */
|
|
80
|
+
static create<T = unknown>(room: RealtimeRoom, channel: string, opts?: PersistentChannelOptions<T>): PersistentChannel<T>;
|
|
81
|
+
/**
|
|
82
|
+
* Optimistically record locally, broadcast to peers, and persist. Returns the
|
|
83
|
+
* stable message id. The room dedups its own id, so the broadcast never
|
|
84
|
+
* echoes back into this channel.
|
|
85
|
+
*/
|
|
86
|
+
send(payload: T, meta?: Record<string, unknown>): string;
|
|
87
|
+
/** Current records (deduped + sorted). Read without subscribing. */
|
|
88
|
+
snapshot(): ChannelRecord<T>[];
|
|
89
|
+
/** Stop listening. Does not clear the durable store. */
|
|
90
|
+
dispose(): void;
|
|
91
|
+
private handleEvent;
|
|
92
|
+
private hydrate;
|
|
93
|
+
/** Insert one record and publish if it was new. */
|
|
94
|
+
private commitOne;
|
|
95
|
+
/** Pure insert with dedup + cap. Returns true when a new record was added. */
|
|
96
|
+
private add;
|
|
97
|
+
private commit;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* A {@link ChannelStore} backed by Web Storage (`localStorage` by default).
|
|
101
|
+
* Degrades to in-memory if storage is unavailable or over quota — durability is
|
|
102
|
+
* best-effort, since the relay replica remains authoritative for catch-up.
|
|
103
|
+
*/
|
|
104
|
+
export declare function localStorageChannelStore<T = unknown>(key: string, storage?: Storage | undefined): ChannelStore<T>;
|
|
105
|
+
//# sourceMappingURL=persistent-channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persistent-channel.d.ts","sourceRoot":"","sources":["../../src/realtime/persistent-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,+CAA+C;AAC/C,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,OAAO;IACxC,qDAAqD;IACrD,EAAE,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,6CAA6C;IAC7C,OAAO,EAAE,CAAC,CAAC;IACX,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,OAAO;IACvC,IAAI,IAAI,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACzD,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzD;AAED,MAAM,WAAW,wBAAwB,CAAC,CAAC,GAAG,OAAO;IACnD,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,KAAK,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IACxB,2DAA2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2EAA2E;IAC3E,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC7E,4DAA4D;IAC5D,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,qBAAa,iBAAiB,CAAC,CAAC,GAAG,OAAO;IACxC,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,6BAAsC;IAEvD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAe;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAEY;IACzC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;IAEnC,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,IAAI,CAAuC;IACnD,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,QAAQ,CAAS;IAEzB,OAAO;IAmBP,wDAAwD;IACxD,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,EACvB,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,wBAAwB,CAAC,CAAC,CAAM,GACrC,iBAAiB,CAAC,CAAC,CAAC;IAIvB;;;;OAIG;IACH,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;IAMxD,oEAAoE;IACpE,QAAQ,IAAI,aAAa,CAAC,CAAC,CAAC,EAAE;IAI9B,wDAAwD;IACxD,OAAO,IAAI,IAAI;IAQf,OAAO,CAAC,WAAW,CASjB;YAEY,OAAO;IAgBrB,mDAAmD;IACnD,OAAO,CAAC,SAAS;IAIjB,8EAA8E;IAC9E,OAAO,CAAC,GAAG;IAYX,OAAO,CAAC,MAAM;CAIf;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,GAAG,OAAO,EAClD,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,OAAO,GAAG,SACJ,GACd,YAAY,CAAC,CAAC,CAAC,CAmBjB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport-agnostic presence — the one place the local-first → cloud-optional
|
|
3
|
+
* gradient is encoded.
|
|
4
|
+
*
|
|
5
|
+
* Presence is ephemeral and self-healing; it is never written to the causal op
|
|
6
|
+
* log. That makes the *transport* a free choice, and this helper picks it by
|
|
7
|
+
* intent rather than hardcoding a hub:
|
|
8
|
+
*
|
|
9
|
+
* - no `relayUrl` → {@link BroadcastChannelTransport}: cross-tab, $0, no
|
|
10
|
+
* socket, works with the network killed. This is the free / local tier and
|
|
11
|
+
* the default. (Telos principle 7: kill the network, presence across tabs
|
|
12
|
+
* still works — you just stop seeing remote peers.)
|
|
13
|
+
* - `relayUrl` set → {@link DurableObjectRelayTransport}: a hosted relay room.
|
|
14
|
+
* This opens a socket, so per the ecosystem economics it is a *paid* tier.
|
|
15
|
+
* - `transport` → bring your own (tests, or an Iroh gossip transport at
|
|
16
|
+
* Boulder 2) — the escape hatch that keeps the seam honest.
|
|
17
|
+
*
|
|
18
|
+
* Frameworks consume this inside their room hooks, e.g. Svelte:
|
|
19
|
+
*
|
|
20
|
+
* import { createRoom } from 'trellis/svelte';
|
|
21
|
+
* import { joinPresence } from 'trellis/realtime';
|
|
22
|
+
*
|
|
23
|
+
* const { presence, others, destroy } = createRoom(() =>
|
|
24
|
+
* joinPresence({ peerId, room: 'doc:42', initialPresence: { name, color } }),
|
|
25
|
+
* );
|
|
26
|
+
*/
|
|
27
|
+
import { BroadcastChannelTransport } from './broadcast-channel-transport.js';
|
|
28
|
+
import { DurableObjectRelayTransport } from './durable-object-relay-transport.js';
|
|
29
|
+
import { RealtimeRoom } from './room.js';
|
|
30
|
+
import type { PresenceState, RealtimeTransport } from './types.js';
|
|
31
|
+
export interface PresenceOptions<P extends PresenceState = PresenceState> {
|
|
32
|
+
/** Local peer identity (stable per tab/device). */
|
|
33
|
+
peerId: string;
|
|
34
|
+
/** Logical room — peers sharing it see each other. */
|
|
35
|
+
room: string;
|
|
36
|
+
/** Initial local presence (name, color, cursor, …). */
|
|
37
|
+
initialPresence?: P;
|
|
38
|
+
/**
|
|
39
|
+
* Hosted relay base URL. When set, presence syncs cross-device through the
|
|
40
|
+
* relay (paid tier). When omitted, presence stays local/cross-tab (free).
|
|
41
|
+
*/
|
|
42
|
+
relayUrl?: string;
|
|
43
|
+
/** Auth token for the hosted relay. */
|
|
44
|
+
auth?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Explicit transport — overrides the `relayUrl`/local selection entirely.
|
|
47
|
+
* Use for tests or an alternative transport (e.g. future Iroh gossip).
|
|
48
|
+
*/
|
|
49
|
+
transport?: RealtimeTransport;
|
|
50
|
+
/** Heartbeat interval (ms). Default 2000 (see {@link RealtimeRoom}). */
|
|
51
|
+
heartbeatMs?: number;
|
|
52
|
+
/** Peer expiry after no heartbeat (ms). Default 6000. */
|
|
53
|
+
timeoutMs?: number;
|
|
54
|
+
/** Injectable clock for tests. */
|
|
55
|
+
now?: () => number;
|
|
56
|
+
/** Injectable WebSocket (hosted relay) for tests / non-browser hosts. */
|
|
57
|
+
WebSocketImpl?: ConstructorParameters<typeof DurableObjectRelayTransport>[0]['WebSocketImpl'];
|
|
58
|
+
/** Injectable BroadcastChannel (local) for tests / non-browser hosts. */
|
|
59
|
+
BroadcastChannelImpl?: ConstructorParameters<typeof BroadcastChannelTransport>[0]['BroadcastChannelImpl'];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Select the presence transport for the given options without joining a room.
|
|
63
|
+
* Exposed so callers can inspect or wrap the choice; most code should use
|
|
64
|
+
* {@link joinPresence}.
|
|
65
|
+
*/
|
|
66
|
+
export declare function createPresenceTransport(opts: PresenceOptions): RealtimeTransport;
|
|
67
|
+
/**
|
|
68
|
+
* Join a presence room with a transport chosen by intent (local vs hosted).
|
|
69
|
+
* Returns a {@link RealtimeRoom}; pair it with a framework room hook
|
|
70
|
+
* (`createRoom` / `useRoom`) for reactive presence + broadcast.
|
|
71
|
+
*/
|
|
72
|
+
export declare function joinPresence<P extends PresenceState = PresenceState>(opts: PresenceOptions<P>): RealtimeRoom<P>;
|
|
73
|
+
//# sourceMappingURL=presence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../../src/realtime/presence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEnE,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa;IACtE,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,eAAe,CAAC,EAAE,CAAC,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,yEAAyE;IACzE,aAAa,CAAC,EAAE,qBAAqB,CACnC,OAAO,2BAA2B,CACnC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;IACtB,yEAAyE;IACzE,oBAAoB,CAAC,EAAE,qBAAqB,CAC1C,OAAO,yBAAyB,CACjC,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,eAAe,GACpB,iBAAiB,CAgBnB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EAClE,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,YAAY,CAAC,CAAC,CAAC,CAQjB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory persistence for a WebSocket relay hub (demo / dev).
|
|
3
|
+
*
|
|
4
|
+
* Retains durable-enough session state: latest presence per peer, chat tail,
|
|
5
|
+
* and collaborative text (snapshot preferred, else op tail). Not the VCS op
|
|
6
|
+
* log — reset when the relay process stops.
|
|
7
|
+
*/
|
|
8
|
+
import type { RealtimeMessage } from './types.js';
|
|
9
|
+
export declare const DEFAULT_MAX_CHAT = 200;
|
|
10
|
+
export declare const DEFAULT_MAX_TEXT_OPS = 2000;
|
|
11
|
+
export interface RelayPersistenceOptions {
|
|
12
|
+
maxChat?: number;
|
|
13
|
+
maxTextOps?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Records relay traffic and builds ordered replay batches for newcomers.
|
|
17
|
+
*/
|
|
18
|
+
export declare class RelayPersistence {
|
|
19
|
+
private maxChat;
|
|
20
|
+
private maxTextOps;
|
|
21
|
+
private presence;
|
|
22
|
+
/** Chat is a grow-only set keyed by {@link chatKey} — dedup on record. */
|
|
23
|
+
private chatLog;
|
|
24
|
+
private chatKeys;
|
|
25
|
+
private textSnapshot;
|
|
26
|
+
private textOps;
|
|
27
|
+
constructor(opts?: RelayPersistenceOptions);
|
|
28
|
+
/** Record an inbound client message (skip `hello` / `replay`). */
|
|
29
|
+
record(message: RealtimeMessage): void;
|
|
30
|
+
/** Ordered messages to replay to a peer that just connected. */
|
|
31
|
+
buildReplay(): RealtimeMessage[];
|
|
32
|
+
getPresenceCount(): number;
|
|
33
|
+
getChatCount(): number;
|
|
34
|
+
hasTextSnapshot(): boolean;
|
|
35
|
+
private recordBroadcast;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=relay-persistence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay-persistence.d.ts","sourceRoot":"","sources":["../../src/realtime/relay-persistence.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,eAAO,MAAM,oBAAoB,OAAO,CAAC;AA4BzC,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAkC;IAClD,0EAA0E;IAC1E,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,OAAO,CAAsB;gBAEzB,IAAI,GAAE,uBAA4B;IAK9C,kEAAkE;IAClE,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAoBtC,gEAAgE;IAChE,WAAW,IAAI,eAAe,EAAE;IAmBhC,gBAAgB,IAAI,MAAM;IAI1B,YAAY,IAAI,MAAM;IAItB,eAAe,IAAI,OAAO;IAI1B,OAAO,CAAC,eAAe;CA2BxB"}
|