@moq/net 0.4.8 → 0.22.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/README.md +7 -1
- package/announce.d.ts +1 -1
- package/announce.d.ts.map +1 -1
- package/announce.js +1 -1
- package/announce.js.map +1 -1
- package/announced.d.ts +51 -47
- package/announced.d.ts.map +1 -1
- package/announced.js +183 -31
- package/announced.js.map +1 -1
- package/announced.test-util.d.ts +2 -0
- package/announced.test-util.d.ts.map +1 -0
- package/announced.test-util.js +27 -0
- package/announced.test-util.js.map +1 -0
- package/auth.d.ts +64 -0
- package/auth.d.ts.map +1 -0
- package/auth.js +20 -0
- package/auth.js.map +1 -0
- package/auth_gate.d.ts +2 -0
- package/auth_gate.d.ts.map +1 -0
- package/auth_gate.js +24 -0
- package/auth_gate.js.map +1 -0
- package/auth_session.d.ts +49 -0
- package/auth_session.d.ts.map +1 -0
- package/auth_session.js +1097 -0
- package/auth_session.js.map +1 -0
- package/bandwidth.d.ts +129 -25
- package/bandwidth.d.ts.map +1 -1
- package/bandwidth.js +410 -138
- package/bandwidth.js.map +1 -1
- package/bandwidth_api.d.ts +1 -1
- package/bandwidth_api.d.ts.map +1 -1
- package/bandwidth_api.js +1 -1
- package/bandwidth_api.js.map +1 -1
- package/broadcast.d.ts +62 -36
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +556 -172
- package/broadcast.js.map +1 -1
- package/cache.d.ts +103 -0
- package/cache.d.ts.map +1 -0
- package/cache.js +254 -0
- package/cache.js.map +1 -0
- package/claim.test-util.d.ts +5 -0
- package/claim.test-util.d.ts.map +1 -0
- package/claim.test-util.js +13 -0
- package/claim.test-util.js.map +1 -0
- package/connection/accept.d.ts +20 -12
- package/connection/accept.d.ts.map +1 -1
- package/connection/accept.js +97 -129
- package/connection/accept.js.map +1 -1
- package/connection/browser.d.ts.map +1 -1
- package/connection/browser.js +28 -19
- package/connection/browser.js.map +1 -1
- package/connection/connect.d.ts +119 -23
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +535 -216
- package/connection/connect.js.map +1 -1
- package/connection/dials.d.ts +45 -0
- package/connection/dials.d.ts.map +1 -0
- package/connection/dials.js +109 -0
- package/connection/dials.js.map +1 -0
- package/connection/endpoint.d.ts +60 -0
- package/connection/endpoint.d.ts.map +1 -0
- package/connection/endpoint.js +114 -0
- package/connection/endpoint.js.map +1 -0
- package/connection/forward.d.ts +7 -1
- package/connection/forward.d.ts.map +1 -1
- package/connection/forward.js +265 -80
- package/connection/forward.js.map +1 -1
- package/connection/goaway.d.ts +16 -9
- package/connection/goaway.d.ts.map +1 -1
- package/connection/goaway.js +22 -108
- package/connection/goaway.js.map +1 -1
- package/connection/handshake.d.ts +32 -6
- package/connection/handshake.d.ts.map +1 -1
- package/connection/handshake.js +97 -20
- package/connection/handshake.js.map +1 -1
- package/connection/index.d.ts +3 -6
- package/connection/index.d.ts.map +1 -1
- package/connection/index.js +1 -2
- package/connection/index.js.map +1 -1
- package/connection/liveness.d.ts +14 -0
- package/connection/liveness.d.ts.map +1 -0
- package/connection/liveness.js +30 -0
- package/connection/liveness.js.map +1 -0
- package/connection/pool.d.ts +137 -58
- package/connection/pool.d.ts.map +1 -1
- package/connection/pool.js +281 -117
- package/connection/pool.js.map +1 -1
- package/connection/reload.d.ts +60 -12
- package/connection/reload.d.ts.map +1 -1
- package/connection/reload.js +859 -233
- package/connection/reload.js.map +1 -1
- package/connection/session.d.ts +91 -0
- package/connection/session.d.ts.map +1 -0
- package/connection/session.js +2 -0
- package/connection/session.js.map +1 -0
- package/connection/stats.d.ts +20 -11
- package/connection/stats.d.ts.map +1 -1
- package/connection/stats.js +64 -8
- package/connection/stats.js.map +1 -1
- package/connection/ticker.d.ts +4 -0
- package/connection/ticker.d.ts.map +1 -0
- package/connection/ticker.js +66 -0
- package/connection/ticker.js.map +1 -0
- package/connection/tokens.d.ts +2 -0
- package/connection/tokens.d.ts.map +1 -0
- package/connection/tokens.js +404 -0
- package/connection/tokens.js.map +1 -0
- package/connection/transport.d.ts.map +1 -1
- package/connection/transport.js +4 -4
- package/connection/transport.js.map +1 -1
- package/connection/withdrawal.d.ts +2 -0
- package/connection/withdrawal.d.ts.map +1 -0
- package/connection/withdrawal.js +23 -0
- package/connection/withdrawal.js.map +1 -0
- package/consume.js +213 -46
- package/consume.js.map +1 -1
- package/cover.d.ts +59 -0
- package/cover.d.ts.map +1 -0
- package/cover.js +375 -0
- package/cover.js.map +1 -0
- package/datagram.d.ts +70 -11
- package/datagram.d.ts.map +1 -1
- package/datagram.js +317 -1
- package/datagram.js.map +1 -1
- package/datagram_stream.d.ts +18 -0
- package/datagram_stream.d.ts.map +1 -0
- package/datagram_stream.js +67 -0
- package/datagram_stream.js.map +1 -0
- package/defined.test-util.d.ts +2 -0
- package/defined.test-util.d.ts.map +1 -0
- package/defined.test-util.js +7 -0
- package/defined.test-util.js.map +1 -0
- package/delivered.d.ts +75 -0
- package/delivered.d.ts.map +1 -0
- package/delivered.js +228 -0
- package/delivered.js.map +1 -0
- package/demand.d.ts +173 -0
- package/demand.d.ts.map +1 -0
- package/demand.js +582 -0
- package/demand.js.map +1 -0
- package/drops.d.ts +93 -0
- package/drops.d.ts.map +1 -0
- package/drops.js +283 -0
- package/drops.js.map +1 -0
- package/error.d.ts +120 -21
- package/error.d.ts.map +1 -1
- package/error.js +230 -37
- package/error.js.map +1 -1
- package/errors.d.ts +2 -2
- package/errors.d.ts.map +1 -1
- package/errors.js +2 -2
- package/errors.js.map +1 -1
- package/fill.d.ts +174 -0
- package/fill.d.ts.map +1 -0
- package/fill.js +760 -0
- package/fill.js.map +1 -0
- package/flate/decoder.d.ts +2 -0
- package/flate/decoder.d.ts.map +1 -0
- package/flate/decoder.js +63 -0
- package/flate/decoder.js.map +1 -0
- package/flate/encoder.d.ts +2 -0
- package/flate/encoder.d.ts.map +1 -0
- package/flate/encoder.js +64 -0
- package/flate/encoder.js.map +1 -0
- package/flate/group.d.ts +34 -0
- package/flate/group.d.ts.map +1 -0
- package/flate/group.js +140 -0
- package/flate/group.js.map +1 -0
- package/frame.d.ts +80 -0
- package/frame.d.ts.map +1 -0
- package/frame.js +296 -0
- package/frame.js.map +1 -0
- package/frame.test-util.d.ts +5 -0
- package/frame.test-util.d.ts.map +1 -0
- package/frame.test-util.js +9 -0
- package/frame.test-util.js.map +1 -0
- package/group.d.ts +108 -45
- package/group.d.ts.map +1 -1
- package/group.js +1616 -307
- package/group.js.map +1 -1
- package/group_api.d.ts +7 -0
- package/group_api.d.ts.map +1 -0
- package/group_api.js +7 -0
- package/group_api.js.map +1 -0
- package/hop.d.ts +62 -76
- package/hop.d.ts.map +1 -1
- package/hop.js +92 -64
- package/hop.js.map +1 -1
- package/identity.d.ts +39 -0
- package/identity.d.ts.map +1 -0
- package/identity.js +47 -0
- package/identity.js.map +1 -0
- package/ietf/active_count.d.ts +2 -0
- package/ietf/active_count.d.ts.map +1 -0
- package/ietf/active_count.js +30 -0
- package/ietf/active_count.js.map +1 -0
- package/ietf/aliases.js +69 -35
- package/ietf/aliases.js.map +1 -1
- package/ietf/cluster.d.ts +3 -3
- package/ietf/cluster.js +14 -62
- package/ietf/cluster.js.map +1 -1
- package/ietf/connection.d.ts +1 -31
- package/ietf/connection.d.ts.map +1 -1
- package/ietf/connection.js +305 -143
- package/ietf/connection.js.map +1 -1
- package/ietf/datagram.d.ts +60 -0
- package/ietf/datagram.d.ts.map +1 -0
- package/ietf/datagram.js +152 -0
- package/ietf/datagram.js.map +1 -0
- package/ietf/error.d.ts +3 -3
- package/ietf/error.js +82 -100
- package/ietf/error.js.map +1 -1
- package/ietf/fetch.d.ts +91 -35
- package/ietf/fetch.d.ts.map +1 -1
- package/ietf/fetch.js +172 -93
- package/ietf/fetch.js.map +1 -1
- package/ietf/filter.d.ts +20 -30
- package/ietf/filter.d.ts.map +1 -1
- package/ietf/filter.js +140 -171
- package/ietf/filter.js.map +1 -1
- package/ietf/goaway.d.ts +11 -9
- package/ietf/goaway.d.ts.map +1 -1
- package/ietf/goaway.js +22 -35
- package/ietf/goaway.js.map +1 -1
- package/ietf/hidden.js +1 -1
- package/ietf/hidden.js.map +1 -1
- package/ietf/index.d.ts +2 -14
- package/ietf/index.d.ts.map +1 -1
- package/ietf/index.js +4 -14
- package/ietf/index.js.map +1 -1
- package/ietf/join.d.ts +7 -0
- package/ietf/join.d.ts.map +1 -0
- package/ietf/join.js +234 -0
- package/ietf/join.js.map +1 -0
- package/ietf/message.d.ts +18 -2
- package/ietf/message.d.ts.map +1 -1
- package/ietf/message.js +60 -40
- package/ietf/message.js.map +1 -1
- package/ietf/message.test-util.d.ts +6 -0
- package/ietf/message.test-util.d.ts.map +1 -0
- package/ietf/message.test-util.js +13 -0
- package/ietf/message.test-util.js.map +1 -0
- package/ietf/namespace.d.ts +17 -3
- package/ietf/namespace.d.ts.map +1 -1
- package/ietf/namespace.js +78 -26
- package/ietf/namespace.js.map +1 -1
- package/ietf/object.d.ts +194 -32
- package/ietf/object.d.ts.map +1 -1
- package/ietf/object.js +405 -178
- package/ietf/object.js.map +1 -1
- package/ietf/parameters.d.ts +22 -42
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +260 -472
- package/ietf/parameters.js.map +1 -1
- package/ietf/priority.d.ts +17 -2
- package/ietf/priority.d.ts.map +1 -1
- package/ietf/priority.js +19 -4
- package/ietf/priority.js.map +1 -1
- package/ietf/properties.d.ts +5 -4
- package/ietf/properties.d.ts.map +1 -1
- package/ietf/properties.js +78 -48
- package/ietf/properties.js.map +1 -1
- package/ietf/publish.d.ts +22 -30
- package/ietf/publish.d.ts.map +1 -1
- package/ietf/publish.js +45 -139
- package/ietf/publish.js.map +1 -1
- package/ietf/publish_namespace.d.ts +46 -69
- package/ietf/publish_namespace.d.ts.map +1 -1
- package/ietf/publish_namespace.js +66 -184
- package/ietf/publish_namespace.js.map +1 -1
- package/ietf/publisher.js +1800 -600
- package/ietf/publisher.js.map +1 -1
- package/ietf/range.d.ts +2 -0
- package/ietf/range.d.ts.map +1 -0
- package/ietf/range.js +222 -0
- package/ietf/range.js.map +1 -0
- package/ietf/request.d.ts +3 -27
- package/ietf/request.d.ts.map +1 -1
- package/ietf/request.js +41 -78
- package/ietf/request.js.map +1 -1
- package/ietf/request_stream.d.ts +1 -6
- package/ietf/request_stream.d.ts.map +1 -1
- package/ietf/request_stream.js +306 -16
- package/ietf/request_stream.js.map +1 -1
- package/ietf/session.d.ts +41 -0
- package/ietf/session.d.ts.map +1 -0
- package/ietf/session.js +65 -0
- package/ietf/session.js.map +1 -0
- package/ietf/setup.d.ts +4 -29
- package/ietf/setup.d.ts.map +1 -1
- package/ietf/setup.js +6 -117
- package/ietf/setup.js.map +1 -1
- package/ietf/setup_options.d.ts +31 -0
- package/ietf/setup_options.d.ts.map +1 -0
- package/ietf/setup_options.js +138 -0
- package/ietf/setup_options.js.map +1 -0
- package/ietf/solicit.js +4 -14
- package/ietf/solicit.js.map +1 -1
- package/ietf/subscribe.d.ts +48 -41
- package/ietf/subscribe.d.ts.map +1 -1
- package/ietf/subscribe.js +118 -239
- package/ietf/subscribe.js.map +1 -1
- package/ietf/subscribe_namespace.d.ts +13 -76
- package/ietf/subscribe_namespace.d.ts.map +1 -1
- package/ietf/subscribe_namespace.js +30 -201
- package/ietf/subscribe_namespace.js.map +1 -1
- package/ietf/subscriber.js +1839 -536
- package/ietf/subscriber.js.map +1 -1
- package/ietf/token.js +105 -27
- package/ietf/token.js.map +1 -1
- package/ietf/track.d.ts +25 -22
- package/ietf/track.d.ts.map +1 -1
- package/ietf/track.js +48 -61
- package/ietf/track.js.map +1 -1
- package/ietf/version.d.ts +13 -42
- package/ietf/version.d.ts.map +1 -1
- package/ietf/version.js +22 -48
- package/ietf/version.js.map +1 -1
- package/implementation.d.ts +2 -0
- package/implementation.d.ts.map +1 -0
- package/implementation.js +5 -0
- package/implementation.js.map +1 -0
- package/index.d.ts +25 -10
- package/index.d.ts.map +1 -1
- package/index.js +19 -6
- package/index.js.map +1 -1
- package/internal.d.ts +1512 -64
- package/internal.d.ts.map +1 -1
- package/internal.js +557 -79
- package/internal.js.map +1 -1
- package/ledger.d.ts +23 -0
- package/ledger.d.ts.map +1 -0
- package/ledger.js +247 -0
- package/ledger.js.map +1 -0
- package/listing.d.ts +132 -0
- package/listing.d.ts.map +1 -0
- package/listing.js +486 -0
- package/listing.js.map +1 -0
- package/lite/announce.d.ts +124 -63
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +384 -158
- package/lite/announce.js.map +1 -1
- package/lite/announce_stream.d.ts +2 -0
- package/lite/announce_stream.d.ts.map +1 -0
- package/lite/announce_stream.js +92 -0
- package/lite/announce_stream.js.map +1 -0
- package/lite/answer.d.ts +22 -0
- package/lite/answer.d.ts.map +1 -0
- package/lite/answer.js +301 -0
- package/lite/answer.js.map +1 -0
- package/lite/auth.d.ts +45 -0
- package/lite/auth.d.ts.map +1 -0
- package/lite/auth.js +204 -0
- package/lite/auth.js.map +1 -0
- package/lite/compat.d.ts +31 -0
- package/lite/compat.d.ts.map +1 -0
- package/lite/compat.js +86 -0
- package/lite/compat.js.map +1 -0
- package/lite/connection.d.ts +1 -45
- package/lite/connection.d.ts.map +1 -1
- package/lite/connection.js +360 -77
- package/lite/connection.js.map +1 -1
- package/lite/datagram-end.d.ts +26 -0
- package/lite/datagram-end.d.ts.map +1 -0
- package/lite/datagram-end.js +30 -0
- package/lite/datagram-end.js.map +1 -0
- package/lite/datagram.d.ts +73 -8
- package/lite/datagram.d.ts.map +1 -1
- package/lite/datagram.js +144 -9
- package/lite/datagram.js.map +1 -1
- package/lite/duration.d.ts +6 -0
- package/lite/duration.d.ts.map +1 -0
- package/lite/duration.js +14 -0
- package/lite/duration.js.map +1 -0
- package/lite/error.d.ts +9 -0
- package/lite/error.d.ts.map +1 -0
- package/lite/error.js +24 -0
- package/lite/error.js.map +1 -0
- package/lite/fills.d.ts +162 -0
- package/lite/fills.d.ts.map +1 -0
- package/lite/fills.js +486 -0
- package/lite/fills.js.map +1 -0
- package/lite/fit.d.ts +49 -0
- package/lite/fit.d.ts.map +1 -0
- package/lite/fit.js +305 -0
- package/lite/fit.js.map +1 -0
- package/lite/goaway.d.ts +1 -1
- package/lite/goaway.d.ts.map +1 -1
- package/lite/goaway.js +5 -13
- package/lite/goaway.js.map +1 -1
- package/lite/group.d.ts +64 -13
- package/lite/group.d.ts.map +1 -1
- package/lite/group.js +108 -30
- package/lite/group.js.map +1 -1
- package/lite/identity.d.ts +25 -0
- package/lite/identity.d.ts.map +1 -0
- package/lite/identity.js +79 -0
- package/lite/identity.js.map +1 -0
- package/lite/index.d.ts +2 -1
- package/lite/index.d.ts.map +1 -1
- package/lite/index.js +2 -1
- package/lite/index.js.map +1 -1
- package/lite/message.d.ts +9 -1
- package/lite/message.d.ts.map +1 -1
- package/lite/message.js +28 -44
- package/lite/message.js.map +1 -1
- package/lite/priority.d.ts +9 -2
- package/lite/priority.d.ts.map +1 -1
- package/lite/priority.js +11 -105
- package/lite/priority.js.map +1 -1
- package/lite/probe.d.ts.map +1 -1
- package/lite/probe.js +9 -0
- package/lite/probe.js.map +1 -1
- package/lite/publisher.d.ts +10 -1
- package/lite/publisher.d.ts.map +1 -1
- package/lite/publisher.js +2548 -437
- package/lite/publisher.js.map +1 -1
- package/lite/routed.d.ts +59 -0
- package/lite/routed.d.ts.map +1 -0
- package/lite/routed.js +564 -0
- package/lite/routed.js.map +1 -0
- package/lite/session.d.ts +1 -27
- package/lite/session.d.ts.map +1 -1
- package/lite/session.js +0 -99
- package/lite/session.js.map +1 -1
- package/lite/setup.d.ts +29 -2
- package/lite/setup.d.ts.map +1 -1
- package/lite/setup.js +95 -21
- package/lite/setup.js.map +1 -1
- package/lite/stream.d.ts +5 -11
- package/lite/stream.d.ts.map +1 -1
- package/lite/stream.js +5 -1
- package/lite/stream.js.map +1 -1
- package/lite/subscribe.d.ts +475 -75
- package/lite/subscribe.d.ts.map +1 -1
- package/lite/subscribe.js +1373 -142
- package/lite/subscribe.js.map +1 -1
- package/lite/subscriber.d.ts +7 -44
- package/lite/subscriber.d.ts.map +1 -1
- package/lite/subscriber.js +3290 -515
- package/lite/subscriber.js.map +1 -1
- package/lite/track.d.ts +24 -9
- package/lite/track.d.ts.map +1 -1
- package/lite/track.js +116 -37
- package/lite/track.js.map +1 -1
- package/lite/tracks.d.ts +55 -0
- package/lite/tracks.d.ts.map +1 -0
- package/lite/tracks.js +114 -0
- package/lite/tracks.js.map +1 -0
- package/lite/version.d.ts +132 -24
- package/lite/version.d.ts.map +1 -1
- package/lite/version.js +378 -33
- package/lite/version.js.map +1 -1
- package/meta.d.ts +77 -0
- package/meta.d.ts.map +1 -0
- package/meta.js +130 -0
- package/meta.js.map +1 -0
- package/meta_api.d.ts +7 -0
- package/meta_api.d.ts.map +1 -0
- package/meta_api.js +7 -0
- package/meta_api.js.map +1 -0
- package/mint.d.ts +28 -0
- package/mint.d.ts.map +1 -0
- package/mint.js +66 -0
- package/mint.js.map +1 -0
- package/open.d.ts +63 -0
- package/open.d.ts.map +1 -0
- package/open.js +250 -0
- package/open.js.map +1 -0
- package/origin.d.ts +392 -140
- package/origin.d.ts.map +1 -1
- package/origin.js +2533 -686
- package/origin.js.map +1 -1
- package/package.json +8 -13
- package/path.d.ts +51 -51
- package/path.d.ts.map +1 -1
- package/path.js +210 -57
- package/path.js.map +1 -1
- package/payload.d.ts +33 -0
- package/payload.d.ts.map +1 -0
- package/payload.js +65 -0
- package/payload.js.map +1 -0
- package/prefix.d.ts +152 -0
- package/prefix.d.ts.map +1 -0
- package/prefix.js +349 -0
- package/prefix.js.map +1 -0
- package/priority.d.ts +8 -0
- package/priority.d.ts.map +1 -0
- package/priority.js +185 -0
- package/priority.js.map +1 -0
- package/queue.d.ts +2 -0
- package/queue.d.ts.map +1 -0
- package/queue.js +46 -0
- package/queue.js.map +1 -0
- package/ranges.d.ts +36 -0
- package/ranges.d.ts.map +1 -0
- package/ranges.js +312 -0
- package/ranges.js.map +1 -0
- package/rescale.d.ts +24 -0
- package/rescale.d.ts.map +1 -0
- package/rescale.js +39 -0
- package/rescale.js.map +1 -0
- package/resume.d.ts +55 -0
- package/resume.d.ts.map +1 -0
- package/resume.js +4173 -0
- package/resume.js.map +1 -0
- package/resume.test-util.d.ts +2 -0
- package/resume.test-util.d.ts.map +1 -0
- package/resume.test-util.js +25 -0
- package/resume.test-util.js.map +1 -0
- package/skips.d.ts +48 -0
- package/skips.d.ts.map +1 -0
- package/skips.js +182 -0
- package/skips.js.map +1 -0
- package/stream.d.ts +75 -37
- package/stream.d.ts.map +1 -1
- package/stream.js +236 -92
- package/stream.js.map +1 -1
- package/subscription.test-util.d.ts +2 -0
- package/subscription.test-util.d.ts.map +1 -0
- package/subscription.test-util.js +49 -0
- package/subscription.test-util.js.map +1 -0
- package/tail.d.ts +23 -14
- package/tail.d.ts.map +1 -1
- package/tail.js +224 -97
- package/tail.js.map +1 -1
- package/time.d.ts +41 -102
- package/time.d.ts.map +1 -1
- package/time.js +129 -91
- package/time.js.map +1 -1
- package/timed.d.ts +21 -0
- package/timed.d.ts.map +1 -0
- package/timed.js +2 -0
- package/timed.js.map +1 -0
- package/track.d.ts +577 -245
- package/track.d.ts.map +1 -1
- package/track.js +7306 -771
- package/track.js.map +1 -1
- package/track_api.d.ts +7 -0
- package/track_api.d.ts.map +1 -0
- package/track_api.js +7 -0
- package/track_api.js.map +1 -0
- package/util/abort.d.ts +1 -0
- package/util/abort.d.ts.map +1 -1
- package/util/abort.js +23 -1
- package/util/abort.js.map +1 -1
- package/util/announce.d.ts +4 -0
- package/util/announce.d.ts.map +1 -0
- package/util/announce.js +11 -0
- package/util/announce.js.map +1 -0
- package/util/bigint.d.ts +3 -0
- package/util/bigint.d.ts.map +1 -0
- package/util/bigint.js +8 -0
- package/util/bigint.js.map +1 -0
- package/util/change.d.ts +12 -0
- package/util/change.d.ts.map +1 -0
- package/util/change.js +18 -0
- package/util/change.js.map +1 -0
- package/util/deadline.d.ts +2 -0
- package/util/deadline.d.ts.map +1 -0
- package/util/deadline.js +108 -0
- package/util/deadline.js.map +1 -0
- package/util/decode_error.d.ts +3 -0
- package/util/decode_error.d.ts.map +1 -0
- package/util/decode_error.js +11 -0
- package/util/decode_error.js.map +1 -0
- package/util/demand.d.ts +8 -0
- package/util/demand.d.ts.map +1 -0
- package/util/demand.js +24 -0
- package/util/demand.js.map +1 -0
- package/util/given_up.d.ts +2 -0
- package/util/given_up.d.ts.map +1 -0
- package/util/given_up.js +101 -0
- package/util/given_up.js.map +1 -0
- package/util/hex.d.ts +6 -0
- package/util/hex.d.ts.map +1 -1
- package/util/hex.js +19 -4
- package/util/hex.js.map +1 -1
- package/util/key.d.ts +15 -0
- package/util/key.d.ts.map +1 -0
- package/util/key.js +38 -0
- package/util/key.js.map +1 -0
- package/util/limits.d.ts +2 -0
- package/util/limits.d.ts.map +1 -0
- package/util/limits.js +76 -0
- package/util/limits.js.map +1 -0
- package/util/observed.d.ts +23 -0
- package/util/observed.d.ts.map +1 -0
- package/util/observed.js +122 -0
- package/util/observed.js.map +1 -0
- package/util/sorted.d.ts +2 -0
- package/util/sorted.d.ts.map +1 -0
- package/util/sorted.js +149 -0
- package/util/sorted.js.map +1 -0
- package/util/timeout.d.ts +2 -1
- package/util/timeout.d.ts.map +1 -1
- package/util/timeout.js +13 -9
- package/util/timeout.js.map +1 -1
- package/util/timer.d.ts +2 -0
- package/util/timer.d.ts.map +1 -0
- package/util/timer.js +19 -0
- package/util/timer.js.map +1 -0
- package/util/utf8.d.ts +2 -0
- package/util/utf8.d.ts.map +1 -1
- package/util/utf8.js +7 -1
- package/util/utf8.js.map +1 -1
- package/util/varint.d.ts.map +1 -1
- package/util/varint.js +8 -1
- package/util/varint.js.map +1 -1
- package/util/watch.d.ts +8 -0
- package/util/watch.d.ts.map +1 -0
- package/util/watch.js +38 -0
- package/util/watch.js.map +1 -0
- package/util/yield.d.ts +2 -0
- package/util/yield.d.ts.map +1 -0
- package/util/yield.js +31 -0
- package/util/yield.js.map +1 -0
- package/varint.d.ts +0 -29
- package/varint.d.ts.map +1 -1
- package/varint.js +7 -28
- package/varint.js.map +1 -1
- package/varint_api.d.ts +7 -0
- package/varint_api.d.ts.map +1 -0
- package/varint_api.js +7 -0
- package/varint_api.js.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +4 -0
- package/version.js.map +1 -0
- package/window.d.ts +570 -0
- package/window.d.ts.map +1 -0
- package/window.js +1677 -0
- package/window.js.map +1 -0
- package/wire.d.ts +145 -30
- package/wire.d.ts.map +1 -1
- package/wire.js +27 -0
- package/wire.js.map +1 -1
- package/connection/established.d.ts +0 -53
- package/connection/established.d.ts.map +0 -1
- package/connection/established.js +0 -2
- package/connection/established.js.map +0 -1
- package/ietf/adapter.d.ts +0 -75
- package/ietf/adapter.d.ts.map +0 -1
- package/ietf/adapter.js +0 -699
- package/ietf/adapter.js.map +0 -1
- package/lite/datagram_stream.d.ts +0 -8
- package/lite/datagram_stream.d.ts.map +0 -1
- package/lite/datagram_stream.js +0 -43
- package/lite/datagram_stream.js.map +0 -1
- package/lite/fetch.d.ts +0 -28
- package/lite/fetch.d.ts.map +0 -1
- package/lite/fetch.js +0 -78
- package/lite/fetch.js.map +0 -1
- package/util/log.d.ts +0 -5
- package/util/log.d.ts.map +0 -1
- package/util/log.js +0 -16
- package/util/log.js.map +0 -1
- package/zod.d.ts +0 -13
- package/zod.d.ts.map +0 -1
- package/zod.js +0 -18
- package/zod.js.map +0 -1
package/broadcast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../src/broadcast.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAmB,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,KAAK,EAAsB,MAAM,eAAe,CAAC;AAC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,IAAI,CAAC,OAAO;YAAE,OAAO;QACzB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,CAAC;YAAE,OAAO;QACxC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAChC,CAAC;CACD","sourcesContent":["/**\n * Broadcast role handles: a named collection of tracks produced by a publisher.\n *\n * @module\n */\nimport { type GetPromise, Once, Signal } from \"@moq/signals\";\nimport { NotFound } from \"./error.ts\";\nimport type { Consumer as GroupConsumer } from \"./group.ts\";\nimport { Route } from \"./hop.ts\";\nimport { hooks, type TrackSequence } from \"./internal.ts\";\nimport * as Path from \"./path.ts\";\nimport * as track from \"./track.ts\";\nimport { untilAborted } from \"./util/abort.ts\";\nimport { registerWire, trackOf, type Broadcast as Wire } from \"./wire.ts\";\n\n/** The origin callback a created broadcast uses to advertise its exact path. @internal */\nexport interface Announcer {\n\t/** Advertise or re-price this broadcast's path. */\n\tannounce(route: Route): void;\n\t/** Retract the advertisement from local consumers and peers alike. */\n\tunannounce(): void;\n}\n\nlet attachAnnouncer: (producer: Producer, announcer: Announcer) => void;\nlet stampProducer: (producer: Producer, path: Path.Valid) => void;\n\n/** Reactive backing state shared by broadcast producers and consumers. */\nclass BroadcastState {\n\trequested = new Signal<track.Request[]>([]);\n\tpending = new Set<track.Request>();\n\tclosed = new Once<Error | null>();\n\ttracks = new Map<string, track.Producer>();\n\tsequences = new Map<string, TrackSequence>();\n\t// Live consumer handles sharing this state (see {@link Consumer.clone}). The broadcast\n\t// closes once the last one closes, so a shared consumer can be handed to several callers.\n\tconsumers = 0;\n}\n\nfunction dequeueRequest(state: BroadcastState): track.Request | undefined {\n\tconst requested = state.requested.peek();\n\trequested.sort((a, b) => a.priority - b.priority);\n\treturn requested.pop();\n}\n\n// Close the broadcast and reject any requests still pending in the queue, so a\n// subscriber blocked on the track's info() or group reads is unblocked rather\n// than left waiting on a producer that will never be served.\n//\n// Once.set throws on a second settle, and the producer and each consumer handle close\n// independently, so this has to be idempotent.\nfunction closeState(state: BroadcastState, abort?: Error) {\n\tif (state.closed.peek() !== undefined) return;\n\tstate.closed.set(abort ?? null);\n\tfor (const request of state.pending) request.reject(abort);\n\tstate.requested.mutate((requests) => {\n\t\trequests.length = 0;\n\t});\n}\n\n// `register` is set on the subscribing (consumer) side: the fresh producer is cached in\n// `state.tracks` so repeat subscriptions to the same track fan out from one upstream subscription\n// instead of opening a new one, mirroring the Rust `broadcast::Consumer::track` weak-dedup. The\n// consumer wire watches the producer's demand ({@link track.Producer.used}) and tears the upstream\n// down once its last subscriber leaves, closing the producer, which evicts the cache entry below.\n// The publishing side leaves `register` false: `state.tracks` there holds only the tracks the app\n// inserted, and a dynamic serve stays one request per peer subscription.\nfunction subscribe(\n\tstate: BroadcastState,\n\tname: string,\n\toptions: track.Subscription = {},\n\tregister = false,\n): track.Subscriber {\n\tif (state.closed.peek() !== undefined) {\n\t\tthrow new Error(`broadcast is closed: ${state.closed.peek()}`);\n\t}\n\n\tconst existing = state.tracks.get(name);\n\tif (existing) {\n\t\tif (existing.closed.peek() === undefined) return existing.subscribe(options);\n\t\tstate.tracks.delete(name);\n\t}\n\n\tconst producer = new track.Producer(name);\n\tconst subscriber = producer.subscribe(options);\n\n\tif (register) {\n\t\tstate.tracks.set(name, producer);\n\t\t// Drop the cache entry once the upstream closes (the wire tears it down when its last\n\t\t// subscriber leaves), so a later subscribe re-opens it.\n\t\tvoid producer.closed.then(() => {\n\t\t\tif (state.tracks.get(name) === producer) state.tracks.delete(name);\n\t\t});\n\t}\n\n\tstate.requested.mutate((requested) => {\n\t\trequested.push(hooks.makeRequest({ name, producer, sequences: state.sequences, pending: state.pending }));\n\t});\n\n\treturn subscriber;\n}\n\nasync function resolveTrackInfo(state: BroadcastState, name: string): Promise<track.Info> {\n\tconst existing = state.tracks.get(name);\n\tif (existing && existing.closed.peek() === undefined) {\n\t\treturn existing.info();\n\t}\n\n\tif (state.closed.peek() !== undefined) {\n\t\treturn Promise.reject(new Error(`broadcast is closed: ${state.closed.peek()}`));\n\t}\n\n\tconst producer = new track.Producer(name);\n\tstate.requested.mutate((requested) => {\n\t\trequested.push(hooks.makeRequest({ name, producer, sequences: state.sequences, pending: state.pending }));\n\t});\n\n\ttry {\n\t\treturn await producer.info();\n\t} finally {\n\t\tproducer.close();\n\t}\n}\n\n// Serve a group from the local retained window by subscribing and scanning to the\n// requested sequence. The default for a produced broadcast; the consuming wire layer\n// overrides it to fetch over the network (or to reject when the transport has no FETCH).\nasync function fetchGroup(\n\tstate: BroadcastState,\n\tname: string,\n\tsequence: number,\n\toptions: track.FetchGroupOptions = {},\n): Promise<GroupConsumer> {\n\toptions.signal?.throwIfAborted();\n\tconst subscriber = subscribe(state, name, { priority: options.priority });\n\thooks.exemptFetch(subscriber);\n\ttry {\n\t\tfor (;;) {\n\t\t\tconst group = await untilAborted(subscriber.recvGroup(), options.signal);\n\t\t\tif (!group) throw new NotFound(`group ${sequence}`);\n\t\t\tif (group.sequence === sequence) {\n\t\t\t\t// Close the subscription when the returned group finishes, not now: an\n\t\t\t\t// in-progress group must keep receiving frames for its lifetime (mirrors\n\t\t\t\t// Rust poll_fetch). Also fires if the caller closes the group early.\n\t\t\t\tvoid group.closed.then(() => subscriber.close());\n\t\t\t\treturn group;\n\t\t\t}\n\n\t\t\tgroup.close();\n\t\t\tif (group.sequence > sequence) throw new NotFound(`group ${sequence}`);\n\t\t}\n\t} catch (err) {\n\t\tsubscriber.close();\n\t\tthrow err;\n\t}\n}\n\n/**\n * The write side of a broadcast.\n *\n * @public\n */\nexport class Producer {\n\t#state = new BroadcastState();\n\t#announcer?: Announcer;\n\t#path = Path.empty();\n\n\tconstructor() {\n\t\tregisterWire(this, this.#wire(false));\n\t}\n\n\tstatic {\n\t\tattachAnnouncer = (producer, announcer) => {\n\t\t\tproducer.#announcer = announcer;\n\t\t};\n\t\thooks.attachAnnouncer = attachAnnouncer;\n\t\tstampProducer = (producer, path) => {\n\t\t\tproducer.#path = path;\n\t\t};\n\t}\n\n\t/**\n\t * Settles once the broadcast closes: `null` on a clean close, or the abort {@link Error}.\n\t * Peek it synchronously (`undefined` while open), observe it reactively, or `await` it.\n\t */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#state.closed;\n\t}\n\n\t/** A read handle for this broadcast, named by the path the origin created it at. */\n\tconsume(): Consumer {\n\t\treturn makeConsumer({ state: this.#state, path: this.#path });\n\t}\n\n\tasync #requested(): Promise<track.Request | undefined> {\n\t\tfor (;;) {\n\t\t\tconst request = dequeueRequest(this.#state);\n\t\t\tif (request) return request;\n\n\t\t\tconst closed = this.#state.closed.peek();\n\t\t\tif (closed instanceof Error) throw closed;\n\t\t\tif (closed !== undefined) return undefined;\n\n\t\t\tawait Signal.race(this.#state.requested, this.#state.closed);\n\t\t}\n\t}\n\n\t/** Insert a track that is served directly, without an on-demand request round-trip. */\n\tinsertTrack(track: track.Producer): void {\n\t\tif (this.#state.closed.peek() !== undefined) {\n\t\t\tthrow new Error(`broadcast is closed: ${this.#state.closed.peek()}`);\n\t\t}\n\n\t\tconst existing = this.#state.tracks.get(track.name);\n\t\tif (existing && existing.closed.peek() === undefined) {\n\t\t\tthrow new Error(`duplicate track: ${track.name}`);\n\t\t}\n\n\t\tthis.#state.tracks.set(track.name, track);\n\n\t\tvoid track.closed.then(() => {\n\t\t\tif (this.#state.tracks.get(track.name) === track) {\n\t\t\t\tthis.#state.tracks.delete(track.name);\n\t\t\t}\n\t\t});\n\t}\n\n\t/** Create a track, insert it into the broadcast, and return its producer. */\n\tcreateTrack(name: string, info: Partial<track.Info> = {}): track.Producer {\n\t\tconst producer = new track.Producer(name).accept(info);\n\t\tthis.insertTrack(producer);\n\t\treturn producer;\n\t}\n\n\t/** Remove a statically inserted track by name. */\n\tremoveTrack(name: string): void {\n\t\tthis.#state.tracks.delete(name);\n\t}\n\n\t/** A lazy read handle for a track on this broadcast. */\n\ttrack(name: string): track.Consumer {\n\t\treturn trackOf(name, this);\n\t}\n\n\t#wire(register: boolean): Wire {\n\t\treturn {\n\t\t\tsubscribe: (name, options) => subscribe(this.#state, name, options, register),\n\t\t\tresolveTrackInfo: (name) => resolveTrackInfo(this.#state, name),\n\t\t\tfetchGroup: (name, sequence, options) => fetchGroup(this.#state, name, sequence, options),\n\t\t\trequested: () => this.#requested(),\n\t\t};\n\t}\n\n\t/**\n\t * Advertise this broadcast's exact path, or re-price a standing advertisement in place.\n\t *\n\t * Call it once the tracks a subscriber needs first (a catalog) exist. Until then the\n\t * broadcast exists for nobody, on its own origin or at a peer. Retracts on\n\t * {@link unannounce} or {@link close}. Throws if this producer was not created through an\n\t * origin, or if the broadcast is already closed.\n\t */\n\tannounce(route: Route | { hops?: Route[\"hops\"]; cost?: Route[\"cost\"] | bigint } = Route.default): void {\n\t\tif (this.#state.closed.peek() !== undefined) {\n\t\t\tthrow new Error(`broadcast is closed: ${this.#state.closed.peek()}`);\n\t\t}\n\t\tif (!this.#announcer) throw new Error(\"broadcast is not attached to an origin\");\n\t\tthis.#announcer.announce(Route.normalize(route));\n\t}\n\n\t/**\n\t * Retract the advertisement of this broadcast's path, if any, from local consumers and\n\t * peers alike. {@link announce} brings it back.\n\t */\n\tunannounce(): void {\n\t\tthis.#announcer?.unannounce();\n\t}\n\n\t/** End the broadcast for good: retract it, serve no new tracks, and refuse a later {@link announce}. Idempotent. */\n\tclose(): void;\n\t/** @deprecated A broadcast end carries no cause; call `close()` without one. */\n\tclose(abort?: Error): void;\n\tclose(abort?: Error) {\n\t\tthis.#announcer?.unannounce();\n\t\tthis.#announcer = undefined;\n\t\tcloseState(this.#state, abort);\n\t}\n}\n\n// What a new consumer handle inherits: the shared broadcast plus the path naming it.\ninterface Shared {\n\tstate: BroadcastState;\n\tpath: Path.Valid;\n}\n\n// Constructs a Consumer from within this module without exposing a public constructor\n// that would leak the unexported BroadcastState. Assigned in the class's static block.\nlet makeConsumer: (shared: Shared) => Consumer;\n\n/**\n * The read side of a broadcast.\n *\n * Created internally: obtain one from {@link Producer.consume} or an origin request.\n * The wire layers subclass it to resolve tracks over the network.\n *\n * @public\n */\nexport class Consumer {\n\t#state: BroadcastState;\n\t#path: Path.Valid;\n\n\t// Guards against a double close() on this handle over-decrementing the consumer count.\n\t#closed = false;\n\n\tprotected constructor(shared?: never);\n\tprotected constructor(shared?: Shared) {\n\t\tthis.#state = shared?.state ?? new BroadcastState();\n\t\tthis.#path = shared?.path ?? Path.empty();\n\t\tthis.#state.consumers++;\n\t\tregisterWire(this, {\n\t\t\tsubscribe: (name, options) => subscribe(this.#state, name, options, true),\n\t\t\tresolveTrackInfo: (name) => resolveTrackInfo(this.#state, name),\n\t\t\tfetchGroup: (name, sequence, options) => fetchGroup(this.#state, name, sequence, options),\n\t\t\trequested: () => this.#requested(),\n\t\t});\n\t}\n\n\tstatic {\n\t\tmakeConsumer = (shared) => new Consumer(shared as never);\n\t\thooks.stampPath = (target, path) => {\n\t\t\tif (target instanceof Consumer) target.#path = path;\n\t\t\telse stampProducer(target, path);\n\t\t};\n\t}\n\n\t/**\n\t * The path this handle names the broadcast by, which relative references in its catalog\n\t * (hang's `broadcast` field) resolve against.\n\t *\n\t * An origin stamps each handle it hands out with the path it was requested at, relative to\n\t * that origin handle's scope root, and a broadcast it created with the path it was created at.\n\t * Empty for a standalone broadcast, which is then its own root: any `..` reference escapes.\n\t */\n\tget path(): Path.Valid {\n\t\treturn this.#path;\n\t}\n\n\t/**\n\t * Settles once the broadcast closes: `null` on a clean close, or the abort {@link Error}.\n\t * Peek it synchronously (`undefined` while open), observe it reactively, or `await` it.\n\t *\n\t * Shared by every {@link clone}: it settles once the last handle closes. The subscribing\n\t * wire layer peeks it to evict a closed entry from its per-path consume cache.\n\t */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#state.closed;\n\t}\n\n\t/**\n\t * Return another handle to the same broadcast, reference-counted with this one.\n\t *\n\t * Both handles read the same tracks, carry the same {@link path}, and share one {@link closed}\n\t * state; the broadcast closes only once *every* handle has {@link close}d. Used by the connection's per-path\n\t * consume cache to share one subscription across callers. Subclasses that resolve info over\n\t * the wire override this to preserve their type (see the wire layer's consumed broadcast).\n\t */\n\tclone(): Consumer {\n\t\treturn new Consumer(this.shareState());\n\t}\n\n\t// Hand this consumer's backing state and path to a clone. Opaque (`never`) so the state type\n\t// stays unexported; a subclass passes it straight back into its own `super(...)`.\n\tprotected shareState(): never {\n\t\treturn { state: this.#state, path: this.#path } satisfies Shared as never;\n\t}\n\n\t/** Get a lazy handle for a track on this broadcast. Repeat subscriptions dedupe onto one upstream subscription. */\n\ttrack(name: string): track.Consumer {\n\t\treturn trackOf(name, this);\n\t}\n\n\tasync #requested(): Promise<track.Request | undefined> {\n\t\tfor (;;) {\n\t\t\tconst request = dequeueRequest(this.#state);\n\t\t\tif (request) return request;\n\n\t\t\tconst closed = this.#state.closed.peek();\n\t\t\tif (closed instanceof Error) throw closed;\n\t\t\tif (closed !== undefined) return undefined;\n\n\t\t\tawait Signal.race(this.#state.requested, this.#state.closed);\n\t\t}\n\t}\n\n\t/**\n\t * Release this handle. The broadcast is closed once this was the last live handle;\n\t * while other {@link clone}s remain open it stays live.\n\t */\n\tclose(): void;\n\t/** @deprecated A broadcast end carries no cause; call `close()` without one. */\n\tclose(abort?: Error): void;\n\tclose(abort?: Error) {\n\t\tif (this.#closed) return;\n\t\tthis.#closed = true;\n\t\tif (--this.#state.consumers > 0) return;\n\t\tcloseState(this.#state, abort);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../src/broadcast.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAmB,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAA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ChB,QAAQ,EAAE,IAAI,CAAC,SAAS;YACxB,QAAQ,EAAE,IAAI,CAAC,SAAS;SACE,CAAC;IAC7B,CAAC;IAED,wFAAwF;IACxF,SAAS,CAAC,IAAY;QACrB,SAAS,CAAC,IAAI,CAAC,CAAC;QAChB,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,mHAAmH;IACnH,KAAK,CAAC,IAAY;QACjB,OAAO,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,IAAI,CAAC,IAAY;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM;QACL,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;IAED,OAAO,CAAC,KAAc;QACrB,IAAI,IAAI,CAAC,SAAS;YAAE,MAAM,IAAI,QAAQ,CAAC,2CAA2C,CAAC,CAAC;QACpF,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACH,KAAK;QACJ,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO;QACzB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM;YAAE,OAAO;QAC/D,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;CACD","sourcesContent":["/**\n * Broadcast role handles: a named collection of tracks produced by a publisher.\n *\n * @module\n */\nimport { type GetPromise, Once, Signal } from \"@moq/signals\";\nimport * as cache from \"./cache.ts\";\nimport * as datagram from \"./datagram.ts\";\nimport { NotFound, StreamCode, StreamError } from \"./error.ts\";\nimport type { Consumer as GroupConsumer } from \"./group.ts\";\nimport type * as Identity from \"./identity.ts\";\nimport { holeError, hooks } from \"./internal.ts\";\nimport { Listing, listTracks, makeLister, type Tracks } from \"./listing.ts\";\nimport * as Meta from \"./meta.ts\";\nimport * as Path from \"./path.ts\";\nimport type { Timescale } from \"./time.ts\";\nimport * as track from \"./track.ts\";\nimport { untilAborted } from \"./util/abort.ts\";\nimport { checkName } from \"./util/utf8.ts\";\nimport { type Broadcast, type Produced, registerWire, trackMetaOf, trackOf, wireOf } from \"./wire.ts\";\n\nexport { type Kind, type Listed, Tracks, type TracksEvent } from \"./listing.ts\";\n\nlet stampProducer: (producer: Producer, path: Path.Valid) => void;\n\n// The info lookups on an on-demand track.\nclass Lookups {\n\t// Whether a lookup opened the request, so the last lookup to end closes it unless subscribed.\n\topened = false;\n}\n\n/** Reactive backing state shared by broadcast producers and consumers. */\nclass BroadcastState {\n\trequested = new Signal<track.Request[]>([]);\n\tdatagramRequested = new Signal<datagram.Request[]>([]);\n\tdatagramPending = new Set<datagram.Request>();\n\tdatagrams = new Map<string, datagram.Producer>();\n\tdatagramServed = false;\n\tpending = new Set<track.Request>();\n\tclosed = new Once<null>();\n\t// The tracks the broadcast lists, and the readers listing them.\n\tlisting = new Listing(this.closed);\n\t// The tracks the application inserted. A finished one stays and keeps serving its cache; only an\n\t// abort or removeTrack drops it, the way only a dropped producer leaves a Rust broadcast.\n\ttracks = new Map<string, track.Producer>();\n\t// The on-demand producer for each name, shared by every subscription and info lookup until it closes.\n\trequests = new Map<string, track.Producer>();\n\t// The same for each name's metadata copy, kept apart so no payload reader is ever handed one.\n\t// Only filled while `meta` is set.\n\tmetaRequests = new Map<string, track.Producer>();\n\t// Whether its request handler fills a metadata copy apart from the payload one; see\n\t// `hooks.serveMeta`. Otherwise a metadata reader takes the payload copy's headers.\n\tmeta = false;\n\tlookups = new WeakMap<track.Producer, Lookups>();\n\t// Whether something answers on-demand track requests: a wire layer's consumed broadcast, or a\n\t// publisher that has started pulling them. The counterpart of a live Rust `broadcast::Requests`;\n\t// without one, a track nobody publishes is `NotFound` rather than a request nobody will answer.\n\tserved = false;\n\t// Live consumer handles sharing this state (see {@link Consumer.clone}).\n\tconsumers = 0;\n\t// A wire layer's broadcast, which has no producer: it ends once no consumer holds it, as a\n\t// Rust session retires a source nothing holds. A produced broadcast ends only on its close.\n\tunheld = false;\n\t// Run synchronously once the broadcast closes, before `closed` notifies its observers.\n\tclosers = new Set<() => void>();\n\t// The cache pool every track of the broadcast caches into, defaulting as Rust's\n\t// `broadcast::Info` does: no byte capacity, and the default idle window.\n\tpool = new cache.Pool({ expiry: cache.DEFAULT_EXPIRY });\n}\n\n// A new track of the broadcast, caching into its pool: its metadata copy when `meta`.\nfunction createProducer(state: BroadcastState, name: string, meta = false): track.Producer {\n\tconst producer = hooks.pendingTrack(name);\n\thooks.poolTrack(producer, state.pool);\n\tif (meta) hooks.metaTrack(producer);\n\treturn producer;\n}\n\n// Datagram tracks never enter the stream cache.\nfunction liveDatagrams(state: BroadcastState, name: string, passive = false): datagram.Consumer | undefined {\n\tconst producer = state.datagrams.get(name);\n\tif (!producer) return;\n\tif (producer.closed.peek() !== undefined) {\n\t\tstate.datagrams.delete(name);\n\t\treturn;\n\t}\n\treturn passive ? hooks.observeDatagrams(producer) : producer.consume();\n}\n\n// Create the datagram track `name`, listed until it ends unless `listed` is false: a session's\n// datagram track riding a stream track's subscription serves a request, not the inventory.\nfunction createDatagrams(\n\tstate: BroadcastState,\n\tname: string,\n\tinfo: Partial<datagram.Info>,\n\tlisted = true,\n): datagram.Producer | undefined {\n\tif (state.closed.peek() !== undefined) throw new Error(\"broadcast is closed\");\n\t// A request its readers closed waits for async cleanup; serve the name fresh instead.\n\tconst queued = state.datagramRequested\n\t\t.peek()\n\t\t.find((request) => request.name === name && request.closed.peek() === undefined);\n\tlet producer: datagram.Producer;\n\tif (queued) {\n\t\tstate.datagramRequested.mutate((requests) => requests.splice(requests.indexOf(queued), 1));\n\t\tproducer = queued.accept(info);\n\t} else {\n\t\tconst existing = state.datagrams.get(name);\n\t\tif (existing?.closed.peek() === undefined && existing) return undefined;\n\t\tproducer = new datagram.Producer(name, info);\n\t\tstate.datagrams.set(name, producer);\n\t\tvoid producer.closed.then(() => {\n\t\t\tif (state.datagrams.get(name) === producer) state.datagrams.delete(name);\n\t\t});\n\t}\n\tif (listed) {\n\t\tconst accepted = hooks.datagramInfo(producer);\n\t\tif (!accepted) throw new Error(\"datagram track has not been accepted\");\n\t\tstate.listing.listDatagrams(producer, accepted);\n\t\thooks.onDatagramsEnd(producer, (finished) => state.listing.unlistOwn(producer, \"datagrams\", finished));\n\t}\n\treturn producer;\n}\n\nfunction datagrams(state: BroadcastState, name: string): datagram.Consumer {\n\tif (state.closed.peek() !== undefined) throw new Error(\"broadcast is closed\");\n\tconst existing = liveDatagrams(state, name);\n\tif (existing) return existing;\n\tconst producer = hooks.pendingDatagrams(name);\n\tconst consumer = producer.consume();\n\tif (!state.datagramServed) {\n\t\thooks.abortDatagrams(producer, new NotFound(`datagram track ${name}`));\n\t\treturn consumer;\n\t}\n\tconst request = hooks.datagramRequest(producer, state.datagramPending);\n\tstate.datagrams.set(name, producer);\n\tstate.datagramRequested.mutate((requests) => requests.push(request));\n\tvoid producer.closed.then(() => {\n\t\tstate.datagramPending.delete(request);\n\t\tif (state.datagrams.get(name) === producer) state.datagrams.delete(name);\n\t\tstate.datagramRequested.mutate((requests) => {\n\t\t\tconst index = requests.indexOf(request);\n\t\t\tif (index !== -1) requests.splice(index, 1);\n\t\t});\n\t});\n\treturn consumer;\n}\n\nasync function requestedDatagrams(state: BroadcastState): Promise<datagram.Request | undefined> {\n\tstate.datagramServed = true;\n\tfor (;;) {\n\t\tconst requests = state.datagramRequested.peek();\n\t\trequests.sort((a, b) => (a.priority.peek() ?? -128) - (b.priority.peek() ?? -128));\n\t\tconst request = requests.pop();\n\t\tif (request && request.closed.peek() === undefined) return request;\n\t\tif (request) continue;\n\t\tif (state.closed.peek() !== undefined) return;\n\t\tawait Signal.race(state.datagramRequested, state.closed);\n\t}\n}\n\nfunction dequeueRequest(state: BroadcastState): track.Request | undefined {\n\tconst requested = state.requested.peek();\n\trequested.sort((a, b) => a.priority - b.priority);\n\treturn requested.pop();\n}\n\n// The next on-demand track request, or undefined once the broadcast closes.\nasync function requested(state: BroadcastState): Promise<track.Request | undefined> {\n\t// Pulling requests is what makes a broadcast serve tracks on demand, and it latches for the\n\t// broadcast's lifetime since JS has no drop to mark the handler gone. A subscribe before the first\n\t// pull is answered NotFound, so an on-demand publisher starts pulling before it publishes and keeps\n\t// pulling until the broadcast closes.\n\tstate.served = true;\n\tfor (;;) {\n\t\tconst request = dequeueRequest(state);\n\t\tif (request) return request;\n\n\t\tif (state.closed.peek() !== undefined) return undefined;\n\n\t\tawait Signal.race(state.requested, state.closed);\n\t}\n}\n\n// Close the broadcast and reject any requests still pending in the queue, so a\n// subscriber blocked on the track's info() or group reads is unblocked rather\n// than left waiting on a producer that will never be served.\n//\n// Once.set throws on a second settle, and the producer and each consumer handle close\n// independently, so this has to be idempotent.\nfunction closeState(state: BroadcastState) {\n\tif (state.closed.peek() !== undefined) return;\n\tstate.closed.set(null);\n\tstate.listing.close();\n\tfor (const request of state.datagramPending) request.reject(new StreamError(StreamCode.Cancel));\n\tstate.datagramRequested.set([]);\n\tfor (const request of state.pending)\n\t\trequest.reject(\n\t\t\tnew StreamError(StreamCode.Internal, {\n\t\t\t\tmessage: `track request ${request.name} dropped before acceptance`,\n\t\t\t}),\n\t\t);\n\tstate.requested.mutate((requests) => {\n\t\trequests.length = 0;\n\t});\n\tfor (const fn of state.closers) fn();\n\tstate.closers.clear();\n}\n\n// The producer already serving `name`, or its metadata copy when `meta`, evicting entries that can\n// no longer serve it. The application inserts payload tracks alone.\nfunction lookup(state: BroadcastState, name: string, meta = false): track.Producer | undefined {\n\tconst inserted = meta ? undefined : state.tracks.get(name);\n\tif (inserted) {\n\t\tif (!(hooks.trackReleased(inserted).peek() instanceof Error)) return inserted;\n\t\tstate.tracks.delete(name);\n\t}\n\n\tconst requests = requestsOf(state, meta);\n\tconst requested = requests.get(name);\n\tif (requested) {\n\t\tif (hooks.trackReleased(requested).peek() === undefined) return requested;\n\t\trequests.delete(name);\n\t}\n\n\treturn undefined;\n}\n\n// The on-demand producers for payload copies, or for metadata copies when `meta`.\nfunction requestsOf(state: BroadcastState, meta: boolean): Map<string, track.Producer> {\n\treturn meta ? state.metaRequests : state.requests;\n}\n\n// The producer serving `name`, or a new one with a request queued for it.\n//\n// A broadcast has one logical track per name, mirroring the Rust `broadcast::Consumer::track`\n// weak-dedup: a requested producer is cached in `state.requests` so every subscription and info\n// lookup fans out from one request instead of opening another. Whoever serves it closes it once\n// unused (the consuming wire tears the upstream down when its last subscriber leaves), which evicts\n// the entry so a later subscribe requests the track again.\n//\n// A metadata reader (`meta`) gets a logical track of its own only where the handler fills one\n// (`state.meta`), and the payload one otherwise, whose headers it takes.\nfunction logical(state: BroadcastState, name: string, meta = false): { producer: track.Producer; requested: boolean } {\n\tif (state.closed.peek() !== undefined) {\n\t\tthrow new Error(\"broadcast is closed\");\n\t}\n\n\tconst copy = meta && state.meta;\n\tconst existing = lookup(state, name, copy);\n\tif (existing) return { producer: existing, requested: false };\n\n\tconst producer = createProducer(state, name, copy);\n\tif (!state.served) {\n\t\t// Answer through the track rather than throwing, so a peer's subscribe is refused with\n\t\t// the code instead of an unhandled error.\n\t\thooks.abortTrack(producer, new NotFound(`track ${name}`));\n\t\treturn { producer, requested: false };\n\t}\n\n\tconst lookups = new Lookups();\n\tstate.lookups.set(producer, lookups);\n\tconst requests = requestsOf(state, copy);\n\trequests.set(name, producer);\n\tvoid hooks.trackReleased(producer).then(() => {\n\t\tif (requests.get(name) === producer) requests.delete(name);\n\t});\n\n\tstate.requested.mutate((requested) => {\n\t\trequested.push(hooks.makeRequest({ name, producer, pending: state.pending, lookups, meta: copy }));\n\t});\n\n\treturn { producer, requested: true };\n}\n\nfunction subscribe(state: BroadcastState, name: string, options?: track.Subscription, meta = false): track.Subscriber {\n\treturn logical(state, name, meta).producer.subscribe(options);\n}\n\n// A lookup counts as the track's demand until `hold` aborts (without one, until the answer), before\n// and after acceptance, as a Rust `Resolving` does while held. An unanswered request stays open for its handler; after\n// acceptance, the last holder of a request a lookup opened releases it.\nasync function resolveTrackInfo(\n\tstate: BroadcastState,\n\tname: string,\n\thold?: AbortSignal,\n\tmeta = false,\n): Promise<track.Info> {\n\thold?.throwIfAborted();\n\tconst { producer, requested } = logical(state, name, meta);\n\tconst lookups = state.lookups.get(producer);\n\tif (lookups && requested) lookups.opened = true;\n\tconst unhold = hooks.holdTrack(producer);\n\n\tconst info = producer.info();\n\tlet answered = false;\n\tlet ended = false;\n\tconst release = () => {\n\t\tif (lookups?.opened && !producer.demand().wanted.peek()) hooks.releaseTrack(producer);\n\t};\n\tinfo.then(\n\t\t() => {\n\t\t\tanswered = true;\n\t\t\tif (ended) release();\n\t\t},\n\t\t() => {},\n\t);\n\tconst end = () => {\n\t\tended = true;\n\t\tunhold();\n\t\tif (answered) release();\n\t};\n\n\tif (!hold) {\n\t\ttry {\n\t\t\treturn await info;\n\t\t} finally {\n\t\t\tend();\n\t\t}\n\t}\n\thold.addEventListener(\"abort\", end, { once: true });\n\treturn untilAborted(info, hold);\n}\n\n// The newest frame cached for `name`, without subscribing: undefined when nobody serves it yet.\nfunction largest(state: BroadcastState, name: string, meta = false, timescale?: Timescale): track.Position | undefined {\n\tconst producer = lookup(state, name, meta && state.meta);\n\treturn producer && hooks.cachedLargest(producer, timescale);\n}\n\n// Fetch one group as a one-range subscription: the cached group at once, or else one the track's\n// {@link track.Requests} handler answers, asked at once whether the group was written yet or not,\n// as the Rust `fetch_group` does. A group the producer writes meanwhile answers it too. With no\n// handler open, a miss fails at once with `NotFound`. The default for a produced broadcast and a\n// lite-05/06 session's, whose copies ask their misses upstream; other wire layers override it to\n// fetch over the network, or to reject on a version that cannot fetch.\nasync function fetchGroup(\n\tstate: BroadcastState,\n\tname: string,\n\tkey: bigint,\n\toptions: track.FetchGroupOptions = {},\n\tmeta = false,\n): Promise<GroupConsumer> {\n\toptions.signal?.throwIfAborted();\n\tconst range: track.Range = { start: key, end: key };\n\tif (options.priority !== undefined) range.priority = options.priority;\n\tconst subscriber = subscribe(state, name, { ranges: [range], placed: new Map([[0, key]]) }, meta);\n\thooks.asFetch(subscriber);\n\ttry {\n\t\t// Judged in this turn when the track is known, so a cached group is taken before anything\n\t\t// else can change it. A track requested on demand opens its handler once accepted, so its\n\t\t// miss is judged then.\n\t\tlet asked = hooks.askFetch(subscriber, key);\n\t\tif (asked === \"pending\") {\n\t\t\tawait untilAborted(subscriber.info(), options.signal);\n\t\t\tasked = hooks.askFetch(subscriber, key);\n\t\t}\n\t\tif (asked !== true) throw new NotFound(`group ${key}`);\n\t\tfor (;;) {\n\t\t\tconst recv = hooks.tryRecvGroup(subscriber, true);\n\t\t\tswitch (recv.kind) {\n\t\t\t\tcase \"group\":\n\t\t\t\t\t// Close the subscription once the caller has read or released the group, not\n\t\t\t\t\t// now: an in-progress group must keep receiving frames for its lifetime\n\t\t\t\t\t// (mirrors Rust poll_fetch), and a failed group's unread frames stay in the\n\t\t\t\t\t// cache's reach, expirable, until the caller lets them go.\n\t\t\t\t\tvoid hooks.groupDone(recv.group).then(() => subscriber.close());\n\t\t\t\t\treturn recv.group;\n\t\t\t\tcase \"drop\":\n\t\t\t\t\t// A copy that failed for no verdict of its own (not stale, not skipped) says nothing of\n\t\t\t\t\t// the group, so a caller may ask again or elsewhere.\n\t\t\t\t\tif (recv.failed && recv.reason === \"drop\")\n\t\t\t\t\t\tthrow new StreamError(StreamCode.Cancel, { message: `group ${key} copy failed` });\n\t\t\t\t\t// Rethrown with its own reason, so a stale verdict stays OLD.\n\t\t\t\t\tif (recv.refusal) {\n\t\t\t\t\t\t// A wire-backed fill can return a delivery failure through the same path.\n\t\t\t\t\t\tif (!state.unheld) (options as FetchFrom).refused?.(recv.refusal);\n\t\t\t\t\t\tthrow recv.refusal;\n\t\t\t\t\t}\n\t\t\t\t\tthrow holeError(recv);\n\t\t\t\tcase \"error\":\n\t\t\t\t\tthrow recv.error;\n\t\t\t\tcase \"done\":\n\t\t\t\t\tthrow new NotFound(`group ${key}`);\n\t\t\t}\n\t\t\tawait untilAborted(changed(subscriber), options.signal);\n\t\t}\n\t} catch (err) {\n\t\tsubscriber.close();\n\t\tthrow err;\n\t}\n}\n\n/**\n * What a route passes to {@link fetchGroup} beside its public options.\n *\n * @internal\n */\nexport interface FetchFrom {\n\t/** Report an application fill's explicit refusal to the route issuing this fetch. */\n\trefused?: (error: Error) => void;\n}\n\n// Settles once a read of `subscriber` may go differently.\nfunction changed(subscriber: track.Subscriber): Promise<void> {\n\treturn new Promise((resolve) => {\n\t\tconst dispose = hooks.groupChanged(subscriber, () => {\n\t\t\tdispose();\n\t\t\tresolve();\n\t\t});\n\t});\n}\n\n// Remove and return the payload request queued for `name`, if no handler has taken it yet.\nfunction takeQueued(state: BroadcastState, name: string): track.Request | undefined {\n\tconst queued = state.requested.peek().find((request) => request.name === name && !request.meta);\n\tif (!queued) return undefined;\n\tstate.requested.mutate((requests) => {\n\t\trequests.splice(requests.indexOf(queued), 1);\n\t});\n\treturn queued;\n}\n\n// What a metadata reader resolves names through where the handler fills metadata copies apart\n// (`state.meta`): undefined elsewhere, where it reads the payload copies through `view` itself.\nfunction metaView(state: BroadcastState, view: Produced): () => Broadcast | undefined {\n\tconst meta: Produced = {\n\t\t...view,\n\t\tsubscribe: (name, options) => subscribe(state, name, options, true),\n\t\tresolveTrackInfo: (name, hold) => resolveTrackInfo(state, name, hold, true),\n\t\tlargest: (name) => largest(state, name, true),\n\t\tfetchGroup: (name, key, options) => fetchGroup(state, name, key, options, true),\n\t};\n\treturn () => (state.meta ? meta : undefined);\n}\n\n// Serve `producer` as the broadcast's track for its name, listed with `info`.\nfunction adopt(state: BroadcastState, producer: track.Producer, info: track.Info): void {\n\tstate.tracks.set(producer.name, producer);\n\tstate.listing.listTrack(producer, info);\n\t// Released, it leaves the listing at once, finished if it declared its end, as a dropped Rust\n\t// producer does.\n\thooks.onTrackRelease(producer, (finished) => state.listing.unlistOwn(producer, \"track\", finished));\n\n\t// A finished track keeps serving its cache, so only an abort evicts it from the table.\n\tvoid hooks.trackReleased(producer).then((closed) => {\n\t\tif (closed instanceof Error && state.tracks.get(producer.name) === producer) state.tracks.delete(producer.name);\n\t});\n}\n\n/**\n * The write side of a broadcast.\n *\n * @public\n */\nexport class Producer {\n\t#state = new BroadcastState();\n\t#path = Path.empty();\n\n\tconstructor() {\n\t\tconst view: Produced = {\n\t\t\tlocalDatagrams: !this.#state.unheld,\n\t\t\tdistinguishesKinds: !this.#state.unheld,\n\t\t\tsubscribe: (name, options) => subscribe(this.#state, name, options),\n\t\t\tresolveTrackInfo: (name, hold) => resolveTrackInfo(this.#state, name, hold),\n\t\t\tlargest: (name, timescale) => largest(this.#state, name, false, timescale),\n\t\t\tfetchGroup: (name, key, options) => fetchGroup(this.#state, name, key, options),\n\t\t\trequested: () => requested(this.#state),\n\t\t\tdatagrams: (name) => datagrams(this.#state, name),\n\t\t\tliveDatagrams: (name) => liveDatagrams(this.#state, name, true),\n\t\t\tpublishesTrack: (name) => this.#state.tracks.has(name),\n\t\t\tcreateDatagrams: (name, info, listed) => createDatagrams(this.#state, name, info, listed),\n\t\t\trequestedDatagrams: () => requestedDatagrams(this.#state),\n\t\t\ttracks: (owner) => listTracks(this.#state.listing, owner),\n\t\t\tlister: () => makeLister(this.#state.listing),\n\t\t};\n\t\tregisterWire(this, { ...view, meta: metaView(this.#state, view) });\n\t}\n\n\tstatic {\n\t\thooks.reserveUnlistedTrack = (broadcast, name) => {\n\t\t\tconst state = broadcast.#state;\n\t\t\tif (state.closed.peek() !== undefined) throw new Error(\"broadcast is closed\");\n\t\t\tif (lookup(state, name)) throw new Error(\"duplicate reserved track\");\n\t\t\tconst producer = createProducer(state, name);\n\t\t\tconst lookups = new Lookups();\n\t\t\tstate.lookups.set(producer, lookups);\n\t\t\tstate.requests.set(name, producer);\n\t\t\tvoid hooks.trackReleased(producer).then(() => {\n\t\t\t\tif (state.requests.get(name) === producer) state.requests.delete(name);\n\t\t\t});\n\t\t\treturn hooks.makeRequest({ name, producer, pending: state.pending, lookups });\n\t\t};\n\n\t\thooks.onClosed = (producer, fn) => {\n\t\t\tconst closers = producer.#state.closers;\n\t\t\tclosers.add(fn);\n\t\t\treturn () => closers.delete(fn);\n\t\t};\n\t\tstampProducer = (producer, path) => {\n\t\t\tproducer.#path = path;\n\t\t};\n\t}\n\n\t/**\n\t * Settles with `null` once the broadcast closes; a broadcast end carries no cause.\n\t * Peek it synchronously (`undefined` while open), observe it reactively, or `await` it.\n\t */\n\tget closed(): GetPromise<null> {\n\t\treturn this.#state.closed;\n\t}\n\n\t/** A read handle for this broadcast, named by the path the origin created it at. */\n\tconsume(): Consumer {\n\t\treturn makeConsumer({ state: this.#state, path: this.#path });\n\t}\n\n\t/**\n\t * Create a track, insert it into the broadcast, and return its producer, or `undefined` while\n\t * an open track or a live request holds the name.\n\t *\n\t * A request still queued for the name is answered with this track, so its subscribers read\n\t * from the returned producer. A request a handler has already taken stays a duplicate.\n\t * An append on the track throws if it would reuse a key an earlier track of the name\n\t * wrote in this broadcast, so a replacement writes its first group explicitly. Throws if the\n\t * broadcast is closed, or if the name holds a lone surrogate, which UTF-8 cannot carry. An omitted\n\t * `maxAge` in `info` is zero, the live edge only.\n\t */\n\tcreateTrack(name: string, info: track.InfoInit = {}): track.Producer | undefined {\n\t\tif (this.#state.closed.peek() !== undefined) {\n\t\t\tthrow new Error(\"broadcast is closed\");\n\t\t}\n\n\t\tconst request = takeQueued(this.#state, name);\n\t\tif (request) {\n\t\t\tconst producer = request.accept(info);\n\t\t\thooks.keepRequest(request);\n\t\t\tthis.#state.requests.delete(name);\n\t\t\tadopt(this.#state, producer, track.authoredInfo(info));\n\t\t\treturn producer;\n\t\t}\n\n\t\t// One logical track per name: an open track or a live request already serves it.\n\t\t// A request a handler already pulled stays duplicate, as in Rust.\n\t\tconst live = [this.#state.tracks.get(name), this.#state.requests.get(name)];\n\t\tif (live.some((existing) => existing && hooks.trackReleased(existing).peek() === undefined)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst producer = createProducer(this.#state, name).accept(info);\n\t\tadopt(this.#state, producer, track.authoredInfo(info));\n\t\treturn producer;\n\t}\n\n\t/**\n\t * Create a live datagram track in a namespace separate from stream tracks, or `undefined`\n\t * while a live datagram track holds the name.\n\t */\n\tcreateDatagrams(name: string, info: Partial<datagram.Info> = {}): datagram.Producer | undefined {\n\t\treturn createDatagrams(this.#state, name, info);\n\t}\n\n\t/**\n\t * Remove a statically inserted track, including a finished cached one, and stop listing it\n\t * at once.\n\t */\n\tremoveTrack(name: string): void {\n\t\tconst track = this.#state.tracks.get(name);\n\t\tif (!track) return;\n\t\tthis.#state.tracks.delete(name);\n\t\tthis.#state.listing.unlistOwn(track);\n\t}\n\n\t/** A lazy read handle for a track on this broadcast. */\n\ttrack(name: string): track.Consumer {\n\t\treturn trackOf(name, this);\n\t}\n\n\t/** End the broadcast for good: serve no new tracks. Idempotent. */\n\tclose(): void {\n\t\tcloseState(this.#state);\n\t}\n}\n\n// What a new consumer handle inherits: the shared broadcast plus the path naming it.\ninterface Shared {\n\tstate: BroadcastState;\n\tpath: Path.Valid;\n\tidentity?: Identity.Valid;\n\tunlisted?: boolean;\n}\n\n// Constructs a Consumer from within this module without exposing a public constructor\n// that would leak the unexported BroadcastState. Assigned in the class's static block.\nlet makeConsumer: (shared: Shared) => Consumer;\n\n/**\n * The read side of a broadcast.\n *\n * Created internally: obtain one from {@link Producer.consume} or an origin request.\n * The wire layers subclass it to resolve tracks over the network.\n *\n * @public\n */\nexport class Consumer {\n\t#state: BroadcastState;\n\t#path: Path.Valid;\n\t#identity?: Identity.Valid;\n\t// Served on request through a route claiming a shorter prefix, which names no broadcast to list.\n\t#unlisted: boolean;\n\n\t// Guards against a double close() on this handle over-decrementing the consumer count.\n\t#closed = false;\n\n\tprotected constructor(shared?: never);\n\tprotected constructor(shared?: Shared) {\n\t\tthis.#path = shared?.path ?? Path.empty();\n\t\tthis.#identity = shared?.identity;\n\t\tthis.#unlisted = shared?.unlisted ?? false;\n\t\tif (shared) {\n\t\t\tthis.#state = shared.state;\n\t\t} else {\n\t\t\t// A standalone consumer is a wire layer's, which serves every track on demand.\n\t\t\tthis.#state = new BroadcastState();\n\t\t\tthis.#state.served = true;\n\t\t\tthis.#state.datagramServed = true;\n\t\t\tthis.#state.unheld = true;\n\t\t}\n\t\tthis.#state.consumers++;\n\t\tconst view: Produced = {\n\t\t\tlocalDatagrams: !this.#state.unheld,\n\t\t\tdistinguishesKinds: !this.#state.unheld,\n\t\t\tsubscribe: (name, options) => subscribe(this.#state, name, options),\n\t\t\tresolveTrackInfo: (name, hold) => resolveTrackInfo(this.#state, name, hold),\n\t\t\tlargest: (name, timescale) => largest(this.#state, name, false, timescale),\n\t\t\tfetchGroup: (name, key, options) => fetchGroup(this.#state, name, key, options),\n\t\t\trequested: () => requested(this.#state),\n\t\t\tdatagrams: (name) => datagrams(this.#state, name),\n\t\t\tliveDatagrams: (name) => liveDatagrams(this.#state, name, true),\n\t\t\tpublishesTrack: (name) => this.#state.tracks.has(name),\n\t\t\tcreateDatagrams: (name, info, listed) => createDatagrams(this.#state, name, info, listed),\n\t\t\trequestedDatagrams: () => requestedDatagrams(this.#state),\n\t\t\ttracks: (owner) => this.#tracks(owner),\n\t\t\tlister: () => makeLister(this.#state.listing),\n\t\t};\n\t\tregisterWire(this, { ...view, meta: metaView(this.#state, view) });\n\t}\n\n\tstatic {\n\t\tmakeConsumer = (shared) => new Consumer(shared as never);\n\t\thooks.stampPath = (target, path) => {\n\t\t\tif (target instanceof Consumer) target.#path = path;\n\t\t\telse stampProducer(target, path);\n\t\t};\n\t\thooks.stampIdentity = (target, identity) => {\n\t\t\ttarget.#identity = identity;\n\t\t};\n\t\thooks.stampUnlisted = (target) => {\n\t\t\ttarget.#unlisted = true;\n\t\t};\n\t\thooks.unlisted = (target) => target.#unlisted;\n\t\thooks.serveMeta = (target) => {\n\t\t\ttarget.#state.meta = true;\n\t\t};\n\t\thooks.resolveHeld = (target, name, hold) => {\n\t\t\tconst state = target.#state;\n\t\t\tif (state.closed.peek() !== undefined) return undefined;\n\t\t\tconst producer = lookup(state, name);\n\t\t\tif (!producer || !hooks.acceptedInfo(producer)) return undefined;\n\t\t\treturn resolveTrackInfo(state, name, hold);\n\t\t};\n\t}\n\n\t/**\n\t * The path this handle names the broadcast by, which relative references in its catalog\n\t * (hang's `broadcast` field) resolve against.\n\t *\n\t * An origin stamps each handle it hands out with the path it was requested at, relative to\n\t * that origin handle's scope root, and a broadcast it created with the path it was created at.\n\t * Empty for a standalone broadcast, which is then its own root: any `..` reference escapes.\n\t */\n\tget path(): Path.Valid {\n\t\treturn this.#path;\n\t}\n\n\t/**\n\t * The identity of the route an origin resolved this handle through: the stream it reads.\n\t *\n\t * An origin stamps it with each request's result, so it names the stream actually serving\n\t * this handle even when the request named none. `undefined` for a handle not handed out by\n\t * an origin.\n\t */\n\tget identity(): Identity.Valid | undefined {\n\t\treturn this.#identity;\n\t}\n\n\t/**\n\t * Settles with `null` once the broadcast closes; a broadcast end carries no cause.\n\t * Peek it synchronously (`undefined` while open), observe it reactively, or `await` it.\n\t *\n\t * Shared by every {@link clone}. A produced broadcast settles once its producer closes; a\n\t * broadcast consumed from a session, once the session ends it or the last handle closes.\n\t * The subscribing wire layer peeks it to evict a closed entry from its per-path consume cache.\n\t */\n\tget closed(): GetPromise<null> {\n\t\treturn this.#state.closed;\n\t}\n\n\t/**\n\t * Return another handle to the same broadcast, reference-counted with this one.\n\t *\n\t * Both handles read the same tracks, carry the same {@link path}, and share one {@link closed}\n\t * state. Used by the connection's per-path\n\t * consume cache to share one subscription across callers. Subclasses that resolve info over\n\t * the wire override this to preserve their type (see the wire layer's consumed broadcast).\n\t */\n\tclone(): Consumer {\n\t\treturn new Consumer(this.shareState());\n\t}\n\n\t/**\n\t * This consumer's backing state and path, for a clone. Opaque (`never`) so the state type\n\t * stays unexported; a subclass passes it straight back into its own `super(...)`.\n\t *\n\t * @internal\n\t */\n\tprotected shareState(): never {\n\t\treturn {\n\t\t\tstate: this.#state,\n\t\t\tpath: this.#path,\n\t\t\tidentity: this.#identity,\n\t\t\tunlisted: this.#unlisted,\n\t\t} satisfies Shared as never;\n\t}\n\n\t/** Read a datagram track live from now, independently of any same-name stream track. */\n\tdatagrams(name: string): datagram.Consumer {\n\t\tcheckName(name);\n\t\treturn wireOf(this).datagrams(name);\n\t}\n\n\t/** Get a lazy handle for a track on this broadcast. Repeat subscriptions dedupe onto one upstream subscription. */\n\ttrack(name: string): track.Consumer {\n\t\treturn trackOf(name, this);\n\t}\n\n\t/**\n\t * Get a lazy handle to a track's metadata: its groups and each frame's header, without the\n\t * payload. See {@link Meta}.\n\t */\n\tmeta(name: string): Meta.Consumer {\n\t\treturn Meta.consumerOf(trackMetaOf(name, this));\n\t}\n\n\t/**\n\t * List the broadcast's tracks: each one with its info, then `synced`, then changes as they\n\t * happen, until the broadcast ends.\n\t *\n\t * Lists the tracks its producer created (until they are released, abort, or are removed) and, for a\n\t * broadcast consumed from a session, the tracks the peer lists. Through a session the\n\t * peer's tracks arrive as they come and the listing syncs when the peer does; every\n\t * listing of one broadcast shares one request to the peer. A track served only\n\t * on request is never listed, and listing never requests one. Throws once the broadcast\n\t * has closed.\n\t */\n\ttracks(): Tracks {\n\t\treturn this.#tracks();\n\t}\n\n\t#tracks(owner?: object): Tracks {\n\t\tif (this.#unlisted) throw new NotFound(\"a route claiming a prefix lists no tracks\");\n\t\treturn listTracks(this.#state.listing, owner);\n\t}\n\n\t/**\n\t * Release this handle, like dropping a Rust handle. A produced broadcast stays open until\n\t * its producer closes; one consumed from a session ends once no {@link clone} holds it.\n\t */\n\tclose(): void {\n\t\tif (this.#closed) return;\n\t\tthis.#closed = true;\n\t\tif (--this.#state.consumers > 0 || !this.#state.unheld) return;\n\t\tcloseState(this.#state);\n\t}\n}\n"]}
|
package/cache.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The idle window of cached groups. Mirrors the idle expiry of the Rust `cache` module, without
|
|
3
|
+
* its byte budget: no JS caller sets a capacity, so nothing here evicts for bytes.
|
|
4
|
+
*
|
|
5
|
+
* Every track of a broadcast caches into one {@link Pool} through its own {@link Track} account,
|
|
6
|
+
* and every cached group records its last access through a {@link Charge}. A group nobody reads
|
|
7
|
+
* or writes for the pool's window is reclaimed, except a live track's latest. Writes scan for
|
|
8
|
+
* idle groups as they go, and the pool sweeps every track at half the window for the ones
|
|
9
|
+
* nothing writes to.
|
|
10
|
+
*
|
|
11
|
+
* Package-internal: not exported from the entrypoint.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import { Duration } from "@moq/clock";
|
|
16
|
+
/** How long a group nobody reads or writes stays cached by default, matching Rust `cache::DEFAULT_EXPIRY`. */
|
|
17
|
+
export declare const DEFAULT_EXPIRY: Duration;
|
|
18
|
+
/** The initial policy for a {@link Pool}. */
|
|
19
|
+
export interface Config {
|
|
20
|
+
/** How long a group nobody reads or writes stays cached; never reclaimed for idleness when omitted. */
|
|
21
|
+
expiry?: Duration;
|
|
22
|
+
}
|
|
23
|
+
/** The idle window shared by the cached groups of every track caching into it. */
|
|
24
|
+
export declare class Pool {
|
|
25
|
+
#private;
|
|
26
|
+
constructor(config?: Config);
|
|
27
|
+
/** Ticks since the pool first read the clock. */
|
|
28
|
+
now(): number;
|
|
29
|
+
/** The idle window in ticks, or undefined when idle groups stay. */
|
|
30
|
+
get expiryTicks(): number | undefined;
|
|
31
|
+
/** Visit `track` on each idle sweep, if the pool has an idle window, while it holds something that may expire. */
|
|
32
|
+
register(track: Track<Entry>): void;
|
|
33
|
+
/** Stop visiting `track`, which holds nothing that may expire. */
|
|
34
|
+
unregister(track: Track<Entry>): void;
|
|
35
|
+
/** Expire the idle groups of every registered track. */
|
|
36
|
+
sweep(): void;
|
|
37
|
+
}
|
|
38
|
+
/** A cached group as its track's account knows it. */
|
|
39
|
+
export interface Entry {
|
|
40
|
+
/** Its last access. */
|
|
41
|
+
readonly charge: Charge;
|
|
42
|
+
}
|
|
43
|
+
/** How an account reaches the track whose groups it expires. */
|
|
44
|
+
export interface Owner<E extends Entry> {
|
|
45
|
+
/** Whether `entry` is the live edge, which expiry never takes. */
|
|
46
|
+
protects(entry: E): boolean;
|
|
47
|
+
/** Take `entry` out of the cache and end it for idling. */
|
|
48
|
+
evict(entry: E): void;
|
|
49
|
+
/** Something was evicted: settle what the cache's contents decide. */
|
|
50
|
+
settle(): void;
|
|
51
|
+
/** Forget the runs of the drop set given up longer than the pool's idle window before tick `now`, returning whether any went. */
|
|
52
|
+
expireDrops(now: number): boolean;
|
|
53
|
+
/** Whether the track holds a drop run a reclaim may forget, which keeps its account in the idle sweep. */
|
|
54
|
+
holdsDrops(): boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* One track's account against a {@link Pool}: its cached groups, in the order the idle scan
|
|
58
|
+
* visits them. Mirrors the expiry half of the Rust `cache::Track`.
|
|
59
|
+
*/
|
|
60
|
+
export declare class Track<E extends Entry> {
|
|
61
|
+
#private;
|
|
62
|
+
/** The pool this track caches into. */
|
|
63
|
+
readonly pool: Pool;
|
|
64
|
+
constructor(pool: Pool, owner: Owner<E>);
|
|
65
|
+
/** Open the access record of a new group, stamped now. */
|
|
66
|
+
charge(): Charge;
|
|
67
|
+
/** The drop set changed: keep the account in the idle sweep while it holds a run to forget. */
|
|
68
|
+
dropsChanged(): void;
|
|
69
|
+
/** Whether the account caches any group. */
|
|
70
|
+
get empty(): boolean;
|
|
71
|
+
/** Cache `entry` at the back of the scan order, expirable now unless it is the live edge. */
|
|
72
|
+
insert(entry: E): void;
|
|
73
|
+
/** Make `entry` expirable once the live edge no longer protects it. */
|
|
74
|
+
demote(entry: E): void;
|
|
75
|
+
/** Forget `entry`, which left the cache. */
|
|
76
|
+
remove(entry: E): void;
|
|
77
|
+
/**
|
|
78
|
+
* Evict the groups idle past the pool's window, never the live edge: every one when `full`,
|
|
79
|
+
* or else a bounded scan from a rotating cursor. Returns whether it evicted a group.
|
|
80
|
+
*/
|
|
81
|
+
evictExpired(full: boolean): boolean;
|
|
82
|
+
/** Settle from a frame write: scan for idle groups once per second, so a track that only appends frames to open groups still ages. */
|
|
83
|
+
settle(): void;
|
|
84
|
+
/** Expire every idle group, from the pool's sweep. */
|
|
85
|
+
sweep(): void;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* One cached group's last access, which its idle window runs from, and its route to its track's
|
|
89
|
+
* idle scan. Cleared once the group leaves the cache, after which every operation is a no-op.
|
|
90
|
+
*/
|
|
91
|
+
export declare class Charge {
|
|
92
|
+
#private;
|
|
93
|
+
private constructor();
|
|
94
|
+
/** The tick of the last access. */
|
|
95
|
+
get accessed(): number;
|
|
96
|
+
/** Record an access, a read or a write, restarting the idle window. */
|
|
97
|
+
touch(): void;
|
|
98
|
+
/** Run the account's idle scan after a frame write. */
|
|
99
|
+
settle(): void;
|
|
100
|
+
/** Detach from the account. Idempotent. */
|
|
101
|
+
clear(): void;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=cache.d.ts.map
|
package/cache.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,QAAQ,EAAiC,MAAM,YAAY,CAAC;AAErE,8GAA8G;AAC9G,eAAO,MAAM,cAAc,UAA0B,CAAC;AActD,6CAA6C;AAC7C,MAAM,WAAW,MAAM;IACtB,uGAAuG;IACvG,MAAM,CAAC,EAAE,QAAQ,CAAC;CAClB;AAED,kFAAkF;AAClF,qBAAa,IAAI;;IAUhB,YAAY,MAAM,GAAE,MAAW,EAE9B;I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CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAErB;IAED,4CAA4C;IAC5C,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAWrB;IAED;;;OAGG;IACH,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAqBnC;IAaD,sIAAsI;IACtI,MAAM,IAAI,IAAI,CAEb;IAED,sDAAsD;IACtD,KAAK,IAAI,IAAI,CAMZ;CAWD;AAID;;;GAGG;AACH,qBAAa,MAAM;;IAIlB,OAAO,eAGN;IAMD,mCAAmC;IACnC,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,uEAAuE;IACvE,KAAK,IAAI,IAAI,CAGZ;IAED,uDAAuD;IACvD,MAAM,IAAI,IAAI,CAEb;IAED,2CAA2C;IAC3C,KAAK,IAAI,IAAI,CAEZ;CACD"}
|
package/cache.js
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The idle window of cached groups. Mirrors the idle expiry of the Rust `cache` module, without
|
|
3
|
+
* its byte budget: no JS caller sets a capacity, so nothing here evicts for bytes.
|
|
4
|
+
*
|
|
5
|
+
* Every track of a broadcast caches into one {@link Pool} through its own {@link Track} account,
|
|
6
|
+
* and every cached group records its last access through a {@link Charge}. A group nobody reads
|
|
7
|
+
* or writes for the pool's window is reclaimed, except a live track's latest. Writes scan for
|
|
8
|
+
* idle groups as they go, and the pool sweeps every track at half the window for the ones
|
|
9
|
+
* nothing writes to.
|
|
10
|
+
*
|
|
11
|
+
* Package-internal: not exported from the entrypoint.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import { Duration, now, sleepUntil } from "@moq/clock";
|
|
16
|
+
/** How long a group nobody reads or writes stays cached by default, matching Rust `cache::DEFAULT_EXPIRY`. */
|
|
17
|
+
export const DEFAULT_EXPIRY = Duration.millis(30_000);
|
|
18
|
+
// The coarse clock behind access stamps, as Rust's: the expiry window rounds up to it.
|
|
19
|
+
const TICK = Duration.millis(100);
|
|
20
|
+
// Ticks between the idle scans frame writes run, so a low-bitrate track still ages out.
|
|
21
|
+
const EXPIRY_SCAN_TICKS = 10;
|
|
22
|
+
// Entries one write-driven idle scan examines, few enough that a write never walks a long queue.
|
|
23
|
+
const EXPIRY_SCAN = 4;
|
|
24
|
+
// Dead entries the scan order tolerates beyond twice the live ones before it is rebuilt.
|
|
25
|
+
const ORDER_SLACK = 64;
|
|
26
|
+
/** The idle window shared by the cached groups of every track caching into it. */
|
|
27
|
+
export class Pool {
|
|
28
|
+
// The idle window in ticks.
|
|
29
|
+
#expiry;
|
|
30
|
+
// The first instant the pool read, and the latest tick since it, never moving back.
|
|
31
|
+
#epoch;
|
|
32
|
+
#tick = 0;
|
|
33
|
+
// The accounts holding something that may expire, which the idle sweep visits.
|
|
34
|
+
#tracks = new Set();
|
|
35
|
+
#sweep;
|
|
36
|
+
constructor(config = {}) {
|
|
37
|
+
if (config.expiry !== undefined)
|
|
38
|
+
this.#expiry = Math.max(1, Math.ceil(config.expiry.divDuration(TICK)));
|
|
39
|
+
}
|
|
40
|
+
/** Ticks since the pool first read the clock. */
|
|
41
|
+
now() {
|
|
42
|
+
const at = now();
|
|
43
|
+
this.#epoch ??= at;
|
|
44
|
+
this.#tick = Math.max(this.#tick, Math.floor(at.since(this.#epoch).divDuration(TICK)));
|
|
45
|
+
return this.#tick;
|
|
46
|
+
}
|
|
47
|
+
/** The idle window in ticks, or undefined when idle groups stay. */
|
|
48
|
+
get expiryTicks() {
|
|
49
|
+
return this.#expiry;
|
|
50
|
+
}
|
|
51
|
+
/** Visit `track` on each idle sweep, if the pool has an idle window, while it holds something that may expire. */
|
|
52
|
+
register(track) {
|
|
53
|
+
if (this.#expiry === undefined)
|
|
54
|
+
return;
|
|
55
|
+
this.#tracks.add(track);
|
|
56
|
+
this.#arm();
|
|
57
|
+
}
|
|
58
|
+
/** Stop visiting `track`, which holds nothing that may expire. */
|
|
59
|
+
unregister(track) {
|
|
60
|
+
this.#tracks.delete(track);
|
|
61
|
+
}
|
|
62
|
+
/** Expire the idle groups of every registered track. */
|
|
63
|
+
sweep() {
|
|
64
|
+
for (const track of [...this.#tracks])
|
|
65
|
+
track.sweep();
|
|
66
|
+
}
|
|
67
|
+
// Sweep again in half the idle window while any track holds something that may expire. Never a
|
|
68
|
+
// reason to hold a Node or Bun process open.
|
|
69
|
+
#arm() {
|
|
70
|
+
if (this.#sweep !== undefined || this.#expiry === undefined || this.#tracks.size === 0)
|
|
71
|
+
return;
|
|
72
|
+
const sweep = new AbortController();
|
|
73
|
+
this.#sweep = sweep;
|
|
74
|
+
const at = now().saturatingAdd(TICK.mul(this.#expiry / 2));
|
|
75
|
+
void sleepUntil(at, { signal: sweep.signal, ref: false }).then(() => {
|
|
76
|
+
if (this.#sweep !== sweep)
|
|
77
|
+
return;
|
|
78
|
+
this.#sweep = undefined;
|
|
79
|
+
this.sweep();
|
|
80
|
+
this.#arm();
|
|
81
|
+
}, () => { });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* One track's account against a {@link Pool}: its cached groups, in the order the idle scan
|
|
86
|
+
* visits them. Mirrors the expiry half of the Rust `cache::Track`.
|
|
87
|
+
*/
|
|
88
|
+
export class Track {
|
|
89
|
+
/** The pool this track caches into. */
|
|
90
|
+
pool;
|
|
91
|
+
#owner;
|
|
92
|
+
// The tick a frame write may next run an idle scan at.
|
|
93
|
+
#nextExpiry = 0;
|
|
94
|
+
// Every cached group with its slot in the scan order, oldest first. A group leaving the cache
|
|
95
|
+
// empties its slot, so the order never pins its frames; a compaction drops empty slots. The
|
|
96
|
+
// order starts at `#head`, since `Array.shift` moves every slot behind it in V8.
|
|
97
|
+
#live = new Map();
|
|
98
|
+
#order = [];
|
|
99
|
+
#head = 0;
|
|
100
|
+
// Where the next bounded idle scan starts, rotating so fresh groups at the front do not
|
|
101
|
+
// starve the ones behind them.
|
|
102
|
+
#cursor = 0;
|
|
103
|
+
constructor(pool, owner) {
|
|
104
|
+
this.pool = pool;
|
|
105
|
+
this.#owner = owner;
|
|
106
|
+
}
|
|
107
|
+
/** Open the access record of a new group, stamped now. */
|
|
108
|
+
charge() {
|
|
109
|
+
return makeCharge(this);
|
|
110
|
+
}
|
|
111
|
+
/** The drop set changed: keep the account in the idle sweep while it holds a run to forget. */
|
|
112
|
+
dropsChanged() {
|
|
113
|
+
if (this.#owner.holdsDrops())
|
|
114
|
+
this.pool.register(this);
|
|
115
|
+
}
|
|
116
|
+
/** Whether the account caches any group. */
|
|
117
|
+
get empty() {
|
|
118
|
+
return this.#live.size === 0;
|
|
119
|
+
}
|
|
120
|
+
/** Cache `entry` at the back of the scan order, expirable now unless it is the live edge. */
|
|
121
|
+
insert(entry) {
|
|
122
|
+
const slot = { entry };
|
|
123
|
+
this.#live.set(entry, slot);
|
|
124
|
+
this.#order.push(slot);
|
|
125
|
+
if (!this.#owner.protects(entry))
|
|
126
|
+
this.demote(entry);
|
|
127
|
+
}
|
|
128
|
+
/** Make `entry` expirable once the live edge no longer protects it. */
|
|
129
|
+
demote(entry) {
|
|
130
|
+
if (this.#live.has(entry))
|
|
131
|
+
this.pool.register(this);
|
|
132
|
+
}
|
|
133
|
+
/** Forget `entry`, which left the cache. */
|
|
134
|
+
remove(entry) {
|
|
135
|
+
const slot = this.#live.get(entry);
|
|
136
|
+
if (slot === undefined)
|
|
137
|
+
return;
|
|
138
|
+
this.#live.delete(entry);
|
|
139
|
+
slot.entry = undefined;
|
|
140
|
+
entry.charge.clear();
|
|
141
|
+
if (this.#live.size === 0) {
|
|
142
|
+
this.#order = [];
|
|
143
|
+
this.#head = 0;
|
|
144
|
+
if (!this.#owner.holdsDrops())
|
|
145
|
+
this.pool.unregister(this);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Evict the groups idle past the pool's window, never the live edge: every one when `full`,
|
|
150
|
+
* or else a bounded scan from a rotating cursor. Returns whether it evicted a group.
|
|
151
|
+
*/
|
|
152
|
+
evictExpired(full) {
|
|
153
|
+
const expiry = this.pool.expiryTicks;
|
|
154
|
+
const order = this.#order;
|
|
155
|
+
const head = this.#head;
|
|
156
|
+
const len = order.length - head;
|
|
157
|
+
if (expiry === undefined)
|
|
158
|
+
return false;
|
|
159
|
+
const now = this.pool.now();
|
|
160
|
+
const forgot = this.#owner.expireDrops(now);
|
|
161
|
+
if (len === 0)
|
|
162
|
+
return forgot;
|
|
163
|
+
const start = full ? 0 : this.#cursor % len;
|
|
164
|
+
const width = full ? len : Math.min(len, EXPIRY_SCAN);
|
|
165
|
+
if (!full)
|
|
166
|
+
this.#cursor = start + width;
|
|
167
|
+
const expired = [];
|
|
168
|
+
for (let step = 0; step < width; step++) {
|
|
169
|
+
const entry = order[head + ((start + step) % len)].entry;
|
|
170
|
+
if (entry === undefined || this.#owner.protects(entry))
|
|
171
|
+
continue;
|
|
172
|
+
if (now - entry.charge.accessed > expiry)
|
|
173
|
+
expired.push(entry);
|
|
174
|
+
}
|
|
175
|
+
for (const entry of expired)
|
|
176
|
+
this.#owner.evict(entry);
|
|
177
|
+
this.#compact();
|
|
178
|
+
return expired.length > 0 || forgot;
|
|
179
|
+
}
|
|
180
|
+
// Skip the empty slots at the front of the order, and rebuild it once the slots before the
|
|
181
|
+
// front and the empty ones behind it clearly outnumber the live ones.
|
|
182
|
+
#compact() {
|
|
183
|
+
const order = this.#order;
|
|
184
|
+
while (this.#head < order.length && order[this.#head].entry === undefined)
|
|
185
|
+
this.#head++;
|
|
186
|
+
if (order.length > 2 * this.#live.size + ORDER_SLACK) {
|
|
187
|
+
this.#order = order.slice(this.#head).filter((slot) => slot.entry !== undefined);
|
|
188
|
+
this.#head = 0;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/** Settle from a frame write: scan for idle groups once per second, so a track that only appends frames to open groups still ages. */
|
|
192
|
+
settle() {
|
|
193
|
+
if (this.#expiryDue() && this.evictExpired(false))
|
|
194
|
+
this.#owner.settle();
|
|
195
|
+
}
|
|
196
|
+
/** Expire every idle group, from the pool's sweep. */
|
|
197
|
+
sweep() {
|
|
198
|
+
if (this.evictExpired(true))
|
|
199
|
+
this.#owner.settle();
|
|
200
|
+
// A live edge alone never expires, so it needs no sweep to keep its track alive for.
|
|
201
|
+
if (this.#owner.holdsDrops())
|
|
202
|
+
return;
|
|
203
|
+
for (const entry of this.#live.keys())
|
|
204
|
+
if (!this.#owner.protects(entry))
|
|
205
|
+
return;
|
|
206
|
+
this.pool.unregister(this);
|
|
207
|
+
}
|
|
208
|
+
// Claim the next write-driven idle scan once its time comes.
|
|
209
|
+
#expiryDue() {
|
|
210
|
+
const expiry = this.pool.expiryTicks;
|
|
211
|
+
if (expiry === undefined)
|
|
212
|
+
return false;
|
|
213
|
+
const now = this.pool.now();
|
|
214
|
+
if (now < this.#nextExpiry)
|
|
215
|
+
return false;
|
|
216
|
+
this.#nextExpiry = now + Math.min(expiry, EXPIRY_SCAN_TICKS);
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
let makeCharge;
|
|
221
|
+
/**
|
|
222
|
+
* One cached group's last access, which its idle window runs from, and its route to its track's
|
|
223
|
+
* idle scan. Cleared once the group leaves the cache, after which every operation is a no-op.
|
|
224
|
+
*/
|
|
225
|
+
export class Charge {
|
|
226
|
+
#track;
|
|
227
|
+
#stamp;
|
|
228
|
+
constructor(track) {
|
|
229
|
+
this.#track = track;
|
|
230
|
+
this.#stamp = track.pool.now();
|
|
231
|
+
}
|
|
232
|
+
static {
|
|
233
|
+
makeCharge = (track) => new Charge(track);
|
|
234
|
+
}
|
|
235
|
+
/** The tick of the last access. */
|
|
236
|
+
get accessed() {
|
|
237
|
+
return this.#stamp;
|
|
238
|
+
}
|
|
239
|
+
/** Record an access, a read or a write, restarting the idle window. */
|
|
240
|
+
touch() {
|
|
241
|
+
const track = this.#track;
|
|
242
|
+
if (track)
|
|
243
|
+
this.#stamp = Math.max(this.#stamp, track.pool.now());
|
|
244
|
+
}
|
|
245
|
+
/** Run the account's idle scan after a frame write. */
|
|
246
|
+
settle() {
|
|
247
|
+
this.#track?.settle();
|
|
248
|
+
}
|
|
249
|
+
/** Detach from the account. Idempotent. */
|
|
250
|
+
clear() {
|
|
251
|
+
this.#track = undefined;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=cache.js.map
|
package/cache.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,QAAQ,EAAgB,GAAG,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAErE,8GAA8G;AAC9G,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAEtD,uFAAuF;AACvF,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAElC,wFAAwF;AACxF,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,iGAAiG;AACjG,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,yFAAyF;AACzF,MAAM,WAAW,GAAG,EAAE,CAAC;AAQvB,kFAAkF;AAClF,MAAM,OAAO,IAAI;IAChB,4BAA4B;IACnB,OAAO,CAAU;IAC1B,oFAAoF;IACpF,MAAM,CAAW;IACjB,KAAK,GAAG,CAAC,CAAC;IACV,+EAA+E;IAC/E,OAAO,GAAG,IAAI,GAAG,EAAgB,CAAC;IAClC,MAAM,CAAmB;IAEzB,YAAY,MAAM,GAAW,EAAE;QAC9B,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;YAAE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACzG,CAAC;IAED,iD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C;IACvB,CAAC;IAED,2CAA2C;IAC3C,KAAK;QACJ,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IACzB,CAAC;CACD","sourcesContent":["/**\n * The idle window of cached groups. Mirrors the idle expiry of the Rust `cache` module, without\n * its byte budget: no JS caller sets a capacity, so nothing here evicts for bytes.\n *\n * Every track of a broadcast caches into one {@link Pool} through its own {@link Track} account,\n * and every cached group records its last access through a {@link Charge}. A group nobody reads\n * or writes for the pool's window is reclaimed, except a live track's latest. Writes scan for\n * idle groups as they go, and the pool sweeps every track at half the window for the ones\n * nothing writes to.\n *\n * Package-internal: not exported from the entrypoint.\n *\n * @module\n */\nimport { Duration, type Instant, now, sleepUntil } from \"@moq/clock\";\n\n/** How long a group nobody reads or writes stays cached by default, matching Rust `cache::DEFAULT_EXPIRY`. */\nexport const DEFAULT_EXPIRY = Duration.millis(30_000);\n\n// The coarse clock behind access stamps, as Rust's: the expiry window rounds up to it.\nconst TICK = Duration.millis(100);\n\n// Ticks between the idle scans frame writes run, so a low-bitrate track still ages out.\nconst EXPIRY_SCAN_TICKS = 10;\n\n// Entries one write-driven idle scan examines, few enough that a write never walks a long queue.\nconst EXPIRY_SCAN = 4;\n\n// Dead entries the scan order tolerates beyond twice the live ones before it is rebuilt.\nconst ORDER_SLACK = 64;\n\n/** The initial policy for a {@link Pool}. */\nexport interface Config {\n\t/** How long a group nobody reads or writes stays cached; never reclaimed for idleness when omitted. */\n\texpiry?: Duration;\n}\n\n/** The idle window shared by the cached groups of every track caching into it. */\nexport class Pool {\n\t// The idle window in ticks.\n\treadonly #expiry?: number;\n\t// The first instant the pool read, and the latest tick since it, never moving back.\n\t#epoch?: Instant;\n\t#tick = 0;\n\t// The accounts holding something that may expire, which the idle sweep visits.\n\t#tracks = new Set<Track<Entry>>();\n\t#sweep?: AbortController;\n\n\tconstructor(config: Config = {}) {\n\t\tif (config.expiry !== undefined) this.#expiry = Math.max(1, Math.ceil(config.expiry.divDuration(TICK)));\n\t}\n\n\t/** Ticks since the pool first read the clock. */\n\tnow(): number {\n\t\tconst at = now();\n\t\tthis.#epoch ??= at;\n\t\tthis.#tick = Math.max(this.#tick, Math.floor(at.since(this.#epoch).divDuration(TICK)));\n\t\treturn this.#tick;\n\t}\n\n\t/** The idle window in ticks, or undefined when idle groups stay. */\n\tget expiryTicks(): number | undefined {\n\t\treturn this.#expiry;\n\t}\n\n\t/** Visit `track` on each idle sweep, if the pool has an idle window, while it holds something that may expire. */\n\tregister(track: Track<Entry>): void {\n\t\tif (this.#expiry === undefined) return;\n\t\tthis.#tracks.add(track);\n\t\tthis.#arm();\n\t}\n\n\t/** Stop visiting `track`, which holds nothing that may expire. */\n\tunregister(track: Track<Entry>): void {\n\t\tthis.#tracks.delete(track);\n\t}\n\n\t/** Expire the idle groups of every registered track. */\n\tsweep(): void {\n\t\tfor (const track of [...this.#tracks]) track.sweep();\n\t}\n\n\t// Sweep again in half the idle window while any track holds something that may expire. Never a\n\t// reason to hold a Node or Bun process open.\n\t#arm(): void {\n\t\tif (this.#sweep !== undefined || this.#expiry === undefined || this.#tracks.size === 0) return;\n\t\tconst sweep = new AbortController();\n\t\tthis.#sweep = sweep;\n\t\tconst at = now().saturatingAdd(TICK.mul(this.#expiry / 2));\n\t\tvoid sleepUntil(at, { signal: sweep.signal, ref: false }).then(\n\t\t\t() => {\n\t\t\t\tif (this.#sweep !== sweep) return;\n\t\t\t\tthis.#sweep = undefined;\n\t\t\t\tthis.sweep();\n\t\t\t\tthis.#arm();\n\t\t\t},\n\t\t\t() => {},\n\t\t);\n\t}\n}\n\n/** A cached group as its track's account knows it. */\nexport interface Entry {\n\t/** Its last access. */\n\treadonly charge: Charge;\n}\n\n// A group's place in an account's scan order, emptied once the group leaves the cache.\ninterface Slot<E> {\n\tentry: E | undefined;\n}\n\n/** How an account reaches the track whose groups it expires. */\nexport interface Owner<E extends Entry> {\n\t/** Whether `entry` is the live edge, which expiry never takes. */\n\tprotects(entry: E): boolean;\n\t/** Take `entry` out of the cache and end it for idling. */\n\tevict(entry: E): void;\n\t/** Something was evicted: settle what the cache's contents decide. */\n\tsettle(): void;\n\t/** Forget the runs of the drop set given up longer than the pool's idle window before tick `now`, returning whether any went. */\n\texpireDrops(now: number): boolean;\n\t/** Whether the track holds a drop run a reclaim may forget, which keeps its account in the idle sweep. */\n\tholdsDrops(): boolean;\n}\n\n/**\n * One track's account against a {@link Pool}: its cached groups, in the order the idle scan\n * visits them. Mirrors the expiry half of the Rust `cache::Track`.\n */\nexport class Track<E extends Entry> {\n\t/** The pool this track caches into. */\n\treadonly pool: Pool;\n\t#owner: Owner<E>;\n\t// The tick a frame write may next run an idle scan at.\n\t#nextExpiry = 0;\n\t// Every cached group with its slot in the scan order, oldest first. A group leaving the cache\n\t// empties its slot, so the order never pins its frames; a compaction drops empty slots. The\n\t// order starts at `#head`, since `Array.shift` moves every slot behind it in V8.\n\t#live = new Map<E, Slot<E>>();\n\t#order: Slot<E>[] = [];\n\t#head = 0;\n\t// Where the next bounded idle scan starts, rotating so fresh groups at the front do not\n\t// starve the ones behind them.\n\t#cursor = 0;\n\n\tconstructor(pool: Pool, owner: Owner<E>) {\n\t\tthis.pool = pool;\n\t\tthis.#owner = owner;\n\t}\n\n\t/** Open the access record of a new group, stamped now. */\n\tcharge(): Charge {\n\t\treturn makeCharge(this as Track<Entry>);\n\t}\n\n\t/** The drop set changed: keep the account in the idle sweep while it holds a run to forget. */\n\tdropsChanged(): void {\n\t\tif (this.#owner.holdsDrops()) this.pool.register(this as Track<Entry>);\n\t}\n\n\t/** Whether the account caches any group. */\n\tget empty(): boolean {\n\t\treturn this.#live.size === 0;\n\t}\n\n\t/** Cache `entry` at the back of the scan order, expirable now unless it is the live edge. */\n\tinsert(entry: E): void {\n\t\tconst slot = { entry };\n\t\tthis.#live.set(entry, slot);\n\t\tthis.#order.push(slot);\n\t\tif (!this.#owner.protects(entry)) this.demote(entry);\n\t}\n\n\t/** Make `entry` expirable once the live edge no longer protects it. */\n\tdemote(entry: E): void {\n\t\tif (this.#live.has(entry)) this.pool.register(this as Track<Entry>);\n\t}\n\n\t/** Forget `entry`, which left the cache. */\n\tremove(entry: E): void {\n\t\tconst slot = this.#live.get(entry);\n\t\tif (slot === undefined) return;\n\t\tthis.#live.delete(entry);\n\t\tslot.entry = undefined;\n\t\tentry.charge.clear();\n\t\tif (this.#live.size === 0) {\n\t\t\tthis.#order = [];\n\t\t\tthis.#head = 0;\n\t\t\tif (!this.#owner.holdsDrops()) this.pool.unregister(this as Track<Entry>);\n\t\t}\n\t}\n\n\t/**\n\t * Evict the groups idle past the pool's window, never the live edge: every one when `full`,\n\t * or else a bounded scan from a rotating cursor. Returns whether it evicted a group.\n\t */\n\tevictExpired(full: boolean): boolean {\n\t\tconst expiry = this.pool.expiryTicks;\n\t\tconst order = this.#order;\n\t\tconst head = this.#head;\n\t\tconst len = order.length - head;\n\t\tif (expiry === undefined) return false;\n\t\tconst now = this.pool.now();\n\t\tconst forgot = this.#owner.expireDrops(now);\n\t\tif (len === 0) return forgot;\n\t\tconst start = full ? 0 : this.#cursor % len;\n\t\tconst width = full ? len : Math.min(len, EXPIRY_SCAN);\n\t\tif (!full) this.#cursor = start + width;\n\t\tconst expired: E[] = [];\n\t\tfor (let step = 0; step < width; step++) {\n\t\t\tconst entry = order[head + ((start + step) % len)].entry;\n\t\t\tif (entry === undefined || this.#owner.protects(entry)) continue;\n\t\t\tif (now - entry.charge.accessed > expiry) expired.push(entry);\n\t\t}\n\t\tfor (const entry of expired) this.#owner.evict(entry);\n\t\tthis.#compact();\n\t\treturn expired.length > 0 || forgot;\n\t}\n\n\t// Skip the empty slots at the front of the order, and rebuild it once the slots before the\n\t// front and the empty ones behind it clearly outnumber the live ones.\n\t#compact(): void {\n\t\tconst order = this.#order;\n\t\twhile (this.#head < order.length && order[this.#head].entry === undefined) this.#head++;\n\t\tif (order.length > 2 * this.#live.size + ORDER_SLACK) {\n\t\t\tthis.#order = order.slice(this.#head).filter((slot) => slot.entry !== undefined);\n\t\t\tthis.#head = 0;\n\t\t}\n\t}\n\n\t/** Settle from a frame write: scan for idle groups once per second, so a track that only appends frames to open groups still ages. */\n\tsettle(): void {\n\t\tif (this.#expiryDue() && this.evictExpired(false)) this.#owner.settle();\n\t}\n\n\t/** Expire every idle group, from the pool's sweep. */\n\tsweep(): void {\n\t\tif (this.evictExpired(true)) this.#owner.settle();\n\t\t// A live edge alone never expires, so it needs no sweep to keep its track alive for.\n\t\tif (this.#owner.holdsDrops()) return;\n\t\tfor (const entry of this.#live.keys()) if (!this.#owner.protects(entry)) return;\n\t\tthis.pool.unregister(this as Track<Entry>);\n\t}\n\n\t// Claim the next write-driven idle scan once its time comes.\n\t#expiryDue(): boolean {\n\t\tconst expiry = this.pool.expiryTicks;\n\t\tif (expiry === undefined) return false;\n\t\tconst now = this.pool.now();\n\t\tif (now < this.#nextExpiry) return false;\n\t\tthis.#nextExpiry = now + Math.min(expiry, EXPIRY_SCAN_TICKS);\n\t\treturn true;\n\t}\n}\n\nlet makeCharge: (track: Track<Entry>) => Charge;\n\n/**\n * One cached group's last access, which its idle window runs from, and its route to its track's\n * idle scan. Cleared once the group leaves the cache, after which every operation is a no-op.\n */\nexport class Charge {\n\t#track?: Track<Entry>;\n\t#stamp: number;\n\n\tprivate constructor(track: Track<Entry>) {\n\t\tthis.#track = track;\n\t\tthis.#stamp = track.pool.now();\n\t}\n\n\tstatic {\n\t\tmakeCharge = (track) => new Charge(track);\n\t}\n\n\t/** The tick of the last access. */\n\tget accessed(): number {\n\t\treturn this.#stamp;\n\t}\n\n\t/** Record an access, a read or a write, restarting the idle window. */\n\ttouch(): void {\n\t\tconst track = this.#track;\n\t\tif (track) this.#stamp = Math.max(this.#stamp, track.pool.now());\n\t}\n\n\t/** Run the account's idle scan after a frame write. */\n\tsettle(): void {\n\t\tthis.#track?.settle();\n\t}\n\n\t/** Detach from the account. Idempotent. */\n\tclear(): void {\n\t\tthis.#track = undefined;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Claim } from "./origin.ts";
|
|
2
|
+
import type * as Path from "./path.ts";
|
|
3
|
+
/** The claim among `claims` asked first, checking that it was asked for `path`, not merely closed. */
|
|
4
|
+
export declare function askedFirst<T extends Claim>(path: Path.Valid, claims: readonly T[]): Promise<T>;
|
|
5
|
+
//# sourceMappingURL=claim.test-util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim.test-util.d.ts","sourceRoot":"","sources":["../src/claim.test-util.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AAEvC,sGAAsG;AACtG,wBAAsB,UAAU,CAAC,CAAC,SAAS,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAYpG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { expect } from "bun:test";
|
|
2
|
+
/** The claim among `claims` asked first, checking that it was asked for `path`, not merely closed. */
|
|
3
|
+
export async function askedFirst(path, claims) {
|
|
4
|
+
const [claim, next] = await Promise.race(claims.map((claim) => claim
|
|
5
|
+
.requested()
|
|
6
|
+
.next()
|
|
7
|
+
.then((next) => [claim, next])));
|
|
8
|
+
if (next.done)
|
|
9
|
+
throw new Error("the claim closed without a request");
|
|
10
|
+
expect(next.value.path).toBe(path);
|
|
11
|
+
return claim;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=claim.test-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim.test-util.js","sourceRoot":"","sources":["../src/claim.test-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC,sGAAsG;AACtG,MAAM,CAAC,KAAK,UAAU,UAAU,CAAkB,IAAgB,EAAE,MAAoB;IACvF,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,MAAM,OAAO,CAAC,IAAI,CACvC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACpB,KAAK;SACH,SAAS,EAAE;SACX,IAAI,EAAE;SACN,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,CAAU,CAAC,CACxC,CACD,CAAC;IACF,IAAI,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACrE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import { expect } from \"bun:test\";\nimport type { Claim } from \"./origin.ts\";\nimport type * as Path from \"./path.ts\";\n\n/** The claim among `claims` asked first, checking that it was asked for `path`, not merely closed. */\nexport async function askedFirst<T extends Claim>(path: Path.Valid, claims: readonly T[]): Promise<T> {\n\tconst [claim, next] = await Promise.race(\n\t\tclaims.map((claim) =>\n\t\t\tclaim\n\t\t\t\t.requested()\n\t\t\t\t.next()\n\t\t\t\t.then((next) => [claim, next] as const),\n\t\t),\n\t);\n\tif (next.done) throw new Error(\"the claim closed without a request\");\n\texpect(next.value.path).toBe(path);\n\treturn claim;\n}\n"]}
|