@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/queue.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** An append queue that releases consumed entries without shifting the retained tail. @internal */
|
|
2
|
+
export class Queue {
|
|
3
|
+
#items = [];
|
|
4
|
+
#head = 0;
|
|
5
|
+
constructor(items = []) {
|
|
6
|
+
for (const item of items)
|
|
7
|
+
this.push(item);
|
|
8
|
+
}
|
|
9
|
+
get length() {
|
|
10
|
+
return this.#items.length - this.#head;
|
|
11
|
+
}
|
|
12
|
+
get first() {
|
|
13
|
+
return this.#items[this.#head];
|
|
14
|
+
}
|
|
15
|
+
get last() {
|
|
16
|
+
return this.length === 0 ? undefined : this.#items[this.#items.length - 1];
|
|
17
|
+
}
|
|
18
|
+
/** The retained entry `index` places from the front. */
|
|
19
|
+
at(index) {
|
|
20
|
+
return index < 0 || index >= this.length ? undefined : this.#items[this.#head + index];
|
|
21
|
+
}
|
|
22
|
+
push(item) {
|
|
23
|
+
this.#items.push(item);
|
|
24
|
+
}
|
|
25
|
+
/** Remove the newest entry. */
|
|
26
|
+
pop() {
|
|
27
|
+
return this.length === 0 ? undefined : this.#items.pop();
|
|
28
|
+
}
|
|
29
|
+
shift() {
|
|
30
|
+
if (this.length === 0)
|
|
31
|
+
return undefined;
|
|
32
|
+
const item = this.#items[this.#head];
|
|
33
|
+
this.#items[this.#head++] = undefined;
|
|
34
|
+
// Compact geometrically, so removing a frame costs amortized constant time.
|
|
35
|
+
if (this.#head * 2 >= this.#items.length) {
|
|
36
|
+
this.#items = this.#items.slice(this.#head);
|
|
37
|
+
this.#head = 0;
|
|
38
|
+
}
|
|
39
|
+
return item;
|
|
40
|
+
}
|
|
41
|
+
*[Symbol.iterator]() {
|
|
42
|
+
for (let index = this.#head; index < this.#items.length; index++)
|
|
43
|
+
yield this.#items[index];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=queue.js.map
|
package/queue.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,MAAM,OAAO,KAAK;IACjB,MAAM,GAAsB,EAAE,CAAC;IAC/B,KAAK,GAAG,CAAC,CAAC;IAEV,YAAY,KAAK,GAAgB,EAAE;QAClC,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,MAAM;QACT,OAAO,IAA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AK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC5C,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QAChB,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjB,KAAK,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE;YAAE,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAM,CAAC;IACjG,CAAC;CACD","sourcesContent":["/** An append queue that releases consumed entries without shifting the retained tail. @internal */\nexport class Queue<T> implements Iterable<T> {\n\t#items: (T | undefined)[] = [];\n\t#head = 0;\n\n\tconstructor(items: Iterable<T> = []) {\n\t\tfor (const item of items) this.push(item);\n\t}\n\n\tget length(): number {\n\t\treturn this.#items.length - this.#head;\n\t}\n\n\tget first(): T | undefined {\n\t\treturn this.#items[this.#head];\n\t}\n\n\tget last(): T | undefined {\n\t\treturn this.length === 0 ? undefined : this.#items[this.#items.length - 1];\n\t}\n\n\t/** The retained entry `index` places from the front. */\n\tat(index: number): T | undefined {\n\t\treturn index < 0 || index >= this.length ? undefined : this.#items[this.#head + index];\n\t}\n\n\tpush(item: T): void {\n\t\tthis.#items.push(item);\n\t}\n\n\t/** Remove the newest entry. */\n\tpop(): T | undefined {\n\t\treturn this.length === 0 ? undefined : this.#items.pop();\n\t}\n\n\tshift(): T | undefined {\n\t\tif (this.length === 0) return undefined;\n\t\tconst item = this.#items[this.#head];\n\t\tthis.#items[this.#head++] = undefined;\n\t\t// Compact geometrically, so removing a frame costs amortized constant time.\n\t\tif (this.#head * 2 >= this.#items.length) {\n\t\t\tthis.#items = this.#items.slice(this.#head);\n\t\t\tthis.#head = 0;\n\t\t}\n\t\treturn item;\n\t}\n\n\t*[Symbol.iterator](): Iterator<T> {\n\t\tfor (let index = this.#head; index < this.#items.length; index++) yield this.#items[index] as T;\n\t}\n}\n"]}
|
package/ranges.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The union of every subscriber's ranges, kept current per change rather than refolded. Mirrors
|
|
3
|
+
* the Rust `demand::Ranges`.
|
|
4
|
+
*
|
|
5
|
+
* Time ranges count as runs of group starts in a {@link Cover}, so a change touches two boundaries
|
|
6
|
+
* and asks one range-minimum question, whatever else the audience holds. A start between groups
|
|
7
|
+
* stands for the group containing it, which a range starting at or before it covers too, so spans
|
|
8
|
+
* merge as they do over starts. Ranges with no time start can't be placed on that line and are
|
|
9
|
+
* counted by value instead: live joins by lag and end under the largest max among them, since where
|
|
10
|
+
* a join lands doesn't depend on it, and ranges from the oldest group under the furthest end, which
|
|
11
|
+
* takes in the rest.
|
|
12
|
+
*
|
|
13
|
+
* All that holds within one policy, since folding a range into one at another policy would lose its
|
|
14
|
+
* priority or order. Across policies a range is dropped only once ranges at policies that
|
|
15
|
+
* {@link covers | cover} its own cover its span. With one policy there is nothing to fold, so a
|
|
16
|
+
* change costs O(log n) as above. With several, the fold is redone only when one policy's union
|
|
17
|
+
* moves, at the cost of the union's own length.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
import type { Range } from "./track.ts";
|
|
22
|
+
/**
|
|
23
|
+
* Every subscriber's ranges, counted so that one change costs O(log n) unless several policies are
|
|
24
|
+
* asked and it moves the union of its policy's ranges, folded as the window module's `union` folds
|
|
25
|
+
* them.
|
|
26
|
+
*/
|
|
27
|
+
export declare class Ranges {
|
|
28
|
+
#private;
|
|
29
|
+
/** Count `range`, returning whether the union changed. */
|
|
30
|
+
add(range: Range): boolean;
|
|
31
|
+
/** Uncount `range`, one {@link add} counted, returning whether the union changed. */
|
|
32
|
+
remove(range: Range): boolean;
|
|
33
|
+
/** The union in a canonical order, costing its own length rather than the audience's. Read only. */
|
|
34
|
+
union(): readonly Range[];
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=ranges.d.ts.map
|
package/ranges.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ranges.d.ts","sourceRoot":"","sources":["../src/ranges.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAwCxC;;;;GAIG;AACH,qBAAa,MAAM;;IAOlB,0DAA0D;IAC1D,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAWzB;IAED,qFAAqF;IACrF,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAU5B;IAED,oGAAoG;IACpG,KAAK,IAAI,SAAS,KAAK,EAAE,CAGxB;CA2BD"}
|
package/ranges.js
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The union of every subscriber's ranges, kept current per change rather than refolded. Mirrors
|
|
3
|
+
* the Rust `demand::Ranges`.
|
|
4
|
+
*
|
|
5
|
+
* Time ranges count as runs of group starts in a {@link Cover}, so a change touches two boundaries
|
|
6
|
+
* and asks one range-minimum question, whatever else the audience holds. A start between groups
|
|
7
|
+
* stands for the group containing it, which a range starting at or before it covers too, so spans
|
|
8
|
+
* merge as they do over starts. Ranges with no time start can't be placed on that line and are
|
|
9
|
+
* counted by value instead: live joins by lag and end under the largest max among them, since where
|
|
10
|
+
* a join lands doesn't depend on it, and ranges from the oldest group under the furthest end, which
|
|
11
|
+
* takes in the rest.
|
|
12
|
+
*
|
|
13
|
+
* All that holds within one policy, since folding a range into one at another policy would lose its
|
|
14
|
+
* priority or order. Across policies a range is dropped only once ranges at policies that
|
|
15
|
+
* {@link covers | cover} its own cover its span. With one policy there is nothing to fold, so a
|
|
16
|
+
* change costs O(log n) as above. With several, the fold is redone only when one policy's union
|
|
17
|
+
* moves, at the cost of the union's own length.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
import { Counts, Cover } from "./cover.js";
|
|
22
|
+
import { UNBOUNDED } from "./util/key.js";
|
|
23
|
+
import { compare, isEmpty, joinOf, maxOf, policyOf, policyRank, rangeBudget, rangeKey, rangeTime, rankPolicy, withPolicy, } from "./window.js";
|
|
24
|
+
function shapeOf(range) {
|
|
25
|
+
if (isEmpty(range))
|
|
26
|
+
return { kind: "empty" };
|
|
27
|
+
const start = rangeTime(range);
|
|
28
|
+
const end = range.end;
|
|
29
|
+
if (start !== undefined)
|
|
30
|
+
return { kind: "time", start, end: end === undefined ? UNBOUNDED : end + 1n };
|
|
31
|
+
const join = joinOf(range);
|
|
32
|
+
if (join !== undefined && typeof range.start === "object")
|
|
33
|
+
return { kind: "join", join, min: range.start.live.min, budget: rangeBudget(range) };
|
|
34
|
+
if (end === undefined)
|
|
35
|
+
return { kind: "open" };
|
|
36
|
+
return { kind: "oldest", end };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Every subscriber's ranges, counted so that one change costs O(log n) unless several policies are
|
|
40
|
+
* asked and it moves the union of its policy's ranges, folded as the window module's `union` folds
|
|
41
|
+
* them.
|
|
42
|
+
*/
|
|
43
|
+
export class Ranges {
|
|
44
|
+
// The ranges of each policy, by its rank.
|
|
45
|
+
#classes = new Map();
|
|
46
|
+
// The union, until a change moves it. Kept while several policies are asked, to tell whether a
|
|
47
|
+
// change moved it.
|
|
48
|
+
#union = [];
|
|
49
|
+
/** Count `range`, returning whether the union changed. */
|
|
50
|
+
add(range) {
|
|
51
|
+
if (isEmpty(range))
|
|
52
|
+
return false;
|
|
53
|
+
const rank = policyRank(policyOf(range));
|
|
54
|
+
const several = this.#classes.size > 1 || (this.#classes.size === 1 && !this.#classes.has(rank));
|
|
55
|
+
if (several)
|
|
56
|
+
this.union();
|
|
57
|
+
let held = this.#classes.get(rank);
|
|
58
|
+
if (!held) {
|
|
59
|
+
held = new Class();
|
|
60
|
+
this.#classes.set(rank, held);
|
|
61
|
+
}
|
|
62
|
+
return held.add(range) && this.#moved(several);
|
|
63
|
+
}
|
|
64
|
+
/** Uncount `range`, one {@link add} counted, returning whether the union changed. */
|
|
65
|
+
remove(range) {
|
|
66
|
+
if (isEmpty(range))
|
|
67
|
+
return false;
|
|
68
|
+
const several = this.#classes.size > 1;
|
|
69
|
+
if (several)
|
|
70
|
+
this.union();
|
|
71
|
+
const rank = policyRank(policyOf(range));
|
|
72
|
+
const held = this.#classes.get(rank);
|
|
73
|
+
if (!held)
|
|
74
|
+
throw new Error("a counted policy");
|
|
75
|
+
const moved = held.remove(range);
|
|
76
|
+
if (held.held === 0)
|
|
77
|
+
this.#classes.delete(rank);
|
|
78
|
+
return moved && this.#moved(several);
|
|
79
|
+
}
|
|
80
|
+
/** The union in a canonical order, costing its own length rather than the audience's. Read only. */
|
|
81
|
+
union() {
|
|
82
|
+
this.#union ??= this.#fold();
|
|
83
|
+
return this.#union;
|
|
84
|
+
}
|
|
85
|
+
// Whether a change that moved one policy's union moved the union: always with one policy asked,
|
|
86
|
+
// and otherwise only when the fold comes out different.
|
|
87
|
+
#moved(several) {
|
|
88
|
+
const old = this.#union;
|
|
89
|
+
this.#union = undefined;
|
|
90
|
+
if (!several || old === undefined)
|
|
91
|
+
return true;
|
|
92
|
+
const union = this.#fold();
|
|
93
|
+
this.#union = union;
|
|
94
|
+
return union.length !== old.length || union.some((range, index) => rangeKey(range) !== rangeKey(old[index]));
|
|
95
|
+
}
|
|
96
|
+
// Fold every policy's union, dropping a range that ranges at covering policies cover.
|
|
97
|
+
#fold() {
|
|
98
|
+
const above = new Above();
|
|
99
|
+
const union = [];
|
|
100
|
+
// Those covering others first.
|
|
101
|
+
for (const rank of [...this.#classes.keys()].sort((a, b) => b - a)) {
|
|
102
|
+
const policy = rankPolicy(rank);
|
|
103
|
+
const spans = this.#classes.get(rank).union();
|
|
104
|
+
for (const range of spans)
|
|
105
|
+
if (!above.covers(range))
|
|
106
|
+
union.push(withPolicy(range, policy));
|
|
107
|
+
above.extend(spans);
|
|
108
|
+
}
|
|
109
|
+
union.sort(compare);
|
|
110
|
+
return union;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* What ranges at covering policies already ask, as a range of one policy is checked against them:
|
|
115
|
+
* the same spans {@link Class} merges ranges into.
|
|
116
|
+
*/
|
|
117
|
+
class Above {
|
|
118
|
+
// Whether a range from the oldest group follows the live edge, covering everything.
|
|
119
|
+
#all = false;
|
|
120
|
+
// The time spans, merged where they overlap or touch, as exclusive spans of starts in order.
|
|
121
|
+
#runs = [];
|
|
122
|
+
// The furthest end of a range from the oldest group.
|
|
123
|
+
#oldest;
|
|
124
|
+
// Live joins by lag and end, under the widest budget.
|
|
125
|
+
#joins = new Map();
|
|
126
|
+
covers(range) {
|
|
127
|
+
if (this.#all)
|
|
128
|
+
return true;
|
|
129
|
+
const shape = shapeOf(range);
|
|
130
|
+
switch (shape.kind) {
|
|
131
|
+
case "empty":
|
|
132
|
+
return true;
|
|
133
|
+
case "open":
|
|
134
|
+
return false;
|
|
135
|
+
case "time": {
|
|
136
|
+
// The last run starting at or before it, which alone can reach it.
|
|
137
|
+
let low = 0;
|
|
138
|
+
let high = this.#runs.length;
|
|
139
|
+
while (low < high) {
|
|
140
|
+
const mid = (low + high) >> 1;
|
|
141
|
+
if (this.#runs[mid].start <= shape.start)
|
|
142
|
+
low = mid + 1;
|
|
143
|
+
else
|
|
144
|
+
high = mid;
|
|
145
|
+
}
|
|
146
|
+
const run = this.#runs[low - 1];
|
|
147
|
+
return run !== undefined && shape.end <= run.end;
|
|
148
|
+
}
|
|
149
|
+
case "join":
|
|
150
|
+
return (this.#joins.get(shape.join) ?? -1) >= shape.budget;
|
|
151
|
+
case "oldest":
|
|
152
|
+
return this.#oldest !== undefined && this.#oldest >= shape.end;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Take in one policy's union.
|
|
156
|
+
extend(ranges) {
|
|
157
|
+
const spans = [...this.#runs];
|
|
158
|
+
for (const range of ranges) {
|
|
159
|
+
const shape = shapeOf(range);
|
|
160
|
+
switch (shape.kind) {
|
|
161
|
+
case "empty":
|
|
162
|
+
break;
|
|
163
|
+
case "open":
|
|
164
|
+
this.#all = true;
|
|
165
|
+
break;
|
|
166
|
+
case "time":
|
|
167
|
+
spans.push({ start: shape.start, end: shape.end });
|
|
168
|
+
break;
|
|
169
|
+
case "join":
|
|
170
|
+
this.#joins.set(shape.join, Math.max(this.#joins.get(shape.join) ?? -1, shape.budget));
|
|
171
|
+
break;
|
|
172
|
+
case "oldest":
|
|
173
|
+
this.#oldest = this.#oldest === undefined || shape.end > this.#oldest ? shape.end : this.#oldest;
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
spans.sort((a, b) => (a.start < b.start ? -1 : a.start > b.start ? 1 : 0));
|
|
178
|
+
const runs = [];
|
|
179
|
+
for (const span of spans) {
|
|
180
|
+
const last = runs.at(-1);
|
|
181
|
+
if (!last || span.start > last.end)
|
|
182
|
+
runs.push({ ...span });
|
|
183
|
+
else if (span.end > last.end)
|
|
184
|
+
last.end = span.end;
|
|
185
|
+
}
|
|
186
|
+
this.#runs = runs;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/** The ranges of one policy, counted so that one change costs O(log n). */
|
|
190
|
+
class Class {
|
|
191
|
+
/** How many non-empty ranges are counted. */
|
|
192
|
+
held = 0;
|
|
193
|
+
// Holders of a range from the oldest group following the live edge, which covers every other.
|
|
194
|
+
#open = 0;
|
|
195
|
+
// Time ranges, as spans of starts.
|
|
196
|
+
#time = new Cover();
|
|
197
|
+
// Ranges from the oldest group with an end, by end: the furthest takes in the rest.
|
|
198
|
+
#oldest = new Counts();
|
|
199
|
+
// Live joins by lag and end, each with the budgets its holders ask under, and the range asking
|
|
200
|
+
// the widest.
|
|
201
|
+
#joins = new Map();
|
|
202
|
+
// The last union read, until a change moves it.
|
|
203
|
+
#union;
|
|
204
|
+
/** Count `range`, returning whether the union changed. */
|
|
205
|
+
add(range) {
|
|
206
|
+
const shape = shapeOf(range);
|
|
207
|
+
let changed = false;
|
|
208
|
+
this.held++;
|
|
209
|
+
switch (shape.kind) {
|
|
210
|
+
case "empty":
|
|
211
|
+
break;
|
|
212
|
+
case "open":
|
|
213
|
+
changed = ++this.#open === 1;
|
|
214
|
+
break;
|
|
215
|
+
case "time": {
|
|
216
|
+
const uncovered = this.#time.least(shape.start, shape.end) <= 0;
|
|
217
|
+
this.#time.add(shape.start, shape.end, 1);
|
|
218
|
+
changed = uncovered && this.#open === 0;
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
case "join": {
|
|
222
|
+
let held = this.#joins.get(shape.join);
|
|
223
|
+
if (!held) {
|
|
224
|
+
held = { budgets: new Counts(), min: shape.min, end: range.end };
|
|
225
|
+
this.#joins.set(shape.join, held);
|
|
226
|
+
}
|
|
227
|
+
const widest = held.budgets.last();
|
|
228
|
+
held.budgets.add(shape.budget);
|
|
229
|
+
changed = (widest === undefined || shape.budget > widest) && this.#open === 0;
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
case "oldest": {
|
|
233
|
+
const furthest = this.#oldest.last();
|
|
234
|
+
this.#oldest.add(shape.end);
|
|
235
|
+
changed = (furthest === undefined || shape.end > furthest) && this.#open === 0;
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return this.#moved(changed);
|
|
240
|
+
}
|
|
241
|
+
/** Uncount `range`, one {@link add} counted, returning whether the union changed. */
|
|
242
|
+
remove(range) {
|
|
243
|
+
const shape = shapeOf(range);
|
|
244
|
+
let changed = false;
|
|
245
|
+
this.held--;
|
|
246
|
+
switch (shape.kind) {
|
|
247
|
+
case "empty":
|
|
248
|
+
break;
|
|
249
|
+
case "open":
|
|
250
|
+
changed = --this.#open === 0;
|
|
251
|
+
break;
|
|
252
|
+
case "time":
|
|
253
|
+
this.#time.add(shape.start, shape.end, -1);
|
|
254
|
+
changed = this.#open === 0 && this.#time.least(shape.start, shape.end) <= 0;
|
|
255
|
+
break;
|
|
256
|
+
case "join": {
|
|
257
|
+
const held = this.#joins.get(shape.join);
|
|
258
|
+
if (!held)
|
|
259
|
+
break;
|
|
260
|
+
const widest = held.budgets.last();
|
|
261
|
+
held.budgets.remove(shape.budget);
|
|
262
|
+
const now = held.budgets.last();
|
|
263
|
+
if (now === undefined)
|
|
264
|
+
this.#joins.delete(shape.join);
|
|
265
|
+
changed = now !== widest && this.#open === 0;
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
case "oldest": {
|
|
269
|
+
const furthest = this.#oldest.last();
|
|
270
|
+
this.#oldest.remove(shape.end);
|
|
271
|
+
changed = this.#oldest.last() !== furthest && this.#open === 0;
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return this.#moved(changed);
|
|
276
|
+
}
|
|
277
|
+
// Drop the cached union when `changed`, passing it through.
|
|
278
|
+
#moved(changed) {
|
|
279
|
+
if (changed)
|
|
280
|
+
this.#union = undefined;
|
|
281
|
+
return changed;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* The union at the default policy in a canonical order, costing its own length rather than the
|
|
285
|
+
* audience's. Read only.
|
|
286
|
+
*/
|
|
287
|
+
union() {
|
|
288
|
+
this.#union ??= this.#fold();
|
|
289
|
+
return this.#union;
|
|
290
|
+
}
|
|
291
|
+
#fold() {
|
|
292
|
+
if (this.#open > 0)
|
|
293
|
+
return [{}];
|
|
294
|
+
const union = this.#time
|
|
295
|
+
.runs()
|
|
296
|
+
.map((run) => (run.end === UNBOUNDED ? { start: run.start } : { start: run.start, end: run.end - 1n }));
|
|
297
|
+
const furthest = this.#oldest.last();
|
|
298
|
+
if (furthest !== undefined)
|
|
299
|
+
union.push({ end: furthest });
|
|
300
|
+
for (const { budgets, min, end } of this.#joins.values()) {
|
|
301
|
+
const widest = budgets.last();
|
|
302
|
+
if (widest === undefined)
|
|
303
|
+
continue;
|
|
304
|
+
const range = { start: { live: { min, max: maxOf(widest) } } };
|
|
305
|
+
if (end !== undefined)
|
|
306
|
+
range.end = end;
|
|
307
|
+
union.push(range);
|
|
308
|
+
}
|
|
309
|
+
return union.sort(compare);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
//# sourceMappingURL=ranges.js.map
|
package/ranges.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ranges.js","sourceRoot":"","sources":["../src/ranges.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EACN,OAAO,EACP,OAAO,EACP,MAAM,EACN,KAAK,EACL,QAAQ,EACR,UAAU,EACV,WAAW,EACX,QAAQ,EACR,SAAS,EACT,UAAU,EACV,UAAU,GACV,MAAM,aAAa,CAAC;AAcrB,SAAS,OAAO,CAAC,KAAY;IAC5B,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC7C,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;IACtB,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC;IACvG,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3B,IAAI,IAAI,KAAK,SAAS,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;QACxD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,M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,EAAE,EAAE,CAAC;YAC1D,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;YAC9B,IAAI,MAAM,KAAK,SAAS;gBAAE,SAAS;YACnC,MAAM,KAAK,GAAU,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC;YACtE,IAAI,GAAG,KAAK,SAAS;gBAAE,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC;YACvC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnB,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;CACD","sourcesContent":["/**\n * The union of every subscriber's ranges, kept current per change rather than refolded. Mirrors\n * the Rust `demand::Ranges`.\n *\n * Time ranges count as runs of group starts in a {@link Cover}, so a change touches two boundaries\n * and asks one range-minimum question, whatever else the audience holds. A start between groups\n * stands for the group containing it, which a range starting at or before it covers too, so spans\n * merge as they do over starts. Ranges with no time start can't be placed on that line and are\n * counted by value instead: live joins by lag and end under the largest max among them, since where\n * a join lands doesn't depend on it, and ranges from the oldest group under the furthest end, which\n * takes in the rest.\n *\n * All that holds within one policy, since folding a range into one at another policy would lose its\n * priority or order. Across policies a range is dropped only once ranges at policies that\n * {@link covers | cover} its own cover its span. With one policy there is nothing to fold, so a\n * change costs O(log n) as above. With several, the fold is redone only when one policy's union\n * moves, at the cost of the union's own length.\n *\n * @module\n */\n\nimport type { Duration } from \"@moq/clock\";\nimport { Counts, Cover } from \"./cover.ts\";\nimport type { Range } from \"./track.ts\";\nimport { UNBOUNDED } from \"./util/key.ts\";\nimport {\n\tcompare,\n\tisEmpty,\n\tjoinOf,\n\tmaxOf,\n\tpolicyOf,\n\tpolicyRank,\n\trangeBudget,\n\trangeKey,\n\trangeTime,\n\trankPolicy,\n\twithPolicy,\n} from \"./window.ts\";\n\n/** How {@link Ranges} counts one range. */\ntype Shape =\n\t| { kind: \"empty\" }\n\t/** From the oldest group, following the live edge. */\n\t| { kind: \"open\" }\n\t/** A time range, as the exclusive span of starts it covers, {@link UNBOUNDED} when open. */\n\t| { kind: \"time\"; start: bigint; end: bigint }\n\t/** A live join, by lag and end, and its budget. */\n\t| { kind: \"join\"; join: string; min: Duration | null; budget: number }\n\t/** A range from the oldest group, by its end. */\n\t| { kind: \"oldest\"; end: bigint };\n\nfunction shapeOf(range: Range): Shape {\n\tif (isEmpty(range)) return { kind: \"empty\" };\n\tconst start = rangeTime(range);\n\tconst end = range.end;\n\tif (start !== undefined) return { kind: \"time\", start, end: end === undefined ? UNBOUNDED : end + 1n };\n\tconst join = joinOf(range);\n\tif (join !== undefined && typeof range.start === \"object\")\n\t\treturn { kind: \"join\", join, min: range.start.live.min, budget: rangeBudget(range) };\n\tif (end === undefined) return { kind: \"open\" };\n\treturn { kind: \"oldest\", end };\n}\n\n/**\n * Every subscriber's ranges, counted so that one change costs O(log n) unless several policies are\n * asked and it moves the union of its policy's ranges, folded as the window module's `union` folds\n * them.\n */\nexport class Ranges {\n\t// The ranges of each policy, by its rank.\n\t#classes = new Map<number, Class>();\n\t// The union, until a change moves it. Kept while several policies are asked, to tell whether a\n\t// change moved it.\n\t#union: Range[] | undefined = [];\n\n\t/** Count `range`, returning whether the union changed. */\n\tadd(range: Range): boolean {\n\t\tif (isEmpty(range)) return false;\n\t\tconst rank = policyRank(policyOf(range));\n\t\tconst several = this.#classes.size > 1 || (this.#classes.size === 1 && !this.#classes.has(rank));\n\t\tif (several) this.union();\n\t\tlet held = this.#classes.get(rank);\n\t\tif (!held) {\n\t\t\theld = new Class();\n\t\t\tthis.#classes.set(rank, held);\n\t\t}\n\t\treturn held.add(range) && this.#moved(several);\n\t}\n\n\t/** Uncount `range`, one {@link add} counted, returning whether the union changed. */\n\tremove(range: Range): boolean {\n\t\tif (isEmpty(range)) return false;\n\t\tconst several = this.#classes.size > 1;\n\t\tif (several) this.union();\n\t\tconst rank = policyRank(policyOf(range));\n\t\tconst held = this.#classes.get(rank);\n\t\tif (!held) throw new Error(\"a counted policy\");\n\t\tconst moved = held.remove(range);\n\t\tif (held.held === 0) this.#classes.delete(rank);\n\t\treturn moved && this.#moved(several);\n\t}\n\n\t/** The union in a canonical order, costing its own length rather than the audience's. Read only. */\n\tunion(): readonly Range[] {\n\t\tthis.#union ??= this.#fold();\n\t\treturn this.#union;\n\t}\n\n\t// Whether a change that moved one policy's union moved the union: always with one policy asked,\n\t// and otherwise only when the fold comes out different.\n\t#moved(several: boolean): boolean {\n\t\tconst old = this.#union;\n\t\tthis.#union = undefined;\n\t\tif (!several || old === undefined) return true;\n\t\tconst union = this.#fold();\n\t\tthis.#union = union;\n\t\treturn union.length !== old.length || union.some((range, index) => rangeKey(range) !== rangeKey(old[index]));\n\t}\n\n\t// Fold every policy's union, dropping a range that ranges at covering policies cover.\n\t#fold(): Range[] {\n\t\tconst above = new Above();\n\t\tconst union: Range[] = [];\n\t\t// Those covering others first.\n\t\tfor (const rank of [...this.#classes.keys()].sort((a, b) => b - a)) {\n\t\t\tconst policy = rankPolicy(rank);\n\t\t\tconst spans = (this.#classes.get(rank) as Class).union();\n\t\t\tfor (const range of spans) if (!above.covers(range)) union.push(withPolicy(range, policy));\n\t\t\tabove.extend(spans);\n\t\t}\n\t\tunion.sort(compare);\n\t\treturn union;\n\t}\n}\n\n/**\n * What ranges at covering policies already ask, as a range of one policy is checked against them:\n * the same spans {@link Class} merges ranges into.\n */\nclass Above {\n\t// Whether a range from the oldest group follows the live edge, covering everything.\n\t#all = false;\n\t// The time spans, merged where they overlap or touch, as exclusive spans of starts in order.\n\t#runs: { start: bigint; end: bigint }[] = [];\n\t// The furthest end of a range from the oldest group.\n\t#oldest: bigint | undefined;\n\t// Live joins by lag and end, under the widest budget.\n\t#joins = new Map<string, number>();\n\n\tcovers(range: Range): boolean {\n\t\tif (this.#all) return true;\n\t\tconst shape = shapeOf(range);\n\t\tswitch (shape.kind) {\n\t\t\tcase \"empty\":\n\t\t\t\treturn true;\n\t\t\tcase \"open\":\n\t\t\t\treturn false;\n\t\t\tcase \"time\": {\n\t\t\t\t// The last run starting at or before it, which alone can reach it.\n\t\t\t\tlet low = 0;\n\t\t\t\tlet high = this.#runs.length;\n\t\t\t\twhile (low < high) {\n\t\t\t\t\tconst mid = (low + high) >> 1;\n\t\t\t\t\tif (this.#runs[mid].start <= shape.start) low = mid + 1;\n\t\t\t\t\telse high = mid;\n\t\t\t\t}\n\t\t\t\tconst run = this.#runs[low - 1];\n\t\t\t\treturn run !== undefined && shape.end <= run.end;\n\t\t\t}\n\t\t\tcase \"join\":\n\t\t\t\treturn (this.#joins.get(shape.join) ?? -1) >= shape.budget;\n\t\t\tcase \"oldest\":\n\t\t\t\treturn this.#oldest !== undefined && this.#oldest >= shape.end;\n\t\t}\n\t}\n\n\t// Take in one policy's union.\n\textend(ranges: readonly Range[]): void {\n\t\tconst spans = [...this.#runs];\n\t\tfor (const range of ranges) {\n\t\t\tconst shape = shapeOf(range);\n\t\t\tswitch (shape.kind) {\n\t\t\t\tcase \"empty\":\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"open\":\n\t\t\t\t\tthis.#all = true;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"time\":\n\t\t\t\t\tspans.push({ start: shape.start, end: shape.end });\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"join\":\n\t\t\t\t\tthis.#joins.set(shape.join, Math.max(this.#joins.get(shape.join) ?? -1, shape.budget));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"oldest\":\n\t\t\t\t\tthis.#oldest = this.#oldest === undefined || shape.end > this.#oldest ? shape.end : this.#oldest;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tspans.sort((a, b) => (a.start < b.start ? -1 : a.start > b.start ? 1 : 0));\n\t\tconst runs: { start: bigint; end: bigint }[] = [];\n\t\tfor (const span of spans) {\n\t\t\tconst last = runs.at(-1);\n\t\t\tif (!last || span.start > last.end) runs.push({ ...span });\n\t\t\telse if (span.end > last.end) last.end = span.end;\n\t\t}\n\t\tthis.#runs = runs;\n\t}\n}\n\n/** The ranges of one policy, counted so that one change costs O(log n). */\nclass Class {\n\t/** How many non-empty ranges are counted. */\n\theld = 0;\n\t// Holders of a range from the oldest group following the live edge, which covers every other.\n\t#open = 0;\n\t// Time ranges, as spans of starts.\n\t#time = new Cover();\n\t// Ranges from the oldest group with an end, by end: the furthest takes in the rest.\n\t#oldest = new Counts<bigint>();\n\t// Live joins by lag and end, each with the budgets its holders ask under, and the range asking\n\t// the widest.\n\t#joins = new Map<string, { budgets: Counts<number>; min: Duration | null; end: bigint | undefined }>();\n\t// The last union read, until a change moves it.\n\t#union?: Range[];\n\n\t/** Count `range`, returning whether the union changed. */\n\tadd(range: Range): boolean {\n\t\tconst shape = shapeOf(range);\n\t\tlet changed = false;\n\t\tthis.held++;\n\t\tswitch (shape.kind) {\n\t\t\tcase \"empty\":\n\t\t\t\tbreak;\n\t\t\tcase \"open\":\n\t\t\t\tchanged = ++this.#open === 1;\n\t\t\t\tbreak;\n\t\t\tcase \"time\": {\n\t\t\t\tconst uncovered = this.#time.least(shape.start, shape.end) <= 0;\n\t\t\t\tthis.#time.add(shape.start, shape.end, 1);\n\t\t\t\tchanged = uncovered && this.#open === 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"join\": {\n\t\t\t\tlet held = this.#joins.get(shape.join);\n\t\t\t\tif (!held) {\n\t\t\t\t\theld = { budgets: new Counts<number>(), min: shape.min, end: range.end };\n\t\t\t\t\tthis.#joins.set(shape.join, held);\n\t\t\t\t}\n\t\t\t\tconst widest = held.budgets.last();\n\t\t\t\theld.budgets.add(shape.budget);\n\t\t\t\tchanged = (widest === undefined || shape.budget > widest) && this.#open === 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"oldest\": {\n\t\t\t\tconst furthest = this.#oldest.last();\n\t\t\t\tthis.#oldest.add(shape.end);\n\t\t\t\tchanged = (furthest === undefined || shape.end > furthest) && this.#open === 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn this.#moved(changed);\n\t}\n\n\t/** Uncount `range`, one {@link add} counted, returning whether the union changed. */\n\tremove(range: Range): boolean {\n\t\tconst shape = shapeOf(range);\n\t\tlet changed = false;\n\t\tthis.held--;\n\t\tswitch (shape.kind) {\n\t\t\tcase \"empty\":\n\t\t\t\tbreak;\n\t\t\tcase \"open\":\n\t\t\t\tchanged = --this.#open === 0;\n\t\t\t\tbreak;\n\t\t\tcase \"time\":\n\t\t\t\tthis.#time.add(shape.start, shape.end, -1);\n\t\t\t\tchanged = this.#open === 0 && this.#time.least(shape.start, shape.end) <= 0;\n\t\t\t\tbreak;\n\t\t\tcase \"join\": {\n\t\t\t\tconst held = this.#joins.get(shape.join);\n\t\t\t\tif (!held) break;\n\t\t\t\tconst widest = held.budgets.last();\n\t\t\t\theld.budgets.remove(shape.budget);\n\t\t\t\tconst now = held.budgets.last();\n\t\t\t\tif (now === undefined) this.#joins.delete(shape.join);\n\t\t\t\tchanged = now !== widest && this.#open === 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"oldest\": {\n\t\t\t\tconst furthest = this.#oldest.last();\n\t\t\t\tthis.#oldest.remove(shape.end);\n\t\t\t\tchanged = this.#oldest.last() !== furthest && this.#open === 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn this.#moved(changed);\n\t}\n\n\t// Drop the cached union when `changed`, passing it through.\n\t#moved(changed: boolean): boolean {\n\t\tif (changed) this.#union = undefined;\n\t\treturn changed;\n\t}\n\n\t/**\n\t * The union at the default policy in a canonical order, costing its own length rather than the\n\t * audience's. Read only.\n\t */\n\tunion(): readonly Range[] {\n\t\tthis.#union ??= this.#fold();\n\t\treturn this.#union;\n\t}\n\n\t#fold(): Range[] {\n\t\tif (this.#open > 0) return [{}];\n\t\tconst union: Range[] = this.#time\n\t\t\t.runs()\n\t\t\t.map((run) => (run.end === UNBOUNDED ? { start: run.start } : { start: run.start, end: run.end - 1n }));\n\t\tconst furthest = this.#oldest.last();\n\t\tif (furthest !== undefined) union.push({ end: furthest });\n\t\tfor (const { budgets, min, end } of this.#joins.values()) {\n\t\t\tconst widest = budgets.last();\n\t\t\tif (widest === undefined) continue;\n\t\t\tconst range: Range = { start: { live: { min, max: maxOf(widest) } } };\n\t\t\tif (end !== undefined) range.end = end;\n\t\t\tunion.push(range);\n\t\t}\n\t\treturn union.sort(compare);\n\t}\n}\n"]}
|
package/rescale.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Timescale, Timestamp } from "./time.ts";
|
|
2
|
+
/**
|
|
3
|
+
* `timestamp` at `info`'s timescale, rounded down, as Rust's `Timestamp::convert` does.
|
|
4
|
+
*
|
|
5
|
+
* A track is all timed or all scale-less, so a frame must match it: an unscaled timestamp on a
|
|
6
|
+
* timed track, a scaled one on a scale-less track, or one the scale can't hold throws
|
|
7
|
+
* {@link TimestampMismatch}. A scale-less track's timestamp passes through unchanged. A writer
|
|
8
|
+
* that changes state before its frame reaches the track, such as signing or encrypting it,
|
|
9
|
+
* rescales first so a refused timestamp changes nothing. Mirrors Rust's track and datagram
|
|
10
|
+
* `Info::rescale`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function rescale(info: {
|
|
13
|
+
timescale?: Timescale | null;
|
|
14
|
+
}, timestamp: Timestamp): Timestamp;
|
|
15
|
+
/**
|
|
16
|
+
* {@link rescale} for a frame of group `key` (or a datagram keyed `key`): a scale-less
|
|
17
|
+
* track's frame carries its group's key, so any other throws {@link TimestampMismatch}. A writer
|
|
18
|
+
* that changes state before its frame reaches the group checks this first, as with
|
|
19
|
+
* {@link rescale}. Mirrors Rust's `Info::rescale_in`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function rescaleIn(info: {
|
|
22
|
+
timescale?: Timescale | null;
|
|
23
|
+
}, timestamp: Timestamp, key: bigint): Timestamp;
|
|
24
|
+
//# sourceMappingURL=rescale.d.ts.map
|
package/rescale.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rescale.d.ts","sourceRoot":"","sources":["../src/rescale.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE/D;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE;IAAE,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,CAAA;CAAE,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,CAS/F;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE;IAAE,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,CAAA;CAAE,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CAI9G"}
|
package/rescale.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Shared by stream and datagram tracks, without a cycle through their model modules.
|
|
2
|
+
import { TimestampMismatch } from "./error.js";
|
|
3
|
+
import { floorAt, Timestamp } from "./time.js";
|
|
4
|
+
/**
|
|
5
|
+
* `timestamp` at `info`'s timescale, rounded down, as Rust's `Timestamp::convert` does.
|
|
6
|
+
*
|
|
7
|
+
* A track is all timed or all scale-less, so a frame must match it: an unscaled timestamp on a
|
|
8
|
+
* timed track, a scaled one on a scale-less track, or one the scale can't hold throws
|
|
9
|
+
* {@link TimestampMismatch}. A scale-less track's timestamp passes through unchanged. A writer
|
|
10
|
+
* that changes state before its frame reaches the track, such as signing or encrypting it,
|
|
11
|
+
* rescales first so a refused timestamp changes nothing. Mirrors Rust's track and datagram
|
|
12
|
+
* `Info::rescale`.
|
|
13
|
+
*/
|
|
14
|
+
export function rescale(info, timestamp) {
|
|
15
|
+
const timescale = info.timescale ?? undefined;
|
|
16
|
+
if ((timescale !== undefined) !== (timestamp.scale !== undefined))
|
|
17
|
+
throw new TimestampMismatch();
|
|
18
|
+
if (timescale === undefined)
|
|
19
|
+
return timestamp;
|
|
20
|
+
try {
|
|
21
|
+
return new Timestamp(floorAt(timestamp, timescale), timescale);
|
|
22
|
+
}
|
|
23
|
+
catch (cause) {
|
|
24
|
+
throw new TimestampMismatch({ cause });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* {@link rescale} for a frame of group `key` (or a datagram keyed `key`): a scale-less
|
|
29
|
+
* track's frame carries its group's key, so any other throws {@link TimestampMismatch}. A writer
|
|
30
|
+
* that changes state before its frame reaches the group checks this first, as with
|
|
31
|
+
* {@link rescale}. Mirrors Rust's `Info::rescale_in`.
|
|
32
|
+
*/
|
|
33
|
+
export function rescaleIn(info, timestamp, key) {
|
|
34
|
+
const rescaled = rescale(info, timestamp);
|
|
35
|
+
if (rescaled.scale === undefined && BigInt(rescaled.value) !== key)
|
|
36
|
+
throw new TimestampMismatch();
|
|
37
|
+
return rescaled;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=rescale.js.map
|
package/rescale.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rescale.js","sourceRoot":"","sources":["../src/rescale.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAkB,SAAS,EAAE,MAAM,WAAW,CAAC;AAE/D;;;;;;;;;GASG;AACH,MAAM,UAAU,OAAO,CAAC,IAAsC,EAAE,SAAoB;IACnF,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC;IAC9C,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,KAAK,SAAS,CAAC;QAAE,MAAM,IAAI,iBAAiB,EAAE,CAAC;IACjG,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC9C,IAAI,CAAC;QACJ,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE,SAAS,CAAC,CAAC;IAChE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,iBAAiB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACxC,CAAC;AACF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,IAAsC,EAAE,SAAoB,EAAE,GAAW;IAClG,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC1C,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,GAAG;QAAE,MAAM,IAAI,iBAAiB,EAAE,CAAC;IAClG,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["// Shared by stream and datagram tracks, without a cycle through their model modules.\nimport { TimestampMismatch } from \"./error.ts\";\nimport { floorAt, type Timescale, Timestamp } from \"./time.ts\";\n\n/**\n * `timestamp` at `info`'s timescale, rounded down, as Rust's `Timestamp::convert` does.\n *\n * A track is all timed or all scale-less, so a frame must match it: an unscaled timestamp on a\n * timed track, a scaled one on a scale-less track, or one the scale can't hold throws\n * {@link TimestampMismatch}. A scale-less track's timestamp passes through unchanged. A writer\n * that changes state before its frame reaches the track, such as signing or encrypting it,\n * rescales first so a refused timestamp changes nothing. Mirrors Rust's track and datagram\n * `Info::rescale`.\n */\nexport function rescale(info: { timescale?: Timescale | null }, timestamp: Timestamp): Timestamp {\n\tconst timescale = info.timescale ?? undefined;\n\tif ((timescale !== undefined) !== (timestamp.scale !== undefined)) throw new TimestampMismatch();\n\tif (timescale === undefined) return timestamp;\n\ttry {\n\t\treturn new Timestamp(floorAt(timestamp, timescale), timescale);\n\t} catch (cause) {\n\t\tthrow new TimestampMismatch({ cause });\n\t}\n}\n\n/**\n * {@link rescale} for a frame of group `key` (or a datagram keyed `key`): a scale-less\n * track's frame carries its group's key, so any other throws {@link TimestampMismatch}. A writer\n * that changes state before its frame reaches the group checks this first, as with\n * {@link rescale}. Mirrors Rust's `Info::rescale_in`.\n */\nexport function rescaleIn(info: { timescale?: Timescale | null }, timestamp: Timestamp, key: bigint): Timestamp {\n\tconst rescaled = rescale(info, timestamp);\n\tif (rescaled.scale === undefined && BigInt(rescaled.value) !== key) throw new TimestampMismatch();\n\treturn rescaled;\n}\n"]}
|
package/resume.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as broadcast from "./broadcast.ts";
|
|
2
|
+
import type { Consumer as GroupConsumer } from "./group.ts";
|
|
3
|
+
import type { Timescale } from "./time.ts";
|
|
4
|
+
import * as track from "./track.ts";
|
|
5
|
+
/**
|
|
6
|
+
* One broadcast served through one route at a time; see the module docs.
|
|
7
|
+
*
|
|
8
|
+
* Its {@link consumer} is the broadcast handed out: every track read through it follows the
|
|
9
|
+
* front's route. The origin calls {@link serve} as routes of the same identity take over, and
|
|
10
|
+
* {@link conclude} once none will: readers then follow the last copy to its end.
|
|
11
|
+
*/
|
|
12
|
+
export declare class Front {
|
|
13
|
+
#private;
|
|
14
|
+
/** The logical broadcast; closing its last handle concludes the front. */
|
|
15
|
+
readonly consumer: broadcast.Consumer;
|
|
16
|
+
/**
|
|
17
|
+
* `superseded` says whether another identity than the one the front serves wins its path,
|
|
18
|
+
* judged over every route the origin holds: a claim's refusal is then final.
|
|
19
|
+
*/
|
|
20
|
+
constructor(superseded?: () => boolean);
|
|
21
|
+
/**
|
|
22
|
+
* Serve every track from `from` from now on, once each copy proves compatible. `claim` marks a
|
|
23
|
+
* lite-07 peer's claim, whose refusal is final once its identity loses the path.
|
|
24
|
+
*/
|
|
25
|
+
serve(from: broadcast.Consumer, local?: boolean, claim?: boolean): void;
|
|
26
|
+
/**
|
|
27
|
+
* The table moved for the path while the same route still wins, with no takeover pending: a
|
|
28
|
+
* read stranded on a lost route asks the serving source again, the evidence it waited for.
|
|
29
|
+
* Unless the serving source is a claim whose identity lost the path: a read it refused before
|
|
30
|
+
* any copy delivered ends with that refusal, as nothing else of its identity answers for it,
|
|
31
|
+
* while one that delivered is asked once more and ends on that answer. Mirrors the Rust front's
|
|
32
|
+
* `unstrand` and `refuse_stranded`.
|
|
33
|
+
*/
|
|
34
|
+
moved(): void;
|
|
35
|
+
/** Between routes: readers keep what they have and wait for the next one. */
|
|
36
|
+
park(): void;
|
|
37
|
+
/** No route will replace the serving one: readers follow it to its end. Idempotent. */
|
|
38
|
+
conclude(): void;
|
|
39
|
+
/** Subscribe the logical track `name`, or its metadata copy when `meta`. */
|
|
40
|
+
subscribe(name: string, options?: track.Subscription, meta?: boolean): track.Subscriber;
|
|
41
|
+
/** Whether the serving source's datagram metadata comes from an application. */
|
|
42
|
+
get localDatagrams(): boolean;
|
|
43
|
+
/** Whether the serving source keeps a name's stream track and datagram track apart. */
|
|
44
|
+
get distinguishesKinds(): boolean;
|
|
45
|
+
/** Whether the serving source already publishes a stream track of this name. */
|
|
46
|
+
publishesTrack(name: string): boolean;
|
|
47
|
+
/** Join the serving source's live datagram track; it holds no cached route copies. */
|
|
48
|
+
datagrams(name: string): import("./datagram.ts").Consumer;
|
|
49
|
+
/** Join an already present datagram track without opening a request. */
|
|
50
|
+
liveDatagrams(name: string): import("./datagram.ts").Consumer | undefined;
|
|
51
|
+
resolveTrackInfo(name: string, hold?: AbortSignal): Promise<track.Info>;
|
|
52
|
+
largest(name: string, meta?: boolean, timescale?: Timescale): track.Position | undefined;
|
|
53
|
+
fetchGroup(name: string, key: bigint, options?: track.FetchGroupOptions, meta?: boolean): Promise<GroupConsumer>;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=resume.d.ts.map
|
package/resume.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resume.d.ts","sourceRoot":"","sources":["../src/resume.ts"],"names":[],"mappings":"AAkDA,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAI5C,OAA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