@moq/net 0.4.8 → 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 -1
- package/announce.js.map +1 -1
- package/announced.d.ts +51 -47
- package/announced.d.ts.map +1 -1
- package/announced.js +183 -31
- 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 -138
- 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 -1
- package/bandwidth_api.js.map +1 -1
- package/broadcast.d.ts +62 -36
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +556 -172
- 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 +20 -12
- package/connection/accept.d.ts.map +1 -1
- package/connection/accept.js +97 -129
- package/connection/accept.js.map +1 -1
- package/connection/browser.d.ts.map +1 -1
- package/connection/browser.js +28 -19
- package/connection/browser.js.map +1 -1
- package/connection/connect.d.ts +119 -23
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +535 -216
- 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 -80
- 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 -108
- package/connection/goaway.js.map +1 -1
- package/connection/handshake.d.ts +32 -6
- package/connection/handshake.d.ts.map +1 -1
- package/connection/handshake.js +97 -20
- package/connection/handshake.js.map +1 -1
- package/connection/index.d.ts +3 -6
- package/connection/index.d.ts.map +1 -1
- package/connection/index.js +1 -2
- 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 +137 -58
- package/connection/pool.d.ts.map +1 -1
- package/connection/pool.js +281 -117
- 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 -233
- 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 -8
- 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 -4
- 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 -46
- 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 -1
- 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 -37
- package/error.js.map +1 -1
- package/errors.d.ts +2 -2
- package/errors.d.ts.map +1 -1
- package/errors.js +2 -2
- 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 -307
- 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 -64
- 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 -35
- package/ietf/aliases.js.map +1 -1
- package/ietf/cluster.d.ts +3 -3
- package/ietf/cluster.js +14 -62
- 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 -143
- 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 -100
- package/ietf/error.js.map +1 -1
- package/ietf/fetch.d.ts +91 -35
- package/ietf/fetch.d.ts.map +1 -1
- package/ietf/fetch.js +172 -93
- package/ietf/fetch.js.map +1 -1
- package/ietf/filter.d.ts +20 -30
- package/ietf/filter.d.ts.map +1 -1
- package/ietf/filter.js +140 -171
- package/ietf/filter.js.map +1 -1
- package/ietf/goaway.d.ts +11 -9
- package/ietf/goaway.d.ts.map +1 -1
- package/ietf/goaway.js +22 -35
- package/ietf/goaway.js.map +1 -1
- package/ietf/hidden.js +1 -1
- package/ietf/hidden.js.map +1 -1
- package/ietf/index.d.ts +2 -14
- package/ietf/index.d.ts.map +1 -1
- package/ietf/index.js +4 -14
- 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 -40
- 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 +17 -3
- package/ietf/namespace.d.ts.map +1 -1
- package/ietf/namespace.js +78 -26
- package/ietf/namespace.js.map +1 -1
- package/ietf/object.d.ts +194 -32
- package/ietf/object.d.ts.map +1 -1
- package/ietf/object.js +405 -178
- package/ietf/object.js.map +1 -1
- package/ietf/parameters.d.ts +22 -42
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +260 -472
- 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 -4
- package/ietf/priority.js.map +1 -1
- package/ietf/properties.d.ts +5 -4
- package/ietf/properties.d.ts.map +1 -1
- package/ietf/properties.js +78 -48
- package/ietf/properties.js.map +1 -1
- package/ietf/publish.d.ts +22 -30
- package/ietf/publish.d.ts.map +1 -1
- package/ietf/publish.js +45 -139
- package/ietf/publish.js.map +1 -1
- package/ietf/publish_namespace.d.ts +46 -69
- package/ietf/publish_namespace.d.ts.map +1 -1
- package/ietf/publish_namespace.js +66 -184
- package/ietf/publish_namespace.js.map +1 -1
- package/ietf/publisher.js +1800 -600
- 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 +3 -27
- package/ietf/request.d.ts.map +1 -1
- package/ietf/request.js +41 -78
- 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 -16
- 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 +4 -29
- package/ietf/setup.d.ts.map +1 -1
- package/ietf/setup.js +6 -117
- 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 -14
- package/ietf/solicit.js.map +1 -1
- package/ietf/subscribe.d.ts +48 -41
- package/ietf/subscribe.d.ts.map +1 -1
- package/ietf/subscribe.js +118 -239
- package/ietf/subscribe.js.map +1 -1
- package/ietf/subscribe_namespace.d.ts +13 -76
- package/ietf/subscribe_namespace.d.ts.map +1 -1
- package/ietf/subscribe_namespace.js +30 -201
- package/ietf/subscribe_namespace.js.map +1 -1
- package/ietf/subscriber.js +1839 -536
- package/ietf/subscriber.js.map +1 -1
- package/ietf/token.js +105 -27
- package/ietf/token.js.map +1 -1
- package/ietf/track.d.ts +25 -22
- package/ietf/track.d.ts.map +1 -1
- package/ietf/track.js +48 -61
- 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 -48
- 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 +25 -10
- package/index.d.ts.map +1 -1
- package/index.js +19 -6
- package/index.js.map +1 -1
- package/internal.d.ts +1512 -64
- package/internal.d.ts.map +1 -1
- package/internal.js +557 -79
- 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 +124 -63
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +384 -158
- 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 -77
- 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 -9
- 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 +1 -1
- package/lite/goaway.d.ts.map +1 -1
- package/lite/goaway.js +5 -13
- package/lite/goaway.js.map +1 -1
- package/lite/group.d.ts +64 -13
- package/lite/group.d.ts.map +1 -1
- package/lite/group.js +108 -30
- 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 +2 -1
- package/lite/index.d.ts.map +1 -1
- package/lite/index.js +2 -1
- package/lite/index.js.map +1 -1
- package/lite/message.d.ts +9 -1
- package/lite/message.d.ts.map +1 -1
- package/lite/message.js +28 -44
- 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 -105
- package/lite/priority.js.map +1 -1
- package/lite/probe.d.ts.map +1 -1
- package/lite/probe.js +9 -0
- 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 -437
- 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 +1 -27
- package/lite/session.d.ts.map +1 -1
- package/lite/session.js +0 -99
- package/lite/session.js.map +1 -1
- package/lite/setup.d.ts +29 -2
- package/lite/setup.d.ts.map +1 -1
- package/lite/setup.js +95 -21
- 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 -1
- package/lite/stream.js.map +1 -1
- package/lite/subscribe.d.ts +475 -75
- package/lite/subscribe.d.ts.map +1 -1
- package/lite/subscribe.js +1373 -142
- 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 -515
- package/lite/subscriber.js.map +1 -1
- package/lite/track.d.ts +24 -9
- package/lite/track.d.ts.map +1 -1
- package/lite/track.js +116 -37
- 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 -33
- 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 +392 -140
- package/origin.d.ts.map +1 -1
- package/origin.js +2533 -686
- 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 -57
- 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 +75 -37
- package/stream.d.ts.map +1 -1
- package/stream.js +236 -92
- 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 -97
- package/tail.js.map +1 -1
- package/time.d.ts +41 -102
- package/time.d.ts.map +1 -1
- package/time.js +129 -91
- 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 +577 -245
- package/track.d.ts.map +1 -1
- package/track.js +7306 -771
- 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 -1
- 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 -4
- 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 -9
- 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/utf8.d.ts +2 -0
- package/util/utf8.d.ts.map +1 -1
- package/util/utf8.js +7 -1
- package/util/utf8.js.map +1 -1
- package/util/varint.d.ts.map +1 -1
- package/util/varint.js +8 -1
- 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 -28
- 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 +145 -30
- package/wire.d.ts.map +1 -1
- package/wire.js +27 -0
- 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 -2
- 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 -699
- 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 -43
- 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 -78
- 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 -16
- package/util/log.js.map +0 -1
- package/zod.d.ts +0 -13
- package/zod.d.ts.map +0 -1
- package/zod.js +0 -18
- package/zod.js.map +0 -1
package/internal.js
CHANGED
|
@@ -1,4 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package-internal constructor hooks. Classes keep their constructors private so consumers
|
|
3
|
+
* can't mint detached handles; sibling modules create identities through these hooks instead.
|
|
4
|
+
* Not exported from the package entrypoint.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { Duration } from "@moq/clock";
|
|
9
|
+
import { NotFound, StreamCode, StreamError, toStreamCode } from "./error.js";
|
|
10
|
+
import { isAnonymous } from "./hop.js";
|
|
11
|
+
import * as Identity from "./identity.js";
|
|
1
12
|
import * as Path from "./path.js";
|
|
13
|
+
import { max, min, UNBOUNDED } from "./util/key.js";
|
|
14
|
+
import * as Varint from "./varint.js";
|
|
15
|
+
/** A null {@link Live.max} in milliseconds, which the model holds as the largest value every peer can read. */
|
|
16
|
+
export const NO_MAX_DELAY = Varint.MAX_U53;
|
|
17
|
+
/** A datagram track's properties as the stream track info a wire answers with: no groups, so no age, refresh, or compression. */
|
|
18
|
+
export function datagramTrackInfo(info) {
|
|
19
|
+
return {
|
|
20
|
+
compression: "none",
|
|
21
|
+
timescale: info.timescale,
|
|
22
|
+
maxAge: null,
|
|
23
|
+
priority: info.priority,
|
|
24
|
+
refresh: { ratio: null, interval: null },
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* `value` rounded up to a whole millisecond, as the wire carries it: callers derive one from
|
|
29
|
+
* measurements (a jitter estimate scaled off RTT), and a budget shortened by rounding skips a group
|
|
30
|
+
* the subscriber still wants. Refused past the safe integer range, naming `field`.
|
|
31
|
+
*/
|
|
32
|
+
export function wireMillis(field, value) {
|
|
33
|
+
const millis = Math.ceil(value.asMillis());
|
|
34
|
+
if (!Number.isSafeInteger(millis)) {
|
|
35
|
+
throw new RangeError(`${field} exceeds the safe integer millisecond range: ${value}`);
|
|
36
|
+
}
|
|
37
|
+
return Duration.millis(millis);
|
|
38
|
+
}
|
|
2
39
|
/** Normalize public group bounds into an inclusive start and exclusive end. */
|
|
3
40
|
export function groupBounds(groups = {}) {
|
|
4
41
|
const bound = (value, start) => {
|
|
@@ -7,20 +44,13 @@ export function groupBounds(groups = {}) {
|
|
|
7
44
|
if ((value.included === undefined) === (value.excluded === undefined)) {
|
|
8
45
|
throw new Error("a group bound must be either included or excluded");
|
|
9
46
|
}
|
|
10
|
-
const
|
|
11
|
-
if (
|
|
12
|
-
throw new Error("a group bound must be a non-negative
|
|
47
|
+
const key = value.included ?? value.excluded;
|
|
48
|
+
if (typeof key !== "bigint" || key < 0n) {
|
|
49
|
+
throw new Error("a group bound must be a non-negative bigint");
|
|
13
50
|
}
|
|
14
|
-
return
|
|
51
|
+
return key + ((start ? value.excluded !== undefined : value.included !== undefined) ? 1n : 0n);
|
|
15
52
|
};
|
|
16
|
-
return { start: bound(groups.start, true) ??
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* The announce-interest prefix a scope needs on a prefix-shaped wire: its literal head.
|
|
20
|
-
* The peer echoes every suffix beneath it, and the caller filters what arrives.
|
|
21
|
-
*/
|
|
22
|
-
export function scopeHead(scope) {
|
|
23
|
-
return Path.from(scope.head);
|
|
53
|
+
return { start: bound(groups.start, true) ?? 0n, end: bound(groups.end, false) };
|
|
24
54
|
}
|
|
25
55
|
/**
|
|
26
56
|
* Whether a segment of `path` below `prefix` starts with `.`, which hides it from announce
|
|
@@ -33,83 +63,531 @@ export function hiddenBelow(prefix, path) {
|
|
|
33
63
|
/**
|
|
34
64
|
* Where each carried route lands under the requested prefix: its suffix beneath the
|
|
35
65
|
* prefix, or the empty suffix for a route above it, where the most specific such route
|
|
36
|
-
* wins the way a request through the prefix would resolve.
|
|
66
|
+
* wins the way a request through the prefix would resolve. Only a candidate `shows` admits
|
|
67
|
+
* at the path it lands on competes.
|
|
37
68
|
*/
|
|
38
|
-
export function presented(prefix, table, carries) {
|
|
69
|
+
export function presented(prefix, table, carries, options = {}) {
|
|
70
|
+
const { root = Path.empty(), keepAbove = false, shows = () => true } = options;
|
|
39
71
|
const out = new Map();
|
|
40
|
-
|
|
41
|
-
|
|
72
|
+
// Hashed on the absolute path requested, as a request for it resolves. A prefix that is
|
|
73
|
+
// valid alone but too deep under the root can name no broadcast, so nothing lands on it.
|
|
74
|
+
// The wire also counts escaped `/`s while the previous release lives, which a request checks.
|
|
75
|
+
const at = Path.tryJoin(root, prefix);
|
|
76
|
+
if (at === undefined || Path.check(at) !== undefined)
|
|
77
|
+
return out;
|
|
78
|
+
// Every claim covering the prefix, as a request through the prefix resolves: the most specific
|
|
79
|
+
// tier, ranked across the prefixes its claims are filed at, each by its absolute filing.
|
|
80
|
+
const covering = [];
|
|
42
81
|
for (const [covered, candidates] of table) {
|
|
43
82
|
if (!carries(covered))
|
|
44
83
|
continue;
|
|
45
84
|
if (Path.hasPrefix(covered, prefix)) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
85
|
+
const depth = Path.parts(covered).length;
|
|
86
|
+
candidates.forEach((candidate, order) => {
|
|
87
|
+
if (!shows(candidate, prefix))
|
|
88
|
+
return;
|
|
89
|
+
// Hold the empty suffix's place in the order the table lists its first claim.
|
|
90
|
+
if (covering.length === 0)
|
|
91
|
+
out.set(Path.empty(), candidate);
|
|
92
|
+
covering.push({
|
|
93
|
+
prefix: candidate.filed ?? Path.join(root, covered),
|
|
94
|
+
depth,
|
|
95
|
+
order: candidate.order ?? order,
|
|
96
|
+
arrival: arrival(candidate.ref),
|
|
97
|
+
candidate,
|
|
98
|
+
route: candidate.route,
|
|
99
|
+
});
|
|
100
|
+
});
|
|
54
101
|
continue;
|
|
55
102
|
}
|
|
56
103
|
const suffix = Path.stripPrefix(prefix, covered);
|
|
57
|
-
|
|
58
|
-
|
|
104
|
+
const best = suffix !== null ? firstEligible(candidates, (candidate) => shows(candidate, covered)) : undefined;
|
|
105
|
+
if (suffix !== null && best)
|
|
106
|
+
out.set(suffix, best);
|
|
107
|
+
}
|
|
108
|
+
// A broadcast published above the requested path serves only its own, so a tier-mate that
|
|
109
|
+
// serves the path ranks ahead of it.
|
|
110
|
+
const best = bestOfTier(at, covering, { serves: (entry) => !entry.candidate.exact || entry.prefix === at });
|
|
111
|
+
if (best) {
|
|
112
|
+
const snap = best.candidate;
|
|
113
|
+
const above = BigInt(Path.parts(prefix).length - best.depth);
|
|
114
|
+
out.set(Path.empty(), keepAbove && above > 0n
|
|
115
|
+
? { ...snap, route: { ...snap.route, above: (snap.route.above ?? 0n) + above } }
|
|
116
|
+
: snap);
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
// When each advertisement's ref was first received, across every filing.
|
|
121
|
+
const receipts = new WeakMap();
|
|
122
|
+
let nextReceipt = 0;
|
|
123
|
+
/** Records `ref` as received now, as each announce of a claim is: it ranks as the newest. */
|
|
124
|
+
export function receive(ref) {
|
|
125
|
+
receipts.set(ref, nextReceipt++);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The order `ref` was last {@link receive}d in, stamped now if it never was: a later one is
|
|
129
|
+
* larger, so a full tie across filings goes to the most recently received claim, as Rust's newest
|
|
130
|
+
* route entry. An update keeps its ref's place.
|
|
131
|
+
*/
|
|
132
|
+
export function arrival(ref) {
|
|
133
|
+
let order = receipts.get(ref);
|
|
134
|
+
if (order === undefined) {
|
|
135
|
+
order = nextReceipt++;
|
|
136
|
+
receipts.set(ref, order);
|
|
137
|
+
}
|
|
138
|
+
return order;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The best of the most specific claims among `filed`, which all cover `path`: a claim shown above
|
|
142
|
+
* its own prefix counts for the shallower prefix it is really at, and claims of one prefix rank
|
|
143
|
+
* against each other wherever each is filed. Only an identity's highest epoch among them (and
|
|
144
|
+
* `others`, of the same claim when `exact`) is eligible; one that `serves` `path` ranks ahead, then
|
|
145
|
+
* {@link compareTier}, then {@link compareTie}. Mirrors `RouteTable::best_route` in rs/moq-net,
|
|
146
|
+
* and with `serves`, `TableCursor::best`.
|
|
147
|
+
*/
|
|
148
|
+
export function bestOfTier(path, filed, options = {}) {
|
|
149
|
+
const { others = () => [], serves = () => true } = options;
|
|
150
|
+
const specificity = (entry) => entry.depth - Number(entry.route.above ?? 0n);
|
|
151
|
+
// A loop, not a spread: a table may hold more candidates than a call takes arguments.
|
|
152
|
+
let most = Number.NEGATIVE_INFINITY;
|
|
153
|
+
for (const entry of filed)
|
|
154
|
+
most = Math.max(most, specificity(entry));
|
|
155
|
+
const tier = filed.filter((entry) => specificity(entry) === most);
|
|
156
|
+
// One claim prefix: an identity's epochs compare across the whole tier.
|
|
157
|
+
const epochs = new Epochs([...tier.map((entry) => entry.route), ...others(most)], () => 0n);
|
|
158
|
+
let best;
|
|
159
|
+
for (const entry of tier) {
|
|
160
|
+
if (epochs.supersedes(entry.route))
|
|
161
|
+
continue;
|
|
162
|
+
if (best === undefined) {
|
|
163
|
+
best = entry;
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
const serving = Number(serves(best)) - Number(serves(entry));
|
|
167
|
+
if ((serving || compareTier(path, entry, best) || compareTie(path, entry, best)) < 0)
|
|
168
|
+
best = entry;
|
|
169
|
+
}
|
|
170
|
+
return best;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* How a full tie between two claims of one tier resolving `path` breaks: to the newest, by each
|
|
174
|
+
* prefix's own order and across prefixes the most recently {@link arrival}, as Rust's final
|
|
175
|
+
* `Reverse(entry.id)`, so a publisher that restarts under a new identity takes over at once. Filed
|
|
176
|
+
* beneath `path` where neither is a lite-07 claim, it goes to the oldest instead, as Rust's
|
|
177
|
+
* `RouteEntry::since`: switching there would restart the route at every relay downstream that
|
|
178
|
+
* ranks it alike. Rust also renews `since` when a re-price changes the rank; this origin forwards
|
|
179
|
+
* no route it received, so a route that dips and recovers here restarts only its own readers.
|
|
180
|
+
* Then the deeper filing.
|
|
181
|
+
*/
|
|
182
|
+
export function compareTie(path, a, b) {
|
|
183
|
+
const newest = a.prefix === b.prefix ? a.order - b.order : b.arrival - a.arrival;
|
|
184
|
+
const holds = a.prefix !== path && b.prefix !== path && !a.route.claimed && !b.route.claimed;
|
|
185
|
+
return (holds ? -newest : newest) || b.depth - a.depth;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* The first of `candidates`, most preferred first, that `admits` and that no other admitted
|
|
189
|
+
* candidate supersedes. Supersession is decided among what the reader may see, so a higher epoch
|
|
190
|
+
* it cannot see never hides a route it can.
|
|
191
|
+
*/
|
|
192
|
+
export function firstEligible(candidates, admits = () => true) {
|
|
193
|
+
const admitted = candidates.filter(admits);
|
|
194
|
+
const epochs = new Epochs(admitted.map((candidate) => candidate.route));
|
|
195
|
+
return admitted.find((candidate) => !epochs.supersedes(candidate.route));
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* What of `path`'s subtree every one of `scopes` serves: undefined when all of it, and otherwise
|
|
199
|
+
* the prefixes beneath `path` that all of them share, possibly none. Asked about a path rather
|
|
200
|
+
* than a {@link Path.Prefix}, so a path no prefix can spell still gets an answer.
|
|
201
|
+
*/
|
|
202
|
+
export function within(path, scopes) {
|
|
203
|
+
let out;
|
|
204
|
+
for (const scope of scopes) {
|
|
205
|
+
if (!scope || scope.matches(path))
|
|
206
|
+
continue;
|
|
207
|
+
const beneath = new Path.Prefixes(scope.toArray().filter((member) => Path.hasPrefix(path, member.text)));
|
|
208
|
+
out = out ? out.intersect(beneath) : beneath;
|
|
59
209
|
}
|
|
60
210
|
return out;
|
|
61
211
|
}
|
|
62
|
-
/**
|
|
63
|
-
export function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
212
|
+
/** Add `[start, end)` to sorted, disjoint, non-adjacent `runs`, merging every run it touches. */
|
|
213
|
+
export function insertRun(runs, start, end) {
|
|
214
|
+
if (start >= end)
|
|
215
|
+
return;
|
|
216
|
+
// Merging a run it touches, so the first that ends at or past `start`.
|
|
217
|
+
const first = runsFrom(runs, start - 1n);
|
|
218
|
+
let last = first;
|
|
219
|
+
while (last < runs.length && runs[last].start <= end)
|
|
220
|
+
last++;
|
|
221
|
+
const merged = first === last ? { start, end } : { start: min(start, runs[first].start), end: max(end, runs[last - 1].end) };
|
|
222
|
+
runs.splice(first, last - first, merged);
|
|
223
|
+
}
|
|
224
|
+
/** The sorted, disjoint `runs` with `[start, end)` taken out, each part keeping its run's fields. */
|
|
225
|
+
export function removeRun(runs, start, end) {
|
|
226
|
+
return runs.flatMap((run) => [
|
|
227
|
+
{ ...run, start: run.start, end: min(run.end, start) },
|
|
228
|
+
{ ...run, start: max(run.start, end), end: run.end },
|
|
229
|
+
].filter((part) => part.start < part.end));
|
|
230
|
+
}
|
|
231
|
+
/** Take `[start, end)` out of sorted, disjoint `runs` in place, each part keeping its run's fields. */
|
|
232
|
+
export function cutRun(runs, start, end) {
|
|
233
|
+
if (start >= end)
|
|
234
|
+
return;
|
|
235
|
+
const from = runsFrom(runs, start);
|
|
236
|
+
let to = from;
|
|
237
|
+
while (to < runs.length && runs[to].start < end)
|
|
238
|
+
to++;
|
|
239
|
+
if (from === to)
|
|
240
|
+
return;
|
|
241
|
+
const parts = [];
|
|
242
|
+
if (runs[from].start < start)
|
|
243
|
+
parts.push({ ...runs[from], end: start });
|
|
244
|
+
if (runs[to - 1].end > end)
|
|
245
|
+
parts.push({ ...runs[to - 1], start: end });
|
|
246
|
+
runs.splice(from, to - from, ...parts);
|
|
247
|
+
}
|
|
248
|
+
/** A key never produced; see {@link Hole}. */
|
|
249
|
+
export function skipHole() {
|
|
250
|
+
return { reason: "skip" };
|
|
251
|
+
}
|
|
252
|
+
/** A key not found, which a later fill or failover may still find; see {@link Hole}. */
|
|
253
|
+
export function dropHole() {
|
|
254
|
+
return { reason: "drop" };
|
|
255
|
+
}
|
|
256
|
+
/** A group judged stale under `budget` milliseconds, within the exclusive group end `cap` when it has one. */
|
|
257
|
+
export function staleHole(budget, cap) {
|
|
258
|
+
return { reason: "old", maxAge: budget, cap };
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* The verdict a reader's own refusal or failure with `error` reaches: `old` for a superseded
|
|
262
|
+
* group, `skip` for one never produced, else not found. Mirrors the Rust `Hole::missed`.
|
|
263
|
+
*/
|
|
264
|
+
export function holeOf(error) {
|
|
265
|
+
switch (toStreamCode(error)) {
|
|
266
|
+
case StreamCode.Old:
|
|
267
|
+
return { reason: "old" };
|
|
268
|
+
case StreamCode.Skip:
|
|
269
|
+
return skipHole();
|
|
270
|
+
default:
|
|
271
|
+
return dropHole();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/** The error a reader waiting on a key given up as `hole` ends with: a key never produced is simply not found. */
|
|
275
|
+
export function holeError(hole) {
|
|
276
|
+
switch (hole.reason) {
|
|
277
|
+
case "skip":
|
|
278
|
+
return new StreamError(StreamCode.NotFound, { message: "group never produced" });
|
|
279
|
+
case "drop":
|
|
280
|
+
return new NotFound("group");
|
|
281
|
+
case "old":
|
|
282
|
+
return new StreamError(StreamCode.Old, { message: "group is past the budget" });
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Whether `run` settles a reader judging under `budget` with `coverage`. Any run but a received
|
|
287
|
+
* stale one does. A stale verdict holds for a reader no wider than the budget it was judged under
|
|
288
|
+
* that reads every group above the run's start: its own successor and edge are then no older than
|
|
289
|
+
* those the verdict was judged against, since a group's verdict looks only above it. An uncapped
|
|
290
|
+
* reader reads them past the live edge; a capped one only when the upstream judged within the very
|
|
291
|
+
* cap it has (`run.cap`), else the verdict may rest on groups above the cap it never sees. A reader
|
|
292
|
+
* whose budget varies by group is held to its widest. Mirrors the Rust `settles`.
|
|
293
|
+
*/
|
|
294
|
+
export function settles(run, budget, coverage) {
|
|
295
|
+
if (run.maxAge === undefined)
|
|
296
|
+
return true;
|
|
297
|
+
if ((budget.isUniform() ? budget.at(run.start) : budget.widest()) > run.maxAge)
|
|
298
|
+
return false;
|
|
299
|
+
if (coverage === undefined)
|
|
300
|
+
return false;
|
|
301
|
+
const { cap } = coverage;
|
|
302
|
+
if (cap !== undefined && run.cap !== cap)
|
|
303
|
+
return false;
|
|
304
|
+
const above = run.start + 1n;
|
|
305
|
+
const end = cap ?? UNBOUNDED;
|
|
306
|
+
if (above >= end)
|
|
307
|
+
return true;
|
|
308
|
+
const held = coverage.runs.find((run) => run.start <= above && above < run.end);
|
|
309
|
+
return held !== undefined && held.end >= end;
|
|
310
|
+
}
|
|
311
|
+
/** Whether two runs say the same thing, so they may merge. */
|
|
312
|
+
export function sameHole(a, b) {
|
|
313
|
+
return (a.reason === b.reason &&
|
|
314
|
+
a.maxAge === b.maxAge &&
|
|
315
|
+
a.cap === b.cap &&
|
|
316
|
+
a.refusal === b.refusal &&
|
|
317
|
+
!a.received === !b.received &&
|
|
318
|
+
!a.own === !b.own);
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Sorted, disjoint `drops` with `[start, end)` given up as `hole` says, which replaces whatever
|
|
322
|
+
* it overlaps. Neighbours given up alike merge, so a wide DROP stays one run and a peer naming
|
|
323
|
+
* one key per DROP cannot grow the runs.
|
|
324
|
+
*/
|
|
325
|
+
export function insertDrop(drops, start, end, hole) {
|
|
326
|
+
if (start >= end)
|
|
327
|
+
return [...drops];
|
|
328
|
+
const next = removeRun(drops, start, end);
|
|
329
|
+
let at = 0;
|
|
330
|
+
while (at < next.length && next[at].start < start)
|
|
331
|
+
at++;
|
|
332
|
+
next.splice(at, 0, {
|
|
333
|
+
start,
|
|
334
|
+
end,
|
|
335
|
+
reason: hole.reason,
|
|
336
|
+
maxAge: hole.maxAge,
|
|
337
|
+
cap: hole.cap,
|
|
338
|
+
received: hole.received,
|
|
339
|
+
own: hole.own,
|
|
340
|
+
refusal: hole.refusal,
|
|
341
|
+
});
|
|
342
|
+
const merged = [];
|
|
343
|
+
for (const run of next) {
|
|
344
|
+
const last = merged[merged.length - 1];
|
|
345
|
+
if (last && last.end === run.start && sameHole(last, run))
|
|
346
|
+
last.end = run.end;
|
|
347
|
+
else
|
|
348
|
+
merged.push({ ...run });
|
|
349
|
+
}
|
|
350
|
+
return merged;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* The parts of sorted, disjoint `runs` that sorted, disjoint `cut` leaves, each keeping its run's
|
|
354
|
+
* fields, as {@link removeRun} of each cut would, in one pass.
|
|
355
|
+
*/
|
|
356
|
+
export function subtractRuns(runs, cut) {
|
|
357
|
+
const kept = [];
|
|
358
|
+
let first = 0;
|
|
359
|
+
for (const run of runs) {
|
|
360
|
+
while (first < cut.length && cut[first].end <= run.start)
|
|
361
|
+
first++;
|
|
362
|
+
let from = run.start;
|
|
363
|
+
for (let i = first; i < cut.length && cut[i].start < run.end; i++) {
|
|
364
|
+
if (cut[i].start > from)
|
|
365
|
+
kept.push({ ...run, start: from, end: cut[i].start });
|
|
366
|
+
from = max(from, cut[i].end);
|
|
367
|
+
}
|
|
368
|
+
if (from < run.end)
|
|
369
|
+
kept.push({ ...run, start: from, end: run.end });
|
|
370
|
+
}
|
|
371
|
+
return kept;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* `drops` with each of the sorted, disjoint `runs` inserted as {@link insertDrop} inserts it, in
|
|
375
|
+
* one pass: folding in a span of many runs costs the runs, not their square.
|
|
376
|
+
*/
|
|
377
|
+
export function insertDrops(drops, runs) {
|
|
378
|
+
if (runs.length === 0)
|
|
379
|
+
return [...drops];
|
|
380
|
+
const next = subtractRuns(drops, runs);
|
|
381
|
+
// Appended one by one: a peer controls how many runs there are, past any argument limit.
|
|
382
|
+
for (const run of runs)
|
|
383
|
+
next.push(run);
|
|
384
|
+
next.sort((a, b) => (a.start < b.start ? -1 : a.start > b.start ? 1 : 0));
|
|
385
|
+
const merged = [];
|
|
386
|
+
for (const run of next) {
|
|
387
|
+
const last = merged[merged.length - 1];
|
|
388
|
+
if (last && last.end === run.start && sameHole(last, run))
|
|
389
|
+
last.end = run.end;
|
|
390
|
+
else
|
|
391
|
+
merged.push({ ...run });
|
|
392
|
+
}
|
|
393
|
+
return merged;
|
|
394
|
+
}
|
|
395
|
+
/** The run of `drops` giving `key` up, if any. */
|
|
396
|
+
export function dropAt(drops, key) {
|
|
397
|
+
return drops.find((run) => run.start <= key && key < run.end);
|
|
398
|
+
}
|
|
399
|
+
/** The index of the first of sorted, disjoint `runs` ending past `key`. */
|
|
400
|
+
export function runsFrom(runs, key) {
|
|
401
|
+
let lo = 0;
|
|
402
|
+
let hi = runs.length;
|
|
403
|
+
while (lo < hi) {
|
|
404
|
+
const mid = (lo + hi) >>> 1;
|
|
405
|
+
if (runs[mid].end <= key)
|
|
406
|
+
lo = mid + 1;
|
|
407
|
+
else
|
|
408
|
+
hi = mid;
|
|
409
|
+
}
|
|
410
|
+
return lo;
|
|
411
|
+
}
|
|
412
|
+
/** The parts of `[start, end)` that sorted, disjoint `runs` do not cover, in order. */
|
|
413
|
+
export function runGaps(runs, start, end) {
|
|
414
|
+
const gaps = [];
|
|
415
|
+
let next = start;
|
|
416
|
+
for (let i = runsFrom(runs, start); i < runs.length; i++) {
|
|
417
|
+
const run = runs[i];
|
|
418
|
+
if (next >= end)
|
|
419
|
+
break;
|
|
420
|
+
if (run.start > next)
|
|
421
|
+
gaps.push({ start: next, end: min(run.start, end) });
|
|
422
|
+
next = max(next, run.end);
|
|
423
|
+
}
|
|
424
|
+
if (next < end)
|
|
425
|
+
gaps.push({ start: next, end });
|
|
426
|
+
return gaps;
|
|
427
|
+
}
|
|
428
|
+
/** The first group an exclusive track end excludes whole: one past the last group that may exist. */
|
|
429
|
+
export function finalKey(end) {
|
|
430
|
+
return end.group + (end.frame === 0 ? 0n : 1n);
|
|
431
|
+
}
|
|
432
|
+
/** Filled in by each owning module as it loads. */
|
|
433
|
+
export const hooks = {};
|
|
434
|
+
/** The Spread Hash's offset basis, which lite-06 and earlier rank by. */
|
|
435
|
+
const SPREAD_BASIS = 0x420c0decb00bn;
|
|
436
|
+
/** FNV-1a 64 from `basis` of `path`, then `bytes`. */
|
|
437
|
+
function fnv(path, bytes, basis = SPREAD_BASIS) {
|
|
438
|
+
const prime = 0x100000001b3n;
|
|
439
|
+
let hash = basis;
|
|
440
|
+
for (const byte of new TextEncoder().encode(path)) {
|
|
441
|
+
hash = BigInt.asUintN(64, (hash ^ BigInt(byte)) * prime);
|
|
442
|
+
}
|
|
443
|
+
for (const byte of bytes) {
|
|
444
|
+
hash = BigInt.asUintN(64, (hash ^ BigInt(byte)) * prime);
|
|
445
|
+
}
|
|
446
|
+
return hash;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Spreads a pool's identities across paths: FNV-1a 64 of `path` then the identity's UTF-8.
|
|
450
|
+
* Keyed on the requested path so a pool advertising one prefix shares its paths, and every
|
|
451
|
+
* node agrees, since the identity reads the same everywhere. Mirrors `identity_key` in
|
|
452
|
+
* `rs/moq-net`.
|
|
453
|
+
*/
|
|
454
|
+
export function spreadHash(path, identity) {
|
|
455
|
+
return fnv(path, new TextEncoder().encode(identity));
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* The draft's Rendezvous Hash: standard FNV-1a 64 of `path` then the identity's UTF-8, which
|
|
459
|
+
* spreads a pool's lite-07 claims across paths the same on every node. Mirrors `rendezvous` in
|
|
460
|
+
* `rs/moq-net`.
|
|
461
|
+
*/
|
|
462
|
+
function rendezvousHash(path, identity) {
|
|
463
|
+
return fnv(path, new TextEncoder().encode(identity), 0xcbf29ce484222325n);
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* The best claim covering `path`, as `RouteTable::best_route` in rs/moq-net picks it: only the
|
|
467
|
+
* most specific claims compete, a claim shown above its own prefix counting for the shallower
|
|
468
|
+
* prefix it is really at, and they rank against each other wherever each is filed. Of those, only
|
|
469
|
+
* an identity's highest epoch is eligible, an exact claim's `others` (which never win) included,
|
|
470
|
+
* and the rest order by {@link compareTier}, then {@link compareTie}: a claim is new when it
|
|
471
|
+
* starts or restarts (another identity or epoch), and keeps its place through a re-price.
|
|
472
|
+
* `candidates` lists each
|
|
473
|
+
* covering prefix's, newest first, and `advertised` names each one's ref and route. Every
|
|
474
|
+
* selector ranks through this, so the announcements and the consumes of one session never pick
|
|
475
|
+
* apart.
|
|
476
|
+
*/
|
|
477
|
+
export function mostSpecific(path, candidates, advertised, others = []) {
|
|
478
|
+
const filed = [];
|
|
479
|
+
let depth = Path.parts(path).length;
|
|
480
|
+
const exact = depth;
|
|
481
|
+
for (const prefix of coveringPrefixes(path)) {
|
|
482
|
+
let order = 0;
|
|
483
|
+
for (const candidate of candidates(prefix)) {
|
|
484
|
+
const { ref, route } = advertised(candidate);
|
|
485
|
+
filed.push({ prefix, depth, order: order++, arrival: arrival(ref), candidate, route });
|
|
486
|
+
}
|
|
487
|
+
depth--;
|
|
488
|
+
}
|
|
489
|
+
return bestOfTier(path, filed, { others: (specificity) => (specificity === exact ? others : []) })?.candidate;
|
|
490
|
+
}
|
|
491
|
+
/** Covering prefixes, most specific first, including the empty root. */
|
|
492
|
+
export function* coveringPrefixes(path) {
|
|
493
|
+
const segments = Path.parts(path);
|
|
494
|
+
let end = path.length;
|
|
495
|
+
for (let i = segments.length;; i--) {
|
|
496
|
+
yield path.slice(0, end);
|
|
497
|
+
if (i === 0)
|
|
498
|
+
return;
|
|
499
|
+
// Drop the last segment and the `/` before it, if any.
|
|
500
|
+
end = Math.max(end - segments[i - 1].length - 1, 0);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Whether `route` at `prefix` is superseded among `others`: one of them carries its identity at
|
|
505
|
+
* a higher epoch at the same prefix. An older incarnation of an identity is never eligible,
|
|
506
|
+
* however cheap, since its publisher was replaced.
|
|
507
|
+
*/
|
|
508
|
+
export function superseded(route, others) {
|
|
509
|
+
return new Epochs(others).supersedes(route);
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* The highest epoch each identity reaches among a set of routes, per claim: a claim is its prefix
|
|
513
|
+
* and how far above it was shown, so a broader claim shown at a prefix is another claim than the
|
|
514
|
+
* one made there, and its epoch supersedes nothing of it. Built in one pass so ranking N routes
|
|
515
|
+
* stays linear. Only epochs above 0 are kept, since nothing is below 0: the common case, where
|
|
516
|
+
* every identity announces epoch 0, stores nothing. Mirrors `Epochs` in rs/moq-net, whose routes
|
|
517
|
+
* are all of one prefix here.
|
|
518
|
+
*/
|
|
519
|
+
class Epochs {
|
|
520
|
+
#highest = new Map();
|
|
521
|
+
#claim;
|
|
522
|
+
/** `claim` names each route's claim among `routes`: its Above, for routes all of one prefix. */
|
|
523
|
+
constructor(routes, claim = (route) => route.above ?? 0n) {
|
|
524
|
+
this.#claim = claim;
|
|
525
|
+
for (const route of routes) {
|
|
526
|
+
const epoch = route.epoch ?? 0n;
|
|
527
|
+
if (epoch === 0n)
|
|
528
|
+
continue;
|
|
529
|
+
let claims = this.#highest.get(route.identity);
|
|
530
|
+
if (!claims) {
|
|
531
|
+
claims = new Map();
|
|
532
|
+
this.#highest.set(route.identity, claims);
|
|
533
|
+
}
|
|
534
|
+
const highest = claims.get(claim(route));
|
|
535
|
+
if (highest === undefined || epoch > highest)
|
|
536
|
+
claims.set(claim(route), epoch);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
/** Whether a route carries `route`'s identity at a higher epoch on the same claim. */
|
|
540
|
+
supersedes(route) {
|
|
541
|
+
const highest = this.#highest.get(route.identity)?.get(this.#claim(route));
|
|
542
|
+
return highest !== undefined && highest > (route.epoch ?? 0n);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Prefer a route that is available (not held), then one that is not draining (a peer that sent
|
|
547
|
+
* GOAWAY), which still reaches its origin, then the highest priority on its path, then identified
|
|
548
|
+
* publishers, then lower static cost.
|
|
549
|
+
*/
|
|
550
|
+
export function compareRoutes(a, b) {
|
|
551
|
+
const held = (route) => Number(route.available === false);
|
|
552
|
+
const draining = (route) => Number(route.draining ?? false);
|
|
553
|
+
return (held(a) - held(b) ||
|
|
554
|
+
draining(a) - draining(b) ||
|
|
555
|
+
(b.priority ?? 0) - (a.priority ?? 0) ||
|
|
556
|
+
Number(isAnonymous(a)) - Number(isAnonymous(b)) ||
|
|
557
|
+
(a.cost < b.cost ? -1 : a.cost > b.cost ? 1 : 0));
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Order two claims of one tier resolving `path`, each filed at its `prefix`: by preference, hop
|
|
561
|
+
* count, then one filed at `path` itself, then, keyed on `path` whatever each claim's filing, the
|
|
562
|
+
* rendezvous hash of a lite-07 claim's identity or the spread hash of a named one. The hashes only
|
|
563
|
+
* spread a pool over a prefix's paths, as `route_order` in rs/moq-net does. Any other tie breaks by
|
|
564
|
+
* {@link compareTie}.
|
|
565
|
+
*/
|
|
566
|
+
export function compareTier(path, a, b) {
|
|
567
|
+
const order = compareRoutes(a.route, b.route) || routeHops(a.route) - routeHops(b.route);
|
|
568
|
+
if (order !== 0)
|
|
569
|
+
return order;
|
|
570
|
+
// A claim filed at the path itself skips the hash and ranks first, as a route entered here at
|
|
571
|
+
// the path does in Rust; two of them tie, for the newest to win.
|
|
572
|
+
const exact = Number(b.prefix === path) - Number(a.prefix === path);
|
|
573
|
+
if (exact !== 0 || a.prefix === path)
|
|
574
|
+
return exact;
|
|
575
|
+
const [ka, kb] = [routeKey(path, a.route), routeKey(path, b.route)];
|
|
576
|
+
return ka < kb ? -1 : ka > kb ? 1 : 0;
|
|
577
|
+
}
|
|
578
|
+
/** The hops a route ranks by: a lite-07 claim counts as the one hop to the peer that sent it. */
|
|
579
|
+
export function routeHops(route) {
|
|
580
|
+
return route.claimed ? 1 : route.hops.length;
|
|
581
|
+
}
|
|
582
|
+
/** The hash a route ranks by beneath its prefix, each route keyed on its own: a lite-07 claim by
|
|
583
|
+
* the rendezvous hash of its identity, a named identity by its spread hash, and one a session
|
|
584
|
+
* minted by none, since no other node shares it. As `route_order` in rs/moq-net. */
|
|
585
|
+
function routeKey(path, route) {
|
|
586
|
+
const identity = route.identity;
|
|
587
|
+
if (route.claimed)
|
|
588
|
+
return rendezvousHash(path, identity ? Identity.text(identity) : "");
|
|
589
|
+
if (identity !== undefined && Identity.isMinted(identity))
|
|
590
|
+
return 0n;
|
|
591
|
+
return spreadHash(path, identity ? Identity.text(identity) : "");
|
|
592
|
+
}
|
|
115
593
|
//# sourceMappingURL=internal.js.map
|