@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
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Version } from "./ietf/version.js";
|
|
1
|
+
import { now } from "@moq/clock";
|
|
2
|
+
import { fromTransport, StreamCode, streamCode, TooFarBehind, toStreamCode, toTransport } from "./error.js";
|
|
3
|
+
import { sharedStreamCode } from "./ietf/error.js";
|
|
5
4
|
import { Version as Lite } from "./lite/version.js";
|
|
6
|
-
import {
|
|
5
|
+
import { lines } from "./open.js";
|
|
6
|
+
import { decodeError } from "./util/decode_error.js";
|
|
7
7
|
import { POW32, toBigInt, toNumber, U64 } from "./util/u64.js";
|
|
8
8
|
import { decodeUtf8 } from "./util/utf8.js";
|
|
9
9
|
import { lengthLeadingOnes, lengthQuic, parts, peekLeadingOnes, peekQuic, readLeadingOnes, readQuic, split, writeLeadingOnes, writeQuic, } from "./util/varint.js";
|
|
10
|
+
import { Budget } from "./util/yield.js";
|
|
11
|
+
/** Sharing the slice across writers bounds concurrent groups and subscriber fanout too.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export const writeBudget = new Budget();
|
|
15
|
+
/** Stream credit alone lets a peer keep thousands of streams ready, each accepted in a
|
|
16
|
+
* microtask, so accept loops share a slice that lets the host's other tasks run.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export const acceptBudget = new Budget();
|
|
10
20
|
// Decode raw transport errors before mapping so they cannot bypass the negotiated
|
|
11
21
|
// registry. Ordinary errors already send 0 and retain their local identity.
|
|
12
22
|
function withCode(reason, stream) {
|
|
@@ -15,37 +25,16 @@ function withCode(reason, stream) {
|
|
|
15
25
|
const code = toStreamCode(decoded, { version });
|
|
16
26
|
return code === StreamCode.Internal && decoded === reason ? reason : toTransport(code, decoded.message);
|
|
17
27
|
}
|
|
28
|
+
// A bare number is a stream code, and only Reader.stop takes one. Writer.reset stays on
|
|
29
|
+
// withCode, which reads a number as a non-stream error and sends Internal.
|
|
30
|
+
function stopReason(reason, stream) {
|
|
31
|
+
if (typeof reason !== "number")
|
|
32
|
+
return withCode(reason, stream);
|
|
33
|
+
const code = asIetf(stream) === undefined || sharedStreamCode(reason) ? reason : StreamCode.Internal;
|
|
34
|
+
return toTransport(code, "cancel");
|
|
35
|
+
}
|
|
18
36
|
const MAX_U31 = 2 ** 31 - 1;
|
|
19
37
|
const MAX_READ_SIZE = 1024 * 1024 * 64; // don't allocate more than 64MB for a message
|
|
20
|
-
/**
|
|
21
|
-
* Options handed to the transport for one outgoing stream.
|
|
22
|
-
*
|
|
23
|
-
* `waitUntilAvailable` waits for the peer's concurrent stream limit to free a slot instead
|
|
24
|
-
* of rejecting with a `QuotaExceededError`, which is what we want for the streams a session
|
|
25
|
-
* opens occasionally. `@types/web` doesn't declare it yet, hence the intersection.
|
|
26
|
-
*/
|
|
27
|
-
export function sendOptions(options) {
|
|
28
|
-
return { sendOrder: options?.sendOrder, waitUntilAvailable: options?.waitUntilAvailable ?? true };
|
|
29
|
-
}
|
|
30
|
-
// How long any open may wait for the peer to free a stream slot. Every open needs this,
|
|
31
|
-
// whether or not it asked to wait: an implementation may park an over-limit open rather
|
|
32
|
-
// than rejecting it, and a peer can advertise a stream limit of zero and never raise it.
|
|
33
|
-
// Matches the subscribe budget.
|
|
34
|
-
const OPEN_TIMEOUT_MS = 10_000;
|
|
35
|
-
/**
|
|
36
|
-
* Bound an open that would otherwise park until the peer grants stream credit, restoring
|
|
37
|
-
* the pre-waitUntilAvailable failure after a grace period. A stream arriving after the
|
|
38
|
-
* deadline is discarded, since nobody is waiting for it any more.
|
|
39
|
-
*/
|
|
40
|
-
async function openWithin(opening, timeout, discard) {
|
|
41
|
-
try {
|
|
42
|
-
return await withTimeout(opening, timeout, `stream open timed out after ${timeout}ms waiting for a slot`);
|
|
43
|
-
}
|
|
44
|
-
catch (err) {
|
|
45
|
-
opening.then(discard).catch(() => void 0);
|
|
46
|
-
throw err;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
38
|
const LITE = new Set(Object.values(Lite));
|
|
50
39
|
function isLite(version) {
|
|
51
40
|
return LITE.has(version);
|
|
@@ -54,12 +43,12 @@ function isLite(version) {
|
|
|
54
43
|
export function asIetf(version) {
|
|
55
44
|
return isLite(version) ? undefined : version;
|
|
56
45
|
}
|
|
57
|
-
|
|
58
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Whether `version` writes leading-ones varints, which carry the full u64; older versions use QUIC's, which stop at 2^62-1.
|
|
48
|
+
* Every draft newer than these counts leading ones, so a new version falls forward.
|
|
49
|
+
*/
|
|
50
|
+
export function isLeadingOnes(version) {
|
|
59
51
|
switch (version) {
|
|
60
|
-
case Version.DRAFT_14:
|
|
61
|
-
case Version.DRAFT_15:
|
|
62
|
-
case Version.DRAFT_16:
|
|
63
52
|
case Lite.DRAFT_01:
|
|
64
53
|
case Lite.DRAFT_02:
|
|
65
54
|
case Lite.DRAFT_03:
|
|
@@ -113,6 +102,9 @@ export class Stream {
|
|
|
113
102
|
}
|
|
114
103
|
static async accept(quic, version) {
|
|
115
104
|
for (;;) {
|
|
105
|
+
const pause = acceptBudget.poll();
|
|
106
|
+
if (pause !== undefined)
|
|
107
|
+
await pause;
|
|
116
108
|
const reader = quic.incomingBidirectionalStreams.getReader();
|
|
117
109
|
const next = await reader.read();
|
|
118
110
|
reader.releaseLock();
|
|
@@ -128,19 +120,26 @@ export class Stream {
|
|
|
128
120
|
* @param options - The version its varints encode with, and the send order ranking it
|
|
129
121
|
* against the session's other streams
|
|
130
122
|
*/
|
|
123
|
+
/** Open a stream, waiting its turn for the peer's stream credit. */
|
|
131
124
|
static async open(quic, options) {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
125
|
+
const opened = await lines(quic).bi.open(options.sendOrder ?? 0);
|
|
126
|
+
return new Stream({ readable: opened.readable, writable: opened.writable, version: options.version });
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Like {@link Stream.open}, but leaves the line once `signal` aborts, returning undefined so
|
|
130
|
+
* the caller can drop its request. The stream its create admits later goes to the next open
|
|
131
|
+
* in line. A transport failure still throws.
|
|
132
|
+
*/
|
|
133
|
+
static async tryOpen(quic, options) {
|
|
134
|
+
const opened = await lines(quic).bi.open(options.sendOrder ?? 0, options.signal);
|
|
135
|
+
return opened && new Stream({ readable: opened.readable, writable: opened.writable, version: options.version });
|
|
137
136
|
}
|
|
138
137
|
close() {
|
|
139
138
|
this.writer.close();
|
|
140
139
|
// A routine unsubscribe, so send CANCELLED. A bare Error would put 0 on the wire,
|
|
141
140
|
// which the stream registry reads as INTERNAL_ERROR: the peer would log a failure
|
|
142
141
|
// for every subscription we walk away from.
|
|
143
|
-
this.reader.stop(
|
|
142
|
+
this.reader.stop(StreamCode.Cancel);
|
|
144
143
|
}
|
|
145
144
|
abort(reason) {
|
|
146
145
|
this.writer.reset(reason);
|
|
@@ -155,8 +154,10 @@ export class Reader {
|
|
|
155
154
|
#buffer;
|
|
156
155
|
#chunks = [];
|
|
157
156
|
#chunked = 0; // bytes across #chunks
|
|
158
|
-
#
|
|
157
|
+
#last = now(); // when the stream last delivered bytes, or it was created
|
|
158
|
+
// Undefined once the stream finishes, or without a stream: the buffer is consumed then EOF.
|
|
159
159
|
#reader;
|
|
160
|
+
#stream;
|
|
160
161
|
#closed;
|
|
161
162
|
// The decode that last ran short and how far, so a retry can wait for those bytes.
|
|
162
163
|
#short;
|
|
@@ -164,20 +165,32 @@ export class Reader {
|
|
|
164
165
|
constructor(stream, buffer, version) {
|
|
165
166
|
this.#buffer = buffer ?? new Uint8Array();
|
|
166
167
|
this.#stream = stream;
|
|
167
|
-
this.#reader =
|
|
168
|
+
this.#reader = stream?.getReader();
|
|
168
169
|
this.version = version;
|
|
169
170
|
}
|
|
171
|
+
/** When the stream last delivered bytes, which tells a watcher a quiet stream from one still arriving. */
|
|
172
|
+
get last() {
|
|
173
|
+
return this.#last;
|
|
174
|
+
}
|
|
170
175
|
// Adds more data to the buffer, returning true if more data was added.
|
|
171
176
|
async #fill() {
|
|
172
|
-
|
|
177
|
+
const reader = this.#reader;
|
|
178
|
+
if (!reader) {
|
|
173
179
|
return false;
|
|
174
180
|
}
|
|
175
181
|
// Every read of this stream funnels through here, so decoding the peer's reset code
|
|
176
182
|
// once is enough to keep the raw transport error out of every caller (and every app).
|
|
177
|
-
const result = await
|
|
183
|
+
const result = await reader.read().catch((err) => {
|
|
178
184
|
throw fromTransport(err, { version: asIetf(this.version) });
|
|
179
185
|
});
|
|
180
186
|
if (result.done) {
|
|
187
|
+
// The transport already finished the stream. Drop the reader so a later stop
|
|
188
|
+
// neither builds a cancel error nor sends a reset the peer will ignore. Dropped,
|
|
189
|
+
// not released: releasing a closed stream's lock builds a TypeError per stream.
|
|
190
|
+
if (this.#reader === reader) {
|
|
191
|
+
this.#reader = undefined;
|
|
192
|
+
this.#stream = undefined;
|
|
193
|
+
}
|
|
181
194
|
return false;
|
|
182
195
|
}
|
|
183
196
|
if (result.value.byteLength === 0) {
|
|
@@ -185,6 +198,7 @@ export class Reader {
|
|
|
185
198
|
}
|
|
186
199
|
this.#chunks.push(result.value);
|
|
187
200
|
this.#chunked += result.value.byteLength;
|
|
201
|
+
this.#last = now();
|
|
188
202
|
return true;
|
|
189
203
|
}
|
|
190
204
|
// Add more data to the buffer until it's at least size bytes.
|
|
@@ -237,6 +251,11 @@ export class Reader {
|
|
|
237
251
|
const result = this.#try(decode);
|
|
238
252
|
return result instanceof Short ? undefined : result;
|
|
239
253
|
}
|
|
254
|
+
/** Like {@link tryDecode}, but consumes nothing: a look at what is buffered. */
|
|
255
|
+
tryPeek(decode) {
|
|
256
|
+
const result = this.#try(decode, false);
|
|
257
|
+
return result instanceof Short ? undefined : result;
|
|
258
|
+
}
|
|
240
259
|
/** Run a synchronous decode, filling from the stream until it has the bytes it needs. */
|
|
241
260
|
async decode(decode) {
|
|
242
261
|
for (;;) {
|
|
@@ -246,8 +265,8 @@ export class Reader {
|
|
|
246
265
|
await this.#fillTo(result.need);
|
|
247
266
|
}
|
|
248
267
|
}
|
|
249
|
-
|
|
250
|
-
async
|
|
268
|
+
/** Like {@link decode}, but leaves the bytes buffered for the next read. */
|
|
269
|
+
async peek(decode) {
|
|
251
270
|
for (;;) {
|
|
252
271
|
const result = this.#try(decode, false);
|
|
253
272
|
if (!(result instanceof Short))
|
|
@@ -281,7 +300,7 @@ export class Reader {
|
|
|
281
300
|
}
|
|
282
301
|
catch (err) {
|
|
283
302
|
if (!(err instanceof Short))
|
|
284
|
-
throw err;
|
|
303
|
+
throw decodeError(err);
|
|
285
304
|
// Filling could never satisfy it, so retrying would spin.
|
|
286
305
|
if (err.need <= this.#buffer.byteLength)
|
|
287
306
|
throw new Error("decode ran short of bytes it already had");
|
|
@@ -294,6 +313,27 @@ export class Reader {
|
|
|
294
313
|
return new Uint8Array();
|
|
295
314
|
return this.decode((c) => c.read(size));
|
|
296
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* Read between 1 and `max` bytes as they arrive, without joining them into one buffer, so
|
|
318
|
+
* a payload of any size streams through. Throws {@link UnexpectedEnd} at a clean end.
|
|
319
|
+
*/
|
|
320
|
+
async readChunk(max) {
|
|
321
|
+
if (this.#buffer.byteLength === 0 && this.#chunked === 0 && !(await this.#fill()))
|
|
322
|
+
throw new UnexpectedEnd();
|
|
323
|
+
// What a decode ran short of is measured from bytes this consumes.
|
|
324
|
+
this.#short = undefined;
|
|
325
|
+
if (this.#buffer.byteLength > 0)
|
|
326
|
+
return this.#slice(Math.min(max, this.#buffer.byteLength));
|
|
327
|
+
const chunk = this.#chunks[0];
|
|
328
|
+
if (chunk.byteLength <= max) {
|
|
329
|
+
this.#chunks.shift();
|
|
330
|
+
this.#chunked -= chunk.byteLength;
|
|
331
|
+
return chunk;
|
|
332
|
+
}
|
|
333
|
+
this.#chunks[0] = chunk.subarray(max);
|
|
334
|
+
this.#chunked -= max;
|
|
335
|
+
return chunk.subarray(0, max);
|
|
336
|
+
}
|
|
297
337
|
async readAll() {
|
|
298
338
|
while (await this.#fill()) {
|
|
299
339
|
// keep going
|
|
@@ -331,7 +371,7 @@ export class Reader {
|
|
|
331
371
|
}
|
|
332
372
|
/** Like {@link u62}, but leaves the varint buffered, so a stream's type can be read twice. */
|
|
333
373
|
async peekU62() {
|
|
334
|
-
return this
|
|
374
|
+
return this.peek(U62);
|
|
335
375
|
}
|
|
336
376
|
async varint() {
|
|
337
377
|
return this.decode(VARINT);
|
|
@@ -342,8 +382,19 @@ export class Reader {
|
|
|
342
382
|
return false;
|
|
343
383
|
return !(await this.#fill());
|
|
344
384
|
}
|
|
385
|
+
// The transport error is built only while the stream is still open. After a FIN the
|
|
386
|
+
// reader is gone, so this allocates nothing and sends nothing.
|
|
345
387
|
stop(reason) {
|
|
346
|
-
this.#reader
|
|
388
|
+
const reader = this.#reader;
|
|
389
|
+
if (!reader)
|
|
390
|
+
return;
|
|
391
|
+
this.#reader = undefined;
|
|
392
|
+
this.#stream = undefined;
|
|
393
|
+
reader.cancel(stopReason(reason, this.version)).catch(() => void 0);
|
|
394
|
+
}
|
|
395
|
+
/** A non-consuming peer reset notification on transports that support one. */
|
|
396
|
+
get resetSignal() {
|
|
397
|
+
return this.#stream?.resetSignal;
|
|
347
398
|
}
|
|
348
399
|
// Decoded like #fill: a caller racing this against a read must not get a different error
|
|
349
400
|
// shape depending on which one won. Derived once, so racing it per frame doesn't allocate.
|
|
@@ -506,10 +557,7 @@ export class Cursor {
|
|
|
506
557
|
let size;
|
|
507
558
|
if (this.#leadingOnes) {
|
|
508
559
|
size = peekLeadingOnes(b[o]);
|
|
509
|
-
// 1111110x is a 7-byte form
|
|
510
|
-
if (size === 7 && this.version === Version.DRAFT_17) {
|
|
511
|
-
throw new Error("invalid leading-ones varint: 1111110x prefix is reserved on draft-17");
|
|
512
|
-
}
|
|
560
|
+
// 1111110x is a 7-byte form, which draft-18+ allows per #1595.
|
|
513
561
|
this.#ensure(size);
|
|
514
562
|
this.#offset += size;
|
|
515
563
|
return readLeadingOnes(b, o, size);
|
|
@@ -533,6 +581,21 @@ export class Writer {
|
|
|
533
581
|
#writer;
|
|
534
582
|
#stream;
|
|
535
583
|
#closed;
|
|
584
|
+
/** The bytes handed to the stream so far. */
|
|
585
|
+
#written = 0;
|
|
586
|
+
#sendOrder = 0;
|
|
587
|
+
/** Whether the transport reports acknowledgements, as the session's open streams say. */
|
|
588
|
+
#acknowledges = false;
|
|
589
|
+
/** Reset by this side, or failed or stopped by the peer, so never acknowledged. */
|
|
590
|
+
#aborted = false;
|
|
591
|
+
/** The bytes every later reset still delivers, once {@link hold} marks them. */
|
|
592
|
+
#held;
|
|
593
|
+
/** What this side first reset the stream with, which tells its end apart from a peer's stop. */
|
|
594
|
+
#reason;
|
|
595
|
+
/** The code the peer stopped the stream with. */
|
|
596
|
+
#stop;
|
|
597
|
+
/** The session's open group streams, while this one is among them. */
|
|
598
|
+
#listed;
|
|
536
599
|
// Scratch buffer for each primitive write, sized for the longest (a 9-byte leading-ones varint).
|
|
537
600
|
#scratch;
|
|
538
601
|
version;
|
|
@@ -541,6 +604,18 @@ export class Writer {
|
|
|
541
604
|
this.#scratch = new ArrayBuffer(9);
|
|
542
605
|
this.#writer = this.#stream.getWriter();
|
|
543
606
|
this.version = version;
|
|
607
|
+
// The stream ends once it is finished, or with a failure: a reset, a stop, or the session closing.
|
|
608
|
+
this.#writer.closed.then(() => this.#unlist(), (err) => {
|
|
609
|
+
this.#aborted = true;
|
|
610
|
+
// A reset of this side's ends the stream with its own reason, so any other code is the peer's stop.
|
|
611
|
+
if (err !== this.#reason)
|
|
612
|
+
this.#stop = streamCode(err);
|
|
613
|
+
this.#unlist();
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
/** The send order the stream has now, where HIGHER values are sent first. */
|
|
617
|
+
get sendOrder() {
|
|
618
|
+
return this.#sendOrder;
|
|
544
619
|
}
|
|
545
620
|
/**
|
|
546
621
|
* Rank this stream against the session's others, where HIGHER values are sent first.
|
|
@@ -553,8 +628,54 @@ export class Writer {
|
|
|
553
628
|
* ignored property, the same way an ignored `sendOrder` option does at {@link open}.
|
|
554
629
|
*/
|
|
555
630
|
setPriority(sendOrder) {
|
|
631
|
+
this.#sendOrder = sendOrder;
|
|
556
632
|
this.#stream.sendOrder = sendOrder;
|
|
557
633
|
}
|
|
634
|
+
/**
|
|
635
|
+
* Whether the peer has acknowledged every byte written so far, or undefined when the
|
|
636
|
+
* transport cannot tell, as a browser's WebTransport cannot.
|
|
637
|
+
*/
|
|
638
|
+
async acknowledged() {
|
|
639
|
+
if (!this.#acknowledges)
|
|
640
|
+
return undefined;
|
|
641
|
+
if (this.#aborted)
|
|
642
|
+
return false;
|
|
643
|
+
const written = this.#written;
|
|
644
|
+
const stats = await this.#stream.getStats();
|
|
645
|
+
return !this.#aborted && stats.bytesAcknowledged >= written;
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* From now on, every reset of the stream, a preemption included, still delivers the bytes
|
|
649
|
+
* written so far. Call it once every write so far resolved. Returns whether the transport
|
|
650
|
+
* can, holding nothing otherwise: a browser's WebTransport cannot, nor can a peer without
|
|
651
|
+
* RESET_STREAM_AT, whose plain reset lets it discard bytes it has not read; and a stream
|
|
652
|
+
* already reset or stopped, perhaps preempted before this, has lost them already.
|
|
653
|
+
*/
|
|
654
|
+
hold() {
|
|
655
|
+
if (this.#aborted || this.#stream.reliableReset !== true)
|
|
656
|
+
return false;
|
|
657
|
+
this.#held = this.#written;
|
|
658
|
+
return true;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Whether the peer acknowledged every byte {@link hold} marked, even after the stream ended;
|
|
662
|
+
* false when nothing is held or the transport cannot tell.
|
|
663
|
+
*/
|
|
664
|
+
async heldAcknowledged() {
|
|
665
|
+
const held = this.#held;
|
|
666
|
+
if (held === undefined || !this.#acknowledges)
|
|
667
|
+
return false;
|
|
668
|
+
const stats = await this.#stream.getStats();
|
|
669
|
+
return stats.bytesAcknowledged >= held;
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* The code the peer stopped the stream with, or undefined while it has not: still open,
|
|
673
|
+
* finished, reset by this side first, or failed with its session. Known before a write or
|
|
674
|
+
* {@link closed} that the stop failed settles.
|
|
675
|
+
*/
|
|
676
|
+
get stopped() {
|
|
677
|
+
return this.#stop;
|
|
678
|
+
}
|
|
558
679
|
async bool(v) {
|
|
559
680
|
await this.write(setUint8(this.#scratch, v ? 1 : 0));
|
|
560
681
|
}
|
|
@@ -592,6 +713,13 @@ export class Writer {
|
|
|
592
713
|
return this.write(encodeTo(this.#scratch, hi, lo, this.version));
|
|
593
714
|
}
|
|
594
715
|
async write(v) {
|
|
716
|
+
// Yield before handing the bytes over, so a write still pending is one the transport has
|
|
717
|
+
// not taken: a caller racing it against the peer's end never abandons bytes already sent.
|
|
718
|
+
// Count it synchronously, so acknowledged() never treats a pending write as acknowledged.
|
|
719
|
+
this.#written += v.byteLength;
|
|
720
|
+
const pause = writeBudget.poll();
|
|
721
|
+
if (pause !== undefined)
|
|
722
|
+
await pause;
|
|
595
723
|
// Mirrors Reader.#fill: every write funnels through here, so a STOP_SENDING from the
|
|
596
724
|
// peer surfaces as a typed code rather than the transport's own error shape.
|
|
597
725
|
await this.#writer.write(v).catch((err) => {
|
|
@@ -604,6 +732,7 @@ export class Writer {
|
|
|
604
732
|
await this.write(data);
|
|
605
733
|
}
|
|
606
734
|
close() {
|
|
735
|
+
this.#unlist();
|
|
607
736
|
this.#writer.close().catch(() => void 0);
|
|
608
737
|
}
|
|
609
738
|
// Mirrors Reader.closed: a STOP_SENDING reaches a caller racing this with the same
|
|
@@ -614,8 +743,27 @@ export class Writer {
|
|
|
614
743
|
});
|
|
615
744
|
return this.#closed;
|
|
616
745
|
}
|
|
746
|
+
/** Reset the stream to make room for a higher one, failing its writer as too far behind. */
|
|
747
|
+
preempt() {
|
|
748
|
+
this.reset(new TooFarBehind());
|
|
749
|
+
}
|
|
750
|
+
/** Reset the stream with `reason`, still delivering what {@link hold} marked where the transport can. */
|
|
617
751
|
reset(reason) {
|
|
618
|
-
this.#
|
|
752
|
+
this.#aborted = true;
|
|
753
|
+
this.#unlist();
|
|
754
|
+
const coded = withCode(reason, this.version);
|
|
755
|
+
// Only the first reset reaches the transport, so its reason is the one the stream ends with.
|
|
756
|
+
this.#reason ??= coded;
|
|
757
|
+
if (this.#held !== undefined) {
|
|
758
|
+
this.#stream.resetAt(this.#held, coded);
|
|
759
|
+
}
|
|
760
|
+
else {
|
|
761
|
+
this.#writer.abort(coded).catch(() => void 0);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
#unlist() {
|
|
765
|
+
this.#listed?.delete(this);
|
|
766
|
+
this.#listed = undefined;
|
|
619
767
|
}
|
|
620
768
|
/** Run `f` against a Writer that buffers in memory, returning everything it wrote as one chunk. */
|
|
621
769
|
static async collect(version, f) {
|
|
@@ -637,43 +785,38 @@ export class Writer {
|
|
|
637
785
|
* @param options - The version its varints encode with, and the send order ranking it
|
|
638
786
|
* against the session's other streams
|
|
639
787
|
*/
|
|
788
|
+
/** Open a send-only stream, waiting its turn for the peer's stream credit. */
|
|
640
789
|
static async open(quic, options) {
|
|
641
|
-
const
|
|
642
|
-
|
|
790
|
+
const session = lines(quic);
|
|
791
|
+
const writable = await session.uni.open(options.sendOrder ?? 0);
|
|
792
|
+
return Writer.#opened(writable, options.version, options.sendOrder ?? 0, session.streams);
|
|
643
793
|
}
|
|
644
794
|
/**
|
|
645
|
-
* Like {@link Writer.open}, but
|
|
646
|
-
*
|
|
647
|
-
*
|
|
648
|
-
*
|
|
649
|
-
* Worth using even with `waitUntilAvailable: false`, since an implementation may park
|
|
650
|
-
* an over-limit open instead of rejecting it.
|
|
795
|
+
* Like {@link Writer.open}, but leaves the line once `cancel` settles, returning undefined
|
|
796
|
+
* so the caller can drop whatever it meant to send. The stream its create admits later goes
|
|
797
|
+
* to the next open in line. A transport failure, or a rejected `cancel`, still throws.
|
|
651
798
|
*/
|
|
652
799
|
static async tryOpen(quic, options) {
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
//
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
const
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
return stream;
|
|
666
|
-
}
|
|
667
|
-
catch (err) {
|
|
668
|
-
// open already discarded the late stream on its way out.
|
|
669
|
-
if (err instanceof TimeoutError)
|
|
670
|
-
return undefined;
|
|
671
|
-
// A rejected `cancel` still leaves the open pending.
|
|
672
|
-
abandon();
|
|
673
|
-
throw err;
|
|
800
|
+
const session = lines(quic);
|
|
801
|
+
const rank = options.sendOrder ?? 0;
|
|
802
|
+
// The line ranks the stream it hands out by its last read, which can differ from a read now.
|
|
803
|
+
let sendOrder = typeof rank === "number" ? rank : 0;
|
|
804
|
+
const read = typeof rank === "number" ? rank : () => (sendOrder = rank());
|
|
805
|
+
const writable = await session.uni.open(read, options.cancel);
|
|
806
|
+
if (!writable)
|
|
807
|
+
return undefined;
|
|
808
|
+
const writer = Writer.#opened(writable, options.version, sendOrder, session.streams);
|
|
809
|
+
if (options.group) {
|
|
810
|
+
writer.#listed = session.streams;
|
|
811
|
+
session.streams.add(writer);
|
|
674
812
|
}
|
|
675
|
-
|
|
676
|
-
|
|
813
|
+
return writer;
|
|
814
|
+
}
|
|
815
|
+
static #opened(writable, version, sendOrder, streams) {
|
|
816
|
+
const writer = new Writer(writable, version);
|
|
817
|
+
writer.#sendOrder = sendOrder;
|
|
818
|
+
writer.#acknowledges = streams.acknowledges;
|
|
819
|
+
return writer;
|
|
677
820
|
}
|
|
678
821
|
}
|
|
679
822
|
function setUint8(dst, v) {
|
|
@@ -700,13 +843,13 @@ export class Readers {
|
|
|
700
843
|
this.#version = version;
|
|
701
844
|
}
|
|
702
845
|
async next() {
|
|
846
|
+
const pause = acceptBudget.poll();
|
|
847
|
+
if (pause !== undefined)
|
|
848
|
+
await pause;
|
|
703
849
|
const next = await this.#reader.read();
|
|
704
850
|
if (next.done)
|
|
705
851
|
return;
|
|
706
852
|
return new Reader(next.value, undefined, this.#version);
|
|
707
853
|
}
|
|
708
|
-
close() {
|
|
709
|
-
this.#reader.cancel();
|
|
710
|
-
}
|
|
711
854
|
}
|
|
712
855
|
//# sourceMappingURL=stream.js.map
|