@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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Once } from "@moq/signals";
|
|
2
|
+
/** Tracks session-local announcement loops until their withdrawals are acknowledged. @internal */
|
|
3
|
+
export class Withdrawal {
|
|
4
|
+
closing = new Once();
|
|
5
|
+
#tasks = new Set();
|
|
6
|
+
track(task) {
|
|
7
|
+
const tracked = task.finally(() => this.#tasks.delete(tracked));
|
|
8
|
+
this.#tasks.add(tracked);
|
|
9
|
+
return tracked;
|
|
10
|
+
}
|
|
11
|
+
async close() {
|
|
12
|
+
if (!this.closing.peek())
|
|
13
|
+
this.closing.set(true);
|
|
14
|
+
// Settle every loop, not just the first to fail: one rejected withdrawal must not
|
|
15
|
+
// strand its siblings mid-write, which is the same lost-DONE this class prevents.
|
|
16
|
+
// The first failure still rejects, so the caller learns the drain was incomplete.
|
|
17
|
+
const settled = await Promise.allSettled(this.#tasks);
|
|
18
|
+
const failed = settled.find((result) => result.status === "rejected");
|
|
19
|
+
if (failed?.status === "rejected")
|
|
20
|
+
throw failed.reason;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=withdrawal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withdrawal.js","sourceRoot":"","sources":["../../src/connection/withdrawal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,kGAAkG;AAClG,MAAM,OAAO,UAAU;IACb,OAAO,GAAG,IAAI,IAAI,EAAQ,CAAC;IACpC,MAAM,GAAG,IAAI,GAAG,EAAiB,CAAC;IAElC,KAAK,CAAC,IAAmB;QACxB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QAChE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,OAAO,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,KAAK;QACV,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;YAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACjD,kFAAkF;QAClF,kFAAkF;QAClF,kFAAkF;QAClF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC;QACtE,IAAI,MAAM,EAAE,MAAM,KAAK,UAAU;YAAE,MAAM,MAAM,CAAC,MAAM,CAAC;IACxD,CAAC;CACD","sourcesContent":["import { Once } from \"@moq/signals\";\n\n/** Tracks session-local announcement loops until their withdrawals are acknowledged. @internal */\nexport class Withdrawal {\n\treadonly closing = new Once<true>();\n\t#tasks = new Set<Promise<void>>();\n\n\ttrack(task: Promise<void>): Promise<void> {\n\t\tconst tracked = task.finally(() => this.#tasks.delete(tracked));\n\t\tthis.#tasks.add(tracked);\n\t\treturn tracked;\n\t}\n\n\tasync close(): Promise<void> {\n\t\tif (!this.closing.peek()) this.closing.set(true);\n\t\t// Settle every loop, not just the first to fail: one rejected withdrawal must not\n\t\t// strand its siblings mid-write, which is the same lost-DONE this class prevents.\n\t\t// The first failure still rejects, so the caller learns the drain was incomplete.\n\t\tconst settled = await Promise.allSettled(this.#tasks);\n\t\tconst failed = settled.find((result) => result.status === \"rejected\");\n\t\tif (failed?.status === \"rejected\") throw failed.reason;\n\t}\n}\n"]}
|
package/consume.js
CHANGED
|
@@ -1,60 +1,226 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { StreamCode, StreamError } from "./error.js";
|
|
2
|
+
import * as Identity from "./identity.js";
|
|
3
|
+
import { arrival, coveringPrefixes, mostSpecific } from "./internal.js";
|
|
4
|
+
import { sameIdentity } from "./wire.js";
|
|
5
|
+
// Unroutable, as in Rust: the identity going away is an end, not a failure.
|
|
6
|
+
function retired() {
|
|
7
|
+
return new StreamError(StreamCode.Unroutable, { message: "broadcast identity retired" });
|
|
8
|
+
}
|
|
9
|
+
class Validity {
|
|
10
|
+
#current = new AbortController();
|
|
11
|
+
#answering = new AbortController();
|
|
12
|
+
get signal() {
|
|
13
|
+
return this.#current.signal;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Aborted once another identity takes the path, which may answer a request still unanswered.
|
|
17
|
+
* A withdrawal alone leaves it, and the identity winning again keeps it.
|
|
18
|
+
*/
|
|
19
|
+
get answering() {
|
|
20
|
+
return this.#answering.signal;
|
|
21
|
+
}
|
|
22
|
+
update(allowed, replaced = false) {
|
|
23
|
+
if (allowed) {
|
|
24
|
+
if (this.#current.signal.aborted)
|
|
25
|
+
this.#current = new AbortController();
|
|
26
|
+
if (this.#answering.signal.aborted)
|
|
27
|
+
this.#answering = new AbortController();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (!this.#current.signal.aborted)
|
|
31
|
+
this.#current.abort(retired());
|
|
32
|
+
if (replaced && !this.#answering.signal.aborted)
|
|
33
|
+
this.#answering.abort(retired());
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
class Blind {
|
|
37
|
+
ref = {};
|
|
38
|
+
route = {};
|
|
39
|
+
validity = new Validity();
|
|
40
|
+
}
|
|
41
|
+
/** Consumed broadcasts shared only within the selected serving identity. @internal */
|
|
15
42
|
export class BroadcastCache {
|
|
16
|
-
// The base handle per path; callers get reference-counted clones of it.
|
|
17
43
|
#cache = new Map();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
44
|
+
#announced = new Map();
|
|
45
|
+
#blind = new Map();
|
|
46
|
+
#blindPrefixes = new Map();
|
|
47
|
+
#paths = new Map();
|
|
48
|
+
// The prefixes a batch changed, rechecked once it ends.
|
|
49
|
+
#batched;
|
|
50
|
+
/**
|
|
51
|
+
* Apply several changes as one: each path they touch is rechecked once, after the last, so
|
|
52
|
+
* a selection that only passes through another route on the way never retires a request.
|
|
53
|
+
*/
|
|
54
|
+
batch(apply) {
|
|
55
|
+
if (this.#batched) {
|
|
56
|
+
apply();
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const batched = new Set();
|
|
60
|
+
this.#batched = batched;
|
|
61
|
+
try {
|
|
62
|
+
apply();
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
this.#batched = undefined;
|
|
66
|
+
}
|
|
67
|
+
const paths = new Set();
|
|
68
|
+
for (const prefix of batched)
|
|
69
|
+
for (const path of this.#paths.get(prefix) ?? [])
|
|
70
|
+
paths.add(path);
|
|
71
|
+
for (const path of paths)
|
|
72
|
+
this.#check(path);
|
|
73
|
+
}
|
|
74
|
+
/** Record this interest's live advertisement, preserving ref across route updates. */
|
|
75
|
+
announce(path, owner, route, restart = false) {
|
|
76
|
+
// Only unannounced consumers covered by this advertisement lose their blind ref.
|
|
77
|
+
for (const covered of this.#blindPrefixes.get(path) ?? [])
|
|
78
|
+
this.#forgetBlind(covered);
|
|
79
|
+
let entries = this.#announced.get(path);
|
|
80
|
+
if (!entries) {
|
|
81
|
+
entries = new Map();
|
|
82
|
+
this.#announced.set(path, entries);
|
|
83
|
+
}
|
|
84
|
+
const previous = entries.get(owner);
|
|
85
|
+
const ref = (!restart && previous?.ref) || {};
|
|
86
|
+
arrival(ref);
|
|
87
|
+
// A new or restarted stream ranks as the newest, which wins a full tie at its own path; see mostSpecific.
|
|
88
|
+
if (!previous || restart)
|
|
89
|
+
entries.delete(owner);
|
|
90
|
+
entries.set(owner, { ref, route });
|
|
91
|
+
this.#update(path);
|
|
92
|
+
}
|
|
93
|
+
/** Withdraw this interest's advertisement without disturbing another interest's routes. */
|
|
94
|
+
withdraw(path, owner) {
|
|
95
|
+
const entries = this.#announced.get(path);
|
|
96
|
+
entries?.delete(owner);
|
|
97
|
+
if (entries?.size === 0)
|
|
98
|
+
this.#announced.delete(path);
|
|
99
|
+
this.#update(path);
|
|
100
|
+
}
|
|
101
|
+
/** Resolve the same most-specific-prefix and route preference as the origin. */
|
|
102
|
+
identity(path) {
|
|
103
|
+
const best = mostSpecific(path, (prefix) => this.#eligible(prefix).reverse(), (entry) => entry);
|
|
104
|
+
if (best) {
|
|
105
|
+
const cached = this.#live(path, best);
|
|
106
|
+
// A minted identity names the announcement, not the publisher's stream, so a
|
|
107
|
+
// request for it can only name the path: it holds while this route is selected.
|
|
108
|
+
const named = best.route.identity !== undefined && !Identity.isMinted(best.route.identity);
|
|
109
|
+
return {
|
|
110
|
+
...best,
|
|
111
|
+
validity: !named ? (cached?.selection.validity ?? new Validity()) : undefined,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return this.#blind.get(path) ?? new Blind();
|
|
24
115
|
}
|
|
25
116
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
117
|
+
* The best route of `identity` alone at `path`, whichever identity wins the path, as a
|
|
118
|
+
* request pinned to it resolves. With no route of it, the identity alone, which the peer
|
|
119
|
+
* resolves or refuses.
|
|
28
120
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
121
|
+
pinned(path, identity) {
|
|
122
|
+
const best = mostSpecific(path, (prefix) => this.#eligible(prefix)
|
|
123
|
+
.filter((entry) => entry.route.identity === identity)
|
|
124
|
+
.reverse(), (entry) => entry);
|
|
125
|
+
return best ?? { ref: {}, route: { identity } };
|
|
126
|
+
}
|
|
127
|
+
/** Clone the live cached consumer only when it serves the selected identity and epoch. */
|
|
128
|
+
get(path, identity) {
|
|
129
|
+
return this.#live(path, identity)?.consumer.clone();
|
|
130
|
+
}
|
|
131
|
+
// The live cached entry consumed through `served`'s identity and epoch: an older epoch never
|
|
132
|
+
// answers a fresh request, since the newer one may refuse it.
|
|
133
|
+
#live(path, served) {
|
|
134
|
+
const cached = this.#cache.get(path)?.get(served.route.identity ?? served.ref);
|
|
135
|
+
if (cached?.consumer.closed.peek() !== undefined)
|
|
136
|
+
return undefined;
|
|
137
|
+
return cached?.selection.route.epoch === served.route.epoch ? cached : undefined;
|
|
138
|
+
}
|
|
139
|
+
/** Cache each live identity so a temporary route winner never displaces a held fallback. */
|
|
140
|
+
insert(path, identity, consumer) {
|
|
141
|
+
let entries = this.#cache.get(path);
|
|
142
|
+
if (!entries) {
|
|
143
|
+
entries = new Map();
|
|
144
|
+
this.#cache.set(path, entries);
|
|
145
|
+
}
|
|
146
|
+
const key = identity.route.identity ?? identity.ref;
|
|
147
|
+
const entry = { consumer, selection: identity };
|
|
148
|
+
entries.set(key, entry);
|
|
149
|
+
for (const prefix of coveringPrefixes(path)) {
|
|
150
|
+
let paths = this.#paths.get(prefix);
|
|
151
|
+
if (!paths) {
|
|
152
|
+
paths = new Set();
|
|
153
|
+
this.#paths.set(prefix, paths);
|
|
154
|
+
}
|
|
155
|
+
paths.add(path);
|
|
156
|
+
}
|
|
157
|
+
if (identity instanceof Blind) {
|
|
158
|
+
this.#blind.set(path, identity);
|
|
159
|
+
for (const prefix of coveringPrefixes(path)) {
|
|
160
|
+
let paths = this.#blindPrefixes.get(prefix);
|
|
161
|
+
if (!paths) {
|
|
162
|
+
paths = new Set();
|
|
163
|
+
this.#blindPrefixes.set(prefix, paths);
|
|
164
|
+
}
|
|
165
|
+
paths.add(path);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
33
168
|
void consumer.closed.then(() => {
|
|
34
|
-
|
|
35
|
-
|
|
169
|
+
identity.validity?.update(false);
|
|
170
|
+
if (entries.get(key) !== entry)
|
|
171
|
+
return;
|
|
172
|
+
entries.delete(key);
|
|
173
|
+
if (entries.size === 0 && this.#cache.get(path) === entries)
|
|
174
|
+
this.#forgetPath(path);
|
|
175
|
+
if (this.#blind.get(path) === identity)
|
|
176
|
+
this.#forgetBlind(path);
|
|
36
177
|
});
|
|
37
178
|
return consumer;
|
|
38
179
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
180
|
+
#forgetBlind(path) {
|
|
181
|
+
const blind = this.#blind.get(path);
|
|
182
|
+
if (!blind)
|
|
183
|
+
return;
|
|
184
|
+
blind.validity.update(false);
|
|
185
|
+
this.#blind.delete(path);
|
|
186
|
+
const entries = this.#cache.get(path);
|
|
187
|
+
entries?.delete(blind.ref);
|
|
188
|
+
if (entries?.size === 0)
|
|
189
|
+
this.#forgetPath(path);
|
|
190
|
+
for (const prefix of coveringPrefixes(path)) {
|
|
191
|
+
const paths = this.#blindPrefixes.get(prefix);
|
|
192
|
+
paths?.delete(path);
|
|
193
|
+
if (paths?.size === 0)
|
|
194
|
+
this.#blindPrefixes.delete(prefix);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
#forgetPath(path) {
|
|
57
198
|
this.#cache.delete(path);
|
|
199
|
+
for (const prefix of coveringPrefixes(path)) {
|
|
200
|
+
const paths = this.#paths.get(prefix);
|
|
201
|
+
paths?.delete(path);
|
|
202
|
+
if (paths?.size === 0)
|
|
203
|
+
this.#paths.delete(prefix);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// The advertisements at `prefix`, oldest first.
|
|
207
|
+
#eligible(prefix) {
|
|
208
|
+
return [...(this.#announced.get(prefix)?.values() ?? [])];
|
|
209
|
+
}
|
|
210
|
+
#update(prefix) {
|
|
211
|
+
if (this.#batched) {
|
|
212
|
+
this.#batched.add(prefix);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
for (const path of this.#paths.get(prefix) ?? [])
|
|
216
|
+
this.#check(path);
|
|
217
|
+
}
|
|
218
|
+
#check(path) {
|
|
219
|
+
const selected = this.identity(path);
|
|
220
|
+
for (const entry of this.#cache.get(path)?.values() ?? []) {
|
|
221
|
+
const same = sameIdentity(entry.selection, selected);
|
|
222
|
+
entry.selection.validity?.update(same, !same && !(selected instanceof Blind));
|
|
223
|
+
}
|
|
58
224
|
}
|
|
59
225
|
}
|
|
60
226
|
//# sourceMappingURL=consume.js.map
|
package/consume.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consume.js","sourceRoot":"","sources":["../src/consume.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,cAAc;IAC1B,wEAAwE;IACxE,MAAM,GAAG,IAAI,GAAG,EAAkC,CAAC;IAEnD,yFAAyF;IACzF,GAAG,CAAC,IAAgB;QACnB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;QAClE,OAAO,SAAS,CAAC;IAClB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,IAAgB,EAAE,QAA4B;QACpD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAEhC,wFAAwF;QACxF,2FAA2F;QAC3F,KAAK,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;YAC9B,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,QAAQ;gBAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,IAAgB;QACrB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACD","sourcesContent":["import type * as broadcast from \"./broadcast.ts\";\nimport type * as Path from \"./path.ts\";\n\n/**\n * Per-path dedup cache for consumed broadcasts, shared by the moq-lite and moq-ietf\n * subscribers.\n *\n * Resolving the same path must not mint a fresh subscription per call: repeat requests\n * for the same path (e.g. several renditions referencing one `broadcast: \"./source\"`) should\n * share a single upstream subscription. This mirrors the Rust `origin::Consumer` weak-cache:\n * a still-live path resolves to a shared {@link broadcast.Consumer.clone}, a closed one is\n * re-consumed on the next request. Each handle is reference-counted, so the shared broadcast\n * closes once every caller has closed its handle.\n *\n * @internal\n */\nexport class BroadcastCache {\n\t// The base handle per path; callers get reference-counted clones of it.\n\t#cache = new Map<Path.Valid, broadcast.Consumer>();\n\n\t/** A shared handle to the live broadcast cached for `path`, or `undefined` on a miss. */\n\tget(path: Path.Valid): broadcast.Consumer | undefined {\n\t\tconst base = this.#cache.get(path);\n\t\tif (base && base.closed.peek() === undefined) return base.clone();\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Cache `consumer` as the base handle for `path` (evicting it once it closes) and return it.\n\t * Call on a {@link get} miss, after wiring up the fresh consumer's subscribe loop.\n\t */\n\tinsert(path: Path.Valid, consumer: broadcast.Consumer): broadcast.Consumer {\n\t\tthis.#cache.set(path, consumer);\n\n\t\t// Drop the entry once the broadcast closes (every handle released), so the next request\n\t\t// re-consumes rather than cloning a dead handle. Guard against a newer entry for the path.\n\t\tvoid consumer.closed.then(() => {\n\t\t\tif (this.#cache.get(path) === consumer) this.#cache.delete(path);\n\t\t});\n\n\t\treturn consumer;\n\t}\n\n\t/**\n\t * Stop sharing the broadcast cached for `path`, so the next request subscribes fresh.\n\t *\n\t * Call when the path's advertisement goes away. A handle only leaves the cache on its own\n\t * once *every* holder has closed it, so one holder outliving the publisher (a second\n\t * watcher, or a caller consuming the path directly) would otherwise keep the dead\n\t * generation's cached tracks alive and hand them to whoever consumes the path next.\n\t * Existing handles are left alone: they belong to their holders, and the wire resets\n\t * whatever they still have open.\n\t *\n\t * Eviction is unconditional, which costs a dedup miss when two announcement streams watch\n\t * one path: the second stream's retraction can arrive after the first has already seen the\n\t * replacement, dropping the fresh entry so the next request subscribes again instead of\n\t * sharing. Telling that stale retraction from a live one needs a generation id on the\n\t * advertisement (moq-lite's `Epoch`, not yet on the wire), so until then this errs toward a\n\t * duplicate subscription rather than risk handing out a dead one.\n\t */\n\tevict(path: Path.Valid): void {\n\t\tthis.#cache.delete(path);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"consume.js","sourceRoot":"","sources":["../src/consume.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAExE,OAAO,EAAe,YAAY,EAAE,MAAM,WAAW,CAAC;AAEtD,4EAA4E;AAC5E,SAAS,OAAO;IACf,OAAO,IAAI,WAAW,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC,CAAC;AAC1F,CAAC;AAED,MAAM,QAAQ;IACb,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;IACjC,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IAEnC,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACH,IAAI,SAAS;QACZ,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,OAAgB,EAAE,QAAQ,GAAG,KAAK;QACxC,IAAI,OAAO,EAAE,CAAC;YACb,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO;gBAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;YACxE,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO;gBAAE,IAAI,CAAC,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;YAC5E,OAAO;QACR,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CA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CACD","sourcesContent":["import type * as broadcast from \"./broadcast.ts\";\nimport { StreamCode, StreamError } from \"./error.ts\";\nimport type { WireRoute } from \"./hop.ts\";\nimport * as Identity from \"./identity.ts\";\nimport { arrival, coveringPrefixes, mostSpecific } from \"./internal.ts\";\nimport type * as Path from \"./path.ts\";\nimport { type Served, sameIdentity } from \"./wire.ts\";\n\n// Unroutable, as in Rust: the identity going away is an end, not a failure.\nfunction retired(): StreamError {\n\treturn new StreamError(StreamCode.Unroutable, { message: \"broadcast identity retired\" });\n}\n\nclass Validity {\n\t#current = new AbortController();\n\t#answering = new AbortController();\n\n\tget signal(): AbortSignal {\n\t\treturn this.#current.signal;\n\t}\n\n\t/**\n\t * Aborted once another identity takes the path, which may answer a request still unanswered.\n\t * A withdrawal alone leaves it, and the identity winning again keeps it.\n\t */\n\tget answering(): AbortSignal {\n\t\treturn this.#answering.signal;\n\t}\n\n\tupdate(allowed: boolean, replaced = false): void {\n\t\tif (allowed) {\n\t\t\tif (this.#current.signal.aborted) this.#current = new AbortController();\n\t\t\tif (this.#answering.signal.aborted) this.#answering = new AbortController();\n\t\t\treturn;\n\t\t}\n\t\tif (!this.#current.signal.aborted) this.#current.abort(retired());\n\t\tif (replaced && !this.#answering.signal.aborted) this.#answering.abort(retired());\n\t}\n}\n\n// The route a consume selected: its identity, which its requests pin, and epoch.\ntype Selection = Served & {\n\treadonly validity?: Validity;\n};\n\nclass Blind implements Selection {\n\treadonly ref = {};\n\treadonly route = {};\n\treadonly validity = new Validity();\n}\n\ntype Advertised = { ref: object; route: WireRoute };\n\ntype CacheEntry = { consumer: broadcast.Consumer; selection: Selection };\n\n/** Consumed broadcasts shared only within the selected serving identity. @internal */\nexport class BroadcastCache {\n\t#cache = new Map<Path.Valid, Map<Identity.Valid | object, CacheEntry>>();\n\t#announced = new Map<Path.Valid, Map<object, Advertised>>();\n\t#blind = new Map<Path.Valid, Blind>();\n\t#blindPrefixes = new Map<Path.Valid, Set<Path.Valid>>();\n\t#paths = new Map<Path.Valid, Set<Path.Valid>>();\n\t// The prefixes a batch changed, rechecked once it ends.\n\t#batched?: Set<Path.Valid>;\n\n\t/**\n\t * Apply several changes as one: each path they touch is rechecked once, after the last, so\n\t * a selection that only passes through another route on the way never retires a request.\n\t */\n\tbatch(apply: () => void): void {\n\t\tif (this.#batched) {\n\t\t\tapply();\n\t\t\treturn;\n\t\t}\n\t\tconst batched = new Set<Path.Valid>();\n\t\tthis.#batched = batched;\n\t\ttry {\n\t\t\tapply();\n\t\t} finally {\n\t\t\tthis.#batched = undefined;\n\t\t}\n\t\tconst paths = new Set<Path.Valid>();\n\t\tfor (const prefix of batched) for (const path of this.#paths.get(prefix) ?? []) paths.add(path);\n\t\tfor (const path of paths) this.#check(path);\n\t}\n\n\t/** Record this interest's live advertisement, preserving ref across route updates. */\n\tannounce(path: Path.Valid, owner: object, route: WireRoute, restart = false): void {\n\t\t// Only unannounced consumers covered by this advertisement lose their blind ref.\n\t\tfor (const covered of this.#blindPrefixes.get(path) ?? []) this.#forgetBlind(covered);\n\t\tlet entries = this.#announced.get(path);\n\t\tif (!entries) {\n\t\t\tentries = new Map();\n\t\t\tthis.#announced.set(path, entries);\n\t\t}\n\t\tconst previous = entries.get(owner);\n\t\tconst ref = (!restart && previous?.ref) || {};\n\t\tarrival(ref);\n\t\t// A new or restarted stream ranks as the newest, which wins a full tie at its own path; see mostSpecific.\n\t\tif (!previous || restart) entries.delete(owner);\n\t\tentries.set(owner, { ref, route });\n\t\tthis.#update(path);\n\t}\n\n\t/** Withdraw this interest's advertisement without disturbing another interest's routes. */\n\twithdraw(path: Path.Valid, owner: object): void {\n\t\tconst entries = this.#announced.get(path);\n\t\tentries?.delete(owner);\n\t\tif (entries?.size === 0) this.#announced.delete(path);\n\t\tthis.#update(path);\n\t}\n\n\t/** Resolve the same most-specific-prefix and route preference as the origin. */\n\tidentity(path: Path.Valid): Selection {\n\t\tconst best = mostSpecific(\n\t\t\tpath,\n\t\t\t(prefix) => this.#eligible(prefix).reverse(),\n\t\t\t(entry) => entry,\n\t\t);\n\t\tif (best) {\n\t\t\tconst cached = this.#live(path, best);\n\t\t\t// A minted identity names the announcement, not the publisher's stream, so a\n\t\t\t// request for it can only name the path: it holds while this route is selected.\n\t\t\tconst named = best.route.identity !== undefined && !Identity.isMinted(best.route.identity);\n\t\t\treturn {\n\t\t\t\t...best,\n\t\t\t\tvalidity: !named ? (cached?.selection.validity ?? new Validity()) : undefined,\n\t\t\t};\n\t\t}\n\t\treturn this.#blind.get(path) ?? new Blind();\n\t}\n\n\t/**\n\t * The best route of `identity` alone at `path`, whichever identity wins the path, as a\n\t * request pinned to it resolves. With no route of it, the identity alone, which the peer\n\t * resolves or refuses.\n\t */\n\tpinned(path: Path.Valid, identity: Identity.Valid): Selection {\n\t\tconst best = mostSpecific(\n\t\t\tpath,\n\t\t\t(prefix) =>\n\t\t\t\tthis.#eligible(prefix)\n\t\t\t\t\t.filter((entry) => entry.route.identity === identity)\n\t\t\t\t\t.reverse(),\n\t\t\t(entry) => entry,\n\t\t);\n\t\treturn best ?? { ref: {}, route: { identity } };\n\t}\n\n\t/** Clone the live cached consumer only when it serves the selected identity and epoch. */\n\tget(path: Path.Valid, identity: Served): broadcast.Consumer | undefined {\n\t\treturn this.#live(path, identity)?.consumer.clone();\n\t}\n\n\t// The live cached entry consumed through `served`'s identity and epoch: an older epoch never\n\t// answers a fresh request, since the newer one may refuse it.\n\t#live(path: Path.Valid, served: Served): CacheEntry | undefined {\n\t\tconst cached = this.#cache.get(path)?.get(served.route.identity ?? served.ref);\n\t\tif (cached?.consumer.closed.peek() !== undefined) return undefined;\n\t\treturn cached?.selection.route.epoch === served.route.epoch ? cached : undefined;\n\t}\n\n\t/** Cache each live identity so a temporary route winner never displaces a held fallback. */\n\tinsert(path: Path.Valid, identity: Selection, consumer: broadcast.Consumer): broadcast.Consumer {\n\t\tlet entries = this.#cache.get(path);\n\t\tif (!entries) {\n\t\t\tentries = new Map();\n\t\t\tthis.#cache.set(path, entries);\n\t\t}\n\t\tconst key = identity.route.identity ?? identity.ref;\n\t\tconst entry = { consumer, selection: identity };\n\t\tentries.set(key, entry);\n\t\tfor (const prefix of coveringPrefixes(path)) {\n\t\t\tlet paths = this.#paths.get(prefix);\n\t\t\tif (!paths) {\n\t\t\t\tpaths = new Set();\n\t\t\t\tthis.#paths.set(prefix, paths);\n\t\t\t}\n\t\t\tpaths.add(path);\n\t\t}\n\t\tif (identity instanceof Blind) {\n\t\t\tthis.#blind.set(path, identity);\n\t\t\tfor (const prefix of coveringPrefixes(path)) {\n\t\t\t\tlet paths = this.#blindPrefixes.get(prefix);\n\t\t\t\tif (!paths) {\n\t\t\t\t\tpaths = new Set();\n\t\t\t\t\tthis.#blindPrefixes.set(prefix, paths);\n\t\t\t\t}\n\t\t\t\tpaths.add(path);\n\t\t\t}\n\t\t}\n\t\tvoid consumer.closed.then(() => {\n\t\t\tidentity.validity?.update(false);\n\t\t\tif (entries.get(key) !== entry) return;\n\t\t\tentries.delete(key);\n\t\t\tif (entries.size === 0 && this.#cache.get(path) === entries) this.#forgetPath(path);\n\t\t\tif (this.#blind.get(path) === identity) this.#forgetBlind(path);\n\t\t});\n\t\treturn consumer;\n\t}\n\n\t#forgetBlind(path: Path.Valid): void {\n\t\tconst blind = this.#blind.get(path);\n\t\tif (!blind) return;\n\t\tblind.validity.update(false);\n\t\tthis.#blind.delete(path);\n\t\tconst entries = this.#cache.get(path);\n\t\tentries?.delete(blind.ref);\n\t\tif (entries?.size === 0) this.#forgetPath(path);\n\t\tfor (const prefix of coveringPrefixes(path)) {\n\t\t\tconst paths = this.#blindPrefixes.get(prefix);\n\t\t\tpaths?.delete(path);\n\t\t\tif (paths?.size === 0) this.#blindPrefixes.delete(prefix);\n\t\t}\n\t}\n\n\t#forgetPath(path: Path.Valid): void {\n\t\tthis.#cache.delete(path);\n\t\tfor (const prefix of coveringPrefixes(path)) {\n\t\t\tconst paths = this.#paths.get(prefix);\n\t\t\tpaths?.delete(path);\n\t\t\tif (paths?.size === 0) this.#paths.delete(prefix);\n\t\t}\n\t}\n\n\t// The advertisements at `prefix`, oldest first.\n\t#eligible(prefix: Path.Valid): Advertised[] {\n\t\treturn [...(this.#announced.get(prefix)?.values() ?? [])];\n\t}\n\n\t#update(prefix: Path.Valid): void {\n\t\tif (this.#batched) {\n\t\t\tthis.#batched.add(prefix);\n\t\t\treturn;\n\t\t}\n\t\tfor (const path of this.#paths.get(prefix) ?? []) this.#check(path);\n\t}\n\n\t#check(path: Path.Valid): void {\n\t\tconst selected = this.identity(path);\n\t\tfor (const entry of this.#cache.get(path)?.values() ?? []) {\n\t\t\tconst same = sameIdentity(entry.selection, selected);\n\t\t\tentry.selection.validity?.update(same, !same && !(selected instanceof Blind));\n\t\t}\n\t}\n}\n"]}
|
package/cover.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Counted runs of group keys, so one edit and each query cost O(log n) however many runs are held.
|
|
3
|
+
* Mirrors the Rust `Cover`, without its persistence.
|
|
4
|
+
*
|
|
5
|
+
* A subscription may name thousands of ranges, and an update may edit one of them. Each run counts
|
|
6
|
+
* +1 at its start and -1 at its exclusive end, so a key is covered while the running sum through it
|
|
7
|
+
* stays positive. A treap keeps each subtree's sum and its lowest and highest running sums, so
|
|
8
|
+
* adding or removing a run touches two keys and every query is one descent.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
/** A run of keys `[start, end)`; an open run ends at {@link UNBOUNDED}. */
|
|
13
|
+
type Run = {
|
|
14
|
+
start: bigint;
|
|
15
|
+
end: bigint;
|
|
16
|
+
};
|
|
17
|
+
/** A multiset of runs of keys, read as the set of keys any run covers. */
|
|
18
|
+
export declare class Cover {
|
|
19
|
+
#private;
|
|
20
|
+
/** Count `delta` more of `[start, end)`, or fewer when negative; an empty run counts nothing. */
|
|
21
|
+
add(start: bigint, end: bigint, delta: number): void;
|
|
22
|
+
/** Whether any run covers `key`. */
|
|
23
|
+
contains(key: bigint): boolean;
|
|
24
|
+
/** The fewest runs covering any key in `[start, end)`. */
|
|
25
|
+
least(start: bigint, end: bigint): number;
|
|
26
|
+
/** The lowest key covered at or after `from`. */
|
|
27
|
+
next(from: bigint): bigint | undefined;
|
|
28
|
+
/** The highest key covered below `before`. */
|
|
29
|
+
prev(before: bigint): bigint | undefined;
|
|
30
|
+
/** The lowest key covered: where the first run starts. */
|
|
31
|
+
lowest(): bigint | undefined;
|
|
32
|
+
/** The exclusive end past every key covered: {@link UNBOUNDED} while a run is open, 0 for none. */
|
|
33
|
+
end(): bigint;
|
|
34
|
+
/** Where the run reaching past every key starts, undefined when the last run ends. */
|
|
35
|
+
openFrom(): bigint | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* The runs reaching into `[from, end)`, lowest first, clipped to it. One walk in key order that
|
|
38
|
+
* skips every subtree holding no run's edge, so each run costs about one descent.
|
|
39
|
+
*/
|
|
40
|
+
runs(from?: bigint, end?: bigint): Run[];
|
|
41
|
+
}
|
|
42
|
+
/** A multiset of keys, counted so that adding, removing, and finding the lowest or highest cost O(log n). */
|
|
43
|
+
export declare class Counts<K extends number | bigint> {
|
|
44
|
+
#private;
|
|
45
|
+
/** Count `key` once more, returning whether it is new. */
|
|
46
|
+
add(key: K): boolean;
|
|
47
|
+
/** Count `key` once less, returning whether that was its last. Nothing for a key not held. */
|
|
48
|
+
remove(key: K): boolean;
|
|
49
|
+
/** Whether `key` is held. */
|
|
50
|
+
has(key: K): boolean;
|
|
51
|
+
/** The lowest key held. */
|
|
52
|
+
first(): K | undefined;
|
|
53
|
+
/** The highest key held. */
|
|
54
|
+
last(): K | undefined;
|
|
55
|
+
/** The keys held at or below `limit`, lowest first, costing those keys and one descent. */
|
|
56
|
+
through(limit: K): K[];
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=cover.d.ts.map
|
package/cover.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cover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