@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/stream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE/F,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC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AC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACrC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrB,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,QAAQ,CAAC,GAAgB,EAAE,CAAS;IAC5C,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACrC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACpB,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AACtE,CAAC;AAED,8CAA8C;AAC9C,MAAM,OAAO,OAAO;IACnB,OAAO,CAA0D;IACjE,QAAQ,CAAgB;IAExB,YAAY,IAAkB,EAAE,OAAsB;QACrD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,6BAA6B,CAAC,SAAS,EAE1D,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,IAAI;QACT,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,IAAI;YAAE,OAAO;QACtB,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzD,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;CACD","sourcesContent":["import { race } from \"@moq/signals\";\nimport { fromTransport, StreamCode, StreamError, toStreamCode, toTransport } from \"./error.ts\";\nimport type { IetfVersion } from \"./ietf/version.ts\";\nimport { Version } from \"./ietf/version.ts\";\nimport { Version as Lite, type Version as LiteVersion } from \"./lite/version.ts\";\nimport { TimeoutError, withTimeout } from \"./util/timeout.ts\";\nimport { POW32, toBigInt, toNumber, U64 } from \"./util/u64.ts\";\nimport { decodeUtf8 } from \"./util/utf8.ts\";\nimport {\n\tlengthLeadingOnes,\n\tlengthQuic,\n\tparts,\n\tpeekLeadingOnes,\n\tpeekQuic,\n\treadLeadingOnes,\n\treadQuic,\n\tsplit,\n\twriteLeadingOnes,\n\twriteQuic,\n} from \"./util/varint.ts\";\n\n// Decode raw transport errors before mapping so they cannot bypass the negotiated\n// registry. Ordinary errors already send 0 and retain their local identity.\nfunction withCode(reason: unknown, stream: StreamVersion): unknown {\n\tconst version = asIetf(stream);\n\tconst decoded = fromTransport(reason, { version });\n\tconst code = toStreamCode(decoded, { version });\n\treturn code === StreamCode.Internal && decoded === reason ? reason : toTransport(code, decoded.message);\n}\n\nconst MAX_U31 = 2 ** 31 - 1;\nconst MAX_READ_SIZE = 1024 * 1024 * 64; // don't allocate more than 64MB for a message\n\n/**\n * Options handed to the transport for one outgoing stream.\n *\n * `waitUntilAvailable` waits for the peer's concurrent stream limit to free a slot instead\n * of rejecting with a `QuotaExceededError`, which is what we want for the streams a session\n * opens occasionally. `@types/web` doesn't declare it yet, hence the intersection.\n */\nexport function sendOptions(options?: OpenOptions): WebTransportSendStreamOptions & { waitUntilAvailable?: boolean } {\n\treturn { sendOrder: options?.sendOrder, waitUntilAvailable: options?.waitUntilAvailable ?? true };\n}\n\n// How long any open may wait for the peer to free a stream slot. Every open needs this,\n// whether or not it asked to wait: an implementation may park an over-limit open rather\n// than rejecting it, and a peer can advertise a stream limit of zero and never raise it.\n// Matches the subscribe budget.\nconst OPEN_TIMEOUT_MS = 10_000;\n\n/**\n * Bound an open that would otherwise park until the peer grants stream credit, restoring\n * the pre-waitUntilAvailable failure after a grace period. A stream arriving after the\n * deadline is discarded, since nobody is waiting for it any more.\n */\nasync function openWithin<T>(opening: Promise<T>, timeout: number, discard: (stream: T) => void): Promise<T> {\n\ttry {\n\t\treturn await withTimeout(opening, timeout, `stream open timed out after ${timeout}ms waiting for a slot`);\n\t} catch (err: unknown) {\n\t\topening.then(discard).catch(() => void 0);\n\t\tthrow err;\n\t}\n}\n\n/**\n * The version a stream's bytes follow: a moq-transport draft or a moq-lite draft. Required on\n * every stream so the varint form never defaults silently; a stream opened before negotiation\n * names the version its handshake is encoded with.\n */\nexport type StreamVersion = IetfVersion | LiteVersion;\n\nconst LITE: ReadonlySet<number> = new Set(Object.values(Lite));\n\nfunction isLite(version: StreamVersion): version is LiteVersion {\n\treturn LITE.has(version);\n}\n\n/** The moq-transport draft a stream follows, or undefined on moq-lite, whose stream codes are the same on every draft. */\nexport function asIetf(version: StreamVersion): IetfVersion | undefined {\n\treturn isLite(version) ? undefined : version;\n}\n\n// Every draft newer than these counts leading ones, so a new version falls forward.\nfunction isLeadingOnes(version: StreamVersion): boolean {\n\tswitch (version) {\n\t\tcase Version.DRAFT_14:\n\t\tcase Version.DRAFT_15:\n\t\tcase Version.DRAFT_16:\n\t\tcase Lite.DRAFT_01:\n\t\tcase Lite.DRAFT_02:\n\t\tcase Lite.DRAFT_03:\n\t\tcase Lite.DRAFT_04:\n\t\tcase Lite.DRAFT_05:\n\t\tcase Lite.DRAFT_06:\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn true;\n\t}\n}\n\n// Encode `hi`/`lo` into `dst` in the varint form `version` uses: QUIC up to 2^62-1, leading-ones up to 2^64-1.\nfunction encodeTo(dst: ArrayBuffer, hi: number, lo: number, version: StreamVersion): Uint8Array {\n\tlet buf: Uint8Array;\n\tif (isLeadingOnes(version)) {\n\t\tbuf = new Uint8Array(dst, 0, lengthLeadingOnes(hi, lo));\n\t\twriteLeadingOnes(buf, hi, lo, buf.length);\n\t} else {\n\t\tbuf = new Uint8Array(dst, 0, lengthQuic(hi, lo));\n\t\twriteQuic(buf, hi, lo, buf.length);\n\t}\n\treturn buf;\n}\n\n/** Encode one varint in the form `version` uses, for a body written outside a {@link Writer}. */\nexport function encodeVarint(v: number | bigint, version: StreamVersion): Uint8Array {\n\tconst lo = split(v);\n\treturn encodeTo(new ArrayBuffer(9), parts.hi, lo, version);\n}\n\n/** The parts joined into one buffer, so they can go out in one write. */\nexport function concat(parts: Uint8Array[]): Uint8Array {\n\tconst out = new Uint8Array(parts.reduce((n, p) => n + p.byteLength, 0));\n\tlet offset = 0;\n\tfor (const part of parts) {\n\t\tout.set(part, offset);\n\t\toffset += part.byteLength;\n\t}\n\treturn out;\n}\n\n/**\n * The `WebTransportSendStream` that every outgoing stream is, narrowed to the one attribute\n * this package uses. The DOM types available here still describe them as plain\n * `WritableStream`s, so the interface has to be named structurally.\n *\n * `sendOrder` is optional because it is absent until set, and stays absent on an\n * implementation that doesn't carry the interface at all.\n *\n * @see https://www.w3.org/TR/webtransport/#webtransportsendstream\n */\nexport type SendStream = WritableStream<Uint8Array> & { sendOrder?: number };\n\n/** Options for opening an outgoing stream. */\nexport interface OpenOptions {\n\t/** The negotiated version, which selects the varint encoding. */\n\tversion: StreamVersion;\n\n\t/**\n\t * The transport send order, where HIGHER values are transmitted first.\n\t * Left to the transport's default when unset.\n\t */\n\tsendOrder?: number;\n\n\t/**\n\t * Reject if the peer hasn't freed a stream slot within this many milliseconds. Defaults\n\t * to 10s. There is no way to wait indefinitely: a peer can advertise a stream limit of\n\t * zero and never raise it, so every open needs a way out.\n\t */\n\ttimeout?: number;\n\n\t/**\n\t * Ask the transport to wait for a stream slot rather than failing when the peer's\n\t * concurrent stream limit is exhausted. Defaults to true.\n\t *\n\t * Set it false on a path that opens streams faster than the peer can retire them. The\n\t * transport queues the opens it can't satisfy and serves them in order, with no way to\n\t * cancel one, so waiting there spends returning credit on whatever was requested first\n\t * rather than on what matters now.\n\t */\n\twaitUntilAvailable?: boolean;\n}\n\n/** Options for {@link Writer.tryOpen}. */\nexport interface TryOpenOptions extends OpenOptions {\n\t/** Give up once this resolves. */\n\tcancel: Promise<void>;\n}\n\nexport class Stream {\n\treader: Reader;\n\twriter: Writer;\n\n\t/** Wrap the two halves of a transport stream. */\n\tconstructor(props: {\n\t\twritable: WritableStream<Uint8Array>;\n\t\treadable: ReadableStream<Uint8Array>;\n\t\tversion: StreamVersion;\n\t});\n\t/** Pair halves that were opened separately, as the SETUP exchange does. */\n\tconstructor(props: { writer: Writer; reader: Reader });\n\tconstructor(props: {\n\t\twritable?: WritableStream<Uint8Array>;\n\t\treadable?: ReadableStream<Uint8Array>;\n\t\twriter?: Writer;\n\t\treader?: Reader;\n\t\tversion?: StreamVersion;\n\t}) {\n\t\tconst version = props.version;\n\t\tconst writer = props.writer ?? (props.writable && version !== undefined && new Writer(props.writable, version));\n\t\tconst reader =\n\t\t\tprops.reader ?? (props.readable && version !== undefined && new Reader(props.readable, undefined, version));\n\t\tif (!writer || !reader) throw new Error(\"stream needs both halves\");\n\n\t\tthis.writer = writer;\n\t\tthis.reader = reader;\n\t}\n\n\tstatic async accept(quic: WebTransport, version: StreamVersion): Promise<Stream | undefined> {\n\t\tfor (;;) {\n\t\t\tconst reader =\n\t\t\t\tquic.incomingBidirectionalStreams.getReader() as ReadableStreamDefaultReader<WebTransportBidirectionalStream>;\n\t\t\tconst next = await reader.read();\n\t\t\treader.releaseLock();\n\n\t\t\tif (next.done) return;\n\t\t\tconst { readable, writable } = next.value;\n\t\t\treturn new Stream({ readable, writable, version });\n\t\t}\n\t}\n\n\t/**\n\t * Open an outgoing bidirectional stream.\n\t * @param quic - The session to open it on\n\t * @param options - The version its varints encode with, and the send order ranking it\n\t * against the session's other streams\n\t */\n\tstatic async open(quic: WebTransport, options: OpenOptions): Promise<Stream> {\n\t\tconst { readable, writable } = await openWithin(\n\t\t\tquic.createBidirectionalStream(sendOptions(options)),\n\t\t\toptions?.timeout ?? OPEN_TIMEOUT_MS,\n\t\t\t(stream) => {\n\t\t\t\tvoid stream.writable.abort().catch(() => void 0);\n\t\t\t\tvoid stream.readable.cancel().catch(() => void 0);\n\t\t\t},\n\t\t);\n\t\treturn new Stream({ readable, writable, version: options.version });\n\t}\n\n\tclose() {\n\t\tthis.writer.close();\n\t\t// A routine unsubscribe, so send CANCELLED. A bare Error would put 0 on the wire,\n\t\t// which the stream registry reads as INTERNAL_ERROR: the peer would log a failure\n\t\t// for every subscription we walk away from.\n\t\tthis.reader.stop(new StreamError(StreamCode.Cancel, { message: \"cancel\" }));\n\t}\n\n\tabort(reason: Error) {\n\t\tthis.writer.reset(reason);\n\t\tthis.reader.stop(reason);\n\t}\n}\n\n// Reader wraps a stream and provides convience methods for reading pieces from a stream\n// Unfortunately we can't use a BYOB reader because it's not supported with WebTransport+WebWorkers yet.\nexport class Reader {\n\t// Contiguous unread bytes, followed by chunks not yet joined onto it. Joining only once a\n\t// read needs the bytes keeps a frame arriving in N chunks linear rather than quadratic.\n\t#buffer: Uint8Array;\n\t#chunks: Uint8Array[] = [];\n\t#chunked = 0; // bytes across #chunks\n\t#stream?: ReadableStream<Uint8Array>; // if undefined, the buffer is consumed then EOF\n\t#reader?: ReadableStreamDefaultReader<Uint8Array>;\n\t#closed?: Promise<void>;\n\t// The decode that last ran short and how far, so a retry can wait for those bytes.\n\t#short?: { decode: (c: Cursor) => unknown; err: Short };\n\tversion: StreamVersion;\n\n\t// Either stream or buffer MUST be provided.\n\tconstructor(stream: ReadableStream<Uint8Array>, buffer: Uint8Array | undefined, version: StreamVersion);\n\tconstructor(stream: undefined, buffer: Uint8Array, version: StreamVersion);\n\tconstructor(\n\t\tstream: ReadableStream<Uint8Array> | undefined,\n\t\tbuffer: Uint8Array | undefined,\n\t\tversion: StreamVersion,\n\t) {\n\t\tthis.#buffer = buffer ?? new Uint8Array();\n\t\tthis.#stream = stream;\n\t\tthis.#reader = this.#stream?.getReader();\n\t\tthis.version = version;\n\t}\n\n\t// Adds more data to the buffer, returning true if more data was added.\n\tasync #fill(): Promise<boolean> {\n\t\tif (!this.#reader) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Every read of this stream funnels through here, so decoding the peer's reset code\n\t\t// once is enough to keep the raw transport error out of every caller (and every app).\n\t\tconst result = await this.#reader.read().catch((err: unknown) => {\n\t\t\tthrow fromTransport(err, { version: asIetf(this.version) });\n\t\t});\n\n\t\tif (result.done) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (result.value.byteLength === 0) {\n\t\t\tthrow new Error(\"unexpected empty chunk\");\n\t\t}\n\n\t\tthis.#chunks.push(result.value);\n\t\tthis.#chunked += result.value.byteLength;\n\n\t\treturn true;\n\t}\n\n\t// Add more data to the buffer until it's at least size bytes.\n\tasync #fillTo(size: number) {\n\t\tif (size > MAX_READ_SIZE) {\n\t\t\tthrow new Error(`read size ${size} exceeds max size ${MAX_READ_SIZE}`);\n\t\t}\n\n\t\tif (this.#buffer.byteLength >= size) return;\n\n\t\twhile (this.#buffer.byteLength + this.#chunked < size) {\n\t\t\tif (!(await this.#fill())) {\n\t\t\t\tthrow new UnexpectedEnd();\n\t\t\t}\n\t\t}\n\n\t\tthis.#join();\n\t}\n\n\t// Move every pending chunk into the buffer, copying only when there's more than one piece.\n\t#join() {\n\t\tif (this.#chunks.length === 0) return;\n\n\t\tif (this.#buffer.byteLength === 0 && this.#chunks.length === 1) {\n\t\t\tthis.#buffer = this.#chunks[0];\n\t\t} else {\n\t\t\tconst joined = new Uint8Array(this.#buffer.byteLength + this.#chunked);\n\t\t\tjoined.set(this.#buffer);\n\t\t\tlet offset = this.#buffer.byteLength;\n\t\t\tfor (const chunk of this.#chunks) {\n\t\t\t\tjoined.set(chunk, offset);\n\t\t\t\toffset += chunk.byteLength;\n\t\t\t}\n\t\t\tthis.#buffer = joined;\n\t\t}\n\n\t\tthis.#chunks = [];\n\t\tthis.#chunked = 0;\n\t}\n\n\t// Consumes the first size bytes of the buffer.\n\t#slice(size: number): Uint8Array {\n\t\tconst result = new Uint8Array(this.#buffer.buffer, this.#buffer.byteOffset, size);\n\t\tthis.#buffer = new Uint8Array(\n\t\t\tthis.#buffer.buffer,\n\t\t\tthis.#buffer.byteOffset + size,\n\t\t\tthis.#buffer.byteLength - size,\n\t\t);\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Run a synchronous decode over the buffered bytes and consume what it read.\n\t *\n\t * Returns undefined and consumes nothing when the decode ran past the buffered bytes, so a\n\t * caller can drain every complete message already here without waiting on the stream.\n\t */\n\ttryDecode<T extends NonNullable<unknown>>(decode: (c: Cursor) => T): T | undefined {\n\t\tconst result = this.#try(decode);\n\t\treturn result instanceof Short ? undefined : result;\n\t}\n\n\t/** Run a synchronous decode, filling from the stream until it has the bytes it needs. */\n\tasync decode<T>(decode: (c: Cursor) => T): Promise<T> {\n\t\tfor (;;) {\n\t\t\tconst result = this.#try(decode);\n\t\t\tif (!(result instanceof Short)) return result;\n\t\t\tawait this.#fillTo(result.need);\n\t\t}\n\t}\n\n\t// Like decode, but leaves the bytes buffered for the next read.\n\tasync #peek<T>(decode: (c: Cursor) => T): Promise<T> {\n\t\tfor (;;) {\n\t\t\tconst result = this.#try(decode, false);\n\t\t\tif (!(result instanceof Short)) return result;\n\t\t\tawait this.#fillTo(result.need);\n\t\t}\n\t}\n\n\t/** Like {@link decode}, but returns undefined if the stream ends cleanly first. */\n\tasync decodeMaybe<T>(decode: (c: Cursor) => T): Promise<T | undefined> {\n\t\tif (await this.done()) return undefined;\n\t\treturn this.decode(decode);\n\t}\n\n\t#try<T>(decode: (c: Cursor) => T, consume = true): T | Short {\n\t\t// A retry of the decode that last ran short, before the bytes it needs have arrived,\n\t\t// would only throw again. Every decode reads at least a byte, so none can succeed on\n\t\t// an empty buffer either.\n\t\tconst available = this.#buffer.byteLength + this.#chunked;\n\t\tif (available === 0) return EMPTY;\n\t\tif (decode === this.#short?.decode && available < this.#short.err.need) return this.#short.err;\n\n\t\tthis.#join();\n\t\tconst cursor = new Cursor(this.#buffer, this.version);\n\t\ttry {\n\t\t\tconst result = decode(cursor);\n\t\t\tif (consume) this.#slice(cursor.offset);\n\t\t\tthis.#short = undefined;\n\t\t\treturn result;\n\t\t} catch (err: unknown) {\n\t\t\tif (!(err instanceof Short)) throw err;\n\t\t\t// Filling could never satisfy it, so retrying would spin.\n\t\t\tif (err.need <= this.#buffer.byteLength) throw new Error(\"decode ran short of bytes it already had\");\n\t\t\tthis.#short = { decode, err };\n\t\t\treturn err;\n\t\t}\n\t}\n\n\tasync read(size: number): Promise<Uint8Array> {\n\t\tif (size === 0) return new Uint8Array();\n\t\treturn this.decode((c) => c.read(size));\n\t}\n\n\tasync readAll(): Promise<Uint8Array> {\n\t\twhile (await this.#fill()) {\n\t\t\t// keep going\n\t\t}\n\t\tthis.#join();\n\t\treturn this.#slice(this.#buffer.byteLength);\n\t}\n\n\t// Reads to the end of the stream, dropping every byte instead of buffering it.\n\tasync discard(): Promise<void> {\n\t\tthis.#buffer = new Uint8Array();\n\t\tdo {\n\t\t\tthis.#chunks = [];\n\t\t\tthis.#chunked = 0;\n\t\t} while (await this.#fill());\n\t}\n\n\tasync string(): Promise<string> {\n\t\treturn this.decode(STRING);\n\t}\n\n\tasync bool(): Promise<boolean> {\n\t\treturn this.decode(BOOL);\n\t}\n\n\tasync u8(): Promise<number> {\n\t\treturn this.decode(U8);\n\t}\n\n\tasync u16(): Promise<number> {\n\t\treturn this.decode(U16);\n\t}\n\n\t// Returns a Number using 53-bits, the max Javascript can use for integer math.\n\tasync u53(): Promise<number> {\n\t\treturn this.decode(U53);\n\t}\n\n\t// NOTE: Returns a bigint instead of a number since it may be larger than 53-bits\n\tasync u62(): Promise<bigint> {\n\t\treturn this.decode(U62);\n\t}\n\n\t/** Like {@link u62}, but leaves the varint buffered, so a stream's type can be read twice. */\n\tasync peekU62(): Promise<bigint> {\n\t\treturn this.#peek(U62);\n\t}\n\n\tasync varint(): Promise<U64> {\n\t\treturn this.decode(VARINT);\n\t}\n\n\t// Returns false if there is more data to read, blocking if it hasn't been received yet.\n\tasync done(): Promise<boolean> {\n\t\tif (this.#buffer.byteLength > 0 || this.#chunked > 0) return false;\n\t\treturn !(await this.#fill());\n\t}\n\n\tstop(reason: unknown) {\n\t\tthis.#reader?.cancel(withCode(reason, this.version)).catch(() => void 0);\n\t}\n\n\t// Decoded like #fill: a caller racing this against a read must not get a different error\n\t// shape depending on which one won. Derived once, so racing it per frame doesn't allocate.\n\tget closed(): Promise<void> {\n\t\tthis.#closed ??= (this.#reader?.closed ?? Promise.resolve()).catch((err: unknown) => {\n\t\t\tthrow fromTransport(err, { version: asIetf(this.version) });\n\t\t});\n\t\treturn this.#closed;\n\t}\n}\n\n/** The stream ended cleanly partway through a read. */\nexport class UnexpectedEnd extends Error {\n\tconstructor() {\n\t\tsuper(\"unexpected end of stream\");\n\t}\n}\n\n// Thrown by a Cursor read that runs past the buffered bytes, carrying how many bytes from the\n// start of the buffer the decode needs. Not an Error: it ends every chunk, so it must not\n// capture a stack.\nclass Short {\n\treadonly need: number;\n\n\tconstructor(need: number) {\n\t\tthis.need = need;\n\t}\n}\n\nconst EMPTY = new Short(1);\n\n/**\n * A synchronous view over a {@link Reader}'s buffered bytes, handed to {@link Reader.decode}.\n *\n * A read past the buffered bytes throws an internal signal that the Reader catches: it consumes\n * nothing, fills, and runs the decode again from the start. A decode must therefore not mutate\n * anything before its last read, must not swallow what it throws, and must read at least a byte.\n */\nexport class Cursor {\n\treadonly version: StreamVersion;\n\t#buffer: Uint8Array;\n\t#offset = 0;\n\t// Resolved once, since every varint read branches on it.\n\t#leadingOnes: boolean;\n\t// First bytes below this are a whole 1-byte varint, and below this + 0x40 a 2-byte one whose\n\t// value is the low 6 bits and the next byte. Both formats share that shape; only the bound moves.\n\t#short: number;\n\t// First bytes below this are a varint of at most 4 bytes: 0xc0 for QUIC, 0xf0 for leading-ones.\n\t#word: number;\n\n\tconstructor(buffer: Uint8Array, version: StreamVersion) {\n\t\tthis.#buffer = buffer;\n\t\tthis.version = version;\n\t\tthis.#leadingOnes = isLeadingOnes(version);\n\t\tthis.#short = this.#leadingOnes ? 0x80 : 0x40;\n\t\tthis.#word = this.#leadingOnes ? 0xf0 : 0xc0;\n\t}\n\n\t/** How many bytes have been read. */\n\tget offset(): number {\n\t\treturn this.#offset;\n\t}\n\n\t/** How many buffered bytes are left to read. */\n\tget remaining(): number {\n\t\treturn this.#buffer.byteLength - this.#offset;\n\t}\n\n\t/**\n\t * Decode the next `size` bytes on their own. Running past them, or leaving any unread, is\n\t * malformed rather than a reason to wait for more.\n\t */\n\texact<T>(size: number, decode: (c: Cursor) => T): T {\n\t\tconst inner = new Cursor(this.read(size), this.version);\n\t\tlet result: T;\n\t\ttry {\n\t\t\tresult = decode(inner);\n\t\t} catch (err: unknown) {\n\t\t\tif (err instanceof Short) throw new Error(`message is shorter than its fields: ${size} bytes`);\n\t\t\tthrow err;\n\t\t}\n\t\tif (inner.remaining > 0) throw new Error(`message has ${inner.remaining} unread bytes`);\n\t\treturn result;\n\t}\n\n\t#ensure(size: number) {\n\t\tconst need = this.#offset + size;\n\t\t// Checked here too, and on the whole decode like the fill, since bytes that are already\n\t\t// buffered never reach the fill.\n\t\tif (need > MAX_READ_SIZE) throw new Error(`read size ${need} exceeds max size ${MAX_READ_SIZE}`);\n\t\tif (need > this.#buffer.byteLength) throw new Short(need);\n\t}\n\n\t/** Read `size` bytes, as a view onto the buffer rather than a copy. */\n\tread(size: number): Uint8Array {\n\t\tthis.#ensure(size);\n\t\tconst start = this.#offset;\n\t\tthis.#offset += size;\n\t\treturn this.#buffer.subarray(start, this.#offset);\n\t}\n\n\tstring(): string {\n\t\treturn decodeUtf8(this.read(this.u53()));\n\t}\n\n\tbool(): boolean {\n\t\tconst v = this.u8();\n\t\tif (v === 0) return false;\n\t\tif (v === 1) return true;\n\t\tthrow new Error(\"invalid bool value\");\n\t}\n\n\tu8(): number {\n\t\tthis.#ensure(1);\n\t\treturn this.#buffer[this.#offset++];\n\t}\n\n\tu16(): number {\n\t\tthis.#ensure(2);\n\t\tconst b = this.#buffer;\n\t\tconst o = this.#offset;\n\t\tthis.#offset += 2;\n\t\treturn (b[o] << 8) | b[o + 1];\n\t}\n\n\t/** Read a varint as a `number`, throwing if it is above `Number.MAX_SAFE_INTEGER`. */\n\tu53(): number {\n\t\t// Most varints are 1 or 2 bytes, which skip the general decode.\n\t\tthis.#ensure(1);\n\t\tconst b = this.#buffer;\n\t\tconst o = this.#offset;\n\t\tconst first = b[o];\n\t\tif (first < this.#short) {\n\t\t\tthis.#offset = o + 1;\n\t\t\treturn first;\n\t\t}\n\t\tif (first < this.#short + 0x40) {\n\t\t\tthis.#ensure(2);\n\t\t\tthis.#offset = o + 2;\n\t\t\treturn ((first & 0x3f) << 8) | b[o + 1];\n\t\t}\n\t\t// Up to 4 bytes still fits 28 (leading-ones) or 30 (QUIC) bits, with no upper half.\n\t\tif (first < this.#word) {\n\t\t\tconst size = this.#leadingOnes ? peekLeadingOnes(first) : 4;\n\t\t\tthis.#ensure(size);\n\t\t\tthis.#offset = o + size;\n\t\t\tif (size === 3) return ((first & 0x1f) << 16) | (b[o + 1] << 8) | b[o + 2];\n\t\t\treturn ((first & (this.#leadingOnes ? 0x0f : 0x3f)) << 24) | (b[o + 1] << 16) | (b[o + 2] << 8) | b[o + 3];\n\t\t}\n\t\tconst lo = this.#varint();\n\t\treturn toNumber(parts.hi, lo);\n\t}\n\n\t/** Read a varint as a bigint. A leading-ones varint may exceed 62 bits. */\n\tu62(): bigint {\n\t\tconst lo = this.#varint();\n\t\treturn toBigInt(parts.hi, lo);\n\t}\n\n\t/** Read a varint. */\n\tvarint(): U64 {\n\t\tconst lo = this.#varint();\n\t\treturn new U64(parts.hi, lo);\n\t}\n\n\t// Decode the next varint in the version's format, returning its lower half and leaving the upper in `parts`.\n\t#varint(): number {\n\t\tthis.#ensure(1);\n\t\tconst b = this.#buffer;\n\t\tconst o = this.#offset;\n\t\tlet size: number;\n\t\tif (this.#leadingOnes) {\n\t\t\tsize = peekLeadingOnes(b[o]);\n\t\t\t// 1111110x is a 7-byte form. Draft-17 rejects it; draft-18+ allows it per #1595.\n\t\t\tif (size === 7 && this.version === Version.DRAFT_17) {\n\t\t\t\tthrow new Error(\"invalid leading-ones varint: 1111110x prefix is reserved on draft-17\");\n\t\t\t}\n\t\t\tthis.#ensure(size);\n\t\t\tthis.#offset += size;\n\t\t\treturn readLeadingOnes(b, o, size);\n\t\t}\n\t\tsize = peekQuic(b[o]);\n\t\tthis.#ensure(size);\n\t\tthis.#offset += size;\n\t\treturn readQuic(b, o, size);\n\t}\n}\n\n// Shared decodes for the Reader's async primitives, so a read allocates no closure.\nconst STRING = (c: Cursor) => c.string();\nconst BOOL = (c: Cursor) => c.bool();\nconst U8 = (c: Cursor) => c.u8();\nconst U16 = (c: Cursor) => c.u16();\nconst U53 = (c: Cursor) => c.u53();\nconst U62 = (c: Cursor) => c.u62();\nconst VARINT = (c: Cursor) => c.varint();\n\n// Writer wraps a stream and writes chunks of data\nexport class Writer {\n\t#writer: WritableStreamDefaultWriter<Uint8Array>;\n\t#stream: WritableStream<Uint8Array>;\n\t#closed?: Promise<void>;\n\n\t// Scratch buffer for each primitive write, sized for the longest (a 9-byte leading-ones varint).\n\t#scratch: ArrayBuffer;\n\n\tversion: StreamVersion;\n\n\tconstructor(stream: WritableStream<Uint8Array>, version: StreamVersion) {\n\t\tthis.#stream = stream;\n\t\tthis.#scratch = new ArrayBuffer(9);\n\t\tthis.#writer = this.#stream.getWriter();\n\t\tthis.version = version;\n\t}\n\n\t/**\n\t * Rank this stream against the session's others, where HIGHER values are sent first.\n\t *\n\t * A send order only schedules the local end, so a stream the peer opened has to be ranked\n\t * here rather than at the peer's {@link open}.\n\t *\n\t * The spec makes `sendOrder` a settable attribute on every {@link SendStream}. Where the\n\t * interface isn't implemented (Chrome as of writing, a mock, a polyfill) this just sets an\n\t * ignored property, the same way an ignored `sendOrder` option does at {@link open}.\n\t */\n\tsetPriority(sendOrder: number) {\n\t\t(this.#stream as SendStream).sendOrder = sendOrder;\n\t}\n\n\tasync bool(v: boolean) {\n\t\tawait this.write(setUint8(this.#scratch, v ? 1 : 0));\n\t}\n\n\tasync u8(v: number) {\n\t\tif (!Number.isInteger(v) || v < 0 || v > 255) {\n\t\t\tthrow new RangeError(`invalid u8: ${v}`);\n\t\t}\n\t\tawait this.write(setUint8(this.#scratch, v));\n\t}\n\n\tasync u16(v: number) {\n\t\tawait this.write(setUint16(this.#scratch, v));\n\t}\n\n\tasync i32(v: number) {\n\t\tif (Math.abs(v) > MAX_U31) {\n\t\t\tthrow new Error(`overflow, value larger than 32-bits: ${v.toString()}`);\n\t\t}\n\n\t\t// We don't use a varint, so it always takes 4 bytes.\n\t\t// This could be improved but nothing is standardized yet.\n\t\tawait this.write(setInt32(this.#scratch, v));\n\t}\n\n\tasync u53(v: number) {\n\t\tif (!Number.isSafeInteger(v) || v < 0) {\n\t\t\tthrow new RangeError(`invalid u53: ${v}`);\n\t\t}\n\t\tawait this.#varint(Math.floor(v / POW32), v >>> 0);\n\t}\n\n\tasync u62(v: bigint) {\n\t\tconst lo = split(v);\n\t\tawait this.#varint(parts.hi, lo);\n\t}\n\n\tasync varint(v: U64) {\n\t\tawait this.#varint(v.hi, v.lo);\n\t}\n\n\t#varint(hi: number, lo: number): Promise<void> {\n\t\treturn this.write(encodeTo(this.#scratch, hi, lo, this.version));\n\t}\n\n\tasync write(v: Uint8Array) {\n\t\t// Mirrors Reader.#fill: every write funnels through here, so a STOP_SENDING from the\n\t\t// peer surfaces as a typed code rather than the transport's own error shape.\n\t\tawait this.#writer.write(v).catch((err: unknown) => {\n\t\t\tthrow fromTransport(err, { version: asIetf(this.version) });\n\t\t});\n\t}\n\n\tasync string(str: string) {\n\t\tconst data = new TextEncoder().encode(str);\n\t\tawait this.u53(data.byteLength);\n\t\tawait this.write(data);\n\t}\n\n\tclose() {\n\t\tthis.#writer.close().catch(() => void 0);\n\t}\n\n\t// Mirrors Reader.closed: a STOP_SENDING reaches a caller racing this with the same\n\t// typed code it would get from a write.\n\tget closed(): Promise<void> {\n\t\tthis.#closed ??= this.#writer.closed.catch((err: unknown) => {\n\t\t\tthrow fromTransport(err, { version: asIetf(this.version) });\n\t\t});\n\t\treturn this.#closed;\n\t}\n\n\treset(reason: unknown) {\n\t\tthis.#writer.abort(withCode(reason, this.version)).catch(() => void 0);\n\t}\n\n\t/** Run `f` against a Writer that buffers in memory, returning everything it wrote as one chunk. */\n\tstatic async collect(version: StreamVersion, f: (w: Writer) => Promise<void>): Promise<Uint8Array> {\n\t\tconst chunks: Uint8Array[] = [];\n\t\t// Copied, since each primitive reuses the Writer's scratch buffer.\n\t\tconst w = new Writer(\n\t\t\tnew WritableStream<Uint8Array>({ write: (chunk) => void chunks.push(chunk.slice()) }),\n\t\t\tversion,\n\t\t);\n\t\ttry {\n\t\t\tawait f(w);\n\t\t} finally {\n\t\t\tw.close();\n\t\t}\n\t\tawait w.closed;\n\t\treturn concat(chunks);\n\t}\n\n\t/**\n\t * Open an outgoing unidirectional stream.\n\t * @param quic - The session to open it on\n\t * @param options - The version its varints encode with, and the send order ranking it\n\t * against the session's other streams\n\t */\n\tstatic async open(quic: WebTransport, options: OpenOptions): Promise<Writer> {\n\t\tconst writable = await openWithin(\n\t\t\tquic.createUnidirectionalStream(sendOptions(options)) as Promise<WritableStream<Uint8Array>>,\n\t\t\toptions?.timeout ?? OPEN_TIMEOUT_MS,\n\t\t\t(stream) => void stream.abort().catch(() => void 0),\n\t\t);\n\n\t\treturn new Writer(writable, options.version);\n\t}\n\n\t/**\n\t * Like {@link Writer.open}, but gives up when `cancel` settles or `timeout` elapses,\n\t * returning undefined so the caller can drop whatever it meant to send. A stream that\n\t * opens after that is reset rather than leaked. A real transport failure still throws.\n\t *\n\t * Worth using even with `waitUntilAvailable: false`, since an implementation may park\n\t * an over-limit open instead of rejecting it.\n\t */\n\tstatic async tryOpen(quic: WebTransport, options: TryOpenOptions): Promise<Writer | undefined> {\n\t\t// Raced ahead of the open, so an already-cancelled caller wins even against a slot\n\t\t// that is free right now. `race` rather than `Promise.race`: the caller shares one\n\t\t// `cancel` across every group of a subscription, which must not gain a reaction per call.\n\t\tconst open = Writer.open(quic, options);\n\n\t\t// Resets a stream that opens after we gave up; a no-op if the open itself failed.\n\t\tconst abandon = () => {\n\t\t\tconst abandoned = new Error(\"abandoned waiting for a stream slot\");\n\t\t\topen.then((w) => w.reset(abandoned)).catch(() => void 0);\n\t\t};\n\n\t\ttry {\n\t\t\tconst stream = await race([options.cancel, open]);\n\t\t\tif (stream) return stream;\n\t\t} catch (err: unknown) {\n\t\t\t// open already discarded the late stream on its way out.\n\t\t\tif (err instanceof TimeoutError) return undefined;\n\t\t\t// A rejected `cancel` still leaves the open pending.\n\t\t\tabandon();\n\t\t\tthrow err;\n\t\t}\n\n\t\tabandon();\n\t\treturn undefined;\n\t}\n}\n\nfunction setUint8(dst: ArrayBuffer, v: number): Uint8Array {\n\tconst buffer = new Uint8Array(dst, 0, 1);\n\tbuffer[0] = v;\n\treturn buffer;\n}\n\nfunction setUint16(dst: ArrayBuffer, v: number): Uint8Array {\n\tconst view = new DataView(dst, 0, 2);\n\tview.setUint16(0, v);\n\treturn new Uint8Array(view.buffer, view.byteOffset, view.byteLength);\n}\n\nfunction setInt32(dst: ArrayBuffer, v: number): Uint8Array {\n\tconst view = new DataView(dst, 0, 4);\n\tview.setInt32(0, v);\n\treturn new Uint8Array(view.buffer, view.byteOffset, view.byteLength);\n}\n\n// Returns the next stream from the connection\nexport class Readers {\n\t#reader: ReadableStreamDefaultReader<ReadableStream<Uint8Array>>;\n\t#version: StreamVersion;\n\n\tconstructor(quic: WebTransport, version: StreamVersion) {\n\t\tthis.#reader = quic.incomingUnidirectionalStreams.getReader() as ReadableStreamDefaultReader<\n\t\t\tReadableStream<Uint8Array>\n\t\t>;\n\t\tthis.#version = version;\n\t}\n\n\tasync next(): Promise<Reader | undefined> {\n\t\tconst next = await this.#reader.read();\n\t\tif (next.done) return;\n\t\treturn new Reader(next.value, undefined, this.#version);\n\t}\n\n\tclose() {\n\t\tthis.#reader.cancel();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../src/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,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACrC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrB,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,QAAQ,CAAC,GAAgB,EAAE,CAAS;IAC5C,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACrC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACpB,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AACtE,CAAC;AAED,8CAA8C;AAC9C,MAAM,OAAO,OAAO;IACnB,OAAO,CAA0D;IACjE,QAAQ,CAAgB;IAExB,YAAY,IAAkB,EAAE,OAAsB;QACrD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,6BAA6B,CAAC,SAAS,EAE1D,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,IAAI;QACT,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC;QAClC,IAAI,KAAK,KAAK,SAAS;YAAE,MAAM,KAAK,CAAC;QACrC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,IAAI;YAAE,OAAO;QACtB,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzD,CAAC;CACD","sourcesContent":["import { type Instant, now } from \"@moq/clock\";\nimport { fromTransport, StreamCode, streamCode, TooFarBehind, toStreamCode, toTransport } from \"./error.ts\";\nimport { sharedStreamCode } from \"./ietf/error.ts\";\nimport type { IetfVersion } from \"./ietf/version.ts\";\nimport { Version as Lite, type Version as LiteVersion } from \"./lite/version.ts\";\nimport { lines, type OpenStream, type OpenStreams, type Rank } from \"./open.ts\";\nimport { decodeError } from \"./util/decode_error.ts\";\nimport { POW32, toBigInt, toNumber, U64 } from \"./util/u64.ts\";\nimport { decodeUtf8 } from \"./util/utf8.ts\";\nimport {\n\tlengthLeadingOnes,\n\tlengthQuic,\n\tparts,\n\tpeekLeadingOnes,\n\tpeekQuic,\n\treadLeadingOnes,\n\treadQuic,\n\tsplit,\n\twriteLeadingOnes,\n\twriteQuic,\n} from \"./util/varint.ts\";\nimport { Budget } from \"./util/yield.ts\";\n\n/** Sharing the slice across writers bounds concurrent groups and subscriber fanout too.\n * @internal\n */\nexport const writeBudget = new Budget();\n\n/** Stream credit alone lets a peer keep thousands of streams ready, each accepted in a\n * microtask, so accept loops share a slice that lets the host's other tasks run.\n * @internal\n */\nexport const acceptBudget = new Budget();\n\n// Decode raw transport errors before mapping so they cannot bypass the negotiated\n// registry. Ordinary errors already send 0 and retain their local identity.\nfunction withCode(reason: unknown, stream: StreamVersion): unknown {\n\tconst version = asIetf(stream);\n\tconst decoded = fromTransport(reason, { version });\n\tconst code = toStreamCode(decoded, { version });\n\treturn code === StreamCode.Internal && decoded === reason ? reason : toTransport(code, decoded.message);\n}\n\n// A bare number is a stream code, and only Reader.stop takes one. Writer.reset stays on\n// withCode, which reads a number as a non-stream error and sends Internal.\nfunction stopReason(reason: unknown, stream: StreamVersion): unknown {\n\tif (typeof reason !== \"number\") return withCode(reason, stream);\n\tconst code =\n\t\tasIetf(stream) === undefined || sharedStreamCode(reason) ? (reason as StreamCode) : StreamCode.Internal;\n\treturn toTransport(code, \"cancel\");\n}\n\nconst MAX_U31 = 2 ** 31 - 1;\nconst MAX_READ_SIZE = 1024 * 1024 * 64; // don't allocate more than 64MB for a message\n\n/**\n * The version a stream's bytes follow: a moq-transport draft or a moq-lite draft. Required on\n * every stream so the varint form never defaults silently; a stream opened before negotiation\n * names the version its handshake is encoded with.\n */\nexport type StreamVersion = IetfVersion | LiteVersion;\n\nconst LITE: ReadonlySet<number> = new Set(Object.values(Lite));\n\nfunction isLite(version: StreamVersion): version is LiteVersion {\n\treturn LITE.has(version);\n}\n\n/** The moq-transport draft a stream follows, or undefined on moq-lite, whose stream codes are the same on every draft. */\nexport function asIetf(version: StreamVersion): IetfVersion | undefined {\n\treturn isLite(version) ? undefined : version;\n}\n\n/**\n * Whether `version` writes leading-ones varints, which carry the full u64; older versions use QUIC's, which stop at 2^62-1.\n * Every draft newer than these counts leading ones, so a new version falls forward.\n */\nexport function isLeadingOnes(version: StreamVersion): boolean {\n\tswitch (version) {\n\t\tcase Lite.DRAFT_01:\n\t\tcase Lite.DRAFT_02:\n\t\tcase Lite.DRAFT_03:\n\t\tcase Lite.DRAFT_04:\n\t\tcase Lite.DRAFT_05:\n\t\tcase Lite.DRAFT_06:\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn true;\n\t}\n}\n\n// Encode `hi`/`lo` into `dst` in the varint form `version` uses: QUIC up to 2^62-1, leading-ones up to 2^64-1.\nfunction encodeTo(dst: ArrayBuffer, hi: number, lo: number, version: StreamVersion): Uint8Array {\n\tlet buf: Uint8Array;\n\tif (isLeadingOnes(version)) {\n\t\tbuf = new Uint8Array(dst, 0, lengthLeadingOnes(hi, lo));\n\t\twriteLeadingOnes(buf, hi, lo, buf.length);\n\t} else {\n\t\tbuf = new Uint8Array(dst, 0, lengthQuic(hi, lo));\n\t\twriteQuic(buf, hi, lo, buf.length);\n\t}\n\treturn buf;\n}\n\n/** Encode one varint in the form `version` uses, for a body written outside a {@link Writer}. */\nexport function encodeVarint(v: number | bigint, version: StreamVersion): Uint8Array {\n\tconst lo = split(v);\n\treturn encodeTo(new ArrayBuffer(9), parts.hi, lo, version);\n}\n\n/** The parts joined into one buffer, so they can go out in one write. */\nexport function concat(parts: Uint8Array[]): Uint8Array {\n\tconst out = new Uint8Array(parts.reduce((n, p) => n + p.byteLength, 0));\n\tlet offset = 0;\n\tfor (const part of parts) {\n\t\tout.set(part, offset);\n\t\toffset += part.byteLength;\n\t}\n\treturn out;\n}\n\n/**\n * The `WebTransportSendStream` that every outgoing stream is, narrowed to the one attribute\n * this package uses. The DOM types available here still describe them as plain\n * `WritableStream`s, so the interface has to be named structurally.\n *\n * `sendOrder` is optional because it is absent until set, and stays absent on an\n * implementation that doesn't carry the interface at all.\n *\n * @see https://www.w3.org/TR/webtransport/#webtransportsendstream\n */\nexport type SendStream = WritableStream<Uint8Array> & { sendOrder?: number };\n\n/** Options for opening an outgoing stream. */\nexport interface OpenOptions {\n\t/** The negotiated version, which selects the varint encoding. */\n\tversion: StreamVersion;\n\n\t/**\n\t * The transport send order, where HIGHER values are transmitted first: also where the open\n\t * waits for the peer's stream credit, ahead of every lower one. Defaults to 0, the\n\t * transport's default.\n\t */\n\tsendOrder?: number;\n}\n\n/** Options for {@link Writer.tryOpen}. */\nexport interface TryOpenOptions extends Omit<OpenOptions, \"sendOrder\"> {\n\t/**\n\t * The send order, as {@link OpenOptions.sendOrder}, or a function read again whenever the\n\t * line hands out a stream, for a rank that moves while the open waits.\n\t */\n\tsendOrder?: Rank;\n\n\t/** Give up once this resolves. */\n\tcancel: Promise<void>;\n\n\t/** List the stream among the session's open group streams until it is closed or reset. */\n\tgroup?: boolean;\n}\n\n/** A send stream that reports what it sent, as W3C WebTransport's `WebTransportSendStream.getStats()` does. */\ntype Stats = WritableStream<Uint8Array> & { getStats(): Promise<{ bytesAcknowledged: number }> };\n\n/**\n * A send stream that can reset while still delivering a prefix to the peer's reader, as `@moq/qmux`'s\n * can once both sides negotiated RESET_STREAM_AT, which `reliableReset` says.\n */\ntype ResetsAt = WritableStream<Uint8Array> & {\n\tresetAt(offset: number, reason?: unknown): void;\n\treadonly reliableReset: boolean;\n};\n\nexport class Stream {\n\treader: Reader;\n\twriter: Writer;\n\n\t/** Wrap the two halves of a transport stream. */\n\tconstructor(props: {\n\t\twritable: WritableStream<Uint8Array>;\n\t\treadable: ReadableStream<Uint8Array>;\n\t\tversion: StreamVersion;\n\t});\n\t/** Pair halves that were opened separately, as the SETUP exchange does. */\n\tconstructor(props: { writer: Writer; reader: Reader });\n\tconstructor(props: {\n\t\twritable?: WritableStream<Uint8Array>;\n\t\treadable?: ReadableStream<Uint8Array>;\n\t\twriter?: Writer;\n\t\treader?: Reader;\n\t\tversion?: StreamVersion;\n\t}) {\n\t\tconst version = props.version;\n\t\tconst writer = props.writer ?? (props.writable && version !== undefined && new Writer(props.writable, version));\n\t\tconst reader =\n\t\t\tprops.reader ?? (props.readable && version !== undefined && new Reader(props.readable, undefined, version));\n\t\tif (!writer || !reader) throw new Error(\"stream needs both halves\");\n\n\t\tthis.writer = writer;\n\t\tthis.reader = reader;\n\t}\n\n\tstatic async accept(quic: WebTransport, version: StreamVersion): Promise<Stream | undefined> {\n\t\tfor (;;) {\n\t\t\tconst pause = acceptBudget.poll();\n\t\t\tif (pause !== undefined) await pause;\n\t\t\tconst reader =\n\t\t\t\tquic.incomingBidirectionalStreams.getReader() as ReadableStreamDefaultReader<WebTransportBidirectionalStream>;\n\t\t\tconst next = await reader.read();\n\t\t\treader.releaseLock();\n\n\t\t\tif (next.done) return;\n\t\t\tconst { readable, writable } = next.value;\n\t\t\treturn new Stream({ readable, writable, version });\n\t\t}\n\t}\n\n\t/**\n\t * Open an outgoing bidirectional stream.\n\t * @param quic - The session to open it on\n\t * @param options - The version its varints encode with, and the send order ranking it\n\t * against the session's other streams\n\t */\n\t/** Open a stream, waiting its turn for the peer's stream credit. */\n\tstatic async open(quic: WebTransport, options: OpenOptions): Promise<Stream> {\n\t\tconst opened = await lines(quic).bi.open(options.sendOrder ?? 0);\n\t\treturn new Stream({ readable: opened.readable, writable: opened.writable, version: options.version });\n\t}\n\n\t/**\n\t * Like {@link Stream.open}, but leaves the line once `signal` aborts, returning undefined so\n\t * the caller can drop its request. The stream its create admits later goes to the next open\n\t * in line. A transport failure still throws.\n\t */\n\tstatic async tryOpen(\n\t\tquic: WebTransport,\n\t\toptions: OpenOptions & { signal: AbortSignal },\n\t): Promise<Stream | undefined> {\n\t\tconst opened = await lines(quic).bi.open(options.sendOrder ?? 0, options.signal);\n\t\treturn opened && new Stream({ readable: opened.readable, writable: opened.writable, version: options.version });\n\t}\n\n\tclose() {\n\t\tthis.writer.close();\n\t\t// A routine unsubscribe, so send CANCELLED. A bare Error would put 0 on the wire,\n\t\t// which the stream registry reads as INTERNAL_ERROR: the peer would log a failure\n\t\t// for every subscription we walk away from.\n\t\tthis.reader.stop(StreamCode.Cancel);\n\t}\n\n\tabort(reason: Error) {\n\t\tthis.writer.reset(reason);\n\t\tthis.reader.stop(reason);\n\t}\n}\n\n// Reader wraps a stream and provides convience methods for reading pieces from a stream\n// Unfortunately we can't use a BYOB reader because it's not supported with WebTransport+WebWorkers yet.\nexport class Reader {\n\t// Contiguous unread bytes, followed by chunks not yet joined onto it. Joining only once a\n\t// read needs the bytes keeps a frame arriving in N chunks linear rather than quadratic.\n\t#buffer: Uint8Array;\n\t#chunks: Uint8Array[] = [];\n\t#chunked = 0; // bytes across #chunks\n\t#last = now(); // when the stream last delivered bytes, or it was created\n\t// Undefined once the stream finishes, or without a stream: the buffer is consumed then EOF.\n\t#reader?: ReadableStreamDefaultReader<Uint8Array>;\n\t#stream?: ReadableStream<Uint8Array> & { readonly resetSignal?: AbortSignal };\n\t#closed?: Promise<void>;\n\t// The decode that last ran short and how far, so a retry can wait for those bytes.\n\t#short?: { decode: (c: Cursor) => unknown; err: Short };\n\tversion: StreamVersion;\n\n\t// Either stream or buffer MUST be provided.\n\tconstructor(stream: ReadableStream<Uint8Array>, buffer: Uint8Array | undefined, version: StreamVersion);\n\tconstructor(stream: undefined, buffer: Uint8Array, version: StreamVersion);\n\tconstructor(\n\t\tstream: ReadableStream<Uint8Array> | undefined,\n\t\tbuffer: Uint8Array | undefined,\n\t\tversion: StreamVersion,\n\t) {\n\t\tthis.#buffer = buffer ?? new Uint8Array();\n\t\tthis.#stream = stream;\n\t\tthis.#reader = stream?.getReader();\n\t\tthis.version = version;\n\t}\n\n\t/** When the stream last delivered bytes, which tells a watcher a quiet stream from one still arriving. */\n\tget last(): Instant {\n\t\treturn this.#last;\n\t}\n\n\t// Adds more data to the buffer, returning true if more data was added.\n\tasync #fill(): Promise<boolean> {\n\t\tconst reader = this.#reader;\n\t\tif (!reader) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Every read of this stream funnels through here, so decoding the peer's reset code\n\t\t// once is enough to keep the raw transport error out of every caller (and every app).\n\t\tconst result = await reader.read().catch((err: unknown) => {\n\t\t\tthrow fromTransport(err, { version: asIetf(this.version) });\n\t\t});\n\n\t\tif (result.done) {\n\t\t\t// The transport already finished the stream. Drop the reader so a later stop\n\t\t\t// neither builds a cancel error nor sends a reset the peer will ignore. Dropped,\n\t\t\t// not released: releasing a closed stream's lock builds a TypeError per stream.\n\t\t\tif (this.#reader === reader) {\n\t\t\t\tthis.#reader = undefined;\n\t\t\t\tthis.#stream = undefined;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\tif (result.value.byteLength === 0) {\n\t\t\tthrow new Error(\"unexpected empty chunk\");\n\t\t}\n\n\t\tthis.#chunks.push(result.value);\n\t\tthis.#chunked += result.value.byteLength;\n\t\tthis.#last = now();\n\n\t\treturn true;\n\t}\n\n\t// Add more data to the buffer until it's at least size bytes.\n\tasync #fillTo(size: number) {\n\t\tif (size > MAX_READ_SIZE) {\n\t\t\tthrow new Error(`read size ${size} exceeds max size ${MAX_READ_SIZE}`);\n\t\t}\n\n\t\tif (this.#buffer.byteLength >= size) return;\n\n\t\twhile (this.#buffer.byteLength + this.#chunked < size) {\n\t\t\tif (!(await this.#fill())) {\n\t\t\t\tthrow new UnexpectedEnd();\n\t\t\t}\n\t\t}\n\n\t\tthis.#join();\n\t}\n\n\t// Move every pending chunk into the buffer, copying only when there's more than one piece.\n\t#join() {\n\t\tif (this.#chunks.length === 0) return;\n\n\t\tif (this.#buffer.byteLength === 0 && this.#chunks.length === 1) {\n\t\t\tthis.#buffer = this.#chunks[0];\n\t\t} else {\n\t\t\tconst joined = new Uint8Array(this.#buffer.byteLength + this.#chunked);\n\t\t\tjoined.set(this.#buffer);\n\t\t\tlet offset = this.#buffer.byteLength;\n\t\t\tfor (const chunk of this.#chunks) {\n\t\t\t\tjoined.set(chunk, offset);\n\t\t\t\toffset += chunk.byteLength;\n\t\t\t}\n\t\t\tthis.#buffer = joined;\n\t\t}\n\n\t\tthis.#chunks = [];\n\t\tthis.#chunked = 0;\n\t}\n\n\t// Consumes the first size bytes of the buffer.\n\t#slice(size: number): Uint8Array {\n\t\tconst result = new Uint8Array(this.#buffer.buffer, this.#buffer.byteOffset, size);\n\t\tthis.#buffer = new Uint8Array(\n\t\t\tthis.#buffer.buffer,\n\t\t\tthis.#buffer.byteOffset + size,\n\t\t\tthis.#buffer.byteLength - size,\n\t\t);\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Run a synchronous decode over the buffered bytes and consume what it read.\n\t *\n\t * Returns undefined and consumes nothing when the decode ran past the buffered bytes, so a\n\t * caller can drain every complete message already here without waiting on the stream.\n\t */\n\ttryDecode<T extends NonNullable<unknown>>(decode: (c: Cursor) => T): T | undefined {\n\t\tconst result = this.#try(decode);\n\t\treturn result instanceof Short ? undefined : result;\n\t}\n\n\t/** Like {@link tryDecode}, but consumes nothing: a look at what is buffered. */\n\ttryPeek<T extends NonNullable<unknown>>(decode: (c: Cursor) => T): T | undefined {\n\t\tconst result = this.#try(decode, false);\n\t\treturn result instanceof Short ? undefined : result;\n\t}\n\n\t/** Run a synchronous decode, filling from the stream until it has the bytes it needs. */\n\tasync decode<T>(decode: (c: Cursor) => T): Promise<T> {\n\t\tfor (;;) {\n\t\t\tconst result = this.#try(decode);\n\t\t\tif (!(result instanceof Short)) return result;\n\t\t\tawait this.#fillTo(result.need);\n\t\t}\n\t}\n\n\t/** Like {@link decode}, but leaves the bytes buffered for the next read. */\n\tasync peek<T>(decode: (c: Cursor) => T): Promise<T> {\n\t\tfor (;;) {\n\t\t\tconst result = this.#try(decode, false);\n\t\t\tif (!(result instanceof Short)) return result;\n\t\t\tawait this.#fillTo(result.need);\n\t\t}\n\t}\n\n\t/** Like {@link decode}, but returns undefined if the stream ends cleanly first. */\n\tasync decodeMaybe<T>(decode: (c: Cursor) => T): Promise<T | undefined> {\n\t\tif (await this.done()) return undefined;\n\t\treturn this.decode(decode);\n\t}\n\n\t#try<T>(decode: (c: Cursor) => T, consume = true): T | Short {\n\t\t// A retry of the decode that last ran short, before the bytes it needs have arrived,\n\t\t// would only throw again. Every decode reads at least a byte, so none can succeed on\n\t\t// an empty buffer either.\n\t\tconst available = this.#buffer.byteLength + this.#chunked;\n\t\tif (available === 0) return EMPTY;\n\t\tif (decode === this.#short?.decode && available < this.#short.err.need) return this.#short.err;\n\n\t\tthis.#join();\n\t\tconst cursor = new Cursor(this.#buffer, this.version);\n\t\ttry {\n\t\t\tconst result = decode(cursor);\n\t\t\tif (consume) this.#slice(cursor.offset);\n\t\t\tthis.#short = undefined;\n\t\t\treturn result;\n\t\t} catch (err: unknown) {\n\t\t\tif (!(err instanceof Short)) throw decodeError(err);\n\t\t\t// Filling could never satisfy it, so retrying would spin.\n\t\t\tif (err.need <= this.#buffer.byteLength) throw new Error(\"decode ran short of bytes it already had\");\n\t\t\tthis.#short = { decode, err };\n\t\t\treturn err;\n\t\t}\n\t}\n\n\tasync read(size: number): Promise<Uint8Array> {\n\t\tif (size === 0) return new Uint8Array();\n\t\treturn this.decode((c) => c.read(size));\n\t}\n\n\t/**\n\t * Read between 1 and `max` bytes as they arrive, without joining them into one buffer, so\n\t * a payload of any size streams through. Throws {@link UnexpectedEnd} at a clean end.\n\t */\n\tasync readChunk(max: number): Promise<Uint8Array> {\n\t\tif (this.#buffer.byteLength === 0 && this.#chunked === 0 && !(await this.#fill())) throw new UnexpectedEnd();\n\t\t// What a decode ran short of is measured from bytes this consumes.\n\t\tthis.#short = undefined;\n\t\tif (this.#buffer.byteLength > 0) return this.#slice(Math.min(max, this.#buffer.byteLength));\n\t\tconst chunk = this.#chunks[0];\n\t\tif (chunk.byteLength <= max) {\n\t\t\tthis.#chunks.shift();\n\t\t\tthis.#chunked -= chunk.byteLength;\n\t\t\treturn chunk;\n\t\t}\n\t\tthis.#chunks[0] = chunk.subarray(max);\n\t\tthis.#chunked -= max;\n\t\treturn chunk.subarray(0, max);\n\t}\n\n\tasync readAll(): Promise<Uint8Array> {\n\t\twhile (await this.#fill()) {\n\t\t\t// keep going\n\t\t}\n\t\tthis.#join();\n\t\treturn this.#slice(this.#buffer.byteLength);\n\t}\n\n\t// Reads to the end of the stream, dropping every byte instead of buffering it.\n\tasync discard(): Promise<void> {\n\t\tthis.#buffer = new Uint8Array();\n\t\tdo {\n\t\t\tthis.#chunks = [];\n\t\t\tthis.#chunked = 0;\n\t\t} while (await this.#fill());\n\t}\n\n\tasync string(): Promise<string> {\n\t\treturn this.decode(STRING);\n\t}\n\n\tasync bool(): Promise<boolean> {\n\t\treturn this.decode(BOOL);\n\t}\n\n\tasync u8(): Promise<number> {\n\t\treturn this.decode(U8);\n\t}\n\n\tasync u16(): Promise<number> {\n\t\treturn this.decode(U16);\n\t}\n\n\t// Returns a Number using 53-bits, the max Javascript can use for integer math.\n\tasync u53(): Promise<number> {\n\t\treturn this.decode(U53);\n\t}\n\n\t// NOTE: Returns a bigint instead of a number since it may be larger than 53-bits\n\tasync u62(): Promise<bigint> {\n\t\treturn this.decode(U62);\n\t}\n\n\t/** Like {@link u62}, but leaves the varint buffered, so a stream's type can be read twice. */\n\tasync peekU62(): Promise<bigint> {\n\t\treturn this.peek(U62);\n\t}\n\n\tasync varint(): Promise<U64> {\n\t\treturn this.decode(VARINT);\n\t}\n\n\t// Returns false if there is more data to read, blocking if it hasn't been received yet.\n\tasync done(): Promise<boolean> {\n\t\tif (this.#buffer.byteLength > 0 || this.#chunked > 0) return false;\n\t\treturn !(await this.#fill());\n\t}\n\n\t// The transport error is built only while the stream is still open. After a FIN the\n\t// reader is gone, so this allocates nothing and sends nothing.\n\tstop(reason: unknown) {\n\t\tconst reader = this.#reader;\n\t\tif (!reader) return;\n\t\tthis.#reader = undefined;\n\t\tthis.#stream = undefined;\n\t\treader.cancel(stopReason(reason, this.version)).catch(() => void 0);\n\t}\n\n\t/** A non-consuming peer reset notification on transports that support one. */\n\tget resetSignal(): AbortSignal | undefined {\n\t\treturn this.#stream?.resetSignal;\n\t}\n\n\t// Decoded like #fill: a caller racing this against a read must not get a different error\n\t// shape depending on which one won. Derived once, so racing it per frame doesn't allocate.\n\tget closed(): Promise<void> {\n\t\tthis.#closed ??= (this.#reader?.closed ?? Promise.resolve()).catch((err: unknown) => {\n\t\t\tthrow fromTransport(err, { version: asIetf(this.version) });\n\t\t});\n\t\treturn this.#closed;\n\t}\n}\n\n/** The stream ended cleanly partway through a read. */\nexport class UnexpectedEnd extends Error {\n\tconstructor() {\n\t\tsuper(\"unexpected end of stream\");\n\t}\n}\n\n// Thrown by a Cursor read that runs past the buffered bytes, carrying how many bytes from the\n// start of the buffer the decode needs. Not an Error: it ends every chunk, so it must not\n// capture a stack.\nclass Short {\n\treadonly need: number;\n\n\tconstructor(need: number) {\n\t\tthis.need = need;\n\t}\n}\n\nconst EMPTY = new Short(1);\n\n/**\n * A synchronous view over a {@link Reader}'s buffered bytes, handed to {@link Reader.decode}.\n *\n * A read past the buffered bytes throws an internal signal that the Reader catches: it consumes\n * nothing, fills, and runs the decode again from the start. A decode must therefore not mutate\n * anything before its last read, must not swallow what it throws, and must read at least a byte.\n */\nexport class Cursor {\n\treadonly version: StreamVersion;\n\t#buffer: Uint8Array;\n\t#offset = 0;\n\t// Resolved once, since every varint read branches on it.\n\t#leadingOnes: boolean;\n\t// First bytes below this are a whole 1-byte varint, and below this + 0x40 a 2-byte one whose\n\t// value is the low 6 bits and the next byte. Both formats share that shape; only the bound moves.\n\t#short: number;\n\t// First bytes below this are a varint of at most 4 bytes: 0xc0 for QUIC, 0xf0 for leading-ones.\n\t#word: number;\n\n\tconstructor(buffer: Uint8Array, version: StreamVersion) {\n\t\tthis.#buffer = buffer;\n\t\tthis.version = version;\n\t\tthis.#leadingOnes = isLeadingOnes(version);\n\t\tthis.#short = this.#leadingOnes ? 0x80 : 0x40;\n\t\tthis.#word = this.#leadingOnes ? 0xf0 : 0xc0;\n\t}\n\n\t/** How many bytes have been read. */\n\tget offset(): number {\n\t\treturn this.#offset;\n\t}\n\n\t/** How many buffered bytes are left to read. */\n\tget remaining(): number {\n\t\treturn this.#buffer.byteLength - this.#offset;\n\t}\n\n\t/**\n\t * Decode the next `size` bytes on their own. Running past them, or leaving any unread, is\n\t * malformed rather than a reason to wait for more.\n\t */\n\texact<T>(size: number, decode: (c: Cursor) => T): T {\n\t\tconst inner = new Cursor(this.read(size), this.version);\n\t\tlet result: T;\n\t\ttry {\n\t\t\tresult = decode(inner);\n\t\t} catch (err: unknown) {\n\t\t\tif (err instanceof Short) throw new Error(`message is shorter than its fields: ${size} bytes`);\n\t\t\tthrow err;\n\t\t}\n\t\tif (inner.remaining > 0) throw new Error(`message has ${inner.remaining} unread bytes`);\n\t\treturn result;\n\t}\n\n\t#ensure(size: number) {\n\t\tconst need = this.#offset + size;\n\t\t// Checked here too, and on the whole decode like the fill, since bytes that are already\n\t\t// buffered never reach the fill.\n\t\tif (need > MAX_READ_SIZE) throw new Error(`read size ${need} exceeds max size ${MAX_READ_SIZE}`);\n\t\tif (need > this.#buffer.byteLength) throw new Short(need);\n\t}\n\n\t/** Read `size` bytes, as a view onto the buffer rather than a copy. */\n\tread(size: number): Uint8Array {\n\t\tthis.#ensure(size);\n\t\tconst start = this.#offset;\n\t\tthis.#offset += size;\n\t\treturn this.#buffer.subarray(start, this.#offset);\n\t}\n\n\tstring(): string {\n\t\treturn decodeUtf8(this.read(this.u53()));\n\t}\n\n\tbool(): boolean {\n\t\tconst v = this.u8();\n\t\tif (v === 0) return false;\n\t\tif (v === 1) return true;\n\t\tthrow new Error(\"invalid bool value\");\n\t}\n\n\tu8(): number {\n\t\tthis.#ensure(1);\n\t\treturn this.#buffer[this.#offset++];\n\t}\n\n\tu16(): number {\n\t\tthis.#ensure(2);\n\t\tconst b = this.#buffer;\n\t\tconst o = this.#offset;\n\t\tthis.#offset += 2;\n\t\treturn (b[o] << 8) | b[o + 1];\n\t}\n\n\t/** Read a varint as a `number`, throwing if it is above `Number.MAX_SAFE_INTEGER`. */\n\tu53(): number {\n\t\t// Most varints are 1 or 2 bytes, which skip the general decode.\n\t\tthis.#ensure(1);\n\t\tconst b = this.#buffer;\n\t\tconst o = this.#offset;\n\t\tconst first = b[o];\n\t\tif (first < this.#short) {\n\t\t\tthis.#offset = o + 1;\n\t\t\treturn first;\n\t\t}\n\t\tif (first < this.#short + 0x40) {\n\t\t\tthis.#ensure(2);\n\t\t\tthis.#offset = o + 2;\n\t\t\treturn ((first & 0x3f) << 8) | b[o + 1];\n\t\t}\n\t\t// Up to 4 bytes still fits 28 (leading-ones) or 30 (QUIC) bits, with no upper half.\n\t\tif (first < this.#word) {\n\t\t\tconst size = this.#leadingOnes ? peekLeadingOnes(first) : 4;\n\t\t\tthis.#ensure(size);\n\t\t\tthis.#offset = o + size;\n\t\t\tif (size === 3) return ((first & 0x1f) << 16) | (b[o + 1] << 8) | b[o + 2];\n\t\t\treturn ((first & (this.#leadingOnes ? 0x0f : 0x3f)) << 24) | (b[o + 1] << 16) | (b[o + 2] << 8) | b[o + 3];\n\t\t}\n\t\tconst lo = this.#varint();\n\t\treturn toNumber(parts.hi, lo);\n\t}\n\n\t/** Read a varint as a bigint. A leading-ones varint may exceed 62 bits. */\n\tu62(): bigint {\n\t\tconst lo = this.#varint();\n\t\treturn toBigInt(parts.hi, lo);\n\t}\n\n\t/** Read a varint. */\n\tvarint(): U64 {\n\t\tconst lo = this.#varint();\n\t\treturn new U64(parts.hi, lo);\n\t}\n\n\t// Decode the next varint in the version's format, returning its lower half and leaving the upper in `parts`.\n\t#varint(): number {\n\t\tthis.#ensure(1);\n\t\tconst b = this.#buffer;\n\t\tconst o = this.#offset;\n\t\tlet size: number;\n\t\tif (this.#leadingOnes) {\n\t\t\tsize = peekLeadingOnes(b[o]);\n\t\t\t// 1111110x is a 7-byte form, which draft-18+ allows per #1595.\n\t\t\tthis.#ensure(size);\n\t\t\tthis.#offset += size;\n\t\t\treturn readLeadingOnes(b, o, size);\n\t\t}\n\t\tsize = peekQuic(b[o]);\n\t\tthis.#ensure(size);\n\t\tthis.#offset += size;\n\t\treturn readQuic(b, o, size);\n\t}\n}\n\n// Shared decodes for the Reader's async primitives, so a read allocates no closure.\nconst STRING = (c: Cursor) => c.string();\nconst BOOL = (c: Cursor) => c.bool();\nconst U8 = (c: Cursor) => c.u8();\nconst U16 = (c: Cursor) => c.u16();\nconst U53 = (c: Cursor) => c.u53();\nconst U62 = (c: Cursor) => c.u62();\nconst VARINT = (c: Cursor) => c.varint();\n\n// Writer wraps a stream and writes chunks of data\nexport class Writer implements OpenStream {\n\t#writer: WritableStreamDefaultWriter<Uint8Array>;\n\t#stream: WritableStream<Uint8Array>;\n\t#closed?: Promise<void>;\n\n\t/** The bytes handed to the stream so far. */\n\t#written = 0;\n\t#sendOrder = 0;\n\t/** Whether the transport reports acknowledgements, as the session's open streams say. */\n\t#acknowledges = false;\n\t/** Reset by this side, or failed or stopped by the peer, so never acknowledged. */\n\t#aborted = false;\n\t/** The bytes every later reset still delivers, once {@link hold} marks them. */\n\t#held?: number;\n\t/** What this side first reset the stream with, which tells its end apart from a peer's stop. */\n\t#reason?: unknown;\n\t/** The code the peer stopped the stream with. */\n\t#stop?: StreamCode;\n\t/** The session's open group streams, while this one is among them. */\n\t#listed?: OpenStreams;\n\n\t// Scratch buffer for each primitive write, sized for the longest (a 9-byte leading-ones varint).\n\t#scratch: ArrayBuffer;\n\n\tversion: StreamVersion;\n\n\tconstructor(stream: WritableStream<Uint8Array>, version: StreamVersion) {\n\t\tthis.#stream = stream;\n\t\tthis.#scratch = new ArrayBuffer(9);\n\t\tthis.#writer = this.#stream.getWriter();\n\t\tthis.version = version;\n\t\t// The stream ends once it is finished, or with a failure: a reset, a stop, or the session closing.\n\t\tthis.#writer.closed.then(\n\t\t\t() => this.#unlist(),\n\t\t\t(err: unknown) => {\n\t\t\t\tthis.#aborted = true;\n\t\t\t\t// A reset of this side's ends the stream with its own reason, so any other code is the peer's stop.\n\t\t\t\tif (err !== this.#reason) this.#stop = streamCode(err);\n\t\t\t\tthis.#unlist();\n\t\t\t},\n\t\t);\n\t}\n\n\t/** The send order the stream has now, where HIGHER values are sent first. */\n\tget sendOrder(): number {\n\t\treturn this.#sendOrder;\n\t}\n\n\t/**\n\t * Rank this stream against the session's others, where HIGHER values are sent first.\n\t *\n\t * A send order only schedules the local end, so a stream the peer opened has to be ranked\n\t * here rather than at the peer's {@link open}.\n\t *\n\t * The spec makes `sendOrder` a settable attribute on every {@link SendStream}. Where the\n\t * interface isn't implemented (Chrome as of writing, a mock, a polyfill) this just sets an\n\t * ignored property, the same way an ignored `sendOrder` option does at {@link open}.\n\t */\n\tsetPriority(sendOrder: number) {\n\t\tthis.#sendOrder = sendOrder;\n\t\t(this.#stream as SendStream).sendOrder = sendOrder;\n\t}\n\n\t/**\n\t * Whether the peer has acknowledged every byte written so far, or undefined when the\n\t * transport cannot tell, as a browser's WebTransport cannot.\n\t */\n\tasync acknowledged(): Promise<boolean | undefined> {\n\t\tif (!this.#acknowledges) return undefined;\n\t\tif (this.#aborted) return false;\n\t\tconst written = this.#written;\n\t\tconst stats = await (this.#stream as Stats).getStats();\n\t\treturn !this.#aborted && stats.bytesAcknowledged >= written;\n\t}\n\n\t/**\n\t * From now on, every reset of the stream, a preemption included, still delivers the bytes\n\t * written so far. Call it once every write so far resolved. Returns whether the transport\n\t * can, holding nothing otherwise: a browser's WebTransport cannot, nor can a peer without\n\t * RESET_STREAM_AT, whose plain reset lets it discard bytes it has not read; and a stream\n\t * already reset or stopped, perhaps preempted before this, has lost them already.\n\t */\n\thold(): boolean {\n\t\tif (this.#aborted || (this.#stream as Partial<ResetsAt>).reliableReset !== true) return false;\n\t\tthis.#held = this.#written;\n\t\treturn true;\n\t}\n\n\t/**\n\t * Whether the peer acknowledged every byte {@link hold} marked, even after the stream ended;\n\t * false when nothing is held or the transport cannot tell.\n\t */\n\tasync heldAcknowledged(): Promise<boolean> {\n\t\tconst held = this.#held;\n\t\tif (held === undefined || !this.#acknowledges) return false;\n\t\tconst stats = await (this.#stream as Stats).getStats();\n\t\treturn stats.bytesAcknowledged >= held;\n\t}\n\n\t/**\n\t * The code the peer stopped the stream with, or undefined while it has not: still open,\n\t * finished, reset by this side first, or failed with its session. Known before a write or\n\t * {@link closed} that the stop failed settles.\n\t */\n\tget stopped(): StreamCode | undefined {\n\t\treturn this.#stop;\n\t}\n\n\tasync bool(v: boolean) {\n\t\tawait this.write(setUint8(this.#scratch, v ? 1 : 0));\n\t}\n\n\tasync u8(v: number) {\n\t\tif (!Number.isInteger(v) || v < 0 || v > 255) {\n\t\t\tthrow new RangeError(`invalid u8: ${v}`);\n\t\t}\n\t\tawait this.write(setUint8(this.#scratch, v));\n\t}\n\n\tasync u16(v: number) {\n\t\tawait this.write(setUint16(this.#scratch, v));\n\t}\n\n\tasync i32(v: number) {\n\t\tif (Math.abs(v) > MAX_U31) {\n\t\t\tthrow new Error(`overflow, value larger than 32-bits: ${v.toString()}`);\n\t\t}\n\n\t\t// We don't use a varint, so it always takes 4 bytes.\n\t\t// This could be improved but nothing is standardized yet.\n\t\tawait this.write(setInt32(this.#scratch, v));\n\t}\n\n\tasync u53(v: number) {\n\t\tif (!Number.isSafeInteger(v) || v < 0) {\n\t\t\tthrow new RangeError(`invalid u53: ${v}`);\n\t\t}\n\t\tawait this.#varint(Math.floor(v / POW32), v >>> 0);\n\t}\n\n\tasync u62(v: bigint) {\n\t\tconst lo = split(v);\n\t\tawait this.#varint(parts.hi, lo);\n\t}\n\n\tasync varint(v: U64) {\n\t\tawait this.#varint(v.hi, v.lo);\n\t}\n\n\t#varint(hi: number, lo: number): Promise<void> {\n\t\treturn this.write(encodeTo(this.#scratch, hi, lo, this.version));\n\t}\n\n\tasync write(v: Uint8Array) {\n\t\t// Yield before handing the bytes over, so a write still pending is one the transport has\n\t\t// not taken: a caller racing it against the peer's end never abandons bytes already sent.\n\t\t// Count it synchronously, so acknowledged() never treats a pending write as acknowledged.\n\t\tthis.#written += v.byteLength;\n\t\tconst pause = writeBudget.poll();\n\t\tif (pause !== undefined) await pause;\n\t\t// Mirrors Reader.#fill: every write funnels through here, so a STOP_SENDING from the\n\t\t// peer surfaces as a typed code rather than the transport's own error shape.\n\t\tawait this.#writer.write(v).catch((err: unknown) => {\n\t\t\tthrow fromTransport(err, { version: asIetf(this.version) });\n\t\t});\n\t}\n\n\tasync string(str: string) {\n\t\tconst data = new TextEncoder().encode(str);\n\t\tawait this.u53(data.byteLength);\n\t\tawait this.write(data);\n\t}\n\n\tclose() {\n\t\tthis.#unlist();\n\t\tthis.#writer.close().catch(() => void 0);\n\t}\n\n\t// Mirrors Reader.closed: a STOP_SENDING reaches a caller racing this with the same\n\t// typed code it would get from a write.\n\tget closed(): Promise<void> {\n\t\tthis.#closed ??= this.#writer.closed.catch((err: unknown) => {\n\t\t\tthrow fromTransport(err, { version: asIetf(this.version) });\n\t\t});\n\t\treturn this.#closed;\n\t}\n\n\t/** Reset the stream to make room for a higher one, failing its writer as too far behind. */\n\tpreempt() {\n\t\tthis.reset(new TooFarBehind());\n\t}\n\n\t/** Reset the stream with `reason`, still delivering what {@link hold} marked where the transport can. */\n\treset(reason: unknown) {\n\t\tthis.#aborted = true;\n\t\tthis.#unlist();\n\t\tconst coded = withCode(reason, this.version);\n\t\t// Only the first reset reaches the transport, so its reason is the one the stream ends with.\n\t\tthis.#reason ??= coded;\n\t\tif (this.#held !== undefined) {\n\t\t\t(this.#stream as ResetsAt).resetAt(this.#held, coded);\n\t\t} else {\n\t\t\tthis.#writer.abort(coded).catch(() => void 0);\n\t\t}\n\t}\n\n\t#unlist() {\n\t\tthis.#listed?.delete(this);\n\t\tthis.#listed = undefined;\n\t}\n\n\t/** Run `f` against a Writer that buffers in memory, returning everything it wrote as one chunk. */\n\tstatic async collect(version: StreamVersion, f: (w: Writer) => Promise<void>): Promise<Uint8Array> {\n\t\tconst chunks: Uint8Array[] = [];\n\t\t// Copied, since each primitive reuses the Writer's scratch buffer.\n\t\tconst w = new Writer(\n\t\t\tnew WritableStream<Uint8Array>({ write: (chunk) => void chunks.push(chunk.slice()) }),\n\t\t\tversion,\n\t\t);\n\t\ttry {\n\t\t\tawait f(w);\n\t\t} finally {\n\t\t\tw.close();\n\t\t}\n\t\tawait w.closed;\n\t\treturn concat(chunks);\n\t}\n\n\t/**\n\t * Open an outgoing unidirectional stream.\n\t * @param quic - The session to open it on\n\t * @param options - The version its varints encode with, and the send order ranking it\n\t * against the session's other streams\n\t */\n\t/** Open a send-only stream, waiting its turn for the peer's stream credit. */\n\tstatic async open(quic: WebTransport, options: OpenOptions): Promise<Writer> {\n\t\tconst session = lines(quic);\n\t\tconst writable = await session.uni.open(options.sendOrder ?? 0);\n\t\treturn Writer.#opened(writable, options.version, options.sendOrder ?? 0, session.streams);\n\t}\n\n\t/**\n\t * Like {@link Writer.open}, but leaves the line once `cancel` settles, returning undefined\n\t * so the caller can drop whatever it meant to send. The stream its create admits later goes\n\t * to the next open in line. A transport failure, or a rejected `cancel`, still throws.\n\t */\n\tstatic async tryOpen(quic: WebTransport, options: TryOpenOptions): Promise<Writer | undefined> {\n\t\tconst session = lines(quic);\n\t\tconst rank = options.sendOrder ?? 0;\n\t\t// The line ranks the stream it hands out by its last read, which can differ from a read now.\n\t\tlet sendOrder = typeof rank === \"number\" ? rank : 0;\n\t\tconst read = typeof rank === \"number\" ? rank : () => (sendOrder = rank());\n\t\tconst writable = await session.uni.open(read, options.cancel);\n\t\tif (!writable) return undefined;\n\t\tconst writer = Writer.#opened(writable, options.version, sendOrder, session.streams);\n\t\tif (options.group) {\n\t\t\twriter.#listed = session.streams;\n\t\t\tsession.streams.add(writer);\n\t\t}\n\t\treturn writer;\n\t}\n\n\tstatic #opened(writable: SendStream, version: StreamVersion, sendOrder: number, streams: OpenStreams): Writer {\n\t\tconst writer = new Writer(writable, version);\n\t\twriter.#sendOrder = sendOrder;\n\t\twriter.#acknowledges = streams.acknowledges;\n\t\treturn writer;\n\t}\n}\n\nfunction setUint8(dst: ArrayBuffer, v: number): Uint8Array {\n\tconst buffer = new Uint8Array(dst, 0, 1);\n\tbuffer[0] = v;\n\treturn buffer;\n}\n\nfunction setUint16(dst: ArrayBuffer, v: number): Uint8Array {\n\tconst view = new DataView(dst, 0, 2);\n\tview.setUint16(0, v);\n\treturn new Uint8Array(view.buffer, view.byteOffset, view.byteLength);\n}\n\nfunction setInt32(dst: ArrayBuffer, v: number): Uint8Array {\n\tconst view = new DataView(dst, 0, 4);\n\tview.setInt32(0, v);\n\treturn new Uint8Array(view.buffer, view.byteOffset, view.byteLength);\n}\n\n// Returns the next stream from the connection\nexport class Readers {\n\t#reader: ReadableStreamDefaultReader<ReadableStream<Uint8Array>>;\n\t#version: StreamVersion;\n\n\tconstructor(quic: WebTransport, version: StreamVersion) {\n\t\tthis.#reader = quic.incomingUnidirectionalStreams.getReader() as ReadableStreamDefaultReader<\n\t\t\tReadableStream<Uint8Array>\n\t\t>;\n\t\tthis.#version = version;\n\t}\n\n\tasync next(): Promise<Reader | undefined> {\n\t\tconst pause = acceptBudget.poll();\n\t\tif (pause !== undefined) await pause;\n\t\tconst next = await this.#reader.read();\n\t\tif (next.done) return;\n\t\treturn new Reader(next.value, undefined, this.#version);\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription.test-util.d.ts","sourceRoot":"","sources":["../src/subscription.test-util.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Duration } from "@moq/clock";
|
|
2
|
+
import { Subscription } from "./track.js";
|
|
3
|
+
import { policyOf, rangesPolicy, withPolicy } from "./window.js";
|
|
4
|
+
/** The priority and order `subscription`'s ranges ask as a whole, or nothing without one. @internal */
|
|
5
|
+
export function topPolicy(subscription) {
|
|
6
|
+
return subscription && rangesPolicy(subscription.ranges ?? []);
|
|
7
|
+
}
|
|
8
|
+
/** `subscription` with every range at `priority` and `order`, as one subscription-wide policy asked. @internal */
|
|
9
|
+
export function everyRange(subscription, policy) {
|
|
10
|
+
// The defaults left out, as the model holds them.
|
|
11
|
+
const ranges = (subscription.ranges ?? Subscription.default().ranges ?? []).map((range) => withPolicy(range, {
|
|
12
|
+
priority: policy.priority ?? policyOf(range).priority,
|
|
13
|
+
order: policy.order ?? policyOf(range).order,
|
|
14
|
+
}));
|
|
15
|
+
return { ...subscription, ranges };
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* `subscription` under its `delay.max` the way one subscription-wide max applied it: the oldest
|
|
19
|
+
* group, and the default ranges, take every group still within it (or every group for `null`); a
|
|
20
|
+
* live join keeps its lag and takes it; a time start is history either way. Mirrors the Rust test
|
|
21
|
+
* helper `Subscription::with_max`. @internal
|
|
22
|
+
*/
|
|
23
|
+
export function withMax(subscription) {
|
|
24
|
+
const { delay, ranges, priority, order, ...rest } = subscription;
|
|
25
|
+
const max = delay?.max === undefined ? Duration.ZERO : delay.max;
|
|
26
|
+
const within = () => (max === null ? undefined : { live: { min: null, max } });
|
|
27
|
+
const out = (ranges ?? [{}]).map((range) => {
|
|
28
|
+
const start = range.start;
|
|
29
|
+
const mapped = {};
|
|
30
|
+
if (start === undefined) {
|
|
31
|
+
const joined = within();
|
|
32
|
+
if (joined !== undefined)
|
|
33
|
+
mapped.start = joined;
|
|
34
|
+
}
|
|
35
|
+
else if (typeof start === "bigint")
|
|
36
|
+
mapped.start = start;
|
|
37
|
+
else
|
|
38
|
+
mapped.start = { live: { min: Duration.is(start.live) ? start.live : start.live.min, max } };
|
|
39
|
+
if (range.end !== undefined)
|
|
40
|
+
mapped.end = range.end;
|
|
41
|
+
if (range.priority !== undefined)
|
|
42
|
+
mapped.priority = range.priority;
|
|
43
|
+
if (range.order !== undefined)
|
|
44
|
+
mapped.order = range.order;
|
|
45
|
+
return mapped;
|
|
46
|
+
});
|
|
47
|
+
return everyRange({ ...rest, ranges: out }, { priority, order });
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=subscription.test-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription.test-util.js","sourceRoot":"","sources":["../src/subscription.test-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAqC,YAAY,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAe,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAqB9E,uGAAuG;AACvG,MAAM,UAAU,SAAS,CAAC,YAAsC;IAC/D,OAAO,YAAY,IAAI,YAAY,CAAC,YAAY,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;AAChE,CAAC;AAED,kHAAkH;AAClH,MAAM,UAAU,UAAU,CAAC,YAA0B,EAAE,MAA4C;IAClG,kDAAkD;IAClD,MAAM,MAAM,GAAG,CAAC,YAAY,CAAC,MAAM,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACzF,UAAU,CAAC,KAAK,EAAE;QACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,QAAQ;QACrD,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK;KAC5C,CAAC,CACF,CAAC;IACF,OAAO,EAAE,GAAG,YAAY,EAAE,MAAM,EAAE,CAAC;AACpC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,YAAgC;I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SAAS;YAAE,MAAM,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QACnE,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;YAAE,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAC1D,OAAO,MAAM,CAAC;IACf,CAAC,CAAC,CAAC;IACH,OAAO,UAAU,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import { Duration } from \"@moq/clock\";\nimport { type Live, type Order, type Range, Subscription } from \"./track.ts\";\nimport { type Policy, policyOf, rangesPolicy, withPolicy } from \"./window.ts\";\n\n/** A range as a test states it under one subscription-wide max: a live join may give its lag alone. @internal */\nexport type LegacyRange = {\n\tstart?: bigint | { live: Duration | Live };\n\tend?: bigint;\n\tpriority?: number;\n\torder?: Order;\n};\n\n/**\n * A subscription as a test states it under one subscription-wide `delay.max`, `null` for none, and\n * one priority and order every range takes. @internal\n */\nexport type LegacySubscription = Omit<Subscription, \"ranges\"> & {\n\tdelay?: { max?: Duration | null };\n\tpriority?: number;\n\torder?: Order;\n\tranges?: readonly LegacyRange[];\n};\n\n/** The priority and order `subscription`'s ranges ask as a whole, or nothing without one. @internal */\nexport function topPolicy(subscription: Subscription | undefined): Policy | undefined {\n\treturn subscription && rangesPolicy(subscription.ranges ?? []);\n}\n\n/** `subscription` with every range at `priority` and `order`, as one subscription-wide policy asked. @internal */\nexport function everyRange(subscription: Subscription, policy: { priority?: number; order?: Order }): Subscription {\n\t// The defaults left out, as the model holds them.\n\tconst ranges = (subscription.ranges ?? Subscription.default().ranges ?? []).map((range) =>\n\t\twithPolicy(range, {\n\t\t\tpriority: policy.priority ?? policyOf(range).priority,\n\t\t\torder: policy.order ?? policyOf(range).order,\n\t\t}),\n\t);\n\treturn { ...subscription, ranges };\n}\n\n/**\n * `subscription` under its `delay.max` the way one subscription-wide max applied it: the oldest\n * group, and the default ranges, take every group still within it (or every group for `null`); a\n * live join keeps its lag and takes it; a time start is history either way. Mirrors the Rust test\n * helper `Subscription::with_max`. @internal\n */\nexport function withMax(subscription: LegacySubscription): Subscription {\n\tconst { delay, ranges, priority, order, ...rest } = subscription;\n\tconst max = delay?.max === undefined ? Duration.ZERO : delay.max;\n\tconst within = (): Range[\"start\"] => (max === null ? undefined : { live: { min: null, max } });\n\tconst out = (ranges ?? [{}]).map((range): Range => {\n\t\tconst start = range.start;\n\t\tconst mapped: Range = {};\n\t\tif (start === undefined) {\n\t\t\tconst joined = within();\n\t\t\tif (joined !== undefined) mapped.start = joined;\n\t\t} else if (typeof start === \"bigint\") mapped.start = start;\n\t\telse mapped.start = { live: { min: Duration.is(start.live) ? start.live : start.live.min, max } };\n\t\tif (range.end !== undefined) mapped.end = range.end;\n\t\tif (range.priority !== undefined) mapped.priority = range.priority;\n\t\tif (range.order !== undefined) mapped.order = range.order;\n\t\treturn mapped;\n\t});\n\treturn everyRange({ ...rest, ranges: out }, { priority, order });\n}\n"]}
|
package/tail.d.ts
CHANGED
|
@@ -1,18 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/**
|
|
3
|
-
* How long a subscriber waits for a group stream it cannot account for once the publisher
|
|
4
|
-
* has ended the subscription.
|
|
5
|
-
*
|
|
6
|
-
* A group reset before its header arrived leaves no trace, and QUIC does not order streams,
|
|
7
|
-
* so a stream opened before the end can still be in flight after it. This bounds the wait on
|
|
8
|
-
* IETF, and on moq-lite when the subscription has no max age to bound it with.
|
|
9
|
-
*/
|
|
10
|
-
export declare const TAIL_GRACE_MS: Milli;
|
|
1
|
+
import { type Duration } from "@moq/clock";
|
|
11
2
|
/** How a {@link Tail} measures its grace. */
|
|
12
3
|
export interface TailOptions {
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
/**
|
|
5
|
+
* How long to wait for a group that cannot be accounted for, or `undefined` to wait until the
|
|
6
|
+
* wire accounts for it (lite-07, which names every start). Read each time it is needed.
|
|
7
|
+
*/
|
|
8
|
+
grace?: () => Duration | undefined;
|
|
9
|
+
/** Lite-07: the publisher names every start, so the ledger never folds a gap (see {@link Tail.lost}). */
|
|
10
|
+
proven?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** A group stream a {@link Tail} counts, from its header until it is read to its end. */
|
|
13
|
+
export interface Counted {
|
|
14
|
+
/** Stop holding the end open for it: read to its end, or a drop accounted for its group. Idempotent. */
|
|
15
|
+
done(): void;
|
|
16
|
+
/** Stop holding the end open while it waits, unread, on a copy another stream delivers. Idempotent. */
|
|
17
|
+
park(): void;
|
|
18
|
+
/** Hold the end open again once it reads the group itself. Idempotent. */
|
|
19
|
+
resume(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Settles once {@link Tail.drain} gave up on it: the subscription ended and it delivered nothing
|
|
22
|
+
* for the grace, as a stream whose reset the browser lost does. It stays counted
|
|
23
|
+
* until the reader ends it with {@link done}.
|
|
24
|
+
*/
|
|
25
|
+
readonly stalled: Promise<void>;
|
|
17
26
|
}
|
|
18
27
|
//# sourceMappingURL=tail.d.ts.map
|
package/tail.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tail.d.ts","sourceRoot":"","sources":["../src/tail.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tail.d.ts","sourceRoot":"","sources":["../src/tail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAA4B,MAAM,YAAY,CAAC;AAMrE,6CAA6C;AAC7C,MAAM,WAAW,WAAW;IAC3B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,QAAQ,GAAG,SAAS,CAAC;IACnC,yGAAyG;IACzG,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,yFAAyF;AACzF,MAAM,WAAW,OAAO;IACvB,wGAAwG;IACxG,IAAI,IAAI,IAAI,CAAC;IACb,uGAAuG;IACvG,IAAI,IAAI,IAAI,CAAC;IACb,0EAA0E;IAC1E,MAAM,IAAI,IAAI,CAAC;IACf;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC"}
|