@moq/net 0.4.7 → 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 -2
- package/announce.js.map +1 -1
- package/announced.d.ts +51 -47
- package/announced.d.ts.map +1 -1
- package/announced.js +183 -32
- 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 -139
- 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 -2
- package/bandwidth_api.js.map +1 -1
- package/broadcast.d.ts +64 -38
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +556 -173
- 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 +21 -13
- package/connection/accept.d.ts.map +1 -1
- package/connection/accept.js +97 -130
- package/connection/accept.js.map +1 -1
- package/connection/browser.d.ts.map +1 -1
- package/connection/browser.js +28 -20
- package/connection/browser.js.map +1 -1
- package/connection/connect.d.ts +120 -24
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +535 -217
- 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 -81
- 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 -95
- package/connection/goaway.js.map +1 -1
- package/connection/handshake.d.ts +34 -8
- package/connection/handshake.d.ts.map +1 -1
- package/connection/handshake.js +97 -21
- package/connection/handshake.js.map +1 -1
- package/connection/index.d.ts +4 -7
- package/connection/index.d.ts.map +1 -1
- package/connection/index.js +1 -3
- 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 +142 -63
- package/connection/pool.d.ts.map +1 -1
- package/connection/pool.js +281 -118
- 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 -234
- 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 -9
- 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 -5
- 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 -47
- 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 -2
- 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 -38
- package/error.js.map +1 -1
- package/errors.d.ts +2 -2
- package/errors.d.ts.map +1 -1
- package/errors.js +2 -3
- 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 -308
- 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 -65
- 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 -36
- package/ietf/aliases.js.map +1 -1
- package/ietf/cluster.d.ts +3 -3
- package/ietf/cluster.js +14 -55
- 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 -144
- 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 -101
- package/ietf/error.js.map +1 -1
- package/ietf/fetch.d.ts +93 -37
- package/ietf/fetch.d.ts.map +1 -1
- package/ietf/fetch.js +172 -94
- package/ietf/fetch.js.map +1 -1
- package/ietf/filter.d.ts +21 -31
- package/ietf/filter.d.ts.map +1 -1
- package/ietf/filter.js +140 -172
- package/ietf/filter.js.map +1 -1
- package/ietf/goaway.d.ts +12 -10
- package/ietf/goaway.d.ts.map +1 -1
- package/ietf/goaway.js +22 -36
- package/ietf/goaway.js.map +1 -1
- package/ietf/hidden.js +1 -2
- package/ietf/hidden.js.map +1 -1
- package/ietf/index.d.ts +8 -20
- package/ietf/index.d.ts.map +1 -1
- package/ietf/index.js +4 -15
- 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 -41
- 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 +19 -5
- package/ietf/namespace.d.ts.map +1 -1
- package/ietf/namespace.js +78 -27
- package/ietf/namespace.js.map +1 -1
- package/ietf/object.d.ts +195 -33
- package/ietf/object.d.ts.map +1 -1
- package/ietf/object.js +405 -179
- package/ietf/object.js.map +1 -1
- package/ietf/parameters.d.ts +25 -45
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +260 -473
- 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 -5
- package/ietf/priority.js.map +1 -1
- package/ietf/properties.d.ts +6 -5
- package/ietf/properties.d.ts.map +1 -1
- package/ietf/properties.js +78 -49
- package/ietf/properties.js.map +1 -1
- package/ietf/publish.d.ts +25 -33
- package/ietf/publish.d.ts.map +1 -1
- package/ietf/publish.js +45 -140
- package/ietf/publish.js.map +1 -1
- package/ietf/publish_namespace.d.ts +49 -72
- package/ietf/publish_namespace.d.ts.map +1 -1
- package/ietf/publish_namespace.js +66 -185
- package/ietf/publish_namespace.js.map +1 -1
- package/ietf/publisher.js +1800 -601
- 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 +6 -30
- package/ietf/request.d.ts.map +1 -1
- package/ietf/request.js +41 -79
- 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 -17
- 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 +5 -30
- package/ietf/setup.d.ts.map +1 -1
- package/ietf/setup.js +6 -118
- 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 -15
- package/ietf/solicit.js.map +1 -1
- package/ietf/subscribe.d.ts +52 -45
- package/ietf/subscribe.d.ts.map +1 -1
- package/ietf/subscribe.js +118 -240
- package/ietf/subscribe.js.map +1 -1
- package/ietf/subscribe_namespace.d.ts +16 -79
- package/ietf/subscribe_namespace.d.ts.map +1 -1
- package/ietf/subscribe_namespace.js +30 -202
- package/ietf/subscribe_namespace.js.map +1 -1
- package/ietf/subscriber.js +1839 -537
- package/ietf/subscriber.js.map +1 -1
- package/ietf/token.js +105 -28
- package/ietf/token.js.map +1 -1
- package/ietf/track.d.ts +27 -24
- package/ietf/track.d.ts.map +1 -1
- package/ietf/track.js +48 -62
- 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 -49
- 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 +34 -19
- package/index.d.ts.map +1 -1
- package/index.js +19 -7
- package/index.js.map +1 -1
- package/internal.d.ts +1515 -67
- package/internal.d.ts.map +1 -1
- package/internal.js +557 -80
- 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 +127 -66
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +384 -159
- 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 -78
- 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 -10
- 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 +2 -2
- package/lite/goaway.d.ts.map +1 -1
- package/lite/goaway.js +5 -14
- package/lite/goaway.js.map +1 -1
- package/lite/group.d.ts +67 -16
- package/lite/group.d.ts.map +1 -1
- package/lite/group.js +108 -31
- 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 +14 -13
- package/lite/index.d.ts.map +1 -1
- package/lite/index.js +2 -2
- package/lite/index.js.map +1 -1
- package/lite/message.d.ts +10 -2
- package/lite/message.d.ts.map +1 -1
- package/lite/message.js +28 -45
- 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 -106
- package/lite/priority.js.map +1 -1
- package/lite/probe.d.ts +2 -2
- package/lite/probe.d.ts.map +1 -1
- package/lite/probe.js +9 -1
- 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 -438
- 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 +2 -28
- package/lite/session.d.ts.map +1 -1
- package/lite/session.js +0 -100
- package/lite/session.js.map +1 -1
- package/lite/setup.d.ts +32 -5
- package/lite/setup.d.ts.map +1 -1
- package/lite/setup.js +95 -22
- 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 -2
- package/lite/stream.js.map +1 -1
- package/lite/subscribe.d.ts +478 -78
- package/lite/subscribe.d.ts.map +1 -1
- package/lite/subscribe.js +1373 -143
- 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 -516
- package/lite/subscriber.js.map +1 -1
- package/lite/track.d.ts +27 -12
- package/lite/track.d.ts.map +1 -1
- package/lite/track.js +116 -38
- 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 -34
- 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 +394 -142
- package/origin.d.ts.map +1 -1
- package/origin.js +2533 -687
- 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 -58
- 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 +78 -40
- package/stream.d.ts.map +1 -1
- package/stream.js +236 -93
- 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 -98
- package/tail.js.map +1 -1
- package/time.d.ts +41 -102
- package/time.d.ts.map +1 -1
- package/time.js +129 -92
- 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 +578 -246
- package/track.d.ts.map +1 -1
- package/track.js +7306 -772
- 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 -2
- 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 -5
- 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 -10
- 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/u64.js +0 -1
- package/util/utf8.d.ts +2 -0
- package/util/utf8.d.ts.map +1 -1
- package/util/utf8.js +7 -2
- package/util/utf8.js.map +1 -1
- package/util/varint.d.ts.map +1 -1
- package/util/varint.js +8 -2
- 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 -29
- 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 +150 -35
- package/wire.d.ts.map +1 -1
- package/wire.js +27 -1
- 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 -3
- 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 -700
- 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 -44
- 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 -79
- 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 -17
- package/util/log.js.map +0 -1
- package/zod.d.ts +0 -13
- package/zod.d.ts.map +0 -1
- package/zod.js +0 -19
- package/zod.js.map +0 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ A TypeScript [Media over QUIC](https://moq.dev/) (MoQ) client for both browsers
|
|
|
12
12
|
|
|
13
13
|
Check out [hang](../hang) for a higher-level media library that uses this package.
|
|
14
14
|
|
|
15
|
-
> **Note:** moq-lite is a subset of moq-transport and is forwards compatible with it, so this client works with any moq-transport CDN (ex. [Cloudflare](https://moq.dev/blog/first-cdn/)). See the [compatibility docs](https://doc.moq.dev/concept/moq-lite#
|
|
15
|
+
> **Note:** moq-lite is a subset of moq-transport and is forwards compatible with it, so this client works with any moq-transport CDN (ex. [Cloudflare](https://moq.dev/blog/first-cdn/)). See the [compatibility docs](https://doc.moq.dev/concept/moq-lite#what-moq-lite-leaves-out) for details.
|
|
16
16
|
|
|
17
17
|
## Quick Start
|
|
18
18
|
|
|
@@ -63,6 +63,12 @@ await quicheLoaded; //This is a promise, connect after it resolves
|
|
|
63
63
|
- **[Waiting](examples/wait.ts)** - Wait for one known broadcast to come online, and follow it
|
|
64
64
|
- **[Server side usage](https://github.com/sb2702/webcodecs-examples/tree/main/src/moq-server)** - Publish from browser to a server
|
|
65
65
|
|
|
66
|
+
## Integer precision
|
|
67
|
+
|
|
68
|
+
Group identities and relative group counts use `bigint`. Frame indices, timestamps,
|
|
69
|
+
and durations use bounded numbers and refuse unsafe wire values. See
|
|
70
|
+
[wire integer precision](INTEGERS.md) for the field-by-field limits.
|
|
71
|
+
|
|
66
72
|
## License
|
|
67
73
|
|
|
68
74
|
Licensed under either:
|
package/announce.d.ts
CHANGED
package/announce.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"announce.d.ts","sourceRoot":"","sources":["../src/announce.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"announce.d.ts","sourceRoot":"","sources":["../src/announce.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,QAAQ,EAAE,QAAQ,EAAE,KAAK,KAAK,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC"}
|
package/announce.js
CHANGED
package/announce.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"announce.js","sourceRoot":"","sources":["../src/announce.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"announce.js","sourceRoot":"","sources":["../src/announce.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAiB,QAAQ,EAA4B,MAAM,gBAAgB,CAAC","sourcesContent":["/**\n * Broadcast announcement streams.\n *\n * @module\n */\nexport { type Announce, Consumer, type Event, type Options } from \"./announced.ts\";\n"]}
|
package/announced.d.ts
CHANGED
|
@@ -3,38 +3,43 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import { type GetPromise } from "@moq/signals";
|
|
7
|
-
import type
|
|
6
|
+
import { type GetPromise, type Getter } from "@moq/signals";
|
|
7
|
+
import { type RouteInfo } from "./hop.ts";
|
|
8
8
|
import type * as Path from "./path.js";
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
export type Kind = "announced" | "updated" | "retracted";
|
|
15
|
-
/**
|
|
16
|
-
* A route announcement, update, or retraction.
|
|
10
|
+
* A route over a prefix, delivered inside an {@link Event}.
|
|
17
11
|
*
|
|
18
12
|
* An announcement is always a prefix, never a broadcast: a route claims that
|
|
19
13
|
* {@link prefix} and every path beneath it can be served. By convention a publisher
|
|
20
14
|
* announces each broadcast's exact path, so enumerating routes enumerates broadcasts;
|
|
21
|
-
* resolve one with the origin's `request(path)`.
|
|
22
|
-
* locally to follow a subset.
|
|
15
|
+
* resolve one with the origin's `request(path)`. List a narrower prefix, or filter the
|
|
16
|
+
* announced paths locally, to follow a subset.
|
|
23
17
|
*
|
|
24
18
|
* @public
|
|
25
19
|
*/
|
|
26
|
-
export interface
|
|
20
|
+
export interface Announce {
|
|
27
21
|
/**
|
|
28
22
|
* The prefix the route covers, relative to the origin (for a session, its URL path).
|
|
29
23
|
*/
|
|
30
24
|
prefix: Path.Valid;
|
|
31
|
-
/** What the filter's wildcards stood for, when this prefix pins all of them. */
|
|
32
|
-
captures: Path.Pattern[] | undefined;
|
|
33
|
-
/** Whether the prefix was announced, re-priced, or retracted. */
|
|
34
|
-
kind: Kind;
|
|
35
25
|
/** Hops and cost of the route; on a retraction, its last advertised values. */
|
|
36
|
-
route:
|
|
26
|
+
route: RouteInfo;
|
|
37
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* What an announcement listing yields: a path becoming present or absent.
|
|
30
|
+
*
|
|
31
|
+
* `present`: a route now covers the path, which was absent; it may arrive unavailable (see
|
|
32
|
+
* {@link RouteInfo.available}). `absent`: no route covers the path any more, whether its origin
|
|
33
|
+
* withdrew it or this side let go of it; carries its last advertised route.
|
|
34
|
+
*
|
|
35
|
+
* Another identity taking a path over keeps it present, and a change in availability is not
|
|
36
|
+
* reported: follow it with the origin's `follow(path)` to see the broadcast change.
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export type Event = {
|
|
41
|
+
kind: "present" | "absent";
|
|
42
|
+
} & Announce;
|
|
38
43
|
/**
|
|
39
44
|
* Options for an announcement stream.
|
|
40
45
|
*
|
|
@@ -43,51 +48,50 @@ export interface Update {
|
|
|
43
48
|
export interface Options {
|
|
44
49
|
/**
|
|
45
50
|
* Also report hidden routes: those with a path segment starting with `.` below the
|
|
46
|
-
*
|
|
51
|
+
* listed prefix. Hidden routes are left out by default, so a platform can add
|
|
47
52
|
* `.`-named broadcasts (stats, internal routes) without them turning up in apps that
|
|
48
53
|
* list everything. Subscribing to a hidden path by name works either way.
|
|
49
54
|
*/
|
|
50
55
|
hidden?: boolean;
|
|
51
|
-
}
|
|
52
|
-
/** Whether a route covers the path after an update of this {@link Kind}. */
|
|
53
|
-
export declare function isActive(kind: Kind): boolean;
|
|
54
|
-
/**
|
|
55
|
-
* The write side of an announcement stream.
|
|
56
|
-
*
|
|
57
|
-
* @public
|
|
58
|
-
*/
|
|
59
|
-
export declare class Producer {
|
|
60
|
-
#private;
|
|
61
56
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
57
|
+
* Also report every route that could serve a path in scope, not just those at or beneath
|
|
58
|
+
* the listed prefix. A route is a prefix serving everything beneath it, so listing
|
|
59
|
+
* `room/lobby` still reports a route at `room`, which can serve it. A broadcast serves only
|
|
60
|
+
* its own path, yet is reported too, since it shadows broader routes beneath it, as in Rust. Code that routes or forwards needs these;
|
|
61
|
+
* listing broadcasts does not. Requests resolve through covering routes either way.
|
|
64
62
|
*/
|
|
65
|
-
|
|
66
|
-
/** A read handle for this announcement stream. */
|
|
67
|
-
consume(): Consumer;
|
|
68
|
-
/** Writes an announcement to the queue. */
|
|
69
|
-
append(update: Update): void;
|
|
70
|
-
/** Closes the writer. Idempotent. */
|
|
71
|
-
close(abort?: Error): void;
|
|
63
|
+
covering?: boolean;
|
|
72
64
|
}
|
|
73
65
|
/**
|
|
74
|
-
* The
|
|
66
|
+
* The paths announced under a scope, each reported as it becomes present or absent.
|
|
75
67
|
*
|
|
76
|
-
* Created internally: obtain one from
|
|
77
|
-
* `announced(scope)`.
|
|
68
|
+
* Created internally: obtain one from an origin or the connection's `announced(scope)`.
|
|
78
69
|
*
|
|
79
70
|
* @public
|
|
80
71
|
*/
|
|
81
72
|
export declare class Consumer {
|
|
82
73
|
#private;
|
|
83
74
|
private constructor();
|
|
84
|
-
/** Settles once the stream closes
|
|
75
|
+
/** Settles once the stream closes: `null` on a clean close, or the abort {@link Error}. */
|
|
85
76
|
get closed(): GetPromise<Error | null>;
|
|
86
|
-
/**
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Whether the listing has delivered its source's initial announcements and the reader has
|
|
79
|
+
* taken them, so a path not present by now is absent rather than not yet heard of.
|
|
80
|
+
*
|
|
81
|
+
* Flips once the reader asks for the event after the last of them, and is true once
|
|
82
|
+
* closed. Through a session, the initial set is the peer's view when it answered: exact
|
|
83
|
+
* on versions that count it, best-effort on the rest. Reading an origin, it is every
|
|
84
|
+
* attached session's initial set, so a reconnect takes it back until the new one lands.
|
|
85
|
+
*/
|
|
86
|
+
get synced(): Getter<boolean>;
|
|
87
|
+
/** The events as they arrive, until the listing closes. */
|
|
88
|
+
[Symbol.asyncIterator](): AsyncGenerator<Event, void, undefined>;
|
|
89
|
+
/** Returns the next change to a path, or undefined once the listing or this handle closes. */
|
|
90
|
+
next(): Promise<Event | undefined>;
|
|
91
|
+
/**
|
|
92
|
+
* Release this handle, like dropping a Rust handle: the source sees the listing as no
|
|
93
|
+
* longer wanted. Idempotent.
|
|
94
|
+
*/
|
|
95
|
+
close(): void;
|
|
92
96
|
}
|
|
93
97
|
//# sourceMappingURL=announced.d.ts.map
|
package/announced.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"announced.d.ts","sourceRoot":"","sources":["../src/announced.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,UAAU,EAAgB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"announced.d.ts","sourceRoot":"","sources":["../src/announced.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,MAAM,EAAgB,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,KAAK,SAAS,EAA6B,MAAM,UAAU,CAAC;AACrE,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AAEvC;;;;;;;;;;GAUG;AACH,MAAM,WAAW,QAAQ;IACxB;;OAEG;IACH,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC;IACnB,+EAA+E;IAC/E,KAAK,EAAE,SAAS,CAAC;CACjB;AASD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,KAAK,GAAG;IAAE,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAA;CAAE,GAAG,QAAQ,CAAC;AAc9D;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACvB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CAWnB;AA+MD;;;;;;GAMG;AACH,qBAAa,QAAQ;;IAGpB,OAAO,eAEN;IAMD,2FAA2F;IAE3F,IAAI,MAAM,IAAI,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,CAErC;IAED;;;;;;;;OAQG;IACH,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,CAAC,CAE5B;IAED,2DAA2D;IACpD,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,CAMtE;IAED,8FAA8F;IACxF,IAAI,IAAI,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CASvC;IAED;;;OAGG;IACH,KAAK,SAEJ;CACD"}
|
package/announced.js
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
|
-
/* @ts-self-types="./announced.d.ts" */
|
|
2
1
|
/**
|
|
3
2
|
* Broadcast announcement streams: which broadcast paths are available under a scope.
|
|
4
3
|
*
|
|
5
4
|
* @module
|
|
6
5
|
*/
|
|
7
6
|
import { Once, Signal } from "@moq/signals";
|
|
8
|
-
|
|
9
|
-
export function isActive(kind) {
|
|
10
|
-
return kind !== "retracted";
|
|
11
|
-
}
|
|
7
|
+
import { routeInfo } from "./hop.js";
|
|
12
8
|
/** Reactive backing state shared by announcement producers and consumers. */
|
|
13
9
|
class AnnounceState {
|
|
14
10
|
queue = new Signal([]);
|
|
15
11
|
closed = new Once();
|
|
12
|
+
synced = new Signal(false);
|
|
13
|
+
// The queued events still to read before the stream counts as synced, or undefined
|
|
14
|
+
// while the initial set is still arriving.
|
|
15
|
+
owed;
|
|
16
|
+
// A reader holds the last event it took before syncing until it asks for the next
|
|
17
|
+
// one, so whatever it does with that event lands before synced flips.
|
|
18
|
+
reading = false;
|
|
19
|
+
// Open consumer handles; the stream is wanted while any is.
|
|
20
|
+
consumers = 0;
|
|
21
|
+
wanted = new Signal(false);
|
|
22
|
+
}
|
|
23
|
+
// Synced once nothing is owed and the reader has come back for more.
|
|
24
|
+
function settle(state) {
|
|
25
|
+
if (state.owed === 0 && !state.reading)
|
|
26
|
+
state.synced.set(true);
|
|
16
27
|
}
|
|
17
28
|
// Once.set throws on a second settle, and both ends of a stream can close independently.
|
|
18
29
|
function closeState(state, abort) {
|
|
@@ -22,11 +33,15 @@ function closeState(state, abort) {
|
|
|
22
33
|
state.queue.mutate((queue) => {
|
|
23
34
|
queue.length = 0;
|
|
24
35
|
});
|
|
36
|
+
// Nothing more is coming, so nothing waiting on the boundary should hang.
|
|
37
|
+
state.owed = 0;
|
|
38
|
+
state.reading = false;
|
|
39
|
+
state.synced.set(true);
|
|
25
40
|
}
|
|
26
41
|
/**
|
|
27
|
-
* The write side of
|
|
42
|
+
* The write side of a route stream.
|
|
28
43
|
*
|
|
29
|
-
* @
|
|
44
|
+
* @internal
|
|
30
45
|
*/
|
|
31
46
|
export class Producer {
|
|
32
47
|
#state = new AnnounceState();
|
|
@@ -39,70 +54,206 @@ export class Producer {
|
|
|
39
54
|
}
|
|
40
55
|
/** A read handle for this announcement stream. */
|
|
41
56
|
consume() {
|
|
42
|
-
return
|
|
57
|
+
return makeRoutes(this.#state);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Whether any consumer still holds the stream: false before the first {@link consume} and
|
|
61
|
+
* once the last one {@link Routes.close}s, which is how a reader cancels it.
|
|
62
|
+
*/
|
|
63
|
+
get wanted() {
|
|
64
|
+
return this.#state.wanted;
|
|
43
65
|
}
|
|
44
|
-
/** Writes an
|
|
45
|
-
append(
|
|
66
|
+
/** Writes an event to the queue. */
|
|
67
|
+
append(event) {
|
|
46
68
|
if (this.#state.closed.peek() !== undefined)
|
|
47
69
|
throw new Error("announcements are closed");
|
|
48
70
|
this.#state.queue.mutate((queue) => {
|
|
49
|
-
queue.push(
|
|
71
|
+
queue.push(event);
|
|
50
72
|
});
|
|
51
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Marks the initial set as delivered: the stream syncs once the reader has taken
|
|
76
|
+
* everything queued so far. A no-op until {@link behind} once marked.
|
|
77
|
+
*
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
synced() {
|
|
81
|
+
const state = this.#state;
|
|
82
|
+
if (state.owed !== undefined)
|
|
83
|
+
return;
|
|
84
|
+
state.owed = state.queue.peek().length;
|
|
85
|
+
settle(state);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Takes sync back until the next {@link synced}, as when another initial set starts.
|
|
89
|
+
*
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
behind() {
|
|
93
|
+
const state = this.#state;
|
|
94
|
+
if (state.closed.peek() !== undefined)
|
|
95
|
+
return;
|
|
96
|
+
state.owed = undefined;
|
|
97
|
+
state.synced.set(false);
|
|
98
|
+
}
|
|
52
99
|
/** Closes the writer. Idempotent. */
|
|
53
100
|
close(abort) {
|
|
54
101
|
closeState(this.#state, abort);
|
|
55
102
|
}
|
|
56
103
|
}
|
|
57
|
-
// Constructs a
|
|
104
|
+
// Constructs a Routes from within this module without exposing a public constructor
|
|
58
105
|
// that would leak the unexported AnnounceState. Assigned in the class's static block.
|
|
59
|
-
let
|
|
106
|
+
let makeRoutes;
|
|
60
107
|
/**
|
|
61
|
-
* The read side of
|
|
62
|
-
*
|
|
63
|
-
* Created internally: obtain one from {@link Producer.consume} or the connection's
|
|
64
|
-
* `announced(scope)`.
|
|
108
|
+
* The read side of a route stream: every change, for code that forwards or routes them.
|
|
65
109
|
*
|
|
66
|
-
* @
|
|
110
|
+
* @internal
|
|
67
111
|
*/
|
|
68
|
-
export class
|
|
112
|
+
export class Routes {
|
|
69
113
|
#state;
|
|
114
|
+
// Set once this handle closes, ending its own reads and guarding the consumer count.
|
|
115
|
+
#released = new Signal(false);
|
|
70
116
|
constructor(state) {
|
|
71
117
|
this.#state = state;
|
|
118
|
+
state.consumers++;
|
|
119
|
+
state.wanted.set(true);
|
|
72
120
|
}
|
|
73
|
-
/** Settles once the stream closes
|
|
121
|
+
/** Settles once the stream closes: `null` on a clean close, or the abort {@link Error}. */
|
|
74
122
|
get closed() {
|
|
75
123
|
return this.#state.closed;
|
|
76
124
|
}
|
|
77
125
|
static {
|
|
78
|
-
|
|
126
|
+
makeRoutes = (state) => new Routes(state);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Whether the stream has delivered its source's initial announcements and the reader has
|
|
130
|
+
* taken them, so a prefix not announced by now is absent rather than not yet heard of.
|
|
131
|
+
*
|
|
132
|
+
* Flips once the reader asks for the event after the last of them, and is true once
|
|
133
|
+
* closed. Through a session, the initial set is the peer's view when it answered: exact
|
|
134
|
+
* on versions that count it, best-effort on the rest. Reading an origin, it is every
|
|
135
|
+
* attached session's initial set, so a reconnect takes it back until the new one lands.
|
|
136
|
+
*/
|
|
137
|
+
get synced() {
|
|
138
|
+
return this.#state.synced;
|
|
79
139
|
}
|
|
80
|
-
/** The
|
|
140
|
+
/** The events as they arrive, until the stream closes. */
|
|
81
141
|
async *[Symbol.asyncIterator]() {
|
|
82
142
|
for (;;) {
|
|
83
|
-
const
|
|
84
|
-
if (!
|
|
143
|
+
const event = await this.next();
|
|
144
|
+
if (!event)
|
|
85
145
|
return;
|
|
86
|
-
yield
|
|
146
|
+
yield event;
|
|
87
147
|
}
|
|
88
148
|
}
|
|
89
|
-
/** Returns the next
|
|
149
|
+
/** Returns the next event, or undefined once the stream or this handle closes. */
|
|
90
150
|
async next() {
|
|
151
|
+
const state = this.#state;
|
|
152
|
+
state.reading = false;
|
|
153
|
+
settle(state);
|
|
91
154
|
for (;;) {
|
|
92
|
-
|
|
93
|
-
|
|
155
|
+
if (this.#released.peek())
|
|
156
|
+
return undefined;
|
|
157
|
+
const announce = state.queue.peek().shift();
|
|
158
|
+
if (announce) {
|
|
159
|
+
if (state.owed)
|
|
160
|
+
state.owed -= 1;
|
|
161
|
+
if (!state.synced.peek())
|
|
162
|
+
state.reading = true;
|
|
94
163
|
return announce;
|
|
164
|
+
}
|
|
95
165
|
const closed = this.#state.closed.peek();
|
|
96
166
|
if (closed instanceof Error)
|
|
97
167
|
throw closed;
|
|
98
168
|
if (closed !== undefined)
|
|
99
169
|
return undefined;
|
|
100
|
-
await Signal.race(
|
|
170
|
+
await Signal.race(state.queue, state.closed, this.#released);
|
|
101
171
|
}
|
|
102
172
|
}
|
|
103
|
-
/**
|
|
104
|
-
|
|
105
|
-
|
|
173
|
+
/**
|
|
174
|
+
* Release this handle, like dropping a Rust handle: other consumers keep reading, and the
|
|
175
|
+
* producer sees the stream as no longer wanted once the last one closes.
|
|
176
|
+
* Idempotent.
|
|
177
|
+
*/
|
|
178
|
+
close() {
|
|
179
|
+
if (this.#released.peek())
|
|
180
|
+
return;
|
|
181
|
+
this.#released.set(true);
|
|
182
|
+
if (--this.#state.consumers === 0)
|
|
183
|
+
this.#state.wanted.set(false);
|
|
106
184
|
}
|
|
107
185
|
}
|
|
186
|
+
// Constructs a listing over a route stream without a public constructor. Declared before the
|
|
187
|
+
// class, whose static block assigns it.
|
|
188
|
+
let makeConsumer;
|
|
189
|
+
/**
|
|
190
|
+
* The paths announced under a scope, each reported as it becomes present or absent.
|
|
191
|
+
*
|
|
192
|
+
* Created internally: obtain one from an origin or the connection's `announced(scope)`.
|
|
193
|
+
*
|
|
194
|
+
* @public
|
|
195
|
+
*/
|
|
196
|
+
export class Consumer {
|
|
197
|
+
#routes;
|
|
198
|
+
constructor(routes) {
|
|
199
|
+
this.#routes = routes;
|
|
200
|
+
}
|
|
201
|
+
static {
|
|
202
|
+
makeConsumer = (routes) => new Consumer(routes);
|
|
203
|
+
}
|
|
204
|
+
/** Settles once the stream closes: `null` on a clean close, or the abort {@link Error}. */
|
|
205
|
+
// fallow-ignore-next-line unused-class-member
|
|
206
|
+
get closed() {
|
|
207
|
+
return this.#routes.closed;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Whether the listing has delivered its source's initial announcements and the reader has
|
|
211
|
+
* taken them, so a path not present by now is absent rather than not yet heard of.
|
|
212
|
+
*
|
|
213
|
+
* Flips once the reader asks for the event after the last of them, and is true once
|
|
214
|
+
* closed. Through a session, the initial set is the peer's view when it answered: exact
|
|
215
|
+
* on versions that count it, best-effort on the rest. Reading an origin, it is every
|
|
216
|
+
* attached session's initial set, so a reconnect takes it back until the new one lands.
|
|
217
|
+
*/
|
|
218
|
+
get synced() {
|
|
219
|
+
return this.#routes.synced;
|
|
220
|
+
}
|
|
221
|
+
/** The events as they arrive, until the listing closes. */
|
|
222
|
+
async *[Symbol.asyncIterator]() {
|
|
223
|
+
for (;;) {
|
|
224
|
+
const event = await this.next();
|
|
225
|
+
if (!event)
|
|
226
|
+
return;
|
|
227
|
+
yield event;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/** Returns the next change to a path, or undefined once the listing or this handle closes. */
|
|
231
|
+
async next() {
|
|
232
|
+
for (;;) {
|
|
233
|
+
const event = await this.#routes.next();
|
|
234
|
+
if (!event)
|
|
235
|
+
return undefined;
|
|
236
|
+
const { kind, prefix } = event;
|
|
237
|
+
if (kind === "update" || kind === "restart")
|
|
238
|
+
continue;
|
|
239
|
+
const route = routeInfo(event.route);
|
|
240
|
+
return { kind: kind === "start" ? "present" : "absent", prefix, route };
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Release this handle, like dropping a Rust handle: the source sees the listing as no
|
|
245
|
+
* longer wanted. Idempotent.
|
|
246
|
+
*/
|
|
247
|
+
close() {
|
|
248
|
+
this.#routes.close();
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* The listing over a route stream: only paths becoming present or absent.
|
|
253
|
+
*
|
|
254
|
+
* @internal
|
|
255
|
+
*/
|
|
256
|
+
export function list(routes) {
|
|
257
|
+
return makeConsumer(routes);
|
|
258
|
+
}
|
|
108
259
|
//# sourceMappingURL=announced.js.map
|
package/announced.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"announced.js","sourceRoot":"","sources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AE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1D,CAAC;IACF,CAAC;IAED,qCAAqC;IACrC,KAAK,CAAC,KAAa;QAClB,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAChC,CAAC;CACD","sourcesContent":["/**\n * Broadcast announcement streams: which broadcast paths are available under a scope.\n *\n * @module\n */\nimport { type GetPromise, Once, Signal } from \"@moq/signals\";\nimport type { Route } from \"./hop.js\";\nimport type * as Path from \"./path.js\";\n\n/**\n * What an {@link Update} reports about its prefix.\n *\n * @public\n */\nexport type Kind = \"announced\" | \"updated\" | \"retracted\";\n\n/**\n * A route announcement, update, or retraction.\n *\n * An announcement is always a prefix, never a broadcast: a route claims that\n * {@link prefix} and every path beneath it can be served. By convention a publisher\n * announces each broadcast's exact path, so enumerating routes enumerates broadcasts;\n * resolve one with the origin's `request(path)`. Narrow with a {@link Path.Pattern}\n * locally to follow a subset.\n *\n * @public\n */\nexport interface Update {\n\t/**\n\t * The prefix the route covers, relative to the origin (for a session, its URL path).\n\t */\n\tprefix: Path.Valid;\n\t/** What the filter's wildcards stood for, when this prefix pins all of them. */\n\tcaptures: Path.Pattern[] | undefined;\n\t/** Whether the prefix was announced, re-priced, or retracted. */\n\tkind: Kind;\n\t/** Hops and cost of the route; on a retraction, its last advertised values. */\n\troute: Route;\n}\n\n/**\n * Options for an announcement stream.\n *\n * @public\n */\nexport interface Options {\n\t/**\n\t * Also report hidden routes: those with a path segment starting with `.` below the\n\t * scope's literal head. Hidden routes are left out by default, so a platform can add\n\t * `.`-named broadcasts (stats, internal routes) without them turning up in apps that\n\t * list everything. Subscribing to a hidden path by name works either way.\n\t */\n\thidden?: boolean;\n}\n\n/** Whether a route covers the path after an update of this {@link Kind}. */\nexport function isActive(kind: Kind): boolean {\n\treturn kind !== \"retracted\";\n}\n\n/** Reactive backing state shared by announcement producers and consumers. */\nclass AnnounceState {\n\tqueue = new Signal<Update[]>([]);\n\tclosed = new Once<Error | null>();\n}\n\n// Once.set throws on a second settle, and both ends of a stream can close independently.\nfunction closeState(state: AnnounceState, abort?: Error) {\n\tif (state.closed.peek() !== undefined) return;\n\tstate.closed.set(abort ?? null);\n\tstate.queue.mutate((queue) => {\n\t\tqueue.length = 0;\n\t});\n}\n\n/**\n * The write side of an announcement stream.\n *\n * @public\n */\nexport class Producer {\n\t#state = new AnnounceState();\n\n\t/**\n\t * Settles once the stream 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 announcement stream. */\n\tconsume(): Consumer {\n\t\treturn makeConsumer(this.#state);\n\t}\n\n\t/** Writes an announcement to the queue. */\n\tappend(update: Update) {\n\t\tif (this.#state.closed.peek() !== undefined) throw new Error(\"announcements are closed\");\n\t\tthis.#state.queue.mutate((queue) => {\n\t\t\tqueue.push(update);\n\t\t});\n\t}\n\n\t/** Closes the writer. Idempotent. */\n\tclose(abort?: Error) {\n\t\tcloseState(this.#state, abort);\n\t}\n}\n\n// Constructs a Consumer from within this module without exposing a public constructor\n// that would leak the unexported AnnounceState. Assigned in the class's static block.\nlet makeConsumer: (state: AnnounceState) => Consumer;\n\n/**\n * The read side of an announcement stream.\n *\n * Created internally: obtain one from {@link Producer.consume} or the connection's\n * `announced(scope)`.\n *\n * @public\n */\nexport class Consumer {\n\t#state: AnnounceState;\n\n\tprivate constructor(state: AnnounceState) {\n\t\tthis.#state = state;\n\t}\n\n\t/** Settles once the stream closes; see {@link Producer.closed}. */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#state.closed;\n\t}\n\n\tstatic {\n\t\tmakeConsumer = (state) => new Consumer(state);\n\t}\n\n\t/** The announcements as they arrive, until the stream closes. */\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<Update, void, undefined> {\n\t\tfor (;;) {\n\t\t\tconst update = await this.next();\n\t\t\tif (!update) return;\n\t\t\tyield update;\n\t\t}\n\t}\n\n\t/** Returns the next announcement. */\n\tasync next(): Promise<Update | undefined> {\n\t\tfor (;;) {\n\t\t\tconst announce = this.#state.queue.peek().shift();\n\t\t\tif (announce) return announce;\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.queue, this.#state.closed);\n\t\t}\n\t}\n\n\t/** Closes the reader. Idempotent. */\n\tclose(abort?: Error) {\n\t\tcloseState(this.#state, abort);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"announced.js","sourceRoot":"","sources":["../src/announced.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAgC,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAkB,SAAS,EAAkB,MAAM,UAAU,CAAC;AAwGrE,6EAA6E;AAC7E,MAAM,aAAa;IAClB,KAAK,GAAG,IAAI,MAAM,CAAe,EAAE,CAAC,CAAC;IACrC,MAAM,GAAG,IAAI,IAAI,EAAgB,CAAC;IAClC,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3B,mFAAmF;IACnF,2CAA2C;IAC3C,IAAI,CAAqB;IACzB,kFAAkF;IAClF,sEAAsE;IACtE,OAAO,GAAG,KAAK,CAAC;IAChB,4DAA4D;IAC5D,SAAS,GAAG,CAAC,CAAC;IACd,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;CAC3B;AAED,qEAAqE;AACrE,SAAS,MAAM,CAAC,KAAoB;IACnC,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO;QAAE,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAChE,CAAC;AAED,yFAAyF;AACzF,SAAS,UAAU,CAAC,KAAoB,EAAE,KAAa;IACtD,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AAC;YACrC,OAAO,EAAE,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QACzE,CAAC;IACF,CAAC;IAED;;;OAGG;IACH,KAAK;QACJ,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAC,MAAc;IAClC,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["/**\n * Broadcast announcement streams: which broadcast paths are available under a scope.\n *\n * @module\n */\nimport { type GetPromise, type Getter, Once, Signal } from \"@moq/signals\";\nimport { type RouteInfo, routeInfo, type WireRoute } from \"./hop.ts\";\nimport type * as Path from \"./path.js\";\n\n/**\n * A route over a prefix, delivered inside an {@link Event}.\n *\n * An announcement is always a prefix, never a broadcast: a route claims that\n * {@link prefix} and every path beneath it can be served. By convention a publisher\n * announces each broadcast's exact path, so enumerating routes enumerates broadcasts;\n * resolve one with the origin's `request(path)`. List a narrower prefix, or filter the\n * announced paths locally, to follow a subset.\n *\n * @public\n */\nexport interface Announce {\n\t/**\n\t * The prefix the route covers, relative to the origin (for a session, its URL path).\n\t */\n\tprefix: Path.Valid;\n\t/** Hops and cost of the route; on a retraction, its last advertised values. */\n\troute: RouteInfo;\n}\n\n/**\n * An {@link Announce} as the origin and sessions carry it, with the route's internal metadata.\n *\n * @internal\n */\nexport type Routed = Omit<Announce, \"route\"> & { route: WireRoute };\n\n/**\n * What an announcement listing yields: a path becoming present or absent.\n *\n * `present`: a route now covers the path, which was absent; it may arrive unavailable (see\n * {@link RouteInfo.available}). `absent`: no route covers the path any more, whether its origin\n * withdrew it or this side let go of it; carries its last advertised route.\n *\n * Another identity taking a path over keeps it present, and a change in availability is not\n * reported: follow it with the origin's `follow(path)` to see the broadcast change.\n *\n * @public\n */\nexport type Event = { kind: \"present\" | \"absent\" } & Announce;\n\n/**\n * Every change to a route, for code that forwards or routes them.\n *\n * `start`: a route now covers the prefix. `update`: the route covering it changed hops, cost,\n * or availability, in place. `restart`: another identity now serves the prefix. `end`: the\n * origin withdrew it, and no route covers it any more. `offline`: this side let go of it,\n * and no route covers it any more.\n *\n * @internal\n */\nexport type RouteEvent = { kind: \"start\" | \"update\" | \"restart\" | \"end\" | \"offline\" } & Routed;\n\n/**\n * Options for an announcement stream.\n *\n * @public\n */\nexport interface Options {\n\t/**\n\t * Also report hidden routes: those with a path segment starting with `.` below the\n\t * listed prefix. Hidden routes are left out by default, so a platform can add\n\t * `.`-named broadcasts (stats, internal routes) without them turning up in apps that\n\t * list everything. Subscribing to a hidden path by name works either way.\n\t */\n\thidden?: boolean;\n\n\t/**\n\t * Also report every route that could serve a path in scope, not just those at or beneath\n\t * the listed prefix. A route is a prefix serving everything beneath it, so listing\n\t * `room/lobby` still reports a route at `room`, which can serve it. A broadcast serves only\n\t * its own path, yet is reported too, since it shadows broader routes beneath it, as in Rust. Code that routes or forwards needs these;\n\t * listing broadcasts does not. Requests resolve through covering routes either way.\n\t */\n\tcovering?: boolean;\n\n\t/**\n\t * Report only the routes that could serve the listed prefix itself, those at or above it,\n\t * and none beneath it; synced once no session owes an initial set at or above it. Implies\n\t * `covering`. For code asking whether a path is reachable, as a request resolves it, not\n\t * what lies beneath it.\n\t *\n\t * @internal\n\t */\n\texact?: boolean;\n}\n\n/**\n * Options for a route stream, which forwarding code reads.\n *\n * @internal\n */\nexport interface RouteOptions extends Options {\n\t/**\n\t * Report each origin node's claim at a path as its own route, rather than only the one the\n\t * session ranks best, so the origin it feeds ranks every candidate as rs/moq-net's does. Only\n\t * lite-07 carries more than one route per path on a stream.\n\t */\n\tclaims?: boolean;\n}\n\n/** Reactive backing state shared by announcement producers and consumers. */\nclass AnnounceState {\n\tqueue = new Signal<RouteEvent[]>([]);\n\tclosed = new Once<Error | null>();\n\tsynced = new Signal(false);\n\t// The queued events still to read before the stream counts as synced, or undefined\n\t// while the initial set is still arriving.\n\towed: number | undefined;\n\t// A reader holds the last event it took before syncing until it asks for the next\n\t// one, so whatever it does with that event lands before synced flips.\n\treading = false;\n\t// Open consumer handles; the stream is wanted while any is.\n\tconsumers = 0;\n\twanted = new Signal(false);\n}\n\n// Synced once nothing is owed and the reader has come back for more.\nfunction settle(state: AnnounceState) {\n\tif (state.owed === 0 && !state.reading) state.synced.set(true);\n}\n\n// Once.set throws on a second settle, and both ends of a stream can close independently.\nfunction closeState(state: AnnounceState, abort?: Error) {\n\tif (state.closed.peek() !== undefined) return;\n\tstate.closed.set(abort ?? null);\n\tstate.queue.mutate((queue) => {\n\t\tqueue.length = 0;\n\t});\n\t// Nothing more is coming, so nothing waiting on the boundary should hang.\n\tstate.owed = 0;\n\tstate.reading = false;\n\tstate.synced.set(true);\n}\n\n/**\n * The write side of a route stream.\n *\n * @internal\n */\nexport class Producer {\n\t#state = new AnnounceState();\n\n\t/**\n\t * Settles once the stream 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 announcement stream. */\n\tconsume(): Routes {\n\t\treturn makeRoutes(this.#state);\n\t}\n\n\t/**\n\t * Whether any consumer still holds the stream: false before the first {@link consume} and\n\t * once the last one {@link Routes.close}s, which is how a reader cancels it.\n\t */\n\tget wanted(): Getter<boolean> {\n\t\treturn this.#state.wanted;\n\t}\n\n\t/** Writes an event to the queue. */\n\tappend(event: RouteEvent) {\n\t\tif (this.#state.closed.peek() !== undefined) throw new Error(\"announcements are closed\");\n\t\tthis.#state.queue.mutate((queue) => {\n\t\t\tqueue.push(event);\n\t\t});\n\t}\n\n\t/**\n\t * Marks the initial set as delivered: the stream syncs once the reader has taken\n\t * everything queued so far. A no-op until {@link behind} once marked.\n\t *\n\t * @internal\n\t */\n\tsynced() {\n\t\tconst state = this.#state;\n\t\tif (state.owed !== undefined) return;\n\t\tstate.owed = state.queue.peek().length;\n\t\tsettle(state);\n\t}\n\n\t/**\n\t * Takes sync back until the next {@link synced}, as when another initial set starts.\n\t *\n\t * @internal\n\t */\n\tbehind() {\n\t\tconst state = this.#state;\n\t\tif (state.closed.peek() !== undefined) return;\n\t\tstate.owed = undefined;\n\t\tstate.synced.set(false);\n\t}\n\n\t/** Closes the writer. Idempotent. */\n\tclose(abort?: Error) {\n\t\tcloseState(this.#state, abort);\n\t}\n}\n\n// Constructs a Routes from within this module without exposing a public constructor\n// that would leak the unexported AnnounceState. Assigned in the class's static block.\nlet makeRoutes: (state: AnnounceState) => Routes;\n\n/**\n * The read side of a route stream: every change, for code that forwards or routes them.\n *\n * @internal\n */\nexport class Routes {\n\t#state: AnnounceState;\n\t// Set once this handle closes, ending its own reads and guarding the consumer count.\n\t#released = new Signal(false);\n\n\tprivate constructor(state: AnnounceState) {\n\t\tthis.#state = state;\n\t\tstate.consumers++;\n\t\tstate.wanted.set(true);\n\t}\n\n\t/** Settles once the stream closes: `null` on a clean close, or the abort {@link Error}. */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#state.closed;\n\t}\n\n\tstatic {\n\t\tmakeRoutes = (state) => new Routes(state);\n\t}\n\n\t/**\n\t * Whether the stream has delivered its source's initial announcements and the reader has\n\t * taken them, so a prefix not announced by now is absent rather than not yet heard of.\n\t *\n\t * Flips once the reader asks for the event after the last of them, and is true once\n\t * closed. Through a session, the initial set is the peer's view when it answered: exact\n\t * on versions that count it, best-effort on the rest. Reading an origin, it is every\n\t * attached session's initial set, so a reconnect takes it back until the new one lands.\n\t */\n\tget synced(): Getter<boolean> {\n\t\treturn this.#state.synced;\n\t}\n\n\t/** The events as they arrive, until the stream closes. */\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<RouteEvent, void, undefined> {\n\t\tfor (;;) {\n\t\t\tconst event = await this.next();\n\t\t\tif (!event) return;\n\t\t\tyield event;\n\t\t}\n\t}\n\n\t/** Returns the next event, or undefined once the stream or this handle closes. */\n\tasync next(): Promise<RouteEvent | undefined> {\n\t\tconst state = this.#state;\n\t\tstate.reading = false;\n\t\tsettle(state);\n\t\tfor (;;) {\n\t\t\tif (this.#released.peek()) return undefined;\n\t\t\tconst announce = state.queue.peek().shift();\n\t\t\tif (announce) {\n\t\t\t\tif (state.owed) state.owed -= 1;\n\t\t\t\tif (!state.synced.peek()) state.reading = true;\n\t\t\t\treturn announce;\n\t\t\t}\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(state.queue, state.closed, this.#released);\n\t\t}\n\t}\n\n\t/**\n\t * Release this handle, like dropping a Rust handle: other consumers keep reading, and the\n\t * producer sees the stream as no longer wanted once the last one closes.\n\t * Idempotent.\n\t */\n\tclose() {\n\t\tif (this.#released.peek()) return;\n\t\tthis.#released.set(true);\n\t\tif (--this.#state.consumers === 0) this.#state.wanted.set(false);\n\t}\n}\n\n// Constructs a listing over a route stream without a public constructor. Declared before the\n// class, whose static block assigns it.\nlet makeConsumer: (routes: Routes) => Consumer;\n\n/**\n * The paths announced under a scope, each reported as it becomes present or absent.\n *\n * Created internally: obtain one from an origin or the connection's `announced(scope)`.\n *\n * @public\n */\nexport class Consumer {\n\t#routes: Routes;\n\n\tprivate constructor(routes: Routes) {\n\t\tthis.#routes = routes;\n\t}\n\n\tstatic {\n\t\tmakeConsumer = (routes) => new Consumer(routes);\n\t}\n\n\t/** Settles once the stream closes: `null` on a clean close, or the abort {@link Error}. */\n\t// fallow-ignore-next-line unused-class-member\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#routes.closed;\n\t}\n\n\t/**\n\t * Whether the listing has delivered its source's initial announcements and the reader has\n\t * taken them, so a path not present by now is absent rather than not yet heard of.\n\t *\n\t * Flips once the reader asks for the event after the last of them, and is true once\n\t * closed. Through a session, the initial set is the peer's view when it answered: exact\n\t * on versions that count it, best-effort on the rest. Reading an origin, it is every\n\t * attached session's initial set, so a reconnect takes it back until the new one lands.\n\t */\n\tget synced(): Getter<boolean> {\n\t\treturn this.#routes.synced;\n\t}\n\n\t/** The events as they arrive, until the listing closes. */\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<Event, void, undefined> {\n\t\tfor (;;) {\n\t\t\tconst event = await this.next();\n\t\t\tif (!event) return;\n\t\t\tyield event;\n\t\t}\n\t}\n\n\t/** Returns the next change to a path, or undefined once the listing or this handle closes. */\n\tasync next(): Promise<Event | undefined> {\n\t\tfor (;;) {\n\t\t\tconst event = await this.#routes.next();\n\t\t\tif (!event) return undefined;\n\t\t\tconst { kind, prefix } = event;\n\t\t\tif (kind === \"update\" || kind === \"restart\") continue;\n\t\t\tconst route = routeInfo(event.route);\n\t\t\treturn { kind: kind === \"start\" ? \"present\" : \"absent\", prefix, route };\n\t\t}\n\t}\n\n\t/**\n\t * Release this handle, like dropping a Rust handle: the source sees the listing as no\n\t * longer wanted. Idempotent.\n\t */\n\tclose() {\n\t\tthis.#routes.close();\n\t}\n}\n\n/**\n * The listing over a route stream: only paths becoming present or absent.\n *\n * @internal\n */\nexport function list(routes: Routes): Consumer {\n\treturn makeConsumer(routes);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"announced.test-util.d.ts","sourceRoot":"","sources":["../src/announced.test-util.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Signal } from "@moq/signals";
|
|
2
|
+
/** A closeable announcement snapshot for tests and benchmarks. @internal */
|
|
3
|
+
export async function announcedView(origin, prefix, options) {
|
|
4
|
+
const stream = origin.routes(prefix, options);
|
|
5
|
+
const value = new Signal(new Map());
|
|
6
|
+
const done = (async () => {
|
|
7
|
+
for await (const event of stream)
|
|
8
|
+
value.update((previous) => {
|
|
9
|
+
const next = new Map(previous);
|
|
10
|
+
if (event.kind === "end" || event.kind === "offline")
|
|
11
|
+
next.delete(event.prefix);
|
|
12
|
+
else
|
|
13
|
+
next.set(event.prefix, event.route);
|
|
14
|
+
return next;
|
|
15
|
+
});
|
|
16
|
+
})();
|
|
17
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
18
|
+
return {
|
|
19
|
+
peek: () => value.peek(),
|
|
20
|
+
subscribe: value.subscribe.bind(value),
|
|
21
|
+
close: async () => {
|
|
22
|
+
stream.close();
|
|
23
|
+
await done;
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=announced.test-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"announced.test-util.js","sourceRoot":"","sources":["../src/announced.test-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAKtC,4EAA4E;AAC5E,MAAM,CAAC,KAAK,UAAU,aAAa,CAClC,MAAkE,EAClE,MAAmB,EACnB,OAAiB;IAEjB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,IAAI,MAAM,CAAqC,IAAI,GAAG,EAAE,CAAC,CAAC;IACxE,MAAM,IAAI,GAAG,CAAC,KAAK,IAAI,EAAE;QACxB,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM;YAC/B,KAAK,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACzB,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAC/B,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;oBAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;;oBAC3E,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;gBACzC,OAAO,IAAI,CAAC;YACb,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,EAAE,CAAC;IACL,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5D,OAAO;QACN,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE;QACxB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;QACtC,KAAK,EAAE,KAAK,IAAI,EAAE;YACjB,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,CAAC;QACZ,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { Signal } from \"@moq/signals\";\nimport type { Options, Routes } from \"./announced\";\nimport type { WireRoute } from \"./hop\";\nimport type * as Path from \"./path\";\n\n/** A closeable announcement snapshot for tests and benchmarks. @internal */\nexport async function announcedView(\n\torigin: { routes(prefix?: Path.Valid, options?: Options): Routes },\n\tprefix?: Path.Valid,\n\toptions?: Options,\n) {\n\tconst stream = origin.routes(prefix, options);\n\tconst value = new Signal<ReadonlyMap<Path.Valid, WireRoute>>(new Map());\n\tconst done = (async () => {\n\t\tfor await (const event of stream)\n\t\t\tvalue.update((previous) => {\n\t\t\t\tconst next = new Map(previous);\n\t\t\t\tif (event.kind === \"end\" || event.kind === \"offline\") next.delete(event.prefix);\n\t\t\t\telse next.set(event.prefix, event.route);\n\t\t\t\treturn next;\n\t\t\t});\n\t})();\n\tawait new Promise<void>((resolve) => setImmediate(resolve));\n\treturn {\n\t\tpeek: () => value.peek(),\n\t\tsubscribe: value.subscribe.bind(value),\n\t\tclose: async () => {\n\t\t\tstream.close();\n\t\t\tawait done;\n\t\t},\n\t};\n}\n"]}
|