@moq/net 0.4.7 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/announce.d.ts +1 -1
- package/announce.d.ts.map +1 -1
- package/announce.js +1 -2
- package/announce.js.map +1 -1
- package/announced.d.ts +51 -47
- package/announced.d.ts.map +1 -1
- package/announced.js +183 -32
- package/announced.js.map +1 -1
- package/announced.test-util.d.ts +2 -0
- package/announced.test-util.d.ts.map +1 -0
- package/announced.test-util.js +27 -0
- package/announced.test-util.js.map +1 -0
- package/auth.d.ts +64 -0
- package/auth.d.ts.map +1 -0
- package/auth.js +20 -0
- package/auth.js.map +1 -0
- package/auth_gate.d.ts +2 -0
- package/auth_gate.d.ts.map +1 -0
- package/auth_gate.js +24 -0
- package/auth_gate.js.map +1 -0
- package/auth_session.d.ts +49 -0
- package/auth_session.d.ts.map +1 -0
- package/auth_session.js +1097 -0
- package/auth_session.js.map +1 -0
- package/bandwidth.d.ts +129 -25
- package/bandwidth.d.ts.map +1 -1
- package/bandwidth.js +410 -139
- package/bandwidth.js.map +1 -1
- package/bandwidth_api.d.ts +1 -1
- package/bandwidth_api.d.ts.map +1 -1
- package/bandwidth_api.js +1 -2
- package/bandwidth_api.js.map +1 -1
- package/broadcast.d.ts +64 -38
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +556 -173
- package/broadcast.js.map +1 -1
- package/cache.d.ts +103 -0
- package/cache.d.ts.map +1 -0
- package/cache.js +254 -0
- package/cache.js.map +1 -0
- package/claim.test-util.d.ts +5 -0
- package/claim.test-util.d.ts.map +1 -0
- package/claim.test-util.js +13 -0
- package/claim.test-util.js.map +1 -0
- package/connection/accept.d.ts +21 -13
- package/connection/accept.d.ts.map +1 -1
- package/connection/accept.js +97 -130
- package/connection/accept.js.map +1 -1
- package/connection/browser.d.ts.map +1 -1
- package/connection/browser.js +28 -20
- package/connection/browser.js.map +1 -1
- package/connection/connect.d.ts +120 -24
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +535 -217
- package/connection/connect.js.map +1 -1
- package/connection/dials.d.ts +45 -0
- package/connection/dials.d.ts.map +1 -0
- package/connection/dials.js +109 -0
- package/connection/dials.js.map +1 -0
- package/connection/endpoint.d.ts +60 -0
- package/connection/endpoint.d.ts.map +1 -0
- package/connection/endpoint.js +114 -0
- package/connection/endpoint.js.map +1 -0
- package/connection/forward.d.ts +7 -1
- package/connection/forward.d.ts.map +1 -1
- package/connection/forward.js +265 -81
- package/connection/forward.js.map +1 -1
- package/connection/goaway.d.ts +16 -9
- package/connection/goaway.d.ts.map +1 -1
- package/connection/goaway.js +22 -95
- package/connection/goaway.js.map +1 -1
- package/connection/handshake.d.ts +34 -8
- package/connection/handshake.d.ts.map +1 -1
- package/connection/handshake.js +97 -21
- package/connection/handshake.js.map +1 -1
- package/connection/index.d.ts +4 -7
- package/connection/index.d.ts.map +1 -1
- package/connection/index.js +1 -3
- package/connection/index.js.map +1 -1
- package/connection/liveness.d.ts +14 -0
- package/connection/liveness.d.ts.map +1 -0
- package/connection/liveness.js +30 -0
- package/connection/liveness.js.map +1 -0
- package/connection/pool.d.ts +142 -63
- package/connection/pool.d.ts.map +1 -1
- package/connection/pool.js +281 -118
- package/connection/pool.js.map +1 -1
- package/connection/reload.d.ts +60 -12
- package/connection/reload.d.ts.map +1 -1
- package/connection/reload.js +859 -234
- package/connection/reload.js.map +1 -1
- package/connection/session.d.ts +91 -0
- package/connection/session.d.ts.map +1 -0
- package/connection/session.js +2 -0
- package/connection/session.js.map +1 -0
- package/connection/stats.d.ts +20 -11
- package/connection/stats.d.ts.map +1 -1
- package/connection/stats.js +64 -9
- package/connection/stats.js.map +1 -1
- package/connection/ticker.d.ts +4 -0
- package/connection/ticker.d.ts.map +1 -0
- package/connection/ticker.js +66 -0
- package/connection/ticker.js.map +1 -0
- package/connection/tokens.d.ts +2 -0
- package/connection/tokens.d.ts.map +1 -0
- package/connection/tokens.js +404 -0
- package/connection/tokens.js.map +1 -0
- package/connection/transport.d.ts.map +1 -1
- package/connection/transport.js +4 -5
- package/connection/transport.js.map +1 -1
- package/connection/withdrawal.d.ts +2 -0
- package/connection/withdrawal.d.ts.map +1 -0
- package/connection/withdrawal.js +23 -0
- package/connection/withdrawal.js.map +1 -0
- package/consume.js +213 -47
- package/consume.js.map +1 -1
- package/cover.d.ts +59 -0
- package/cover.d.ts.map +1 -0
- package/cover.js +375 -0
- package/cover.js.map +1 -0
- package/datagram.d.ts +70 -11
- package/datagram.d.ts.map +1 -1
- package/datagram.js +317 -2
- package/datagram.js.map +1 -1
- package/datagram_stream.d.ts +18 -0
- package/datagram_stream.d.ts.map +1 -0
- package/datagram_stream.js +67 -0
- package/datagram_stream.js.map +1 -0
- package/defined.test-util.d.ts +2 -0
- package/defined.test-util.d.ts.map +1 -0
- package/defined.test-util.js +7 -0
- package/defined.test-util.js.map +1 -0
- package/delivered.d.ts +75 -0
- package/delivered.d.ts.map +1 -0
- package/delivered.js +228 -0
- package/delivered.js.map +1 -0
- package/demand.d.ts +173 -0
- package/demand.d.ts.map +1 -0
- package/demand.js +582 -0
- package/demand.js.map +1 -0
- package/drops.d.ts +93 -0
- package/drops.d.ts.map +1 -0
- package/drops.js +283 -0
- package/drops.js.map +1 -0
- package/error.d.ts +120 -21
- package/error.d.ts.map +1 -1
- package/error.js +230 -38
- package/error.js.map +1 -1
- package/errors.d.ts +2 -2
- package/errors.d.ts.map +1 -1
- package/errors.js +2 -3
- package/errors.js.map +1 -1
- package/fill.d.ts +174 -0
- package/fill.d.ts.map +1 -0
- package/fill.js +760 -0
- package/fill.js.map +1 -0
- package/flate/decoder.d.ts +2 -0
- package/flate/decoder.d.ts.map +1 -0
- package/flate/decoder.js +63 -0
- package/flate/decoder.js.map +1 -0
- package/flate/encoder.d.ts +2 -0
- package/flate/encoder.d.ts.map +1 -0
- package/flate/encoder.js +64 -0
- package/flate/encoder.js.map +1 -0
- package/flate/group.d.ts +34 -0
- package/flate/group.d.ts.map +1 -0
- package/flate/group.js +140 -0
- package/flate/group.js.map +1 -0
- package/frame.d.ts +80 -0
- package/frame.d.ts.map +1 -0
- package/frame.js +296 -0
- package/frame.js.map +1 -0
- package/frame.test-util.d.ts +5 -0
- package/frame.test-util.d.ts.map +1 -0
- package/frame.test-util.js +9 -0
- package/frame.test-util.js.map +1 -0
- package/group.d.ts +108 -45
- package/group.d.ts.map +1 -1
- package/group.js +1616 -308
- package/group.js.map +1 -1
- package/group_api.d.ts +7 -0
- package/group_api.d.ts.map +1 -0
- package/group_api.js +7 -0
- package/group_api.js.map +1 -0
- package/hop.d.ts +62 -76
- package/hop.d.ts.map +1 -1
- package/hop.js +92 -65
- package/hop.js.map +1 -1
- package/identity.d.ts +39 -0
- package/identity.d.ts.map +1 -0
- package/identity.js +47 -0
- package/identity.js.map +1 -0
- package/ietf/active_count.d.ts +2 -0
- package/ietf/active_count.d.ts.map +1 -0
- package/ietf/active_count.js +30 -0
- package/ietf/active_count.js.map +1 -0
- package/ietf/aliases.js +69 -36
- package/ietf/aliases.js.map +1 -1
- package/ietf/cluster.d.ts +3 -3
- package/ietf/cluster.js +14 -55
- package/ietf/cluster.js.map +1 -1
- package/ietf/connection.d.ts +1 -31
- package/ietf/connection.d.ts.map +1 -1
- package/ietf/connection.js +305 -144
- package/ietf/connection.js.map +1 -1
- package/ietf/datagram.d.ts +60 -0
- package/ietf/datagram.d.ts.map +1 -0
- package/ietf/datagram.js +152 -0
- package/ietf/datagram.js.map +1 -0
- package/ietf/error.d.ts +3 -3
- package/ietf/error.js +82 -101
- package/ietf/error.js.map +1 -1
- package/ietf/fetch.d.ts +93 -37
- package/ietf/fetch.d.ts.map +1 -1
- package/ietf/fetch.js +172 -94
- package/ietf/fetch.js.map +1 -1
- package/ietf/filter.d.ts +21 -31
- package/ietf/filter.d.ts.map +1 -1
- package/ietf/filter.js +140 -172
- package/ietf/filter.js.map +1 -1
- package/ietf/goaway.d.ts +12 -10
- package/ietf/goaway.d.ts.map +1 -1
- package/ietf/goaway.js +22 -36
- package/ietf/goaway.js.map +1 -1
- package/ietf/hidden.js +1 -2
- package/ietf/hidden.js.map +1 -1
- package/ietf/index.d.ts +8 -20
- package/ietf/index.d.ts.map +1 -1
- package/ietf/index.js +4 -15
- package/ietf/index.js.map +1 -1
- package/ietf/join.d.ts +7 -0
- package/ietf/join.d.ts.map +1 -0
- package/ietf/join.js +234 -0
- package/ietf/join.js.map +1 -0
- package/ietf/message.d.ts +18 -2
- package/ietf/message.d.ts.map +1 -1
- package/ietf/message.js +60 -41
- package/ietf/message.js.map +1 -1
- package/ietf/message.test-util.d.ts +6 -0
- package/ietf/message.test-util.d.ts.map +1 -0
- package/ietf/message.test-util.js +13 -0
- package/ietf/message.test-util.js.map +1 -0
- package/ietf/namespace.d.ts +19 -5
- package/ietf/namespace.d.ts.map +1 -1
- package/ietf/namespace.js +78 -27
- package/ietf/namespace.js.map +1 -1
- package/ietf/object.d.ts +195 -33
- package/ietf/object.d.ts.map +1 -1
- package/ietf/object.js +405 -179
- package/ietf/object.js.map +1 -1
- package/ietf/parameters.d.ts +25 -45
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +260 -473
- package/ietf/parameters.js.map +1 -1
- package/ietf/priority.d.ts +17 -2
- package/ietf/priority.d.ts.map +1 -1
- package/ietf/priority.js +19 -5
- package/ietf/priority.js.map +1 -1
- package/ietf/properties.d.ts +6 -5
- package/ietf/properties.d.ts.map +1 -1
- package/ietf/properties.js +78 -49
- package/ietf/properties.js.map +1 -1
- package/ietf/publish.d.ts +25 -33
- package/ietf/publish.d.ts.map +1 -1
- package/ietf/publish.js +45 -140
- package/ietf/publish.js.map +1 -1
- package/ietf/publish_namespace.d.ts +49 -72
- package/ietf/publish_namespace.d.ts.map +1 -1
- package/ietf/publish_namespace.js +66 -185
- package/ietf/publish_namespace.js.map +1 -1
- package/ietf/publisher.js +1800 -601
- package/ietf/publisher.js.map +1 -1
- package/ietf/range.d.ts +2 -0
- package/ietf/range.d.ts.map +1 -0
- package/ietf/range.js +222 -0
- package/ietf/range.js.map +1 -0
- package/ietf/request.d.ts +6 -30
- package/ietf/request.d.ts.map +1 -1
- package/ietf/request.js +41 -79
- package/ietf/request.js.map +1 -1
- package/ietf/request_stream.d.ts +1 -6
- package/ietf/request_stream.d.ts.map +1 -1
- package/ietf/request_stream.js +306 -17
- package/ietf/request_stream.js.map +1 -1
- package/ietf/session.d.ts +41 -0
- package/ietf/session.d.ts.map +1 -0
- package/ietf/session.js +65 -0
- package/ietf/session.js.map +1 -0
- package/ietf/setup.d.ts +5 -30
- package/ietf/setup.d.ts.map +1 -1
- package/ietf/setup.js +6 -118
- package/ietf/setup.js.map +1 -1
- package/ietf/setup_options.d.ts +31 -0
- package/ietf/setup_options.d.ts.map +1 -0
- package/ietf/setup_options.js +138 -0
- package/ietf/setup_options.js.map +1 -0
- package/ietf/solicit.js +4 -15
- package/ietf/solicit.js.map +1 -1
- package/ietf/subscribe.d.ts +52 -45
- package/ietf/subscribe.d.ts.map +1 -1
- package/ietf/subscribe.js +118 -240
- package/ietf/subscribe.js.map +1 -1
- package/ietf/subscribe_namespace.d.ts +16 -79
- package/ietf/subscribe_namespace.d.ts.map +1 -1
- package/ietf/subscribe_namespace.js +30 -202
- package/ietf/subscribe_namespace.js.map +1 -1
- package/ietf/subscriber.js +1839 -537
- package/ietf/subscriber.js.map +1 -1
- package/ietf/token.js +105 -28
- package/ietf/token.js.map +1 -1
- package/ietf/track.d.ts +27 -24
- package/ietf/track.d.ts.map +1 -1
- package/ietf/track.js +48 -62
- package/ietf/track.js.map +1 -1
- package/ietf/version.d.ts +13 -42
- package/ietf/version.d.ts.map +1 -1
- package/ietf/version.js +22 -49
- package/ietf/version.js.map +1 -1
- package/implementation.d.ts +2 -0
- package/implementation.d.ts.map +1 -0
- package/implementation.js +5 -0
- package/implementation.js.map +1 -0
- package/index.d.ts +34 -19
- package/index.d.ts.map +1 -1
- package/index.js +19 -7
- package/index.js.map +1 -1
- package/internal.d.ts +1515 -67
- package/internal.d.ts.map +1 -1
- package/internal.js +557 -80
- package/internal.js.map +1 -1
- package/ledger.d.ts +23 -0
- package/ledger.d.ts.map +1 -0
- package/ledger.js +247 -0
- package/ledger.js.map +1 -0
- package/listing.d.ts +132 -0
- package/listing.d.ts.map +1 -0
- package/listing.js +486 -0
- package/listing.js.map +1 -0
- package/lite/announce.d.ts +127 -66
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +384 -159
- package/lite/announce.js.map +1 -1
- package/lite/announce_stream.d.ts +2 -0
- package/lite/announce_stream.d.ts.map +1 -0
- package/lite/announce_stream.js +92 -0
- package/lite/announce_stream.js.map +1 -0
- package/lite/answer.d.ts +22 -0
- package/lite/answer.d.ts.map +1 -0
- package/lite/answer.js +301 -0
- package/lite/answer.js.map +1 -0
- package/lite/auth.d.ts +45 -0
- package/lite/auth.d.ts.map +1 -0
- package/lite/auth.js +204 -0
- package/lite/auth.js.map +1 -0
- package/lite/compat.d.ts +31 -0
- package/lite/compat.d.ts.map +1 -0
- package/lite/compat.js +86 -0
- package/lite/compat.js.map +1 -0
- package/lite/connection.d.ts +1 -45
- package/lite/connection.d.ts.map +1 -1
- package/lite/connection.js +360 -78
- package/lite/connection.js.map +1 -1
- package/lite/datagram-end.d.ts +26 -0
- package/lite/datagram-end.d.ts.map +1 -0
- package/lite/datagram-end.js +30 -0
- package/lite/datagram-end.js.map +1 -0
- package/lite/datagram.d.ts +73 -8
- package/lite/datagram.d.ts.map +1 -1
- package/lite/datagram.js +144 -10
- package/lite/datagram.js.map +1 -1
- package/lite/duration.d.ts +6 -0
- package/lite/duration.d.ts.map +1 -0
- package/lite/duration.js +14 -0
- package/lite/duration.js.map +1 -0
- package/lite/error.d.ts +9 -0
- package/lite/error.d.ts.map +1 -0
- package/lite/error.js +24 -0
- package/lite/error.js.map +1 -0
- package/lite/fills.d.ts +162 -0
- package/lite/fills.d.ts.map +1 -0
- package/lite/fills.js +486 -0
- package/lite/fills.js.map +1 -0
- package/lite/fit.d.ts +49 -0
- package/lite/fit.d.ts.map +1 -0
- package/lite/fit.js +305 -0
- package/lite/fit.js.map +1 -0
- package/lite/goaway.d.ts +2 -2
- package/lite/goaway.d.ts.map +1 -1
- package/lite/goaway.js +5 -14
- package/lite/goaway.js.map +1 -1
- package/lite/group.d.ts +67 -16
- package/lite/group.d.ts.map +1 -1
- package/lite/group.js +108 -31
- package/lite/group.js.map +1 -1
- package/lite/identity.d.ts +25 -0
- package/lite/identity.d.ts.map +1 -0
- package/lite/identity.js +79 -0
- package/lite/identity.js.map +1 -0
- package/lite/index.d.ts +14 -13
- package/lite/index.d.ts.map +1 -1
- package/lite/index.js +2 -2
- package/lite/index.js.map +1 -1
- package/lite/message.d.ts +10 -2
- package/lite/message.d.ts.map +1 -1
- package/lite/message.js +28 -45
- package/lite/message.js.map +1 -1
- package/lite/priority.d.ts +9 -2
- package/lite/priority.d.ts.map +1 -1
- package/lite/priority.js +11 -106
- package/lite/priority.js.map +1 -1
- package/lite/probe.d.ts +2 -2
- package/lite/probe.d.ts.map +1 -1
- package/lite/probe.js +9 -1
- package/lite/probe.js.map +1 -1
- package/lite/publisher.d.ts +10 -1
- package/lite/publisher.d.ts.map +1 -1
- package/lite/publisher.js +2548 -438
- package/lite/publisher.js.map +1 -1
- package/lite/routed.d.ts +59 -0
- package/lite/routed.d.ts.map +1 -0
- package/lite/routed.js +564 -0
- package/lite/routed.js.map +1 -0
- package/lite/session.d.ts +2 -28
- package/lite/session.d.ts.map +1 -1
- package/lite/session.js +0 -100
- package/lite/session.js.map +1 -1
- package/lite/setup.d.ts +32 -5
- package/lite/setup.d.ts.map +1 -1
- package/lite/setup.js +95 -22
- package/lite/setup.js.map +1 -1
- package/lite/stream.d.ts +5 -11
- package/lite/stream.d.ts.map +1 -1
- package/lite/stream.js +5 -2
- package/lite/stream.js.map +1 -1
- package/lite/subscribe.d.ts +478 -78
- package/lite/subscribe.d.ts.map +1 -1
- package/lite/subscribe.js +1373 -143
- package/lite/subscribe.js.map +1 -1
- package/lite/subscriber.d.ts +7 -44
- package/lite/subscriber.d.ts.map +1 -1
- package/lite/subscriber.js +3290 -516
- package/lite/subscriber.js.map +1 -1
- package/lite/track.d.ts +27 -12
- package/lite/track.d.ts.map +1 -1
- package/lite/track.js +116 -38
- package/lite/track.js.map +1 -1
- package/lite/tracks.d.ts +55 -0
- package/lite/tracks.d.ts.map +1 -0
- package/lite/tracks.js +114 -0
- package/lite/tracks.js.map +1 -0
- package/lite/version.d.ts +132 -24
- package/lite/version.d.ts.map +1 -1
- package/lite/version.js +378 -34
- package/lite/version.js.map +1 -1
- package/meta.d.ts +77 -0
- package/meta.d.ts.map +1 -0
- package/meta.js +130 -0
- package/meta.js.map +1 -0
- package/meta_api.d.ts +7 -0
- package/meta_api.d.ts.map +1 -0
- package/meta_api.js +7 -0
- package/meta_api.js.map +1 -0
- package/mint.d.ts +28 -0
- package/mint.d.ts.map +1 -0
- package/mint.js +66 -0
- package/mint.js.map +1 -0
- package/open.d.ts +63 -0
- package/open.d.ts.map +1 -0
- package/open.js +250 -0
- package/open.js.map +1 -0
- package/origin.d.ts +394 -142
- package/origin.d.ts.map +1 -1
- package/origin.js +2533 -687
- package/origin.js.map +1 -1
- package/package.json +8 -13
- package/path.d.ts +51 -51
- package/path.d.ts.map +1 -1
- package/path.js +210 -58
- package/path.js.map +1 -1
- package/payload.d.ts +33 -0
- package/payload.d.ts.map +1 -0
- package/payload.js +65 -0
- package/payload.js.map +1 -0
- package/prefix.d.ts +152 -0
- package/prefix.d.ts.map +1 -0
- package/prefix.js +349 -0
- package/prefix.js.map +1 -0
- package/priority.d.ts +8 -0
- package/priority.d.ts.map +1 -0
- package/priority.js +185 -0
- package/priority.js.map +1 -0
- package/queue.d.ts +2 -0
- package/queue.d.ts.map +1 -0
- package/queue.js +46 -0
- package/queue.js.map +1 -0
- package/ranges.d.ts +36 -0
- package/ranges.d.ts.map +1 -0
- package/ranges.js +312 -0
- package/ranges.js.map +1 -0
- package/rescale.d.ts +24 -0
- package/rescale.d.ts.map +1 -0
- package/rescale.js +39 -0
- package/rescale.js.map +1 -0
- package/resume.d.ts +55 -0
- package/resume.d.ts.map +1 -0
- package/resume.js +4173 -0
- package/resume.js.map +1 -0
- package/resume.test-util.d.ts +2 -0
- package/resume.test-util.d.ts.map +1 -0
- package/resume.test-util.js +25 -0
- package/resume.test-util.js.map +1 -0
- package/skips.d.ts +48 -0
- package/skips.d.ts.map +1 -0
- package/skips.js +182 -0
- package/skips.js.map +1 -0
- package/stream.d.ts +78 -40
- package/stream.d.ts.map +1 -1
- package/stream.js +236 -93
- package/stream.js.map +1 -1
- package/subscription.test-util.d.ts +2 -0
- package/subscription.test-util.d.ts.map +1 -0
- package/subscription.test-util.js +49 -0
- package/subscription.test-util.js.map +1 -0
- package/tail.d.ts +23 -14
- package/tail.d.ts.map +1 -1
- package/tail.js +224 -98
- package/tail.js.map +1 -1
- package/time.d.ts +41 -102
- package/time.d.ts.map +1 -1
- package/time.js +129 -92
- package/time.js.map +1 -1
- package/timed.d.ts +21 -0
- package/timed.d.ts.map +1 -0
- package/timed.js +2 -0
- package/timed.js.map +1 -0
- package/track.d.ts +578 -246
- package/track.d.ts.map +1 -1
- package/track.js +7306 -772
- package/track.js.map +1 -1
- package/track_api.d.ts +7 -0
- package/track_api.d.ts.map +1 -0
- package/track_api.js +7 -0
- package/track_api.js.map +1 -0
- package/util/abort.d.ts +1 -0
- package/util/abort.d.ts.map +1 -1
- package/util/abort.js +23 -2
- package/util/abort.js.map +1 -1
- package/util/announce.d.ts +4 -0
- package/util/announce.d.ts.map +1 -0
- package/util/announce.js +11 -0
- package/util/announce.js.map +1 -0
- package/util/bigint.d.ts +3 -0
- package/util/bigint.d.ts.map +1 -0
- package/util/bigint.js +8 -0
- package/util/bigint.js.map +1 -0
- package/util/change.d.ts +12 -0
- package/util/change.d.ts.map +1 -0
- package/util/change.js +18 -0
- package/util/change.js.map +1 -0
- package/util/deadline.d.ts +2 -0
- package/util/deadline.d.ts.map +1 -0
- package/util/deadline.js +108 -0
- package/util/deadline.js.map +1 -0
- package/util/decode_error.d.ts +3 -0
- package/util/decode_error.d.ts.map +1 -0
- package/util/decode_error.js +11 -0
- package/util/decode_error.js.map +1 -0
- package/util/demand.d.ts +8 -0
- package/util/demand.d.ts.map +1 -0
- package/util/demand.js +24 -0
- package/util/demand.js.map +1 -0
- package/util/given_up.d.ts +2 -0
- package/util/given_up.d.ts.map +1 -0
- package/util/given_up.js +101 -0
- package/util/given_up.js.map +1 -0
- package/util/hex.d.ts +6 -0
- package/util/hex.d.ts.map +1 -1
- package/util/hex.js +19 -5
- package/util/hex.js.map +1 -1
- package/util/key.d.ts +15 -0
- package/util/key.d.ts.map +1 -0
- package/util/key.js +38 -0
- package/util/key.js.map +1 -0
- package/util/limits.d.ts +2 -0
- package/util/limits.d.ts.map +1 -0
- package/util/limits.js +76 -0
- package/util/limits.js.map +1 -0
- package/util/observed.d.ts +23 -0
- package/util/observed.d.ts.map +1 -0
- package/util/observed.js +122 -0
- package/util/observed.js.map +1 -0
- package/util/sorted.d.ts +2 -0
- package/util/sorted.d.ts.map +1 -0
- package/util/sorted.js +149 -0
- package/util/sorted.js.map +1 -0
- package/util/timeout.d.ts +2 -1
- package/util/timeout.d.ts.map +1 -1
- package/util/timeout.js +13 -10
- package/util/timeout.js.map +1 -1
- package/util/timer.d.ts +2 -0
- package/util/timer.d.ts.map +1 -0
- package/util/timer.js +19 -0
- package/util/timer.js.map +1 -0
- package/util/u64.js +0 -1
- package/util/utf8.d.ts +2 -0
- package/util/utf8.d.ts.map +1 -1
- package/util/utf8.js +7 -2
- package/util/utf8.js.map +1 -1
- package/util/varint.d.ts.map +1 -1
- package/util/varint.js +8 -2
- package/util/varint.js.map +1 -1
- package/util/watch.d.ts +8 -0
- package/util/watch.d.ts.map +1 -0
- package/util/watch.js +38 -0
- package/util/watch.js.map +1 -0
- package/util/yield.d.ts +2 -0
- package/util/yield.d.ts.map +1 -0
- package/util/yield.js +31 -0
- package/util/yield.js.map +1 -0
- package/varint.d.ts +0 -29
- package/varint.d.ts.map +1 -1
- package/varint.js +7 -29
- package/varint.js.map +1 -1
- package/varint_api.d.ts +7 -0
- package/varint_api.d.ts.map +1 -0
- package/varint_api.js +7 -0
- package/varint_api.js.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +4 -0
- package/version.js.map +1 -0
- package/window.d.ts +570 -0
- package/window.d.ts.map +1 -0
- package/window.js +1677 -0
- package/window.js.map +1 -0
- package/wire.d.ts +150 -35
- package/wire.d.ts.map +1 -1
- package/wire.js +27 -1
- package/wire.js.map +1 -1
- package/connection/established.d.ts +0 -53
- package/connection/established.d.ts.map +0 -1
- package/connection/established.js +0 -3
- package/connection/established.js.map +0 -1
- package/ietf/adapter.d.ts +0 -75
- package/ietf/adapter.d.ts.map +0 -1
- package/ietf/adapter.js +0 -700
- package/ietf/adapter.js.map +0 -1
- package/lite/datagram_stream.d.ts +0 -8
- package/lite/datagram_stream.d.ts.map +0 -1
- package/lite/datagram_stream.js +0 -44
- package/lite/datagram_stream.js.map +0 -1
- package/lite/fetch.d.ts +0 -28
- package/lite/fetch.d.ts.map +0 -1
- package/lite/fetch.js +0 -79
- package/lite/fetch.js.map +0 -1
- package/util/log.d.ts +0 -5
- package/util/log.d.ts.map +0 -1
- package/util/log.js +0 -17
- package/util/log.js.map +0 -1
- package/zod.d.ts +0 -13
- package/zod.d.ts.map +0 -1
- package/zod.js +0 -19
- package/zod.js.map +0 -1
package/connection/pool.js
CHANGED
|
@@ -1,49 +1,55 @@
|
|
|
1
|
-
/* @ts-self-types="./pool.d.ts" */
|
|
2
1
|
/**
|
|
3
|
-
* A reconnecting, shareable connection: one origin and
|
|
2
|
+
* A reconnecting, shareable connection: one origin and reconnect loop per URL and version list.
|
|
4
3
|
*
|
|
5
4
|
* @module
|
|
6
5
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
6
|
+
import { Duration } from "@moq/clock";
|
|
7
|
+
import { Derived, Effect, Once, Signal } from "@moq/signals";
|
|
8
|
+
import { Producer as AnnounceProducer, list } from "../announced.js";
|
|
9
9
|
import * as Origin from "../origin.js";
|
|
10
10
|
import * as Path from "../path.js";
|
|
11
|
-
import
|
|
11
|
+
import { closeUnwanted } from "../util/announce.js";
|
|
12
|
+
import { Follow } from "../util/observed.js";
|
|
13
|
+
import { after } from "../util/timer.js";
|
|
12
14
|
import { accept } from "./accept.js";
|
|
13
15
|
import { isWebTransportSupported } from "./browser.js";
|
|
14
|
-
import { certificateHash, connect, } from "./connect.js";
|
|
15
|
-
import {
|
|
16
|
+
import { certificateHash, checkVersions, connect, normalizeVersions, } from "./connect.js";
|
|
17
|
+
import { Dials as DialsClass } from "./dials.js";
|
|
18
|
+
import { DISCOVERY_REMOVED } from "./forward.js";
|
|
19
|
+
import { pumpAnnounced, Reload } from "./reload.js";
|
|
16
20
|
/** How long an unreferenced shared connection lingers before it actually closes. */
|
|
17
|
-
const
|
|
21
|
+
const LINGER = Duration.millis(2000);
|
|
18
22
|
/**
|
|
19
23
|
* A cloneable handle on a MoQ connection: `new Connection({ url })` reconnects and, by
|
|
20
|
-
* default, shares one origin and
|
|
24
|
+
* default, shares one origin and reconnect loop with handles using the same URL and versions.
|
|
21
25
|
*
|
|
22
26
|
* The shared {@link origin} is wired to both directions. Everything the relay announces
|
|
23
27
|
* lands in it, a publish into it is announced to the relay, and a page that publishes and
|
|
24
28
|
* watches the same path resolves it locally with no round trip.
|
|
25
29
|
*
|
|
26
|
-
* {@link close} releases this handle; the connection survives its last handle by a
|
|
27
|
-
* linger window
|
|
28
|
-
* reuses the warm connection instead of redialing.
|
|
30
|
+
* {@link close} releases this handle; the connection survives its last handle by a two-second
|
|
31
|
+
* linger window, so a component torn down and rebuilt reuses the warm connection instead of redialing.
|
|
29
32
|
*
|
|
30
33
|
* The loop reconnects for as long as a handle holds it, so an outage of any length recovers
|
|
31
34
|
* on its own. An auth rejection stops retrying those credentials and retires the shared
|
|
32
35
|
* connection so the next handle dials fresh; a new URL on this handle starts another
|
|
33
|
-
*
|
|
36
|
+
* key. {@link closed} settles only when this handle is released.
|
|
34
37
|
*
|
|
35
38
|
* A relay's GOAWAY migrates rather than drops: the replacement dials at once while the old
|
|
36
39
|
* session finishes its groups, and the handle and its origin carry across. A redirect the
|
|
37
|
-
*
|
|
40
|
+
* `goaway` policy refuses stops the loop like an auth rejection does.
|
|
38
41
|
*
|
|
39
|
-
* Options the pool cannot honor (transport options,
|
|
40
|
-
* certificate, caller-owned origins) use a private loop. An explicit `share: true`
|
|
42
|
+
* Options the pool cannot honor (transport options, backoff, timeout, goaway, tokens, a credential
|
|
43
|
+
* in the URL, a pinned certificate, caller-owned origins) use a private loop. An explicit `share: true`
|
|
41
44
|
* refuses them. A supplied transport cannot reconnect at all; pass it to {@link Connection.connect}
|
|
42
45
|
* instead.
|
|
43
46
|
*
|
|
44
47
|
* @public
|
|
45
48
|
*/
|
|
46
49
|
export class Connection {
|
|
50
|
+
/** Tokens a connection asks for at each dial: pass one as `tokens` and answer its {@link Dials.next} dials. */
|
|
51
|
+
// fallow-ignore-next-line unused-class-member
|
|
52
|
+
static Dials = DialsClass;
|
|
47
53
|
/** Establish a one-shot session; a supplied transport belongs here, not in the reconnect loop. */
|
|
48
54
|
static connect = connect;
|
|
49
55
|
/** Accept a one-shot session on an already-open transport. */
|
|
@@ -52,8 +58,12 @@ export class Connection {
|
|
|
52
58
|
static certificateHash = certificateHash;
|
|
53
59
|
/** Whether this runtime can connect with WebTransport. */
|
|
54
60
|
static isWebTransportSupported = isWebTransportSupported;
|
|
61
|
+
/** Copy a version list that can be offered, throwing a `TypeError` if it is empty or has an unsupported or duplicate name. */
|
|
62
|
+
static checkVersions = checkVersions;
|
|
55
63
|
/** Relay URL to connect to; updating it reconnects to that URL. */
|
|
56
64
|
url;
|
|
65
|
+
/** Protocol versions to offer, or undefined for the defaults; updating it reconnects with that list. */
|
|
66
|
+
versions;
|
|
57
67
|
/** Whether to hold a connection at all; clearing it releases this handle's share. */
|
|
58
68
|
enabled;
|
|
59
69
|
/** Current status of the connection. */
|
|
@@ -61,10 +71,16 @@ export class Connection {
|
|
|
61
71
|
/**
|
|
62
72
|
* The failure that stopped retrying the current URL, or undefined while the loop is live.
|
|
63
73
|
*
|
|
64
|
-
* Set on an auth rejection
|
|
65
|
-
*
|
|
74
|
+
* Set on an auth rejection, when a private retry window expires, or when {@link versions} names
|
|
75
|
+
* one this build cannot offer. Cleared when a new URL or version list, or a disable/re-enable,
|
|
76
|
+
* starts another key, not on a page hide/show.
|
|
66
77
|
*/
|
|
67
78
|
error;
|
|
79
|
+
/**
|
|
80
|
+
* Why the connection is retrying: how its last attempt or session ended, cleared once a
|
|
81
|
+
* session serves again or a new URL starts. Mirrors Rust's `Monitor::failure()`.
|
|
82
|
+
*/
|
|
83
|
+
failure;
|
|
68
84
|
/**
|
|
69
85
|
* The wire transport the current session runs over, or undefined while disconnected.
|
|
70
86
|
*
|
|
@@ -72,17 +88,29 @@ export class Connection {
|
|
|
72
88
|
* or reconfigure it, and everything else it offers is reachable through {@link origin}.
|
|
73
89
|
*/
|
|
74
90
|
transport;
|
|
75
|
-
/**
|
|
91
|
+
/** Receive estimates while observed, or undefined while disconnected; peek does not request them. */
|
|
76
92
|
probe;
|
|
93
|
+
/** The latest transport counters, sampled while observed on a connection supporting getStats. */
|
|
94
|
+
sample;
|
|
95
|
+
/** The current session's liveness, or undefined on a transport that can't probe its peer (WebTransport, qmux-00) or while disconnected. */
|
|
96
|
+
liveness;
|
|
77
97
|
/**
|
|
78
98
|
* The send-side bandwidth allocator for the current URL, or undefined
|
|
79
99
|
* while disabled or URL-less.
|
|
80
100
|
*
|
|
81
|
-
* Every handle on this URL shares the same
|
|
101
|
+
* Every handle on this URL shares the same identity, so publishers reserve
|
|
82
102
|
* against one registry. Borrowed, not owned: the type has no close, since
|
|
83
103
|
* closing it would starve every other handle.
|
|
84
104
|
*/
|
|
85
|
-
|
|
105
|
+
allocator;
|
|
106
|
+
/**
|
|
107
|
+
* The receive-side registry for the current URL, or undefined while disabled or URL-less.
|
|
108
|
+
*
|
|
109
|
+
* Every handle on this URL shares the same identity, so players watching over one
|
|
110
|
+
* connection split its receive estimate instead of each selecting against all of it,
|
|
111
|
+
* and their ceilings summed are the PROBE target. Borrowed, not owned: it has no close.
|
|
112
|
+
*/
|
|
113
|
+
viewers;
|
|
86
114
|
/**
|
|
87
115
|
* The origin for the current URL, or undefined while disabled or URL-less.
|
|
88
116
|
*
|
|
@@ -92,6 +120,16 @@ export class Connection {
|
|
|
92
120
|
* every other handle.
|
|
93
121
|
*/
|
|
94
122
|
origin;
|
|
123
|
+
/**
|
|
124
|
+
* The auth handle every session presents, or undefined while disabled or URL-less.
|
|
125
|
+
*
|
|
126
|
+
* Every session the connection makes presents the tokens it holds, so a route naming one
|
|
127
|
+
* keeps it across a reconnect, and its grant follows the live session. A private
|
|
128
|
+
* connection keeps one handle across URL changes, so its tokens go to the new URL, and
|
|
129
|
+
* starts another when `versions` changes. A shared connection's is the one every other
|
|
130
|
+
* handle on its URL uses, since they share the session.
|
|
131
|
+
*/
|
|
132
|
+
auth;
|
|
95
133
|
/**
|
|
96
134
|
* Settles once this handle is released via {@link close}: `null` on a clean close, or
|
|
97
135
|
* the abort {@link Error}. Peek it synchronously (`undefined` while open), observe it
|
|
@@ -101,15 +139,21 @@ export class Connection {
|
|
|
101
139
|
return this.#closed;
|
|
102
140
|
}
|
|
103
141
|
#closed = new Once();
|
|
142
|
+
// Ended with this handle, so whoever answers its dials stops.
|
|
143
|
+
#dials;
|
|
104
144
|
#status = new Signal("disconnected");
|
|
105
145
|
#established = new Signal(undefined);
|
|
106
146
|
#probe = new Signal(undefined);
|
|
107
147
|
#origin = new Signal(undefined);
|
|
108
|
-
#
|
|
148
|
+
#allocator = new Signal(undefined);
|
|
149
|
+
#viewers = new Signal(undefined);
|
|
150
|
+
#auth = new Signal(undefined);
|
|
151
|
+
#loop = new Signal(undefined);
|
|
109
152
|
#error = new Signal(undefined);
|
|
153
|
+
#failure = new Signal(undefined);
|
|
110
154
|
#signals;
|
|
111
155
|
/**
|
|
112
|
-
* Take a handle on the connection for
|
|
156
|
+
* Take a handle on the connection for the `url` option.
|
|
113
157
|
*
|
|
114
158
|
* Dials immediately when a URL is given and `enabled` is not false; otherwise waits for
|
|
115
159
|
* the signals to say go. The handle owns nothing but its own share: {@link close}
|
|
@@ -117,22 +161,42 @@ export class Connection {
|
|
|
117
161
|
* (plus the linger window) wants them.
|
|
118
162
|
*/
|
|
119
163
|
constructor(props) {
|
|
164
|
+
const given = props?.versions;
|
|
165
|
+
// A plain list is checked and copied now, so a bad name throws here and mutating the array
|
|
166
|
+
// later changes nothing. A live list is checked as it changes, failing on `error`.
|
|
167
|
+
const fixed = normalizeVersions({ ...props, versions: Array.isArray(given) ? given : undefined });
|
|
120
168
|
refuse(props);
|
|
121
169
|
this.#signals = new Effect();
|
|
170
|
+
if (props?.tokens instanceof DialsClass) {
|
|
171
|
+
// One connection answers them: another would sign for this one's dials.
|
|
172
|
+
if (props.tokens.claimed)
|
|
173
|
+
throw new TypeError("these dials already serve another connection");
|
|
174
|
+
this.#dials = props.tokens;
|
|
175
|
+
}
|
|
122
176
|
this.url = Signal.from(props?.url);
|
|
177
|
+
this.versions = Signal.from(Array.isArray(given) ? fixed : given);
|
|
123
178
|
this.enabled = Signal.from(props?.enabled ?? true);
|
|
124
179
|
this.status = this.#status;
|
|
125
180
|
this.error = this.#error;
|
|
126
|
-
this.
|
|
181
|
+
this.failure = this.#failure;
|
|
182
|
+
this.probe = new Follow(this.#probe);
|
|
183
|
+
this.sample = new Follow(new Derived([this.#loop], (loop) => loop?.sample));
|
|
127
184
|
this.origin = this.#origin;
|
|
128
|
-
this.
|
|
185
|
+
this.allocator = this.#allocator;
|
|
186
|
+
this.viewers = this.#viewers;
|
|
187
|
+
this.auth = this.#auth;
|
|
129
188
|
this.transport = this.#signals.computed((effect) => effect.get(this.#established)?.transport);
|
|
130
|
-
|
|
189
|
+
this.liveness = this.#signals.computed((effect) => {
|
|
190
|
+
const liveness = effect.get(this.#established)?.liveness;
|
|
191
|
+
return liveness && effect.get(liveness);
|
|
192
|
+
});
|
|
131
193
|
// Key on the serialized URL: URL objects use identity equality, and an equivalent
|
|
132
194
|
// instance must not release and redial.
|
|
133
195
|
const href = this.#signals.computed((effect) => effect.get(this.url)?.href);
|
|
134
196
|
if (props && (props.share === false || requiresPrivate(props))) {
|
|
135
197
|
this.#runPrivate(props, href);
|
|
198
|
+
// Only once nothing above threw, so a rejected config leaves the dials free.
|
|
199
|
+
this.#dials?.claim();
|
|
136
200
|
return;
|
|
137
201
|
}
|
|
138
202
|
this.#signals.run((effect) => {
|
|
@@ -141,15 +205,24 @@ export class Connection {
|
|
|
141
205
|
const key = effect.get(href);
|
|
142
206
|
if (!key)
|
|
143
207
|
return;
|
|
144
|
-
const
|
|
208
|
+
const versions = offered(effect.get(this.versions));
|
|
209
|
+
if (versions instanceof TypeError) {
|
|
210
|
+
effect.set(this.#error, versions, undefined);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const lease = acquire(key, versions);
|
|
145
214
|
effect.cleanup(lease.release);
|
|
146
215
|
effect.set(this.#origin, lease.origin, undefined);
|
|
147
|
-
effect.set(this.#
|
|
216
|
+
effect.set(this.#allocator, lease.connection.allocator, undefined);
|
|
217
|
+
effect.set(this.#viewers, lease.connection.viewers, undefined);
|
|
218
|
+
effect.set(this.#auth, lease.connection.auth, undefined);
|
|
219
|
+
effect.set(this.#loop, lease.connection, undefined);
|
|
148
220
|
// Proxy the shared loop's outputs, so this handle reads like its own connection.
|
|
149
221
|
effect.run((nested) => nested.set(this.#status, nested.get(lease.connection.status), "disconnected"));
|
|
150
222
|
effect.run((nested) => nested.set(this.#established, nested.get(lease.connection.established), undefined));
|
|
151
|
-
effect.run((nested) => nested.set(this.#probe,
|
|
223
|
+
effect.run((nested) => nested.set(this.#probe, lease.connection.probe, undefined));
|
|
152
224
|
effect.run((nested) => nested.set(this.#error, nested.get(lease.connection.error), undefined));
|
|
225
|
+
effect.run((nested) => nested.set(this.#failure, nested.get(lease.connection.failure), undefined));
|
|
153
226
|
});
|
|
154
227
|
}
|
|
155
228
|
#runPrivate(props, href) {
|
|
@@ -157,101 +230,177 @@ export class Connection {
|
|
|
157
230
|
const origin = props.consume ?? new Origin.Producer();
|
|
158
231
|
if (owned)
|
|
159
232
|
this.#signals.cleanup(() => origin.close());
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
});
|
|
173
|
-
this.#signals.cleanup(() => loop.close());
|
|
174
|
-
this.#signals.run((effect) => {
|
|
175
|
-
if (!effect.get(this.enabled) || !effect.get(href))
|
|
233
|
+
const publish = props.publish ?? (owned ? origin.consume() : undefined);
|
|
234
|
+
// The origin spans version changes; only the loop dialing it is replaced. Each loop is built
|
|
235
|
+
// synchronously, not in an effect a microtask later, so its hold on `consume` is in place
|
|
236
|
+
// before a watcher created alongside could sync on an empty table.
|
|
237
|
+
let stop;
|
|
238
|
+
const start = (list) => {
|
|
239
|
+
stop?.();
|
|
240
|
+
const signals = new Effect();
|
|
241
|
+
stop = () => signals.close();
|
|
242
|
+
const versions = offered(list);
|
|
243
|
+
if (versions instanceof TypeError) {
|
|
244
|
+
signals.run((effect) => effect.set(this.#error, versions, undefined));
|
|
176
245
|
return;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
246
|
+
}
|
|
247
|
+
const loop = new Reload({
|
|
248
|
+
url: this.url,
|
|
249
|
+
enabled: this.enabled,
|
|
250
|
+
publish,
|
|
251
|
+
consume: origin,
|
|
252
|
+
versions,
|
|
253
|
+
webtransport: props.webtransport,
|
|
254
|
+
websocket: props.websocket,
|
|
255
|
+
backoff: props.backoff,
|
|
256
|
+
timeout: props.timeout,
|
|
257
|
+
cost: props.cost,
|
|
258
|
+
goaway: props.goaway,
|
|
259
|
+
tokens: props.tokens,
|
|
260
|
+
urlAuth: props.urlAuth,
|
|
261
|
+
});
|
|
262
|
+
signals.cleanup(() => loop.close());
|
|
263
|
+
signals.run((effect) => {
|
|
264
|
+
if (!effect.get(this.enabled) || !effect.get(href))
|
|
265
|
+
return;
|
|
266
|
+
effect.set(this.#origin, origin, undefined);
|
|
267
|
+
effect.set(this.#allocator, loop.allocator, undefined);
|
|
268
|
+
effect.set(this.#viewers, loop.viewers, undefined);
|
|
269
|
+
effect.set(this.#auth, loop.auth, undefined);
|
|
270
|
+
effect.set(this.#loop, loop, undefined);
|
|
271
|
+
});
|
|
272
|
+
signals.run((effect) => effect.set(this.#status, effect.get(loop.status), "disconnected"));
|
|
273
|
+
signals.run((effect) => effect.set(this.#established, effect.get(loop.established), undefined));
|
|
274
|
+
signals.run((effect) => effect.set(this.#probe, loop.probe, undefined));
|
|
275
|
+
signals.run((effect) => effect.set(this.#error, effect.get(loop.error), undefined));
|
|
276
|
+
signals.run((effect) => effect.set(this.#failure, effect.get(loop.failure), undefined));
|
|
277
|
+
};
|
|
278
|
+
start(this.versions.peek());
|
|
279
|
+
this.#signals.cleanup(this.versions.subscribe(start));
|
|
280
|
+
this.#signals.cleanup(() => stop?.());
|
|
184
281
|
}
|
|
185
282
|
/**
|
|
186
|
-
* Subscribe to broadcast announcements
|
|
283
|
+
* Subscribe to broadcast announcements at or beneath `prefix`, spanning reconnects
|
|
187
284
|
* and URL switches: a switch retracts everything from
|
|
188
285
|
* the old relay's origin, then the new one's arrivals stream in.
|
|
189
286
|
*/
|
|
190
|
-
announced(
|
|
191
|
-
|
|
287
|
+
announced(prefix = Path.empty(), options) {
|
|
288
|
+
return list(this.routes(prefix, options));
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Every route change at or beneath `prefix`, spanning reconnects like {@link announced}.
|
|
292
|
+
*
|
|
293
|
+
* @internal
|
|
294
|
+
*/
|
|
295
|
+
routes(prefix = Path.empty(), options) {
|
|
296
|
+
// Throw here: inside the effect below, a refused prefix would leave the listing open and empty.
|
|
297
|
+
Path.Prefix.parse(prefix);
|
|
298
|
+
Path.encode(prefix);
|
|
299
|
+
const producer = new AnnounceProducer();
|
|
192
300
|
const consumer = producer.consume();
|
|
193
|
-
// Closing the consumer closes the shared state, so stop appending after that.
|
|
194
|
-
let closed = false;
|
|
195
|
-
void consumer.closed.then(() => {
|
|
196
|
-
closed = true;
|
|
197
|
-
});
|
|
198
301
|
// A child of this handle's scope rather than a standalone Effect it merely cleans up
|
|
199
302
|
// after: the disposer run() hands back also drops itself from the parent, so opening
|
|
200
303
|
// and closing announcement streams repeatedly does not pile up dead pumps that live
|
|
201
304
|
// until the whole handle closes.
|
|
202
305
|
const stop = this.#signals.run((effect) => {
|
|
203
306
|
const origin = effect.get(this.#origin);
|
|
204
|
-
if (!origin)
|
|
307
|
+
if (!origin) {
|
|
308
|
+
// Like a reconnecting loop's origin: behind while enabled with nothing to deliver.
|
|
309
|
+
if (effect.get(this.enabled))
|
|
310
|
+
producer.behind();
|
|
311
|
+
else
|
|
312
|
+
producer.synced();
|
|
205
313
|
return;
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
active.set(entry.prefix, entry);
|
|
219
|
-
else
|
|
220
|
-
active.delete(entry.prefix);
|
|
221
|
-
producer.append(entry);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
finally {
|
|
225
|
-
if (!closed) {
|
|
226
|
-
for (const entry of active.values()) {
|
|
227
|
-
producer.append({ ...entry, kind: "retracted" });
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
});
|
|
314
|
+
}
|
|
315
|
+
let routes;
|
|
316
|
+
try {
|
|
317
|
+
routes = origin.routes(prefix, options);
|
|
318
|
+
}
|
|
319
|
+
catch (err) {
|
|
320
|
+
// The origin's root can still push the prefix past the wire limits: end the listing with why.
|
|
321
|
+
producer.close(err instanceof Error ? err : new Error(String(err)));
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
// A URL switch retracts what the old origin announced.
|
|
325
|
+
pumpAnnounced(effect, routes, producer);
|
|
232
326
|
});
|
|
233
|
-
|
|
327
|
+
closeUnwanted(producer);
|
|
328
|
+
void producer.closed.then(stop);
|
|
234
329
|
return consumer;
|
|
235
330
|
}
|
|
236
331
|
/** Snapshot the live connection's transport counters, or undefined while disconnected. */
|
|
332
|
+
// fallow-ignore-next-line unused-class-member
|
|
237
333
|
async stats() {
|
|
238
334
|
return this.#established.peek()?.stats();
|
|
239
335
|
}
|
|
240
336
|
/**
|
|
241
|
-
*
|
|
242
|
-
*
|
|
337
|
+
* Resolve once the peer first answers the latest {@link ConnectionProps.tokens}, as Rust's
|
|
338
|
+
* `Tokens::poll_answered` does: each token the latest set newly presented, or the initial
|
|
339
|
+
* ones before any set, is granted in band, or is the connection credential a dial carried and
|
|
340
|
+
* the peer accepted. A token the set kept, the connection credential included, counts only
|
|
341
|
+
* once the peer refuses it, and nothing is re-checked after the answer. A set replaced before
|
|
342
|
+
* its answer moves the wait to the new one, and a connection with no tokens answers at once.
|
|
343
|
+
*
|
|
344
|
+
* An app that re-signs its credential for each dial can end the connection on a refusal by
|
|
345
|
+
* aborting its {@link auth} handle, which makes the loop give up with that error.
|
|
346
|
+
*
|
|
347
|
+
* Waits while no connection is held, such as before a URL is set.
|
|
348
|
+
*
|
|
349
|
+
* @throws The peer's refusal, an `Unsupported` error when the session cannot carry a token in
|
|
350
|
+
* band, the connection's end such as an abort of its auth handle, or the failure that stopped
|
|
351
|
+
* it retrying its URL while no session answered, such as a refused first dial.
|
|
352
|
+
*/
|
|
353
|
+
async answered() {
|
|
354
|
+
for (;;) {
|
|
355
|
+
const closed = this.#closed.peek();
|
|
356
|
+
if (closed !== undefined)
|
|
357
|
+
throw closed ?? new Error("connection closed");
|
|
358
|
+
const loop = this.#loop.peek();
|
|
359
|
+
// A new loop, such as one a version change built, restarts the wait.
|
|
360
|
+
const { promise: moved, resolve } = Promise.withResolvers();
|
|
361
|
+
const stop = this.#loop.changed(() => resolve("moved"));
|
|
362
|
+
// Closing this handle ends the wait, even with no loop to notice.
|
|
363
|
+
const closing = this.#closed.changed(() => resolve("moved"));
|
|
364
|
+
try {
|
|
365
|
+
const answered = loop?.answered().then(() => "answered");
|
|
366
|
+
if ((await Promise.race(answered ? [answered, moved] : [moved])) === "answered")
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
finally {
|
|
370
|
+
stop();
|
|
371
|
+
closing();
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Release this handle. The shared connection drains and closes once its last handle is
|
|
377
|
+
* gone and the linger window passes; other handles on the URL are unaffected. Idempotent.
|
|
243
378
|
*/
|
|
244
379
|
close(abort) {
|
|
245
380
|
this.#signals.close();
|
|
381
|
+
this.#dials?.close();
|
|
246
382
|
if (this.#closed.peek() === undefined)
|
|
247
383
|
this.#closed.set(abort ?? null);
|
|
248
384
|
}
|
|
249
385
|
}
|
|
386
|
+
/** The checked copy of `versions` to dial with, or why it cannot be offered. */
|
|
387
|
+
function offered(versions) {
|
|
388
|
+
try {
|
|
389
|
+
return versions === undefined ? undefined : checkVersions(versions);
|
|
390
|
+
}
|
|
391
|
+
catch (err) {
|
|
392
|
+
if (err instanceof TypeError)
|
|
393
|
+
return err;
|
|
394
|
+
throw err;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
250
397
|
/** Throw if `props` cannot be honored, rather than silently dropping them. */
|
|
251
398
|
function refuse(props) {
|
|
252
399
|
if (!props)
|
|
253
400
|
return;
|
|
254
401
|
const extra = props;
|
|
402
|
+
if ("discovery" in props)
|
|
403
|
+
throw new TypeError(DISCOVERY_REMOVED);
|
|
255
404
|
if (extra.transport) {
|
|
256
405
|
throw new Error("a supplied transport cannot reconnect; call Connection.connect() instead");
|
|
257
406
|
}
|
|
@@ -273,44 +422,58 @@ function refuse(props) {
|
|
|
273
422
|
if (props.websocket !== undefined) {
|
|
274
423
|
throw new Error("websocket options cannot be shared; pass share: false");
|
|
275
424
|
}
|
|
276
|
-
if (props.
|
|
277
|
-
throw new Error("
|
|
425
|
+
if (props.backoff !== undefined) {
|
|
426
|
+
throw new Error("backoff cannot be shared; pass share: false");
|
|
427
|
+
}
|
|
428
|
+
if (props.tokens !== undefined) {
|
|
429
|
+
throw new Error("tokens cannot be shared; pass share: false");
|
|
278
430
|
}
|
|
279
|
-
if (props.
|
|
280
|
-
throw new Error("
|
|
431
|
+
if (props.urlAuth) {
|
|
432
|
+
throw new Error("urlAuth cannot be shared; pass share: false");
|
|
433
|
+
}
|
|
434
|
+
if (props.timeout !== undefined) {
|
|
435
|
+
throw new Error("timeout cannot be shared; pass share: false");
|
|
281
436
|
}
|
|
282
437
|
if (props.goaway !== undefined) {
|
|
283
438
|
throw new Error("goaway cannot be shared; pass share: false");
|
|
284
439
|
}
|
|
440
|
+
if (props.cost !== undefined) {
|
|
441
|
+
throw new Error("cost cannot be shared; pass share: false");
|
|
442
|
+
}
|
|
285
443
|
}
|
|
286
444
|
/** Options tied to one handle cannot be represented by a URL-keyed shared entry. */
|
|
287
445
|
function requiresPrivate(props) {
|
|
288
446
|
return (props.webtransport !== undefined ||
|
|
289
447
|
props.websocket !== undefined ||
|
|
290
|
-
props.
|
|
291
|
-
props.
|
|
448
|
+
props.backoff !== undefined ||
|
|
449
|
+
props.tokens !== undefined ||
|
|
450
|
+
props.urlAuth === true ||
|
|
451
|
+
props.timeout !== undefined ||
|
|
292
452
|
props.goaway !== undefined ||
|
|
453
|
+
props.cost !== undefined ||
|
|
293
454
|
props.publish !== undefined ||
|
|
294
455
|
props.consume !== undefined);
|
|
295
456
|
}
|
|
296
457
|
/** The process-wide pool backing {@link Connection}. */
|
|
297
458
|
const pool = new Map();
|
|
298
|
-
|
|
299
|
-
function
|
|
459
|
+
// Preserve the ordered versions when a redirect moves the URL.
|
|
460
|
+
function poolKey(url, versions) {
|
|
461
|
+
return JSON.stringify([url, versions]);
|
|
462
|
+
}
|
|
463
|
+
/** Take a reference on the shared entry, creating it on first use. */
|
|
464
|
+
function acquire(url, versions) {
|
|
465
|
+
const key = poolKey(url, versions);
|
|
300
466
|
let entry = pool.get(key);
|
|
301
467
|
if (!entry) {
|
|
302
468
|
const origin = new Origin.Producer();
|
|
303
469
|
const connection = new Reload({
|
|
304
|
-
url: new URL(
|
|
470
|
+
url: new URL(url),
|
|
471
|
+
versions,
|
|
305
472
|
enabled: true,
|
|
306
473
|
publish: origin.consume(),
|
|
307
474
|
consume: origin,
|
|
308
|
-
// Nobody observes a shared loop's `closed`, so giving up would strand every handle
|
|
309
|
-
// on this URL offline until the page reloads. Retry for as long as the entry lives
|
|
310
|
-
// instead; an auth rejection still stops this URL, and evicts below.
|
|
311
|
-
delay: { timeout: Time.Milli(0) },
|
|
312
475
|
});
|
|
313
|
-
const created = { key, origin, connection, refs: 0
|
|
476
|
+
const created = { key, origin, connection, refs: 0 };
|
|
314
477
|
// The loop only stops on a peer saying these credentials will never work, or on a
|
|
315
478
|
// GOAWAY redirect it refused. Drop the entry so a later handle dials fresh rather
|
|
316
479
|
// than joining a loop that has stopped; handles already on it keep it until they
|
|
@@ -319,16 +482,19 @@ function acquire(key, linger) {
|
|
|
319
482
|
if (err !== undefined && pool.get(created.key) === created)
|
|
320
483
|
pool.delete(created.key);
|
|
321
484
|
});
|
|
322
|
-
//
|
|
323
|
-
// configured with that URL shares it
|
|
324
|
-
//
|
|
325
|
-
// the
|
|
485
|
+
// The entry follows the URL its loop dials: an accepted redirect moves it to the
|
|
486
|
+
// target, so a later handle configured with that URL shares it and one asking for
|
|
487
|
+
// the old URL dials fresh, and a dead target's dropped redirect moves it back to the
|
|
488
|
+
// configured URL. A live entry already at the new key wins: this one leaves the pool
|
|
489
|
+
// and serves only the handles it has until they release it.
|
|
490
|
+
const configured = key;
|
|
326
491
|
connection.redirect.subscribe((redirect) => {
|
|
327
|
-
|
|
492
|
+
const key = redirect ? poolKey(redirect.href, versions) : configured;
|
|
493
|
+
if (key === created.key)
|
|
328
494
|
return;
|
|
329
495
|
if (pool.get(created.key) === created)
|
|
330
496
|
pool.delete(created.key);
|
|
331
|
-
created.key =
|
|
497
|
+
created.key = key;
|
|
332
498
|
if (!pool.has(created.key))
|
|
333
499
|
pool.set(created.key, created);
|
|
334
500
|
});
|
|
@@ -336,10 +502,9 @@ function acquire(key, linger) {
|
|
|
336
502
|
pool.set(key, created);
|
|
337
503
|
}
|
|
338
504
|
const taken = entry;
|
|
339
|
-
taken.linger = Time.Milli(Math.max(taken.linger, linger ?? LINGER_MS));
|
|
340
505
|
taken.refs += 1;
|
|
341
506
|
if (taken.timer !== undefined) {
|
|
342
|
-
|
|
507
|
+
taken.timer();
|
|
343
508
|
taken.timer = undefined;
|
|
344
509
|
}
|
|
345
510
|
let released = false;
|
|
@@ -352,14 +517,13 @@ function acquire(key, linger) {
|
|
|
352
517
|
taken.refs -= 1;
|
|
353
518
|
if (taken.refs > 0)
|
|
354
519
|
return;
|
|
355
|
-
|
|
520
|
+
// Don't hold a Node process open for a connection nobody is using.
|
|
521
|
+
taken.timer = after(LINGER, () => {
|
|
356
522
|
if (pool.get(taken.key) === taken)
|
|
357
523
|
pool.delete(taken.key);
|
|
358
524
|
taken.connection.close();
|
|
359
525
|
taken.origin.close();
|
|
360
|
-
},
|
|
361
|
-
// Don't hold a Node process open for a connection nobody is using.
|
|
362
|
-
taken.timer.unref?.();
|
|
526
|
+
}, { ref: false });
|
|
363
527
|
},
|
|
364
528
|
};
|
|
365
529
|
}
|
|
@@ -374,8 +538,7 @@ export function resetShared() {
|
|
|
374
538
|
const entries = [...pool.values()];
|
|
375
539
|
pool.clear();
|
|
376
540
|
for (const entry of entries) {
|
|
377
|
-
|
|
378
|
-
clearTimeout(entry.timer);
|
|
541
|
+
entry.timer?.();
|
|
379
542
|
entry.connection.close();
|
|
380
543
|
entry.origin.close();
|
|
381
544
|
}
|