@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/bandwidth.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* @ts-self-types="./bandwidth.d.ts" */
|
|
2
1
|
/**
|
|
3
2
|
* Rate estimation split among the tracks sharing one connection.
|
|
4
3
|
*
|
|
@@ -6,11 +5,17 @@
|
|
|
6
5
|
* an {@link Allocator} rather than each targeting the whole thing. How a sender
|
|
7
6
|
* then follows its share is policy and lives with the sender.
|
|
8
7
|
*
|
|
8
|
+
* The receive direction mirrors it: {@link Viewers} divides the receive estimate
|
|
9
|
+
* among the broadcasts watched over one connection, and their ceilings summed are
|
|
10
|
+
* the PROBE target the connection asks its peer to probe up to.
|
|
11
|
+
*
|
|
9
12
|
* @module
|
|
10
13
|
*/
|
|
11
|
-
import { Effect, Signal } from "@moq/signals";
|
|
14
|
+
import { Derived, Effect, Signal } from "@moq/signals";
|
|
15
|
+
import { hooks } from "./internal.js";
|
|
12
16
|
/**
|
|
13
|
-
*
|
|
17
|
+
* One division of `estimate` among the demanded `wants`, computed once and read by every
|
|
18
|
+
* reservation instead of each re-dividing the whole table.
|
|
14
19
|
*
|
|
15
20
|
* Strict priority: a tier is filled to its reservations before the next one
|
|
16
21
|
* sees a bit. Within a tier the split is max-min fair, so a share asking for
|
|
@@ -20,52 +25,105 @@ import { Effect, Signal } from "@moq/signals";
|
|
|
20
25
|
* A reservation is what a sender can use, so handing it more is not a reason to
|
|
21
26
|
* send more than it was configured for.
|
|
22
27
|
*
|
|
23
|
-
* `undefined` when `id` isn't among the wants, which is how an idle or closed
|
|
24
|
-
* track reports "hold your rate" instead of a grant of zero.
|
|
25
|
-
*
|
|
26
28
|
* Rates are bits per second.
|
|
27
29
|
*/
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
//
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
30
|
+
export class Plan {
|
|
31
|
+
/**
|
|
32
|
+
* The wants in the order they are served: higher priority first, then ascending by
|
|
33
|
+
* reservation, then by registration.
|
|
34
|
+
*/
|
|
35
|
+
#order;
|
|
36
|
+
#grants = new Map();
|
|
37
|
+
/** What is left once every want is served. */
|
|
38
|
+
#leftover;
|
|
39
|
+
constructor(estimate, wants) {
|
|
40
|
+
// Read each want once. Registration order breaks ties, as in the Rust allocator.
|
|
41
|
+
const order = wants.map((want) => ({ id: want.id, priority: want.priority, max: want.max, budget: 0 }));
|
|
42
|
+
order.sort((a, b) => b.priority - a.priority || a.max - b.max || a.id - b.id);
|
|
43
|
+
// Integer bits per second: the same truncation the Rust allocator uses.
|
|
44
|
+
let budget = estimate;
|
|
45
|
+
for (let start = 0; start < order.length;) {
|
|
46
|
+
let end = start;
|
|
47
|
+
while (end < order.length && order[end].priority === order[start].priority)
|
|
48
|
+
end++;
|
|
49
|
+
// Ascending by reservation: each share takes an even cut of what's left, or
|
|
50
|
+
// all it asked for if that's less, which frees the difference for the rest.
|
|
51
|
+
for (let at = start; at < end; at++) {
|
|
52
|
+
const served = order[at];
|
|
53
|
+
served.budget = budget;
|
|
54
|
+
const grant = Math.min(served.max, Math.floor(budget / (end - at)));
|
|
55
|
+
this.#grants.set(served.id, grant);
|
|
56
|
+
budget -= grant;
|
|
53
57
|
}
|
|
58
|
+
start = end;
|
|
54
59
|
}
|
|
55
|
-
|
|
60
|
+
this.#order = order;
|
|
61
|
+
this.#leftover = budget;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The slice for `id`, or `undefined` when `id` isn't among the wants, which is how a
|
|
65
|
+
* released or closed reservation reports "hold your rate" instead of a grant of zero.
|
|
66
|
+
*/
|
|
67
|
+
grant(id) {
|
|
68
|
+
return this.#grants.get(id);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* What a want missing from this division would get were it demanded again.
|
|
72
|
+
*
|
|
73
|
+
* Tiers above its own are served first either way, so only its own tier is walked
|
|
74
|
+
* again, with one more want sharing it, as far as where it would be served: after
|
|
75
|
+
* every want of its tier reserving less than it, or as much but registered earlier.
|
|
76
|
+
*/
|
|
77
|
+
rejoin(want) {
|
|
78
|
+
const { id, priority, max } = want;
|
|
79
|
+
const order = this.#order;
|
|
80
|
+
let start = 0;
|
|
81
|
+
while (start < order.length && order[start].priority > priority)
|
|
82
|
+
start++;
|
|
83
|
+
let at = start;
|
|
84
|
+
while (at < order.length &&
|
|
85
|
+
order[at].priority === priority &&
|
|
86
|
+
(order[at].max < max || (order[at].max === max && order[at].id < id)))
|
|
87
|
+
at++;
|
|
88
|
+
let end = at;
|
|
89
|
+
while (end < order.length && order[end].priority === priority)
|
|
90
|
+
end++;
|
|
91
|
+
let budget = start < order.length ? order[start].budget : this.#leftover;
|
|
92
|
+
let remaining = end - start + 1;
|
|
93
|
+
for (let index = start; index < at; index++) {
|
|
94
|
+
budget -= Math.min(order[index].max, Math.floor(budget / remaining));
|
|
95
|
+
remaining -= 1;
|
|
96
|
+
}
|
|
97
|
+
return Math.min(max, Math.floor(budget / remaining));
|
|
56
98
|
}
|
|
57
|
-
return undefined;
|
|
58
99
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Divide `estimate` among `wants`, returning the slice for `id`.
|
|
102
|
+
*
|
|
103
|
+
* `undefined` when `id` isn't among the wants. See {@link Plan}, which computes every
|
|
104
|
+
* slice at once.
|
|
105
|
+
*/
|
|
106
|
+
export function allocate(estimate, wants, id) {
|
|
107
|
+
return new Plan(estimate, wants).grant(id);
|
|
108
|
+
}
|
|
109
|
+
function demanded(entry) {
|
|
110
|
+
return !entry.demand || (hooks.demandReleased(entry.demand).peek() === undefined && entry.demand.wanted.peek());
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* `entry`'s slice of `plan`, the division among the demanded entries.
|
|
114
|
+
*
|
|
115
|
+
* An idle entry claims nothing from the others but still reads the slice it would
|
|
116
|
+
* get back: a rendition stopped for lack of bandwidth, whose viewers then left,
|
|
117
|
+
* needs that to know when to resume.
|
|
118
|
+
*/
|
|
119
|
+
function shareOf(plan, entry) {
|
|
120
|
+
if (entry.demand) {
|
|
62
121
|
if (entry.demand.closed.peek() !== undefined)
|
|
63
|
-
|
|
64
|
-
if (!entry.demand.
|
|
65
|
-
|
|
66
|
-
wants.push({ id: entry.id, priority: entry.priority, max: entry.max });
|
|
122
|
+
return undefined;
|
|
123
|
+
if (!entry.demand.wanted.peek())
|
|
124
|
+
return plan.rejoin(entry);
|
|
67
125
|
}
|
|
68
|
-
return
|
|
126
|
+
return plan.grant(entry.id);
|
|
69
127
|
}
|
|
70
128
|
function ceiling(max) {
|
|
71
129
|
if (!Number.isFinite(max) || max < 0) {
|
|
@@ -73,35 +131,34 @@ function ceiling(max) {
|
|
|
73
131
|
}
|
|
74
132
|
return max;
|
|
75
133
|
}
|
|
134
|
+
/** The ceilings summed in order, the way {@link Viewers.target} sums them. */
|
|
135
|
+
function total(entries) {
|
|
136
|
+
let sum = 0;
|
|
137
|
+
for (const entry of entries)
|
|
138
|
+
sum += entry.max;
|
|
139
|
+
return sum;
|
|
140
|
+
}
|
|
76
141
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* Every sender on a connection reads the same estimate, so N senders each
|
|
80
|
-
* targeting all of it oversubscribe the uplink N times over. Register a track
|
|
81
|
-
* here and it gets a {@link Reservation} reporting only its own slice, so the
|
|
82
|
-
* slices sum to the estimate instead of each matching it.
|
|
83
|
-
*
|
|
84
|
-
* Advisory, not enforced. A track that ignores its slice, or can't follow it at
|
|
85
|
-
* all (PCM audio has a fixed bitrate), still sends what it sends; the transport
|
|
86
|
-
* sheds the excess by dropping groups.
|
|
87
|
-
*
|
|
88
|
-
* Hand the same instance to every sender on the connection.
|
|
142
|
+
* The registry behind {@link Allocator} and {@link Viewers}: divides one estimate
|
|
143
|
+
* among its claims, publishing each claim's slice.
|
|
89
144
|
*/
|
|
90
|
-
|
|
145
|
+
class Divider {
|
|
91
146
|
#estimate;
|
|
92
|
-
|
|
147
|
+
/** The most the ceilings may sum to, or `undefined` for no limit. */
|
|
148
|
+
#limit;
|
|
149
|
+
entries = new Signal([]);
|
|
150
|
+
/** Whether a live claim reads the estimate; see {@link reserved}. */
|
|
151
|
+
reserved = new Signal(false);
|
|
93
152
|
#alive = new Signal(true);
|
|
94
153
|
#nextId = 0;
|
|
95
154
|
#signals = new Effect();
|
|
96
155
|
#registry;
|
|
97
|
-
/**
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
* reports `undefined`, which already means "no opinion, hold your rate".
|
|
102
|
-
*/
|
|
103
|
-
constructor(estimate) {
|
|
156
|
+
/** Bumped whenever an entry is added, moved or removed. */
|
|
157
|
+
#version = 0;
|
|
158
|
+
#division;
|
|
159
|
+
constructor(estimate, limit) {
|
|
104
160
|
this.#estimate = estimate;
|
|
161
|
+
this.#limit = limit;
|
|
105
162
|
this.#registry = {
|
|
106
163
|
peek: (id) => this.#peek(id),
|
|
107
164
|
update: (id, max) => this.#update(id, max),
|
|
@@ -110,93 +167,93 @@ export class Allocator {
|
|
|
110
167
|
this.#signals.run((effect) => {
|
|
111
168
|
if (!effect.get(this.#alive))
|
|
112
169
|
return;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const entries = effect.get(this.#entries);
|
|
170
|
+
const entries = effect.get(this.entries);
|
|
171
|
+
let reserved = false;
|
|
116
172
|
for (const entry of entries) {
|
|
117
|
-
|
|
118
|
-
|
|
173
|
+
// A claim without a demand always reads its slice.
|
|
174
|
+
if (!entry.demand) {
|
|
175
|
+
reserved = true;
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
effect.get(entry.demand.wanted);
|
|
179
|
+
effect.get(hooks.demandReleased(entry.demand));
|
|
180
|
+
// The same test shareOf applies: a closed demand reads no slice.
|
|
181
|
+
if (effect.get(entry.demand.closed) === undefined)
|
|
182
|
+
reserved = true;
|
|
119
183
|
}
|
|
184
|
+
this.reserved.set(reserved);
|
|
185
|
+
// Observe the estimate only while something claims it: reading a session's
|
|
186
|
+
// receive estimate is what requests PROBE, so an empty registry asks for nothing.
|
|
187
|
+
if (entries.length === 0)
|
|
188
|
+
return;
|
|
189
|
+
if (this.#estimate)
|
|
190
|
+
effect.get(this.#estimate);
|
|
120
191
|
this.#publish();
|
|
121
192
|
});
|
|
122
193
|
}
|
|
123
|
-
/**
|
|
124
|
-
|
|
125
|
-
*
|
|
126
|
-
* `undefined` already means "no opinion, hold your rate" to a sender, so this is
|
|
127
|
-
* what a transport with no congestion estimate, a local file, or a test harness
|
|
128
|
-
* wants.
|
|
129
|
-
*/
|
|
130
|
-
static unlimited() {
|
|
131
|
-
return new Allocator();
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Reserve up to `max` for `track`, returning the reservation.
|
|
135
|
-
*
|
|
136
|
-
* `max` is a ceiling, not a measurement: reserve the most the track can ever
|
|
137
|
-
* send, not what it happens to be sending. A VBR encoder sitting on a black
|
|
138
|
-
* screen at 1 Mbps can jump to 6 Mbps between one frame and the next, and a
|
|
139
|
-
* reservation that had followed it down would have already handed that room
|
|
140
|
-
* to somebody else.
|
|
141
|
-
*
|
|
142
|
-
* Priority comes from the track (higher served first). A tier is filled to
|
|
143
|
-
* its reservations before the next one sees a bit; within a tier the split is
|
|
144
|
-
* max-min fair.
|
|
145
|
-
*
|
|
146
|
-
* The reservation lasts until {@link Reservation.close}: hold it for as long
|
|
147
|
-
* as the sender is publishing, change the ceiling with
|
|
148
|
-
* {@link Reservation.update}, and close it to hand the room back.
|
|
149
|
-
*
|
|
150
|
-
* {@link Reservation.peek} / {@link Reservation.grant} report `undefined`
|
|
151
|
-
* while nothing is subscribed to the track or the connection has no estimate.
|
|
152
|
-
* That tells a sender to hold its current rate rather than encode at zero.
|
|
153
|
-
*/
|
|
154
|
-
reserve(track, max) {
|
|
194
|
+
/** Claim up to `max`, active whenever `demand` is, or always without one. */
|
|
195
|
+
claim(demand, priority, max) {
|
|
155
196
|
max = ceiling(max);
|
|
156
197
|
this.#prune();
|
|
198
|
+
if (this.#limit !== undefined && this.#alive.peek())
|
|
199
|
+
this.#fits([...this.entries.peek(), { max }]);
|
|
157
200
|
const id = this.#nextId++;
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
demand
|
|
163
|
-
priority: track.priority,
|
|
164
|
-
max,
|
|
165
|
-
grant,
|
|
201
|
+
const rate = new Signal(undefined);
|
|
202
|
+
// A closed registry hands back an inert reservation, so its target stays zero.
|
|
203
|
+
if (this.#alive.peek()) {
|
|
204
|
+
this.#mutate((entries) => {
|
|
205
|
+
entries.push({ id, demand, priority, max, rate });
|
|
166
206
|
});
|
|
167
|
-
}
|
|
168
|
-
const reservation = makeReservation(this.#registry, id,
|
|
207
|
+
}
|
|
208
|
+
const reservation = makeReservation(this.#registry, id, rate);
|
|
169
209
|
this.#publish();
|
|
170
210
|
return reservation;
|
|
171
211
|
}
|
|
172
|
-
/**
|
|
173
|
-
* Stop dividing. Existing reservations report `undefined` and further
|
|
174
|
-
* {@link reserve} calls still return a handle that never claims.
|
|
175
|
-
*/
|
|
176
212
|
close() {
|
|
177
213
|
if (!this.#alive.peek())
|
|
178
214
|
return;
|
|
179
215
|
this.#alive.set(false);
|
|
180
|
-
|
|
181
|
-
|
|
216
|
+
this.reserved.set(false);
|
|
217
|
+
for (const entry of this.entries.peek()) {
|
|
218
|
+
entry.rate.set(undefined);
|
|
182
219
|
}
|
|
183
|
-
this
|
|
220
|
+
this.entries.set([]);
|
|
221
|
+
this.#division = undefined;
|
|
184
222
|
this.#signals.close();
|
|
185
223
|
}
|
|
186
224
|
#prune() {
|
|
187
|
-
const entries = this
|
|
188
|
-
const live = entries.filter((entry) => entry.demand.
|
|
189
|
-
if (live.length !== entries.length)
|
|
190
|
-
this.#
|
|
225
|
+
const entries = this.entries.peek();
|
|
226
|
+
const live = entries.filter((entry) => !entry.demand || hooks.demandReleased(entry.demand).peek() === undefined);
|
|
227
|
+
if (live.length !== entries.length) {
|
|
228
|
+
this.#version++;
|
|
229
|
+
this.entries.set(live);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
#mutate(fn) {
|
|
233
|
+
this.#version++;
|
|
234
|
+
this.entries.mutate(fn);
|
|
235
|
+
}
|
|
236
|
+
/** The division of `estimate` among `entries`, divided again only when either moved. */
|
|
237
|
+
#plan(estimate, entries) {
|
|
238
|
+
const last = this.#division;
|
|
239
|
+
if (last?.estimate === estimate &&
|
|
240
|
+
last.version === this.#version &&
|
|
241
|
+
entries.every((entry, index) => demanded(entry) === last.demanded[index])) {
|
|
242
|
+
return last.plan;
|
|
243
|
+
}
|
|
244
|
+
const flags = entries.map(demanded);
|
|
245
|
+
const plan = new Plan(estimate, entries.filter((_, index) => flags[index]));
|
|
246
|
+
this.#division = { plan, estimate, version: this.#version, demanded: flags };
|
|
247
|
+
return plan;
|
|
191
248
|
}
|
|
192
249
|
#publish() {
|
|
193
250
|
if (!this.#alive.peek())
|
|
194
251
|
return;
|
|
195
252
|
const estimate = this.#estimate?.peek();
|
|
196
|
-
const entries = this
|
|
197
|
-
const
|
|
253
|
+
const entries = this.entries.peek();
|
|
254
|
+
const plan = estimate == null ? undefined : this.#plan(estimate, entries);
|
|
198
255
|
for (const entry of entries) {
|
|
199
|
-
entry.
|
|
256
|
+
entry.rate.set(plan && shareOf(plan, entry));
|
|
200
257
|
}
|
|
201
258
|
}
|
|
202
259
|
#peek(id) {
|
|
@@ -205,16 +262,27 @@ export class Allocator {
|
|
|
205
262
|
const estimate = this.#estimate?.peek();
|
|
206
263
|
if (estimate == null)
|
|
207
264
|
return undefined;
|
|
208
|
-
const entries = this
|
|
209
|
-
|
|
265
|
+
const entries = this.entries.peek();
|
|
266
|
+
const entry = entries.find((candidate) => candidate.id === id);
|
|
267
|
+
if (!entry)
|
|
210
268
|
return undefined;
|
|
211
|
-
return
|
|
269
|
+
return shareOf(this.#plan(estimate, entries), entry);
|
|
270
|
+
}
|
|
271
|
+
/** Throw when `entries`' ceilings sum above the limit. */
|
|
272
|
+
#fits(entries) {
|
|
273
|
+
const sum = total(entries);
|
|
274
|
+
if (sum > (this.#limit ?? Number.POSITIVE_INFINITY)) {
|
|
275
|
+
throw new RangeError(`ceilings sum to ${sum}, above the limit of ${this.#limit}`);
|
|
276
|
+
}
|
|
212
277
|
}
|
|
213
278
|
#update(id, max) {
|
|
214
279
|
if (!this.#alive.peek())
|
|
215
280
|
return;
|
|
216
281
|
max = ceiling(max);
|
|
217
|
-
this.#
|
|
282
|
+
if (this.#limit !== undefined) {
|
|
283
|
+
this.#fits(this.entries.peek().map((entry) => (entry.id === id ? { max } : entry)));
|
|
284
|
+
}
|
|
285
|
+
this.#mutate((entries) => {
|
|
218
286
|
const entry = entries.find((candidate) => candidate.id === id);
|
|
219
287
|
if (entry)
|
|
220
288
|
entry.max = max;
|
|
@@ -224,7 +292,7 @@ export class Allocator {
|
|
|
224
292
|
#release(id) {
|
|
225
293
|
if (!this.#alive.peek())
|
|
226
294
|
return;
|
|
227
|
-
this.#
|
|
295
|
+
this.#mutate((entries) => {
|
|
228
296
|
const index = entries.findIndex((entry) => entry.id === id);
|
|
229
297
|
if (index >= 0)
|
|
230
298
|
entries.splice(index, 1);
|
|
@@ -232,6 +300,209 @@ export class Allocator {
|
|
|
232
300
|
this.#publish();
|
|
233
301
|
}
|
|
234
302
|
}
|
|
303
|
+
// Assigned by Allocator's static block, which runs before any instance exists.
|
|
304
|
+
let reservedOf;
|
|
305
|
+
/**
|
|
306
|
+
* Whether `allocator` holds a reservation that reads the estimate.
|
|
307
|
+
*
|
|
308
|
+
* The estimate's source can stop sampling while this is false: nothing reads it.
|
|
309
|
+
*
|
|
310
|
+
* @internal
|
|
311
|
+
*/
|
|
312
|
+
export function reserved(allocator) {
|
|
313
|
+
return reservedOf(allocator);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Divides one connection's bandwidth estimate among the tracks sharing it.
|
|
317
|
+
*
|
|
318
|
+
* Every sender on a connection reads the same estimate, so N senders each
|
|
319
|
+
* targeting all of it oversubscribe the uplink N times over. Register a track
|
|
320
|
+
* here and it gets a {@link Reservation} reporting only its own slice, so the
|
|
321
|
+
* slices sum to the estimate instead of each matching it.
|
|
322
|
+
*
|
|
323
|
+
* Advisory, not enforced. A track that ignores its slice, or can't follow it at
|
|
324
|
+
* all (PCM audio has a fixed bitrate), still sends what it sends; the transport
|
|
325
|
+
* sheds the excess by dropping groups.
|
|
326
|
+
*
|
|
327
|
+
* Hand the same identity to every sender on the connection.
|
|
328
|
+
*/
|
|
329
|
+
export class Allocator {
|
|
330
|
+
#divider;
|
|
331
|
+
/**
|
|
332
|
+
* Divide `estimate`, normally a connection's sampled send rate.
|
|
333
|
+
*
|
|
334
|
+
* Omit it (or call {@link unlimited}) for nothing to divide: every reservation
|
|
335
|
+
* reports `undefined`, which already means "no opinion, hold your rate".
|
|
336
|
+
*/
|
|
337
|
+
constructor(estimate) {
|
|
338
|
+
this.#divider = new Divider(estimate);
|
|
339
|
+
}
|
|
340
|
+
static {
|
|
341
|
+
reservedOf = (allocator) => allocator.#divider.reserved;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* An allocator with nothing to divide, so every reservation reports `undefined`.
|
|
345
|
+
*
|
|
346
|
+
* `undefined` already means "no opinion, hold your rate" to a sender, so this is
|
|
347
|
+
* what a transport with no congestion estimate, a local file, or a test harness
|
|
348
|
+
* wants.
|
|
349
|
+
*/
|
|
350
|
+
static unlimited() {
|
|
351
|
+
return new Allocator();
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Reserve up to `max` for `track`, returning the reservation.
|
|
355
|
+
*
|
|
356
|
+
* `max` is a ceiling, not a measurement: reserve the most the track can ever
|
|
357
|
+
* send, not what it happens to be sending. A VBR encoder sitting on a black
|
|
358
|
+
* screen at 1 Mbps can jump to 6 Mbps between one frame and the next, and a
|
|
359
|
+
* reservation that had followed it down would have already handed that room
|
|
360
|
+
* to somebody else.
|
|
361
|
+
*
|
|
362
|
+
* Priority comes from the track's `Info.priority` (higher served first). A tier is filled to
|
|
363
|
+
* its reservations before the next one sees a bit; within a tier the split is
|
|
364
|
+
* max-min fair.
|
|
365
|
+
*
|
|
366
|
+
* The reservation lasts until {@link Reservation.close}: hold it for as long
|
|
367
|
+
* as the sender is publishing, change the ceiling with
|
|
368
|
+
* {@link Reservation.update}, and close it to hand the room back.
|
|
369
|
+
*
|
|
370
|
+
* {@link Reservation.peek} / {@link Reservation.rate} report `undefined`
|
|
371
|
+
* while the connection has no estimate, telling a sender to hold its current
|
|
372
|
+
* rate rather than encode at zero. While nothing is subscribed to the track they
|
|
373
|
+
* report the slice the track would get back, without claiming it from the others.
|
|
374
|
+
*/
|
|
375
|
+
reserve(track, max) {
|
|
376
|
+
return this.#divider.claim(track, hooks.demandPriority(track), max);
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Stop dividing. Existing reservations report `undefined` and further
|
|
380
|
+
* {@link reserve} calls still return a handle that never claims.
|
|
381
|
+
*/
|
|
382
|
+
close() {
|
|
383
|
+
this.#divider.close();
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Divides one connection's receive estimate among the broadcasts watched over it.
|
|
388
|
+
*
|
|
389
|
+
* The receive-side mirror of {@link Allocator}. Every player on a connection reads the
|
|
390
|
+
* same receive estimate, so N players each selecting against all of it oversubscribe
|
|
391
|
+
* the downlink N times over. {@link watch} a broadcast here and its {@link Viewer}
|
|
392
|
+
* reports only its own slice, split max-min fair by each viewer's ceiling, so the
|
|
393
|
+
* slices sum to the estimate instead of each matching it. Viewers carry no priority:
|
|
394
|
+
* a viewer asking for less than an even cut takes all it asked for and leaves the
|
|
395
|
+
* rest to the others.
|
|
396
|
+
*
|
|
397
|
+
* The viewers' ceilings summed are also the PROBE target the connection sends its
|
|
398
|
+
* peer, which probes up to it when it advertised `Increase`, so the estimate can rise
|
|
399
|
+
* to fund a larger rendition. The target never leaves this hop.
|
|
400
|
+
*
|
|
401
|
+
* The estimate is observed only while a viewer is live, since observing a
|
|
402
|
+
* connection's receive estimate is what requests PROBE.
|
|
403
|
+
*/
|
|
404
|
+
export class Viewers {
|
|
405
|
+
/**
|
|
406
|
+
* The largest PROBE target: the most the viewers' ceilings, summed, or an override may be.
|
|
407
|
+
*
|
|
408
|
+
* `Number.MAX_SAFE_INTEGER` bits per second, the largest integer the PROBE stream encodes.
|
|
409
|
+
*/
|
|
410
|
+
static MAX_TARGET = Number.MAX_SAFE_INTEGER;
|
|
411
|
+
#divider;
|
|
412
|
+
#override = new Signal(undefined);
|
|
413
|
+
#closed = false;
|
|
414
|
+
/**
|
|
415
|
+
* The PROBE target: the live viewers' ceilings summed, or the {@link setTarget} override.
|
|
416
|
+
* Zero sends no target.
|
|
417
|
+
*/
|
|
418
|
+
target;
|
|
419
|
+
/** Divide `estimate`, normally a connection's receive estimate from PROBE. */
|
|
420
|
+
constructor(estimate) {
|
|
421
|
+
this.#divider = new Divider(estimate, Viewers.MAX_TARGET);
|
|
422
|
+
this.target = new Derived([this.#divider.entries, this.#override], (entries, override) => override !== undefined ? override : total(entries));
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Watch a broadcast receiving at most `max` bits per second, returning its viewer.
|
|
426
|
+
*
|
|
427
|
+
* `max` is a ceiling: what the largest rendition the player would switch to needs,
|
|
428
|
+
* not what it happens to be receiving. The claim lasts until {@link Viewer.close}:
|
|
429
|
+
* change the ceiling with {@link Viewer.update}, and close it once the broadcast
|
|
430
|
+
* stops being watched.
|
|
431
|
+
*
|
|
432
|
+
* @throws {RangeError} watching nothing, when the ceilings would sum above {@link Viewers.MAX_TARGET}.
|
|
433
|
+
*/
|
|
434
|
+
watch(max) {
|
|
435
|
+
return makeViewer(this.#divider.claim(undefined, 0, max));
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Send `target` as the PROBE target instead of the viewers' sum, or `undefined` to follow them again.
|
|
439
|
+
*
|
|
440
|
+
* `0` sends no target, so the peer stops probing for these viewers.
|
|
441
|
+
*
|
|
442
|
+
* @throws {RangeError} keeping the previous override, for a target above {@link Viewers.MAX_TARGET}.
|
|
443
|
+
*/
|
|
444
|
+
setTarget(target) {
|
|
445
|
+
if (this.#closed)
|
|
446
|
+
return;
|
|
447
|
+
if (target !== undefined && ceiling(target) > Viewers.MAX_TARGET) {
|
|
448
|
+
throw new RangeError(`PROBE target ${target} is above the limit of ${Viewers.MAX_TARGET}`);
|
|
449
|
+
}
|
|
450
|
+
this.#override.set(target);
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Stop dividing. Existing viewers report `undefined` and release their claims, and the
|
|
454
|
+
* target drops to zero for good, override included.
|
|
455
|
+
*/
|
|
456
|
+
close() {
|
|
457
|
+
this.#closed = true;
|
|
458
|
+
this.#override.set(undefined);
|
|
459
|
+
this.#divider.close();
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
let makeViewer;
|
|
463
|
+
/**
|
|
464
|
+
* One watched broadcast's standing claim on {@link Viewers}, held for as long as it is watched.
|
|
465
|
+
*
|
|
466
|
+
* Close it to release the claim and lower the PROBE target.
|
|
467
|
+
*/
|
|
468
|
+
export class Viewer {
|
|
469
|
+
#reservation;
|
|
470
|
+
constructor(reservation) {
|
|
471
|
+
this.#reservation = reservation;
|
|
472
|
+
}
|
|
473
|
+
static {
|
|
474
|
+
makeViewer = (reservation) => new Viewer(reservation);
|
|
475
|
+
}
|
|
476
|
+
/** This viewer's slice of the receive estimate right now; see {@link Reservation.peek}. */
|
|
477
|
+
peek() {
|
|
478
|
+
return this.#reservation.peek();
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* This viewer's current slice of the receive estimate.
|
|
482
|
+
*
|
|
483
|
+
* `undefined` while the connection has no receive estimate or this viewer has been
|
|
484
|
+
* closed, telling a player to hold its current selection.
|
|
485
|
+
*/
|
|
486
|
+
get rate() {
|
|
487
|
+
return this.#reservation.rate;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Change the ceiling, keeping the same claim, as when a catalog enables or disables a rendition.
|
|
491
|
+
*
|
|
492
|
+
* @throws {RangeError} keeping the previous ceiling, when the ceilings would sum above {@link Viewers.MAX_TARGET}.
|
|
493
|
+
*/
|
|
494
|
+
update(max) {
|
|
495
|
+
this.#reservation.update(max);
|
|
496
|
+
}
|
|
497
|
+
/** Release the claim so other viewers take the room. Idempotent. */
|
|
498
|
+
close() {
|
|
499
|
+
this.#reservation.close();
|
|
500
|
+
}
|
|
501
|
+
/** Calls {@link close}, so `using` releases the claim. */
|
|
502
|
+
[Symbol.dispose]() {
|
|
503
|
+
this.close();
|
|
504
|
+
}
|
|
505
|
+
}
|
|
235
506
|
let makeReservation;
|
|
236
507
|
/**
|
|
237
508
|
* One track's standing claim on an {@link Allocator}, held for as long as the
|
|
@@ -244,20 +515,20 @@ let makeReservation;
|
|
|
244
515
|
export class Reservation {
|
|
245
516
|
#registry;
|
|
246
517
|
#id;
|
|
247
|
-
#
|
|
518
|
+
#rate;
|
|
248
519
|
#closed = false;
|
|
249
|
-
constructor(registry, id,
|
|
520
|
+
constructor(registry, id, rate) {
|
|
250
521
|
this.#registry = registry;
|
|
251
522
|
this.#id = id;
|
|
252
|
-
this.#
|
|
523
|
+
this.#rate = rate;
|
|
253
524
|
}
|
|
254
525
|
static {
|
|
255
|
-
makeReservation = (registry, id,
|
|
526
|
+
makeReservation = (registry, id, rate) => new Reservation(registry, id, rate);
|
|
256
527
|
}
|
|
257
528
|
/**
|
|
258
529
|
* This reservation's slice right now.
|
|
259
530
|
*
|
|
260
|
-
* Stateless, unlike {@link
|
|
531
|
+
* Stateless, unlike {@link rate}, which is a signal of what was last
|
|
261
532
|
* published and so can lag a synchronous {@link update} by a microtask if
|
|
262
533
|
* something else writes the registry first. Call this after {@link update}.
|
|
263
534
|
*/
|
|
@@ -269,12 +540,12 @@ export class Reservation {
|
|
|
269
540
|
/**
|
|
270
541
|
* This reservation's current slice of the estimate.
|
|
271
542
|
*
|
|
272
|
-
* `undefined` while
|
|
273
|
-
*
|
|
274
|
-
*
|
|
543
|
+
* `undefined` while the connection has no estimate or this reservation has
|
|
544
|
+
* been closed: hold the current rate rather than encode at zero. While nothing
|
|
545
|
+
* is subscribed it is the slice the track would get back.
|
|
275
546
|
*/
|
|
276
|
-
get
|
|
277
|
-
return this.#
|
|
547
|
+
get rate() {
|
|
548
|
+
return this.#rate;
|
|
278
549
|
}
|
|
279
550
|
/**
|
|
280
551
|
* Change the ceiling, keeping the same claim.
|
|
@@ -293,7 +564,7 @@ export class Reservation {
|
|
|
293
564
|
if (this.#closed)
|
|
294
565
|
return;
|
|
295
566
|
this.#closed = true;
|
|
296
|
-
this.#
|
|
567
|
+
this.#rate.set(undefined);
|
|
297
568
|
this.#registry.release(this.#id);
|
|
298
569
|
}
|
|
299
570
|
/** Calls {@link close}, so `using` releases the claim. */
|