@moq/net 0.4.8 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/announce.d.ts +1 -1
- package/announce.d.ts.map +1 -1
- package/announce.js +1 -1
- package/announce.js.map +1 -1
- package/announced.d.ts +51 -47
- package/announced.d.ts.map +1 -1
- package/announced.js +183 -31
- package/announced.js.map +1 -1
- package/announced.test-util.d.ts +2 -0
- package/announced.test-util.d.ts.map +1 -0
- package/announced.test-util.js +27 -0
- package/announced.test-util.js.map +1 -0
- package/auth.d.ts +64 -0
- package/auth.d.ts.map +1 -0
- package/auth.js +20 -0
- package/auth.js.map +1 -0
- package/auth_gate.d.ts +2 -0
- package/auth_gate.d.ts.map +1 -0
- package/auth_gate.js +24 -0
- package/auth_gate.js.map +1 -0
- package/auth_session.d.ts +49 -0
- package/auth_session.d.ts.map +1 -0
- package/auth_session.js +1097 -0
- package/auth_session.js.map +1 -0
- package/bandwidth.d.ts +129 -25
- package/bandwidth.d.ts.map +1 -1
- package/bandwidth.js +410 -138
- package/bandwidth.js.map +1 -1
- package/bandwidth_api.d.ts +1 -1
- package/bandwidth_api.d.ts.map +1 -1
- package/bandwidth_api.js +1 -1
- package/bandwidth_api.js.map +1 -1
- package/broadcast.d.ts +62 -36
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +556 -172
- package/broadcast.js.map +1 -1
- package/cache.d.ts +103 -0
- package/cache.d.ts.map +1 -0
- package/cache.js +254 -0
- package/cache.js.map +1 -0
- package/claim.test-util.d.ts +5 -0
- package/claim.test-util.d.ts.map +1 -0
- package/claim.test-util.js +13 -0
- package/claim.test-util.js.map +1 -0
- package/connection/accept.d.ts +20 -12
- package/connection/accept.d.ts.map +1 -1
- package/connection/accept.js +97 -129
- package/connection/accept.js.map +1 -1
- package/connection/browser.d.ts.map +1 -1
- package/connection/browser.js +28 -19
- package/connection/browser.js.map +1 -1
- package/connection/connect.d.ts +119 -23
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +535 -216
- package/connection/connect.js.map +1 -1
- package/connection/dials.d.ts +45 -0
- package/connection/dials.d.ts.map +1 -0
- package/connection/dials.js +109 -0
- package/connection/dials.js.map +1 -0
- package/connection/endpoint.d.ts +60 -0
- package/connection/endpoint.d.ts.map +1 -0
- package/connection/endpoint.js +114 -0
- package/connection/endpoint.js.map +1 -0
- package/connection/forward.d.ts +7 -1
- package/connection/forward.d.ts.map +1 -1
- package/connection/forward.js +265 -80
- package/connection/forward.js.map +1 -1
- package/connection/goaway.d.ts +16 -9
- package/connection/goaway.d.ts.map +1 -1
- package/connection/goaway.js +22 -108
- package/connection/goaway.js.map +1 -1
- package/connection/handshake.d.ts +32 -6
- package/connection/handshake.d.ts.map +1 -1
- package/connection/handshake.js +97 -20
- package/connection/handshake.js.map +1 -1
- package/connection/index.d.ts +3 -6
- package/connection/index.d.ts.map +1 -1
- package/connection/index.js +1 -2
- package/connection/index.js.map +1 -1
- package/connection/liveness.d.ts +14 -0
- package/connection/liveness.d.ts.map +1 -0
- package/connection/liveness.js +30 -0
- package/connection/liveness.js.map +1 -0
- package/connection/pool.d.ts +137 -58
- package/connection/pool.d.ts.map +1 -1
- package/connection/pool.js +281 -117
- package/connection/pool.js.map +1 -1
- package/connection/reload.d.ts +60 -12
- package/connection/reload.d.ts.map +1 -1
- package/connection/reload.js +859 -233
- package/connection/reload.js.map +1 -1
- package/connection/session.d.ts +91 -0
- package/connection/session.d.ts.map +1 -0
- package/connection/session.js +2 -0
- package/connection/session.js.map +1 -0
- package/connection/stats.d.ts +20 -11
- package/connection/stats.d.ts.map +1 -1
- package/connection/stats.js +64 -8
- package/connection/stats.js.map +1 -1
- package/connection/ticker.d.ts +4 -0
- package/connection/ticker.d.ts.map +1 -0
- package/connection/ticker.js +66 -0
- package/connection/ticker.js.map +1 -0
- package/connection/tokens.d.ts +2 -0
- package/connection/tokens.d.ts.map +1 -0
- package/connection/tokens.js +404 -0
- package/connection/tokens.js.map +1 -0
- package/connection/transport.d.ts.map +1 -1
- package/connection/transport.js +4 -4
- package/connection/transport.js.map +1 -1
- package/connection/withdrawal.d.ts +2 -0
- package/connection/withdrawal.d.ts.map +1 -0
- package/connection/withdrawal.js +23 -0
- package/connection/withdrawal.js.map +1 -0
- package/consume.js +213 -46
- package/consume.js.map +1 -1
- package/cover.d.ts +59 -0
- package/cover.d.ts.map +1 -0
- package/cover.js +375 -0
- package/cover.js.map +1 -0
- package/datagram.d.ts +70 -11
- package/datagram.d.ts.map +1 -1
- package/datagram.js +317 -1
- package/datagram.js.map +1 -1
- package/datagram_stream.d.ts +18 -0
- package/datagram_stream.d.ts.map +1 -0
- package/datagram_stream.js +67 -0
- package/datagram_stream.js.map +1 -0
- package/defined.test-util.d.ts +2 -0
- package/defined.test-util.d.ts.map +1 -0
- package/defined.test-util.js +7 -0
- package/defined.test-util.js.map +1 -0
- package/delivered.d.ts +75 -0
- package/delivered.d.ts.map +1 -0
- package/delivered.js +228 -0
- package/delivered.js.map +1 -0
- package/demand.d.ts +173 -0
- package/demand.d.ts.map +1 -0
- package/demand.js +582 -0
- package/demand.js.map +1 -0
- package/drops.d.ts +93 -0
- package/drops.d.ts.map +1 -0
- package/drops.js +283 -0
- package/drops.js.map +1 -0
- package/error.d.ts +120 -21
- package/error.d.ts.map +1 -1
- package/error.js +230 -37
- package/error.js.map +1 -1
- package/errors.d.ts +2 -2
- package/errors.d.ts.map +1 -1
- package/errors.js +2 -2
- package/errors.js.map +1 -1
- package/fill.d.ts +174 -0
- package/fill.d.ts.map +1 -0
- package/fill.js +760 -0
- package/fill.js.map +1 -0
- package/flate/decoder.d.ts +2 -0
- package/flate/decoder.d.ts.map +1 -0
- package/flate/decoder.js +63 -0
- package/flate/decoder.js.map +1 -0
- package/flate/encoder.d.ts +2 -0
- package/flate/encoder.d.ts.map +1 -0
- package/flate/encoder.js +64 -0
- package/flate/encoder.js.map +1 -0
- package/flate/group.d.ts +34 -0
- package/flate/group.d.ts.map +1 -0
- package/flate/group.js +140 -0
- package/flate/group.js.map +1 -0
- package/frame.d.ts +80 -0
- package/frame.d.ts.map +1 -0
- package/frame.js +296 -0
- package/frame.js.map +1 -0
- package/frame.test-util.d.ts +5 -0
- package/frame.test-util.d.ts.map +1 -0
- package/frame.test-util.js +9 -0
- package/frame.test-util.js.map +1 -0
- package/group.d.ts +108 -45
- package/group.d.ts.map +1 -1
- package/group.js +1616 -307
- package/group.js.map +1 -1
- package/group_api.d.ts +7 -0
- package/group_api.d.ts.map +1 -0
- package/group_api.js +7 -0
- package/group_api.js.map +1 -0
- package/hop.d.ts +62 -76
- package/hop.d.ts.map +1 -1
- package/hop.js +92 -64
- package/hop.js.map +1 -1
- package/identity.d.ts +39 -0
- package/identity.d.ts.map +1 -0
- package/identity.js +47 -0
- package/identity.js.map +1 -0
- package/ietf/active_count.d.ts +2 -0
- package/ietf/active_count.d.ts.map +1 -0
- package/ietf/active_count.js +30 -0
- package/ietf/active_count.js.map +1 -0
- package/ietf/aliases.js +69 -35
- package/ietf/aliases.js.map +1 -1
- package/ietf/cluster.d.ts +3 -3
- package/ietf/cluster.js +14 -62
- package/ietf/cluster.js.map +1 -1
- package/ietf/connection.d.ts +1 -31
- package/ietf/connection.d.ts.map +1 -1
- package/ietf/connection.js +305 -143
- package/ietf/connection.js.map +1 -1
- package/ietf/datagram.d.ts +60 -0
- package/ietf/datagram.d.ts.map +1 -0
- package/ietf/datagram.js +152 -0
- package/ietf/datagram.js.map +1 -0
- package/ietf/error.d.ts +3 -3
- package/ietf/error.js +82 -100
- package/ietf/error.js.map +1 -1
- package/ietf/fetch.d.ts +91 -35
- package/ietf/fetch.d.ts.map +1 -1
- package/ietf/fetch.js +172 -93
- package/ietf/fetch.js.map +1 -1
- package/ietf/filter.d.ts +20 -30
- package/ietf/filter.d.ts.map +1 -1
- package/ietf/filter.js +140 -171
- package/ietf/filter.js.map +1 -1
- package/ietf/goaway.d.ts +11 -9
- package/ietf/goaway.d.ts.map +1 -1
- package/ietf/goaway.js +22 -35
- package/ietf/goaway.js.map +1 -1
- package/ietf/hidden.js +1 -1
- package/ietf/hidden.js.map +1 -1
- package/ietf/index.d.ts +2 -14
- package/ietf/index.d.ts.map +1 -1
- package/ietf/index.js +4 -14
- package/ietf/index.js.map +1 -1
- package/ietf/join.d.ts +7 -0
- package/ietf/join.d.ts.map +1 -0
- package/ietf/join.js +234 -0
- package/ietf/join.js.map +1 -0
- package/ietf/message.d.ts +18 -2
- package/ietf/message.d.ts.map +1 -1
- package/ietf/message.js +60 -40
- package/ietf/message.js.map +1 -1
- package/ietf/message.test-util.d.ts +6 -0
- package/ietf/message.test-util.d.ts.map +1 -0
- package/ietf/message.test-util.js +13 -0
- package/ietf/message.test-util.js.map +1 -0
- package/ietf/namespace.d.ts +17 -3
- package/ietf/namespace.d.ts.map +1 -1
- package/ietf/namespace.js +78 -26
- package/ietf/namespace.js.map +1 -1
- package/ietf/object.d.ts +194 -32
- package/ietf/object.d.ts.map +1 -1
- package/ietf/object.js +405 -178
- package/ietf/object.js.map +1 -1
- package/ietf/parameters.d.ts +22 -42
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +260 -472
- package/ietf/parameters.js.map +1 -1
- package/ietf/priority.d.ts +17 -2
- package/ietf/priority.d.ts.map +1 -1
- package/ietf/priority.js +19 -4
- package/ietf/priority.js.map +1 -1
- package/ietf/properties.d.ts +5 -4
- package/ietf/properties.d.ts.map +1 -1
- package/ietf/properties.js +78 -48
- package/ietf/properties.js.map +1 -1
- package/ietf/publish.d.ts +22 -30
- package/ietf/publish.d.ts.map +1 -1
- package/ietf/publish.js +45 -139
- package/ietf/publish.js.map +1 -1
- package/ietf/publish_namespace.d.ts +46 -69
- package/ietf/publish_namespace.d.ts.map +1 -1
- package/ietf/publish_namespace.js +66 -184
- package/ietf/publish_namespace.js.map +1 -1
- package/ietf/publisher.js +1800 -600
- package/ietf/publisher.js.map +1 -1
- package/ietf/range.d.ts +2 -0
- package/ietf/range.d.ts.map +1 -0
- package/ietf/range.js +222 -0
- package/ietf/range.js.map +1 -0
- package/ietf/request.d.ts +3 -27
- package/ietf/request.d.ts.map +1 -1
- package/ietf/request.js +41 -78
- package/ietf/request.js.map +1 -1
- package/ietf/request_stream.d.ts +1 -6
- package/ietf/request_stream.d.ts.map +1 -1
- package/ietf/request_stream.js +306 -16
- package/ietf/request_stream.js.map +1 -1
- package/ietf/session.d.ts +41 -0
- package/ietf/session.d.ts.map +1 -0
- package/ietf/session.js +65 -0
- package/ietf/session.js.map +1 -0
- package/ietf/setup.d.ts +4 -29
- package/ietf/setup.d.ts.map +1 -1
- package/ietf/setup.js +6 -117
- package/ietf/setup.js.map +1 -1
- package/ietf/setup_options.d.ts +31 -0
- package/ietf/setup_options.d.ts.map +1 -0
- package/ietf/setup_options.js +138 -0
- package/ietf/setup_options.js.map +1 -0
- package/ietf/solicit.js +4 -14
- package/ietf/solicit.js.map +1 -1
- package/ietf/subscribe.d.ts +48 -41
- package/ietf/subscribe.d.ts.map +1 -1
- package/ietf/subscribe.js +118 -239
- package/ietf/subscribe.js.map +1 -1
- package/ietf/subscribe_namespace.d.ts +13 -76
- package/ietf/subscribe_namespace.d.ts.map +1 -1
- package/ietf/subscribe_namespace.js +30 -201
- package/ietf/subscribe_namespace.js.map +1 -1
- package/ietf/subscriber.js +1839 -536
- package/ietf/subscriber.js.map +1 -1
- package/ietf/token.js +105 -27
- package/ietf/token.js.map +1 -1
- package/ietf/track.d.ts +25 -22
- package/ietf/track.d.ts.map +1 -1
- package/ietf/track.js +48 -61
- package/ietf/track.js.map +1 -1
- package/ietf/version.d.ts +13 -42
- package/ietf/version.d.ts.map +1 -1
- package/ietf/version.js +22 -48
- package/ietf/version.js.map +1 -1
- package/implementation.d.ts +2 -0
- package/implementation.d.ts.map +1 -0
- package/implementation.js +5 -0
- package/implementation.js.map +1 -0
- package/index.d.ts +25 -10
- package/index.d.ts.map +1 -1
- package/index.js +19 -6
- package/index.js.map +1 -1
- package/internal.d.ts +1512 -64
- package/internal.d.ts.map +1 -1
- package/internal.js +557 -79
- package/internal.js.map +1 -1
- package/ledger.d.ts +23 -0
- package/ledger.d.ts.map +1 -0
- package/ledger.js +247 -0
- package/ledger.js.map +1 -0
- package/listing.d.ts +132 -0
- package/listing.d.ts.map +1 -0
- package/listing.js +486 -0
- package/listing.js.map +1 -0
- package/lite/announce.d.ts +124 -63
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +384 -158
- package/lite/announce.js.map +1 -1
- package/lite/announce_stream.d.ts +2 -0
- package/lite/announce_stream.d.ts.map +1 -0
- package/lite/announce_stream.js +92 -0
- package/lite/announce_stream.js.map +1 -0
- package/lite/answer.d.ts +22 -0
- package/lite/answer.d.ts.map +1 -0
- package/lite/answer.js +301 -0
- package/lite/answer.js.map +1 -0
- package/lite/auth.d.ts +45 -0
- package/lite/auth.d.ts.map +1 -0
- package/lite/auth.js +204 -0
- package/lite/auth.js.map +1 -0
- package/lite/compat.d.ts +31 -0
- package/lite/compat.d.ts.map +1 -0
- package/lite/compat.js +86 -0
- package/lite/compat.js.map +1 -0
- package/lite/connection.d.ts +1 -45
- package/lite/connection.d.ts.map +1 -1
- package/lite/connection.js +360 -77
- package/lite/connection.js.map +1 -1
- package/lite/datagram-end.d.ts +26 -0
- package/lite/datagram-end.d.ts.map +1 -0
- package/lite/datagram-end.js +30 -0
- package/lite/datagram-end.js.map +1 -0
- package/lite/datagram.d.ts +73 -8
- package/lite/datagram.d.ts.map +1 -1
- package/lite/datagram.js +144 -9
- package/lite/datagram.js.map +1 -1
- package/lite/duration.d.ts +6 -0
- package/lite/duration.d.ts.map +1 -0
- package/lite/duration.js +14 -0
- package/lite/duration.js.map +1 -0
- package/lite/error.d.ts +9 -0
- package/lite/error.d.ts.map +1 -0
- package/lite/error.js +24 -0
- package/lite/error.js.map +1 -0
- package/lite/fills.d.ts +162 -0
- package/lite/fills.d.ts.map +1 -0
- package/lite/fills.js +486 -0
- package/lite/fills.js.map +1 -0
- package/lite/fit.d.ts +49 -0
- package/lite/fit.d.ts.map +1 -0
- package/lite/fit.js +305 -0
- package/lite/fit.js.map +1 -0
- package/lite/goaway.d.ts +1 -1
- package/lite/goaway.d.ts.map +1 -1
- package/lite/goaway.js +5 -13
- package/lite/goaway.js.map +1 -1
- package/lite/group.d.ts +64 -13
- package/lite/group.d.ts.map +1 -1
- package/lite/group.js +108 -30
- package/lite/group.js.map +1 -1
- package/lite/identity.d.ts +25 -0
- package/lite/identity.d.ts.map +1 -0
- package/lite/identity.js +79 -0
- package/lite/identity.js.map +1 -0
- package/lite/index.d.ts +2 -1
- package/lite/index.d.ts.map +1 -1
- package/lite/index.js +2 -1
- package/lite/index.js.map +1 -1
- package/lite/message.d.ts +9 -1
- package/lite/message.d.ts.map +1 -1
- package/lite/message.js +28 -44
- package/lite/message.js.map +1 -1
- package/lite/priority.d.ts +9 -2
- package/lite/priority.d.ts.map +1 -1
- package/lite/priority.js +11 -105
- package/lite/priority.js.map +1 -1
- package/lite/probe.d.ts.map +1 -1
- package/lite/probe.js +9 -0
- package/lite/probe.js.map +1 -1
- package/lite/publisher.d.ts +10 -1
- package/lite/publisher.d.ts.map +1 -1
- package/lite/publisher.js +2548 -437
- package/lite/publisher.js.map +1 -1
- package/lite/routed.d.ts +59 -0
- package/lite/routed.d.ts.map +1 -0
- package/lite/routed.js +564 -0
- package/lite/routed.js.map +1 -0
- package/lite/session.d.ts +1 -27
- package/lite/session.d.ts.map +1 -1
- package/lite/session.js +0 -99
- package/lite/session.js.map +1 -1
- package/lite/setup.d.ts +29 -2
- package/lite/setup.d.ts.map +1 -1
- package/lite/setup.js +95 -21
- package/lite/setup.js.map +1 -1
- package/lite/stream.d.ts +5 -11
- package/lite/stream.d.ts.map +1 -1
- package/lite/stream.js +5 -1
- package/lite/stream.js.map +1 -1
- package/lite/subscribe.d.ts +475 -75
- package/lite/subscribe.d.ts.map +1 -1
- package/lite/subscribe.js +1373 -142
- package/lite/subscribe.js.map +1 -1
- package/lite/subscriber.d.ts +7 -44
- package/lite/subscriber.d.ts.map +1 -1
- package/lite/subscriber.js +3290 -515
- package/lite/subscriber.js.map +1 -1
- package/lite/track.d.ts +24 -9
- package/lite/track.d.ts.map +1 -1
- package/lite/track.js +116 -37
- package/lite/track.js.map +1 -1
- package/lite/tracks.d.ts +55 -0
- package/lite/tracks.d.ts.map +1 -0
- package/lite/tracks.js +114 -0
- package/lite/tracks.js.map +1 -0
- package/lite/version.d.ts +132 -24
- package/lite/version.d.ts.map +1 -1
- package/lite/version.js +378 -33
- package/lite/version.js.map +1 -1
- package/meta.d.ts +77 -0
- package/meta.d.ts.map +1 -0
- package/meta.js +130 -0
- package/meta.js.map +1 -0
- package/meta_api.d.ts +7 -0
- package/meta_api.d.ts.map +1 -0
- package/meta_api.js +7 -0
- package/meta_api.js.map +1 -0
- package/mint.d.ts +28 -0
- package/mint.d.ts.map +1 -0
- package/mint.js +66 -0
- package/mint.js.map +1 -0
- package/open.d.ts +63 -0
- package/open.d.ts.map +1 -0
- package/open.js +250 -0
- package/open.js.map +1 -0
- package/origin.d.ts +392 -140
- package/origin.d.ts.map +1 -1
- package/origin.js +2533 -686
- package/origin.js.map +1 -1
- package/package.json +8 -13
- package/path.d.ts +51 -51
- package/path.d.ts.map +1 -1
- package/path.js +210 -57
- package/path.js.map +1 -1
- package/payload.d.ts +33 -0
- package/payload.d.ts.map +1 -0
- package/payload.js +65 -0
- package/payload.js.map +1 -0
- package/prefix.d.ts +152 -0
- package/prefix.d.ts.map +1 -0
- package/prefix.js +349 -0
- package/prefix.js.map +1 -0
- package/priority.d.ts +8 -0
- package/priority.d.ts.map +1 -0
- package/priority.js +185 -0
- package/priority.js.map +1 -0
- package/queue.d.ts +2 -0
- package/queue.d.ts.map +1 -0
- package/queue.js +46 -0
- package/queue.js.map +1 -0
- package/ranges.d.ts +36 -0
- package/ranges.d.ts.map +1 -0
- package/ranges.js +312 -0
- package/ranges.js.map +1 -0
- package/rescale.d.ts +24 -0
- package/rescale.d.ts.map +1 -0
- package/rescale.js +39 -0
- package/rescale.js.map +1 -0
- package/resume.d.ts +55 -0
- package/resume.d.ts.map +1 -0
- package/resume.js +4173 -0
- package/resume.js.map +1 -0
- package/resume.test-util.d.ts +2 -0
- package/resume.test-util.d.ts.map +1 -0
- package/resume.test-util.js +25 -0
- package/resume.test-util.js.map +1 -0
- package/skips.d.ts +48 -0
- package/skips.d.ts.map +1 -0
- package/skips.js +182 -0
- package/skips.js.map +1 -0
- package/stream.d.ts +75 -37
- package/stream.d.ts.map +1 -1
- package/stream.js +236 -92
- package/stream.js.map +1 -1
- package/subscription.test-util.d.ts +2 -0
- package/subscription.test-util.d.ts.map +1 -0
- package/subscription.test-util.js +49 -0
- package/subscription.test-util.js.map +1 -0
- package/tail.d.ts +23 -14
- package/tail.d.ts.map +1 -1
- package/tail.js +224 -97
- package/tail.js.map +1 -1
- package/time.d.ts +41 -102
- package/time.d.ts.map +1 -1
- package/time.js +129 -91
- package/time.js.map +1 -1
- package/timed.d.ts +21 -0
- package/timed.d.ts.map +1 -0
- package/timed.js +2 -0
- package/timed.js.map +1 -0
- package/track.d.ts +577 -245
- package/track.d.ts.map +1 -1
- package/track.js +7306 -771
- package/track.js.map +1 -1
- package/track_api.d.ts +7 -0
- package/track_api.d.ts.map +1 -0
- package/track_api.js +7 -0
- package/track_api.js.map +1 -0
- package/util/abort.d.ts +1 -0
- package/util/abort.d.ts.map +1 -1
- package/util/abort.js +23 -1
- package/util/abort.js.map +1 -1
- package/util/announce.d.ts +4 -0
- package/util/announce.d.ts.map +1 -0
- package/util/announce.js +11 -0
- package/util/announce.js.map +1 -0
- package/util/bigint.d.ts +3 -0
- package/util/bigint.d.ts.map +1 -0
- package/util/bigint.js +8 -0
- package/util/bigint.js.map +1 -0
- package/util/change.d.ts +12 -0
- package/util/change.d.ts.map +1 -0
- package/util/change.js +18 -0
- package/util/change.js.map +1 -0
- package/util/deadline.d.ts +2 -0
- package/util/deadline.d.ts.map +1 -0
- package/util/deadline.js +108 -0
- package/util/deadline.js.map +1 -0
- package/util/decode_error.d.ts +3 -0
- package/util/decode_error.d.ts.map +1 -0
- package/util/decode_error.js +11 -0
- package/util/decode_error.js.map +1 -0
- package/util/demand.d.ts +8 -0
- package/util/demand.d.ts.map +1 -0
- package/util/demand.js +24 -0
- package/util/demand.js.map +1 -0
- package/util/given_up.d.ts +2 -0
- package/util/given_up.d.ts.map +1 -0
- package/util/given_up.js +101 -0
- package/util/given_up.js.map +1 -0
- package/util/hex.d.ts +6 -0
- package/util/hex.d.ts.map +1 -1
- package/util/hex.js +19 -4
- package/util/hex.js.map +1 -1
- package/util/key.d.ts +15 -0
- package/util/key.d.ts.map +1 -0
- package/util/key.js +38 -0
- package/util/key.js.map +1 -0
- package/util/limits.d.ts +2 -0
- package/util/limits.d.ts.map +1 -0
- package/util/limits.js +76 -0
- package/util/limits.js.map +1 -0
- package/util/observed.d.ts +23 -0
- package/util/observed.d.ts.map +1 -0
- package/util/observed.js +122 -0
- package/util/observed.js.map +1 -0
- package/util/sorted.d.ts +2 -0
- package/util/sorted.d.ts.map +1 -0
- package/util/sorted.js +149 -0
- package/util/sorted.js.map +1 -0
- package/util/timeout.d.ts +2 -1
- package/util/timeout.d.ts.map +1 -1
- package/util/timeout.js +13 -9
- package/util/timeout.js.map +1 -1
- package/util/timer.d.ts +2 -0
- package/util/timer.d.ts.map +1 -0
- package/util/timer.js +19 -0
- package/util/timer.js.map +1 -0
- package/util/utf8.d.ts +2 -0
- package/util/utf8.d.ts.map +1 -1
- package/util/utf8.js +7 -1
- package/util/utf8.js.map +1 -1
- package/util/varint.d.ts.map +1 -1
- package/util/varint.js +8 -1
- package/util/varint.js.map +1 -1
- package/util/watch.d.ts +8 -0
- package/util/watch.d.ts.map +1 -0
- package/util/watch.js +38 -0
- package/util/watch.js.map +1 -0
- package/util/yield.d.ts +2 -0
- package/util/yield.d.ts.map +1 -0
- package/util/yield.js +31 -0
- package/util/yield.js.map +1 -0
- package/varint.d.ts +0 -29
- package/varint.d.ts.map +1 -1
- package/varint.js +7 -28
- package/varint.js.map +1 -1
- package/varint_api.d.ts +7 -0
- package/varint_api.d.ts.map +1 -0
- package/varint_api.js +7 -0
- package/varint_api.js.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +4 -0
- package/version.js.map +1 -0
- package/window.d.ts +570 -0
- package/window.d.ts.map +1 -0
- package/window.js +1677 -0
- package/window.js.map +1 -0
- package/wire.d.ts +145 -30
- package/wire.d.ts.map +1 -1
- package/wire.js +27 -0
- package/wire.js.map +1 -1
- package/connection/established.d.ts +0 -53
- package/connection/established.d.ts.map +0 -1
- package/connection/established.js +0 -2
- package/connection/established.js.map +0 -1
- package/ietf/adapter.d.ts +0 -75
- package/ietf/adapter.d.ts.map +0 -1
- package/ietf/adapter.js +0 -699
- package/ietf/adapter.js.map +0 -1
- package/lite/datagram_stream.d.ts +0 -8
- package/lite/datagram_stream.d.ts.map +0 -1
- package/lite/datagram_stream.js +0 -43
- package/lite/datagram_stream.js.map +0 -1
- package/lite/fetch.d.ts +0 -28
- package/lite/fetch.d.ts.map +0 -1
- package/lite/fetch.js +0 -78
- package/lite/fetch.js.map +0 -1
- package/util/log.d.ts +0 -5
- package/util/log.d.ts.map +0 -1
- package/util/log.js +0 -16
- package/util/log.js.map +0 -1
- package/zod.d.ts +0 -13
- package/zod.d.ts.map +0 -1
- package/zod.js +0 -18
- package/zod.js.map +0 -1
package/track_api.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Track role handles. The public surface of `track.ts`, leaving its package-internal helpers out.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
export { type Compression, Consumer, Demand, type FetchGroupOptions, FillGroups, type Finished, type Info, type InfoInit, type InfoOptions, type Item, type Live, type Order, Ordered, type Position, Producer, type Range, type Refresh, type RefreshOptions, Requests, rescale, rescaleIn, type Start, Subscriber, Subscription, } from "./track.ts";
|
|
7
|
+
//# sourceMappingURL=track_api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"track_api.d.ts","sourceRoot":"","sources":["../src/track_api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACN,KAAK,WAAW,EAChB,QAAQ,EACR,MAAM,EACN,KAAK,iBAAiB,EACtB,UAAU,EACV,KAAK,QAAQ,EACb,KAAK,IAAI,EACT,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,IAAI,EACT,KAAK,IAAI,EACT,KAAK,KAAK,EACV,OAAO,EACP,KAAK,QAAQ,EACb,QAAQ,EACR,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,QAAQ,EACR,OAAO,EACP,SAAS,EACT,KAAK,KAAK,EACV,UAAU,EACV,YAAY,GACZ,MAAM,YAAY,CAAC"}
|
package/track_api.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Track role handles. The public surface of `track.ts`, leaving its package-internal helpers out.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
export { Consumer, Demand, FillGroups, Ordered, Producer, Requests, rescale, rescaleIn, Subscriber, Subscription, } from "./track.js";
|
|
7
|
+
//# sourceMappingURL=track_api.js.map
|
package/track_api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"track_api.js","sourceRoot":"","sources":["../src/track_api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAEN,QAAQ,EACR,MAAM,EAEN,UAAU,EAQV,OAAO,EAEP,QAAQ,EAIR,QAAQ,EACR,OAAO,EACP,SAAS,EAET,UAAU,EACV,YAAY,GACZ,MAAM,YAAY,CAAC","sourcesContent":["/**\n * Track role handles. The public surface of `track.ts`, leaving its package-internal helpers out.\n *\n * @module\n */\nexport {\n\ttype Compression,\n\tConsumer,\n\tDemand,\n\ttype FetchGroupOptions,\n\tFillGroups,\n\ttype Finished,\n\ttype Info,\n\ttype InfoInit,\n\ttype InfoOptions,\n\ttype Item,\n\ttype Live,\n\ttype Order,\n\tOrdered,\n\ttype Position,\n\tProducer,\n\ttype Range,\n\ttype Refresh,\n\ttype RefreshOptions,\n\tRequests,\n\trescale,\n\trescaleIn,\n\ttype Start,\n\tSubscriber,\n\tSubscription,\n} from \"./track.ts\";\n"]}
|
package/util/abort.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export declare function untilAborted<T>(promise: Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
2
|
+
export declare function raceAborted<const T extends readonly unknown[]>(values: T, signal: AbortSignal | undefined, cause?: (reason: unknown) => unknown): Promise<Awaited<T[number]>>;
|
|
2
3
|
//# sourceMappingURL=abort.d.ts.map
|
package/util/abort.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abort.d.ts","sourceRoot":"","sources":["../../src/util/abort.ts"],"names":[],"mappings":"AAKA,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"abort.d.ts","sourceRoot":"","sources":["../../src/util/abort.ts"],"names":[],"mappings":"AAKA,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAgB3F;AAID,wBAAsB,WAAW,CAAC,KAAK,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,EACnE,MAAM,EAAE,CAAC,EACT,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,KAAK,GAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAA4B,GACtD,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAW7B"}
|
package/util/abort.js
CHANGED
|
@@ -5,7 +5,11 @@ import { race } from "@moq/signals";
|
|
|
5
5
|
export async function untilAborted(promise, signal) {
|
|
6
6
|
if (!signal)
|
|
7
7
|
return promise;
|
|
8
|
-
signal.
|
|
8
|
+
if (signal.aborted) {
|
|
9
|
+
// Observed, since the caller drops it: a later rejection is not unhandled.
|
|
10
|
+
promise.catch(() => undefined);
|
|
11
|
+
throw signal.reason;
|
|
12
|
+
}
|
|
9
13
|
const { promise: aborted, reject } = Promise.withResolvers();
|
|
10
14
|
const onAbort = () => reject(signal.reason);
|
|
11
15
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
@@ -16,4 +20,22 @@ export async function untilAborted(promise, signal) {
|
|
|
16
20
|
signal.removeEventListener("abort", onAbort);
|
|
17
21
|
}
|
|
18
22
|
}
|
|
23
|
+
// Settle with the first of `values`, as `race` does, or reject with `cause` of the signal's reason
|
|
24
|
+
// once it aborts. One race holds every listener, so whichever settles first drops them all.
|
|
25
|
+
export async function raceAborted(values, signal, cause = (reason) => reason) {
|
|
26
|
+
if (!signal)
|
|
27
|
+
return race(values);
|
|
28
|
+
const { promise: aborted, reject } = Promise.withResolvers();
|
|
29
|
+
const onAbort = () => reject(cause(signal.reason));
|
|
30
|
+
if (signal.aborted)
|
|
31
|
+
onAbort();
|
|
32
|
+
else
|
|
33
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
34
|
+
try {
|
|
35
|
+
return await race([...values, aborted]);
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
signal.removeEventListener("abort", onAbort);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
19
41
|
//# sourceMappingURL=abort.js.map
|
package/util/abort.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abort.js","sourceRoot":"","sources":["../../src/util/abort.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,+FAA+F;AAC/F,2FAA2F;AAC3F,uCAAuC;AACvC,MAAM,CAAC,KAAK,UAAU,YAAY,CAAI,OAAmB,EAAE,MAAoB;IAC9E,IAAI,CAAC,MAAM;QAAE,OAAO,OAAO,CAAC;IAC5B,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"abort.js","sourceRoot":"","sources":["../../src/util/abort.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,+FAA+F;AAC/F,2FAA2F;AAC3F,uCAAuC;AACvC,MAAM,CAAC,KAAK,UAAU,YAAY,CAAI,OAAmB,EAAE,MAAoB;IAC9E,IAAI,CAAC,MAAM;QAAE,OAAO,OAAO,CAAC;IAC5B,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,2EAA2E;QAC3E,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC/B,MAAM,MAAM,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,EAAS,CAAC;IACpE,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,IAAI,CAAC;QACJ,OAAO,MAAM,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IACvC,CAAC;YAAS,CAAC;QACV,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;AACF,CAAC;AAED,mGAAmG;AACnG,4FAA4F;AAC5F,MAAM,CAAC,KAAK,UAAU,WAAW,CAChC,MAAS,EACT,MAA+B,EAC/B,KAAK,GAAiC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM;IAExD,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,EAAS,CAAC;IACpE,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACnD,IAAI,MAAM,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;;QACzB,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,IAAI,CAAC;QACJ,OAAO,MAAM,IAAI,CAAC,CAAC,GAAG,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACzC,CAAC;YAAS,CAAC;QACV,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;AACF,CAAC","sourcesContent":["import { race } from \"@moq/signals\";\n\n// Settle with `promise`, or reject with the signal's reason once it aborts. An already-aborted\n// signal rejects at once. There's no cancellation of `promise` itself; the caller releases\n// whatever it holds when this rejects.\nexport async function untilAborted<T>(promise: Promise<T>, signal?: AbortSignal): Promise<T> {\n\tif (!signal) return promise;\n\tif (signal.aborted) {\n\t\t// Observed, since the caller drops it: a later rejection is not unhandled.\n\t\tpromise.catch(() => undefined);\n\t\tthrow signal.reason;\n\t}\n\n\tconst { promise: aborted, reject } = Promise.withResolvers<never>();\n\tconst onAbort = () => reject(signal.reason);\n\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\ttry {\n\t\treturn await race([promise, aborted]);\n\t} finally {\n\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t}\n}\n\n// Settle with the first of `values`, as `race` does, or reject with `cause` of the signal's reason\n// once it aborts. One race holds every listener, so whichever settles first drops them all.\nexport async function raceAborted<const T extends readonly unknown[]>(\n\tvalues: T,\n\tsignal: AbortSignal | undefined,\n\tcause: (reason: unknown) => unknown = (reason) => reason,\n): Promise<Awaited<T[number]>> {\n\tif (!signal) return race(values);\n\tconst { promise: aborted, reject } = Promise.withResolvers<never>();\n\tconst onAbort = () => reject(cause(signal.reason));\n\tif (signal.aborted) onAbort();\n\telse signal.addEventListener(\"abort\", onAbort, { once: true });\n\ttry {\n\t\treturn await race([...values, aborted]);\n\t} finally {\n\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"announce.d.ts","sourceRoot":"","sources":["../../src/util/announce.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,gGAAgG;AAChG,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAOtD"}
|
package/util/announce.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Signal } from "@moq/signals";
|
|
2
|
+
/** Close an announcement stream once no consumer wants it: how a reader cancels the request. */
|
|
3
|
+
export function closeUnwanted(producer) {
|
|
4
|
+
void (async () => {
|
|
5
|
+
while (producer.wanted.peek() && producer.closed.peek() === undefined) {
|
|
6
|
+
await Signal.race(producer.wanted, producer.closed);
|
|
7
|
+
}
|
|
8
|
+
producer.close();
|
|
9
|
+
})();
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=announce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"announce.js","sourceRoot":"","sources":["../../src/util/announce.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtC,gGAAgG;AAChG,MAAM,UAAU,aAAa,CAAC,QAAkB;IAC/C,KAAK,CAAC,KAAK,IAAI,EAAE;QAChB,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;YACvE,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC;QACD,QAAQ,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC,CAAC,EAAE,CAAC;AACN,CAAC","sourcesContent":["import { Signal } from \"@moq/signals\";\nimport type { Producer } from \"../announced.ts\";\n\n/** Close an announcement stream once no consumer wants it: how a reader cancels the request. */\nexport function closeUnwanted(producer: Producer): void {\n\tvoid (async () => {\n\t\twhile (producer.wanted.peek() && producer.closed.peek() === undefined) {\n\t\t\tawait Signal.race(producer.wanted, producer.closed);\n\t\t}\n\t\tproducer.close();\n\t})();\n}\n"]}
|
package/util/bigint.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bigint.d.ts","sourceRoot":"","sources":["../../src/util/bigint.ts"],"names":[],"mappings":"AAEA,sFAAsF;AACtF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAG9C"}
|
package/util/bigint.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const MAX_SAFE_INTEGER = BigInt(Number.MAX_SAFE_INTEGER);
|
|
2
|
+
/** Convert an unsigned integer to a model number, refusing it before any rounding. */
|
|
3
|
+
export function toNumber(value) {
|
|
4
|
+
if (value < 0n || value > MAX_SAFE_INTEGER)
|
|
5
|
+
throw new RangeError(`integer outside the safe number range: ${value}`);
|
|
6
|
+
return Number(value);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=bigint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bigint.js","sourceRoot":"","sources":["../../src/util/bigint.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEzD,sFAAsF;AACtF,MAAM,UAAU,QAAQ,CAAC,KAAa;IACrC,IAAI,KAAK,GAAG,EAAE,IAAI,KAAK,GAAG,gBAAgB;QAAE,MAAM,IAAI,UAAU,CAAC,0CAA0C,KAAK,EAAE,CAAC,CAAC;IACpH,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC","sourcesContent":["const MAX_SAFE_INTEGER = BigInt(Number.MAX_SAFE_INTEGER);\n\n/** Convert an unsigned integer to a model number, refusing it before any rounding. */\nexport function toNumber(value: bigint): number {\n\tif (value < 0n || value > MAX_SAFE_INTEGER) throw new RangeError(`integer outside the safe number range: ${value}`);\n\treturn Number(value);\n}\n"]}
|
package/util/change.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Dispose, Getter } from "@moq/signals";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve with "changed" on the next change to any of `sources`, listening from now.
|
|
4
|
+
*
|
|
5
|
+
* Unlike the lazy `Signal.race`, this registers before the caller's next await, so a change
|
|
6
|
+
* landing while it works still wakes the wait. Call `dispose` once done waiting.
|
|
7
|
+
*/
|
|
8
|
+
export declare function nextChange(...sources: (Getter<unknown> | undefined)[]): {
|
|
9
|
+
changed: Promise<"changed">;
|
|
10
|
+
dispose: Dispose;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=change.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"change.d.ts","sourceRoot":"","sources":["../../src/util/change.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,OAAO,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,EAAE,GAAG;IACxE,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;CACjB,CASA"}
|
package/util/change.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve with "changed" on the next change to any of `sources`, listening from now.
|
|
3
|
+
*
|
|
4
|
+
* Unlike the lazy `Signal.race`, this registers before the caller's next await, so a change
|
|
5
|
+
* landing while it works still wakes the wait. Call `dispose` once done waiting.
|
|
6
|
+
*/
|
|
7
|
+
export function nextChange(...sources) {
|
|
8
|
+
const { promise: changed, resolve } = Promise.withResolvers();
|
|
9
|
+
const disposers = sources.map((source) => source?.changed(() => resolve("changed")));
|
|
10
|
+
return {
|
|
11
|
+
changed,
|
|
12
|
+
dispose: () => {
|
|
13
|
+
for (const dispose of disposers)
|
|
14
|
+
dispose?.();
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=change.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"change.js","sourceRoot":"","sources":["../../src/util/change.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,GAAG,OAAwC;IAIrE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,aAAa,EAAa,CAAC;IACzE,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACrF,OAAO;QACN,OAAO;QACP,OAAO,EAAE,GAAG,EAAE;YACb,KAAK,MAAM,OAAO,IAAI,SAAS;gBAAE,OAAO,EAAE,EAAE,CAAC;QAC9C,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import type { Dispose, Getter } from \"@moq/signals\";\n\n/**\n * Resolve with \"changed\" on the next change to any of `sources`, listening from now.\n *\n * Unlike the lazy `Signal.race`, this registers before the caller's next await, so a change\n * landing while it works still wakes the wait. Call `dispose` once done waiting.\n */\nexport function nextChange(...sources: (Getter<unknown> | undefined)[]): {\n\tchanged: Promise<\"changed\">;\n\tdispose: Dispose;\n} {\n\tconst { promise: changed, resolve } = Promise.withResolvers<\"changed\">();\n\tconst disposers = sources.map((source) => source?.changed(() => resolve(\"changed\")));\n\treturn {\n\t\tchanged,\n\t\tdispose: () => {\n\t\t\tfor (const dispose of disposers) dispose?.();\n\t\t},\n\t};\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deadline.d.ts","sourceRoot":"","sources":["../../src/util/deadline.ts"],"names":[],"mappings":""}
|
package/util/deadline.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { sleep } from "@moq/clock";
|
|
2
|
+
import { race } from "@moq/signals";
|
|
3
|
+
import { controlTimeout, error } from "../error.js";
|
|
4
|
+
import { TimeoutError } from "./timeout.js";
|
|
5
|
+
/** Milliseconds an advertisement may go unanswered while none of its streams waits to open. @internal */
|
|
6
|
+
export const REQUEST_TIMEOUT_MS = 10_000;
|
|
7
|
+
/**
|
|
8
|
+
* Owns a request's setup streams and optionally bounds its answer. Track requests take no
|
|
9
|
+
* budget: their publisher may hold the answer until demand, cancellation, or the session
|
|
10
|
+
* ends it. A budget runs only while none of the request's streams waits to open. @internal
|
|
11
|
+
*/
|
|
12
|
+
export class Deadline {
|
|
13
|
+
/** Creates still waiting on credit: a fetch opens its TRACK stream alongside. */
|
|
14
|
+
#opening = 0;
|
|
15
|
+
/** Settles whenever an open starts or ends, restarting the budget. */
|
|
16
|
+
#changed;
|
|
17
|
+
#notify;
|
|
18
|
+
#owners = [];
|
|
19
|
+
#failure;
|
|
20
|
+
#budget;
|
|
21
|
+
constructor(budget) {
|
|
22
|
+
this.#budget = budget;
|
|
23
|
+
this.#rearm();
|
|
24
|
+
}
|
|
25
|
+
#rearm() {
|
|
26
|
+
this.#changed = new Promise((resolve) => {
|
|
27
|
+
this.#notify = resolve;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
#change(delta) {
|
|
31
|
+
this.#opening += delta;
|
|
32
|
+
this.#notify();
|
|
33
|
+
this.#rearm();
|
|
34
|
+
}
|
|
35
|
+
async open(opening, own = (stream) => stream) {
|
|
36
|
+
this.#change(1);
|
|
37
|
+
let stream;
|
|
38
|
+
try {
|
|
39
|
+
stream = await opening;
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
this.#change(-1);
|
|
43
|
+
}
|
|
44
|
+
const owner = own(stream);
|
|
45
|
+
if (this.#failure) {
|
|
46
|
+
owner.abort(this.#failure);
|
|
47
|
+
throw this.#failure;
|
|
48
|
+
}
|
|
49
|
+
this.#owners.push(owner);
|
|
50
|
+
return owner;
|
|
51
|
+
}
|
|
52
|
+
/** Write the request on an opened stream, which a deadline failure after resets. */
|
|
53
|
+
async send(stream, write) {
|
|
54
|
+
if (this.#failure)
|
|
55
|
+
throw this.#failure;
|
|
56
|
+
if (!this.#owners.includes(stream))
|
|
57
|
+
throw new Error("request sent on a stream the deadline did not open");
|
|
58
|
+
await write();
|
|
59
|
+
}
|
|
60
|
+
/** Wait for the first answer, within the budget if one was given. */
|
|
61
|
+
async wait(answer) {
|
|
62
|
+
const budget = this.#budget;
|
|
63
|
+
if (budget === undefined)
|
|
64
|
+
return answer;
|
|
65
|
+
const done = new AbortController();
|
|
66
|
+
try {
|
|
67
|
+
return (await race([answer, this.#expire(budget, done.signal)]));
|
|
68
|
+
}
|
|
69
|
+
catch (cause) {
|
|
70
|
+
const failure = cause instanceof TimeoutError ? controlTimeout(cause) : error(cause);
|
|
71
|
+
this.#failure = failure;
|
|
72
|
+
// Other failures keep the caller's cancellation ordering.
|
|
73
|
+
if (cause instanceof TimeoutError) {
|
|
74
|
+
for (const owner of this.#owners)
|
|
75
|
+
owner.abort(failure);
|
|
76
|
+
}
|
|
77
|
+
throw failure;
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
done.abort();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/** Reject once the request goes the whole budget with none of its streams waiting to open. */
|
|
84
|
+
async #expire(limit, done) {
|
|
85
|
+
const budget = limit;
|
|
86
|
+
const answered = new Promise((resolve) => done.addEventListener("abort", () => resolve(), { once: true }));
|
|
87
|
+
for (;;) {
|
|
88
|
+
const changed = this.#changed;
|
|
89
|
+
const restart = new AbortController();
|
|
90
|
+
const timer = this.#opening > 0
|
|
91
|
+
? new Promise(() => { })
|
|
92
|
+
: sleep(budget, { signal: AbortSignal.any([restart.signal, done]) }).catch(() => undefined);
|
|
93
|
+
const why = await race([
|
|
94
|
+
timer.then(() => "expired"),
|
|
95
|
+
changed.then(() => "changed"),
|
|
96
|
+
answered,
|
|
97
|
+
]);
|
|
98
|
+
restart.abort();
|
|
99
|
+
// Answered: the waiting is over, and nothing is left to reject.
|
|
100
|
+
if (why === undefined)
|
|
101
|
+
return new Promise(() => { });
|
|
102
|
+
if (why === "expired" && !done.aborted) {
|
|
103
|
+
throw new TimeoutError(`request timed out after ${this.#budget}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=deadline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deadline.js","sourceRoot":"","sources":["../../src/util/deadline.ts"],"names":[],"mappings":"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","sourcesContent":["import { type Duration, sleep } from \"@moq/clock\";\nimport { race } from \"@moq/signals\";\nimport { controlTimeout, error } from \"../error.ts\";\nimport type { Stream } from \"../stream.ts\";\nimport { TimeoutError } from \"./timeout.ts\";\n\n/** Milliseconds an advertisement may go unanswered while none of its streams waits to open. @internal */\nexport const REQUEST_TIMEOUT_MS = 10_000;\n\n/** What a deadline failure resets: a stream, or whatever owns one. @internal */\nexport interface Abortable {\n\tabort(err: Error): void;\n}\n\n/**\n * Owns a request's setup streams and optionally bounds its answer. Track requests take no\n * budget: their publisher may hold the answer until demand, cancellation, or the session\n * ends it. A budget runs only while none of the request's streams waits to open. @internal\n */\nexport class Deadline {\n\t/** Creates still waiting on credit: a fetch opens its TRACK stream alongside. */\n\t#opening = 0;\n\t/** Settles whenever an open starts or ends, restarting the budget. */\n\t#changed!: Promise<void>;\n\t#notify!: () => void;\n\t#owners: Abortable[] = [];\n\t#failure?: Error;\n\n\t#budget?: Duration;\n\n\tconstructor(budget?: Duration) {\n\t\tthis.#budget = budget;\n\t\tthis.#rearm();\n\t}\n\n\t#rearm() {\n\t\tthis.#changed = new Promise((resolve) => {\n\t\t\tthis.#notify = resolve;\n\t\t});\n\t}\n\n\t#change(delta: number) {\n\t\tthis.#opening += delta;\n\t\tthis.#notify();\n\t\tthis.#rearm();\n\t}\n\n\t/**\n\t * Record a create so deadline failures reset its stream even if it opens late. `own` wraps\n\t * the opened stream in its owner, which the failure then resets instead.\n\t */\n\topen(opening: Stream | Promise<Stream>): Promise<Stream>;\n\topen<T extends Abortable>(opening: Stream | Promise<Stream>, own: (stream: Stream) => T): Promise<T>;\n\tasync open(\n\t\topening: Stream | Promise<Stream>,\n\t\town: (stream: Stream) => Abortable = (stream) => stream,\n\t): Promise<Abortable> {\n\t\tthis.#change(1);\n\t\tlet stream: Stream;\n\t\ttry {\n\t\t\tstream = await opening;\n\t\t} finally {\n\t\t\tthis.#change(-1);\n\t\t}\n\t\tconst owner = own(stream);\n\t\tif (this.#failure) {\n\t\t\towner.abort(this.#failure);\n\t\t\tthrow this.#failure;\n\t\t}\n\t\tthis.#owners.push(owner);\n\t\treturn owner;\n\t}\n\n\t/** Write the request on an opened stream, which a deadline failure after resets. */\n\tasync send(stream: Abortable, write: () => Promise<void>): Promise<void> {\n\t\tif (this.#failure) throw this.#failure;\n\t\tif (!this.#owners.includes(stream)) throw new Error(\"request sent on a stream the deadline did not open\");\n\t\tawait write();\n\t}\n\n\t/** Wait for the first answer, within the budget if one was given. */\n\tasync wait<T>(answer: Promise<T>): Promise<T> {\n\t\tconst budget = this.#budget;\n\t\tif (budget === undefined) return answer;\n\t\tconst done = new AbortController();\n\t\ttry {\n\t\t\treturn (await race([answer, this.#expire(budget, done.signal)])) as T;\n\t\t} catch (cause) {\n\t\t\tconst failure = cause instanceof TimeoutError ? controlTimeout(cause) : error(cause);\n\t\t\tthis.#failure = failure;\n\t\t\t// Other failures keep the caller's cancellation ordering.\n\t\t\tif (cause instanceof TimeoutError) {\n\t\t\t\tfor (const owner of this.#owners) owner.abort(failure);\n\t\t\t}\n\t\t\tthrow failure;\n\t\t} finally {\n\t\t\tdone.abort();\n\t\t}\n\t}\n\n\t/** Reject once the request goes the whole budget with none of its streams waiting to open. */\n\tasync #expire(limit: Duration, done: AbortSignal): Promise<never> {\n\t\tconst budget = limit;\n\t\tconst answered = new Promise<void>((resolve) =>\n\t\t\tdone.addEventListener(\"abort\", () => resolve(), { once: true }),\n\t\t);\n\t\tfor (;;) {\n\t\t\tconst changed = this.#changed;\n\t\t\tconst restart = new AbortController();\n\t\t\tconst timer =\n\t\t\t\tthis.#opening > 0\n\t\t\t\t\t? new Promise<void>(() => {})\n\t\t\t\t\t: sleep(budget, { signal: AbortSignal.any([restart.signal, done]) }).catch(() => undefined);\n\t\t\tconst why = await race([\n\t\t\t\ttimer.then(() => \"expired\" as const),\n\t\t\t\tchanged.then(() => \"changed\" as const),\n\t\t\t\tanswered,\n\t\t\t]);\n\t\t\trestart.abort();\n\t\t\t// Answered: the waiting is over, and nothing is left to reject.\n\t\t\tif (why === undefined) return new Promise<never>(() => {});\n\t\t\tif (why === \"expired\" && !done.aborted) {\n\t\t\t\tthrow new TimeoutError(`request timed out after ${this.#budget}`);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode_error.d.ts","sourceRoot":"","sources":["../../src/util/decode_error.ts"],"names":[],"mappings":"AAGA,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAIjD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAErD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Preserve the original typed error: data decoders use its type to recover locally.
|
|
2
|
+
const malformed = new WeakSet();
|
|
3
|
+
export function decodeError(cause) {
|
|
4
|
+
const err = cause instanceof Error ? cause : new Error(String(cause));
|
|
5
|
+
malformed.add(err);
|
|
6
|
+
return err;
|
|
7
|
+
}
|
|
8
|
+
export function isDecodeError(cause) {
|
|
9
|
+
return cause instanceof Error && malformed.has(cause);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=decode_error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode_error.js","sourceRoot":"","sources":["../../src/util/decode_error.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,MAAM,SAAS,GAAG,IAAI,OAAO,EAAS,CAAC;AAEvC,MAAM,UAAU,WAAW,CAAC,KAAc;IACzC,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACtE,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAc;IAC3C,OAAO,KAAK,YAAY,KAAK,IAAI,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvD,CAAC","sourcesContent":["// Preserve the original typed error: data decoders use its type to recover locally.\nconst malformed = new WeakSet<Error>();\n\nexport function decodeError(cause: unknown): Error {\n\tconst err = cause instanceof Error ? cause : new Error(String(cause));\n\tmalformed.add(err);\n\treturn err;\n}\n\nexport function isDecodeError(cause: unknown): boolean {\n\treturn cause instanceof Error && malformed.has(cause);\n}\n"]}
|
package/util/demand.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Demand } from "../track.ts";
|
|
2
|
+
/** Resolve once neither a subscriber nor a held info lookup wants the track, or it closed. */
|
|
3
|
+
export declare function unwanted(demand: Demand): Promise<void>;
|
|
4
|
+
/** Resolve once demand that arrived for the track leaves, or it closed: demand that never arrived is not abandonment. */
|
|
5
|
+
export declare function abandoned(demand: Demand): Promise<void>;
|
|
6
|
+
/** Whether neither a subscriber nor a held info lookup wants the track now, or it closed. */
|
|
7
|
+
export declare function isAbandoned(demand: Demand): boolean;
|
|
8
|
+
//# sourceMappingURL=demand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demand.d.ts","sourceRoot":"","sources":["../../src/util/demand.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,8FAA8F;AAC9F,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI5D;AAED,yHAAyH;AACzH,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ7D;AAED,6FAA6F;AAC7F,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEnD"}
|
package/util/demand.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Signal } from "@moq/signals";
|
|
2
|
+
import { hooks } from "../internal.js";
|
|
3
|
+
/** Resolve once neither a subscriber nor a held info lookup wants the track, or it closed. */
|
|
4
|
+
export async function unwanted(demand) {
|
|
5
|
+
while (demand.wanted.peek() && hooks.demandReleased(demand).peek() === undefined) {
|
|
6
|
+
await Signal.race(demand.wanted, hooks.demandReleased(demand));
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/** Resolve once demand that arrived for the track leaves, or it closed: demand that never arrived is not abandonment. */
|
|
10
|
+
export async function abandoned(demand) {
|
|
11
|
+
while (!demand.wanted.peek() && hooks.demandReleased(demand).peek() === undefined) {
|
|
12
|
+
await Signal.race(demand.wanted, hooks.demandReleased(demand));
|
|
13
|
+
}
|
|
14
|
+
for (;;) {
|
|
15
|
+
await unwanted(demand);
|
|
16
|
+
if (isAbandoned(demand))
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** Whether neither a subscriber nor a held info lookup wants the track now, or it closed. */
|
|
21
|
+
export function isAbandoned(demand) {
|
|
22
|
+
return hooks.demandReleased(demand).peek() !== undefined || !demand.wanted.peek();
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=demand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demand.js","sourceRoot":"","sources":["../../src/util/demand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,8FAA8F;AAC9F,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,MAAc;IAC5C,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QAClF,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAChE,CAAC;AACF,CAAC;AAED,yHAAyH;AACzH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAc;IAC7C,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACnF,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAChE,CAAC;IACD,SAAS,CAAC;QACT,MAAM,QAAQ,CAAC,MAAM,CAAC,CAAC;QACvB,IAAI,WAAW,CAAC,MAAM,CAAC;YAAE,OAAO;IACjC,CAAC;AACF,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,WAAW,CAAC,MAAc;IACzC,OAAO,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AACnF,CAAC","sourcesContent":["import { Signal } from \"@moq/signals\";\nimport { hooks } from \"../internal.ts\";\nimport type { Demand } from \"../track.ts\";\n\n/** Resolve once neither a subscriber nor a held info lookup wants the track, or it closed. */\nexport async function unwanted(demand: Demand): Promise<void> {\n\twhile (demand.wanted.peek() && hooks.demandReleased(demand).peek() === undefined) {\n\t\tawait Signal.race(demand.wanted, hooks.demandReleased(demand));\n\t}\n}\n\n/** Resolve once demand that arrived for the track leaves, or it closed: demand that never arrived is not abandonment. */\nexport async function abandoned(demand: Demand): Promise<void> {\n\twhile (!demand.wanted.peek() && hooks.demandReleased(demand).peek() === undefined) {\n\t\tawait Signal.race(demand.wanted, hooks.demandReleased(demand));\n\t}\n\tfor (;;) {\n\t\tawait unwanted(demand);\n\t\tif (isAbandoned(demand)) return;\n\t}\n}\n\n/** Whether neither a subscriber nor a held info lookup wants the track now, or it closed. */\nexport function isAbandoned(demand: Demand): boolean {\n\treturn hooks.demandReleased(demand).peek() !== undefined || !demand.wanted.peek();\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"given_up.d.ts","sourceRoot":"","sources":["../../src/util/given_up.ts"],"names":[],"mappings":""}
|
package/util/given_up.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { race } from "@moq/signals";
|
|
2
|
+
import { hooks } from "../internal.js";
|
|
3
|
+
import { watchVia } from "./watch.js";
|
|
4
|
+
// Why to stop writing `group`: the subscription's budget gave it up, or it failed for good
|
|
5
|
+
// before it was read whole (evicted, or its copy aborted with no route to continue it). Through
|
|
6
|
+
// the close a watch never decides, so watching a short close does not end a group a route move
|
|
7
|
+
// may still continue.
|
|
8
|
+
function reason(group) {
|
|
9
|
+
const closed = hooks.groupClosed(group).peek();
|
|
10
|
+
return group.expired.peek() ?? (closed instanceof Error ? closed : undefined);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Why a publisher should stop writing one group: `expired`, or `closed` with an error. A clean
|
|
14
|
+
* close is no reason. Settles with that reason, which latches. Mirrors the Rust publishers'
|
|
15
|
+
* `poll_given_up`.
|
|
16
|
+
*
|
|
17
|
+
* Watches the group once while it is served, until {@link close}, rather than once per write:
|
|
18
|
+
* a fresh watch per frame would subscribe to the track's drift inputs and judge the budget
|
|
19
|
+
* again each time. A served group spends its life parked on a read or a write, and a parked
|
|
20
|
+
* read watches the same inputs, so this judges no more often than a watch per write.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export class GivenUp {
|
|
25
|
+
#group;
|
|
26
|
+
#stop;
|
|
27
|
+
#listeners = new Set();
|
|
28
|
+
#unwatch;
|
|
29
|
+
constructor(group) {
|
|
30
|
+
this.#group = group;
|
|
31
|
+
this.#unwatch = [
|
|
32
|
+
group.expired.subscribe(() => this.#check()),
|
|
33
|
+
hooks.groupClosed(group).subscribe(() => this.#check()),
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Run a write of the group, settling with why to stop it instead if that comes first. A
|
|
38
|
+
* group already given up never starts the write. Rejects if the write does.
|
|
39
|
+
*
|
|
40
|
+
* `cancel`, if given, also ends the wait, settling with `undefined` and leaving the write
|
|
41
|
+
* abandoned: the caller learns why from its own state. Racing it here saves a caller with
|
|
42
|
+
* its own reasons to stop a second race per write. Make it once per group and reuse it: a
|
|
43
|
+
* long-lived promise only gains and drops a listener per race.
|
|
44
|
+
*/
|
|
45
|
+
async write(write, cancel) {
|
|
46
|
+
// Judged afresh rather than read from the watch: a wall-clock deadline can pass before
|
|
47
|
+
// its timer wakes the watch.
|
|
48
|
+
this.#check();
|
|
49
|
+
if (this.#stop)
|
|
50
|
+
return this.#stop;
|
|
51
|
+
const done = write().then(() => true);
|
|
52
|
+
const result = await race(cancel === undefined ? [done, this] : [done, this, cancel]);
|
|
53
|
+
return result === true || result === false ? undefined : result;
|
|
54
|
+
}
|
|
55
|
+
/** Stop watching the group, once its publisher no longer writes it. */
|
|
56
|
+
close() {
|
|
57
|
+
for (const dispose of this.#unwatch)
|
|
58
|
+
dispose();
|
|
59
|
+
this.#unwatch = [];
|
|
60
|
+
}
|
|
61
|
+
peek() {
|
|
62
|
+
return this.#stop;
|
|
63
|
+
}
|
|
64
|
+
// It settles once, so every listener hears it at most once.
|
|
65
|
+
subscribe(fn) {
|
|
66
|
+
if (this.#stop)
|
|
67
|
+
return () => { };
|
|
68
|
+
this.#listeners.add(fn);
|
|
69
|
+
return () => this.#listeners.delete(fn);
|
|
70
|
+
}
|
|
71
|
+
watch(fn) {
|
|
72
|
+
return watchVia(this, fn);
|
|
73
|
+
}
|
|
74
|
+
changed(fn) {
|
|
75
|
+
if (!fn)
|
|
76
|
+
return new Promise((resolve) => this.subscribe(resolve));
|
|
77
|
+
return this.subscribe(fn);
|
|
78
|
+
}
|
|
79
|
+
// biome-ignore lint/suspicious/noThenProperty: GivenUp is intentionally awaitable.
|
|
80
|
+
then(onFulfilled, onRejected) {
|
|
81
|
+
const stop = this.#stop;
|
|
82
|
+
const settled = stop
|
|
83
|
+
? Promise.resolve(stop)
|
|
84
|
+
: new Promise((resolve) => this.subscribe((value) => value && resolve(value)));
|
|
85
|
+
return settled.then(onFulfilled, onRejected);
|
|
86
|
+
}
|
|
87
|
+
#check() {
|
|
88
|
+
if (this.#stop)
|
|
89
|
+
return;
|
|
90
|
+
const stop = reason(this.#group);
|
|
91
|
+
if (!stop)
|
|
92
|
+
return;
|
|
93
|
+
this.#stop = stop;
|
|
94
|
+
this.close();
|
|
95
|
+
const listeners = [...this.#listeners];
|
|
96
|
+
this.#listeners.clear();
|
|
97
|
+
for (const fn of listeners)
|
|
98
|
+
fn(stop);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=given_up.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"given_up.js","sourceRoot":"","sources":["../../src/util/given_up.ts"],"names":[],"mappings":"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","sourcesContent":["import { type Dispose, type GetPromise, race } from \"@moq/signals\";\nimport type { Consumer as GroupConsumer } from \"../group.ts\";\nimport { hooks } from \"../internal.ts\";\nimport { watchVia } from \"./watch.ts\";\n\n// Why to stop writing `group`: the subscription's budget gave it up, or it failed for good\n// before it was read whole (evicted, or its copy aborted with no route to continue it). Through\n// the close a watch never decides, so watching a short close does not end a group a route move\n// may still continue.\nfunction reason(group: GroupConsumer): Error | undefined {\n\tconst closed = hooks.groupClosed(group).peek();\n\treturn group.expired.peek() ?? (closed instanceof Error ? closed : undefined);\n}\n\n/**\n * Why a publisher should stop writing one group: `expired`, or `closed` with an error. A clean\n * close is no reason. Settles with that reason, which latches. Mirrors the Rust publishers'\n * `poll_given_up`.\n *\n * Watches the group once while it is served, until {@link close}, rather than once per write:\n * a fresh watch per frame would subscribe to the track's drift inputs and judge the budget\n * again each time. A served group spends its life parked on a read or a write, and a parked\n * read watches the same inputs, so this judges no more often than a watch per write.\n *\n * @internal\n */\nexport class GivenUp implements GetPromise<Error> {\n\t#group: GroupConsumer;\n\t#stop?: Error;\n\t#listeners = new Set<(value: Error | undefined) => void>();\n\t#unwatch: Dispose[];\n\n\tconstructor(group: GroupConsumer) {\n\t\tthis.#group = group;\n\t\tthis.#unwatch = [\n\t\t\tgroup.expired.subscribe(() => this.#check()),\n\t\t\thooks.groupClosed(group).subscribe(() => this.#check()),\n\t\t];\n\t}\n\n\t/**\n\t * Run a write of the group, settling with why to stop it instead if that comes first. A\n\t * group already given up never starts the write. Rejects if the write does.\n\t *\n\t * `cancel`, if given, also ends the wait, settling with `undefined` and leaving the write\n\t * abandoned: the caller learns why from its own state. Racing it here saves a caller with\n\t * its own reasons to stop a second race per write. Make it once per group and reuse it: a\n\t * long-lived promise only gains and drops a listener per race.\n\t */\n\tasync write(write: () => Promise<unknown>, cancel?: Promise<false>): Promise<Error | undefined> {\n\t\t// Judged afresh rather than read from the watch: a wall-clock deadline can pass before\n\t\t// its timer wakes the watch.\n\t\tthis.#check();\n\t\tif (this.#stop) return this.#stop;\n\t\tconst done = write().then(() => true as const);\n\t\tconst result = await race(cancel === undefined ? [done, this] : [done, this, cancel]);\n\t\treturn result === true || result === false ? undefined : result;\n\t}\n\n\t/** Stop watching the group, once its publisher no longer writes it. */\n\tclose() {\n\t\tfor (const dispose of this.#unwatch) dispose();\n\t\tthis.#unwatch = [];\n\t}\n\n\tpeek(): Error | undefined {\n\t\treturn this.#stop;\n\t}\n\n\t// It settles once, so every listener hears it at most once.\n\tsubscribe(fn: (value: Error | undefined) => void): Dispose {\n\t\tif (this.#stop) return () => {};\n\t\tthis.#listeners.add(fn);\n\t\treturn () => this.#listeners.delete(fn);\n\t}\n\n\twatch(fn: (value: Error | undefined) => void): Dispose {\n\t\treturn watchVia(this, fn);\n\t}\n\n\tchanged(): Promise<Error | undefined>;\n\tchanged(fn: (value: Error | undefined) => void): Dispose;\n\tchanged(fn?: (value: Error | undefined) => void): Promise<Error | undefined> | Dispose {\n\t\tif (!fn) return new Promise((resolve) => this.subscribe(resolve));\n\t\treturn this.subscribe(fn);\n\t}\n\n\t// biome-ignore lint/suspicious/noThenProperty: GivenUp is intentionally awaitable.\n\tthen<R1 = Error, R2 = never>(\n\t\tonFulfilled?: ((value: Error) => R1 | PromiseLike<R1>) | null,\n\t\tonRejected?: ((reason: unknown) => R2 | PromiseLike<R2>) | null,\n\t): PromiseLike<R1 | R2> {\n\t\tconst stop = this.#stop;\n\t\tconst settled = stop\n\t\t\t? Promise.resolve(stop)\n\t\t\t: new Promise<Error>((resolve) => this.subscribe((value) => value && resolve(value)));\n\t\treturn settled.then(onFulfilled, onRejected);\n\t}\n\n\t#check(): void {\n\t\tif (this.#stop) return;\n\t\tconst stop = reason(this.#group);\n\t\tif (!stop) return;\n\t\tthis.#stop = stop;\n\t\tthis.close();\n\t\tconst listeners = [...this.#listeners];\n\t\tthis.#listeners.clear();\n\t\tfor (const fn of listeners) fn(stop);\n\t}\n}\n"]}
|
package/util/hex.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decode a hex string (with optional `0x` prefix) into bytes.
|
|
3
|
+
*
|
|
4
|
+
* Throws on anything that isn't hex: `parseInt` stops at the first bad character rather than
|
|
5
|
+
* failing, so a typo in a pinned certificate hash would otherwise pin a different hash.
|
|
6
|
+
*/
|
|
1
7
|
export declare function toBytes(hex: string): Uint8Array<ArrayBuffer>;
|
|
2
8
|
export declare function fromBytes(bytes: Uint8Array): string;
|
|
3
9
|
//# sourceMappingURL=hex.d.ts.map
|
package/util/hex.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../../src/util/hex.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../../src/util/hex.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAoB5D;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAEnD"}
|
package/util/hex.js
CHANGED
|
@@ -1,13 +1,28 @@
|
|
|
1
|
+
const HEX = /^[0-9a-fA-F]*$/;
|
|
2
|
+
/**
|
|
3
|
+
* Decode a hex string (with optional `0x` prefix) into bytes.
|
|
4
|
+
*
|
|
5
|
+
* Throws on anything that isn't hex: `parseInt` stops at the first bad character rather than
|
|
6
|
+
* failing, so a typo in a pinned certificate hash would otherwise pin a different hash.
|
|
7
|
+
*/
|
|
1
8
|
export function toBytes(hex) {
|
|
2
9
|
hex = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
10
|
+
// A zero-length certificate hash can never match, so an empty value is a config error.
|
|
11
|
+
if (!hex) {
|
|
12
|
+
throw new Error("empty hex string");
|
|
13
|
+
}
|
|
3
14
|
if (hex.length % 2) {
|
|
4
15
|
throw new Error("invalid hex string length");
|
|
5
16
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
throw new Error(
|
|
17
|
+
if (!HEX.test(hex)) {
|
|
18
|
+
const index = hex.search(/[^0-9a-fA-F]/);
|
|
19
|
+
throw new Error(`invalid hex character '${hex[index]}' at position ${index}`);
|
|
20
|
+
}
|
|
21
|
+
const bytes = new Uint8Array(hex.length / 2);
|
|
22
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
23
|
+
bytes[i] = Number.parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
9
24
|
}
|
|
10
|
-
return
|
|
25
|
+
return bytes;
|
|
11
26
|
}
|
|
12
27
|
export function fromBytes(bytes) {
|
|
13
28
|
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
package/util/hex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hex.js","sourceRoot":"","sources":["../../src/util/hex.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO,CAAC,GAAW;IAClC,GAAG,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAChD,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC9C,CAAC;
|
|
1
|
+
{"version":3,"file":"hex.js","sourceRoot":"","sources":["../../src/util/hex.ts"],"names":[],"mappings":"AAAA,MAAM,GAAG,GAAG,gBAAgB,CAAC;AAE7B;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,GAAW;IAClC,GAAG,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAChD,uFAAuF;IACvF,IAAI,CAAC,GAAG,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACrC,CAAC;IACD,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC9C,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,0BAA0B,GAAG,CAAC,KAAK,CAAC,iBAAiB,KAAK,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAiB;IAC1C,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACjF,CAAC","sourcesContent":["const HEX = /^[0-9a-fA-F]*$/;\n\n/**\n * Decode a hex string (with optional `0x` prefix) into bytes.\n *\n * Throws on anything that isn't hex: `parseInt` stops at the first bad character rather than\n * failing, so a typo in a pinned certificate hash would otherwise pin a different hash.\n */\nexport function toBytes(hex: string): Uint8Array<ArrayBuffer> {\n\thex = hex.startsWith(\"0x\") ? hex.slice(2) : hex;\n\t// A zero-length certificate hash can never match, so an empty value is a config error.\n\tif (!hex) {\n\t\tthrow new Error(\"empty hex string\");\n\t}\n\tif (hex.length % 2) {\n\t\tthrow new Error(\"invalid hex string length\");\n\t}\n\tif (!HEX.test(hex)) {\n\t\tconst index = hex.search(/[^0-9a-fA-F]/);\n\t\tthrow new Error(`invalid hex character '${hex[index]}' at position ${index}`);\n\t}\n\n\tconst bytes = new Uint8Array(hex.length / 2);\n\tfor (let i = 0; i < bytes.length; i++) {\n\t\tbytes[i] = Number.parseInt(hex.slice(i * 2, i * 2 + 2), 16);\n\t}\n\n\treturn bytes;\n}\n\nexport function fromBytes(bytes: Uint8Array): string {\n\treturn Array.from(bytes, (byte) => byte.toString(16).padStart(2, \"0\")).join(\"\");\n}\n"]}
|
package/util/key.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** The smaller of two keys. */
|
|
2
|
+
export declare function min(a: bigint, b: bigint): bigint;
|
|
3
|
+
/** The larger of two keys. */
|
|
4
|
+
export declare function max(a: bigint, b: bigint): bigint;
|
|
5
|
+
/** `a - b`, or 0 when `b` is at or past `a`. */
|
|
6
|
+
export declare function saturatingSub(a: bigint, b: bigint): bigint;
|
|
7
|
+
/** An exclusive end past every group a wire can carry (2^64), which an open run ends at. */
|
|
8
|
+
export declare const UNBOUNDED: bigint;
|
|
9
|
+
/** The reserved group key, 2^64-1: no group is created there, so every group fits a half-open range. */
|
|
10
|
+
export declare const RESERVED: bigint;
|
|
11
|
+
/** Refuse a group key a u64 cannot hold, or that is not a bigint, either of which a plain JS caller can pass. */
|
|
12
|
+
export declare function checkKey(key: bigint): bigint;
|
|
13
|
+
/** Refuse an exclusive end of a run of group keys that is not a bigint in `[0, 2^64-1]`, so a run never names the reserved group. */
|
|
14
|
+
export declare function checkEnd(end: bigint): bigint;
|
|
15
|
+
//# sourceMappingURL=key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../../src/util/key.ts"],"names":[],"mappings":"AAEA,+BAA+B;AAC/B,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,8BAA8B;AAC9B,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,gDAAgD;AAChD,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,4FAA4F;AAC5F,eAAO,MAAM,SAAS,QAAY,CAAC;AAEnC,wGAAwG;AACxG,eAAO,MAAM,QAAQ,QAAiB,CAAC;AAEvC,iHAAiH;AACjH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK5C;AAED,qIAAqI;AACrI,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK5C"}
|