@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/lite/connection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/lite/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAIzD,OAAO,EAA0B,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAkB,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,UAA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;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAkB,EAAE,OAAgB;IACpE,MAAM,QAAQ,GACb,IAGA,CAAC,QAAQ,CAAC;IACX,IAAI,OAAO,QAAQ,KAAK,UAAU;QAAE,OAAO,UAAU,CAAC,IAAI,CAAC;IAE3D,6EAA6E;IAC7E,IAAI,KAAwE,CAAC;IAC7E,IAAI,CAAC;QACJ,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,UAAU,CAAC,IAAI,CAAC;IACxB,CAAC;IAED,MAAM,GAAG,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;IACjE,OAAO,KAAK,CAAC,iBAAiB,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC;AAC7F,CAAC","sourcesContent":["import { type Getter, Once, Signal } from \"@moq/signals\";\nimport type * as announce from \"../announced.ts\";\nimport type { Established } from \"../connection/established.ts\";\nimport type { Drain } from \"../connection/goaway.ts\";\nimport { type Probe, type Stats, transportStats } from \"../connection/stats.ts\";\nimport { type Transport, transportOf } from \"../connection/transport.ts\";\nimport { closeError, error, fromClose, ProtocolViolation, StreamCode, StreamError, sessionCause } from \"../error.ts\";\nimport { type Hop, randomHop } from \"../hop.ts\";\nimport type { Consumer as OriginConsumer } from \"../origin.ts\";\nimport type * as Path from \"../path.ts\";\nimport { type Reader, Readers, Stream, Writer } from \"../stream.ts\";\nimport { registerWire } from \"../wire.ts\";\nimport { AnnounceRequest } from \"./announce.ts\";\nimport { Fetch } from \"./fetch.ts\";\nimport { Goaway } from \"./goaway.ts\";\nimport { Group } from \"./group.ts\";\nimport { Publisher } from \"./publisher.ts\";\nimport { SessionInfo } from \"./session.ts\";\nimport { ProbeLevel, type Role, Setup } from \"./setup.ts\";\nimport { DataType, StreamId } from \"./stream.ts\";\nimport { Subscribe } from \"./subscribe.ts\";\nimport { Subscriber } from \"./subscriber.ts\";\nimport { Track as TrackMessage } from \"./track.ts\";\nimport { hasDatagrams, hasProbeRtt, hasSetupStream, type Version, versionName } from \"./version.ts\";\n\n/**\n * Constructor options for {@link Connection}.\n *\n * @internal\n */\nexport interface ConnectionProps {\n\t/** The URL of the connection. */\n\turl: URL;\n\t/** The established WebTransport session. */\n\tquic: WebTransport;\n\t/** The negotiated wire version. */\n\tversion: Version;\n\t/** The session stream, absent on drafts that have none. */\n\tsession?: Stream;\n\t/** Whether the relay supports broadcast discovery. Defaults to true. */\n\tdiscovery?: boolean;\n\t/** The origin whose broadcasts are served to the peer. Omit to publish nothing. */\n\tpublish?: OriginConsumer;\n}\n\n/**\n * Represents a connection to a MoQ server.\n *\n * @public\n */\nexport class Connection implements Established {\n\t// The URL of the connection.\n\treadonly url: URL;\n\n\t// The version of the connection as a human-readable string.\n\treadonly version: string;\n\n\t// The wire transport this session runs over.\n\treadonly transport: Transport;\n\n\t/** Whether the relay supports broadcast discovery; see {@link Established.discovery}. */\n\treadonly discovery: boolean;\n\n\t// The version used for encoding/decoding.\n\t#version: Version;\n\n\t// The established WebTransport session.\n\t#quic: WebTransport;\n\n\t// Use to receive/send session messages.\n\t#session?: Stream;\n\n\t// Module for contributing tracks.\n\t#publisher: Publisher;\n\n\t// Module for distributing tracks.\n\t#subscriber: Subscriber;\n\n\t/** The peer's PROBE estimates; see {@link Established.probe}. */\n\treadonly probe: Getter<Probe>;\n\n\t/** Random per-connection Hop ID. Shared by Publisher (for outbound hop\n\t * chains) and Subscriber (available for optional self-filtering on announces). */\n\treadonly hop: Hop;\n\n\t// The peer's SETUP, recorded once its Setup stream is read (lite-05+). Streams whose\n\t// encoding depends on a negotiated capability (e.g. PROBE) wait on this. undefined\n\t// until the peer's SETUP arrives; stays undefined forever on older drafts.\n\t#peerSetup = new Signal<Setup | undefined>(undefined);\n\n\t// Mirrors the role out of #peerSetup, so the public surface exposes the peer's declared\n\t// direction without handing out the whole SETUP (whose probe level gates our own streams).\n\t#peerRole = new Signal<Role | undefined>(undefined);\n\n\t// Written by the Subscriber as PROBE messages arrive.\n\t#probe = new Signal<Probe>({});\n\n\t// The peer's GOAWAY. Lite carries no deadline, so only the URI is set.\n\t#goaway = new Once<Drain>();\n\n\t/**\n\t * The {@link Role} the peer advertised in its SETUP, for a server deciding whether the\n\t * peer's authorization grants the direction it intends to use.\n\t *\n\t * `undefined` until the peer's SETUP arrives, and forever on pre-lite-05 versions, which\n\t * carry no in-band role. {@link Role.Both} is the absence of the parameter, so it is what\n\t * a peer reports when it declines to declare a direction, sends a value we don't\n\t * recognize, or is a server (which never sends one).\n\t */\n\tget peerRole(): Getter<Role | undefined> {\n\t\treturn this.#peerRole;\n\t}\n\n\t/**\n\t * Creates a new Connection instance.\n\t *\n\t * @internal\n\t */\n\tconstructor({ url, quic, version, session, discovery = true, publish }: ConnectionProps) {\n\t\tthis.url = url;\n\t\tthis.#quic = quic;\n\t\tthis.#session = session;\n\t\t// The session stream was opened at the SETUP exchange's version; the rest of it speaks this one.\n\t\tif (session) {\n\t\t\tsession.reader.version = version;\n\t\t\tsession.writer.version = version;\n\t\t}\n\t\tthis.version = versionName(version);\n\t\tthis.#version = version;\n\t\tthis.transport = transportOf(quic);\n\t\tthis.discovery = discovery;\n\n\t\tthis.probe = this.#probe;\n\n\t\tthis.hop = randomHop();\n\t\tthis.#publisher = new Publisher(this.#quic, this.#version, this.hop, publish);\n\t\tthis.#subscriber = new Subscriber(this.#quic, this.#version, this.hop, this.#probe, this.#peerSetup);\n\t\tregisterWire(this, { consume: (path) => this.#subscriber.consume(path), goaway: this.#goaway });\n\n\t\tvoid this.#run();\n\t}\n\n\t/**\n\t * Closes the connection.\n\t */\n\tclose() {\n\t\tthis.#publisher.close();\n\t\tthis.#subscriber.close();\n\n\t\ttry {\n\t\t\t// TODO: For whatever reason, this try/catch doesn't seem to work..?\n\t\t\tthis.#quic.close();\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\t}\n\n\tasync #run(): Promise<void> {\n\t\tconst tasks: Promise<void>[] = [this.#runSession(), this.#runBidis(), this.#runUnis()];\n\n\t\tif (hasSetupStream(this.#version)) {\n\t\t\ttasks.push(this.#sendSetup());\n\t\t}\n\n\t\ttasks.push(this.#subscriber.runProbe());\n\n\t\t// Route incoming QUIC datagrams into their subscriptions (lite-05+; runDatagrams\n\t\t// no-ops on a transport that doesn't carry them).\n\t\tif (hasDatagrams(this.#version)) {\n\t\t\ttasks.push(this.#subscriber.runDatagrams());\n\t\t}\n\n\t\tlet fatal: Error | undefined;\n\t\ttry {\n\t\t\tawait Promise.all(tasks);\n\t\t} catch (err) {\n\t\t\tconsole.error(\"fatal error running connection\", err);\n\t\t\t// A session-sourced failure is the peer's close, not the raw transport error.\n\t\t\tfatal = await sessionCause(this.#quic, err);\n\t\t} finally {\n\t\t\t// The session died under every track it was receiving, so they end with its\n\t\t\t// error. A deliberate close() already ended them cleanly, which makes this a no-op.\n\t\t\tthis.#subscriber.close(fatal ?? (await closeError(this.#quic)));\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\tannounced(scope?: Path.Pattern, options?: announce.Options): announce.Consumer {\n\t\treturn this.#subscriber.announced(scope, options);\n\t}\n\n\tasync #runSession() {\n\t\tif (!this.#session) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tconst msg = await SessionInfo.decodeMaybe(this.#session.reader, this.#version);\n\t\t\t\tif (!msg) break;\n\t\t\t}\n\t\t} finally {\n\t\t\tconsole.debug(\"session stream closed\");\n\t\t}\n\t}\n\n\t// Open the unidirectional Setup Stream, send our single SETUP, and FIN (lite-05+).\n\t// The browser uses WebTransport, which carries the request URI, so we advertise no\n\t// path and leave routing to the URL. The probe level reflects what this transport\n\t// can actually measure; we never pad, so we never advertise Increase.\n\t// Role stays Both: the publish origin starts empty and fills later, and consume is\n\t// called after this point, so there is nothing to narrow yet. The origin declares\n\t// our session identity so the peer can filter\n\t// reflected announcements (lite-06 removed ANNOUNCE_REQUEST's exclude_hop for it).\n\tasync #sendSetup(): Promise<void> {\n\t\tconst writer = await Writer.open(this.#quic, { version: this.#version });\n\t\ttry {\n\t\t\tawait writer.u53(DataType.Setup);\n\t\t\tconst probe = await probeLevel(this.#quic, this.#version);\n\t\t\tawait new Setup({ probe, hop: this.hop }).encode(writer, this.#version);\n\t\t\twriter.close();\n\t\t} catch (err: unknown) {\n\t\t\twriter.reset(err);\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tasync #runBidis() {\n\t\tfor (;;) {\n\t\t\tconst stream = await Stream.accept(this.#quic, this.#version);\n\t\t\tif (!stream) break;\n\n\t\t\tthis.#runBidi(stream)\n\t\t\t\t.catch((err: unknown) => {\n\t\t\t\t\tstream.writer.reset(err);\n\t\t\t\t\t// A protocol violation on one stream is the peer breaking the session.\n\t\t\t\t\t// Resetting that stream leaves it free to repeat the violation; a duplicate\n\t\t\t\t\t// GOAWAY is the one this dispatcher raises.\n\t\t\t\t\tif (err instanceof ProtocolViolation) this.close();\n\t\t\t\t})\n\t\t\t\t.finally(() => {\n\t\t\t\t\tstream.writer.close();\n\t\t\t\t});\n\t\t}\n\t}\n\n\tasync #runBidi(stream: Stream) {\n\t\tconst typ = await stream.reader.u53();\n\n\t\tif (typ === StreamId.Session) {\n\t\t\tthrow new Error(\"duplicate session stream\");\n\t\t} else if (typ === StreamId.Announce) {\n\t\t\tconst msg = await AnnounceRequest.decode(stream.reader, this.#version);\n\t\t\tawait this.#publisher.runAnnounce(msg, stream);\n\t\t} else if (typ === StreamId.Subscribe) {\n\t\t\tconst msg = await Subscribe.decode(stream.reader, this.#version);\n\t\t\tawait this.#publisher.runSubscribe(msg, stream);\n\t\t} else if (typ === StreamId.Fetch) {\n\t\t\tconst msg = await Fetch.decode(stream.reader, this.#version);\n\t\t\tawait this.#publisher.runFetch(msg, stream);\n\t\t} else if (typ === StreamId.Track) {\n\t\t\tconst msg = await TrackMessage.decode(stream.reader, this.#version);\n\t\t\tawait this.#publisher.runTrackInfo(msg, stream);\n\t\t} else if (typ === StreamId.Probe) {\n\t\t\tawait this.#publisher.runProbe(stream);\n\t\t} else if (typ === StreamId.Goaway) {\n\t\t\tconst msg = await Goaway.decode(stream.reader, this.#version);\n\t\t\t// A peer sends at most one; a second is a protocol violation.\n\t\t\tif (this.#goaway.peek() !== undefined) throw new ProtocolViolation(\"duplicate GOAWAY\");\n\t\t\tthis.#goaway.set({ uri: msg.uri });\n\t\t} else {\n\t\t\tthrow new Error(`unknown stream type: ${typ.toString()}`);\n\t\t}\n\t}\n\n\tasync #runUnis() {\n\t\tconst readers = new Readers(this.#quic, this.#version);\n\n\t\tfor (;;) {\n\t\t\tconst stream = await readers.next();\n\t\t\tif (!stream) break;\n\n\t\t\tthis.#runUni(stream)\n\t\t\t\t.then(() => {\n\t\t\t\t\tstream.stop(new StreamError(StreamCode.Cancel, { message: \"cancel\" }));\n\t\t\t\t})\n\t\t\t\t.catch((err: unknown) => {\n\t\t\t\t\tstream.stop(err);\n\t\t\t\t});\n\t\t}\n\t}\n\n\tasync #runUni(stream: Reader) {\n\t\tconst typ = await stream.u53();\n\t\tif (typ === DataType.Group) {\n\t\t\tconst msg = await Group.decode(stream, this.#version);\n\t\t\tawait this.#subscriber.runGroup(msg, stream);\n\t\t} else if (typ === DataType.Setup) {\n\t\t\t// The peer sends exactly one SETUP, then FINs. Record it so capability-gated\n\t\t\t// streams (e.g. PROBE) can react, then drain to the FIN.\n\t\t\tconst setup = await Setup.decode(stream, this.#version);\n\t\t\tthis.#peerSetup.set(setup);\n\t\t\tthis.#peerRole.set(setup.role);\n\t\t} else {\n\t\t\tthrow new Error(`unknown stream type: ${typ.toString()}`);\n\t\t}\n\t}\n\n\t/** Snapshot the transport's counters; see {@link Established.stats}. */\n\tasync stats(): Promise<Stats> {\n\t\treturn transportStats(this.#quic);\n\t}\n\n\t/** Resolves when the session closes, decoding the peer's close code; see {@link Established.closed}. */\n\tget closed(): Promise<Error | null> {\n\t\treturn this.#quic.closed.then(fromClose, (err: unknown) => error(err));\n\t}\n}\n\n/**\n * The probe level to advertise in SETUP, from what the transport can measure.\n *\n * `Report` claims we can measure and periodically report, so it is only truthful\n * when a metric this version can carry actually exists. The qmux/WebSocket fallback\n * implements no `getStats()` at all, and even a transport that has one may report\n * neither figure. Advertising `Report` and then holding the subscriber's PROBE\n * stream open with nothing to send is the state this avoids; the subscriber's own\n * gate then skips a stream it could not use.\n *\n * Mirrors `ProbeLevel::detect` in `moq-net`, including its limitation: a metric\n * that only appears after SETUP reads as unsupported here.\n *\n * @internal\n */\nexport async function probeLevel(quic: WebTransport, version: Version): Promise<ProbeLevel> {\n\tconst getStats = (\n\t\tquic as unknown as {\n\t\t\tgetStats?: () => Promise<{ estimatedSendRate: number | null; smoothedRtt?: number | null }>;\n\t\t}\n\t).getStats;\n\tif (typeof getStats !== \"function\") return ProbeLevel.None;\n\n\t// A transport that can't answer tells us nothing, which is itself an answer.\n\tlet stats: { estimatedSendRate: number | null; smoothedRtt?: number | null };\n\ttry {\n\t\tstats = await getStats.call(quic);\n\t} catch {\n\t\treturn ProbeLevel.None;\n\t}\n\n\tconst rtt = hasProbeRtt(version) ? stats.smoothedRtt : undefined;\n\treturn stats.estimatedSendRate != null || rtt != null ? ProbeLevel.Report : ProbeLevel.None;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/lite/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,MAAM,EAAgC,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAIjD,OA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AC;AAC1G,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAkB,EAAE,OAAgB;IACpE,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,CAAC,QAAQ;QAAE,OAAO,UAAU,CAAC,IAAI,CAAC;IAEtC,6EAA6E;IAC7E,IAAI,KAAqB,CAAC;IAC1B,IAAI,CAAC;QACJ,KAAK,GAAG,MAAM,QAAQ,EAAE,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,UAAU,CAAC,IAAI,CAAC;IACxB,CAAC;IAED,MAAM,GAAG,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;IACjE,OAAO,YAAY,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,SAAS,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC;AACjH,CAAC","sourcesContent":["import { Duration } from \"@moq/clock\";\nimport { Effect, type GetPromise, type Getter, Once, Signal } from \"@moq/signals\";\nimport * as announce from \"../announced.ts\";\nimport type * as Auth from \"../auth.ts\";\nimport { AuthSession } from \"../auth_session.ts\";\nimport type { Goaway as Received } from \"../connection/goaway.ts\";\nimport type { Liveness } from \"../connection/liveness.ts\";\nimport type { Session } from \"../connection/session.ts\";\nimport { detect, type Probe, type Stats, statsOf, type TransportStats, transportStats } from \"../connection/stats.ts\";\nimport { type Transport, transportOf } from \"../connection/transport.ts\";\nimport {\n\tcloseError,\n\tcloseReason,\n\terror,\n\tfromClose,\n\tProtocolViolation,\n\tpeerEnded,\n\tSessionCode,\n\tStreamCode,\n\tStreamError,\n\tsessionCause,\n} from \"../error.ts\";\nimport { type Cost, type Hop, randomHop } from \"../hop.ts\";\nimport { IMPLEMENTATION } from \"../implementation.ts\";\nimport { lines } from \"../open.ts\";\nimport type { Consumer as OriginConsumer } from \"../origin.ts\";\nimport * as Path from \"../path.ts\";\nimport { type Reader, Readers, Stream, Writer } from \"../stream.ts\";\nimport { Observed } from \"../util/observed.ts\";\nimport { withTimeout } from \"../util/timeout.ts\";\nimport { registerWire } from \"../wire.ts\";\nimport { type AnnounceBroadcast, AnnounceRequest, decodeAnnounceBroadcastMaybe } from \"./announce.ts\";\nimport { AnnounceStream } from \"./announce_stream.ts\";\nimport { LiteAuthWire } from \"./auth.ts\";\nimport { Datagrams } from \"./datagram.ts\";\nimport { closeViolation } from \"./error.ts\";\nimport { Goaway } from \"./goaway.ts\";\nimport { Group } from \"./group.ts\";\nimport { probeBitrate } from \"./probe.ts\";\nimport { Publisher } from \"./publisher.ts\";\nimport { SessionInfo } from \"./session.ts\";\nimport { hasClientParameters, ProbeLevel, Setup } from \"./setup.ts\";\nimport { DataType, StreamId } from \"./stream.ts\";\nimport { Subscribe } from \"./subscribe.ts\";\nimport { Subscriber } from \"./subscriber.ts\";\nimport { Track as TrackMessage } from \"./track.ts\";\nimport { Tracks as TracksMessage } from \"./tracks.ts\";\nimport {\n\thasAuth,\n\thasDatagrams,\n\thasDatagramTracks,\n\thasGoaway,\n\thasProbeRtt,\n\thasRoutes,\n\thasSetupStream,\n\thasTrackStream,\n\thasTracks,\n\tVersion,\n\tversionName,\n} from \"./version.ts\";\n\n/**\n * Constructor options for {@link Connection}.\n *\n * @internal\n */\nexport interface ConnectionProps {\n\t/** The URL of the connection. */\n\turl: URL;\n\t/** The established WebTransport session. */\n\tquic: WebTransport;\n\t/** The negotiated wire version. */\n\tversion: Version;\n\t/** The session stream, absent on drafts that have none. */\n\tsession?: Stream;\n\t/** The origin whose broadcasts are served to the peer. Omit to publish nothing. */\n\tpublish?: OriginConsumer;\n\t/** The auth handle to build the session on, or undefined for one of its own. */\n\thandle?: Auth.Handle;\n\t/**\n\t * Whether this side dialed. Only the dialing side aborts on a publication its grant does\n\t * not cover: a server publishes whatever the peer may read, not what it intends to push.\n\t * Defaults to true.\n\t */\n\tclient?: boolean;\n\t/** The connection credential the client's SETUP presents, on versions that carry one (lite-07+). */\n\ttoken?: Uint8Array;\n\t/** The implementation our SETUP advertises (lite-05+). Defaults to this library's; empty sends nothing. */\n\timplementation?: string;\n\t/** The PROBE target to send a peer that advertised `Increase`, in bits per second; zero sends none. */\n\tprobeTarget?: Getter<number>;\n\t/** The peer's liveness, on a transport that probes it; see {@link Session.liveness}. */\n\tliveness?: Getter<Liveness>;\n\t/** This link's price, declared in our SETUP and winning over the peer's (lite-06+). */\n\tcost?: Cost;\n\t/** This link's rank, which every route the peer sends carries at most. Defaults to 0. */\n\tpriority?: number;\n}\n\n/** Where a session is: open, delivering what it owes before it closes, or closed. */\n/** `leaving` is open but draining at this side's own request; see the wire view's `leave`. */\ntype Phase = { kind: \"open\" } | { kind: \"leaving\" } | { kind: \"closing\"; done: Promise<void> } | { kind: \"closed\" };\n\n/**\n * Represents a connection to a MoQ server.\n *\n * @internal\n */\nexport class Connection implements Session {\n\t#phase: Phase = { kind: \"open\" };\n\t// The URL of the connection.\n\treadonly url: URL;\n\n\t// The version of the connection as a human-readable string.\n\treadonly version: string;\n\n\t// The wire transport this session runs over.\n\treadonly transport: Transport;\n\n\t// The version used for encoding/decoding.\n\t#version: Version;\n\n\t// The established WebTransport session.\n\t#quic: WebTransport;\n\n\t// Use to receive/send session messages.\n\t#session?: Stream;\n\n\t// Module for contributing tracks.\n\t#publisher: Publisher;\n\n\t// Module for distributing tracks.\n\t#subscriber: Subscriber;\n\n\t// The received unidirectional streams still being read, which a closing session drains.\n\t#unis = new Set<Promise<void>>();\n\n\t/** The peer's PROBE estimates; see {@link Session.probe}. */\n\treadonly probe: Getter<Probe>;\n\n\t/** The peer's liveness, on a transport that probes it; see {@link Session.liveness}. */\n\treadonly liveness: Getter<Liveness> | undefined;\n\n\t// Our tokens and grants, and the answers to the peer's; see {@link Session.auth}.\n\t#auth: AuthSession;\n\n\t/** This side's Hop ID, shared by Publisher (for outbound hop chains) and Subscriber (to drop\n\t * what crossed us). Random per connection, except a lite-07 publisher's, which is its origin's. */\n\treadonly hop: Hop;\n\n\t// The peer's SETUP, recorded once its Setup stream is read (lite-05+). Streams whose\n\t// encoding depends on a negotiated capability (e.g. PROBE) wait on this. undefined\n\t// until the peer's SETUP arrives; stays undefined forever on older drafts.\n\t#peerSetup = new Signal<Setup | undefined>(undefined);\n\t#setupSeen = false;\n\t// Lite-07: the peer opened its one Announce Stream.\n\t#announceSeen = false;\n\t// The transport closed, so a stream breaking says nothing about the peer.\n\t#transportClosed = false;\n\n\t// Written by the Subscriber as PROBE messages arrive.\n\t#probe = new Observed<Probe>({});\n\n\t// Whether we dialed; see {@link ConnectionProps.client}.\n\t#client: boolean;\n\t// See {@link ConnectionProps.token}.\n\t#token?: Uint8Array;\n\t// What our SETUP advertises; see {@link ConnectionProps.implementation}.\n\t#implementation: string;\n\t// See {@link ConnectionProps.probeTarget}.\n\t#probeTarget?: Getter<number>;\n\t// See {@link ConnectionProps.cost}.\n\t#cost?: Cost;\n\t#peerImplementation = Promise.withResolvers<string | undefined>();\n\n\t/** The implementation the peer advertised; see {@link Session.peerImplementation}. */\n\treadonly peerImplementation = this.#peerImplementation.promise;\n\n\t// The peer's GOAWAY. Lite carries no deadline, so only the URI is set.\n\t#goaway = new Once<Received>();\n\n\t// How the session ended: `fromClose` of the transport's close, settled after auth lets go of it.\n\t#closed = new Once<Error | null>();\n\n\t/**\n\t * Creates a new Connection instance.\n\t *\n\t * @internal\n\t */\n\tconstructor({\n\t\turl,\n\t\tquic,\n\t\tversion,\n\t\tsession,\n\t\tpublish,\n\t\thandle,\n\t\tclient = true,\n\t\ttoken,\n\t\timplementation = IMPLEMENTATION,\n\t\tprobeTarget,\n\t\tliveness,\n\t\tcost,\n\t\tpriority = 0,\n\t}: ConnectionProps) {\n\t\tthis.liveness = liveness;\n\t\t// A free link would leave a route as cheap as the one it came from, so lite-07 refuses one.\n\t\tif (cost === 0n && hasRoutes(version)) throw new RangeError(\"a moq-lite-07 link cannot cost 0\");\n\t\tthis.#cost = cost;\n\t\tthis.url = url;\n\t\t// Older versions carry the credential in the URL instead.\n\t\tthis.#token = client && hasAuth(version) ? token : undefined;\n\t\tthis.#quic = quic;\n\t\tthis.#session = session;\n\t\t// The session stream was opened at the SETUP exchange's version; the rest of it speaks this one.\n\t\tif (session) {\n\t\t\tsession.reader.version = version;\n\t\t\tsession.writer.version = version;\n\t\t}\n\t\tthis.version = versionName(version);\n\t\tthis.#version = version;\n\t\tthis.transport = transportOf(quic);\n\t\tdetect(this, quic);\n\n\t\tthis.probe = this.#probe;\n\t\t// Opens waiting for credit make room after about this RTT when the transport has none.\n\t\tlines(quic).probe = this.#probe;\n\n\t\tthis.hop = randomHop();\n\t\t// What the peer's connection credential earns by default: publishing anything to us,\n\t\t// since we consume on demand, and subscribing to whatever we publish.\n\t\tthis.#auth = new AuthSession({\n\t\t\twire: hasAuth(version) ? new LiteAuthWire(quic, version) : undefined,\n\t\t\tpeerGrant: {\n\t\t\t\tpublish: Path.Prefixes.all(),\n\t\t\t\tsubscribe: publish ? Path.Prefixes.all() : new Path.Prefixes(),\n\t\t\t},\n\t\t\thandle,\n\t\t\tdraining: () => this.#goaway.peek() !== undefined || this.#phase.kind !== \"open\",\n\t\t\t// Without AUTH, the server checks a client's credential before its SETUP, which the client reads after going live.\n\t\t\tawaiting: client && hasSetupStream(version) && !hasAuth(version),\n\t\t\t// Lite-03/04 have neither, so the peer refuses the credential only by closing the\n\t\t\t// session. Lite-01/02 answered in the negotiation SETUP already read.\n\t\t\tsilent: client && (version === Version.DRAFT_03 || version === Version.DRAFT_04),\n\t\t});\n\t\t// Left before anything observes the close, so a successor on the same handle never\n\t\t// finds this session still active.\n\t\tconst leave = () => {\n\t\t\tthis.#transportClosed = true;\n\t\t\tthis.#auth.close();\n\t\t};\n\t\tvoid quic.closed.then(leave, leave);\n\t\tvoid quic.closed.then(\n\t\t\t(info) => this.#closed.set(fromClose(info)),\n\t\t\t(err: unknown) => this.#closed.set(error(err)),\n\t\t);\n\t\t// Lite-07: a send on this endpoint's Announce Stream failed while the session lives. On\n\t\t// native WebTransport, a peer that stopped it with no code of its own is leaving, as a\n\t\t// server closing the session stops it before its close arrives: the peer's routes end, and\n\t\t// the session's close says why. Otherwise what this endpoint said is lost and the session\n\t\t// cannot go on, as rs/moq-net closes it.\n\t\tif (hasRoutes(version)) {\n\t\t\tvoid AnnounceStream.of(quic, version).broken.then((err) => {\n\t\t\t\tif (this.#transportClosed || this.#phase.kind === \"closed\") return;\n\t\t\t\tif (peerEnded(quic, err)) return this.#subscriber.announceFinished();\n\t\t\t\t// Not a clean close: the peer learns that what this endpoint said was lost.\n\t\t\t\tquic.close({ closeCode: SessionCode.Internal, reason: closeReason(\"announce stream failed\") });\n\t\t\t\tthis.#fail(error(err));\n\t\t\t});\n\t\t}\n\t\tthis.#auth.violated.subscribe((err) => {\n\t\t\tif (!err) return;\n\t\t\tcloseViolation(this.#quic, err);\n\t\t\tthis.#fail(err);\n\t\t});\n\n\t\tthis.#publisher = new Publisher(this.#quic, this.#version, this.hop, publish, {\n\t\t\tgrant: this.#auth.scope,\n\t\t\tready: this.#auth.setupAnswered(),\n\t\t});\n\t\tthis.#subscriber = new Subscriber(\n\t\t\tthis.#quic,\n\t\t\tthis.#version,\n\t\t\tthis.hop,\n\t\t\tthis.#probe,\n\t\t\tthis.#peerSetup,\n\t\t\tthis.#goaway,\n\t\t\tthis.#auth.scope,\n\t\t\tundefined,\n\t\t\tthis.#auth,\n\t\t\t{ cost, priority },\n\t\t);\n\t\tthis.#client = client;\n\t\tthis.#implementation = implementation;\n\t\tthis.#probeTarget = probeTarget;\n\t\t// Only the lite-05+ Setup Stream carries it.\n\t\tif (!hasSetupStream(version)) this.#peerImplementation.resolve(undefined);\n\t\tregisterWire(this, {\n\t\t\tconsume: (path, identity) => this.#subscriber.consume(path, identity),\n\t\t\texclusive: false,\n\t\t\tleave: () => this.#leave(),\n\t\t\tauth: this.#auth,\n\t\t});\n\n\t\tvoid this.#run();\n\t}\n\n\t#leave(): void {\n\t\tif (this.#phase.kind !== \"open\") return;\n\t\tthis.#phase = { kind: \"leaving\" };\n\t\tif (!hasGoaway(this.#version)) return;\n\t\tconst version = this.#version;\n\t\tconst send = async () => {\n\t\t\tconst stream = await Stream.open(this.#quic, { version });\n\t\t\tawait stream.writer.u53(StreamId.Goaway);\n\t\t\tawait new Goaway(\"\").encode(stream.writer, version);\n\t\t\tstream.writer.close();\n\t\t};\n\t\t// A session closing first has nothing left to tell.\n\t\tsend().catch((err: unknown) => console.debug(\"failed to send GOAWAY:\", err));\n\t}\n\n\t/** Our tokens and grants; see {@link Session.auth}. */\n\tget auth(): Auth.Handle {\n\t\treturn this.#auth.handle;\n\t}\n\n\t/**\n\t * Withdraw announcements and finish the requests this session serves, waiting up to one\n\t * second for delivery before closing.\n\t *\n\t * A served subscription first delivers its remaining group streams, and from lite-05 also\n\t * waits for the subscriber's FIN, which says it read the tail. A live track never ends on\n\t * its own, so it holds the close until the deadline.\n\t */\n\tclose(): Promise<void> {\n\t\tswitch (this.#phase.kind) {\n\t\t\tcase \"open\":\n\t\t\tcase \"leaving\": {\n\t\t\t\t// Leaving finishes our Announce Stream, which asks the peer for nothing more.\n\t\t\t\tthis.#subscriber.announceSilenced();\n\t\t\t\tconst done = withTimeout(\n\t\t\t\t\tthis.#publisher.drain(),\n\t\t\t\t\tDuration.millis(1000),\n\t\t\t\t\t\"session close timed out\",\n\t\t\t\t).finally(() => this.abort());\n\t\t\t\tthis.#phase = { kind: \"closing\", done };\n\t\t\t\treturn done;\n\t\t\t}\n\t\t\tcase \"closing\":\n\t\t\t\treturn this.#phase.done;\n\t\t\tcase \"closed\":\n\t\t\t\treturn Promise.resolve();\n\t\t}\n\t}\n\n\t/** End the session immediately without waiting for delivery. */\n\tabort(): void {\n\t\tif (this.#phase.kind === \"closed\") return;\n\t\tthis.#phase = { kind: \"closed\" };\n\t\tthis.#auth.close();\n\t\tthis.#publisher.close();\n\t\t// Received tracks end in #run once what already arrived drains, as on the peer's close.\n\t\tthis.#closeTransport();\n\t}\n\n\t#closeTransport(): void {\n\t\ttry {\n\t\t\t// TODO: For whatever reason, this try/catch doesn't seem to work..?\n\t\t\tthis.#quic.close();\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\t}\n\n\t// End the received tracks with the session's end, then tear down the rest.\n\t#fail(err: Error): void {\n\t\tthis.#subscriber.close(err);\n\t\tthis.abort();\n\t}\n\n\tasync #run(): Promise<void> {\n\t\tconst unis = this.#runUnis();\n\t\tconst tasks: Promise<void>[] = [this.#runSession(), this.#runBidis(), unis];\n\n\t\tif (hasSetupStream(this.#version)) {\n\t\t\ttasks.push(this.#sendSetup());\n\t\t}\n\n\t\tconst probes = new Effect((effect) => {\n\t\t\tif (!effect.get(this.#probe.wanted)) return;\n\t\t\teffect.spawn(() => this.#subscriber.runProbe(effect.abort, this.#probeTarget));\n\t\t});\n\n\t\t// Fail loud on a publication our grant never covers, once the peer has answered the\n\t\t// credential we presented at setup.\n\t\tif (this.#client && hasAuth(this.#version)) {\n\t\t\ttasks.push(this.#publisher.runEnforce(this.#auth.setupAnswered(), this.#auth));\n\t\t}\n\n\t\t// Route incoming QUIC datagrams into their subscriptions (lite-05+; runDatagrams\n\t\t// no-ops on a transport that doesn't carry them).\n\t\tif (hasDatagrams(this.#version)) {\n\t\t\ttasks.push(this.#subscriber.runDatagrams());\n\t\t}\n\n\t\tlet fatal: Error | undefined;\n\t\ttry {\n\t\t\t// An application close rejects QMux's pending accepts with a teardown error.\n\t\t\t// The transport's close result owns that termination, rather than the task failure.\n\t\t\tawait Promise.race([Promise.all(tasks), this.#quic.closed]);\n\t\t} catch (err) {\n\t\t\tconsole.error(\"fatal error running connection\", err);\n\t\t\t// A session-sourced failure is the peer's close, not the raw transport error.\n\t\t\tfatal = await sessionCause(this.#quic, err);\n\t\t} finally {\n\t\t\tprobes.close();\n\t\t\t// A session that ends before the peer's SETUP never learns its implementation.\n\t\t\tthis.#peerImplementation.resolve(undefined);\n\t\t\tconst err = fatal ?? (await closeError(this.#quic));\n\t\t\t// A failed task can end the session over a live transport. Closing it first ends\n\t\t\t// every read the drain waits on.\n\t\t\tthis.#closeTransport();\n\t\t\t// The peer's close can overtake the group streams and SUBSCRIBE FIN it sent first.\n\t\t\t// Read what already arrived, so a track its publisher ended finishes rather than aborts.\n\t\t\t// Accepting yields to the host, so take the streams still queued before draining.\n\t\t\tawait unis.catch(() => {});\n\t\t\tawait Promise.all([...this.#unis, this.#subscriber.drain()]);\n\t\t\t// The session ended under every track it was receiving, so they end with its\n\t\t\t// error: a clean close from either side reads as a cancelled session.\n\t\t\tthis.#fail(err);\n\t\t}\n\t}\n\n\t/** The paths announced at or beneath `prefix`, each present or absent; see {@link Session.announced}. */\n\tannounced(prefix?: Path.Valid, options?: announce.Options): announce.Consumer {\n\t\treturn announce.list(this.#subscriber.routes(prefix, options));\n\t}\n\n\t/** Every route change at or beneath `prefix`, for code that forwards routes. @internal */\n\troutes(prefix?: Path.Valid, options?: announce.RouteOptions): announce.Routes {\n\t\treturn this.#subscriber.routes(prefix, options);\n\t}\n\n\tasync #runSession() {\n\t\tif (!this.#session) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tconst msg = await SessionInfo.decodeMaybe(this.#session.reader, this.#version);\n\t\t\t\tif (!msg) break;\n\t\t\t}\n\t\t} finally {\n\t\t\tconsole.debug(\"session stream closed\");\n\t\t}\n\t}\n\n\t// Open the unidirectional Setup Stream, send our single SETUP, and FIN (lite-05+).\n\t// The browser uses WebTransport, which carries the request URI, so we advertise no\n\t// path and leave routing to the URL. The probe level reflects what this transport\n\t// can actually measure; we never pad, so we never advertise Increase.\n\t// Role stays Both: the publish origin starts empty and fills later, and consume is\n\t// called after this point, so there is nothing to narrow yet. Before lite-07 the hop\n\t// declares our session identity so the peer can filter reflected announcements\n\t// (lite-06 removed ANNOUNCE_REQUEST's exclude_hop for it). Lite-07 sends none: only a node\n\t// that forwards declares a Node ID.\n\tasync #sendSetup(): Promise<void> {\n\t\tconst writer = await Writer.open(this.#quic, { version: this.#version });\n\t\ttry {\n\t\t\tawait writer.u53(DataType.Setup);\n\t\t\tconst probe = await probeLevel(this.#quic, this.#version);\n\t\t\tawait new Setup({\n\t\t\t\tprobe,\n\t\t\t\tcost: this.#cost,\n\t\t\t\thop: this.hop,\n\t\t\t\ttoken: this.#token,\n\t\t\t\timplementation: this.#implementation,\n\t\t\t}).encode(writer, this.#version);\n\t\t\twriter.close();\n\t\t} catch (err: unknown) {\n\t\t\twriter.reset(err);\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tasync #runBidis() {\n\t\tfor (;;) {\n\t\t\tconst stream = await Stream.accept(this.#quic, this.#version);\n\t\t\tif (!stream) break;\n\n\t\t\tthis.#runBidi(stream)\n\t\t\t\t.catch((err: unknown) => {\n\t\t\t\t\tstream.writer.reset(err);\n\t\t\t\t\tstream.reader.stop(err);\n\t\t\t\t\t// A protocol violation on one stream is the peer breaking the session.\n\t\t\t\t\t// Resetting that stream would leave it free to repeat malformed input.\n\t\t\t\t\tconst violation = closeViolation(this.#quic, err);\n\t\t\t\t\tif (violation) this.#fail(violation);\n\t\t\t\t})\n\t\t\t\t.finally(() => {\n\t\t\t\t\tstream.writer.close();\n\t\t\t\t});\n\t\t}\n\t}\n\n\tasync #runBidi(stream: Stream) {\n\t\tconst typ = await stream.reader.u53();\n\n\t\t// A type this version does not know, including one it predates, is an extension stream\n\t\t// opened without negotiating it: NOT_SUPPORTED resets the stream and keeps the session.\n\t\tif (typ === StreamId.Session) {\n\t\t\tthrow new ProtocolViolation(\"duplicate session stream\");\n\t\t} else if (typ === StreamId.Announce && !hasRoutes(this.#version)) {\n\t\t\t// Lite-07 asks on its Announce Stream instead, and knows no such stream type.\n\t\t\tconst msg = await AnnounceRequest.decode(stream.reader, this.#version);\n\t\t\tawait this.#publisher.runAnnounce(msg, stream);\n\t\t} else if (typ === StreamId.Subscribe) {\n\t\t\t// Owed from dispatch, so a close that lands mid-decode still waits for the request.\n\t\t\tawait this.#publisher.owe(\n\t\t\t\t(async () => {\n\t\t\t\t\tconst msg = await Subscribe.decode(stream.reader, this.#version);\n\t\t\t\t\tawait this.#publisher.runSubscribe(msg, stream);\n\t\t\t\t})(),\n\t\t\t);\n\t\t} else if (typ === StreamId.Datagrams) {\n\t\t\tif (!hasDatagramTracks(this.#version)) throw unsupported(\"DATAGRAMS\");\n\t\t\tawait this.#publisher.owe(\n\t\t\t\t(async () => {\n\t\t\t\t\tconst msg = await Datagrams.decode(stream.reader, this.#version);\n\t\t\t\t\tawait this.#publisher.runDatagrams(msg, stream);\n\t\t\t\t})(),\n\t\t\t);\n\t\t} else if (typ === StreamId.Track) {\n\t\t\tif (!hasTrackStream(this.#version)) throw unsupported(\"TRACK\");\n\t\t\tawait this.#publisher.owe(\n\t\t\t\t(async () => {\n\t\t\t\t\tconst msg = await TrackMessage.decode(stream.reader, this.#version);\n\t\t\t\t\tawait this.#publisher.runTrackInfo(msg, stream);\n\t\t\t\t})(),\n\t\t\t);\n\t\t} else if (typ === StreamId.Tracks) {\n\t\t\tif (!hasTracks(this.#version)) throw unsupported(\"TRACKS\");\n\t\t\tconst msg = await TracksMessage.decode(stream.reader, this.#version);\n\t\t\tawait this.#publisher.runTracks(msg, stream);\n\t\t} else if (typ === StreamId.Probe) {\n\t\t\tif (this.#version === Version.DRAFT_01 || this.#version === Version.DRAFT_02) throw unsupported(\"PROBE\");\n\t\t\tawait this.#publisher.runProbe(stream);\n\t\t} else if (typ === StreamId.Auth) {\n\t\t\tif (!hasAuth(this.#version)) throw unsupported(\"AUTH\");\n\t\t\tawait this.#auth.serve(stream);\n\t\t} else if (typ === StreamId.Goaway) {\n\t\t\tif (!hasGoaway(this.#version)) throw unsupported(\"GOAWAY\");\n\t\t\tconst msg = await Goaway.decode(stream.reader, this.#version);\n\t\t\t// A peer sends at most one; a second is a protocol violation.\n\t\t\tif (this.#goaway.peek() !== undefined) throw new ProtocolViolation(\"duplicate GOAWAY\");\n\t\t\tif (!this.#client && msg.uri !== \"\") throw new ProtocolViolation(\"client GOAWAY URI must be empty\");\n\t\t\tthis.#goaway.set({ uri: msg.uri });\n\t\t} else {\n\t\t\tthrow unsupported(`stream type ${typ.toString()}`);\n\t\t}\n\t}\n\n\tasync #runUnis() {\n\t\tconst readers = new Readers(this.#quic, this.#version);\n\n\t\tfor (;;) {\n\t\t\tconst stream = await readers.next();\n\t\t\tif (!stream) break;\n\n\t\t\tconst task = this.#runUni(stream)\n\t\t\t\t.then(() => {\n\t\t\t\t\tstream.stop(StreamCode.Cancel);\n\t\t\t\t})\n\t\t\t\t.catch((err: unknown) => {\n\t\t\t\t\tstream.stop(err);\n\t\t\t\t\tif (err instanceof ProtocolViolation) {\n\t\t\t\t\t\tcloseViolation(this.#quic, err);\n\t\t\t\t\t\tthis.#fail(err);\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.finally(() => this.#unis.delete(task));\n\t\t\tthis.#unis.add(task);\n\t\t}\n\t}\n\n\tasync #runUni(stream: Reader) {\n\t\tconst typ = await stream.u53();\n\t\tif (typ === DataType.Group) {\n\t\t\tconst msg = await Group.decode(stream, this.#version);\n\t\t\tawait this.#subscriber.runGroup(msg, stream);\n\t\t} else if (typ === DataType.Announce && hasRoutes(this.#version)) {\n\t\t\t// Claim the stream before reading it, so two that say nothing yet are duplicates too.\n\t\t\tif (this.#announceSeen) throw new ProtocolViolation(\"duplicate Announce Stream\");\n\t\t\tthis.#announceSeen = true;\n\t\t\tawait this.#runAnnounce(stream);\n\t\t} else if (typ === DataType.Setup) {\n\t\t\t// Claim the stream before decoding, so two incomplete SETUPs are duplicates too.\n\t\t\tif (this.#setupSeen) throw new ProtocolViolation(\"duplicate SETUP\");\n\t\t\tthis.#setupSeen = true;\n\t\t\t// The peer sends exactly one SETUP, then FINs. Record it so capability-gated\n\t\t\t// streams (e.g. PROBE) can react.\n\t\t\t// The slot is claimed, so no other SETUP can arrive and the streams waiting on it\n\t\t\t// would hang. The session cannot continue.\n\t\t\tconst setup = await Setup.decode(stream, this.#version).catch((err: unknown) => {\n\t\t\t\tthrow new ProtocolViolation(\"invalid SETUP\", { cause: err });\n\t\t\t});\n\t\t\tif (this.#client && hasClientParameters(setup))\n\t\t\t\tthrow new ProtocolViolation(\"server SETUP contains Path, Role, or Token\");\n\t\t\tif (!this.#client && setup.path !== undefined)\n\t\t\t\tthrow new ProtocolViolation(\"Path on a URI-carrying binding\");\n\t\t\tthis.#peerSetup.set(setup);\n\t\t\tthis.#auth.accept();\n\t\t\tthis.#peerImplementation.resolve(setup.implementation);\n\t\t} else {\n\t\t\tthrow new Error(`unknown stream type: ${typ.toString()}`);\n\t\t}\n\t}\n\n\t// Lite-07: everything the peer says about discovery and routing, in order, until it leaves.\n\t// The peer leaves by finishing the stream, or, on native WebTransport, resetting it with no\n\t// code of its own.\n\tasync #runAnnounce(stream: Reader) {\n\t\tfor (;;) {\n\t\t\tlet msg: AnnounceBroadcast | undefined;\n\t\t\ttry {\n\t\t\t\tmsg = await decodeAnnounceBroadcastMaybe(stream, this.#version);\n\t\t\t} catch (err: unknown) {\n\t\t\t\t// An ending session's own end says why. On native WebTransport, a peer that reset the\n\t\t\t\t// stream with no code of its own, even mid-message, is leaving: a server closing the\n\t\t\t\t// session resets it before its close arrives, with a code Chrome reports as an\n\t\t\t\t// application's 0. Any other reset, a message cut short, or one that does not decode\n\t\t\t\t// lost what the peer said.\n\t\t\t\tif (this.#transportClosed || this.#phase.kind === \"closed\") throw err;\n\t\t\t\tif (peerEnded(this.#quic, err)) break;\n\t\t\t\tthrow new ProtocolViolation(\"Announce Stream broke\", { cause: err });\n\t\t\t}\n\t\t\tif (!msg) break;\n\t\t\t// Nothing comes between the ANNOUNCE_REQUESTs of one edit.\n\t\t\tif (msg.status !== \"request\" && this.#publisher.continuing())\n\t\t\t\tthrow new ProtocolViolation(\"a message inside an edit\");\n\t\t\tawait this.#subscriber.announce(msg);\n\t\t\tif (msg.status === \"request\") this.#publisher.request(msg.more, msg.remove, msg.add);\n\t\t}\n\t\t// The peer is leaving: its routes end, and what it asked for is still answered.\n\t\tthis.#subscriber.announceFinished();\n\t}\n\n\t/** Snapshot the transport's counters; see {@link Session.stats}. */\n\tasync stats(): Promise<Stats> {\n\t\tconst stats = await transportStats(this.#quic);\n\t\tif (hasDatagrams(this.#version)) stats.datagramsUnrouted = this.#subscriber.datagramsUnrouted;\n\t\treturn stats;\n\t}\n\n\t/** Settles with the peer's GOAWAY; see {@link Session.draining}. */\n\tget draining(): GetPromise<Received> {\n\t\treturn this.#goaway;\n\t}\n\n\t/** Settles when the session closes, decoding the peer's close code; see {@link Session.closed}. */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#closed;\n\t}\n}\n\n// Refuses a bidirectional stream of a type this version does not serve.\nfunction unsupported(what: string): StreamError {\n\treturn new StreamError(StreamCode.NotSupported, { message: `${what} is not supported on this version` });\n}\n\n/**\n * The probe level to advertise in SETUP, from what the transport can measure.\n *\n * `Report` claims we can measure and periodically report, so it is only truthful\n * when a metric this version can carry actually exists. The qmux/WebSocket fallback\n * implements no `getStats()` at all, and even a transport that has one may report\n * neither figure. Advertising `Report` and then holding the subscriber's PROBE\n * stream open with nothing to send is the state this avoids; the subscriber's own\n * gate then skips a stream it could not use.\n *\n * Mirrors `ProbeLevel::detect` in `moq-net`, including its limitation: a metric\n * that only appears after SETUP reads as unsupported here.\n *\n * @internal\n */\nexport async function probeLevel(quic: WebTransport, version: Version): Promise<ProbeLevel> {\n\tconst getStats = statsOf(quic);\n\tif (!getStats) return ProbeLevel.None;\n\n\t// A transport that can't answer tells us nothing, which is itself an answer.\n\tlet stats: TransportStats;\n\ttry {\n\t\tstats = await getStats();\n\t} catch {\n\t\treturn ProbeLevel.None;\n\t}\n\n\tconst rtt = hasProbeRtt(version) ? stats.smoothedRtt : undefined;\n\treturn probeBitrate(stats.estimatedSendRate) !== undefined || rtt != null ? ProbeLevel.Report : ProbeLevel.None;\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The highest key a lite-05/06 subscription carried a datagram under, so its end can declare it.
|
|
3
|
+
*
|
|
4
|
+
* A datagram's key is its timestamp, in the groups' space and sparse beside a stream track's
|
|
5
|
+
* groups. A released client counts it as a group and rejects an end at or below it, so the end
|
|
6
|
+
* rises above every datagram sent and drops everything above the stream's own end. Mirrors the
|
|
7
|
+
* Rust `DatagramEnd`.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
export declare class DatagramEnd {
|
|
12
|
+
#private;
|
|
13
|
+
/** Note that a datagram went out under `key`. */
|
|
14
|
+
record(key: bigint): void;
|
|
15
|
+
/**
|
|
16
|
+
* SUBSCRIBE_END's exclusive end given the stream track's own, `floor`, and the span `floor..end`
|
|
17
|
+
* to drop first, which the stream owes nothing in: its groups end at `floor`, so a datagram's
|
|
18
|
+
* key there is accounted without a stream, and no key waits out the subscriber's tail grace.
|
|
19
|
+
* A drop over a key a datagram already took is a no-op for the subscriber.
|
|
20
|
+
*/
|
|
21
|
+
settle(floor: bigint): {
|
|
22
|
+
end: bigint;
|
|
23
|
+
span?: [bigint, bigint];
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=datagram-end.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datagram-end.d.ts","sourceRoot":"","sources":["../../src/lite/datagram-end.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,qBAAa,WAAW;;IAIvB,iDAAiD;IACjD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAExB;IAED;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAG9D;CACD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The highest key a lite-05/06 subscription carried a datagram under, so its end can declare it.
|
|
3
|
+
*
|
|
4
|
+
* A datagram's key is its timestamp, in the groups' space and sparse beside a stream track's
|
|
5
|
+
* groups. A released client counts it as a group and rejects an end at or below it, so the end
|
|
6
|
+
* rises above every datagram sent and drops everything above the stream's own end. Mirrors the
|
|
7
|
+
* Rust `DatagramEnd`.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
export class DatagramEnd {
|
|
12
|
+
// One past the highest key sent.
|
|
13
|
+
#end = 0n;
|
|
14
|
+
/** Note that a datagram went out under `key`. */
|
|
15
|
+
record(key) {
|
|
16
|
+
if (key + 1n > this.#end)
|
|
17
|
+
this.#end = key + 1n;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* SUBSCRIBE_END's exclusive end given the stream track's own, `floor`, and the span `floor..end`
|
|
21
|
+
* to drop first, which the stream owes nothing in: its groups end at `floor`, so a datagram's
|
|
22
|
+
* key there is accounted without a stream, and no key waits out the subscriber's tail grace.
|
|
23
|
+
* A drop over a key a datagram already took is a no-op for the subscriber.
|
|
24
|
+
*/
|
|
25
|
+
settle(floor) {
|
|
26
|
+
const end = this.#end > floor ? this.#end : floor;
|
|
27
|
+
return end > floor ? { end, span: [floor, end] } : { end };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=datagram-end.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datagram-end.js","sourceRoot":"","sources":["../../src/lite/datagram-end.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,OAAO,WAAW;IACvB,iCAAiC;IACjC,IAAI,GAAG,EAAE,CAAC;IAEV,iDAAiD;IACjD,MAAM,CAAC,GAAW;QACjB,IAAI,GAAG,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI;YAAE,IAAI,CAAC,IAAI,GAAG,GAAG,GAAG,EAAE,CAAC;IAChD,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,KAAa;QACnB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;QAClD,OAAO,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC;IAC5D,CAAC;CACD","sourcesContent":["/**\n * The highest key a lite-05/06 subscription carried a datagram under, so its end can declare it.\n *\n * A datagram's key is its timestamp, in the groups' space and sparse beside a stream track's\n * groups. A released client counts it as a group and rejects an end at or below it, so the end\n * rises above every datagram sent and drops everything above the stream's own end. Mirrors the\n * Rust `DatagramEnd`.\n *\n * @module\n */\n\nexport class DatagramEnd {\n\t// One past the highest key sent.\n\t#end = 0n;\n\n\t/** Note that a datagram went out under `key`. */\n\trecord(key: bigint): void {\n\t\tif (key + 1n > this.#end) this.#end = key + 1n;\n\t}\n\n\t/**\n\t * SUBSCRIBE_END's exclusive end given the stream track's own, `floor`, and the span `floor..end`\n\t * to drop first, which the stream owes nothing in: its groups end at `floor`, so a datagram's\n\t * key there is accounted without a stream, and no key waits out the subscriber's tail grace.\n\t * A drop over a key a datagram already took is a no-op for the subscriber.\n\t */\n\tsettle(floor: bigint): { end: bigint; span?: [bigint, bigint] } {\n\t\tconst end = this.#end > floor ? this.#end : floor;\n\t\treturn end > floor ? { end, span: [floor, end] } : { end };\n\t}\n}\n"]}
|
package/lite/datagram.d.ts
CHANGED
|
@@ -1,24 +1,89 @@
|
|
|
1
|
-
import type { Version } from "./version";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* Wire-level QUIC datagram bodies for moq-lite.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type * as Identity from "../identity.ts";
|
|
7
|
+
import * as Path from "../path.ts";
|
|
8
|
+
import { Reader, type Writer } from "../stream.ts";
|
|
9
|
+
import { Timescale } from "../time.ts";
|
|
10
|
+
import { type Version } from "./version.ts";
|
|
11
|
+
/**
|
|
12
|
+
* A QUIC datagram body: lite-05/06 carry `subscribe (i) | sequence (i) | timestamp (i) | payload (b)`;
|
|
13
|
+
* lite-07 carries `type (i) = 0x0 | subscribe (i) | timestamp (i) | payload (b)`, its only
|
|
14
|
+
* datagram type, with no sequence.
|
|
4
15
|
*
|
|
5
16
|
* The payload runs to the datagram boundary, so unlike a size-prefixed lite message there is no
|
|
6
17
|
* inner length prefix. Mirrors the Rust `lite::Datagram`; the model counterpart is
|
|
7
18
|
* {@link Datagram} in `../datagram.ts`.
|
|
8
19
|
*/
|
|
9
20
|
export declare class Datagram {
|
|
21
|
+
/** The largest encoded datagram body a lite hop carries. */
|
|
22
|
+
static readonly MAX_SIZE = 1200;
|
|
10
23
|
/** Subscribe ID this datagram is delivered on. */
|
|
11
24
|
subscribe: bigint;
|
|
12
|
-
/**
|
|
13
|
-
sequence:
|
|
14
|
-
/**
|
|
15
|
-
|
|
25
|
+
/** The datagram's group sequence on lite-05/06; `undefined` on lite-07, which has none. */
|
|
26
|
+
sequence: bigint | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* The datagram's key in the track's wire timescale. A scale-less track's is the bare value its
|
|
29
|
+
* producer gave.
|
|
30
|
+
*/
|
|
31
|
+
timestamp: bigint;
|
|
16
32
|
/** The frame payload, delimited by the datagram boundary. */
|
|
17
33
|
payload: Uint8Array;
|
|
18
|
-
constructor(subscribe: bigint, sequence:
|
|
34
|
+
constructor(subscribe: bigint, sequence: bigint | undefined, timestamp: bigint, payload: Uint8Array);
|
|
19
35
|
/** Encode the body to a single `Uint8Array` (no length prefix; the datagram boundary delimits it). */
|
|
20
36
|
encode(version: Version): Uint8Array;
|
|
21
|
-
/** Decode a datagram body
|
|
37
|
+
/** Decode a datagram body. An unknown lite-07 type throws, so the caller discards it. */
|
|
22
38
|
static decode(data: Uint8Array, version: Version): Promise<Datagram>;
|
|
23
39
|
}
|
|
40
|
+
/** The subscriber's first message on a Datagrams Stream (0x9), live from now. */
|
|
41
|
+
export declare class Datagrams {
|
|
42
|
+
/** The shared SUBSCRIBE/DATAGRAMS identifier space. */
|
|
43
|
+
id: bigint;
|
|
44
|
+
/** The requested broadcast path. */
|
|
45
|
+
broadcast: Path.Valid;
|
|
46
|
+
/** The publisher identity the subscriber expects. */
|
|
47
|
+
identity?: Identity.Valid;
|
|
48
|
+
/** The datagram track's name. */
|
|
49
|
+
track: string;
|
|
50
|
+
/** The subscriber priority, higher first. */
|
|
51
|
+
priority: number;
|
|
52
|
+
constructor(properties: {
|
|
53
|
+
id: bigint;
|
|
54
|
+
broadcast: Path.Valid;
|
|
55
|
+
identity?: Identity.Valid;
|
|
56
|
+
track: string;
|
|
57
|
+
priority: number;
|
|
58
|
+
});
|
|
59
|
+
/** Encode the size-prefixed request. */
|
|
60
|
+
encode(writer: Writer, version: Version): Promise<void>;
|
|
61
|
+
/** Decode the size-prefixed request. */
|
|
62
|
+
static decode(reader: Reader, version: Version): Promise<Datagrams>;
|
|
63
|
+
}
|
|
64
|
+
/** A subscriber priority update on a Datagrams Stream. */
|
|
65
|
+
export declare class DatagramsUpdate {
|
|
66
|
+
/** The subscriber's replacement priority. */
|
|
67
|
+
priority: number;
|
|
68
|
+
constructor(priority: number);
|
|
69
|
+
/** Encode the size-prefixed update. */
|
|
70
|
+
encode(writer: Writer, version: Version): Promise<void>;
|
|
71
|
+
/** Decode an update, or undefined at the subscriber's FIN. */
|
|
72
|
+
static decodeMaybe(reader: Reader, version: Version): Promise<DatagramsUpdate | undefined>;
|
|
73
|
+
}
|
|
74
|
+
/** The publisher's sole answer on a Datagrams Stream, fixing timestamp framing. */
|
|
75
|
+
export declare class DatagramsInfo {
|
|
76
|
+
/** Publisher priority, breaking ties at one subscriber priority. */
|
|
77
|
+
priority: number;
|
|
78
|
+
/** Timestamp units per second, or undefined for an untimed track. */
|
|
79
|
+
timescale?: Timescale;
|
|
80
|
+
constructor(properties: {
|
|
81
|
+
priority: number;
|
|
82
|
+
timescale?: Timescale | null;
|
|
83
|
+
});
|
|
84
|
+
/** Encode the size-prefixed answer. */
|
|
85
|
+
encode(writer: Writer, version: Version): Promise<void>;
|
|
86
|
+
/** Decode the publisher properties. */
|
|
87
|
+
static decode(reader: Reader, version: Version): Promise<DatagramsInfo>;
|
|
88
|
+
}
|
|
24
89
|
//# sourceMappingURL=datagram.d.ts.map
|
package/lite/datagram.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datagram.d.ts","sourceRoot":"","sources":["../../src/lite/datagram.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"datagram.d.ts","sourceRoot":"","sources":["../../src/lite/datagram.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,OAAO,EAAgB,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EAAmC,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAE7E;;;;;;;;GAQG;AACH,qBAAa,QAAQ;IACpB,4DAA4D;IAC5D,MAAM,CAAC,QAAQ,CAAC,QAAQ,QAAQ;IAEhC,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,2FAA2F;IAC3F,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,OAAO,EAAE,UAAU,CAAC;IAEpB,YAAY,SAAS,EAAE,MAAM,EAAE,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IAAI,CAAC,CAK5D;IACD,8DAA8D;IAC9D,OAAa,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAG/F;CACD;AAED,mFAAmF;AACnF,qBAAa,aAAa;IACzB,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,YAAY,UAAU,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,CAAA;KAAE,EAGzE;IACD,uCAAuC;IACjC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAM5D;IACD,uCAAuC;IACvC,OAAa,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAO5E;CACD"}
|
package/lite/datagram.js
CHANGED
|
@@ -1,23 +1,35 @@
|
|
|
1
|
-
/* @ts-self-types="./datagram.d.ts" */
|
|
2
1
|
/**
|
|
3
|
-
* Wire-level QUIC datagram
|
|
2
|
+
* Wire-level QUIC datagram bodies for moq-lite.
|
|
4
3
|
*
|
|
5
4
|
* @module
|
|
6
5
|
*/
|
|
6
|
+
import * as Path from "../path.js";
|
|
7
7
|
import { encodeVarint, Reader } from "../stream.js";
|
|
8
|
+
import { Timescale } from "../time.js";
|
|
9
|
+
import { decodeNode, decodePin, encodeNode, encodePin } from "./identity.js";
|
|
10
|
+
import * as Message from "./message.js";
|
|
11
|
+
import { fromWire, toWire } from "./priority.js";
|
|
12
|
+
import { hasDatagrams, hasDatagramTracks } from "./version.js";
|
|
8
13
|
/**
|
|
9
|
-
* A QUIC datagram body: `subscribe (i) | sequence (i) | timestamp (i) | payload (b)
|
|
14
|
+
* A QUIC datagram body: lite-05/06 carry `subscribe (i) | sequence (i) | timestamp (i) | payload (b)`;
|
|
15
|
+
* lite-07 carries `type (i) = 0x0 | subscribe (i) | timestamp (i) | payload (b)`, its only
|
|
16
|
+
* datagram type, with no sequence.
|
|
10
17
|
*
|
|
11
18
|
* The payload runs to the datagram boundary, so unlike a size-prefixed lite message there is no
|
|
12
19
|
* inner length prefix. Mirrors the Rust `lite::Datagram`; the model counterpart is
|
|
13
20
|
* {@link Datagram} in `../datagram.ts`.
|
|
14
21
|
*/
|
|
15
22
|
export class Datagram {
|
|
23
|
+
/** The largest encoded datagram body a lite hop carries. */
|
|
24
|
+
static MAX_SIZE = 1200;
|
|
16
25
|
/** Subscribe ID this datagram is delivered on. */
|
|
17
26
|
subscribe;
|
|
18
|
-
/**
|
|
27
|
+
/** The datagram's group sequence on lite-05/06; `undefined` on lite-07, which has none. */
|
|
19
28
|
sequence;
|
|
20
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* The datagram's key in the track's wire timescale. A scale-less track's is the bare value its
|
|
31
|
+
* producer gave.
|
|
32
|
+
*/
|
|
21
33
|
timestamp;
|
|
22
34
|
/** The frame payload, delimited by the datagram boundary. */
|
|
23
35
|
payload;
|
|
@@ -29,11 +41,25 @@ export class Datagram {
|
|
|
29
41
|
}
|
|
30
42
|
/** Encode the body to a single `Uint8Array` (no length prefix; the datagram boundary delimits it). */
|
|
31
43
|
encode(version) {
|
|
44
|
+
if (!hasDatagrams(version))
|
|
45
|
+
throw new Error("datagrams require lite-05 or newer");
|
|
32
46
|
const subscribe = encodeVarint(this.subscribe, version);
|
|
33
|
-
|
|
47
|
+
let sequence = new Uint8Array();
|
|
48
|
+
if (!hasDatagramTracks(version)) {
|
|
49
|
+
if (this.sequence === undefined)
|
|
50
|
+
throw new Error("a lite-05/06 datagram needs its sequence");
|
|
51
|
+
sequence = encodeVarint(this.sequence, version);
|
|
52
|
+
}
|
|
34
53
|
const timestamp = encodeVarint(this.timestamp, version);
|
|
35
|
-
const
|
|
54
|
+
const type = hasDatagramTracks(version) ? encodeVarint(0x0, version) : new Uint8Array();
|
|
55
|
+
const out = new Uint8Array(type.byteLength +
|
|
56
|
+
subscribe.byteLength +
|
|
57
|
+
sequence.byteLength +
|
|
58
|
+
timestamp.byteLength +
|
|
59
|
+
this.payload.byteLength);
|
|
36
60
|
let offset = 0;
|
|
61
|
+
out.set(type, offset);
|
|
62
|
+
offset += type.byteLength;
|
|
37
63
|
out.set(subscribe, offset);
|
|
38
64
|
offset += subscribe.byteLength;
|
|
39
65
|
out.set(sequence, offset);
|
|
@@ -43,14 +69,122 @@ export class Datagram {
|
|
|
43
69
|
out.set(this.payload, offset);
|
|
44
70
|
return out;
|
|
45
71
|
}
|
|
46
|
-
/** Decode a datagram body
|
|
72
|
+
/** Decode a datagram body. An unknown lite-07 type throws, so the caller discards it. */
|
|
47
73
|
static async decode(data, version) {
|
|
74
|
+
if (!hasDatagrams(version))
|
|
75
|
+
throw new Error("datagrams require lite-05 or newer");
|
|
48
76
|
const r = new Reader(undefined, data, version);
|
|
77
|
+
if (hasDatagramTracks(version)) {
|
|
78
|
+
const type = await r.u62();
|
|
79
|
+
if (type !== 0n)
|
|
80
|
+
throw new Error(`unknown datagram type: ${type}`);
|
|
81
|
+
}
|
|
49
82
|
const subscribe = await r.u62();
|
|
50
|
-
const sequence = await r.
|
|
51
|
-
const timestamp = await r.
|
|
83
|
+
const sequence = hasDatagramTracks(version) ? undefined : await r.u62();
|
|
84
|
+
const timestamp = await r.u62();
|
|
52
85
|
const payload = await r.readAll();
|
|
53
86
|
return new Datagram(subscribe, sequence, timestamp, payload);
|
|
54
87
|
}
|
|
55
88
|
}
|
|
89
|
+
function guard(version) {
|
|
90
|
+
if (!hasDatagramTracks(version))
|
|
91
|
+
throw new Error("datagram tracks require lite-07 or newer");
|
|
92
|
+
}
|
|
93
|
+
/** The subscriber's first message on a Datagrams Stream (0x9), live from now. */
|
|
94
|
+
export class Datagrams {
|
|
95
|
+
/** The shared SUBSCRIBE/DATAGRAMS identifier space. */
|
|
96
|
+
id;
|
|
97
|
+
/** The requested broadcast path. */
|
|
98
|
+
broadcast;
|
|
99
|
+
/** The publisher identity the subscriber expects. */
|
|
100
|
+
identity;
|
|
101
|
+
/** The datagram track's name. */
|
|
102
|
+
track;
|
|
103
|
+
/** The subscriber priority, higher first. */
|
|
104
|
+
priority;
|
|
105
|
+
constructor(properties) {
|
|
106
|
+
this.identity = properties.identity;
|
|
107
|
+
this.id = properties.id;
|
|
108
|
+
this.broadcast = properties.broadcast;
|
|
109
|
+
this.track = properties.track;
|
|
110
|
+
this.priority = properties.priority;
|
|
111
|
+
}
|
|
112
|
+
/** Encode the size-prefixed request. */
|
|
113
|
+
async encode(writer, version) {
|
|
114
|
+
guard(version);
|
|
115
|
+
await Message.encode(writer, async (w) => {
|
|
116
|
+
await w.u62(this.id);
|
|
117
|
+
await w.string(Path.encode(this.broadcast));
|
|
118
|
+
await encodePin(w, version, this.identity);
|
|
119
|
+
await encodeNode(w, version);
|
|
120
|
+
await w.string(this.track);
|
|
121
|
+
await w.u8(toWire(this.priority));
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/** Decode the size-prefixed request. */
|
|
125
|
+
static async decode(reader, version) {
|
|
126
|
+
guard(version);
|
|
127
|
+
return Message.decode(reader, async (r) => {
|
|
128
|
+
const id = await r.u62();
|
|
129
|
+
const broadcast = Path.decode(await r.string());
|
|
130
|
+
const identity = await decodePin(r, version);
|
|
131
|
+
await decodeNode(r, version);
|
|
132
|
+
return new Datagrams({
|
|
133
|
+
id,
|
|
134
|
+
broadcast,
|
|
135
|
+
identity,
|
|
136
|
+
track: await r.string(),
|
|
137
|
+
priority: fromWire(await r.u8()),
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/** A subscriber priority update on a Datagrams Stream. */
|
|
143
|
+
export class DatagramsUpdate {
|
|
144
|
+
/** The subscriber's replacement priority. */
|
|
145
|
+
priority;
|
|
146
|
+
constructor(priority) {
|
|
147
|
+
this.priority = priority;
|
|
148
|
+
}
|
|
149
|
+
/** Encode the size-prefixed update. */
|
|
150
|
+
async encode(writer, version) {
|
|
151
|
+
guard(version);
|
|
152
|
+
await Message.encode(writer, async (w) => {
|
|
153
|
+
await w.u8(toWire(this.priority));
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/** Decode an update, or undefined at the subscriber's FIN. */
|
|
157
|
+
static async decodeMaybe(reader, version) {
|
|
158
|
+
guard(version);
|
|
159
|
+
return Message.decodeMaybe(reader, async (r) => new DatagramsUpdate(fromWire(await r.u8())));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/** The publisher's sole answer on a Datagrams Stream, fixing timestamp framing. */
|
|
163
|
+
export class DatagramsInfo {
|
|
164
|
+
/** Publisher priority, breaking ties at one subscriber priority. */
|
|
165
|
+
priority;
|
|
166
|
+
/** Timestamp units per second, or undefined for an untimed track. */
|
|
167
|
+
timescale;
|
|
168
|
+
constructor(properties) {
|
|
169
|
+
this.priority = properties.priority;
|
|
170
|
+
this.timescale = properties.timescale ?? undefined;
|
|
171
|
+
}
|
|
172
|
+
/** Encode the size-prefixed answer. */
|
|
173
|
+
async encode(writer, version) {
|
|
174
|
+
guard(version);
|
|
175
|
+
await Message.encode(writer, async (w) => {
|
|
176
|
+
await w.u8(toWire(this.priority));
|
|
177
|
+
await w.u53(this.timescale ?? 0);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/** Decode the publisher properties. */
|
|
181
|
+
static async decode(reader, version) {
|
|
182
|
+
guard(version);
|
|
183
|
+
return Message.decode(reader, async (r) => {
|
|
184
|
+
const priority = fromWire(await r.u8());
|
|
185
|
+
const scale = await r.u53();
|
|
186
|
+
return new DatagramsInfo({ priority, timescale: scale === 0 ? undefined : Timescale(scale) });
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
56
190
|
//# sourceMappingURL=datagram.js.map
|
package/lite/datagram.js.map
CHANGED
|
@@ -1 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IAAI,QAAQ,CAAC,UAAU,CAAC;QAC9B,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAC3B,MAAM,IAAI,SAAS,CAAC,UAAU,CAAC;QAC/B,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC9B,OAAO,GAAG,CAAC;IACZ,CAAC;IAED,sEAAsE;IACtE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAgB,EAAE,OAAgB;QACrD,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/C,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;QAC/B,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;QAChC,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;QAClC,OAAO,IAAI,QAAQ,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;CACD","sourcesContent":["/**\n * Wire-level QUIC datagram body for moq-lite-05 (§6.4).\n *\n * @module\n */\nimport { encodeVarint, Reader } from \"../stream.ts\";\nimport type { Version } from \"./version.ts\";\n\n/**\n * A QUIC datagram body: `subscribe (i) | sequence (i) | timestamp (i) | payload (b)`.\n *\n * The payload runs to the datagram boundary, so unlike a size-prefixed lite message there is no\n * inner length prefix. Mirrors the Rust `lite::Datagram`; the model counterpart is\n * {@link Datagram} in `../datagram.ts`.\n */\nexport class Datagram {\n\t/** Subscribe ID this datagram is delivered on. */\n\tsubscribe: bigint;\n\t/** Group sequence number (shared with the track's group namespace). */\n\tsequence: number;\n\t/** Absolute presentation timestamp, in the track's negotiated timescale. */\n\ttimestamp: number;\n\t/** The frame payload, delimited by the datagram boundary. */\n\tpayload: Uint8Array;\n\n\tconstructor(subscribe: bigint, sequence: number, timestamp: number, payload: Uint8Array) {\n\t\tthis.subscribe = subscribe;\n\t\tthis.sequence = sequence;\n\t\tthis.timestamp = timestamp;\n\t\tthis.payload = payload;\n\t}\n\n\t/** Encode the body to a single `Uint8Array` (no length prefix; the datagram boundary delimits it). */\n\tencode(version: Version): Uint8Array {\n\t\tconst subscribe = encodeVarint(this.subscribe, version);\n\t\tconst sequence = encodeVarint(this.sequence, version);\n\t\tconst timestamp = encodeVarint(this.timestamp, version);\n\n\t\tconst out = new Uint8Array(\n\t\t\tsubscribe.byteLength + sequence.byteLength + timestamp.byteLength + this.payload.byteLength,\n\t\t);\n\t\tlet offset = 0;\n\t\tout.set(subscribe, offset);\n\t\toffset += subscribe.byteLength;\n\t\tout.set(sequence, offset);\n\t\toffset += sequence.byteLength;\n\t\tout.set(timestamp, offset);\n\t\toffset += timestamp.byteLength;\n\t\tout.set(this.payload, offset);\n\t\treturn out;\n\t}\n\n\t/** Decode a datagram body from the raw bytes of one QUIC datagram. */\n\tstatic async decode(data: Uint8Array, version: Version): Promise<Datagram> {\n\t\tconst r = new Reader(undefined, data, version);\n\t\tconst subscribe = await r.u62();\n\t\tconst sequence = await r.u53();\n\t\tconst timestamp = await r.u53();\n\t\tconst payload = await r.readAll();\n\t\treturn new Datagram(subscribe, sequence, timestamp, payload);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"datagram.js","sourceRoot":"","sources":["../../src/lite/datagram.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAe,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,KAAK,OAAO,MAAM,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AK,EAAE,CAAC,EAAE,EAAE;YACxC,MAAM,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAClC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACJ,CAAC;IACD,uCAAuC;IACvC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAc,EAAE,OAAgB;QACnD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;YACzC,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACxC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;YAC5B,OAAO,IAAI,aAAa,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC/F,CAAC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["/**\n * Wire-level QUIC datagram bodies for moq-lite.\n *\n * @module\n */\n\nimport type * as Identity from \"../identity.ts\";\nimport * as Path from \"../path.ts\";\nimport { encodeVarint, Reader, type Writer } from \"../stream.ts\";\nimport { Timescale } from \"../time.ts\";\nimport { decodeNode, decodePin, encodeNode, encodePin } from \"./identity.ts\";\nimport * as Message from \"./message.ts\";\nimport { fromWire, toWire } from \"./priority.ts\";\nimport { hasDatagrams, hasDatagramTracks, type Version } from \"./version.ts\";\n\n/**\n * A QUIC datagram body: lite-05/06 carry `subscribe (i) | sequence (i) | timestamp (i) | payload (b)`;\n * lite-07 carries `type (i) = 0x0 | subscribe (i) | timestamp (i) | payload (b)`, its only\n * datagram type, with no sequence.\n *\n * The payload runs to the datagram boundary, so unlike a size-prefixed lite message there is no\n * inner length prefix. Mirrors the Rust `lite::Datagram`; the model counterpart is\n * {@link Datagram} in `../datagram.ts`.\n */\nexport class Datagram {\n\t/** The largest encoded datagram body a lite hop carries. */\n\tstatic readonly MAX_SIZE = 1200;\n\n\t/** Subscribe ID this datagram is delivered on. */\n\tsubscribe: bigint;\n\t/** The datagram's group sequence on lite-05/06; `undefined` on lite-07, which has none. */\n\tsequence: bigint | undefined;\n\t/**\n\t * The datagram's key in the track's wire timescale. A scale-less track's is the bare value its\n\t * producer gave.\n\t */\n\ttimestamp: bigint;\n\t/** The frame payload, delimited by the datagram boundary. */\n\tpayload: Uint8Array;\n\n\tconstructor(subscribe: bigint, sequence: bigint | undefined, timestamp: bigint, payload: Uint8Array) {\n\t\tthis.subscribe = subscribe;\n\t\tthis.sequence = sequence;\n\t\tthis.timestamp = timestamp;\n\t\tthis.payload = payload;\n\t}\n\n\t/** Encode the body to a single `Uint8Array` (no length prefix; the datagram boundary delimits it). */\n\tencode(version: Version): Uint8Array {\n\t\tif (!hasDatagrams(version)) throw new Error(\"datagrams require lite-05 or newer\");\n\t\tconst subscribe = encodeVarint(this.subscribe, version);\n\t\tlet sequence: Uint8Array = new Uint8Array();\n\t\tif (!hasDatagramTracks(version)) {\n\t\t\tif (this.sequence === undefined) throw new Error(\"a lite-05/06 datagram needs its sequence\");\n\t\t\tsequence = encodeVarint(this.sequence, version);\n\t\t}\n\t\tconst timestamp = encodeVarint(this.timestamp, version);\n\t\tconst type = hasDatagramTracks(version) ? encodeVarint(0x0, version) : new Uint8Array();\n\n\t\tconst out = new Uint8Array(\n\t\t\ttype.byteLength +\n\t\t\t\tsubscribe.byteLength +\n\t\t\t\tsequence.byteLength +\n\t\t\t\ttimestamp.byteLength +\n\t\t\t\tthis.payload.byteLength,\n\t\t);\n\t\tlet offset = 0;\n\t\tout.set(type, offset);\n\t\toffset += type.byteLength;\n\t\tout.set(subscribe, offset);\n\t\toffset += subscribe.byteLength;\n\t\tout.set(sequence, offset);\n\t\toffset += sequence.byteLength;\n\t\tout.set(timestamp, offset);\n\t\toffset += timestamp.byteLength;\n\t\tout.set(this.payload, offset);\n\t\treturn out;\n\t}\n\n\t/** Decode a datagram body. An unknown lite-07 type throws, so the caller discards it. */\n\tstatic async decode(data: Uint8Array, version: Version): Promise<Datagram> {\n\t\tif (!hasDatagrams(version)) throw new Error(\"datagrams require lite-05 or newer\");\n\t\tconst r = new Reader(undefined, data, version);\n\t\tif (hasDatagramTracks(version)) {\n\t\t\tconst type = await r.u62();\n\t\t\tif (type !== 0n) throw new Error(`unknown datagram type: ${type}`);\n\t\t}\n\t\tconst subscribe = await r.u62();\n\t\tconst sequence = hasDatagramTracks(version) ? undefined : await r.u62();\n\t\tconst timestamp = await r.u62();\n\t\tconst payload = await r.readAll();\n\t\treturn new Datagram(subscribe, sequence, timestamp, payload);\n\t}\n}\n\nfunction guard(version: Version): void {\n\tif (!hasDatagramTracks(version)) throw new Error(\"datagram tracks require lite-07 or newer\");\n}\n\n/** The subscriber's first message on a Datagrams Stream (0x9), live from now. */\nexport class Datagrams {\n\t/** The shared SUBSCRIBE/DATAGRAMS identifier space. */\n\tid: bigint;\n\t/** The requested broadcast path. */\n\tbroadcast: Path.Valid;\n\t/** The publisher identity the subscriber expects. */\n\tidentity?: Identity.Valid;\n\t/** The datagram track's name. */\n\ttrack: string;\n\t/** The subscriber priority, higher first. */\n\tpriority: number;\n\n\tconstructor(properties: {\n\t\tid: bigint;\n\t\tbroadcast: Path.Valid;\n\t\tidentity?: Identity.Valid;\n\t\ttrack: string;\n\t\tpriority: number;\n\t}) {\n\t\tthis.identity = properties.identity;\n\t\tthis.id = properties.id;\n\t\tthis.broadcast = properties.broadcast;\n\t\tthis.track = properties.track;\n\t\tthis.priority = properties.priority;\n\t}\n\n\t/** Encode the size-prefixed request. */\n\tasync encode(writer: Writer, version: Version): Promise<void> {\n\t\tguard(version);\n\t\tawait Message.encode(writer, async (w) => {\n\t\t\tawait w.u62(this.id);\n\t\t\tawait w.string(Path.encode(this.broadcast));\n\t\t\tawait encodePin(w, version, this.identity);\n\t\t\tawait encodeNode(w, version);\n\t\t\tawait w.string(this.track);\n\t\t\tawait w.u8(toWire(this.priority));\n\t\t});\n\t}\n\n\t/** Decode the size-prefixed request. */\n\tstatic async decode(reader: Reader, version: Version): Promise<Datagrams> {\n\t\tguard(version);\n\t\treturn Message.decode(reader, async (r) => {\n\t\t\tconst id = await r.u62();\n\t\t\tconst broadcast = Path.decode(await r.string());\n\t\t\tconst identity = await decodePin(r, version);\n\t\t\tawait decodeNode(r, version);\n\t\t\treturn new Datagrams({\n\t\t\t\tid,\n\t\t\t\tbroadcast,\n\t\t\t\tidentity,\n\t\t\t\ttrack: await r.string(),\n\t\t\t\tpriority: fromWire(await r.u8()),\n\t\t\t});\n\t\t});\n\t}\n}\n\n/** A subscriber priority update on a Datagrams Stream. */\nexport class DatagramsUpdate {\n\t/** The subscriber's replacement priority. */\n\tpriority: number;\n\tconstructor(priority: number) {\n\t\tthis.priority = priority;\n\t}\n\t/** Encode the size-prefixed update. */\n\tasync encode(writer: Writer, version: Version): Promise<void> {\n\t\tguard(version);\n\t\tawait Message.encode(writer, async (w) => {\n\t\t\tawait w.u8(toWire(this.priority));\n\t\t});\n\t}\n\t/** Decode an update, or undefined at the subscriber's FIN. */\n\tstatic async decodeMaybe(reader: Reader, version: Version): Promise<DatagramsUpdate | undefined> {\n\t\tguard(version);\n\t\treturn Message.decodeMaybe(reader, async (r) => new DatagramsUpdate(fromWire(await r.u8())));\n\t}\n}\n\n/** The publisher's sole answer on a Datagrams Stream, fixing timestamp framing. */\nexport class DatagramsInfo {\n\t/** Publisher priority, breaking ties at one subscriber priority. */\n\tpriority: number;\n\t/** Timestamp units per second, or undefined for an untimed track. */\n\ttimescale?: Timescale;\n\tconstructor(properties: { priority: number; timescale?: Timescale | null }) {\n\t\tthis.priority = properties.priority;\n\t\tthis.timescale = properties.timescale ?? undefined;\n\t}\n\t/** Encode the size-prefixed answer. */\n\tasync encode(writer: Writer, version: Version): Promise<void> {\n\t\tguard(version);\n\t\tawait Message.encode(writer, async (w) => {\n\t\t\tawait w.u8(toWire(this.priority));\n\t\t\tawait w.u53(this.timescale ?? 0);\n\t\t});\n\t}\n\t/** Decode the publisher properties. */\n\tstatic async decode(reader: Reader, version: Version): Promise<DatagramsInfo> {\n\t\tguard(version);\n\t\treturn Message.decode(reader, async (r) => {\n\t\t\tconst priority = fromWire(await r.u8());\n\t\t\tconst scale = await r.u53();\n\t\t\treturn new DatagramsInfo({ priority, timescale: scale === 0 ? undefined : Timescale(scale) });\n\t\t});\n\t}\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Reader, Writer } from "../stream.ts";
|
|
2
|
+
/** Encode optional milliseconds, with zero meaning absent and a present value offset by one. */
|
|
3
|
+
export declare function encodeOptional(w: Writer, value: number | undefined): Promise<void>;
|
|
4
|
+
/** Remove the optional offset before converting the duration to safe numeric milliseconds. */
|
|
5
|
+
export declare function decodeOptional(r: Reader): Promise<number | undefined>;
|
|
6
|
+
//# sourceMappingURL=duration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/lite/duration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEnD,gGAAgG;AAChG,wBAAsB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAIxF;AAED,8FAA8F;AAC9F,wBAAsB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAI3E"}
|
package/lite/duration.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Encode optional milliseconds, with zero meaning absent and a present value offset by one. */
|
|
2
|
+
export async function encodeOptional(w, value) {
|
|
3
|
+
if (value !== undefined && (!Number.isSafeInteger(value) || value < 0))
|
|
4
|
+
throw new RangeError("duration exceeds safe milliseconds");
|
|
5
|
+
await w.u62(value === undefined ? 0n : BigInt(value) + 1n);
|
|
6
|
+
}
|
|
7
|
+
/** Remove the optional offset before converting the duration to safe numeric milliseconds. */
|
|
8
|
+
export async function decodeOptional(r) {
|
|
9
|
+
const value = await r.u62();
|
|
10
|
+
if (value > BigInt(Number.MAX_SAFE_INTEGER) + 1n)
|
|
11
|
+
throw new RangeError("duration exceeds safe milliseconds");
|
|
12
|
+
return value === 0n ? undefined : Number(value - 1n);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=duration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.js","sourceRoot":"","sources":["../../src/lite/duration.ts"],"names":[],"mappings":"AAEA,gGAAgG;AAChG,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,CAAS,EAAE,KAAyB;IACxE,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC;QACrE,MAAM,IAAI,UAAU,CAAC,oCAAoC,CAAC,CAAC;IAC5D,MAAM,CAAC,CAAC,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,8FAA8F;AAC9F,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,CAAS;IAC7C,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;IAC5B,IAAI,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE;QAAE,MAAM,IAAI,UAAU,CAAC,oCAAoC,CAAC,CAAC;IAC7G,OAAO,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import type { Reader, Writer } from \"../stream.ts\";\n\n/** Encode optional milliseconds, with zero meaning absent and a present value offset by one. */\nexport async function encodeOptional(w: Writer, value: number | undefined): Promise<void> {\n\tif (value !== undefined && (!Number.isSafeInteger(value) || value < 0))\n\t\tthrow new RangeError(\"duration exceeds safe milliseconds\");\n\tawait w.u62(value === undefined ? 0n : BigInt(value) + 1n);\n}\n\n/** Remove the optional offset before converting the duration to safe numeric milliseconds. */\nexport async function decodeOptional(r: Reader): Promise<number | undefined> {\n\tconst value = await r.u62();\n\tif (value > BigInt(Number.MAX_SAFE_INTEGER) + 1n) throw new RangeError(\"duration exceeds safe milliseconds\");\n\treturn value === 0n ? undefined : Number(value - 1n);\n}\n"]}
|